Code

Black tea. First flush. New locales.
[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'];
112             /* Additionally filter the classes we're interested in in "self edit" mode */
113             if (is_array($data['objectClass'])){
114               foreach($data['objectClass'] as $objectClass){
115                 if (in_array_ics($objectClass, $oc)){
116                   $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
117                   break;
118                 }
119               }
120             } else {
121               if (in_array_ics($data['objectClass'], $oc)){
122                 $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription'];
123               }
124             }
125           }
127         }
128       }
129     }
131     /* Sort categories */
132     asort($this->aclObjects);
134     /* Fill acl types */
135     $this->aclTypes= array( "reset" => _("Reset ACL"),
136                              "one" => _("One level"),
137                              "base" => _("Current object"),
138                              "sub" => _("Complete subtree"),
139                              "psub" => _("Complete subtree (permanent)"));
140     asort($this->aclTypes);
142     /* Finally - we want to get saved... */
143     $this->is_account= TRUE;
144     $this->orig_base = $this->base;
145     $this->orig_dn = $this->dn;
146     $this->orig_cn = $this->cn;
148     /* Instanciate base selector */
149     $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
150     $this->baseSelector->setSubmitButton(false);
151     $this->baseSelector->setHeight(300);
152     $this->baseSelector->update(true);
154     $this->updateList();
156     // Prepare lists
157     $this->sectionList = new sortableListing();
158     $this->sectionList->setDeleteable(false);
159     $this->sectionList->setEditable(false);
160     $this->sectionList->setWidth("100%");
161     $this->sectionList->setHeight("400px");
162     $this->sectionList->setColspecs(array('200px','*'));
163     $this->sectionList->setHeader(array(_("Category"),_("Description")));
164     $this->sectionList->setDefaultSortColumn(1);
165     $this->sectionList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
166   }
169   function updateList()
170   {
171       if(!$this->list){
172           $this->list = new sortableListing($this->gosaAclTemplate,array(),TRUE);
173           $this->list->setDeleteable(true);
174           $this->list->setEditable(true);
175           $this->list->setColspecs(array('*'));
176           $this->list->setWidth("100%");
177           $this->list->setHeight("400px");
178           $this->list->setAcl("rwcdm");
179           $this->list->setHeader(array(_("Permissions"),_("Type")));
180       }
183     // Add ACL entries to the listing
184     $lData = array();
185     foreach($this->gosaAclTemplate as $id => $entry){
186        $lData[] = $this->convertForListing($entry);
187     }
188     $this->list->setListData($this->gosaAclTemplate, $lData);
189   }
192   function convertForListing($entry)
193   {
194     $member = implode($entry['members'],", ");
195     $acl = implode(array_keys($entry['acl']),", ");
196     $type = implode(array_keys($entry['acl']),", ");
197     return(array('data' => array($acl, $this->aclTypes[$entry['type']])));
198   }
202   function execute()
203   {
204     /* Call parent execute */
205     plugin::execute();
207     $tmp= session::get('plist');
208     $plist= $tmp->info;
210     /* Handle posts */
211     if (isset($_POST['new_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
212       $this->dialogState= 'create';
213       $this->dialog= TRUE;
214       $this->currentIndex= count($this->gosaAclTemplate);
215       $this->loadAclEntry(TRUE);
216     }
218     $new_acl= array();
219     $aclDialog= FALSE;
220     $firstedit= FALSE;
222     /* Act on HTML post and gets here.
223      */
225     // Get listing actions. Delete or Edit.
226     $this->list->save_object();
227     $lAction = $this->list->getAction();
228     $this->gosaAclTemplate = array_values($this->list->getMaintainedData());
229     if($lAction['action'] == "edit"){
230         $this->currentIndex = $lAction['targets'][0];
231         $this->dialogState= 'create';
232         $firstedit= TRUE;
233         $this->dialog= TRUE;
234         $this->loadAclEntry();
235     }
236     foreach($_POST as $name => $post){
237       if (preg_match('/^cat_edit_/', $name)){
238         $this->aclObject= preg_replace('/^cat_edit_(.*)$/', '\1', $name);
239         $this->dialogState= 'edit';
240         foreach ($this->ocMapping[$this->aclObject] as $oc){
241           if (isset($this->aclContents[$oc])){
242             $this->savedAclContents[$oc]= $this->aclContents[$oc];
243           }
244         }
245         continue;
246       }
248       if(!$this->acl_is_writeable("gosaAclTemplate")){
249         continue;
250       }
252       if (preg_match('/^cat_del_.*/', $name) && $this->acl_is_writeable("gosaAclTemplate")){
253         $idx= preg_replace('/^cat_del_(.*)$/', '\1', $name);
254         foreach ($this->ocMapping[$idx] as $key){
255           if(isset($this->aclContents[$idx])) 
256             unset($this->aclContents[$idx]);
257           if(isset($this->aclContents["$idx/$key"])) 
258             unset($this->aclContents["$idx/$key"]);
259         }
260         continue;
261       }
263       /* ACL saving... */
264       if (preg_match('/^acl_.*_[^xy]$/', $name) && $this->acl_is_writeable("gosaAclTemplate")){
265         list($dummy, $object, $attribute, $value)= explode('_', $name);
267         /* Skip for detection entry */
268         if ($object == 'dummy') {
269           continue;
270         }
272         /* Ordinary ACL */
273         if (!isset($new_acl[$object])){
274           $new_acl[$object]= array();
275         }
276         if (isset($new_acl[$object][$attribute])){
277           $new_acl[$object][$attribute].= $value;
278         } else {
279           $new_acl[$object][$attribute]= $value;
280         }
281       }
282     }
283    
284     if(isset($_POST['acl_dummy_0_0_0'])){
285       $aclDialog= TRUE;
286     }
287  
288     /* Only be interested in new acl's, if we're in the right _POST place */
289     if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
291       foreach ($this->ocMapping[$this->aclObject] as $oc){
292         unset($this->aclContents[$oc]);
293         unset($this->aclContents[$this->aclObject.'/'.$oc]);
294         if (isset($new_acl[$oc])){
295           $this->aclContents[$oc]= $new_acl[$oc];
296         }
297         if (isset($new_acl[$this->aclObject.'/'.$oc])){
298           $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
299         }
300       }
301     }
303     /* Save new acl in case of base edit mode */
304     if (1 == 0 && $this->aclType == 'base' && !$firstedit){
305       $this->aclContents= $new_acl;
306     }
308     /* Cancel new acl? */
309     if (isset($_POST['cancel_new_acl'])){
310       $this->dialogState= 'head';
311       $this->dialog= FALSE;
312       if ($this->wasNewEntry){
313         unset ($this->gosaAclTemplate[$this->currentIndex]);
314       }
315     }
317     /* Store ACL in main object? */
318     if (isset($_POST['submit_new_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
319       $this->gosaAclTemplate[$this->currentIndex]['type']= $this->aclType;
320       $this->gosaAclTemplate[$this->currentIndex]['members']= $this->recipients;
321       $this->gosaAclTemplate[$this->currentIndex]['acl']= $this->aclContents;
322       $this->dialogState= 'head';
323       $this->dialog= FALSE;
324     }
326     /* Cancel edit acl? */
327     if (isset($_POST['cancel_edit_acl'])){
328       $this->dialogState= 'create';
329       foreach ($this->ocMapping[$this->aclObject] as $oc){
330         if (isset($this->savedAclContents[$oc])){
331           $this->aclContents[$oc]= $this->savedAclContents[$oc];
332         }
333       }
334     }
336     /* Save edit acl? */
337     if (isset($_POST['submit_edit_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
338       $this->dialogState= 'create';
339     }
341     /* Add acl? */
342     if (isset($_POST['add_acl']) && $_POST['aclObject'] != "" && $this->acl_is_writeable("gosaAclTemplate")){
343       $this->dialogState= 'edit';
344       $this->savedAclContents= array();
345       foreach ($this->ocMapping[$this->aclObject] as $oc){
346         if (isset($this->aclContents[$oc])){
347           $this->savedAclContents[$oc]= $this->aclContents[$oc];
348         }
349       }
350     }
352     /* Save common values */
353     foreach (array("aclType", "aclObject", "target") as $key){
354       if (isset($_POST[$key]) && $this->acl_is_writeable("gosaAclTemplate")){
355         $this->$key= validate($_POST[$key]);
356       }
357     }
359     /* Create templating instance */
360     $smarty= get_smarty();
363     $smarty->assign("base", $this->baseSelector->render());
365     $tmp = $this->plInfo();
366     foreach($tmp['plProvidedAcls'] as $name => $translation){
367       $smarty->assign($name."ACL",$this->getacl($name));
368     }
370     if ($this->dialogState == 'head'){
371       $this->updateList();
372       $smarty->assign("aclList", $this->list->render());
373     }
375     if ($this->dialogState == 'create'){
379       /* Draw list */
380       $data = $lData = array();
381     
382       // Create a map of all used sections, this allows us to simply hide the remove button
383       //  if no acl is configured for the given section
384       // e.g. ';all;department/country;users/user;
385       $usedList = ";".implode(array_keys($this->aclContents),';').";";
387       /* Add settings for all categories to the (permanent) list */
388       foreach ($this->aclObjects as $section => $dsc){
389         $summary= "";
390         foreach($this->ocMapping[$section] as $oc){
391           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
392               $this->aclContents[$oc][0] != ""){
394             $summary.= "$oc, ";
395             continue;
396           }
397           if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
398             $summary.= "$oc, ";
399             continue;
400           }
401           if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
402             $summary.= "$oc, ";
403           }
404         }
406         /* Set summary... */
407         if ($summary == ""){
408           $summary= '<i>'._("No ACL settings for this category").'</i>';
409         } else {
410           $summary= sprintf(_("ACL for these objects: %s"), preg_replace('/, $/', '', $summary));
411         }
413         $action = "";
414         if($this->acl_is_readable("gosaAclTemplate")){
415           $action.= image('images/lists/edit.png','cat_edit_'.$section,_("Edit category ACL"));
416         }
417         if($this->acl_is_writeable("gosaAclTemplate")  && preg_match("/;".$section."(;|\/)/", $usedList)){
418           $action.= image('images/lists/trash.png','cat_del_'.$section,_("Delete category ACL"));
419         }
420         $data[] = $section;
421         $lData[] = array('data'=>array($dsc, $summary, $action));
422       }
425       $this->sectionList->setListData($data,$lData);
426       $this->sectionList->update();
427       $smarty->assign("aclList", $this->sectionList->render());
429       $smarty->assign("aclType", $this->aclType);
430       $smarty->assign("aclTypes", $this->aclTypes);
431       $smarty->assign("target", $this->target);
433       if ($this->aclType == 'base'){
434         $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
435       }
436     }
438     if ($this->dialogState == 'edit'){
439       $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
441       /* Collect objects for selected category */
442       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
443         if ($idx == 0){
444           continue;
445         }
446         $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
447       }
448       $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
449     }
451     /* Show main page */
452     $smarty->assign("dialogState", $this->dialogState);
454     /* Assign cn and decription if this is a role */
455     foreach(array("cn","description") as $name){
456       $smarty->assign($name,$this->$name);
457     }
458     return ($smarty->fetch (get_template_path('acl_role.tpl',dirname(__FILE__))));
459   }
461   function sort_by_priority($list)
462   {
463     $tmp= session::get('plist');
464     $plist= $tmp->info;
465     asort($plist);
466     $newSort = array();
468     foreach($list as $name => $translation){
469       $na  =  preg_replace("/^.*\//","",$name);
470       if (!isset($plist[$na]['plPriority'])){
471         $prio= 0;
472       } else {
473         $prio=  $plist[$na]['plPriority'] ;
474       }
476       $newSort[$name] = $prio;
477     }
479     asort($newSort);
481     $ret = array();
482     foreach($newSort as $name => $prio){
483       $ret[$name] = $list[$name];
484     }
485     return($ret);
486   }
488   function loadAclEntry($new= FALSE)
489   {
490     /* New entry gets presets... */
491     if ($new){
492       $this->aclType= 'sub';
493       $this->recipients= array();
494       $this->aclContents= array();
495     } else {
496       $acl= $this->gosaAclTemplate[$this->currentIndex];
497       $this->aclType= $acl['type'];
498       $this->recipients= $acl['members'];
499       $this->aclContents= $acl['acl'];
500     }
502     $this->wasNewEntry= $new;
503   }
506   function aclPostHandler()
507   {
508     if (isset($_POST['save_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
509       $this->save();
510       return TRUE;
511     }
513     return FALSE;
514   }
517   function save()
518   {
519     /* Assemble ACL's */
520     $tmp_acl= array();
521     foreach ($this->gosaAclTemplate as $prio => $entry){
522       $final= "";
523       $members= "";
524       if (isset($entry['members'])){
525         foreach ($entry['members'] as $key => $dummy){
526           $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
527         }
528       }
529       $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
531       /* ACL's if needed */
532       if ($entry['type'] != "reset" && $entry['type'] != "role"){
533         $acl= ":";
534         if (isset($entry['acl'])){
535           foreach ($entry['acl'] as $object => $contents){
537             /* Only save, if we've some contents in there... */
538             if (count($contents)){
539               $acl.= $object.";";
541               foreach($contents as $attr => $permission){
543                 /* First entry? Its the one for global settings... */
544                 if ($attr == '0'){
545                   $acl.= $permission;
546                 } else {
547                   $acl.= '#'.$attr.';'.$permission;
548                 }
550               }
551               $acl.= ',';
552             }
553             
554           }
555         }
556         $final.= preg_replace('/,$/', '', $acl);
557       }
559       $tmp_acl[]= $final;
560     } 
562     /* Call main method */
563     plugin::save();
565     /* Finally (re-)assign it... */
566     $this->attrs["gosaAclTemplate"]= $tmp_acl;
568     /* Remove acl from this entry if it is empty... */
569     if (!count($tmp_acl)){
570       /* Remove attribute */
571       if ($this->initially_was_account){
572         $this->attrs["gosaAclTempalte"]= array();
573       } else {
574         if (isset($this->attrs["gosaAclTemplate"])){
575           unset($this->attrs["gosaAclTemplate"]);
576         }
577       }
578     }
580     /* Do LDAP modifications */
581     $ldap= $this->config->get_ldap_link();
583     /* Check if object already exists */
584     $ldap->cat($this->dn);
585     if($ldap->count()){
586       $ldap->cd($this->dn);
587       $this->cleanup();
588       $ldap->modify ($this->attrs);
589       new log("modify","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
590     }else{
591       $ldap->cd($this->config->current['BASE']);
592       $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn));
593       $ldap->cd($this->dn);
594       $ldap->add($this->attrs);
595       new log("create","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
596     }
598     if (!$ldap->success()){
599       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
600     }
602     /* Refresh users ACL */
603     $ui= get_userinfo();
604     $ui->loadACL();
605     session::set('ui',$ui);
606   }
609   function remove_from_parent()
610   {
611     $ldap = $this->config->get_ldap_link();
612     $serach_for = "*:role:".base64_encode($this->dn).":*"; 
613     $ldap->search ("(&(objectClass=gosaACL)(gosaAclEntry=".$serach_for."))",array('dn','cn','sn','givenName','uid'));
614     $all_names = "";
617     $cnt = 3;
618     while(($attrs = $ldap->fetch()) && $cnt){
619       $name = $attrs['dn'];
620       $name = preg_replace("/[ ]/","&nbsp;",$name);
621       $name = "<i>'".$name."'</i>";
622       $all_names .= $name.", ";
623       $cnt --;
624     }
626     if(!empty($all_names)){
627       $all_names = preg_replace("/, $/","",$all_names);
628       if(!$cnt){
629         $all_names .= ", ...";
630       }
631       $all_names = "<span style='text-align:left;'>".$all_names."</span>";
632       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);
633       return;
634     }
635         
636     $ldap->rmDir($this->dn);
637     new log("remove","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
638     if (!$ldap->success()){
639       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
640     }
642     /* Optionally execute a command after we're done */
643     $this->handle_post_events("remove");
645     /* Delete references to object groups */
646     $ldap->cd ($this->config->current['BASE']);
647     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
648     while ($ldap->fetch()){
649       $og= new ogroup($this->config, $ldap->getDN());
650       unset($og->member[$this->dn]);
651       $og->save ();
652       if (!$ldap->success()){
653         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $og->dn, "", get_class()));
654       }
655     }
656   }
659   function save_object()
660   {
661     plugin::save_object();
662     if(isset($_POST['acl_role_posted'])){
663      
664       /* Refresh base */
665       if ($this->acl_is_moveable($this->base)){
666         if (!$this->baseSelector->update()) {
667           msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
668         }
669         if ($this->base != $this->baseSelector->getBase()) {
670           $this->base= $this->baseSelector->getBase();
671           $this->is_modified= TRUE;
672         }
673       }
674     }
675   }
678   function saveCopyDialog()
679   {
680     if(isset($_POST['cn'])){
681       $this->cn = $_POST['cn'];
682     }
683   }
684   
686   function getCopyDialog()
687   {
688     $smarty = get_smarty();
689     $smarty->assign("cn",$this->cn);
690     $str = $smarty->fetch(get_template_path("paste_role.tpl",TRUE,dirname(__FILE__)));
691     $ret = array();
692     $ret['string'] = $str;
693     $ret['status'] = "";
694     return($ret);
695   }
697   
698   function PrepareForCopyPaste($source)
699   {
700     plugin::PrepareForCopyPaste($source);
701     
702     $source_o = new aclrole($this->config,$source['dn']);
703     $this->gosaAclTemplate = $source_o->gosaAclTemplate;
704   }
705   
707   /* Return plugin informations for acl handling  */
708   static function plInfo()
709   {
710     return (array(
711           "plShortName" => _("Role"),
712           "plDescription" => _("Access control roles"),
713           "plSelfModify"  => FALSE,
714           "plDepends"     => array(),
715           "plPriority"    => 0,
716           "plSection"     => array("administration"),
717           "plCategory"    => array("acl"),
718           "plRequirements"=> array(
719               'ldapSchema' => array('gosaAcl' => '>=2.7'),
720               'onFailureDisablePlugin' => array(get_class(), 'aclManagement')
721               ),
722           "plProperties" =>
723           array(
724               array(
725                   "name"          => "aclRoleRDN",
726                   "type"          => "rdn",
727                   "default"       => "ou=aclroles,",
728                   "description"   => _("The 'aclRoleRDN' statement defines the location where new acl roles will be created. The default is 'ou=aclroles,'."),
729                   "check"         => "gosaProperty::isRdn",
730                   "migrate"       => "migrate_aclRoleRDN",
731                   "group"         => "plugin",
732                   "mandatory"     => FALSE
733                   )
734               ),
737           "plProvidedAcls"    => array(
738             "cn"                => _("Name"),
739             "base"              => _("Base"),
740             "description"       => _("Description"),
741             "gosaAclTemplate"      => _("Permissions"))
742         ));
743   }
745   function check()
746   {
747     $message = plugin::check();
749     if(empty($this->cn)){
750       $message[] = msgPool::required(_("Name"));
751     }
752   
753     $ldap = $this->config->get_ldap_link();
754     $ldap->cd($this->config->current['BASE']);
755     if($this->cn != $this->orig_cn){
756       $ldap->search("(&(objectClass=gosaRole)(cn=".$this->cn."))");
757       if($ldap->count()) {
758         while($attrs = $ldap->fetch()){
759           if($attrs['dn'] != $this->orig_dn){
760             $message[] = msgPool::duplicated(_("Name"));
761           }
762         }
763       }
764     } 
765  
766     if(!count($this->gosaAclTemplate)){
767       $message[] = msgPool::required(_("ACL"));
768     }
770     // Check if a wrong base was supplied
771     if(!$this->baseSelector->checkLastBaseUpdate()){
772       $message[]= msgPool::check_base();;
773     }
774  
775     /* Check if we are allowed to create or move this object
776      */
777     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
778       $message[] = msgPool::permCreate();
779     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
780       $message[] = msgPool::permMove();
781     }
783     return($message);
784   }
788 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
789 ?>