Code

193b9b519717f39d110cf593df4247bad75efad2
[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       if(isset($_POST['selected_role'])){
310         $this->aclContents = "";
311         $this->aclContents = base64_decode($_POST['selected_role']);
312       }
313     }
316     /* Check Posts 
317      */
318     if(isset($_POST['acl_dummy_0_0_0'])){
319       $aclDialog= TRUE;
320       $tmp= session::get('plist');
321       $plist= $tmp->info;
322       $list = $this->ocMapping[$this->aclObject];
323       foreach($list as $plugin){
324         foreach(array("r","w","c","d","s","m") as $acl){
325           $overall = "acl_{$this->aclObject}/{$plugin}_0_{$acl}";
326           if(isset($_POST[$overall])){
327             if(!isset($new_acl["{$this->aclObject}/{$plugin}"][0])) {
328               $new_acl["{$this->aclObject}/{$plugin}"][0] = "";
329             }
330             $new_acl["{$this->aclObject}/{$plugin}"][0] .= $acl;
331           }
332           if(!isset($plist[$plugin]) || !is_array($plist[$plugin])) continue;
333           foreach($plist[$plugin]['plProvidedAcls'] as $attribute => $description){
334             $aclstr = "acl_{$this->aclObject}/{$plugin}_{$attribute}_{$acl}";
335             if(isset($_POST[$aclstr])){
336               if(!isset($new_acl["{$this->aclObject}/{$plugin}"][$attribute])) {
337                 $new_acl["{$this->aclObject}/{$plugin}"][$attribute] = "";
338               }
339               $new_acl["{$this->aclObject}/{$plugin}"][$attribute] .= $acl;
340             }
341           }
342         }
343       }
344     }
346     if($this->acl_is_writeable("")){
347       
348       /* Only be interested in new acl's, if we're in the right _POST place */
349       if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
350         $this->aclContents = $new_acl;
351       }
353       /* Save new acl in case of base edit mode */
354       if ($this->aclType == 'base' && !$firstedit){
355         $this->aclContents= $new_acl;
356       }
357     }
359     /* Cancel new acl? */
360     if (isset($_POST['cancel_new_acl'])){
361       $this->dialogState= 'head';
362       $this->dialog= FALSE;
363       if ($this->wasNewEntry){
364         unset ($this->gosaAclEntry[$this->currentIndex]);
365       }
366     }
368     /* Save common values */
369     if($this->acl_is_writeable("")){
370       foreach (array("aclType","aclFilter", "aclObject", "target") as $key){
371         if (isset($_POST[$key])){
372           $this->$key= validate($_POST[$key]);
373         }
374       }
375     }
377     /* Store ACL in main object? */
378     if (isset($_POST['submit_new_acl'])){
379       $this->gosaAclEntry[$this->currentIndex]['type']= $this->aclType;
380       $this->gosaAclEntry[$this->currentIndex]['members']= $this->recipients;
381       $this->gosaAclEntry[$this->currentIndex]['acl']= $this->aclContents;
382       $this->gosaAclEntry[$this->currentIndex]['filter']= $this->aclFilter;
383       $this->dialogState= 'head';
384       $this->dialog= FALSE;
385     }
387     /* Cancel edit acl? */
388     if (isset($_POST['cancel_edit_acl'])){
389       $this->dialogState= 'create';
390       foreach ($this->ocMapping[$this->aclObject] as $oc){
391         if (isset($this->savedAclContents[$oc])){
392           $this->aclContents[$oc]= $this->savedAclContents[$oc];
393         }
394       }
395     }
397     /* Save edit acl? */
398     if (isset($_POST['submit_edit_acl'])){
399       $this->dialogState= 'create';
400     }
402     /* Add acl? */
403     if (isset($_POST['add_acl']) && $_POST['aclObject'] != ""){
404       $this->dialogState= 'edit';
405       $this->savedAclContents= array();
406       foreach ($this->ocMapping[$this->aclObject] as $oc){
407         if (isset($this->aclContents[$oc])){
408           $this->savedAclContents[$oc]= $this->aclContents[$oc];
409         }
410       }
411     }
413     /* Add to list? */
414     if (isset($_POST['add']) && isset($_POST['source'])){
415       foreach ($_POST['source'] as $key){
416         if ($this->target == 'user'){
417           $this->recipients[$key]= $this->users[$key];
418         }
419         if ($this->target == 'group'){
420           $this->recipients[$key]= $this->groups[$key];
421         }
422       }
423       ksort($this->recipients);
424     }
426     /* Remove from list? */
427     if (isset($_POST['del']) && isset($_POST['recipient'])){
428       foreach ($_POST['recipient'] as $key){
429           unset($this->recipients[$key]);
430       }
431     }
433     /* Create templating instance */
434     $smarty= get_smarty();
435     $smarty->assign("acl_readable",$this->acl_is_readable(""));
436     if(!$this->acl_is_readable("")){
437       return ($smarty->fetch (get_template_path('acl.tpl')));
438     }
440     if ($this->dialogState == 'head'){
441       /* Draw list */
442       $aclList= new divSelectBox("aclList");
443       $aclList->SetHeight(450);
444       
445       /* Fill in entries */
446       foreach ($this->gosaAclEntry as $key => $entry){
447         if(!$this->acl_is_readable("")) continue;
449         $action ="";      
450   
451         $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
452         $field2= array("string" => $this->assembleAclSummary($entry));
454         if($this->acl_is_writeable("")){
455           $action.= "<input type='image' name='sortup_$key' alt='up' 
456             title='"._("Up")."' src='images/lists/sort-up.png' align='top'>";
457           $action.= "<input type='image' name='sortdown_$key' alt='down' 
458             title='"._("Down")."' src='images/lists/sort-down.png'>";
459         } 
460     
461         if($this->acl_is_readable("")){
462           $action.= "<input class='center' type='image' src='images/lists/edit.png' 
463             alt='"._("Edit")."' name='acl_edit_$key' title='".msgPool::editButton(_("ACL"))."'>";
464         }
465         if($this->acl_is_removeable("")){
466           $action.= "<input class='center' type='image' src='images/lists/trash.png' 
467             alt='"._("Delete")."' name='acl_del_$key' title='".msgPool::delButton(_("ACL"))."'>";
468         }
470         $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
471         $aclList->AddEntry(array($field1, $field2, $field3));
472       }
474       $smarty->assign("aclList", $aclList->DrawList());
475     }
477     if ($this->dialogState == 'create'){
478       /* Draw list */
479       $aclList= new divSelectBox("aclList");
480       $aclList->SetHeight(150);
482       /* Add settings for all categories to the (permanent) list */
483       foreach ($this->aclObjects as $section => $dsc){
484         $summary= "";
485         foreach($this->ocMapping[$section] as $oc){
486           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
487               $this->aclContents[$oc][0] != ""){
489             $summary.= "$oc, ";
490             continue;
491           }
492           if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
493             $summary.= "$oc, ";
494             continue;
495           }
496           if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
497             $summary.= "$oc, ";
498           }
499         }
501         /* Set summary... */
502         if ($summary == ""){
503           $summary= '<i>'._("No ACL settings for this category!").'</i>';
504         } else {
505           $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary));
506         }
508         $actions ="";
509         if($this->acl_is_readable("")){
510           $actions= "<input class='center' type='image' src='images/lists/edit.png' 
511             alt='"._("Edit")."' name='cat_edit_$section' title='".msgPool::editButton(_("category ACL"))."'>";
512         }
513         if($this->acl_is_removeable()){
514           $actions.= "<input class='center' type='image' src='images/lists/trash.png' 
515             alt='"._("Delete")."' name='cat_del_$section' title='".msgPool::delButton(_("category ACL"))."'>";
516         }   
518         $field1= array("string" => $dsc, "attach" => "style='width:100px'");
519         $field2= array("string" => $summary);
520         $field3= array("string" => $actions, "attach" => "style='border-right:0px;width:50px'");
521         $aclList->AddEntry(array($field1, $field2, $field3));
522       }
524       $smarty->assign("aclList", $aclList->DrawList());
525       $smarty->assign("aclType", $this->aclType);
526       $smarty->assign("aclFilter", $this->aclFilter);
527       $smarty->assign("aclTypes", $this->aclTypes);
528       $smarty->assign("target", $this->target);
529       $smarty->assign("targets", $this->targets);
531       /* Assign possible target types */
532       $smarty->assign("targets", $this->targets);
533       foreach ($this->attributes as $attr){
534         $smarty->assign($attr, $this->$attr);
535       }
538       /* Generate list */
539       $tmp= array();
540       foreach (array("user" => "users", "group" => "groups") as $field => $arr){
541         if ($this->target == $field){
542           foreach ($this->$arr as $key => $value){
543             if (!isset($this->recipients[$key])){
544               $tmp[$key]= $value;
545             }
546           }
547         }
548       }
549       $smarty->assign('sources', $tmp);
550       $smarty->assign('recipients', $this->recipients);
552       /* Acl selector if scope is base */
553       if ($this->aclType == 'base'){
554         $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
555       }
557       /* Role selector if scope is base */
558       if ($this->aclType == 'role'){
559         $smarty->assign('roleSelector', "Role selector");#, $this->buildRoleSelector($this->myAclObjects));
560         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
561       }
562     }
564     if ($this->dialogState == 'edit'){
565       $smarty->assign('headline', sprintf(_("Edit ACL for '%s' - scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
567       /* Collect objects for selected category */
568       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
569         if ($idx == 0){
570           continue;
571         }
572         $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
573       }
574       if ($this->aclObject == 'all'){
575         $aclObjects['all']= _("All objects in current subtree");
576       }
578       /* Role selector if scope is base */
579       if ($this->aclType == 'role'){
580         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
581       } else {
582         $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
583       }
584     }
586     /* Show main page */
587     $smarty->assign("dialogState", $this->dialogState);
588    
589     /* Assign acls */ 
590     $smarty->assign("acl_createable",$this->acl_is_createable());
591     $smarty->assign("acl_writeable" ,$this->acl_is_writeable(""));
592     $smarty->assign("acl_readable"  ,$this->acl_is_readable(""));
593     $smarty->assign("acl_removeable",$this->acl_is_removeable());
595     return ($smarty->fetch (get_template_path('acl.tpl')));
596   }
599   function sort_by_priority($list)
600   {
601     $tmp= session::get('plist');
602     $plist= $tmp->info;
603     asort($plist);
604     $newSort = array();
606     foreach($list as $name => $translation){
607       $na  =  preg_replace("/^.*\//","",$name);
608       $prio = 0;
609       if(isset($plist[$na]['plPriority'])){
610         $prio=  $plist[$na]['plPriority'] ;
611       }
613       $newSort[$name] = $prio;
614     }
616     asort($newSort);
618     $ret = array();
619     foreach($newSort as $name => $prio){
620       $ret[$name] = $list[$name];
621     }
622     return($ret);
623   }
626   function buildRoleSelector($list)
627   {
628     $D_List =new divSelectBox("Acl_Roles");
629  
630     $selected = $this->aclContents;
631     if(!is_string($this->aclContents) || !isset($list[$this->aclContents])){
632       $selected = key($list);
633     }
635     $str ="";
636     foreach($list as $dn => $values){
638       if($dn == $selected){    
639         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."' checked>";
640       }else{
641         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."'>";
642       }
643  
644       $field1 = array("string" => $option) ;
645       $field2 = array("string" => $values['cn'], "attach" => "style='width:200px;'") ;
646       $field3 = array("string" => $values['description'],"attach" => "style='border-right:0px;'") ;
648       $D_List->AddEntry(array($field1,$field2,$field3));
649     }
650     return($D_List->DrawList());
651   } 
654   function buildAclSelector($list)
655   {
656     /* Do not change the dummy, it is used to detect whether the dialog was opnened or not
657      */
658     $display= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
659     $cols= 3;
660     $tmp= session::get('plist');
661     $plist= $tmp->info;
662     asort($plist);
664     /* Add select all/none buttons */
665     $style = "style='width:100px;'";
667     if($this->acl_is_writeable("")){
668       $display .= "<input ".$style." type='button' name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" value='Toggle C'>";
669       $display .= "<input ".$style." type='button' name='toggle_all_move'   onClick=\"acl_toggle_all('_0_m$');\" value='Toggle M'>";
670       $display .= "<input ".$style." type='button' name='toggle_all_remove' onClick=\"acl_toggle_all('_0_d$');\" value='Toggle D'> - ";
671       $display .= "<input ".$style." type='button' name='toggle_all_read'   onClick=\"acl_toggle_all('_0_r$');\" value='Toggle R'>";
672       $display .= "<input ".$style." type='button' name='toggle_all_write'  onClick=\"acl_toggle_all('_0_w$');\" value='Toggle W'> - ";
674       $display .= "<input ".$style." type='button' name='toggle_all_sub_read'  onClick=\"acl_toggle_all('[^0]_r$');\" value='R+'>";
675       $display .= "<input ".$style." type='button' name='toggle_all_sub_write'  onClick=\"acl_toggle_all('[^0]_w$');\" value='W+'>";
677       $display .= "<br>";
679       $style = "style='width:50px;'";
680       $display .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
681       $display .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
682       $display .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
683       $display .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
684       $display .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
685       $display .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
686       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
687       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
688       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
689       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
691       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('[^0]_r$',true);\" value='R+'>";
692       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('[^0]_r$',false);\" value='R-'>";
693       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('[^0]_w$',true);\" value='W+'>";
694       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('[^0]_w$',false);\" value='W-'>";
695     }
697     /* Build general objects */
698     $list =$this->sort_by_priority($list);
699     foreach ($list as $key => $name){
701       /* Create sub acl if it does not exist */
702       $currentAcl = array("0" => "");
703       if (isset($this->aclContents[$key])){
704         $currentAcl= $this->aclContents[$key];
705       }
707       /* Get the overall plugin acls 
708        */
709       $overall_acl ="";
710       if(isset($currentAcl[0])){
711         $overall_acl = $currentAcl[0];
712       }
714       /* Object header */
715       if(session::get('js')) {
716         if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
717           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
718                      "\n  <tr>".
719                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
720                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
721                      "\n    <input type='button' onclick='divtoggle(\"".preg_replace("/[^a-z0-9]/i","_",$name)."\");' value='"._("Show/hide advanced settings")."' /></td>".
722                      "\n  </tr>";
723         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
724           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
725                      "\n  <tr>".
726                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
727                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
728                      "\n    <input type='button' onclick='divtoggle(\"".preg_replace("/[^a-z0-9]/i","_",$name)."\");' value='"._("Show/hide advanced settings")."' /></td>".
729                      "\n  </tr>";
730         } else {
731           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
732                      "\n  <tr>".
733                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
734                      "\n  </tr>";
735         }
736       } else {
737           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
738                      "\n  <tr>".
739                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
740                      "\n  </tr>";
741       }
743       /* Generate options */
744       $spc= "&nbsp;&nbsp;";
745 #      if ($this->isContainer && $this->aclType != 'base'){
746         $options= $this->mkchkbx($key."_0_c",  _("Create objects"), preg_match('/c/', $overall_acl)).$spc;
747         $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $overall_acl)).$spc;
748         $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $overall_acl)).$spc;
749         if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
750           $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$spc;
751         }
752  #     } else {
753  #       $options= $this->mkchkbx($key."_0_m", _("Move object"), preg_match('/m/', $overall_acl)).$spc;
754  #       $options.= $this->mkchkbx($key."_0_d", _("Remove object"), preg_match('/d/', $overall_acl)).$spc;
755  #       if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
756  #         $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$spc;
757  #       }
758  #     }
760       /* Global options */
761       $more_options= $this->mkchkbx($key."_0_r",  _("read"), preg_match('/r/', $overall_acl)).$spc;
762       $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl));
764       $display.= "\n  <tr>".
765                  "\n    <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
766                  "\n    <td style='background-color:#D4D4D4'>&nbsp;"._("Complete object").": $more_options</td>".
767                  "\n  </tr>";
769       /* Walk through the list of attributes */
770       $cnt= 1;
771       $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls'];
772 #      asort($splist);
773       if(session::get('js')) {
774         if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
775           $display.= "\n  <tr id='tr_".preg_replace("/[^a-z0-9]/i","_",$name)."' style='vertical-align:top;height:0px;'>".
776                      "\n    <td colspan=".$cols.">".
777                      "\n      <div id='".preg_replace("/[^a-z0-9]/i","_",$name)."' style='overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
778                      "\n        <table style='width:100%;'>";
779         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
780           $display.= "\n  <tr id='tr_".preg_replace("/[^a-z0-9]/i","_",$name)."' style='vertical-align:top;height:0px;'>".
781                      "\n    <td colspan=".$cols.">".
782                      "\n      <div id='".preg_replace("/[^a-z0-9]/i","_",$name)."' style='position:absolute;overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
783                      "\n        <table style='width:100%;'>";
784         }
785       }
786       foreach($splist as $attr => $dsc){
788         /* Skip pl* attributes, they are internal... */
789         if (preg_match('/^pl[A-Z]+.*$/', $attr)){
790           continue;
791         }
793         /* Open table row */
794         if ($cnt == 1){
795           $display.= "\n  <tr>";
796         }
798         /* Close table row */
799         if ($cnt == $cols){
800           $cnt= 1;
801           $rb= "";
802           $end= "\n  </tr>";
803         } else {
804           $cnt++;
805           $rb= "border-right:1px solid #A0A0A0;";
806           $end= "";
807         }
809         /* Collect list of attributes */
810         $state= "";
811         if (isset($currentAcl[$attr])){
812           $state= $currentAcl[$attr];
813         }
814         $display.= "\n    <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100/$cols)."%'>".
815                    "\n      <b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."</td>$end";
816       }
817       
818       /* Fill missing td's if needed */
819       if (--$cnt != $cols && $cnt != 0){
820        $display.= str_repeat("\n    <td style='border-top:1px solid #A0A0A0; width:".(int)(100/$cols)."%'>&nbsp;</td>", $cols-$cnt); 
821       }
823       if(session::get('js')) {
824         if(isset($_SERVER['HTTP_USER_AGENT']) && (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT']))) {
825           $display.= "\n        </table>".
826                      "\n      </div>".
827                      "\n    </td>".
828                      "\n  </tr>";
829         }
830       }
832       $display.= "\n</table><br />\n";
833     }
835     return ($display);
836   }
839   function mkchkbx($name, $text, $state= FALSE)
840   {
841     $state= $state?"checked":"";
842     if($this->acl_is_writeable("")){
843       return "\n      <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."' type=checkbox name='acl_$name' $state>".
844         "\n      <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."'>$text</label>";
845     }else{
846       return "\n <input type='checkbox' disabled name='dummy_".microtime(1)."' $state>$text";
847     }
848   }
851   function mkrwbx($name, $state= "")
852   {
853     $rstate= preg_match('/r/', $state)?'checked':'';
854     $wstate= preg_match('/w/', $state)?'checked':'';
855       
856     if($this->acl_is_writeable("")){
857       return ("\n      <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_r' type=checkbox name='acl_${name}_r' $rstate>".
858           "\n      <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_r'>"._("read")."</label>".
859           "\n      <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_w' type=checkbox name='acl_${name}_w' $wstate>".
860           "\n      <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_w'>"._("write")."</label>");
861     }else{
862       return ("\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read").
863           "\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write"));
864     }
865   }
868   static function explodeACL($acl)
869   {
871     $list= split(':', $acl);
872     if(count($list) == 5){
873       list($index, $type,$member,$permission,$filter)= $list;
874       $filter = base64_decode($filter);
875     }else{
876       $filter = "";
877       list($index, $type,$member,$permission)= $list;
878     }
880     $a= array( $index => array("type" => $type,
881                                "filter"=> $filter,
882                                "members" => acl::extractMembers($acl,$type == "role")));
883    
884     /* Handle different types */
885     switch ($type){
887       case 'psub':
888       case 'sub':
889       case 'one':
890       case 'base':
891         $a[$index]['acl']= acl::extractACL($acl);
892         break;
893       
894       case 'role':
895         $a[$index]['acl']= base64_decode(preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl));
896         break;
898       case 'reset':
899         break;
900       
901       default:
902         msg_dialog::display(_("Internal error"), sprintf(_("Unkown ACL type '%s'!"), $type), ERROR_DIALOG);
903         $a= array();
904     }
905     return ($a);
906   }
909   static function extractMembers($acl,$role = FALSE)
910   {
911     global $config;
912     $a= array();
914     /* Rip acl off the string, seperate by ',' and place it in an array */
915     if($role){
916       $ms= preg_replace('/^[^:]+:[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
917     }else{
918       $ms= preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
919     }
920     if ($ms == $acl){
921       return $a;
922     }
923     $ma= split(',', $ms);
925     /* Decode dn's, fill with informations from LDAP */
926     $ldap= $config->get_ldap_link();
927     foreach ($ma as $memberdn){
928       $dn= base64_decode($memberdn);
929       $ldap->cat($dn, array('cn', 'objectClass', 'description', 'uid'));
931       /* Found entry... */
932       if ($ldap->count()){
933         $attrs= $ldap->fetch();
934         if (in_array_ics('gosaAccount', $attrs['objectClass'])){
935           $a['U:'.$dn]= $attrs['cn'][0]." [".$attrs['uid'][0]."]";
936         } else {
937           $a['G:'.$dn]= $attrs['cn'][0];
938           if (isset($attrs['description'][0])){
939             $a['G:'.$dn].= " [".$attrs['description'][0]."]";
940           }
941         }
943       /* ... or not */
944       } else {
945         $a['U:'.$dn]= sprintf(_("Unknown entry '%s'!"), $dn);
946       }
947     }
949     return ($a);
950   }
953   static function extractACL($acl)
954   {
955     /* Rip acl off the string, seperate by ',' and place it in an array */
956     $as= preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
957     $aa= split(',', $as);
958     $a= array();
960     /* Dis-assemble single ACLs */
961     foreach($aa as $sacl){
962       
963       /* Dis-assemble field ACLs */
964       $ao= split('#', $sacl);
965       $gobject= "";
966       foreach($ao as $idx => $ssacl){
968         /* First is department with global acl */
969         $object= preg_replace('/^([^;]+);.*$/', '\1', $ssacl);
970         $gacl=   preg_replace('/^[^;]+;(.*)$/', '\1', $ssacl);
971         if ($idx == 0){
972           /* Create hash for this object */
973           $gobject= $object;
974           $a[$gobject]= array();
976           /* Append ACL if set */
977           if ($gacl != ""){
978             $a[$gobject]= array($gacl);
979           }
980         } else {
982           /* All other entries get appended... */
983           list($field, $facl)= split(';', $ssacl);
984           $a[$gobject][$field]= $facl;
985         }
987       }
988     }
990     return ($a);
991   }
993   
994   function assembleAclSummary($entry)
995   {
996     $summary= "";
998     /* Summarize ACL */
999     if (isset($entry['acl'])){
1000       $acl= "";
1002       if($entry['type'] == "role"){
1004         if(isset($this->roles[$entry['acl']])){  
1005           $summary.= sprintf(_("Role: %s"), $this->roles[$entry['acl']]['cn']);
1006         }else{
1007           $summary.= sprintf(_("Role: %s"), "<i>"._("unknown role")."</i>");
1008         }
1009       }else{
1010         foreach ($entry['acl'] as $name => $object){
1011           if (count($object)){
1012             $acl.= "$name, ";
1013           }
1014         }
1015         $summary.= sprintf(_("Contains settings for these objects: %s"), preg_replace('/, $/', '', $acl));
1016       }
1017     }
1019     /* Summarize members */
1020     if ($summary != ""){
1021       $summary.= ", ";
1022     }
1023     if (count($entry['members'])){
1024       $summary.= _("Members").": ";
1025       foreach ($entry['members'] as $cn){
1026         $cn= preg_replace('/ \[.*$/', '', $cn);
1027         $summary.= $cn.", ";
1028       }
1029     } else {
1030       $summary.= _("ACL takes effect for all users");
1031     }
1033     return (preg_replace('/, $/', '', $summary));
1034   }
1037   function loadAclEntry($new= FALSE)
1038   {
1039     /* New entry gets presets... */
1040     if ($new){
1041       $this->aclType= 'base';
1042       $this->aclFilter= "";
1043       $this->recipients= array();
1044       $this->aclContents= array();
1045     } else {
1046       $acl= $this->gosaAclEntry[$this->currentIndex];
1047       $this->aclType= $acl['type'];
1048       $this->recipients= $acl['members'];
1049       $this->aclContents= $acl['acl'];
1050       $this->aclFilter= $acl['filter'];
1051     }
1053     $this->wasNewEntry= $new;
1054   }
1057   function aclPostHandler()
1058   {
1059     if (isset($_POST['save_acl'])){
1060       $this->save();
1061       return TRUE;
1062     }
1064     return FALSE;
1065   }
1067   
1068   function PrepareForCopyPaste($source)
1069   {
1070     plugin::PrepareForCopyPaste($source);
1071     
1072     $dn = $source['dn'];
1073     $acl_c = new acl($this->config, $this->parent,$dn);
1074     $this->gosaAclEntry = $acl_c->gosaAclEntry;
1075   }
1078   function save()
1079   {
1080     /* Assemble ACL's */
1081     $tmp_acl= array();
1082   
1083     foreach ($this->gosaAclEntry as $prio => $entry){
1084       $final= "";
1085       $members= "";
1086       if (isset($entry['members'])){
1087         foreach ($entry['members'] as $key => $dummy){
1088           $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
1089         }
1090       }
1092       if($entry['type'] != "role"){
1093         $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
1094       }else{
1095         $final= $prio.":".$entry['type'].":".base64_encode($entry['acl']).":".preg_replace('/,$/', '', $members);
1096       }
1098       /* ACL's if needed */
1099       if ($entry['type'] != "reset" && $entry['type'] != "role"){
1100         $acl= ":";
1101         if (isset($entry['acl'])){
1102           foreach ($entry['acl'] as $object => $contents){
1104             /* Only save, if we've some contents in there... */
1105             if (count($contents)){
1106               $acl.= $object.";";
1108               foreach($contents as $attr => $permission){
1110                 /* First entry? Its the one for global settings... */
1111                 if ($attr == '0'){
1112                   $acl.= $permission;
1113                 } else {
1114                   $acl.= '#'.$attr.';'.$permission;
1115                 }
1117               }
1118               $acl.= ',';
1119             }
1120             
1121           }
1122         }
1123         $final.= preg_replace('/,$/', '', $acl);
1124       }
1126       /* Append additional filter options 
1127        */
1128       if(!empty($entry['filter'])){
1129         $final .= ":".base64_encode($entry['filter']);
1130       }
1132       $tmp_acl[]= $final;
1133     } 
1135     /* Call main method */
1136     plugin::save();
1138     /* Finally (re-)assign it... */
1139     $this->attrs['gosaAclEntry']= $tmp_acl;
1141     /* Remove acl from this entry if it is empty... */
1142     if (!count($tmp_acl)){
1143       /* Remove attribute */
1144       if ($this->initially_was_account){
1145         $this->attrs['gosaAclEntry']= array();
1146       } else {
1147         if (isset($this->attrs['gosaAclEntry'])){
1148           unset($this->attrs['gosaAclEntry']);
1149         }
1150       }
1152       /* Remove object class */
1153       $this->attrs['objectClass']= array_remove_entries(array('gosaAcl'), $this->attrs['objectClass']);
1154     }    
1156     /* Do LDAP modifications */
1157     $ldap= $this->config->get_ldap_link();
1158     $ldap->cd($this->dn);
1159     $this->cleanup();
1160     $ldap->modify ($this->attrs);
1162     if(count($this->attrs)){
1163       new log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1164     }
1166     if (!$ldap->success()){
1167       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
1168     }
1170     /* Refresh users ACLs */
1171     $ui= get_userinfo();
1172     $ui->loadACL();
1173     session::set('ui',$ui);
1174   }
1177   function remove_from_parent()
1178   {
1179     plugin::remove_from_parent();
1181     /* include global link_info */
1182     $ldap= $this->config->get_ldap_link();
1184     $ldap->cd($this->dn);
1185     $this->cleanup();
1186     $ldap->modify ($this->attrs);
1188     new log("remove","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1190     /* Optionally execute a command after we're done */
1191     $this->handle_post_events("remove",array("uid" => $this->uid));
1192   }
1194   
1195   /* Return plugin informations for acl handling */
1196   static function plInfo()
1197   {
1198     return (array(
1199           "plShortName"   => _("ACL"),
1200           "plDescription" => _("ACL")."&nbsp;("._("Access control list").")",
1201           "plSelfModify"  => FALSE,
1202           "plDepends"     => array(),
1203           "plPriority"    => 0,
1204           "plSection"     => array("administration"),
1205           "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
1206                                                           "objectClass"  => array("gosaAcl","gosaRole"))),
1207           "plProvidedAcls"=> array(
1208 //            "cn"          => _("Role name"),
1209 //            "description" => _("Role description")
1210             )
1212           ));
1213   }
1216   /* Remove acls defined for $src */
1217   function remove_acl()
1218   {
1219     $this->remove_acl_for_dn($this->dn);
1220   }
1223   /* Remove acls defined for $src */
1224   function remove_acl_for_dn($src = "")
1225   {
1226     if($src == ""){
1227       $src = $this->dn;
1228     }
1229     $ldap = $this->config->get_ldap_link();
1230     $ldap->cd($this->config->current['BASE']);
1231     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1232     while($attrs = $ldap->fetch()){
1233       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1234       foreach($acl->gosaAclEntry as $id => $entry){
1235         foreach($entry['members'] as $m_id => $member){
1236           if($m_id == "U:".$src){
1237             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1238             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Removed acl for user %s on object %s.",$src,$attrs['dn']));
1239           }
1240           if($m_id == "G:".$src){
1241             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1242             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Removed acl for group %s on object %s.",$src,$attrs['dn']));
1243           }
1244         }
1245       }
1246       $acl -> save();
1247     }
1248   }
1250   function update_acl_membership($src,$dst)
1251   {
1252     $ldap = $this->config->get_ldap_link();
1253     $ldap->cd($this->config->current['BASE']);
1254     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1255     while($attrs = $ldap->fetch()){
1256       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1257       foreach($acl->gosaAclEntry as $id => $entry){
1258         foreach($entry['members'] as $m_id => $member){
1259           if($m_id == "U:".$src){
1260             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1261             $new = "U:".$dst;
1262             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1263             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Updated acl for user %s on object %s.",$src,$attrs['dn']));
1264           }
1265           if($m_id == "G:".$src){
1266             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1267             $new = "G:".$dst;
1268             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1269             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Updated acl for group %s on object %s.",$src,$attrs['dn']));
1270           }
1271         }
1272       }
1273       $acl -> save();
1274     }
1275   }
1279 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1280 ?>