Code

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