Code

Reverted last acl change
[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           $cats[preg_replace("/\//","",$obj->acl_category)] = preg_replace("/\//","",$obj->acl_category);
144         }
145       }
146       if (in_array_ics('organizationalUnit', $oc)){
147         $this->isContainer= TRUE;
148       }
149     } else {
150       $oc=  $this->attrs['objectClass'];
151     }
153     /* Extract available categories from plugin info list */
154     foreach ($plist as $class => $acls){
156       /* Only feed categories */
157       if (isset($acls['plCategory'])){
159         /* Walk through supplied list and feed only translated categories */
160         foreach($acls['plCategory'] as $idx => $data){
162           /* Non numeric index means -> base object containing more informations */
163           if (preg_match('/^[0-9]+$/', $idx)){
165             if (!isset($this->ocMapping[$data])){
166               $this->ocMapping[$data]= array();
167               $this->ocMapping[$data][]= '0';
168             }
170             if(isset($cats[$data])){
171               $this->myAclObjects[$data.'/'.$class]= $acls['plDescription'];
172             }
173             $this->ocMapping[$data][]= $class;
174           } else {
175             if (!isset($this->ocMapping[$idx])){
176               $this->ocMapping[$idx]= array();
177               $this->ocMapping[$idx][]= '0';
178             }
179             $this->ocMapping[$idx][]= $class;
180             $this->aclObjects[$idx]= $data['description'];
182             /* Additionally filter the classes we're interested in in "self edit" mode */
183             if (is_array($data['objectClass'])){
184               foreach($data['objectClass'] as $objectClass){
185                 if (in_array_ics($objectClass, $oc)){
186                   $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
187                   break;
188                 }
189               }
190             } else {
191               if (in_array_ics($data['objectClass'], $oc)){
192                 $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
193               }
194             }
195           }
197         }
198       }
199     }
200     $this->aclObjects['all']= '*&nbsp;'._("All categories");
201     $this->ocMapping['all']= array('0' => 'all');
203     /* Sort categories */
204     asort($this->aclObjects);
206     /* Fill acl types */
207     if ($this->isContainer){
208       $this->aclTypes= array("reset" => _("Reset ACLs"),
209                              "one" => _("One level"),
210                              "base" => _("Current object"),
211                              "sub" => _("Complete subtree"),
212                              "psub" => _("Complete subtree (permanent)"),
213                              "role" => _("Use ACL defined in role"));
214     } else {
215       $this->aclTypes= array("base" => _("Current object"),
216           "role" => _("Use ACL defined in role"));
217     }
218     asort($this->aclTypes);
219     $this->targets= array("user" => _("Users"), "group" => _("Groups"));
220     asort($this->targets);
222     /* Finally - we want to get saved... */
223     $this->is_account= TRUE;
224   }
227   function execute()
228   {
229     /* Call parent execute */
230     plugin::execute();
232     $tmp= session::get('plist');
233     $plist= $tmp->info;
235     /* Handle posts */
236     if (isset($_POST['new_acl'])){
237       $this->dialogState= 'create';
238       $this->dialog= TRUE;
239       $this->currentIndex= count($this->gosaAclEntry);
240       $this->loadAclEntry(TRUE);
241     }
243     $new_acl= array();
244     $aclDialog= FALSE;
245     $firstedit= FALSE;
247     foreach($_POST as $name => $post){
249       /* Actions... */
250       if (preg_match('/^acl_edit_.*_x/', $name)){
251         $this->dialogState= 'create';
252         $firstedit= TRUE;
253         $this->dialog= TRUE;
254         $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
255         $this->loadAclEntry();
256         continue;
257       }
259       if (preg_match('/^cat_edit_.*_x/', $name)){
260         $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name);
261         $this->dialogState= 'edit';
262         foreach ($this->ocMapping[$this->aclObject] as $oc){
263           if (isset($this->aclContents[$oc])){
264             $this->savedAclContents[$oc]= $this->aclContents[$oc];
265           }
266         }
267         continue;
268       }
270       /* Only handle posts, if we allowed to modify ACLs 
271        */
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         $aclDialog= TRUE;
312         list($dummy, $object, $attribute, $value)= split('_', $name);
314         /* Skip for detection entry */
315         if ($object == 'dummy') {
316           continue;
317         }
319         /* Ordinary ACLs */
320         if (!isset($new_acl[$object])){
321           $new_acl[$object]= array();
322         }
323         if (isset($new_acl[$object][$attribute])){
324           $new_acl[$object][$attribute].= $value;
325         } else {
326           $new_acl[$object][$attribute]= $value;
327         }
328       }
330       if(isset($_POST['selected_role'])){
331         $this->aclContents = "";
332         $this->aclContents = base64_decode($_POST['selected_role']);
333       }
334     }
336     if($this->acl_is_writeable("")){
337       
338       /* Only be interested in new acl's, if we're in the right _POST place */
339       if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
341         foreach ($this->ocMapping[$this->aclObject] as $oc){
343           if(isset($this->aclContents[$oc]) && is_array($this->aclContents)){
344             unset($this->aclContents[$oc]);
345             unset($this->aclContents[$this->aclObject.'/'.$oc]);
346           }else{
347 #          trigger_error("Huhm?");
348           }
349           if (isset($new_acl[$oc]) && is_array($new_acl)){
350             $this->aclContents[$oc]= $new_acl[$oc];
351           }
352           if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)){
353             $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
354           }
355         }
356       }
358       /* Save new acl in case of base edit mode */
359       if ($this->aclType == 'base' && !$firstedit){
360         $this->aclContents= $new_acl;
361       }
362     }
364     /* Cancel new acl? */
365     if (isset($_POST['cancel_new_acl'])){
366       $this->dialogState= 'head';
367       $this->dialog= FALSE;
368       if ($this->wasNewEntry){
369         unset ($this->gosaAclEntry[$this->currentIndex]);
370       }
371     }
373     /* Save common values */
374     if($this->acl_is_writeable("")){
375       foreach (array("aclType","aclFilter", "aclObject", "target") as $key){
376         if (isset($_POST[$key])){
377           $this->$key= validate($_POST[$key]);
378         }
379       }
380     }
382     /* Store ACL in main object? */
383     if (isset($_POST['submit_new_acl'])){
384       $this->gosaAclEntry[$this->currentIndex]['type']= $this->aclType;
385       $this->gosaAclEntry[$this->currentIndex]['members']= $this->recipients;
386       $this->gosaAclEntry[$this->currentIndex]['acl']= $this->aclContents;
387       $this->gosaAclEntry[$this->currentIndex]['filter']= $this->aclFilter;
388       $this->dialogState= 'head';
389       $this->dialog= FALSE;
390     }
392     /* Cancel edit acl? */
393     if (isset($_POST['cancel_edit_acl'])){
394       $this->dialogState= 'create';
395       foreach ($this->ocMapping[$this->aclObject] as $oc){
396         if (isset($this->savedAclContents[$oc])){
397           $this->aclContents[$oc]= $this->savedAclContents[$oc];
398         }
399       }
400     }
402     /* Save edit acl? */
403     if (isset($_POST['submit_edit_acl'])){
404       $this->dialogState= 'create';
405     }
407     /* Add acl? */
408     if (isset($_POST['add_acl']) && $_POST['aclObject'] != ""){
409       $this->dialogState= 'edit';
410       $this->savedAclContents= array();
411       foreach ($this->ocMapping[$this->aclObject] as $oc){
412         if (isset($this->aclContents[$oc])){
413           $this->savedAclContents[$oc]= $this->aclContents[$oc];
414         }
415       }
416     }
418     /* Add to list? */
419     if (isset($_POST['add']) && isset($_POST['source'])){
420       foreach ($_POST['source'] as $key){
421         if ($this->target == 'user'){
422           $this->recipients[$key]= $this->users[$key];
423         }
424         if ($this->target == 'group'){
425           $this->recipients[$key]= $this->groups[$key];
426         }
427       }
428       ksort($this->recipients);
429     }
431     /* Remove from list? */
432     if (isset($_POST['del']) && isset($_POST['recipient'])){
433       foreach ($_POST['recipient'] as $key){
434           unset($this->recipients[$key]);
435       }
436     }
438     /* Create templating instance */
439     $smarty= get_smarty();
440     $smarty->assign("acl_readable",$this->acl_is_readable(""));
441     if(!$this->acl_is_readable("")){
442       return ($smarty->fetch (get_template_path('acl.tpl')));
443     }
445     if ($this->dialogState == 'head'){
446       /* Draw list */
447       $aclList= new divSelectBox("aclList");
448       $aclList->SetHeight(450);
449       
450       /* Fill in entries */
451       foreach ($this->gosaAclEntry as $key => $entry){
452         if(!$this->acl_is_readable("")) continue;
454         $action ="";      
455   
456         $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
457         $field2= array("string" => $this->assembleAclSummary($entry));
459         if($this->acl_is_writeable("")){
460           $action.= "<input type='image' name='sortup_$key' alt='up' 
461             title='"._("Up")."' src='images/lists/sort-up.png' align='top'>";
462           $action.= "<input type='image' name='sortdown_$key' alt='down' 
463             title='"._("Down")."' src='images/lists/sort-down.png'>";
464         } 
465     
466         if($this->acl_is_readable("")){
467           $action.= "<input class='center' type='image' src='images/lists/edit.png' 
468             alt='"._("Edit")."' name='acl_edit_$key' title='".msgPool::editButton(_("ACL"))."'>";
469         }
470         if($this->acl_is_removeable("")){
471           $action.= "<input class='center' type='image' src='images/lists/trash.png' 
472             alt='"._("Delete")."' name='acl_del_$key' title='".msgPool::delButton(_("ACL"))."'>";
473         }
475         $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
476         $aclList->AddEntry(array($field1, $field2, $field3));
477       }
479       $smarty->assign("aclList", $aclList->DrawList());
480     }
482     if ($this->dialogState == 'create'){
483       /* Draw list */
484       $aclList= new divSelectBox("aclList");
485       $aclList->SetHeight(150);
487       /* Add settings for all categories to the (permanent) list */
488       foreach ($this->aclObjects as $section => $dsc){
489         $summary= "";
490         foreach($this->ocMapping[$section] as $oc){
491           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
492               $this->aclContents[$oc][0] != ""){
494             $summary.= "$oc, ";
495             continue;
496           }
497           if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
498             $summary.= "$oc, ";
499             continue;
500           }
501           if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
502             $summary.= "$oc, ";
503           }
504         }
506         /* Set summary... */
507         if ($summary == ""){
508           $summary= '<i>'._("No ACL settings for this category!").'</i>';
509         } else {
510           $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary));
511         }
513         $actions ="";
514         if($this->acl_is_readable("")){
515           $actions= "<input class='center' type='image' src='images/lists/edit.png' 
516             alt='"._("Edit")."' name='cat_edit_$section' title='".msgPool::editButton(_("category ACL"))."'>";
517         }
518         if($this->acl_is_removeable()){
519           $actions.= "<input class='center' type='image' src='images/lists/trash.png' 
520             alt='"._("Delete")."' name='cat_del_$section' title='".msgPool::delButton(_("category ACL"))."'>";
521         }   
523         $field1= array("string" => $dsc, "attach" => "style='width:100px'");
524         $field2= array("string" => $summary);
525         $field3= array("string" => $actions, "attach" => "style='border-right:0px;width:50px'");
526         $aclList->AddEntry(array($field1, $field2, $field3));
527       }
529       $smarty->assign("aclList", $aclList->DrawList());
530       $smarty->assign("aclType", $this->aclType);
531       $smarty->assign("aclFilter", $this->aclFilter);
532       $smarty->assign("aclTypes", $this->aclTypes);
533       $smarty->assign("target", $this->target);
534       $smarty->assign("targets", $this->targets);
536       /* Assign possible target types */
537       $smarty->assign("targets", $this->targets);
538       foreach ($this->attributes as $attr){
539         $smarty->assign($attr, $this->$attr);
540       }
543       /* Generate list */
544       $tmp= array();
545       foreach (array("user" => "users", "group" => "groups") as $field => $arr){
546         if ($this->target == $field){
547           foreach ($this->$arr as $key => $value){
548             if (!isset($this->recipients[$key])){
549               $tmp[$key]= $value;
550             }
551           }
552         }
553       }
554       $smarty->assign('sources', $tmp);
555       $smarty->assign('recipients', $this->recipients);
557       /* Acl selector if scope is base */
558       if ($this->aclType == 'base'){
559         $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
560       }
562       /* Role selector if scope is base */
563       if ($this->aclType == 'role'){
564         $smarty->assign('roleSelector', "Role selector");#, $this->buildRoleSelector($this->myAclObjects));
565         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
566       }
567     }
569     if ($this->dialogState == 'edit'){
570       $smarty->assign('headline', sprintf(_("Edit ACL for '%s' - scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
572       /* Collect objects for selected category */
573       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
574         if ($idx == 0){
575           continue;
576         }
577         $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
578       }
579       if ($this->aclObject == 'all'){
580         $aclObjects['all']= _("All objects in current subtree");
581       }
583       /* Role selector if scope is base */
584       if ($this->aclType == 'role'){
585         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
586       } else {
587         $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
588       }
589     }
591     /* Show main page */
592     $smarty->assign("dialogState", $this->dialogState);
593    
594     /* Assign acls */ 
595     $smarty->assign("acl_createable",$this->acl_is_createable());
596     $smarty->assign("acl_writeable" ,$this->acl_is_writeable(""));
597     $smarty->assign("acl_readable"  ,$this->acl_is_readable(""));
598     $smarty->assign("acl_removeable",$this->acl_is_removeable());
600     return ($smarty->fetch (get_template_path('acl.tpl')));
601   }
604   function sort_by_priority($list)
605   {
606     $tmp= session::get('plist');
607     $plist= $tmp->info;
608     asort($plist);
609     $newSort = array();
611     foreach($list as $name => $translation){
612       $na  =  preg_replace("/^.*\//","",$name);
613       $prio = 0;
614       if(isset($plist[$na]['plPriority'])){
615         $prio=  $plist[$na]['plPriority'] ;
616       }
618       $newSort[$name] = $prio;
619     }
621     asort($newSort);
623     $ret = array();
624     foreach($newSort as $name => $prio){
625       $ret[$name] = $list[$name];
626     }
627     return($ret);
628   }
631   function buildRoleSelector($list)
632   {
633     $D_List =new divSelectBox("Acl_Roles");
634  
635     $selected = $this->aclContents;
636     if(!is_string($this->aclContents) || !isset($list[$this->aclContents])){
637       $selected = key($list);
638     }
640     $str ="";
641     foreach($list as $dn => $values){
643       if($dn == $selected){    
644         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."' checked>";
645       }else{
646         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."'>";
647       }
648  
649       $field1 = array("string" => $option) ;
650       $field2 = array("string" => $values['cn'], "attach" => "style='width:200px;'") ;
651       $field3 = array("string" => $values['description'],"attach" => "style='border-right:0px;'") ;
653       $D_List->AddEntry(array($field1,$field2,$field3));
654     }
655     return($D_List->DrawList());
656   } 
659   function buildAclSelector($list)
660   {
661     $display= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
662     $cols= 3;
663     $tmp= session::get('plist');
664     $plist= $tmp->info;
665     asort($plist);
667     /* Add select all/none buttons */
668     $style = "style='width:100px;'";
670     if($this->acl_is_writeable("")){
671       $display .= "<input ".$style." type='button' name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" value='Toggle C'>";
672       $display .= "<input ".$style." type='button' name='toggle_all_move'   onClick=\"acl_toggle_all('_0_m$');\" value='Toggle M'>";
673       $display .= "<input ".$style." type='button' name='toggle_all_remove' onClick=\"acl_toggle_all('_0_d$');\" value='Toggle D'> - ";
674       $display .= "<input ".$style." type='button' name='toggle_all_read'   onClick=\"acl_toggle_all('_0_r$');\" value='Toggle R'>";
675       $display .= "<input ".$style." type='button' name='toggle_all_write'  onClick=\"acl_toggle_all('_0_w$');\" value='Toggle W'> - ";
677       $display .= "<input ".$style." type='button' name='toggle_all_sub_read'  onClick=\"acl_toggle_all('[^0]_r$');\" value='R+'>";
678       $display .= "<input ".$style." type='button' name='toggle_all_sub_write'  onClick=\"acl_toggle_all('[^0]_w$');\" value='W+'>";
680       $display .= "<br>";
682       $style = "style='width:50px;'";
683       $display .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
684       $display .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
685       $display .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
686       $display .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
687       $display .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
688       $display .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
689       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
690       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
691       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
692       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
694       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('[^0]_r$',true);\" value='R+'>";
695       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('[^0]_r$',false);\" value='R-'>";
696       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('[^0]_w$',true);\" value='W+'>";
697       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('[^0]_w$',false);\" value='W-'>";
698     }
700     /* Build general objects */
701     $list =$this->sort_by_priority($list);
702     foreach ($list as $key => $name){
704       /* Create sub acl if it does not exist */
705       if (!isset($this->aclContents[$key])){
706         $this->aclContents[$key]= array();
707         $this->aclContents[$key][0]= '';
708       }
709       $currentAcl= $this->aclContents[$key];
711       /* Get the overall plugin acls 
712        */
713       $overall_acl ="";
714       if(isset($currentAcl[0])){
715         $overall_acl = $currentAcl[0];
716       }
718       /* Object header */
719       if(session::get('js')) {
720         if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
721           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
722                      "\n  <tr>".
723                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
724                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
725                      "\n    <input type='button' onclick='divtoggle(\"".preg_replace("/[^a-z0-9]/i","_",$name)."\");' value='"._("Show/hide advanced settings")."' /></td>".
726                      "\n  </tr>";
727         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
728           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
729                      "\n  <tr>".
730                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
731                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
732                      "\n    <input type='button' onclick='divtoggle(\"".preg_replace("/[^a-z0-9]/i","_",$name)."\");' value='"._("Show/hide advanced settings")."' /></td>".
733                      "\n  </tr>";
734         } else {
735           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
736                      "\n  <tr>".
737                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
738                      "\n  </tr>";
739         }
740       } else {
741           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
742                      "\n  <tr>".
743                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
744                      "\n  </tr>";
745       }
747       /* Generate options */
748       $spc= "&nbsp;&nbsp;";
749 #      if ($this->isContainer && $this->aclType != 'base'){
750         $options= $this->mkchkbx($key."_0_c",  _("Create objects"), preg_match('/c/', $overall_acl)).$spc;
751         $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $overall_acl)).$spc;
752         $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $overall_acl)).$spc;
753         if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
754           $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$spc;
755         }
756  #     } else {
757  #       $options= $this->mkchkbx($key."_0_m", _("Move object"), preg_match('/m/', $overall_acl)).$spc;
758  #       $options.= $this->mkchkbx($key."_0_d", _("Remove object"), preg_match('/d/', $overall_acl)).$spc;
759  #       if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
760  #         $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$spc;
761  #       }
762  #     }
764       /* Global options */
765       $more_options= $this->mkchkbx($key."_0_r",  _("read"), preg_match('/r/', $overall_acl)).$spc;
766       $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl));
768       $display.= "\n  <tr>".
769                  "\n    <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
770                  "\n    <td style='background-color:#D4D4D4'>&nbsp;"._("Complete object").": $more_options</td>".
771                  "\n  </tr>";
773       /* Walk through the list of attributes */
774       $cnt= 1;
775       $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls'];
776 #      asort($splist);
777       if(session::get('js')) {
778         if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
779           $display.= "\n  <tr id='tr_".preg_replace("/[^a-z0-9]/i","_",$name)."' style='vertical-align:top;height:0px;'>".
780                      "\n    <td colspan=".$cols.">".
781                      "\n      <div id='".preg_replace("/[^a-z0-9]/i","_",$name)."' style='overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
782                      "\n        <table style='width:100%;'>";
783         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
784           $display.= "\n  <tr id='tr_".preg_replace("/[^a-z0-9]/i","_",$name)."' style='vertical-align:top;height:0px;'>".
785                      "\n    <td colspan=".$cols.">".
786                      "\n      <div id='".preg_replace("/[^a-z0-9]/i","_",$name)."' style='position:absolute;overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
787                      "\n        <table style='width:100%;'>";
788         }
789       }
790       foreach($splist as $attr => $dsc){
792         /* Skip pl* attributes, they are internal... */
793         if (preg_match('/^pl[A-Z]+.*$/', $attr)){
794           continue;
795         }
797         /* Open table row */
798         if ($cnt == 1){
799           $display.= "\n  <tr>";
800         }
802         /* Close table row */
803         if ($cnt == $cols){
804           $cnt= 1;
805           $rb= "";
806           $end= "\n  </tr>";
807         } else {
808           $cnt++;
809           $rb= "border-right:1px solid #A0A0A0;";
810           $end= "";
811         }
813         /* Collect list of attributes */
814         $state= "";
815         if (isset($currentAcl[$attr])){
816           $state= $currentAcl[$attr];
817         }
818         $display.= "\n    <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100/$cols)."%'>".
819                    "\n      <b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."</td>$end";
820       }
821       
822       /* Fill missing td's if needed */
823       if (--$cnt != $cols && $cnt != 0){
824        $display.= str_repeat("\n    <td style='border-top:1px solid #A0A0A0; width:".(int)(100/$cols)."%'>&nbsp;</td>", $cols-$cnt); 
825       }
827       if(session::get('js')) {
828         if(isset($_SERVER['HTTP_USER_AGENT']) && (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT']))) {
829           $display.= "\n        </table>".
830                      "\n      </div>".
831                      "\n    </td>".
832                      "\n  </tr>";
833         }
834       }
836       $display.= "\n</table><br />\n";
837     }
839     return ($display);
840   }
843   function mkchkbx($name, $text, $state= FALSE)
844   {
845     $state= $state?"checked":"";
846     if($this->acl_is_writeable("")){
847       return "\n      <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."' type=checkbox name='acl_$name' $state>".
848         "\n      <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."'>$text</label>";
849     }else{
850       return "\n <input type='checkbox' disabled name='dummy_".microtime(1)."' $state>$text";
851     }
852   }
855   function mkrwbx($name, $state= "")
856   {
857     $rstate= preg_match('/r/', $state)?'checked':'';
858     $wstate= preg_match('/w/', $state)?'checked':'';
859       
860     if($this->acl_is_writeable("")){
861       return ("\n      <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_r' type=checkbox name='acl_${name}_r' $rstate>".
862           "\n      <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_r'>"._("read")."</label>".
863           "\n      <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_w' type=checkbox name='acl_${name}_w' $wstate>".
864           "\n      <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_w'>"._("write")."</label>");
865     }else{
866       return ("\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read").
867           "\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write"));
868     }
869   }
872   static function explodeACL($acl)
873   {
875     $list= split(':', $acl);
876     if(count($list) == 5){
877       list($index, $type,$member,$permission,$filter)= $list;
878       $filter = base64_decode($filter);
879     }else{
880       $filter = "";
881       list($index, $type,$member,$permission)= $list;
882     }
884     $a= array( $index => array("type" => $type,
885                                "filter"=> $filter,
886                                "members" => acl::extractMembers($acl,$type == "role")));
887    
888     /* Handle different types */
889     switch ($type){
891       case 'psub':
892       case 'sub':
893       case 'one':
894       case 'base':
895         $a[$index]['acl']= acl::extractACL($acl);
896         break;
897       
898       case 'role':
899         $a[$index]['acl']= base64_decode(preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl));
900         break;
902       case 'reset':
903         break;
904       
905       default:
906         msg_dialog::display(_("Internal error"), sprintf(_("Unkown ACL type '%s'!"), $type), ERROR_DIALOG);
907         $a= array();
908     }
909     return ($a);
910   }
913   static function extractMembers($acl,$role = FALSE)
914   {
915     global $config;
916     $a= array();
918     /* Rip acl off the string, seperate by ',' and place it in an array */
919     if($role){
920       $ms= preg_replace('/^[^:]+:[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
921     }else{
922       $ms= preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
923     }
924     if ($ms == $acl){
925       return $a;
926     }
927     $ma= split(',', $ms);
929     /* Decode dn's, fill with informations from LDAP */
930     $ldap= $config->get_ldap_link();
931     foreach ($ma as $memberdn){
932       $dn= base64_decode($memberdn);
933       $ldap->cat($dn, array('cn', 'objectClass', 'description', 'uid'));
935       /* Found entry... */
936       if ($ldap->count()){
937         $attrs= $ldap->fetch();
938         if (in_array_ics('gosaAccount', $attrs['objectClass'])){
939           $a['U:'.$dn]= $attrs['cn'][0]." [".$attrs['uid'][0]."]";
940         } else {
941           $a['G:'.$dn]= $attrs['cn'][0];
942           if (isset($attrs['description'][0])){
943             $a['G:'.$dn].= " [".$attrs['description'][0]."]";
944           }
945         }
947       /* ... or not */
948       } else {
949         $a['U:'.$dn]= sprintf(_("Unknown entry '%s'!"), $dn);
950       }
951     }
953     return ($a);
954   }
957   static function extractACL($acl)
958   {
959     /* Rip acl off the string, seperate by ',' and place it in an array */
960     $as= preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
961     $aa= split(',', $as);
962     $a= array();
964     /* Dis-assemble single ACLs */
965     foreach($aa as $sacl){
966       
967       /* Dis-assemble field ACLs */
968       $ao= split('#', $sacl);
969       $gobject= "";
970       foreach($ao as $idx => $ssacl){
972         /* First is department with global acl */
973         $object= preg_replace('/^([^;]+);.*$/', '\1', $ssacl);
974         $gacl=   preg_replace('/^[^;]+;(.*)$/', '\1', $ssacl);
975         if ($idx == 0){
976           /* Create hash for this object */
977           $gobject= $object;
978           $a[$gobject]= array();
980           /* Append ACL if set */
981           if ($gacl != ""){
982             $a[$gobject]= array($gacl);
983           }
984         } else {
986           /* All other entries get appended... */
987           list($field, $facl)= split(';', $ssacl);
988           $a[$gobject][$field]= $facl;
989         }
991       }
992     }
994     return ($a);
995   }
997   
998   function assembleAclSummary($entry)
999   {
1000     $summary= "";
1002     /* Summarize ACL */
1003     if (isset($entry['acl'])){
1004       $acl= "";
1006       if($entry['type'] == "role"){
1008         if(isset($this->roles[$entry['acl']])){  
1009           $summary.= sprintf(_("Role: %s"), $this->roles[$entry['acl']]['cn']);
1010         }else{
1011           $summary.= sprintf(_("Role: %s"), "<i>"._("unknown role")."</i>");
1012         }
1013       }else{
1014         foreach ($entry['acl'] as $name => $object){
1015           if (count($object)){
1016             $acl.= "$name, ";
1017           }
1018         }
1019         $summary.= sprintf(_("Contains settings for these objects: %s"), preg_replace('/, $/', '', $acl));
1020       }
1021     }
1023     /* Summarize members */
1024     if ($summary != ""){
1025       $summary.= ", ";
1026     }
1027     if (count($entry['members'])){
1028       $summary.= _("Members").": ";
1029       foreach ($entry['members'] as $cn){
1030         $cn= preg_replace('/ \[.*$/', '', $cn);
1031         $summary.= $cn.", ";
1032       }
1033     } else {
1034       $summary.= _("ACL takes effect for all users");
1035     }
1037     return (preg_replace('/, $/', '', $summary));
1038   }
1041   function loadAclEntry($new= FALSE)
1042   {
1043     /* New entry gets presets... */
1044     if ($new){
1045       $this->aclType= 'base';
1046       $this->aclFilter= "";
1047       $this->recipients= array();
1048       $this->aclContents= array();
1049     } else {
1050       $acl= $this->gosaAclEntry[$this->currentIndex];
1051       $this->aclType= $acl['type'];
1052       $this->recipients= $acl['members'];
1053       $this->aclContents= $acl['acl'];
1054       $this->aclFilter= $acl['filter'];
1055     }
1057     $this->wasNewEntry= $new;
1058   }
1061   function aclPostHandler()
1062   {
1063     if (isset($_POST['save_acl'])){
1064       $this->save();
1065       return TRUE;
1066     }
1068     return FALSE;
1069   }
1071   
1072   function PrepareForCopyPaste($source)
1073   {
1074     plugin::PrepareForCopyPaste($source);
1075     
1076     $dn = $source['dn'];
1077     $acl_c = new acl($this->config, $this->parent,$dn);
1078     $this->gosaAclEntry = $acl_c->gosaAclEntry;
1079   }
1082   function save()
1083   {
1084     /* Assemble ACL's */
1085     $tmp_acl= array();
1086   
1087     foreach ($this->gosaAclEntry as $prio => $entry){
1088       $final= "";
1089       $members= "";
1090       if (isset($entry['members'])){
1091         foreach ($entry['members'] as $key => $dummy){
1092           $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
1093         }
1094       }
1096       if($entry['type'] != "role"){
1097         $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
1098       }else{
1099         $final= $prio.":".$entry['type'].":".base64_encode($entry['acl']).":".preg_replace('/,$/', '', $members);
1100       }
1102       /* ACL's if needed */
1103       if ($entry['type'] != "reset" && $entry['type'] != "role"){
1104         $acl= ":";
1105         if (isset($entry['acl'])){
1106           foreach ($entry['acl'] as $object => $contents){
1108             /* Only save, if we've some contents in there... */
1109             if (count($contents)){
1110               $acl.= $object.";";
1112               foreach($contents as $attr => $permission){
1114                 /* First entry? Its the one for global settings... */
1115                 if ($attr == '0'){
1116                   $acl.= $permission;
1117                 } else {
1118                   $acl.= '#'.$attr.';'.$permission;
1119                 }
1121               }
1122               $acl.= ',';
1123             }
1124             
1125           }
1126         }
1127         $final.= preg_replace('/,$/', '', $acl);
1128       }
1130       /* Append additional filter options 
1131        */
1132       if(!empty($entry['filter'])){
1133         $final .= ":".base64_encode($entry['filter']);
1134       }
1136       $tmp_acl[]= $final;
1137     } 
1139     /* Call main method */
1140     plugin::save();
1142     /* Finally (re-)assign it... */
1143     $this->attrs['gosaAclEntry']= $tmp_acl;
1145     /* Remove acl from this entry if it is empty... */
1146     if (!count($tmp_acl)){
1147       /* Remove attribute */
1148       if ($this->initially_was_account){
1149         $this->attrs['gosaAclEntry']= array();
1150       } else {
1151         if (isset($this->attrs['gosaAclEntry'])){
1152           unset($this->attrs['gosaAclEntry']);
1153         }
1154       }
1156       /* Remove object class */
1157       $this->attrs['objectClass']= array_remove_entries(array('gosaAcl'), $this->attrs['objectClass']);
1158     }    
1160     /* Do LDAP modifications */
1161     $ldap= $this->config->get_ldap_link();
1162     $ldap->cd($this->dn);
1163     $this->cleanup();
1164     $ldap->modify ($this->attrs);
1166     if(count($this->attrs)){
1167       new log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1168     }
1170     if (!$ldap->success()){
1171       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
1172     }
1174     /* Refresh users ACLs */
1175     $ui= get_userinfo();
1176     $ui->loadACL();
1177     session::set('ui',$ui);
1178   }
1181   function remove_from_parent()
1182   {
1183     plugin::remove_from_parent();
1185     /* include global link_info */
1186     $ldap= $this->config->get_ldap_link();
1188     $ldap->cd($this->dn);
1189     $this->cleanup();
1190     $ldap->modify ($this->attrs);
1192     new log("remove","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1194     /* Optionally execute a command after we're done */
1195     $this->handle_post_events("remove",array("uid" => $this->uid));
1196   }
1198   
1199   /* Return plugin informations for acl handling */
1200   static function plInfo()
1201   {
1202     return (array(
1203           "plShortName"   => _("ACL"),
1204           "plDescription" => _("ACL")."&nbsp;("._("Access control list").")",
1205           "plSelfModify"  => FALSE,
1206           "plDepends"     => array(),
1207           "plPriority"    => 0,
1208           "plSection"     => array("administration"),
1209           "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
1210                                                           "objectClass"  => array("gosaAcl","gosaRole"))),
1211           "plProvidedAcls"=> array(
1212 //            "cn"          => _("Role name"),
1213 //            "description" => _("Role description")
1214             )
1216           ));
1217   }
1220   /* Remove acls defined for $src */
1221   function remove_acl()
1222   {
1223     $this->remove_acl_for_dn($this->dn);
1224   }
1227   /* Remove acls defined for $src */
1228   function remove_acl_for_dn($src = "")
1229   {
1230     if($src == ""){
1231       $src = $this->dn;
1232     }
1233     $ldap = $this->config->get_ldap_link();
1234     $ldap->cd($this->config->current['BASE']);
1235     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1236     while($attrs = $ldap->fetch()){
1237       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1238       foreach($acl->gosaAclEntry as $id => $entry){
1239         foreach($entry['members'] as $m_id => $member){
1240           if($m_id == "U:".$src){
1241             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1242             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Removed acl for user %s on object %s.",$src,$attrs['dn']));
1243           }
1244           if($m_id == "G:".$src){
1245             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1246             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Removed acl for group %s on object %s.",$src,$attrs['dn']));
1247           }
1248         }
1249       }
1250       $acl -> save();
1251     }
1252   }
1254   function update_acl_membership($src,$dst)
1255   {
1256     $ldap = $this->config->get_ldap_link();
1257     $ldap->cd($this->config->current['BASE']);
1258     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1259     while($attrs = $ldap->fetch()){
1260       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1261       foreach($acl->gosaAclEntry as $id => $entry){
1262         foreach($entry['members'] as $m_id => $member){
1263           if($m_id == "U:".$src){
1264             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1265             $new = "U:".$dst;
1266             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1267             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Updated acl for user %s on object %s.",$src,$attrs['dn']));
1268           }
1269           if($m_id == "G:".$src){
1270             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1271             $new = "G:".$dst;
1272             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1273             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Updated acl for group %s on object %s.",$src,$attrs['dn']));
1274           }
1275         }
1276       }
1277       $acl -> save();
1278     }
1279   }
1283 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1284 ?>