Code

Added country class.
[gosa.git] / gosa-core / plugins / admin / departments / class_departmentGeneric.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 department extends plugin
24 {
25         /* department attributes */
26         var $ou= "";
27         var $description= "";
28         var $base= "";
29         var $st= "";
30         var $l= "";
31         var $postalAddress= "";
32         var $businessCategory= "";
33         var $telephoneNumber= "";
34         var $facsimileTelephoneNumber= "";
35         var $is_administrational_unit= false;
36         var $gosaUnitTag= "";
37   var $view_logged = FALSE;
39   var $type ="ou";
41         /* Headpage attributes */
42         var $last_dep_sorting= "invalid";
43         var $departments= array();
44   var $must_be_tagged = false;
46         /* attribute list for save action */
47         var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
48                         "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
49         var $objectclasses= array("top", "gosaDepartment", "organizationalUnit");
50   var $initially_was_tagged = false;
52   var $orig_base = "";
53   var $orig_ou = "";
55         function department (&$config, $dn)
56         {
58                 plugin::plugin($config, $dn);
59                 $this->is_account= TRUE;
60                 $this->ui= get_userinfo();
61                 $this->dn= $dn;
62                 $this->orig_dn= $dn;
63                 $this->orig_ou= $this->ou;
64                 $this->config= $config;
66                 /* Set base */
67                 if ($this->dn == "new"){
68                         $ui= get_userinfo();
69                         if(session::is_set('CurrentMainBase')){
70                                 $this->base = session::get('CurrentMainBase');
71                         }else{
72                                 $this->base= dn2base($ui->dn);
73                         }
74                 } else {
75                         $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
76                 }
78     $this->orig_base = $this->base;
80                 /* Is administrational Unit? */
81                 if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
82                         $this->is_administrational_unit= true;
83       $this->initially_was_tagged = true;
84                 }
85         }
87         function execute()
88         {
89                 /* Call parent execute */
90                 plugin::execute();
92     /* Log view */
93     if($this->is_account && !$this->view_logged){
94       $this->view_logged = TRUE;
95       new log("view","department/".get_class($this),$this->dn);
96     }
98                 /* Reload departments */
99                 $this->config->get_departments($this->dn);
100                 $this->config->make_idepartments();
101                 $smarty= get_smarty();
103     $tmp = $this->plInfo();
104     foreach($tmp['plProvidedAcls'] as $name => $translation){
105       $smarty->assign($name."ACL",$this->getacl($name));
106     }
108                 /* Base select dialog */
109                 $once = true;
110                 foreach($_POST as $name => $value){
111                         if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){
112                                 $once = false;
113                                 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
114                                 $this->dialog->setCurrentBase($this->base);
115                         }
116                 }
118                 /* Dialog handling */
119                 if(is_object($this->dialog)){
120                         /* Must be called before save_object */
121                         $this->dialog->save_object();
123                         if($this->dialog->isClosed()){
124                                 $this->dialog = false;
125                         }elseif($this->dialog->isSelected()){
127         /* A new base was selected, check if it is a valid one */
128         $tmp = $this->get_allowed_bases();
129         if(isset($tmp[$this->dialog->isSelected()])){
130           $this->base = $this->dialog->isSelected();
131         }
132   
133                                 $this->dialog= false;
134                         }else{
135                                 return($this->dialog->execute());
136                         }
137                 }
139                 /* Hide all departments, that are subtrees of this department */
140     $bases = $this->get_allowed_bases();
141                 if(($this->dn == "new")||($this->dn == "")){
142                         $tmp = $bases;
143                 }else{
144                         $tmp    = array();      
145                         foreach($bases as $dn=>$base){
146                                 $fixed = str_replace("/","\\",$this->dn);
147                                 /* Only attach departments which are not a subtree of this one */
148                                 if(!preg_match("/".$fixed."/",$dn)){
149                                         $tmp[$dn]=$base;
150                                 }
151                         }
152                 }
153                 $smarty->assign("bases", $tmp);
155                 foreach ($this->attributes as $val){
156                         $smarty->assign("$val", $this->$val);
157                 }
158                 $smarty->assign("base_select", $this->base);
160     /* Set admin unit flag */
161     if ($this->is_administrational_unit) {
162       $smarty->assign("unitTag", "checked");
163     } else {
164       $smarty->assign("unitTag", "");
165     }
167     $smarty->assign("dep_type",$this->type);
168                 return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
169         }
171         function clear_fields()
172         {
173                 $this->dn   = "";
174                 $this->base = "";
176                 foreach ($this->attributes as $val){
177                         $this->$val= "";
178                 }
179         }
181         function remove_from_parent()
182         {
183                 $ldap= $this->config->get_ldap_link();
184                 $ldap->cd ($this->dn);
185                 $ldap->recursive_remove();
186     new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
187     if (!$ldap->success()){
188       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
189     }
191                 /* Optionally execute a command after we're done */
192                 $this->handle_post_events('remove');
193         }
195         function must_be_tagged()
196         {
197                 return $this->must_be_tagged;
198         }
200         /* Save data to object */
201         function save_object()
202         {
203                 if (isset($_POST['dep_generic_posted'])){
205       /* Create a base backup and reset the
206          base directly after calling plugin::save_object();
207          Base will be set seperatly a few lines below */
208       $base_tmp = $this->base;
209       plugin::save_object();
210       $this->base = $base_tmp;
212       /* Set new base if allowed */
213       $tmp = $this->get_allowed_bases();
214       if(isset($_POST['base'])){
215         if(isset($tmp[$_POST['base']])){
216           $this->base= $_POST['base'];
217         }
218       }
220       /* Save tagging flag */
221       if ($this->acl_is_writeable("unitTag")){
222         if (isset($_POST['unitTag'])){
223           $this->is_administrational_unit= true;
224         } else {
225           $this->is_administrational_unit= false;
226         }
227       }
228     }
229         }
232         /* Check values */
233         function check()
234         {
235                 /* Call common method to give check the hook */
236                 $message= plugin::check();
238                 /* Check for presence of this department */
239                 $ldap= $this->config->get_ldap_link();
240     $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
241     if ($this->orig_dn == "new" && $ldap->count()){
242                         $message[]= msgPool::duplicated(_("Name"));
243                 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
244                         $message[]= msgPool::duplicated(_("Name"));
245                 }
247                 /* All required fields are set? */
248                 if ($this->ou == ""){
249                         $message[]= msgPool::required(_("Name"));
250                 }
251                 if ($this->description == ""){
252                         $message[]= msgPool::required(_("Description"));
253                 }
255     if(tests::is_department_name_reserved($this->ou,$this->base)){
256       $message[]= msgPool::reserved(_("Name"));
257     }
259                 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
260                         $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
261                 }
262                 if (!tests::is_phone_nr($this->telephoneNumber)){
263                         $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
264                 }
265                 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
266                         $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
267                 }
269     /* Check if we are allowed to create or move this object
270      */
271     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
272       $message[] = msgPool::permCreate();
273     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
274       $message[] = msgPool::permMove();
275     }
277     return $message;
278         }
281         /* Save to LDAP */
282         function save()
283         {
284                 $ldap= $this->config->get_ldap_link();
286     /* Add tag objects if needed */
287     if ($this->is_administrational_unit){
289       /* If this wasn't tagged before add oc an reset unit tag */
290       if(!$this->initially_was_tagged){
291         $this->objectclasses[]= "gosaAdministrativeUnit";
292         $this->gosaUnitTag= "";
294         /* It seams that this method is called twice, 
295            set this to true. to avoid adding this oc twice */
296         $this->initially_was_tagged = true;
297       }
299       if ($this->gosaUnitTag == ""){
301         /* It's unlikely, but check if already used... */
302         $try= 5;
303         $ldap->cd($this->config->current['BASE']);
304         while ($try--){
306           /* Generate microtime stamp as tag */
307           list($usec, $sec)= explode(" ", microtime());
308           $time_stamp= preg_replace("/\./", "", $sec.$usec);
310           $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
311           if ($ldap->count() == 0){
312             break;
313           }
314         }
315         if($try == 0) {
316           msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
317           return;
318         }
319         $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
320       }
321     }
322     $this->skipTagging = TRUE;
323     plugin::save();
326     /* Remove tag information if needed */
327     if (!$this->is_administrational_unit && $this->initially_was_tagged){
328       $tmp= array();
330       /* Remove gosaAdministrativeUnit from this plugin */
331       $has_unit_tag= false;
332       foreach($this->attrs['objectClass'] as $oc){
333         if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
334           $tmp[]= $oc;
335         }
336         if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
337           $has_unit_tag= true;
338         }
339       }
340       $this->attrs['objectClass']= $tmp;
341       $this->attrs['gosaUnitTag']= array();
342       $this->gosaUnitTag = "";
343     }
346                 /* Write back to ldap */
347                 $ldap->cat($this->dn, array('dn'));
348                 $ldap->cd($this->dn);
350                 if ($ldap->count()){
351                         $this->cleanup();
352                         $ldap->modify ($this->attrs); 
353       new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
354                         $this->handle_post_events('modify');
355                 } else {
356                         $ldap->add($this->attrs);
357                         $this->handle_post_events('add');
358       new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
359                 }
360     if (!$ldap->success()){
361       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
362     }
364     /* The parameter forces only to set must_be_tagged, and don't touch any objects 
365        This will be done later */
366     $this->tag_objects(true);
367     
368     /* Optionally execute a command after we're done */
369                 $this->postcreate();
370     return(false);
371         }
374         /* Tag objects to have the gosaAdministrativeUnitTag */
375         function tag_objects($OnlySetTagFlag = false)
376         {
377     if(!$OnlySetTagFlag){
378       $smarty= get_smarty();
379       /* Print out html introduction */
380       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
381         <html>
382         <head>
383         <title></title>
384         <style type="text/css">@import url("themes/default/style.css");</style>
385         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
386         </head>
387         <body style="background: none; margin:4px;" id="body" >
388         ';
389       echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".@LDAP::fix($this->dn)."</i>")."</h3>";
390     }
392     $add= $this->is_administrational_unit;
393     $len= strlen($this->dn);
394     $ldap= $this->config->get_ldap_link();
395     $ldap->cd($this->dn);
396     if ($add){
397             $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
398                                                     $this->gosaUnitTag.')))', array('dn'));
399     } else {
400             $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
401     }
403     $objects = array();
404     while ($attrs= $ldap->fetch()){
405       $objects[] = $attrs;
406     }
407     foreach($objects as $attrs){
409             /* Skip self */
410             if ($attrs['dn'] == $this->dn){
411                     continue;
412             }
414             /* Check for confilicting administrative units */
415             $fix= true;
416             foreach ($this->config->adepartments as $key => $tag){
417                     /* This one is shorter than our dn, its not relevant... */
418                     if ($len >= strlen($key)){
419                             continue;
420                     }
422                     /* This one matches with the latter part. Break and don't fix this entry */
423                     if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){
424                             $fix= false;
425                             break;
426                     }
427             }
429             /* Fix entry if needed */
430             if ($fix){
431                     if($OnlySetTagFlag){
432                             $this->must_be_tagged =true;
433                             return;
434                     }
435                     $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
436         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
437             }
438     }
439     
440     if(!$OnlySetTagFlag){
441       $this->must_be_tagged = FALSE;
442             echo '<p class="seperator">&nbsp;</p>';
443       echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
444         <br><input type='submit' name='back' value='"._("Continue")."'>
445         </form></div>";
446       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
447     }
448         }
451         /* Move/Rename complete trees */
452         function recursive_move($src_dn, $dst_dn,$force = false)
453         {
454     /* Print header to have styles included */
455     $smarty= get_smarty();
457     echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
458       <html>
459       <head>
460       <title></title>
461       <style type="text/css">@import url("themes/default/style.css");</style>
462       <script language="javascript" src="include/focus.js" type="text/javascript"></script>
463       </head>
464       <body style="background: none; margin:4px;" id="body" >
465       ';
466     echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".@LDAP::fix($src_dn)."</i>","<i>".@LDAP::fix($dst_dn)."</i>")."</h3>";
469     /* Check if the destination entry exists */
470     $ldap= $this->config->get_ldap_link();
472     /* Check if destination exists - abort */
473     $ldap->cat($dst_dn, array('dn'));
474     if ($ldap->fetch()){
475       trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.",
476           E_USER_WARNING);
477       echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."<br>"; 
478       return (FALSE);
479     }
481     /* Perform a search for all objects to be moved */
482     $objects= array();
483     $ldap->cd($src_dn);
484     $ldap->search("(objectClass=*)", array("dn"));
485     while($attrs= $ldap->fetch()){
486       $dn= $attrs['dn'];
487       $objects[$dn]= strlen($dn);
488     }
490     /* Sort objects by indent level */
491     asort($objects);
492     reset($objects);
494     /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
495     foreach ($objects as $object => $len){
498       $src= str_replace("\\","\\\\",$object);
499       $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
500       $dst= str_replace($src_dn,$dst_dn,$object);
502       echo "<b>"._("Object").":</b> ".@LDAP::fix($src)."<br>";
504       $this->update_acls($object, $dst,TRUE);
506       if (!$this->copy($src, $dst)){
507         echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."</font>";
508         return (FALSE);
509       }
510       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
511       flush();
512     }
514     /* Remove src_dn */
515     $ldap->cd($src_dn);
516     $ldap->recursive_remove();
517     $this->orig_dn  = $this->dn = $dst_dn;
518     $this->orig_base= $this->base;     
519     $this->entryCSN = getEntryCSN($this->dn);
521     echo '<p class="seperator">&nbsp;</p>';
523     echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
524       <br><input type='submit' name='back' value='"._("Continue")."'>
525       </form></div>";
527     echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
528     echo "</body></html>";
530     return (TRUE);
531   }
534   /* Return plugin informations for acl handling */ 
535   static function plInfo()
536   {
537     return (array("plShortName"   => _("Generic"),
538                   "plDescription" => _("Departments"),
539                   "plSelfModify"  => FALSE,
540                   "plPriority"    => 0,
541                   "plDepends"     => array(),
542                   "plSection"     => array("admin"),
543                   "plCategory"    => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
544             
545                   "plProvidedAcls" => array(
546                     "description"       => _("Description"),
547                     "c"                 => _("Country"),
548                     "base"              => _("Base"),
549                     "l"                 => _("Location"),
550                     "telephoneNumber"   => _("Telephone"),
551                     "ou"                => _("Department name"),
552                     "businessCategory"  => _("Category"),
553                     "st"                => _("State"),
554                     "postalAddress"     => _("Address"),
555                     "gosaUnitTag"       => _("Administrative settings"),
556                     "facsimileTelephoneNumber" => _("Fax"))
557                   ));
558   }
560   function handle_object_tagging($dn= "", $tag= "", $show= false)
561   {
562     /* No dn? Self-operation... */
563     if ($dn == ""){
564       $dn= $this->dn;
566       /* No tag? Find it yourself... */
567       if ($tag == ""){
568         $len= strlen($dn);
570         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
571         $relevant= array();
572         foreach ($this->config->adepartments as $key => $ntag){
574           /* This one is bigger than our dn, its not relevant... */
575           if ($len <= strlen($key)){
576             continue;
577           }
579           /* This one matches with the latter part. Break and don't fix this entry */
580           if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
581             @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
582             $relevant[strlen($key)]= $ntag;
583             continue;
584           }
586         }
588         /* If we've some relevant tags to set, just get the longest one */
589         if (count($relevant)){
590           ksort($relevant);
591           $tmp= array_keys($relevant);
592           $idx= end($tmp);
593           $tag= $relevant[$idx];
594           $this->gosaUnitTag= $tag;
595         }
596       }
597     }
599     /* Set tag? */
600     if ($tag != ""){
601       /* Set objectclass and attribute */
602       $ldap= $this->config->get_ldap_link();
603       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
604       $attrs= $ldap->fetch();
605       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
606         if ($show) {
607           echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
608           flush();
609         }
610         return;
611       }
612       if (count($attrs)){
613         if ($show){
614           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
615           flush();
616         }
617         $nattrs= array("gosaUnitTag" => $tag);
618         $nattrs['objectClass']= array();
619         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
620           $oc= $attrs['objectClass'][$i];
621           if ($oc != "gosaAdministrativeUnitTag"){
622             $nattrs['objectClass'][]= $oc;
623           }
624         }
625         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
626         $ldap->cd($dn);
627         $ldap->modify($nattrs);
628         if (!$ldap->success()){
629           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
630         }
631       } else {
632         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
633       }
635     } else {
636       /* Remove objectclass and attribute */
637       $ldap= $this->config->get_ldap_link();
638       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
639       $attrs= $ldap->fetch();
640       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
641         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
642         return;
643       }
644       if (count($attrs)){
645         if ($show){
646           echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
647           flush();
648         }
649         $nattrs= array("gosaUnitTag" => array());
650         $nattrs['objectClass']= array();
651         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
652           $oc= $attrs['objectClass'][$i];
653           if ($oc != "gosaAdministrativeUnitTag"){
654             $nattrs['objectClass'][]= $oc;
655           }
656         }
657         $ldap->cd($dn);
658         $ldap->modify($nattrs);
659         if (!$ldap->success()){
660           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
661         }
662       } else {
663         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
664       }
665     }
666   }
669   
670   /*! \brief    Returns a list of all available departments for this object.
671                 If this object is new, all departments we are allowed to create a new user in are returned.
672                 If this is an existing object, return all deps. we are allowed to move tis object too.
674       @return   Array [dn] => "..name"  // All deps. we are allowed to act on.
675   */
676   function get_allowed_bases()
677   {
678     $ui = get_userinfo();
679     $deps = array();
681     /* Is this a new object ? Or just an edited existing object */
682     if(!$this->initially_was_account && $this->is_account){
683       $new = true;
684     }else{
685       $new = false;
686     }
688     $ideps = $this->config->idepartments;
689     if(!isset($ideps[$this->base])){
690       $ideps[$this->base] = ".";
691     }
692     foreach($deps as $dn => $name){
693       if($new && $this->acl_is_createable($dn)){
694         $deps[$dn] = $name;
695       }elseif(!$new && $this->acl_is_moveable($dn)){
696         $deps[$dn] = $name;
697       }
698     }
700     /* Add current base */
701     if(isset($this->base) && isset($ideps[$this->base])){
702       $deps[$this->base] = $ideps[$this->base];
703     }else{
704       trigger_error("Cannot return list of departments, no default base found in class ".get_class($this).". ".$this->base);
705     }
706     return($deps);
707   }
711 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
712 ?>