Code

More preg_replace replacements
[gosa.git] / gosa-core / include / class_acl.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class acl extends plugin
24 {
25   /* Definitions */
26   var $plHeadline= "Access control";
27   var $plDescription= "Manage access control lists";
29   /* attribute list for save action */
30   var $attributes= array('gosaAclEntry');
31   var $objectclasses= array('gosaAcl');
33   /* Helpers */
34   var $dialogState= "head";
35   var $gosaAclEntry= array();
36   var $aclType= "";
37   var $aclObject= "";
38   var $aclContents= array();
39   var $target= "group";
40   var $aclTypes= array();
41   var $aclObjects= array();
42   var $aclFilter= "";
43   var $aclMyObjects= array();
44   var $users= array();
45   var $roles= array();
46   var $groups= array();
47   var $recipients= array();
48   var $isContainer= FALSE;
49   var $currentIndex= 0;
50   var $wasNewEntry= FALSE;
51   var $ocMapping= array();
52   var $savedAclContents= array();
53   var $myAclObjects = array();
54   var $acl_category = "acl/";
56   function acl (&$config, $parent, $dn= NULL)
57   {
58     /* Include config object */
59     plugin::plugin($config, $dn);
61     /* Load ACL's */
62     $this->gosaAclEntry= array();
63     if (isset($this->attrs['gosaAclEntry'])){
64       for ($i= 0; $i<$this->attrs['gosaAclEntry']['count']; $i++){
65         $acl= $this->attrs['gosaAclEntry'][$i];
66         $this->gosaAclEntry= array_merge($this->gosaAclEntry, acl::explodeACL($acl));
67       }
68     }
69     ksort($this->gosaAclEntry);
71     /* Save parent - we've to know more about it than other plugins... */
72     $this->parent= &$parent;
74     /* Container? */
75     if (preg_match('/^(o|ou|c|l|dc)=/i', $dn)){
76       $this->isContainer= TRUE;
77     }
79     /* Users */
80     $ui= get_userinfo();
81     $tag= $ui->gosaUnitTag;
82     $ldap= $config->get_ldap_link();
83     $ldap->cd($config->current['BASE']);
84     if ($tag == ""){
85       $ldap->search('(objectClass=gosaAccount)', array('uid', 'cn'));
86     } else {
87       $ldap->search('(&(objectClass=gosaAccount)(gosaUnitTag='.$tag.'))', array('uid', 'cn'));
88     }
89     while ($attrs= $ldap->fetch()){
90       $this->users['U:'.$attrs['dn']]= $attrs['cn'][0].' ['.$attrs['uid'][0].']';
91     }
92     ksort($this->users);
94     /* Groups */
95     $ldap->cd($config->current['BASE']);
96 #    if ($tag == ""){
97       $ldap->search('(objectClass=posixGroup)', array('cn', 'description'));
98 #    } else {
99 #      $ldap->search('(&(objectClass=posixGroup)(gosaUnitTag='.$tag.'))', array('cn', 'description'));
100 #    }
101     while ($attrs= $ldap->fetch()){
102       $dsc= "";
103       if (isset($attrs['description'][0])){
104         $dsc= $attrs['description'][0];
105       }
106       $this->groups['G:'.$attrs['dn']]= $attrs['cn'][0].' ['.$dsc.']';
107     }
108     ksort($this->groups);
110     /* Roles */
111     $ldap->cd($config->current['BASE']);
112 #    if ($tag == ""){
113       $ldap->search('(objectClass=gosaRole)', array('cn', 'description','gosaAclTemplate','dn'));
114 #    } else {
115 #     $ldap->search('(&(objectClass=gosaRole)(gosaUnitTag='.$tag.'))', array('cn', 'description','gosaAclTemplate','dn'));
116 #    }
117     while ($attrs= $ldap->fetch()){
118       $dsc= "";
119       if (isset($attrs['description'][0])){
120         $dsc= $attrs['description'][0];
121       }
123       $role_id = $attrs['dn'];
125       $this->roles[$role_id]['acls'] =array();
126       for ($i= 0; $i < $attrs['gosaAclTemplate']['count']; $i++){
127         $acl= $attrs['gosaAclTemplate'][$i];
128         $this->roles[$role_id]['acls'] = array_merge($this->roles[$role_id]['acls'],acl::explodeACL($acl));
129       }
130       $this->roles[$role_id]['description'] = $dsc;
131       $this->roles[$role_id]['cn'] = $attrs['cn'][0];
132     }
134     /* Objects */
135     $tmp= session::get('plist');
136     $plist= $tmp->info;
137     $cats = array();
138     if (isset($this->parent) && $this->parent !== NULL){
139       $oc= array();
140       foreach ($this->parent->by_object as $key => $obj){
141         $oc= array_merge($oc, $obj->objectclasses);
142         if(isset($obj->acl_category)){
143                                         $tmp= str_replace("/","",$obj->acl_category);
144           $cats[$tmp] = $tmp;
145         }
146       }
147       if (in_array_ics('organizationalUnit', $oc)){
148         $this->isContainer= TRUE;
149       }
150     } else {
151       $oc=  $this->attrs['objectClass'];
152     }
154     /* Extract available categories from plugin info list */
155     foreach ($plist as $class => $acls){
157       /* Only feed categories */
158       if (isset($acls['plCategory'])){
160         /* Walk through supplied list and feed only translated categories */
161         foreach($acls['plCategory'] as $idx => $data){
163           /* Non numeric index means -> base object containing more informations */
164           if (preg_match('/^[0-9]+$/', $idx)){
166             if (!isset($this->ocMapping[$data])){
167               $this->ocMapping[$data]= array();
168               $this->ocMapping[$data][]= '0';
169             }
171             if(isset($cats[$data])){
172               $this->myAclObjects[$data.'/'.$class]= $acls['plDescription'];
173             }
174             $this->ocMapping[$data][]= $class;
175           } else {
176             if (!isset($this->ocMapping[$idx])){
177               $this->ocMapping[$idx]= array();
178               $this->ocMapping[$idx][]= '0';
179             }
180             $this->ocMapping[$idx][]= $class;
181             $this->aclObjects[$idx]= $data['description'];
183             /* Additionally filter the classes we're interested in in "self edit" mode */
184             if (is_array($data['objectClass'])){
185               foreach($data['objectClass'] as $objectClass){
186                 if (in_array_ics($objectClass, $oc)){
187                   $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
188                   break;
189                 }
190               }
191             } else {
192               if (in_array_ics($data['objectClass'], $oc)){
193                 $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
194               }
195             }
196           }
198         }
199       }
200     }
201     $this->aclObjects['all']= '*&nbsp;'._("All categories");
202     $this->ocMapping['all']= array('0' => 'all');
204     /* Sort categories */
205     asort($this->aclObjects);
207     /* Fill acl types */
208     if ($this->isContainer){
209       $this->aclTypes= array("reset" => _("Reset ACLs"),
210                              "one" => _("One level"),
211                              "base" => _("Current object"),
212                              "sub" => _("Complete subtree"),
213                              "psub" => _("Complete subtree (permanent)"),
214                              "role" => _("Use ACL defined in role"));
215     } else {
216       $this->aclTypes= array("base" => _("Current object"),
217           "role" => _("Use ACL defined in role"));
218     }
219     asort($this->aclTypes);
220     $this->targets= array("user" => _("Users"), "group" => _("Groups"));
221     asort($this->targets);
223     /* Finally - we want to get saved... */
224     $this->is_account= TRUE;
225   }
228   function execute()
229   {
230     /* Call parent execute */
231     plugin::execute();
233     $tmp= session::get('plist');
234     $plist= $tmp->info;
236     /* Handle posts */
237     if (isset($_POST['new_acl'])){
238       $this->dialogState= 'create';
239       $this->dialog= TRUE;
240       $this->currentIndex= count($this->gosaAclEntry);
241       $this->loadAclEntry(TRUE);
242     }
244     $new_acl= array();
245     $aclDialog= FALSE;
246     $firstedit= FALSE;
248     foreach($_POST as $name => $post){
250       /* Actions... */
251       if (preg_match('/^acl_edit_.*_x/', $name)){
252         $this->dialogState= 'create';
253         $firstedit= TRUE;
254         $this->dialog= TRUE;
255         $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
256         $this->loadAclEntry();
257         continue;
258       }
260       if (preg_match('/^cat_edit_.*_x/', $name)){
261         $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name);
262         $this->dialogState= 'edit';
263         foreach ($this->ocMapping[$this->aclObject] as $oc){
264           if (isset($this->aclContents[$oc])){
265             $this->savedAclContents[$oc]= $this->aclContents[$oc];
266           }
267         }
268         continue;
269       }
271       /* Only handle posts, if we allowed to modify ACLs */
272       if(!$this->acl_is_writeable("")){
273         continue;
274       }
276       if (preg_match('/^acl_del_.*_x/', $name)){
277         unset($this->gosaAclEntry[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]);
278         continue;
279       }
281       if (preg_match('/^cat_del_.*_x/', $name)){
282         $idx= preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name);
283         foreach ($this->ocMapping[$idx] as $key){
284           unset($this->aclContents["$idx/$key"]);
285         }
286         continue;
287       }
289       /* Sorting... */
290       if (preg_match('/^sortup_.*_x/', $name)){
291         $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name);
292         if ($index > 0){
293           $tmp= $this->gosaAclEntry[$index];
294           $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index-1];
295           $this->gosaAclEntry[$index-1]= $tmp;
296         }
297         continue;
298       }
299       if (preg_match('/^sortdown_.*_x/', $name)){
300         $index= preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name);
301         if ($index < count($this->gosaAclEntry)-1){
302           $tmp= $this->gosaAclEntry[$index];
303           $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index+1];
304           $this->gosaAclEntry[$index+1]= $tmp;
305         }
306         continue;
307       }
309       /* ACL saving... */
310       if (preg_match('/^acl_.*_[^xy]$/', $name)){
311         list($dummy, $object, $attribute, $value)= split('_', $name);
313         /* Skip for detection entry */
314         if ($object == 'dummy') {
315           continue;
316         }
318         /* Ordinary ACLs */
319         if (!isset($new_acl[$object])){
320           $new_acl[$object]= array();
321         }
322         if (isset($new_acl[$object][$attribute])){
323           $new_acl[$object][$attribute].= $value;
324         } else {
325           $new_acl[$object][$attribute]= $value;
326         }
327       }
329       if(isset($_POST['selected_role'])){
330         $this->aclContents = "";
331         $this->aclContents = base64_decode($_POST['selected_role']);
332       }
333     }
335     if(isset($_POST['acl_dummy_0_0_0'])){
336       $aclDialog= TRUE;
337     }
339     if($this->acl_is_writeable("")){
340       
341       /* Only be interested in new acl's, if we're in the right _POST place */
342       if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
344         foreach ($this->ocMapping[$this->aclObject] as $oc){
346           if(isset($this->aclContents[$oc]) && is_array($this->aclContents)){
347             unset($this->aclContents[$oc]);
348           }elseif(isset($this->aclContents[$this->aclObject.'/'.$oc]) && is_array($this->aclContents)){
349             unset($this->aclContents[$this->aclObject.'/'.$oc]);
350           }else{
351 #          trigger_error("Huhm?");
352           }
353           if (isset($new_acl[$oc]) && is_array($new_acl)){
354             $this->aclContents[$oc]= $new_acl[$oc];
355           }
356           if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)){
357             $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
358           }
359         }
360       }
362       /* Save new acl in case of base edit mode */
363       if ($this->aclType == 'base' && !$firstedit){
364         $this->aclContents= $new_acl;
365       }
366     }
368     /* Cancel new acl? */
369     if (isset($_POST['cancel_new_acl'])){
370       $this->dialogState= 'head';
371       $this->dialog= FALSE;
372       if ($this->wasNewEntry){
373         unset ($this->gosaAclEntry[$this->currentIndex]);
374       }
375     }
377     /* Save common values */
378     if($this->acl_is_writeable("")){
379       foreach (array("aclType","aclFilter", "aclObject", "target") as $key){
380         if (isset($_POST[$key])){
381           $this->$key= validate($_POST[$key]);
382         }
383       }
384     }
386     /* Store ACL in main object? */
387     if (isset($_POST['submit_new_acl'])){
388       $this->gosaAclEntry[$this->currentIndex]['type']= $this->aclType;
389       $this->gosaAclEntry[$this->currentIndex]['members']= $this->recipients;
390       $this->gosaAclEntry[$this->currentIndex]['acl']= $this->aclContents;
391       $this->gosaAclEntry[$this->currentIndex]['filter']= $this->aclFilter;
392       $this->dialogState= 'head';
393       $this->dialog= FALSE;
394     }
396     /* Cancel edit acl? */
397     if (isset($_POST['cancel_edit_acl'])){
398       $this->dialogState= 'create';
399       foreach ($this->ocMapping[$this->aclObject] as $oc){
400         if (isset($this->savedAclContents[$oc])){
401           $this->aclContents[$oc]= $this->savedAclContents[$oc];
402         }
403       }
404     }
406     /* Save edit acl? */
407     if (isset($_POST['submit_edit_acl'])){
408       $this->dialogState= 'create';
409     }
411     /* Add acl? */
412     if (isset($_POST['add_acl']) && $_POST['aclObject'] != ""){
413       $this->dialogState= 'edit';
414       $this->savedAclContents= array();
415       foreach ($this->ocMapping[$this->aclObject] as $oc){
416         if (isset($this->aclContents[$oc])){
417           $this->savedAclContents[$oc]= $this->aclContents[$oc];
418         }
419       }
420     }
422     /* Add to list? */
423     if (isset($_POST['add']) && isset($_POST['source'])){
424       foreach ($_POST['source'] as $key){
425         if ($this->target == 'user'){
426           $this->recipients[$key]= $this->users[$key];
427         }
428         if ($this->target == 'group'){
429           $this->recipients[$key]= $this->groups[$key];
430         }
431       }
432       ksort($this->recipients);
433     }
435     /* Remove from list? */
436     if (isset($_POST['del']) && isset($_POST['recipient'])){
437       foreach ($_POST['recipient'] as $key){
438           unset($this->recipients[$key]);
439       }
440     }
442     /* Create templating instance */
443     $smarty= get_smarty();
444     $smarty->assign("acl_readable",$this->acl_is_readable(""));
445     if(!$this->acl_is_readable("")){
446       return ($smarty->fetch (get_template_path('acl.tpl')));
447     }
449     if ($this->dialogState == 'head'){
450       /* Draw list */
451       $aclList= new divSelectBox("aclList");
452       $aclList->SetHeight(450);
453       
454       /* Fill in entries */
455       foreach ($this->gosaAclEntry as $key => $entry){
456         if(!$this->acl_is_readable("")) continue;
458         $action ="";      
459   
460         $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
461         $field2= array("string" => $this->assembleAclSummary($entry));
463         if($this->acl_is_writeable("")){
464           $action.= "<input type='image' name='sortup_$key' alt='up' 
465             title='"._("Up")."' src='images/lists/sort-up.png' align='top'>";
466           $action.= "<input type='image' name='sortdown_$key' alt='down' 
467             title='"._("Down")."' src='images/lists/sort-down.png'>";
468         } 
469     
470         if($this->acl_is_readable("")){
471           $action.= "<input class='center' type='image' src='images/lists/edit.png' 
472             alt='"._("Edit")."' name='acl_edit_$key' title='".msgPool::editButton(_("ACL"))."'>";
473         }
474         if($this->acl_is_removeable("")){
475           $action.= "<input class='center' type='image' src='images/lists/trash.png' 
476             alt='"._("Delete")."' name='acl_del_$key' title='".msgPool::delButton(_("ACL"))."'>";
477         }
479         $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
480         $aclList->AddEntry(array($field1, $field2, $field3));
481       }
483       $smarty->assign("aclList", $aclList->DrawList());
484     }
486     if ($this->dialogState == 'create'){
487       /* Draw list */
488       $aclList= new divSelectBox("aclList");
489       $aclList->SetHeight(150);
491       /* Add settings for all categories to the (permanent) list */
492       foreach ($this->aclObjects as $section => $dsc){
493         $summary= "";
494         foreach($this->ocMapping[$section] as $oc){
495           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
496               $this->aclContents[$oc][0] != ""){
498             $summary.= "$oc, ";
499             continue;
500           }
501           if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
502             $summary.= "$oc, ";
503             continue;
504           }
505           if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
506             $summary.= "$oc, ";
507           }
508         }
510         /* Set summary... */
511         if ($summary == ""){
512           $summary= '<i>'._("No ACL settings for this category!").'</i>';
513         } else {
514           $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary));
515         }
517         $actions ="";
518         if($this->acl_is_readable("")){
519           $actions= "<input class='center' type='image' src='images/lists/edit.png' 
520             alt='"._("Edit")."' name='cat_edit_$section' title='".msgPool::editButton(_("category ACL"))."'>";
521         }
522         if($this->acl_is_removeable()){
523           $actions.= "<input class='center' type='image' src='images/lists/trash.png' 
524             alt='"._("Delete")."' name='cat_del_$section' title='".msgPool::delButton(_("category ACL"))."'>";
525         }   
527         $field1= array("string" => $dsc, "attach" => "style='width:100px'");
528         $field2= array("string" => $summary);
529         $field3= array("string" => $actions, "attach" => "style='border-right:0px;width:50px'");
530         $aclList->AddEntry(array($field1, $field2, $field3));
531       }
533       $smarty->assign("aclList", $aclList->DrawList());
534       $smarty->assign("aclType", $this->aclType);
535       $smarty->assign("aclFilter", $this->aclFilter);
536       $smarty->assign("aclTypes", $this->aclTypes);
537       $smarty->assign("target", $this->target);
538       $smarty->assign("targets", $this->targets);
540       /* Assign possible target types */
541       $smarty->assign("targets", $this->targets);
542       foreach ($this->attributes as $attr){
543         $smarty->assign($attr, $this->$attr);
544       }
547       /* Generate list */
548       $tmp= array();
549       foreach (array("user" => "users", "group" => "groups") as $field => $arr){
550         if ($this->target == $field){
551           foreach ($this->$arr as $key => $value){
552             if (!isset($this->recipients[$key])){
553               $tmp[$key]= $value;
554             }
555           }
556         }
557       }
558       $smarty->assign('sources', $tmp);
559       $smarty->assign('recipients', $this->recipients);
561       /* Acl selector if scope is base */
562       if ($this->aclType == 'base'){
563         $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
564       }
566       /* Role selector if scope is base */
567       if ($this->aclType == 'role'){
568         $smarty->assign('roleSelector', "Role selector");#, $this->buildRoleSelector($this->myAclObjects));
569         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
570       }
571     }
573     if ($this->dialogState == 'edit'){
574       $smarty->assign('headline', sprintf(_("Edit ACL for '%s' - scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
576       /* Collect objects for selected category */
577       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
578         if ($idx == 0){
579           continue;
580         }
581         $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
582       }
583       if ($this->aclObject == 'all'){
584         $aclObjects['all']= _("All objects in current subtree");
585       }
587       /* Role selector if scope is base */
588       if ($this->aclType == 'role'){
589         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
590       } else {
591         $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
592       }
593     }
595     /* Show main page */
596     $smarty->assign("dialogState", $this->dialogState);
597    
598     /* Assign acls */ 
599     $smarty->assign("acl_createable",$this->acl_is_createable());
600     $smarty->assign("acl_writeable" ,$this->acl_is_writeable(""));
601     $smarty->assign("acl_readable"  ,$this->acl_is_readable(""));
602     $smarty->assign("acl_removeable",$this->acl_is_removeable());
604     return ($smarty->fetch (get_template_path('acl.tpl')));
605   }
608   function sort_by_priority($list)
609   {
610     $tmp= session::get('plist');
611     $plist= $tmp->info;
612     asort($plist);
613     $newSort = array();
615     foreach($list as $name => $translation){
616       $na  =  preg_replace("/^.*\//","",$name);
617       $prio = 0;
618       if(isset($plist[$na]['plPriority'])){
619         $prio=  $plist[$na]['plPriority'] ;
620       }
622       $newSort[$name] = $prio;
623     }
625     asort($newSort);
627     $ret = array();
628     foreach($newSort as $name => $prio){
629       $ret[$name] = $list[$name];
630     }
631     return($ret);
632   }
635   function buildRoleSelector($list)
636   {
637     $D_List =new divSelectBox("Acl_Roles");
638  
639     $selected = $this->aclContents;
640     if(!is_string($this->aclContents) || !isset($list[$this->aclContents])){
641       $selected = key($list);
642     }
644     $str ="";
645     foreach($list as $dn => $values){
647       if($dn == $selected){    
648         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."' checked>";
649       }else{
650         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."'>";
651       }
652  
653       $field1 = array("string" => $option) ;
654       $field2 = array("string" => $values['cn'], "attach" => "style='width:200px;'") ;
655       $field3 = array("string" => $values['description'],"attach" => "style='border-right:0px;'") ;
657       $D_List->AddEntry(array($field1,$field2,$field3));
658     }
659     return($D_List->DrawList());
660   } 
663   function buildAclSelector($list)
664   {
665     $display= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
666     $cols= 3;
667     $tmp= session::get('plist');
668     $plist= $tmp->info;
669     asort($plist);
671     /* Add select all/none buttons */
672     $style = "style='width:100px;'";
674     if($this->acl_is_writeable("")){
675       $display .= "<input ".$style." type='button' name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" value='Toggle C'>";
676       $display .= "<input ".$style." type='button' name='toggle_all_move'   onClick=\"acl_toggle_all('_0_m$');\" value='Toggle M'>";
677       $display .= "<input ".$style." type='button' name='toggle_all_remove' onClick=\"acl_toggle_all('_0_d$');\" value='Toggle D'> - ";
678       $display .= "<input ".$style." type='button' name='toggle_all_read'   onClick=\"acl_toggle_all('_0_r$');\" value='Toggle R'>";
679       $display .= "<input ".$style." type='button' name='toggle_all_write'  onClick=\"acl_toggle_all('_0_w$');\" value='Toggle W'> - ";
681       $display .= "<input ".$style." type='button' name='toggle_all_sub_read'  onClick=\"acl_toggle_all('[^0]_r$');\" value='R+'>";
682       $display .= "<input ".$style." type='button' name='toggle_all_sub_write'  onClick=\"acl_toggle_all('[^0]_w$');\" value='W+'>";
684       $display .= "<br>";
686       $style = "style='width:50px;'";
687       $display .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
688       $display .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
689       $display .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
690       $display .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
691       $display .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
692       $display .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
693       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
694       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
695       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
696       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
698       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('[^0]_r$',true);\" value='R+'>";
699       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('[^0]_r$',false);\" value='R-'>";
700       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('[^0]_w$',true);\" value='W+'>";
701       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('[^0]_w$',false);\" value='W-'>";
702     }
704     /* Build general objects */
705     $list =$this->sort_by_priority($list);
706     foreach ($list as $key => $name){
708       /* Create sub acl if it does not exist */
709       if (!isset($this->aclContents[$key])){
710         $this->aclContents[$key]= array();
711         $this->aclContents[$key][0]= '';
712       }
713       $currentAcl= $this->aclContents[$key];
715       /* Get the overall plugin acls 
716        */
717       $overall_acl ="";
718       if(isset($currentAcl[0])){
719         $overall_acl = $currentAcl[0];
720       }
722       /* Object header */
723                         $tname= preg_replace("/[^a-z0-9]/i","_",$name);
724       if(session::get('js')) {
725         if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
726           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
727                      "\n  <tr>".
728                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
729                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
730                      "\n    <input type='button' onclick='divtoggle(\"$tname\");' value='"._("Show/hide advanced settings")."' /></td>".
731                      "\n  </tr>";
732         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
733           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
734                      "\n  <tr>".
735                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
736                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
737                      "\n    <input type='button' onclick='divtoggle(\"$tname\");' value='"._("Show/hide advanced settings")."' /></td>".
738                      "\n  </tr>";
739         } else {
740           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
741                      "\n  <tr>".
742                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
743                      "\n  </tr>";
744         }
745       } else {
746           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
747                      "\n  <tr>".
748                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
749                      "\n  </tr>";
750       }
752       /* Generate options */
753       $spc= "&nbsp;&nbsp;";
754 #      if ($this->isContainer && $this->aclType != 'base'){
755         $options= $this->mkchkbx($key."_0_c",  _("Create objects"), preg_match('/c/', $overall_acl)).$spc;
756         $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $overall_acl)).$spc;
757         $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $overall_acl)).$spc;
758         if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
759           $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$spc;
760         }
761  #     } else {
762  #       $options= $this->mkchkbx($key."_0_m", _("Move object"), preg_match('/m/', $overall_acl)).$spc;
763  #       $options.= $this->mkchkbx($key."_0_d", _("Remove object"), preg_match('/d/', $overall_acl)).$spc;
764  #       if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
765  #         $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$spc;
766  #       }
767  #     }
769       /* Global options */
770       $more_options= $this->mkchkbx($key."_0_r",  _("read"), preg_match('/r/', $overall_acl)).$spc;
771       $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl));
773       $display.= "\n  <tr>".
774                  "\n    <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
775                  "\n    <td style='background-color:#D4D4D4'>&nbsp;"._("Complete object").": $more_options</td>".
776                  "\n  </tr>";
778       /* Walk through the list of attributes */
779       $cnt= 1;
780       $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls'];
781 #      asort($splist);
782       if(session::get('js')) {
783         if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
784           $display.= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
785                      "\n    <td colspan=".$cols.">".
786                      "\n      <div id='$tname' style='overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
787                      "\n        <table style='width:100%;'>";
788         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
789           $display.= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
790                      "\n    <td colspan=".$cols.">".
791                      "\n      <div id='$tname' style='position:absolute;overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
792                      "\n        <table style='width:100%;'>";
793         }
794       }
795       foreach($splist as $attr => $dsc){
797         /* Skip pl* attributes, they are internal... */
798         if (preg_match('/^pl[A-Z]+.*$/', $attr)){
799           continue;
800         }
802         /* Open table row */
803         if ($cnt == 1){
804           $display.= "\n  <tr>";
805         }
807         /* Close table row */
808         if ($cnt == $cols){
809           $cnt= 1;
810           $rb= "";
811           $end= "\n  </tr>";
812         } else {
813           $cnt++;
814           $rb= "border-right:1px solid #A0A0A0;";
815           $end= "";
816         }
818         /* Collect list of attributes */
819         $state= "";
820         if (isset($currentAcl[$attr])){
821           $state= $currentAcl[$attr];
822         }
823         $display.= "\n    <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100/$cols)."%'>".
824                    "\n      <b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."</td>$end";
825       }
826       
827       /* Fill missing td's if needed */
828       if (--$cnt != $cols && $cnt != 0){
829        $display.= str_repeat("\n    <td style='border-top:1px solid #A0A0A0; width:".(int)(100/$cols)."%'>&nbsp;</td>", $cols-$cnt); 
830       }
832       if(session::get('js')) {
833         if(isset($_SERVER['HTTP_USER_AGENT']) && (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT']))) {
834           $display.= "\n        </table>".
835                      "\n      </div>".
836                      "\n    </td>".
837                      "\n  </tr>";
838         }
839       }
841       $display.= "\n</table><br />\n";
842     }
844     return ($display);
845   }
848   function mkchkbx($name, $text, $state= FALSE)
849   {
850     $state= $state?"checked":"";
851     if($this->acl_is_writeable("")){
852                         $tname= preg_replace("/[^a-z0-9]/i","_",$name);
853       return "\n      <input id='acl_$tname' type=checkbox name='acl_$name' $state>".
854         "\n      <label for='acl_$tname'>$text</label>";
855     }else{
856       return "\n <input type='checkbox' disabled name='dummy_".microtime(1)."' $state>$text";
857     }
858   }
861   function mkrwbx($name, $state= "")
862   {
863     $rstate= preg_match('/r/', $state)?'checked':'';
864     $wstate= preg_match('/w/', $state)?'checked':'';
865                 $tname= preg_replace("/[^a-z0-9]/i","_",$name);
866       
867     if($this->acl_is_writeable("")){
868       return ("\n      <input id='acl_".$tname."_r' type=checkbox name='acl_${name}_r' $rstate>".
869           "\n      <label for='acl_".$tname."_r'>"._("read")."</label>".
870           "\n      <input id='acl_".$tname."_w' type=checkbox name='acl_${name}_w' $wstate>".
871           "\n      <label for='acl_".$tname."_w'>"._("write")."</label>");
872     }else{
873       return ("\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read").
874           "\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write"));
875     }
876   }
879   static function explodeACL($acl)
880   {
882     $list= split(':', $acl);
883     if(count($list) == 5){
884       list($index, $type,$member,$permission,$filter)= $list;
885       $filter = base64_decode($filter);
886     }else{
887       $filter = "";
888       list($index, $type,$member,$permission)= $list;
889     }
891     $a= array( $index => array("type" => $type,
892                                "filter"=> $filter,
893                                "members" => acl::extractMembers($acl,$type == "role")));
894    
895     /* Handle different types */
896     switch ($type){
898       case 'psub':
899       case 'sub':
900       case 'one':
901       case 'base':
902         $a[$index]['acl']= acl::extractACL($acl);
903         break;
904       
905       case 'role':
906         $a[$index]['acl']= base64_decode(preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl));
907         break;
909       case 'reset':
910         break;
911       
912       default:
913         msg_dialog::display(_("Internal error"), sprintf(_("Unkown ACL type '%s'!"), $type), ERROR_DIALOG);
914         $a= array();
915     }
916     return ($a);
917   }
920   static function extractMembers($acl,$role = FALSE)
921   {
922     global $config;
923     $a= array();
925     /* Rip acl off the string, seperate by ',' and place it in an array */
926     if($role){
927       $ms= preg_replace('/^[^:]+:[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
928     }else{
929       $ms= preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
930     }
931     if ($ms == $acl){
932       return $a;
933     }
934     $ma= split(',', $ms);
936     /* Decode dn's, fill with informations from LDAP */
937     $ldap= $config->get_ldap_link();
938     foreach ($ma as $memberdn){
939       $dn= base64_decode($memberdn);
940       $ldap->cat($dn, array('cn', 'objectClass', 'description', 'uid'));
942       /* Found entry... */
943       if ($ldap->count()){
944         $attrs= $ldap->fetch();
945         if (in_array_ics('gosaAccount', $attrs['objectClass'])){
946           $a['U:'.$dn]= $attrs['cn'][0]." [".$attrs['uid'][0]."]";
947         } else {
948           $a['G:'.$dn]= $attrs['cn'][0];
949           if (isset($attrs['description'][0])){
950             $a['G:'.$dn].= " [".$attrs['description'][0]."]";
951           }
952         }
954       /* ... or not */
955       } else {
956         $a['U:'.$dn]= sprintf(_("Unknown entry '%s'!"), $dn);
957       }
958     }
960     return ($a);
961   }
964   static function extractACL($acl)
965   {
966     /* Rip acl off the string, seperate by ',' and place it in an array */
967     $as= preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
968     $aa= split(',', $as);
969     $a= array();
971     /* Dis-assemble single ACLs */
972     foreach($aa as $sacl){
973       
974       /* Dis-assemble field ACLs */
975       $ao= split('#', $sacl);
976       $gobject= "";
977       foreach($ao as $idx => $ssacl){
979         /* First is department with global acl */
980         $object= preg_replace('/^([^;]+);.*$/', '\1', $ssacl);
981         $gacl=   preg_replace('/^[^;]+;(.*)$/', '\1', $ssacl);
982         if ($idx == 0){
983           /* Create hash for this object */
984           $gobject= $object;
985           $a[$gobject]= array();
987           /* Append ACL if set */
988           if ($gacl != ""){
989             $a[$gobject]= array($gacl);
990           }
991         } else {
993           /* All other entries get appended... */
994           list($field, $facl)= split(';', $ssacl);
995           $a[$gobject][$field]= $facl;
996         }
998       }
999     }
1001     return ($a);
1002   }
1004   
1005   function assembleAclSummary($entry)
1006   {
1007     $summary= "";
1009     /* Summarize ACL */
1010     if (isset($entry['acl'])){
1011       $acl= "";
1013       if($entry['type'] == "role"){
1015         if(isset($this->roles[$entry['acl']])){  
1016           $summary.= sprintf(_("Role: %s"), $this->roles[$entry['acl']]['cn']);
1017         }else{
1018           $summary.= sprintf(_("Role: %s"), "<i>"._("unknown role")."</i>");
1019         }
1020       }else{
1021         foreach ($entry['acl'] as $name => $object){
1022           if (count($object)){
1023             $acl.= "$name, ";
1024           }
1025         }
1026         $summary.= sprintf(_("Contains settings for these objects: %s"), preg_replace('/, $/', '', $acl));
1027       }
1028     }
1030     /* Summarize members */
1031     if ($summary != ""){
1032       $summary.= ", ";
1033     }
1034     if (count($entry['members'])){
1035       $summary.= _("Members").": ";
1036       foreach ($entry['members'] as $cn){
1037         $cn= preg_replace('/ \[.*$/', '', $cn);
1038         $summary.= $cn.", ";
1039       }
1040     } else {
1041       $summary.= _("ACL takes effect for all users");
1042     }
1044     return (preg_replace('/, $/', '', $summary));
1045   }
1048   function loadAclEntry($new= FALSE)
1049   {
1050     /* New entry gets presets... */
1051     if ($new){
1052       $this->aclType= 'base';
1053       $this->aclFilter= "";
1054       $this->recipients= array();
1055       $this->aclContents= array();
1056     } else {
1057       $acl= $this->gosaAclEntry[$this->currentIndex];
1058       $this->aclType= $acl['type'];
1059       $this->recipients= $acl['members'];
1060       $this->aclContents= $acl['acl'];
1061       $this->aclFilter= $acl['filter'];
1062     }
1064     $this->wasNewEntry= $new;
1065   }
1068   function aclPostHandler()
1069   {
1070     if (isset($_POST['save_acl'])){
1071       $this->save();
1072       return TRUE;
1073     }
1075     return FALSE;
1076   }
1078   
1079   function PrepareForCopyPaste($source)
1080   {
1081     plugin::PrepareForCopyPaste($source);
1082     
1083     $dn = $source['dn'];
1084     $acl_c = new acl($this->config, $this->parent,$dn);
1085     $this->gosaAclEntry = $acl_c->gosaAclEntry;
1086   }
1089   function save()
1090   {
1091     /* Assemble ACL's */
1092     $tmp_acl= array();
1093   
1094     foreach ($this->gosaAclEntry as $prio => $entry){
1095       $final= "";
1096       $members= "";
1097       if (isset($entry['members'])){
1098         foreach ($entry['members'] as $key => $dummy){
1099           $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
1100         }
1101       }
1103       if($entry['type'] != "role"){
1104         $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
1105       }else{
1106         $final= $prio.":".$entry['type'].":".base64_encode($entry['acl']).":".preg_replace('/,$/', '', $members);
1107       }
1109       /* ACL's if needed */
1110       if ($entry['type'] != "reset" && $entry['type'] != "role"){
1111         $acl= ":";
1112         if (isset($entry['acl'])){
1113           foreach ($entry['acl'] as $object => $contents){
1115             /* Only save, if we've some contents in there... */
1116             if (count($contents)){
1117               $acl.= $object.";";
1119               foreach($contents as $attr => $permission){
1121                 /* First entry? Its the one for global settings... */
1122                 if ($attr == '0'){
1123                   $acl.= $permission;
1124                 } else {
1125                   $acl.= '#'.$attr.';'.$permission;
1126                 }
1128               }
1129               $acl.= ',';
1130             }
1131             
1132           }
1133         }
1134         $final.= preg_replace('/,$/', '', $acl);
1135       }
1137       /* Append additional filter options 
1138        */
1139       if(!empty($entry['filter'])){
1140         $final .= ":".base64_encode($entry['filter']);
1141       }
1143       $tmp_acl[]= $final;
1144     } 
1146     /* Call main method */
1147     plugin::save();
1149     /* Finally (re-)assign it... */
1150     $this->attrs['gosaAclEntry']= $tmp_acl;
1152     /* Remove acl from this entry if it is empty... */
1153     if (!count($tmp_acl)){
1154       /* Remove attribute */
1155       if ($this->initially_was_account){
1156         $this->attrs['gosaAclEntry']= array();
1157       } else {
1158         if (isset($this->attrs['gosaAclEntry'])){
1159           unset($this->attrs['gosaAclEntry']);
1160         }
1161       }
1163       /* Remove object class */
1164       $this->attrs['objectClass']= array_remove_entries(array('gosaAcl'), $this->attrs['objectClass']);
1165     }    
1167     /* Do LDAP modifications */
1168     $ldap= $this->config->get_ldap_link();
1169     $ldap->cd($this->dn);
1170     $this->cleanup();
1171     $ldap->modify ($this->attrs);
1173     if(count($this->attrs)){
1174       new log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1175     }
1177     if (!$ldap->success()){
1178       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
1179     }
1181     /* Refresh users ACLs */
1182     $ui= get_userinfo();
1183     $ui->loadACL();
1184     session::set('ui',$ui);
1185   }
1188   function remove_from_parent()
1189   {
1190     plugin::remove_from_parent();
1192     /* include global link_info */
1193     $ldap= $this->config->get_ldap_link();
1195     $ldap->cd($this->dn);
1196     $this->cleanup();
1197     $ldap->modify ($this->attrs);
1199     new log("remove","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1201     /* Optionally execute a command after we're done */
1202     $this->handle_post_events("remove",array("uid" => $this->uid));
1203   }
1205   
1206   /* Return plugin informations for acl handling */
1207   static function plInfo()
1208   {
1209     return (array(
1210           "plShortName"   => _("ACL"),
1211           "plDescription" => _("ACL")."&nbsp;("._("Access control list").")",
1212           "plSelfModify"  => FALSE,
1213           "plDepends"     => array(),
1214           "plPriority"    => 0,
1215           "plSection"     => array("administration"),
1216           "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
1217                                                           "objectClass"  => array("gosaAcl","gosaRole"))),
1218           "plProvidedAcls"=> array(
1219 //            "cn"          => _("Role name"),
1220 //            "description" => _("Role description")
1221             )
1223           ));
1224   }
1227   /* Remove acls defined for $src */
1228   function remove_acl()
1229   {
1230     $this->remove_acl_for_dn($this->dn);
1231   }
1234   /* Remove acls defined for $src */
1235   function remove_acl_for_dn($src = "")
1236   {
1237     if($src == ""){
1238       $src = $this->dn;
1239     }
1240     $ldap = $this->config->get_ldap_link();
1241     $ldap->cd($this->config->current['BASE']);
1242     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1243     while($attrs = $ldap->fetch()){
1244       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1245       foreach($acl->gosaAclEntry as $id => $entry){
1246         foreach($entry['members'] as $m_id => $member){
1247           if($m_id == "U:".$src){
1248             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1249             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Removed acl for user %s on object %s.",$src,$attrs['dn']));
1250           }
1251           if($m_id == "G:".$src){
1252             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1253             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Removed acl for group %s on object %s.",$src,$attrs['dn']));
1254           }
1255         }
1256       }
1257       $acl -> save();
1258     }
1259   }
1261   function update_acl_membership($src,$dst)
1262   {
1263     $ldap = $this->config->get_ldap_link();
1264     $ldap->cd($this->config->current['BASE']);
1265     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1266     while($attrs = $ldap->fetch()){
1267       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1268       foreach($acl->gosaAclEntry as $id => $entry){
1269         foreach($entry['members'] as $m_id => $member){
1270           if($m_id == "U:".$src){
1271             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1272             $new = "U:".$dst;
1273             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1274             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Updated acl for user %s on object %s.",$src,$attrs['dn']));
1275           }
1276           if($m_id == "G:".$src){
1277             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1278             $new = "G:".$dst;
1279             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1280             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Updated acl for group %s on object %s.",$src,$attrs['dn']));
1281           }
1282         }
1283       }
1284       $acl -> save();
1285     }
1286   }
1290 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1291 ?>