Code

- Missing gofon.schema in contrib/openldap/slapd.conf
[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::global_get('plist');
136     $plist= $tmp->info;
137     $cats = array();
138     if (isset($this->parent) && $this->parent !== NULL){
139       $oc= array();
140       foreach ($this->parent->by_object as $key => $obj){
141         $oc= array_merge($oc, $obj->objectclasses);
142         if(isset($obj->acl_category)){
143                                         $tmp= str_replace("/","",$obj->acl_category);
144           $cats[$tmp] = $tmp;
145         }
146       }
147       if (in_array_ics('organizationalUnit', $oc)){
148         $this->isContainer= TRUE;
149       }
150     } else {
151       $oc=  $this->attrs['objectClass'];
152     }
154     /* Extract available categories from plugin info list */
155     foreach ($plist as $class => $acls){
157       /* Only feed categories */
158       if (isset($acls['plCategory'])){
160         /* Walk through supplied list and feed only translated categories */
161         foreach($acls['plCategory'] as $idx => $data){
163           /* Non numeric index means -> base object containing more informations */
164           if (preg_match('/^[0-9]+$/', $idx)){
166             if (!isset($this->ocMapping[$data])){
167               $this->ocMapping[$data]= array();
168               $this->ocMapping[$data][]= '0';
169             }
171             if(isset($cats[$data])){
172               $this->myAclObjects[$data.'/'.$class]= $acls['plDescription'];
173             }
174             $this->ocMapping[$data][]= $class;
175           } else {
176             if (!isset($this->ocMapping[$idx])){
177               $this->ocMapping[$idx]= array();
178               $this->ocMapping[$idx][]= '0';
179             }
180             $this->ocMapping[$idx][]= $class;
181             $this->aclObjects[$idx]= $data['description'];
183             /* Additionally filter the classes we're interested in in "self edit" mode */
184             if (is_array($data['objectClass'])){
185               foreach($data['objectClass'] as $objectClass){
186                 if (in_array_ics($objectClass, $oc)){
187                   $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
188                   break;
189                 }
190               }
191             } else {
192               if (in_array_ics($data['objectClass'], $oc)){
193                 $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
194               }
195             }
196           }
198         }
199       }
200     }
201     $this->aclObjects['all']= '*&nbsp;'._("All categories");
202     $this->ocMapping['all']= array('0' => 'all');
204     /* Sort categories */
205     asort($this->aclObjects);
207     /* Fill acl types */
208     if ($this->isContainer){
209       $this->aclTypes= array("reset" => _("Reset ACLs"),
210                              "one" => _("One level"),
211                              "base" => _("Current object"),
212                              "sub" => _("Complete subtree"),
213                              "psub" => _("Complete subtree (permanent)"),
214                              "role" => _("Use ACL defined in role"));
215     } else {
216       $this->aclTypes= array("base" => _("Current object"),
217           "role" => _("Use ACL defined in role"));
218     }
219     asort($this->aclTypes);
220     $this->targets= array("user" => _("Users"), "group" => _("Groups"));
221     asort($this->targets);
223     /* Finally - we want to get saved... */
224     $this->is_account= TRUE;
225   }
228   function execute()
229   {
230     /* Call parent execute */
231     plugin::execute();
233     $tmp= session::global_get('plist');
234     $plist= $tmp->info;
236     /* Handle posts */
237     if (isset($_POST['new_acl'])){
238       $this->dialogState= 'create';
239       $this->dialog= TRUE;
240       $this->currentIndex= count($this->gosaAclEntry);
241       $this->loadAclEntry(TRUE);
242     }
244     $new_acl= array();
245     $aclDialog= FALSE;
246     $firstedit= FALSE;
248     /* Act on HTML post and gets here.
249      */
250     if(isset($_GET['id']) && isset($_GET['act']) && $_GET['act'] == "edit"){
251       $id = trim($_GET['id']);
252       $this->dialogState= 'create';
253       $firstedit= TRUE;
254       $this->dialog= TRUE;
255       $this->currentIndex= $id;
256       $this->loadAclEntry();
257     }
259     foreach($_POST as $name => $post){
261       /* Actions... */
262       if (preg_match('/^acl_edit_.*_x/', $name)){
263         $this->dialogState= 'create';
264         $firstedit= TRUE;
265         $this->dialog= TRUE;
266         $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
267         $this->loadAclEntry();
268         continue;
269       }
271       if (preg_match('/^cat_edit_.*_x/', $name)){
272         $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name);
273         $this->dialogState= 'edit';
274         foreach ($this->ocMapping[$this->aclObject] as $oc){
275           if (isset($this->aclContents[$oc])){
276             $this->savedAclContents[$oc]= $this->aclContents[$oc];
277           }
278         }
279         continue;
280       }
282       /* Only handle posts, if we allowed to modify ACLs */
283       if(!$this->acl_is_writeable("")){
284         continue;
285       }
287       if (preg_match('/^acl_del_.*_x/', $name)){
288         unset($this->gosaAclEntry[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]);
289         continue;
290       }
292       if (preg_match('/^cat_del_.*_x/', $name)){
293         $idx= preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name);
294         foreach ($this->ocMapping[$idx] as $key){
295           unset($this->aclContents["$idx/$key"]);
296         }
297         continue;
298       }
300       /* Sorting... */
301       if (preg_match('/^sortup_.*_x/', $name)){
302         $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name);
303         if ($index > 0){
304           $tmp= $this->gosaAclEntry[$index];
305           $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index-1];
306           $this->gosaAclEntry[$index-1]= $tmp;
307         }
308         continue;
309       }
310       if (preg_match('/^sortdown_.*_x/', $name)){
311         $index= preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name);
312         if ($index < count($this->gosaAclEntry)-1){
313           $tmp= $this->gosaAclEntry[$index];
314           $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index+1];
315           $this->gosaAclEntry[$index+1]= $tmp;
316         }
317         continue;
318       }
320       /* ACL saving... */
321       if (preg_match('/^acl_.*_[^xy]$/', $name)){
322         list($dummy, $object, $attribute, $value)= split('_', $name);
324         /* Skip for detection entry */
325         if ($object == 'dummy') {
326           continue;
327         }
329         /* Ordinary ACLs */
330         if (!isset($new_acl[$object])){
331           $new_acl[$object]= array();
332         }
333         if (isset($new_acl[$object][$attribute])){
334           $new_acl[$object][$attribute].= $value;
335         } else {
336           $new_acl[$object][$attribute]= $value;
337         }
338       }
340       if(isset($_POST['selected_role'])){
341         $this->aclContents = "";
342         $this->aclContents = base64_decode($_POST['selected_role']);
343       }
344     }
346     if(isset($_POST['acl_dummy_0_0_0'])){
347       $aclDialog= TRUE;
348     }
350     if($this->acl_is_writeable("")){
351       
352       /* Only be interested in new acl's, if we're in the right _POST place */
353       if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
355         foreach ($this->ocMapping[$this->aclObject] as $oc){
357           if(isset($this->aclContents[$oc]) && is_array($this->aclContents)){
358             unset($this->aclContents[$oc]);
359           }elseif(isset($this->aclContents[$this->aclObject.'/'.$oc]) && is_array($this->aclContents)){
360             unset($this->aclContents[$this->aclObject.'/'.$oc]);
361           }else{
362 #          trigger_error("Huhm?");
363           }
364           if (isset($new_acl[$oc]) && is_array($new_acl)){
365             $this->aclContents[$oc]= $new_acl[$oc];
366           }
367           if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)){
368             $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
369           }
370         }
371       }
373       /* Save new acl in case of base edit mode */
374       if ($this->aclType == 'base' && !$firstedit){
375         $this->aclContents= $new_acl;
376       }
377     }
379     /* Cancel new acl? */
380     if (isset($_POST['cancel_new_acl'])){
381       $this->dialogState= 'head';
382       $this->dialog= FALSE;
383       if ($this->wasNewEntry){
384         unset ($this->gosaAclEntry[$this->currentIndex]);
385       }
386     }
388     /* Save common values */
389     if($this->acl_is_writeable("")){
390       foreach (array("aclType","aclFilter", "aclObject", "target") as $key){
391         if (isset($_POST[$key])){
392           $this->$key= validate($_POST[$key]);
393         }
394       }
395     }
397     /* Store ACL in main object? */
398     if (isset($_POST['submit_new_acl'])){
399       $this->gosaAclEntry[$this->currentIndex]['type']= $this->aclType;
400       $this->gosaAclEntry[$this->currentIndex]['members']= $this->recipients;
401       $this->gosaAclEntry[$this->currentIndex]['acl']= $this->aclContents;
402       $this->gosaAclEntry[$this->currentIndex]['filter']= $this->aclFilter;
403       $this->dialogState= 'head';
404       $this->dialog= FALSE;
405     }
407     /* Cancel edit acl? */
408     if (isset($_POST['cancel_edit_acl'])){
409       $this->dialogState= 'create';
410       foreach ($this->ocMapping[$this->aclObject] as $oc){
411         if (isset($this->savedAclContents[$oc])){
412           $this->aclContents[$oc]= $this->savedAclContents[$oc];
413         }
414       }
415     }
417     /* Save edit acl? */
418     if (isset($_POST['submit_edit_acl'])){
419       $this->dialogState= 'create';
420     }
422     /* Add acl? */
423     if (isset($_POST['add_acl']) && $_POST['aclObject'] != ""){
424       $this->dialogState= 'edit';
425       $this->savedAclContents= array();
426       foreach ($this->ocMapping[$this->aclObject] as $oc){
427         if (isset($this->aclContents[$oc])){
428           $this->savedAclContents[$oc]= $this->aclContents[$oc];
429         }
430       }
431     }
433     /* Add to list? */
434     if (isset($_POST['add']) && isset($_POST['source'])){
435       foreach ($_POST['source'] as $key){
436         if ($this->target == 'user'){
437           $this->recipients[$key]= $this->users[$key];
438         }
439         if ($this->target == 'group'){
440           $this->recipients[$key]= $this->groups[$key];
441         }
442       }
443       ksort($this->recipients);
444     }
446     /* Remove from list? */
447     if (isset($_POST['del']) && isset($_POST['recipient'])){
448       foreach ($_POST['recipient'] as $key){
449           unset($this->recipients[$key]);
450       }
451     }
453     /* Create templating instance */
454     $smarty= get_smarty();
455     $smarty->assign("acl_readable",$this->acl_is_readable(""));
456     if(!$this->acl_is_readable("")){
457       return ($smarty->fetch (get_template_path('acl.tpl')));
458     }
460     if ($this->dialogState == 'head'){
461       /* Draw list */
462       $aclList= new divSelectBox("aclList");
463       $aclList->SetHeight(450);
464       
465       /* Fill in entries */
466       foreach ($this->gosaAclEntry as $key => $entry){
467         if(!$this->acl_is_readable("")) continue;
469         $action ="";      
471         if($this->acl_is_readable("")){
472           $link = "<a href=?plug=".$_GET['plug']."&amp;id=".$key."&amp;act=edit>".$this->assembleAclSummary($entry)."</a>";
473         }else{
474           $link = $this->assembleAclSummary($entry);
475         }
476   
477         $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
478         $field2= array("string" => $link);
480         if($this->acl_is_writeable("")){
481           $action.= "<input type='image' name='sortup_$key' alt='up' 
482             title='"._("Up")."' src='images/lists/sort-up.png' align='top'>";
483           $action.= "<input type='image' name='sortdown_$key' alt='down' 
484             title='"._("Down")."' src='images/lists/sort-down.png'>";
485         } 
486     
487         if($this->acl_is_readable("")){
488           $action.= "<input class='center' type='image' src='images/lists/edit.png' 
489             alt='"._("Edit")."' name='acl_edit_$key' title='".msgPool::editButton(_("ACL"))."'>";
490         }
491         if($this->acl_is_removeable("")){
492           $action.= "<input class='center' type='image' src='images/lists/trash.png' 
493             alt='"._("Delete")."' name='acl_del_$key' title='".msgPool::delButton(_("ACL"))."'>";
494         }
496         $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
497         $aclList->AddEntry(array($field1, $field2, $field3));
498       }
500       $smarty->assign("aclList", $aclList->DrawList());
501     }
503     if ($this->dialogState == 'create'){
504       /* Draw list */
505       $aclList= new divSelectBox("aclList");
506       $aclList->SetHeight(150);
508       /* Add settings for all categories to the (permanent) list */
509       foreach ($this->aclObjects as $section => $dsc){
510         $summary= "";
511         foreach($this->ocMapping[$section] as $oc){
512           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
513               $this->aclContents[$oc][0] != ""){
515             $summary.= "$oc, ";
516             continue;
517           }
518           if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
519             $summary.= "$oc, ";
520             continue;
521           }
522           if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
523             $summary.= "$oc, ";
524           }
525         }
527         /* Set summary... */
528         if ($summary == ""){
529           $summary= '<i>'._("No ACL settings for this category!").'</i>';
530         } else {
531           $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary));
532         }
534         $actions ="";
535         if($this->acl_is_readable("")){
536           $actions= "<input class='center' type='image' src='images/lists/edit.png' 
537             alt='"._("Edit")."' name='cat_edit_$section' title='".msgPool::editButton(_("category ACL"))."'>";
538         }
539         if($this->acl_is_removeable()){
540           $actions.= "<input class='center' type='image' src='images/lists/trash.png' 
541             alt='"._("Delete")."' name='cat_del_$section' title='".msgPool::delButton(_("category ACL"))."'>";
542         }   
544         $field1= array("string" => $dsc, "attach" => "style='width:100px'");
545         $field2= array("string" => $summary);
546         $field3= array("string" => $actions, "attach" => "style='border-right:0px;width:50px'");
547         $aclList->AddEntry(array($field1, $field2, $field3));
548       }
550       $smarty->assign("aclList", $aclList->DrawList());
551       $smarty->assign("aclType", $this->aclType);
552       $smarty->assign("aclFilter", $this->aclFilter);
553       $smarty->assign("aclTypes", $this->aclTypes);
554       $smarty->assign("target", $this->target);
555       $smarty->assign("targets", $this->targets);
557       /* Assign possible target types */
558       $smarty->assign("targets", $this->targets);
559       foreach ($this->attributes as $attr){
560         $smarty->assign($attr, $this->$attr);
561       }
564       /* Generate list */
565       $tmp= array();
566       foreach (array("user" => "users", "group" => "groups") as $field => $arr){
567         if ($this->target == $field){
568           foreach ($this->$arr as $key => $value){
569             if (!isset($this->recipients[$key])){
570               $tmp[$key]= $value;
571             }
572           }
573         }
574       }
575       $smarty->assign('sources', $tmp);
576       $smarty->assign('recipients', $this->recipients);
578       /* Acl selector if scope is base */
579       if ($this->aclType == 'base'){
580         $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
581       }
583       /* Role selector if scope is base */
584       if ($this->aclType == 'role'){
585         $smarty->assign('roleSelector', "Role selector");#, $this->buildRoleSelector($this->myAclObjects));
586         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
587       }
588     }
590     if ($this->dialogState == 'edit'){
591       $smarty->assign('headline', sprintf(_("Edit ACL for '%s' - scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
593       /* Collect objects for selected category */
594       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
595         if ($idx == 0){
596           continue;
597         }
598         $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
599       }
600       if ($this->aclObject == 'all'){
601         $aclObjects['all']= _("All objects in current subtree");
602       }
604       /* Role selector if scope is base */
605       if ($this->aclType == 'role'){
606         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
607       } else {
608         $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
609       }
610     }
612     /* Show main page */
613     $smarty->assign("dialogState", $this->dialogState);
614    
615     /* Assign acls */ 
616     $smarty->assign("acl_createable",$this->acl_is_createable());
617     $smarty->assign("acl_writeable" ,$this->acl_is_writeable(""));
618     $smarty->assign("acl_readable"  ,$this->acl_is_readable(""));
619     $smarty->assign("acl_removeable",$this->acl_is_removeable());
621     return ($smarty->fetch (get_template_path('acl.tpl')));
622   }
625   function sort_by_priority($list)
626   {
627     $tmp= session::global_get('plist');
628     $plist= $tmp->info;
629     asort($plist);
630     $newSort = array();
632     foreach($list as $name => $translation){
633       $na  =  preg_replace("/^.*\//","",$name);
634       $prio = 0;
635       if(isset($plist[$na]['plPriority'])){
636         $prio=  $plist[$na]['plPriority'] ;
637       }
639       $newSort[$name] = $prio;
640     }
642     asort($newSort);
644     $ret = array();
645     foreach($newSort as $name => $prio){
646       $ret[$name] = $list[$name];
647     }
648     return($ret);
649   }
652   function buildRoleSelector($list)
653   {
654     $D_List =new divSelectBox("Acl_Roles");
655  
656     $selected = $this->aclContents;
657     if(!is_string($this->aclContents) || !isset($list[$this->aclContents])){
658       $selected = key($list);
659     }
661     $str ="";
662     foreach($list as $dn => $values){
664       if($dn == $selected){    
665         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."' checked>";
666       }else{
667         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."'>";
668       }
669  
670       $field1 = array("string" => $option) ;
671       $field2 = array("string" => $values['cn'], "attach" => "style='width:200px;'") ;
672       $field3 = array("string" => $values['description'],"attach" => "style='border-right:0px;'") ;
674       $D_List->AddEntry(array($field1,$field2,$field3));
675     }
676     return($D_List->DrawList());
677   } 
680   function buildAclSelector($list)
681   {
682     $display= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
683     $cols= 3;
684     $tmp= session::global_get('plist');
685     $plist= $tmp->info;
686     asort($plist);
688     /* Add select all/none buttons */
689     $style = "style='width:100px;'";
691     if($this->acl_is_writeable("")){
692       $display .= "<input ".$style." type='button' name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" value='Toggle C'>";
693       $display .= "<input ".$style." type='button' name='toggle_all_move'   onClick=\"acl_toggle_all('_0_m$');\" value='Toggle M'>";
694       $display .= "<input ".$style." type='button' name='toggle_all_remove' onClick=\"acl_toggle_all('_0_d$');\" value='Toggle D'> - ";
695       $display .= "<input ".$style." type='button' name='toggle_all_read'   onClick=\"acl_toggle_all('_0_r$');\" value='Toggle R'>";
696       $display .= "<input ".$style." type='button' name='toggle_all_write'  onClick=\"acl_toggle_all('_0_w$');\" value='Toggle W'> - ";
698       $display .= "<input ".$style." type='button' name='toggle_all_sub_read'  onClick=\"acl_toggle_all('[^0]_r$');\" value='R+'>";
699       $display .= "<input ".$style." type='button' name='toggle_all_sub_write'  onClick=\"acl_toggle_all('[^0]_w$');\" value='W+'>";
701       $display .= "<br>";
703       $style = "style='width:50px;'";
704       $display .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
705       $display .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
706       $display .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
707       $display .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
708       $display .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
709       $display .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
710       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
711       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
712       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
713       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
715       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('[^0]_r$',true);\" value='R+'>";
716       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('[^0]_r$',false);\" value='R-'>";
717       $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('[^0]_w$',true);\" value='W+'>";
718       $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('[^0]_w$',false);\" value='W-'>";
719     }
721     /* Build general objects */
722     $list =$this->sort_by_priority($list);
723     foreach ($list as $key => $name){
725       /* Create sub acl if it does not exist */
726       if (!isset($this->aclContents[$key])){
727         $this->aclContents[$key]= array();
728         $this->aclContents[$key][0]= '';
729       }
730       $currentAcl= $this->aclContents[$key];
732       /* Get the overall plugin acls 
733        */
734       $overall_acl ="";
735       if(isset($currentAcl[0])){
736         $overall_acl = $currentAcl[0];
737       }
739       /* Object header */
740                         $tname= preg_replace("/[^a-z0-9]/i","_",$name);
741       if(session::global_get('js')) {
742         if(isset($_SERVER['HTTP_USER_AGENT']) && 
743              (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || 
744              (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) {
745           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
746                      "\n  <tr>".
747                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
748                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
749                      "\n    <input type='button' onclick='divtoggle(\"$tname\");' value='"._("Show/hide advanced settings")."' /></td>".
750                      "\n  </tr>";
751         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
752           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
753                      "\n  <tr>".
754                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
755                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
756                      "\n    <input type='button' onclick='divtoggle(\"$tname\");' value='"._("Show/hide advanced settings")."' /></td>".
757                      "\n  </tr>";
758         } else {
759           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
760                      "\n  <tr>".
761                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
762                      "\n  </tr>";
763         }
764       } else {
765           $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
766                      "\n  <tr>".
767                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
768                      "\n  </tr>";
769       }
771       /* Generate options */
772       $spc= "&nbsp;&nbsp;";
773       $options= $this->mkchkbx($key."_0_c",  _("Create objects"), preg_match('/c/', $overall_acl)).$spc;
774       $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $overall_acl)).$spc;
775       $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $overall_acl)).$spc;
776       if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
777         $options.= $this->mkchkbx($key."_0_s", _("Grant permission to owner"), preg_match('/s/', $overall_acl)).$spc;
778       }
780       /* Global options */
781       $more_options= $this->mkchkbx($key."_0_r",  _("read"), preg_match('/r/', $overall_acl)).$spc;
782       $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl));
784       $display.= "\n  <tr>".
785                  "\n    <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
786                  "\n    <td style='background-color:#D4D4D4'>&nbsp;"._("Complete object").": $more_options</td>".
787                  "\n  </tr>";
789       /* Walk through the list of attributes */
790       $cnt= 1;
791       $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls'];
792       if(session::global_get('js')) {
793         if(isset($_SERVER['HTTP_USER_AGENT']) && 
794             (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) {
795           $display.= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
796                      "\n    <td colspan=".$cols.">".
797                      "\n      <div id='$tname' style='overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
798                      "\n        <table style='width:100%;'>";
799         } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
800           $display.= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
801                      "\n    <td colspan=".$cols.">".
802                      "\n      <div id='$tname' style='position:absolute;overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
803                      "\n        <table style='width:100%;'>";
804         }else{
805         }
806       }
807       foreach($splist as $attr => $dsc){
809         /* Skip pl* attributes, they are internal... */
810         if (preg_match('/^pl[A-Z]+.*$/', $attr)){
811           continue;
812         }
814         /* Open table row */
815         if ($cnt == 1){
816           $display.= "\n  <tr>";
817         }
819         /* Close table row */
820         if ($cnt == $cols){
821           $cnt= 1;
822           $rb= "";
823           $end= "\n  </tr>";
824         } else {
825           $cnt++;
826           $rb= "border-right:1px solid #A0A0A0;";
827           $end= "";
828         }
830         /* Collect list of attributes */
831         $state= "";
832         if (isset($currentAcl[$attr])){
833           $state= $currentAcl[$attr];
834         }
835         $display.= "\n    <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100/$cols)."%'>".
836                    "\n      <b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."</td>$end";
837       }
838       
839       /* Fill missing td's if needed */
840       if (--$cnt != $cols && $cnt != 0){
841        $display.= str_repeat("\n    <td style='border-top:1px solid #A0A0A0; width:".(int)(100/$cols)."%'>&nbsp;</td>", $cols-$cnt); 
842       }
844       if(session::global_get('js')) {
845         if(isset($_SERVER['HTTP_USER_AGENT']) && 
846             (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || 
847             (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT'])) || 
848             (preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT']))) {
849           $display.= "\n        </table>".
850                      "\n      </div>".
851                      "\n    </td>".
852                      "\n  </tr>";
853         }
854       }
856       $display.= "\n</table><br />\n";
857     }
859     return ($display);
860   }
863   function mkchkbx($name, $text, $state= FALSE)
864   {
865     $state= $state?"checked":"";
866     if($this->acl_is_writeable("")){
867                         $tname= preg_replace("/[^a-z0-9]/i","_",$name);
868       return "\n      <input id='acl_$tname' type=checkbox name='acl_$name' $state>".
869         "\n      <label for='acl_$tname'>$text</label>";
870     }else{
871       return "\n <input type='checkbox' disabled name='dummy_".microtime(1)."' $state>$text";
872     }
873   }
876   function mkrwbx($name, $state= "")
877   {
878     $rstate= preg_match('/r/', $state)?'checked':'';
879     $wstate= preg_match('/w/', $state)?'checked':'';
880                 $tname= preg_replace("/[^a-z0-9]/i","_",$name);
881       
882     if($this->acl_is_writeable("")){
883       return ("\n      <input id='acl_".$tname."_r' type=checkbox name='acl_${name}_r' $rstate>".
884           "\n      <label for='acl_".$tname."_r'>"._("read")."</label>".
885           "\n      <input id='acl_".$tname."_w' type=checkbox name='acl_${name}_w' $wstate>".
886           "\n      <label for='acl_".$tname."_w'>"._("write")."</label>");
887     }else{
888       return ("\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read").
889           "\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write"));
890     }
891   }
894   static function explodeACL($acl)
895   {
897     $list= split(':', $acl);
898     if(count($list) == 5){
899       list($index, $type,$member,$permission,$filter)= $list;
900       $filter = base64_decode($filter);
901     }else{
902       $filter = "";
903       list($index, $type,$member,$permission)= $list;
904     }
906     $a= array( $index => array("type" => $type,
907                                "filter"=> $filter,
908                                "members" => acl::extractMembers($acl,$type == "role")));
909    
910     /* Handle different types */
911     switch ($type){
913       case 'psub':
914       case 'sub':
915       case 'one':
916       case 'base':
917         $a[$index]['acl']= acl::extractACL($acl);
918         break;
919       
920       case 'role':
921         $a[$index]['acl']= base64_decode(preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl));
922         break;
924       case 'reset':
925         break;
926       
927       default:
928         msg_dialog::display(_("Internal error"), sprintf(_("Unkown ACL type '%s'!"), $type), ERROR_DIALOG);
929         $a= array();
930     }
931     return ($a);
932   }
935   static function extractMembers($acl,$role = FALSE)
936   {
937     global $config;
938     $a= array();
940     /* Rip acl off the string, seperate by ',' and place it in an array */
941     if($role){
942       $ms= preg_replace('/^[^:]+:[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
943     }else{
944       $ms= preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
945     }
946     if ($ms == $acl){
947       return $a;
948     }
949     $ma= split(',', $ms);
951     /* Decode dn's, fill with informations from LDAP */
952     $ldap= $config->get_ldap_link();
953     foreach ($ma as $memberdn){
954       $dn= base64_decode($memberdn);
955       $ldap->cat($dn, array('cn', 'objectClass', 'description', 'uid'));
957       /* Found entry... */
958       if ($ldap->count()){
959         $attrs= $ldap->fetch();
960         if (in_array_ics('gosaAccount', $attrs['objectClass'])){
961           $a['U:'.$dn]= $attrs['cn'][0]." [".$attrs['uid'][0]."]";
962         } else {
963           $a['G:'.$dn]= $attrs['cn'][0];
964           if (isset($attrs['description'][0])){
965             $a['G:'.$dn].= " [".$attrs['description'][0]."]";
966           }
967         }
969       /* ... or not */
970       } else {
971         $a['U:'.$dn]= sprintf(_("Unknown entry '%s'!"), $dn);
972       }
973     }
975     return ($a);
976   }
979   static function extractACL($acl)
980   {
981     /* Rip acl off the string, seperate by ',' and place it in an array */
982     $as= preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
983     $aa= split(',', $as);
984     $a= array();
986     /* Dis-assemble single ACLs */
987     foreach($aa as $sacl){
988       
989       /* Dis-assemble field ACLs */
990       $ao= split('#', $sacl);
991       $gobject= "";
992       foreach($ao as $idx => $ssacl){
994         /* First is department with global acl */
995         $object= preg_replace('/^([^;]+);.*$/', '\1', $ssacl);
996         $gacl=   preg_replace('/^[^;]+;(.*)$/', '\1', $ssacl);
997         if ($idx == 0){
998           /* Create hash for this object */
999           $gobject= $object;
1000           $a[$gobject]= array();
1002           /* Append ACL if set */
1003           if ($gacl != ""){
1004             $a[$gobject]= array($gacl);
1005           }
1006         } else {
1008           /* All other entries get appended... */
1009           list($field, $facl)= split(';', $ssacl);
1010           $a[$gobject][$field]= $facl;
1011         }
1013       }
1014     }
1016     return ($a);
1017   }
1019   
1020   function assembleAclSummary($entry)
1021   {
1022     $summary= "";
1024     /* Summarize ACL */
1025     if (isset($entry['acl'])){
1026       $acl= "";
1028       if($entry['type'] == "role"){
1030         if(isset($this->roles[$entry['acl']])){  
1031           $summary.= sprintf(_("Role: %s"), $this->roles[$entry['acl']]['cn']);
1032         }else{
1033           $summary.= sprintf(_("Role: %s"), "<i>"._("unknown role")."</i>");
1034         }
1035       }else{
1036         foreach ($entry['acl'] as $name => $object){
1037           if (count($object)){
1038             $acl.= "$name, ";
1039           }
1040         }
1041         $summary.= sprintf(_("Contains settings for these objects: %s"), preg_replace('/, $/', '', $acl));
1042       }
1043     }
1045     /* Summarize members */
1046     if ($summary != ""){
1047       $summary.= ", ";
1048     }
1049     if (count($entry['members'])){
1050       $summary.= _("Members").": ";
1051       foreach ($entry['members'] as $cn){
1052         $cn= preg_replace('/ \[.*$/', '', $cn);
1053         $summary.= $cn.", ";
1054       }
1055     } else {
1056       $summary.= _("ACL takes effect for all users");
1057     }
1059     return (preg_replace('/, $/', '', $summary));
1060   }
1063   function loadAclEntry($new= FALSE)
1064   {
1065     /* New entry gets presets... */
1066     if ($new){
1067       $this->aclType= 'base';
1068       $this->aclFilter= "";
1069       $this->recipients= array();
1070       $this->aclContents= array();
1071     } else {
1072       $acl= $this->gosaAclEntry[$this->currentIndex];
1073       $this->aclType= $acl['type'];
1074       $this->recipients= $acl['members'];
1075       $this->aclContents= $acl['acl'];
1076       $this->aclFilter= $acl['filter'];
1077     }
1079     $this->wasNewEntry= $new;
1080   }
1083   function aclPostHandler()
1084   {
1085     if (isset($_POST['save_acl'])){
1086       $this->save();
1087       return TRUE;
1088     }
1090     return FALSE;
1091   }
1093   
1094   function PrepareForCopyPaste($source)
1095   {
1096     plugin::PrepareForCopyPaste($source);
1097     
1098     $dn = $source['dn'];
1099     $acl_c = new acl($this->config, $this->parent,$dn);
1100     $this->gosaAclEntry = $acl_c->gosaAclEntry;
1101   }
1104   function save()
1105   {
1106     /* Assemble ACL's */
1107     $tmp_acl= array();
1108   
1109     foreach ($this->gosaAclEntry as $prio => $entry){
1110       $final= "";
1111       $members= "";
1112       if (isset($entry['members'])){
1113         foreach ($entry['members'] as $key => $dummy){
1114           $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
1115         }
1116       }
1118       if($entry['type'] != "role"){
1119         $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
1120       }else{
1121         $final= $prio.":".$entry['type'].":".base64_encode($entry['acl']).":".preg_replace('/,$/', '', $members);
1122       }
1124       /* ACL's if needed */
1125       if ($entry['type'] != "reset" && $entry['type'] != "role"){
1126         $acl= ":";
1127         if (isset($entry['acl'])){
1128           foreach ($entry['acl'] as $object => $contents){
1130             /* Only save, if we've some contents in there... */
1131             if (count($contents)){
1132               $acl.= $object.";";
1134               foreach($contents as $attr => $permission){
1136                 /* First entry? Its the one for global settings... */
1137                 if ($attr == '0'){
1138                   $acl.= $permission;
1139                 } else {
1140                   $acl.= '#'.$attr.';'.$permission;
1141                 }
1143               }
1144               $acl.= ',';
1145             }
1146             
1147           }
1148         }
1149         $final.= preg_replace('/,$/', '', $acl);
1150       }
1152       /* Append additional filter options 
1153        */
1154       if(!empty($entry['filter'])){
1155         $final .= ":".base64_encode($entry['filter']);
1156       }
1158       $tmp_acl[]= $final;
1159     } 
1161     /* Call main method */
1162     plugin::save();
1164     /* Finally (re-)assign it... */
1165     $this->attrs['gosaAclEntry']= $tmp_acl;
1167     /* Remove acl from this entry if it is empty... */
1168     if (!count($tmp_acl)){
1169       /* Remove attribute */
1170       if ($this->initially_was_account){
1171         $this->attrs['gosaAclEntry']= array();
1172       } else {
1173         if (isset($this->attrs['gosaAclEntry'])){
1174           unset($this->attrs['gosaAclEntry']);
1175         }
1176       }
1178       /* Remove object class */
1179       $this->attrs['objectClass']= array_remove_entries(array('gosaAcl'), $this->attrs['objectClass']);
1180     }    
1182     /* Do LDAP modifications */
1183     $ldap= $this->config->get_ldap_link();
1184     $ldap->cd($this->dn);
1185     $this->cleanup();
1186     $ldap->modify ($this->attrs);
1188     if(count($this->attrs)){
1189       new log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1190     }
1192     if (!$ldap->success()){
1193       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
1194     }
1196     /* Refresh users ACLs */
1197     $ui= get_userinfo();
1198     $ui->loadACL();
1199     session::global_set('ui',$ui);
1200   }
1203   function remove_from_parent()
1204   {
1205     plugin::remove_from_parent();
1207     /* include global link_info */
1208     $ldap= $this->config->get_ldap_link();
1210     $ldap->cd($this->dn);
1211     $this->cleanup();
1212     $ldap->modify ($this->attrs);
1214     new log("remove","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1216     /* Optionally execute a command after we're done */
1217     $this->handle_post_events("remove",array("uid" => $this->uid));
1218   }
1220   
1221   /* Return plugin informations for acl handling */
1222   static function plInfo()
1223   {
1224     return (array(
1225           "plShortName"   => _("ACL"),
1226           "plDescription" => _("ACL")."&nbsp;("._("Access control list").")",
1227           "plSelfModify"  => FALSE,
1228           "plDepends"     => array(),
1229           "plPriority"    => 0,
1230           "plSection"     => array("administration"),
1231           "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
1232                                                           "objectClass"  => array("gosaAcl","gosaRole"))),
1233           "plProvidedAcls"=> array(
1234 //            "cn"          => _("Role name"),
1235 //            "description" => _("Role description")
1236             )
1238           ));
1239   }
1242   /* Remove acls defined for $src */
1243   function remove_acl()
1244   {
1245     $this->remove_acl_for_dn($this->dn);
1246   }
1249   /* Remove acls defined for $src */
1250   function remove_acl_for_dn($src = "")
1251   {
1252     if($src == ""){
1253       $src = $this->dn;
1254     }
1255     $ldap = $this->config->get_ldap_link();
1256     $ldap->cd($this->config->current['BASE']);
1257     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1258     while($attrs = $ldap->fetch()){
1259       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1260       foreach($acl->gosaAclEntry as $id => $entry){
1261         foreach($entry['members'] as $m_id => $member){
1262           if($m_id == "U:".$src){
1263             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1264             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Removed acl for user %s on object %s.",$src,$attrs['dn']));
1265           }
1266           if($m_id == "G:".$src){
1267             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1268             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Removed acl for group %s on object %s.",$src,$attrs['dn']));
1269           }
1270         }
1271       }
1272       $acl -> save();
1273     }
1274   }
1276   function update_acl_membership($src,$dst)
1277   {
1278     $ldap = $this->config->get_ldap_link();
1279     $ldap->cd($this->config->current['BASE']);
1280     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
1281     while($attrs = $ldap->fetch()){
1282       $acl = new acl($this->config,$this->parent,$attrs['dn']);
1283       foreach($acl->gosaAclEntry as $id => $entry){
1284         foreach($entry['members'] as $m_id => $member){
1285           if($m_id == "U:".$src){
1286             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1287             $new = "U:".$dst;
1288             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1289             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Updated acl for user %s on object %s.",$src,$attrs['dn']));
1290           }
1291           if($m_id == "G:".$src){
1292             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
1293             $new = "G:".$dst;
1294             $acl->gosaAclEntry[$id]['members'][$new] = $new;
1295             gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Updated acl for group %s on object %s.",$src,$attrs['dn']));
1296           }
1297         }
1298       }
1299       $acl -> save();
1300     }
1301   }
1305 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1306 ?>