Code

plProperty updates
[gosa.git] / gosa-core / plugins / admin / acl / class_aclRole.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 aclrole extends acl
24 {
25   /* Definitions */
26   var $plHeadline= "Access control roles";
27   var $plDescription= "Edit AC roles";
29   /* attribute list for save action */
30   var $attributes= array('gosaAclTemplate',"cn","description");
31   var $objectclasses= array('top','gosaRole');
33   /* Helpers */
34   var $dialogState= "head";
35   var $aclType= "";
36   var $aclObject= "";
37   var $aclContents= array();
38   var $target= "group";
39   var $aclTypes= array();
40   var $aclObjects= array();
41   var $recipients= array();
42   var $isContainer= TRUE;
43   var $currentIndex= 0;
44   var $wasNewEntry= FALSE;
45   var $ocMapping= array();
46   var $savedAclContents= array();
47   var $myAclObjects = array();
49   /* Role attributes */
50   var $gosaAclTemplate= "";
51   var $cn = "";
52   var $orig_cn = "";
53   var $description = "";
54   var $orig_dn;
55   var $orig_base;
56   var $base ="";
57   var $baseSelector;
59   var $list =NULL;
60   var $sectionList = NULL;
62   function aclrole (&$config,  $dn= NULL)
63   {
64     /* Include config object */
65     plugin::plugin($config, $dn);
67     if($this->dn == "new"){
68       $ui = get_userinfo();
69       $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=test,".session::global_get("CurrentMainBase"):$ui->dn);
70     }else{
71       $this->base = preg_replace("/^[^,]+,[^,]+,/","",$this->dn);
72       new log("view","acl/".get_class($this),$this->dn);
73     }
74    
75     /* Load ACL's */
76     $this->gosaAclTemplate= array();
77     if (isset($this->attrs["gosaAclTemplate"])){
78       for ($i= 0; $i<$this->attrs["gosaAclTemplate"]['count']; $i++){
79         $acl= $this->attrs["gosaAclTemplate"][$i];
80         $this->gosaAclTemplate= array_merge($this->gosaAclTemplate, $this->explodeACL($acl));
81       }
82     }
83     ksort($this->gosaAclTemplate);
85     /* Extract available categories from plugin info list */
86     $tmp= session::get('plist');
87     $plist= $tmp->info;
88     $oc = array();
89     foreach ($plist as $class => $acls){
91       /* Only feed categories */
92       if (isset($acls['plCategory'])){
94         /* Walk through supplied list and feed only translated categories */
95         foreach($acls['plCategory'] as $idx => $data){
97           /* Non numeric index means -> base object containing more informations */
98           if (preg_match('/^[0-9]+$/', $idx)){
99             if (!isset($this->ocMapping[$data])){
100               $this->ocMapping[$data]= array();
101               $this->ocMapping[$data][]= '0';
102             }
103             $this->ocMapping[$data][]= $class;
104           } else {
105             if (!isset($this->ocMapping[$idx])){
106               $this->ocMapping[$idx]= array();
107               $this->ocMapping[$idx][]= '0';
108             }
109             $this->ocMapping[$idx][]= $class;
110             $this->aclObjects[$idx]= $data['description'];
113             /* Additionally filter the classes we're interested in in "self edit" mode */
114             if(isset($data['objectClass'])){
115                 if (is_array($data['objectClass'])){
116                     foreach($data['objectClass'] as $objectClass){
117                         if (in_array_ics($objectClass, $oc)){
118                             $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
119                             break;
120                         }
121                     }
122                 } else {
123                     if (in_array_ics($data['objectClass'], $oc)){
124                         $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
125                     }
126                 }
127             }
128           }
130         }
131       }
132     }
134     /* Sort categories */
135     asort($this->aclObjects);
137     /* Fill acl types */
138     $this->aclTypes= array( "reset" => _("Reset ACL"),
139                              "one" => _("One level"),
140                              "base" => _("Current object"),
141                              "sub" => _("Complete subtree"),
142                              "psub" => _("Complete subtree (permanent)"));
143     asort($this->aclTypes);
145     /* Finally - we want to get saved... */
146     $this->is_account= TRUE;
147     $this->orig_base = $this->base;
148     $this->orig_dn = $this->dn;
149     $this->orig_cn = $this->cn;
151     /* Instanciate base selector */
152     $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
153     $this->baseSelector->setSubmitButton(false);
154     $this->baseSelector->setHeight(300);
155     $this->baseSelector->update(true);
157     $this->updateList();
159     // Prepare lists
160     $this->sectionList = new sortableListing();
161     $this->sectionList->setDeleteable(false);
162     $this->sectionList->setEditable(false);
163     $this->sectionList->setWidth("100%");
164     $this->sectionList->setHeight("400px");
165     $this->sectionList->setColspecs(array('200px','*'));
166     $this->sectionList->setHeader(array(_("Category"),_("Description")));
167     $this->sectionList->setDefaultSortColumn(1);
168     $this->sectionList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
169   }
172   function updateList()
173   {
174       if(!$this->list){
175           $this->list = new sortableListing($this->gosaAclTemplate,array(),TRUE);
176           $this->list->setDeleteable(true);
177           $this->list->setEditable(true);
178           $this->list->setColspecs(array('*'));
179           $this->list->setWidth("100%");
180           $this->list->setHeight("400px");
181           $this->list->setAcl("rwcdm");
182           $this->list->setHeader(array(_("Permissions"),_("Type")));
183       }
186     // Add ACL entries to the listing
187     $lData = array();
188     foreach($this->gosaAclTemplate as $id => $entry){
189        $lData[] = $this->convertForListing($entry);
190     }
191     $this->list->setListData($this->gosaAclTemplate, $lData);
192   }
195   function convertForListing($entry)
196   {
197     $member = implode($entry['members'],", ");
198     $acl = implode(array_keys($entry['acl']),", ");
199     $type = implode(array_keys($entry['acl']),", ");
200     return(array('data' => array($acl, $this->aclTypes[$entry['type']])));
201   }
205   function execute()
206   {
207     /* Call parent execute */
208     plugin::execute();
210     $tmp= session::get('plist');
211     $plist= $tmp->info;
213     /* Handle posts */
214     if (isset($_POST['new_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
215       $this->dialogState= 'create';
216       $this->dialog= TRUE;
217       $this->currentIndex= count($this->gosaAclTemplate);
218       $this->loadAclEntry(TRUE);
219     }
221     $new_acl= array();
222     $aclDialog= FALSE;
223     $firstedit= FALSE;
225     /* Act on HTML post and gets here.
226      */
228     // Get listing actions. Delete or Edit.
229     $this->list->save_object();
230     $lAction = $this->list->getAction();
231     $this->gosaAclTemplate = array_values($this->list->getMaintainedData());
232     if($lAction['action'] == "edit"){
233         $this->currentIndex = $lAction['targets'][0];
234         $this->dialogState= 'create';
235         $firstedit= TRUE;
236         $this->dialog= TRUE;
237         $this->loadAclEntry();
238     }
239     foreach($_POST as $name => $post){
240       if (preg_match('/^cat_edit_/', $name)){
241         $this->aclObject= preg_replace('/^cat_edit_(.*)$/', '\1', $name);
242         $this->dialogState= 'edit';
243         foreach ($this->ocMapping[$this->aclObject] as $oc){
244           if (isset($this->aclContents[$oc])){
245             $this->savedAclContents[$oc]= $this->aclContents[$oc];
246           }
247         }
248         continue;
249       }
251       if(!$this->acl_is_writeable("gosaAclTemplate")){
252         continue;
253       }
255       if (preg_match('/^cat_del_.*/', $name) && $this->acl_is_writeable("gosaAclTemplate")){
256         $idx= preg_replace('/^cat_del_(.*)$/', '\1', $name);
257         foreach ($this->ocMapping[$idx] as $key){
258           if(isset($this->aclContents[$idx])) 
259             unset($this->aclContents[$idx]);
260           if(isset($this->aclContents["$idx/$key"])) 
261             unset($this->aclContents["$idx/$key"]);
262         }
263         continue;
264       }
266       /* ACL saving... */
267       if (preg_match('/^acl_.*_[^xy]$/', $name) && $this->acl_is_writeable("gosaAclTemplate")){
268         list($dummy, $object, $attribute, $value)= explode('_', $name);
270         /* Skip for detection entry */
271         if ($object == 'dummy') {
272           continue;
273         }
275         /* Ordinary ACL */
276         if (!isset($new_acl[$object])){
277           $new_acl[$object]= array();
278         }
279         if (isset($new_acl[$object][$attribute])){
280           $new_acl[$object][$attribute].= $value;
281         } else {
282           $new_acl[$object][$attribute]= $value;
283         }
284       }
285     }
286    
287     if(isset($_POST['acl_dummy_0_0_0'])){
288       $aclDialog= TRUE;
289     }
290  
291     /* Only be interested in new acl's, if we're in the right _POST place */
292     if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
294       foreach ($this->ocMapping[$this->aclObject] as $oc){
295         unset($this->aclContents[$oc]);
296         unset($this->aclContents[$this->aclObject.'/'.$oc]);
297         if (isset($new_acl[$oc])){
298           $this->aclContents[$oc]= $new_acl[$oc];
299         }
300         if (isset($new_acl[$this->aclObject.'/'.$oc])){
301           $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
302         }
303       }
304     }
306     /* Save new acl in case of base edit mode */
307     if (1 == 0 && $this->aclType == 'base' && !$firstedit){
308       $this->aclContents= $new_acl;
309     }
311     /* Cancel new acl? */
312     if (isset($_POST['cancel_new_acl'])){
313       $this->dialogState= 'head';
314       $this->dialog= FALSE;
315       if ($this->wasNewEntry){
316         unset ($this->gosaAclTemplate[$this->currentIndex]);
317       }
318     }
320     /* Store ACL in main object? */
321     if (isset($_POST['submit_new_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
322       $this->gosaAclTemplate[$this->currentIndex]['type']= $this->aclType;
323       $this->gosaAclTemplate[$this->currentIndex]['members']= $this->recipients;
324       $this->gosaAclTemplate[$this->currentIndex]['acl']= $this->aclContents;
325       $this->dialogState= 'head';
326       $this->dialog= FALSE;
327     }
329     /* Cancel edit acl? */
330     if (isset($_POST['cancel_edit_acl'])){
331       $this->dialogState= 'create';
332       foreach ($this->ocMapping[$this->aclObject] as $oc){
333         if (isset($this->savedAclContents[$oc])){
334           $this->aclContents[$oc]= $this->savedAclContents[$oc];
335         }
336       }
337     }
339     /* Save edit acl? */
340     if (isset($_POST['submit_edit_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
341       $this->dialogState= 'create';
342     }
344     /* Add acl? */
345     if (isset($_POST['add_acl']) && $_POST['aclObject'] != "" && $this->acl_is_writeable("gosaAclTemplate")){
346       $this->dialogState= 'edit';
347       $this->savedAclContents= array();
348       foreach ($this->ocMapping[$this->aclObject] as $oc){
349         if (isset($this->aclContents[$oc])){
350           $this->savedAclContents[$oc]= $this->aclContents[$oc];
351         }
352       }
353     }
355     /* Save common values */
356     foreach (array("aclType", "aclObject", "target") as $key){
357       if (isset($_POST[$key]) && $this->acl_is_writeable("gosaAclTemplate")){
358         $this->$key= get_post($key);
359       }
360     }
362     /* Create templating instance */
363     $smarty= get_smarty();
366     $smarty->assign("base", $this->baseSelector->render());
368     $tmp = $this->plInfo();
369     foreach($tmp['plProvidedAcls'] as $name => $translation){
370       $smarty->assign($name."ACL",$this->getacl($name));
371     }
373     if ($this->dialogState == 'head'){
374       $this->updateList();
375       $smarty->assign("aclList", $this->list->render());
376     }
378     if ($this->dialogState == 'create'){
382       /* Draw list */
383       $data = $lData = array();
384     
385       // Create a map of all used sections, this allows us to simply hide the remove button
386       //  if no acl is configured for the given section
387       // e.g. ';all;department/country;users/user;
388       $usedList = ";".implode(array_keys($this->aclContents),';').";";
390       /* Add settings for all categories to the (permanent) list */
391       foreach ($this->aclObjects as $section => $dsc){
392         $summary= "";
393         foreach($this->ocMapping[$section] as $oc){
394           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
395               $this->aclContents[$oc][0] != ""){
397             $summary.= "$oc, ";
398             continue;
399           }
400           if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
401             $summary.= "$oc, ";
402             continue;
403           }
404           if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
405             $summary.= "$oc, ";
406           }
407         }
409         /* Set summary... */
410         if ($summary == ""){
411           $summary= '<i>'._("No ACL settings for this category").'</i>';
412         } else {
413           $summary= sprintf(_("ACL for these objects: %s"), preg_replace('/, $/', '', $summary));
414         }
416         $action = "";
417         if($this->acl_is_readable("gosaAclTemplate")){
418           $action.= image('images/lists/edit.png','cat_edit_'.$section,_("Edit category ACL"));
419         }
420         if($this->acl_is_writeable("gosaAclTemplate")  && preg_match("/;".$section."(;|\/)/", $usedList)){
421           $action.= image('images/lists/trash.png','cat_del_'.$section,_("Delete category ACL"));
422         }
423         $data[] = $section;
424         $lData[] = array('data'=>array($dsc, $summary, $action));
425       }
428       $this->sectionList->setListData($data,$lData);
429       $this->sectionList->update();
430       $smarty->assign("aclList", $this->sectionList->render());
432       $smarty->assign("aclType", $this->aclType);
433       $smarty->assign("aclTypes", $this->aclTypes);
434       $smarty->assign("target", $this->target);
436       if ($this->aclType == 'base'){
437         $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
438       }
439     }
441     if ($this->dialogState == 'edit'){
442       $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
444       /* Collect objects for selected category */
445       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
446         if ($idx == 0){
447           continue;
448         }
449         $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
450       }
451       $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
452     }
454     /* Show main page */
455     $smarty->assign("dialogState", $this->dialogState);
457     /* Assign cn and decription if this is a role */
458     foreach(array("cn","description") as $name){
459       $smarty->assign($name,set_post($this->$name));
460     }
461     return ($smarty->fetch (get_template_path('acl_role.tpl',dirname(__FILE__))));
462   }
464   function sort_by_priority($list)
465   {
466     $tmp= session::get('plist');
467     $plist= $tmp->info;
468     asort($plist);
469     $newSort = array();
471     foreach($list as $name => $translation){
472       $na  =  preg_replace("/^.*\//","",$name);
473       if (!isset($plist[$na]['plPriority'])){
474         $prio= 0;
475       } else {
476         $prio=  $plist[$na]['plPriority'] ;
477       }
479       $newSort[$name] = $prio;
480     }
482     asort($newSort);
484     $ret = array();
485     foreach($newSort as $name => $prio){
486       $ret[$name] = $list[$name];
487     }
488     return($ret);
489   }
491   function loadAclEntry($new= FALSE)
492   {
493     /* New entry gets presets... */
494     if ($new){
495       $this->aclType= 'sub';
496       $this->recipients= array();
497       $this->aclContents= array();
498     } else {
499       $acl= $this->gosaAclTemplate[$this->currentIndex];
500       $this->aclType= $acl['type'];
501       $this->recipients= $acl['members'];
502       $this->aclContents= $acl['acl'];
503     }
505     $this->wasNewEntry= $new;
506   }
509   function aclPostHandler()
510   {
511     if (isset($_POST['save_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
512       $this->save();
513       return TRUE;
514     }
516     return FALSE;
517   }
520   function save()
521   {
522     /* Assemble ACL's */
523     $tmp_acl= array();
524     foreach ($this->gosaAclTemplate as $prio => $entry){
525       $final= "";
526       $members= "";
527       if (isset($entry['members'])){
528         foreach ($entry['members'] as $key => $dummy){
529           $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
530         }
531       }
532       $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
534       /* ACL's if needed */
535       if ($entry['type'] != "reset" && $entry['type'] != "role"){
536         $acl= ":";
537         if (isset($entry['acl'])){
538           foreach ($entry['acl'] as $object => $contents){
540             /* Only save, if we've some contents in there... */
541             if (count($contents)){
542               $acl.= $object.";";
544               foreach($contents as $attr => $permission){
546                 /* First entry? Its the one for global settings... */
547                 if ($attr == '0'){
548                   $acl.= $permission;
549                 } else {
550                   $acl.= '#'.$attr.';'.$permission;
551                 }
553               }
554               $acl.= ',';
555             }
556             
557           }
558         }
559         $final.= preg_replace('/,$/', '', $acl);
560       }
562       $tmp_acl[]= $final;
563     } 
565     /* Call main method */
566     plugin::save();
568     /* Finally (re-)assign it... */
569     $this->attrs["gosaAclTemplate"]= $tmp_acl;
571     /* Remove acl from this entry if it is empty... */
572     if (!count($tmp_acl)){
573       /* Remove attribute */
574       if ($this->initially_was_account){
575         $this->attrs["gosaAclTempalte"]= array();
576       } else {
577         if (isset($this->attrs["gosaAclTemplate"])){
578           unset($this->attrs["gosaAclTemplate"]);
579         }
580       }
581     }
583     /* Do LDAP modifications */
584     $ldap= $this->config->get_ldap_link();
586     /* Check if object already exists */
587     $ldap->cat($this->dn);
588     if($ldap->count()){
589       $ldap->cd($this->dn);
590       $this->cleanup();
591       $ldap->modify ($this->attrs);
592       new log("modify","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
593     }else{
594       $ldap->cd($this->config->current['BASE']);
595       $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn));
596       $ldap->cd($this->dn);
597       $ldap->add($this->attrs);
598       new log("create","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
599     }
601     if (!$ldap->success()){
602       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
603     }
605     /* Refresh users ACL */
606     $ui= get_userinfo();
607     $ui->loadACL();
608     session::set('ui',$ui);
609   }
612   function remove_from_parent()
613   {
614     $ldap = $this->config->get_ldap_link();
615     $serach_for = "*:role:".base64_encode($this->dn).":*"; 
616     $ldap->search ("(&(objectClass=gosaACL)(gosaAclEntry=".$serach_for."))",array('dn','cn','sn','givenName','uid'));
617     $all_names = "";
620     $cnt = 3;
621     while(($attrs = $ldap->fetch()) && $cnt){
622       $name = $attrs['dn'];
623       $name = preg_replace("/[ ]/","&nbsp;",$name);
624       $name = "<i>'".$name."'</i>";
625       $all_names .= $name.", ";
626       $cnt --;
627     }
629     if(!empty($all_names)){
630       $all_names = preg_replace("/, $/","",$all_names);
631       if(!$cnt){
632         $all_names .= ", ...";
633       }
634       $all_names = "<span style='text-align:left;'>".$all_names."</span>";
635       msg_dialog::display(_("Object in use"), sprintf(_("This role cannot be removed while it is in use by these objects:")."<br><br>%s", $all_names), WARNING_DIALOG);
636       return;
637     }
638         
639     $ldap->rmDir($this->dn);
640     new log("remove","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
641     if (!$ldap->success()){
642       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
643     }
645     /* Optionally execute a command after we're done */
646     $this->handle_post_events("remove");
648     /* Delete references to object groups */
649     $ldap->cd ($this->config->current['BASE']);
650     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
651     while ($ldap->fetch()){
652       $og= new ogroup($this->config, $ldap->getDN());
653       unset($og->member[$this->dn]);
654       $og->save ();
655       if (!$ldap->success()){
656         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $og->dn, "", get_class()));
657       }
658     }
659   }
662   function save_object()
663   {
664     plugin::save_object();
665     if(isset($_POST['acl_role_posted'])){
666      
667       /* Refresh base */
668       if ($this->acl_is_moveable($this->base)){
669         if (!$this->baseSelector->update()) {
670           msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
671         }
672         if ($this->base != $this->baseSelector->getBase()) {
673           $this->base= $this->baseSelector->getBase();
674           $this->is_modified= TRUE;
675         }
676       }
677     }
678   }
681   function saveCopyDialog()
682   {
683     if(isset($_POST['cn'])){
684       $this->cn = get_post('cn');
685     }
686   }
687   
689   function getCopyDialog()
690   {
691     $smarty = get_smarty();
692     $smarty->assign("cn",set_post($this->cn));
693     $str = $smarty->fetch(get_template_path("paste_role.tpl",TRUE,dirname(__FILE__)));
694     $ret = array();
695     $ret['string'] = $str;
696     $ret['status'] = "";
697     return($ret);
698   }
700   
701   function PrepareForCopyPaste($source)
702   {
703     plugin::PrepareForCopyPaste($source);
704     
705     $source_o = new aclrole($this->config,$source['dn']);
706     $this->gosaAclTemplate = $source_o->gosaAclTemplate;
707   }
708   
710   /* Return plugin informations for acl handling  */
711   static function plInfo()
712   {
713     return (array(
714           "plShortName" => _("Role"),
715           "plDescription" => _("Access control roles"),
716           "plSelfModify"  => FALSE,
717           "plDepends"     => array(),
718           "plPriority"    => 0,
719           "plSection"     => array("administration"),
720           "plCategory"    => array("acl"),
721           "plRequirements"=> array(
722               'ldapSchema' => array('gosaAcl' => '>=2.7'),
723               'onFailureDisablePlugin' => array(get_class(), 'aclManagement')
724               ),
725           "plProperties" =>
726           array(
727               array(
728                   "name"          => "aclRoleRDN",
729                   "type"          => "rdn",
730                   "default"       => "ou=aclroles,",
731                   "description"   => _("RDN for role storage."),
732                   "check"         => "gosaProperty::isRdn",
733                   "migrate"       => "migrate_aclRoleRDN",
734                   "group"         => "plugin",
735                   "mandatory"     => FALSE
736                   )
737               ),
740           "plProvidedAcls"    => array(
741             "cn"                => _("Name"),
742             "base"              => _("Base"),
743             "description"       => _("Description"),
744             "gosaAclTemplate"      => _("Permissions"))
745         ));
746   }
748   function check()
749   {
750     $message = plugin::check();
752     if(empty($this->cn)){
753       $message[] = msgPool::required(_("Name"));
754     }
755   
756     $ldap = $this->config->get_ldap_link();
757     $ldap->cd($this->config->current['BASE']);
758     if($this->cn != $this->orig_cn){
759       $ldap->search("(&(objectClass=gosaRole)(cn=".$this->cn."))");
760       if($ldap->count()) {
761         while($attrs = $ldap->fetch()){
762           if($attrs['dn'] != $this->orig_dn){
763             $message[] = msgPool::duplicated(_("Name"));
764           }
765         }
766       }
767     } 
768  
769     if(!count($this->gosaAclTemplate)){
770       $message[] = msgPool::required(_("ACL"));
771     }
773     // Check if a wrong base was supplied
774     if(!$this->baseSelector->checkLastBaseUpdate()){
775       $message[]= msgPool::check_base();;
776     }
777  
778     /* Check if we are allowed to create or move this object
779      */
780     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
781       $message[] = msgPool::permCreate();
782     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
783       $message[] = msgPool::permMove();
784     }
786     return($message);
787   }
791 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
792 ?>