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 }
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);
177 $dep_types = departmentManagement::get_support_departments();
178 $tpl ="";
179 foreach($dep_types as $key => $data){
180 if($data['ATTR'] == $this->type){
181 $tpl = $data['TPL'];
182 break;
183 }
184 }
185 if($tpl == "") {
186 trigger_error("No template specified for container type '".$this->type."', please update epartmentManagement::get_support_departments().");
187 $tpl = "generic.tpl";
188 }
189 return($smarty->fetch (get_template_path($tpl, TRUE)));
190 }
192 function clear_fields()
193 {
194 $this->dn = "";
195 $this->base = "";
197 foreach ($this->attributes as $val){
198 $this->$val= "";
199 }
200 }
202 function remove_from_parent()
203 {
204 $ldap= $this->config->get_ldap_link();
205 $ldap->cd ($this->dn);
206 $ldap->recursive_remove();
207 new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
208 if (!$ldap->success()){
209 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
210 }
212 /* Optionally execute a command after we're done */
213 $this->handle_post_events('remove');
214 }
216 function must_be_tagged()
217 {
218 return $this->must_be_tagged;
219 }
221 /* Save data to object */
222 function save_object()
223 {
224 if (isset($_POST['dep_generic_posted'])){
226 /* Create a base backup and reset the
227 base directly after calling plugin::save_object();
228 Base will be set seperatly a few lines below */
229 $base_tmp = $this->base;
230 plugin::save_object();
231 $this->base = $base_tmp;
233 /* Set new base if allowed */
234 $tmp = $this->get_allowed_bases();
235 if(isset($_POST['base'])){
236 if(isset($tmp[$_POST['base']])){
237 $this->base= $_POST['base'];
238 }
239 }
241 /* Save tagging flag */
242 if ($this->acl_is_writeable("unitTag")){
243 if (isset($_POST['unitTag'])){
244 $this->is_administrational_unit= true;
245 } else {
246 $this->is_administrational_unit= false;
247 }
248 }
249 }
250 }
253 /* Check values */
254 function check()
255 {
256 /* Call common method to give check the hook */
257 $message= plugin::check();
259 /* Check for presence of this department */
260 $ldap= $this->config->get_ldap_link();
261 $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
262 if ($this->orig_dn == "new" && $ldap->count()){
263 $message[]= msgPool::duplicated(_("Name"));
264 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
265 $message[]= msgPool::duplicated(_("Name"));
266 }
268 /* All required fields are set? */
269 if ($this->ou == ""){
270 $message[]= msgPool::required(_("Name"));
271 }
272 if ($this->description == ""){
273 $message[]= msgPool::required(_("Description"));
274 }
276 if(tests::is_department_name_reserved($this->ou,$this->base)){
277 $message[]= msgPool::reserved(_("Name"));
278 }
280 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
281 $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
282 }
283 if (!tests::is_phone_nr($this->telephoneNumber)){
284 $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
285 }
286 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
287 $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
288 }
290 /* Check if we are allowed to create or move this object
291 */
292 if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
293 $message[] = msgPool::permCreate();
294 }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
295 $message[] = msgPool::permMove();
296 }
298 return $message;
299 }
302 /* Save to LDAP */
303 function save()
304 {
305 $ldap= $this->config->get_ldap_link();
307 /* Ensure that ou is saved too, it is required by objectClass gosaDepartment
308 */
309 $nA = $this->namingAttr;
310 $this->ou = $this->$nA;
312 /* Add tag objects if needed */
313 if ($this->is_administrational_unit){
315 /* If this wasn't tagged before add oc an reset unit tag */
316 if(!$this->initially_was_tagged){
317 $this->objectclasses[]= "gosaAdministrativeUnit";
318 $this->gosaUnitTag= "";
320 /* It seams that this method is called twice,
321 set this to true. to avoid adding this oc twice */
322 $this->initially_was_tagged = true;
323 }
325 if ($this->gosaUnitTag == ""){
327 /* It's unlikely, but check if already used... */
328 $try= 5;
329 $ldap->cd($this->config->current['BASE']);
330 while ($try--){
332 /* Generate microtime stamp as tag */
333 list($usec, $sec)= explode(" ", microtime());
334 $time_stamp= preg_replace("/\./", "", $sec.$usec);
336 $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
337 if ($ldap->count() == 0){
338 break;
339 }
340 }
341 if($try == 0) {
342 msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
343 return;
344 }
345 $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
346 }
347 }
348 $this->skipTagging = TRUE;
349 plugin::save();
352 /* Remove tag information if needed */
353 if (!$this->is_administrational_unit && $this->initially_was_tagged){
354 $tmp= array();
356 /* Remove gosaAdministrativeUnit from this plugin */
357 $has_unit_tag= false;
358 foreach($this->attrs['objectClass'] as $oc){
359 if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
360 $tmp[]= $oc;
361 }
362 if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
363 $has_unit_tag= true;
364 }
365 }
366 $this->attrs['objectClass']= $tmp;
367 $this->attrs['gosaUnitTag']= array();
368 $this->gosaUnitTag = "";
369 }
372 /* Write back to ldap */
373 $ldap->cat($this->dn, array('dn'));
374 $ldap->cd($this->dn);
376 if ($ldap->count()){
377 $this->cleanup();
378 $ldap->modify ($this->attrs);
379 new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
380 $this->handle_post_events('modify');
381 } else {
382 $ldap->add($this->attrs);
383 $this->handle_post_events('add');
384 new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
385 }
386 if (!$ldap->success()){
387 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
388 }
390 /* The parameter forces only to set must_be_tagged, and don't touch any objects
391 This will be done later */
392 $this->tag_objects(true);
394 /* Optionally execute a command after we're done */
395 $this->postcreate();
396 return(false);
397 }
400 /* Tag objects to have the gosaAdministrativeUnitTag */
401 function tag_objects($OnlySetTagFlag = false)
402 {
403 if(!$OnlySetTagFlag){
404 $smarty= get_smarty();
405 /* Print out html introduction */
406 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
407 <html>
408 <head>
409 <title></title>
410 <style type="text/css">@import url("themes/default/style.css");</style>
411 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
412 </head>
413 <body style="background: none; margin:4px;" id="body" >
414 ';
415 echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".@LDAP::fix($this->dn)."</i>")."</h3>";
416 }
418 $add= $this->is_administrational_unit;
419 $len= strlen($this->dn);
420 $ldap= $this->config->get_ldap_link();
421 $ldap->cd($this->dn);
422 if ($add){
423 $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
424 $this->gosaUnitTag.')))', array('dn'));
425 } else {
426 $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
427 }
429 $objects = array();
430 while ($attrs= $ldap->fetch()){
431 $objects[] = $attrs;
432 }
433 foreach($objects as $attrs){
435 /* Skip self */
436 if ($attrs['dn'] == $this->dn){
437 continue;
438 }
440 /* Check for confilicting administrative units */
441 $fix= true;
442 foreach ($this->config->adepartments as $key => $tag){
443 /* This one is shorter than our dn, its not relevant... */
444 if ($len >= strlen($key)){
445 continue;
446 }
448 /* This one matches with the latter part. Break and don't fix this entry */
449 if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){
450 $fix= false;
451 break;
452 }
453 }
455 /* Fix entry if needed */
456 if ($fix){
457 if($OnlySetTagFlag){
458 $this->must_be_tagged =true;
459 return;
460 }
461 $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
462 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
463 }
464 }
466 if(!$OnlySetTagFlag){
467 $this->must_be_tagged = FALSE;
468 echo '<p class="seperator"> </p>';
469 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
470 <br><input type='submit' name='back' value='"._("Continue")."'>
471 </form></div>";
472 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
473 }
474 }
477 /* Move/Rename complete trees */
478 function recursive_move($src_dn, $dst_dn,$force = false)
479 {
480 /* Print header to have styles included */
481 $smarty= get_smarty();
483 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
484 <html>
485 <head>
486 <title></title>
487 <style type="text/css">@import url("themes/default/style.css");</style>
488 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
489 </head>
490 <body style="background: none; margin:4px;" id="body" >
491 ';
492 echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".@LDAP::fix($src_dn)."</i>","<i>".@LDAP::fix($dst_dn)."</i>")."</h3>";
495 /* Check if the destination entry exists */
496 $ldap= $this->config->get_ldap_link();
498 /* Check if destination exists - abort */
499 $ldap->cat($dst_dn, array('dn'));
500 if ($ldap->fetch()){
501 trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.",
502 E_USER_WARNING);
503 echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."<br>";
504 return (FALSE);
505 }
507 /* Perform a search for all objects to be moved */
508 $objects= array();
509 $ldap->cd($src_dn);
510 $ldap->search("(objectClass=*)", array("dn"));
511 while($attrs= $ldap->fetch()){
512 $dn= $attrs['dn'];
513 $objects[$dn]= strlen($dn);
514 }
516 /* Sort objects by indent level */
517 asort($objects);
518 reset($objects);
520 /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
521 foreach ($objects as $object => $len){
524 $src= str_replace("\\","\\\\",$object);
525 $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
526 $dst= str_replace($src_dn,$dst_dn,$object);
528 echo "<b>"._("Object").":</b> ".@LDAP::fix($src)."<br>";
530 $this->update_acls($object, $dst,TRUE);
532 if (!$this->copy($src, $dst)){
533 echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."</font>";
534 return (FALSE);
535 }
536 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
537 flush();
538 }
540 /* Remove src_dn */
541 $ldap->cd($src_dn);
542 $ldap->recursive_remove();
543 $this->orig_dn = $this->dn = $dst_dn;
544 $this->orig_base= $this->base;
545 $this->entryCSN = getEntryCSN($this->dn);
547 echo '<p class="seperator"> </p>';
549 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
550 <br><input type='submit' name='back' value='"._("Continue")."'>
551 </form></div>";
553 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
554 echo "</body></html>";
556 return (TRUE);
557 }
560 /* Return plugin informations for acl handling */
561 static function plInfo()
562 {
563 return (array("plShortName" => _("Generic"),
564 "plDescription" => _("Departments"),
565 "plSelfModify" => FALSE,
566 "plPriority" => 0,
567 "plDepends" => array(),
568 "plSection" => array("admin"),
569 "plCategory" => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
571 "plProvidedAcls" => array(
572 "description" => _("Description"),
573 "c" => _("Country"),
574 "base" => _("Base"),
575 "l" => _("Location"),
576 "telephoneNumber" => _("Telephone"),
577 "ou" => _("Department name"),
578 "businessCategory" => _("Category"),
579 "st" => _("State"),
580 "postalAddress" => _("Address"),
581 "gosaUnitTag" => _("Administrative settings"),
582 "facsimileTelephoneNumber" => _("Fax"))
583 ));
584 }
586 function handle_object_tagging($dn= "", $tag= "", $show= false)
587 {
588 /* No dn? Self-operation... */
589 if ($dn == ""){
590 $dn= $this->dn;
592 /* No tag? Find it yourself... */
593 if ($tag == ""){
594 $len= strlen($dn);
596 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
597 $relevant= array();
598 foreach ($this->config->adepartments as $key => $ntag){
600 /* This one is bigger than our dn, its not relevant... */
601 if ($len <= strlen($key)){
602 continue;
603 }
605 /* This one matches with the latter part. Break and don't fix this entry */
606 if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
607 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
608 $relevant[strlen($key)]= $ntag;
609 continue;
610 }
612 }
614 /* If we've some relevant tags to set, just get the longest one */
615 if (count($relevant)){
616 ksort($relevant);
617 $tmp= array_keys($relevant);
618 $idx= end($tmp);
619 $tag= $relevant[$idx];
620 $this->gosaUnitTag= $tag;
621 }
622 }
623 }
625 /* Set tag? */
626 if ($tag != ""){
627 /* Set objectclass and attribute */
628 $ldap= $this->config->get_ldap_link();
629 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
630 $attrs= $ldap->fetch();
631 if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
632 if ($show) {
633 echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
634 flush();
635 }
636 return;
637 }
638 if (count($attrs)){
639 if ($show){
640 echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
641 flush();
642 }
643 $nattrs= array("gosaUnitTag" => $tag);
644 $nattrs['objectClass']= array();
645 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
646 $oc= $attrs['objectClass'][$i];
647 if ($oc != "gosaAdministrativeUnitTag"){
648 $nattrs['objectClass'][]= $oc;
649 }
650 }
651 $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
652 $ldap->cd($dn);
653 $ldap->modify($nattrs);
654 if (!$ldap->success()){
655 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
656 }
657 } else {
658 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
659 }
661 } else {
662 /* Remove objectclass and attribute */
663 $ldap= $this->config->get_ldap_link();
664 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
665 $attrs= $ldap->fetch();
666 if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
667 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
668 return;
669 }
670 if (count($attrs)){
671 if ($show){
672 echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
673 flush();
674 }
675 $nattrs= array("gosaUnitTag" => array());
676 $nattrs['objectClass']= array();
677 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
678 $oc= $attrs['objectClass'][$i];
679 if ($oc != "gosaAdministrativeUnitTag"){
680 $nattrs['objectClass'][]= $oc;
681 }
682 }
683 $ldap->cd($dn);
684 $ldap->modify($nattrs);
685 if (!$ldap->success()){
686 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
687 }
688 } else {
689 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
690 }
691 }
692 }
696 /*! \brief Returns a list of all available departments for this object.
697 If this object is new, all departments we are allowed to create a new user in are returned.
698 If this is an existing object, return all deps. we are allowed to move tis object too.
700 @return Array [dn] => "..name" // All deps. we are allowed to act on.
701 */
702 function get_allowed_bases()
703 {
704 $ui = get_userinfo();
705 $deps = array();
707 /* Is this a new object ? Or just an edited existing object */
708 if(!$this->initially_was_account && $this->is_account){
709 $new = true;
710 }else{
711 $new = false;
712 }
714 $ideps = $this->config->idepartments;
715 if(!isset($ideps[$this->base])){
716 $ideps[$this->base] = ".";
717 }
718 foreach($deps as $dn => $name){
719 if($new && $this->acl_is_createable($dn)){
720 $deps[$dn] = $name;
721 }elseif(!$new && $this->acl_is_moveable($dn)){
722 $deps[$dn] = $name;
723 }
724 }
726 /* Add current base */
727 if(isset($this->base) && isset($ideps[$this->base])){
728 $deps[$this->base] = $ideps[$this->base];
729 }else{
730 trigger_error("Cannot return list of departments, no default base found in class ".get_class($this).". ".$this->base);
731 }
732 return($deps);
733 }
735 }
737 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
738 ?>