Code

Updated template
[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     }
130     $this->aclObjects['all']= '*&nbsp;'._("All categories");
131     $this->ocMapping['all']= array('0' => 'all');
133     /* Sort categories */
134     asort($this->aclObjects);
136     /* Fill acl types */
137     $this->aclTypes= array( "reset" => _("Reset ACL"),
138                              "one" => _("One level"),
139                              "base" => _("Current object"),
140                              "sub" => _("Complete subtree"),
141                              "psub" => _("Complete subtree (permanent)"));
142     asort($this->aclTypes);
144     /* Finally - we want to get saved... */
145     $this->is_account= TRUE;
146     $this->orig_base = $this->base;
147     $this->orig_dn = $this->dn;
148     $this->orig_cn = $this->cn;
150     /* Instanciate base selector */
151     $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
152     $this->baseSelector->setSubmitButton(false);
153     $this->baseSelector->setHeight(300);
154     $this->baseSelector->update(true);
156     $this->updateList();
158     // Prepare lists
159     $this->sectionList = new sortableListing();
160     $this->sectionList->setDeleteable(false);
161     $this->sectionList->setEditable(false);
162     $this->sectionList->setWidth("100%");
163     $this->sectionList->setHeight("400px");
164     $this->sectionList->setColspecs(array('200px','*'));
165     $this->sectionList->setHeader(array(_("Category"),_("Description")));
166     $this->sectionList->setDefaultSortColumn(1);
167     $this->sectionList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
168   }
171   function updateList()
172   {
173       if(!$this->list){
174           $this->list = new sortableListing($this->gosaAclTemplate,array(),TRUE);
175           $this->list->setDeleteable(true);
176           $this->list->setEditable(true);
177           $this->list->setColspecs(array('*'));
178           $this->list->setWidth("100%");
179           $this->list->setHeight("400px");
180           $this->list->setAcl("rwcdm");
181           $this->list->setHeader(array(_("Permissions"),_("Type")));
182       }
185     // Add ACL entries to the listing
186     $lData = array();
187     foreach($this->gosaAclTemplate as $id => $entry){
188        $lData[] = $this->convertForListing($entry);
189     }
190     $this->list->setListData($this->gosaAclTemplate, $lData);
191   }
194   function convertForListing($entry)
195   {
196     $member = implode($entry['members'],", ");
197     $acl = implode(array_keys($entry['acl']),", ");
198     $type = implode(array_keys($entry['acl']),", ");
199     return(array('data' => array($acl, $this->aclTypes[$entry['type']])));
200   }
204   function execute()
205   {
206     /* Call parent execute */
207     plugin::execute();
209     $tmp= session::get('plist');
210     $plist= $tmp->info;
212     /* Handle posts */
213     if (isset($_POST['new_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
214       $this->dialogState= 'create';
215       $this->dialog= TRUE;
216       $this->currentIndex= count($this->gosaAclTemplate);
217       $this->loadAclEntry(TRUE);
218     }
220     $new_acl= array();
221     $aclDialog= FALSE;
222     $firstedit= FALSE;
224     /* Act on HTML post and gets here.
225      */
227     // Get listing actions. Delete or Edit.
228     $this->list->save_object();
229     $lAction = $this->list->getAction();
230     $this->gosaAclTemplate = array_values($this->list->getMaintainedData());
231     if($lAction['action'] == "edit"){
232         $this->currentIndex = $lAction['targets'][0];
233         $this->dialogState= 'create';
234         $firstedit= TRUE;
235         $this->dialog= TRUE;
236         $this->loadAclEntry();
237     }
238     foreach($_POST as $name => $post){
239       if (preg_match('/^cat_edit_/', $name)){
240         $this->aclObject= preg_replace('/^cat_edit_(.*)$/', '\1', $name);
241         $this->dialogState= 'edit';
242         foreach ($this->ocMapping[$this->aclObject] as $oc){
243           if (isset($this->aclContents[$oc])){
244             $this->savedAclContents[$oc]= $this->aclContents[$oc];
245           }
246         }
247         continue;
248       }
250       if(!$this->acl_is_writeable("gosaAclTemplate")){
251         continue;
252       }
254       if (preg_match('/^cat_del_.*/', $name) && $this->acl_is_writeable("gosaAclTemplate")){
255         $idx= preg_replace('/^cat_del_(.*)$/', '\1', $name);
256         foreach ($this->ocMapping[$idx] as $key){
257           if(isset($this->aclContents[$idx])) 
258             unset($this->aclContents[$idx]);
259           if(isset($this->aclContents["$idx/$key"])) 
260             unset($this->aclContents["$idx/$key"]);
261         }
262         continue;
263       }
265       /* ACL saving... */
266       if (preg_match('/^acl_.*_[^xy]$/', $name) && $this->acl_is_writeable("gosaAclTemplate")){
267         list($dummy, $object, $attribute, $value)= explode('_', $name);
269         /* Skip for detection entry */
270         if ($object == 'dummy') {
271           continue;
272         }
274         /* Ordinary ACL */
275         if (!isset($new_acl[$object])){
276           $new_acl[$object]= array();
277         }
278         if (isset($new_acl[$object][$attribute])){
279           $new_acl[$object][$attribute].= $value;
280         } else {
281           $new_acl[$object][$attribute]= $value;
282         }
283       }
284     }
285    
286     if(isset($_POST['acl_dummy_0_0_0'])){
287       $aclDialog= TRUE;
288     }
289  
290     /* Only be interested in new acl's, if we're in the right _POST place */
291     if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
293       foreach ($this->ocMapping[$this->aclObject] as $oc){
294         unset($this->aclContents[$oc]);
295         unset($this->aclContents[$this->aclObject.'/'.$oc]);
296         if (isset($new_acl[$oc])){
297           $this->aclContents[$oc]= $new_acl[$oc];
298         }
299         if (isset($new_acl[$this->aclObject.'/'.$oc])){
300           $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
301         }
302       }
303     }
305     /* Save new acl in case of base edit mode */
306     if (1 == 0 && $this->aclType == 'base' && !$firstedit){
307       $this->aclContents= $new_acl;
308     }
310     /* Cancel new acl? */
311     if (isset($_POST['cancel_new_acl'])){
312       $this->dialogState= 'head';
313       $this->dialog= FALSE;
314       if ($this->wasNewEntry){
315         unset ($this->gosaAclTemplate[$this->currentIndex]);
316       }
317     }
319     /* Store ACL in main object? */
320     if (isset($_POST['submit_new_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
321       $this->gosaAclTemplate[$this->currentIndex]['type']= $this->aclType;
322       $this->gosaAclTemplate[$this->currentIndex]['members']= $this->recipients;
323       $this->gosaAclTemplate[$this->currentIndex]['acl']= $this->aclContents;
324       $this->dialogState= 'head';
325       $this->dialog= FALSE;
326     }
328     /* Cancel edit acl? */
329     if (isset($_POST['cancel_edit_acl'])){
330       $this->dialogState= 'create';
331       foreach ($this->ocMapping[$this->aclObject] as $oc){
332         if (isset($this->savedAclContents[$oc])){
333           $this->aclContents[$oc]= $this->savedAclContents[$oc];
334         }
335       }
336     }
338     /* Save edit acl? */
339     if (isset($_POST['submit_edit_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
340       $this->dialogState= 'create';
341     }
343     /* Add acl? */
344     if (isset($_POST['add_acl']) && $_POST['aclObject'] != "" && $this->acl_is_writeable("gosaAclTemplate")){
345       $this->dialogState= 'edit';
346       $this->savedAclContents= array();
347       foreach ($this->ocMapping[$this->aclObject] as $oc){
348         if (isset($this->aclContents[$oc])){
349           $this->savedAclContents[$oc]= $this->aclContents[$oc];
350         }
351       }
352     }
354     /* Save common values */
355     foreach (array("aclType", "aclObject", "target") as $key){
356       if (isset($_POST[$key]) && $this->acl_is_writeable("gosaAclTemplate")){
357         $this->$key= validate($_POST[$key]);
358       }
359     }
361     /* Create templating instance */
362     $smarty= get_smarty();
363     $smarty->assign("usePrototype", "true");
365     $smarty->assign("base", $this->baseSelector->render());
367     $tmp = $this->plInfo();
368     foreach($tmp['plProvidedAcls'] as $name => $translation){
369       $smarty->assign($name."ACL",$this->getacl($name));
370     }
372     if ($this->dialogState == 'head'){
373       $this->updateList();
374       $smarty->assign("aclList", $this->list->render());
375     }
377     if ($this->dialogState == 'create'){
381       /* Draw list */
382       $data = $lData = array();
383     
384       // Create a map of all used sections, this allows us to simply hide the remove button
385       //  if no acl is configured for the given section
386       // e.g. ';all;department/country;users/user;
387       $usedList = ";".implode(array_keys($this->aclContents),';').";";
389       /* Add settings for all categories to the (permanent) list */
390       foreach ($this->aclObjects as $section => $dsc){
391         $summary= "";
392         foreach($this->ocMapping[$section] as $oc){
393           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
394               $this->aclContents[$oc][0] != ""){
396             $summary.= "$oc, ";
397             continue;
398           }
399           if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
400             $summary.= "$oc, ";
401             continue;
402           }
403           if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
404             $summary.= "$oc, ";
405           }
406         }
408         /* Set summary... */
409         if ($summary == ""){
410           $summary= '<i>'._("No ACL settings for this category").'</i>';
411         } else {
412           $summary= sprintf(_("ACL for these objects: %s"), preg_replace('/, $/', '', $summary));
413         }
415         $action = "";
416         if($this->acl_is_readable("gosaAclTemplate")){
417           $action.= image('images/lists/edit.png','cat_edit_'.$section,_("Edit category ACL"));
418         }
419         if($this->acl_is_writeable("gosaAclTemplate")  && preg_match("/;".$section."(;|\/)/", $usedList)){
420           $action.= image('images/lists/trash.png','cat_del_'.$section,_("Delete category ACL"));
421         }
422         $data[] = $section;
423         $lData[] = array('data'=>array($dsc, $summary, $action));
424       }
427       $this->sectionList->setListData($data,$lData);
428       $this->sectionList->update();
429       $smarty->assign("aclList", $this->sectionList->render());
431       $smarty->assign("aclType", $this->aclType);
432       $smarty->assign("aclTypes", $this->aclTypes);
433       $smarty->assign("target", $this->target);
435       if ($this->aclType == 'base'){
436         $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
437       }
438     }
440     if ($this->dialogState == 'edit'){
441       $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
443       /* Collect objects for selected category */
444       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
445         if ($idx == 0){
446           continue;
447         }
448         $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
449       }
450       if ($this->aclObject == 'all'){
451         $aclObjects['all']= _("All objects in current subtree");
452       }
453       $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
454     }
456     /* Show main page */
457     $smarty->assign("dialogState", $this->dialogState);
459     /* Assign cn and decription if this is a role */
460     foreach(array("cn","description") as $name){
461       $smarty->assign($name,$this->$name);
462     }
463     return ($smarty->fetch (get_template_path('acl_role.tpl',dirname(__FILE__))));
464   }
466   function sort_by_priority($list)
467   {
468     $tmp= session::get('plist');
469     $plist= $tmp->info;
470     asort($plist);
471     $newSort = array();
473     foreach($list as $name => $translation){
474       $na  =  preg_replace("/^.*\//","",$name);
475       if (!isset($plist[$na]['plPriority'])){
476         $prio= 0;
477       } else {
478         $prio=  $plist[$na]['plPriority'] ;
479       }
481       $newSort[$name] = $prio;
482     }
484     asort($newSort);
486     $ret = array();
487     foreach($newSort as $name => $prio){
488       $ret[$name] = $list[$name];
489     }
490     return($ret);
491   }
493   function loadAclEntry($new= FALSE)
494   {
495     /* New entry gets presets... */
496     if ($new){
497       $this->aclType= 'sub';
498       $this->recipients= array();
499       $this->aclContents= array();
500     } else {
501       $acl= $this->gosaAclTemplate[$this->currentIndex];
502       $this->aclType= $acl['type'];
503       $this->recipients= $acl['members'];
504       $this->aclContents= $acl['acl'];
505     }
507     $this->wasNewEntry= $new;
508   }
511   function aclPostHandler()
512   {
513     if (isset($_POST['save_acl']) && $this->acl_is_writeable("gosaAclTemplate")){
514       $this->save();
515       return TRUE;
516     }
518     return FALSE;
519   }
522   function save()
523   {
524     /* Assemble ACL's */
525     $tmp_acl= array();
526     foreach ($this->gosaAclTemplate as $prio => $entry){
527       $final= "";
528       $members= "";
529       if (isset($entry['members'])){
530         foreach ($entry['members'] as $key => $dummy){
531           $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
532         }
533       }
534       $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
536       /* ACL's if needed */
537       if ($entry['type'] != "reset" && $entry['type'] != "role"){
538         $acl= ":";
539         if (isset($entry['acl'])){
540           foreach ($entry['acl'] as $object => $contents){
542             /* Only save, if we've some contents in there... */
543             if (count($contents)){
544               $acl.= $object.";";
546               foreach($contents as $attr => $permission){
548                 /* First entry? Its the one for global settings... */
549                 if ($attr == '0'){
550                   $acl.= $permission;
551                 } else {
552                   $acl.= '#'.$attr.';'.$permission;
553                 }
555               }
556               $acl.= ',';
557             }
558             
559           }
560         }
561         $final.= preg_replace('/,$/', '', $acl);
562       }
564       $tmp_acl[]= $final;
565     } 
567     /* Call main method */
568     plugin::save();
570     /* Finally (re-)assign it... */
571     $this->attrs["gosaAclTemplate"]= $tmp_acl;
573     /* Remove acl from this entry if it is empty... */
574     if (!count($tmp_acl)){
575       /* Remove attribute */
576       if ($this->initially_was_account){
577         $this->attrs["gosaAclTempalte"]= array();
578       } else {
579         if (isset($this->attrs["gosaAclTemplate"])){
580           unset($this->attrs["gosaAclTemplate"]);
581         }
582       }
583     }
585     /* Do LDAP modifications */
586     $ldap= $this->config->get_ldap_link();
588     /* Check if object already exists */
589     $ldap->cat($this->dn);
590     if($ldap->count()){
591       $ldap->cd($this->dn);
592       $this->cleanup();
593       $ldap->modify ($this->attrs);
594       new log("modify","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
595     }else{
596       $ldap->cd($this->config->current['BASE']);
597       $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn));
598       $ldap->cd($this->dn);
599       $ldap->add($this->attrs);
600       new log("create","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
601     }
603     if (!$ldap->success()){
604       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
605     }
607     /* Refresh users ACL */
608     $ui= get_userinfo();
609     $ui->loadACL();
610     session::set('ui',$ui);
611   }
614   function remove_from_parent()
615   {
616     $ldap = $this->config->get_ldap_link();
617     $serach_for = "*:role:".base64_encode($this->dn).":*"; 
618     $ldap->search ("(&(objectClass=gosaACL)(gosaAclEntry=".$serach_for."))",array('dn','cn','sn','givenName','uid'));
619     $all_names = "";
622     $cnt = 3;
623     while(($attrs = $ldap->fetch()) && $cnt){
624       $name = $attrs['dn'];
625       $name = preg_replace("/[ ]/","&nbsp;",$name);
626       $name = "<i>'".$name."'</i>";
627       $all_names .= $name.", ";
628       $cnt --;
629     }
631     if(!empty($all_names)){
632       $all_names = preg_replace("/, $/","",$all_names);
633       if(!$cnt){
634         $all_names .= ", ...";
635       }
636       $all_names = "<span style='text-align:left;'>".$all_names."</span>";
637       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);
638       return;
639     }
640         
641     $ldap->rmDir($this->dn);
642     new log("remove","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
643     if (!$ldap->success()){
644       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
645     }
647     /* Optionally execute a command after we're done */
648     $this->handle_post_events("remove");
650     /* Delete references to object groups */
651     $ldap->cd ($this->config->current['BASE']);
652     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
653     while ($ldap->fetch()){
654       $og= new ogroup($this->config, $ldap->getDN());
655       unset($og->member[$this->dn]);
656       $og->save ();
657       if (!$ldap->success()){
658         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $og->dn, "", get_class()));
659       }
660     }
661   }
664   function save_object()
665   {
666     plugin::save_object();
667     if(isset($_POST['acl_role_posted'])){
668      
669       /* Refresh base */
670       if ($this->acl_is_moveable($this->base)){
671         if (!$this->baseSelector->update()) {
672           msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
673         }
674         if ($this->base != $this->baseSelector->getBase()) {
675           $this->base= $this->baseSelector->getBase();
676           $this->is_modified= TRUE;
677         }
678       }
679     }
680   }
683   function saveCopyDialog()
684   {
685     if(isset($_POST['cn'])){
686       $this->cn = $_POST['cn'];
687     }
688   }
689   
691   function getCopyDialog()
692   {
693     $smarty = get_smarty();
694     $smarty->assign("cn",$this->cn);
695     $str = $smarty->fetch(get_template_path("paste_role.tpl",TRUE,dirname(__FILE__)));
696     $ret = array();
697     $ret['string'] = $str;
698     $ret['status'] = "";
699     return($ret);
700   }
702   
703   function PrepareForCopyPaste($source)
704   {
705     plugin::PrepareForCopyPaste($source);
706     
707     $source_o = new aclrole($this->config,$source['dn']);
708     $this->gosaAclTemplate = $source_o->gosaAclTemplate;
709   }
710   
712   /* Return plugin informations for acl handling  */
713   static function plInfo()
714   {
715     return (array(
716           "plShortName" => _("Role"),
717           "plDescription" => _("Access control roles"),
718           "plSelfModify"  => FALSE,
719           "plDepends"     => array(),
720           "plPriority"    => 0,
721           "plSection"     => array("administration"),
722           "plCategory"    => array("acl"),
723           "plProvidedAcls"    => array(
724             "cn"                => _("Name"),
725             "base"              => _("Base"),
726             "description"       => _("Description"),
727             "gosaAclTemplate"      => _("Permissions"))
728         ));
729   }
731   function check()
732   {
733     $message = plugin::check();
735     if(empty($this->cn)){
736       $message[] = msgPool::required(_("Name"));
737     }
738   
739     $ldap = $this->config->get_ldap_link();
740     $ldap->cd($this->config->current['BASE']);
741     if($this->cn != $this->orig_cn){
742       $ldap->search("(&(objectClass=gosaRole)(cn=".$this->cn."))");
743       if($ldap->count()) {
744         while($attrs = $ldap->fetch()){
745           if($attrs['dn'] != $this->orig_dn){
746             $message[] = msgPool::duplicated(_("Name"));
747           }
748         }
749       }
750     } 
751  
752     if(!count($this->gosaAclTemplate)){
753       $message[] = msgPool::required(_("ACL"));
754     }
756     // Check if a wrong base was supplied
757     if(!$this->baseSelector->checkLastBaseUpdate()){
758       $message[]= msgPool::check_base();;
759     }
760  
761     /* Check if we are allowed to create or move this object
762      */
763     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
764       $message[] = msgPool::permCreate();
765     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
766       $message[] = msgPool::permMove();
767     }
769     return($message);
770   }
774 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
775 ?>