Code

Made department tagging && recursive move PHP 4compatible
[gosa.git] / plugins / admin / departments / tabs_department.inc
1 <?php
3 class deptabs extends tabs
4 {
5   var $base             = "";
7   function deptabs($config, $data, $dn)
8   {
9     tabs::tabs($config, $data, $dn);
10     $this->base= $this->by_object['department']->base;
11   }
13   function check()
14   {
15     return (tabs::check(TRUE));
16   }
19   /* Save all changes (generic tab will do our tagging)
20       if source dn != destination dn then MustBeMoved will be set */
21   function save()
22   {
23     $baseobject = $this->by_object['department'];
25     $ou         = preg_replace('/,/', '\,', $baseobject->ou);
26     $new_dn     = @LDAP::convert('ou='.$ou.','.$baseobject->base);
28     /* If dn has changed move dep & sub entries */
29     if ($this->dn != $new_dn && $this->dn != "new"){
30       /* if( new_dn is subtree of this->dn ) */
31       $cnt1 = count(split(",",$this->dn));
32       $cnt2 = count(split(",",$new_dn));
33       if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){
34         print_red(_("Try to move tree failed. Destination tree is subtree of source tree."));
35       }else{
36         $this->by_object['department']->MustBeMoved      = true;
37         $this->by_object['department']->MoveDestination  = $new_dn;
38         $this->by_object['department']->MoveSource       = $this->dn;
39         $this->by_object['department']->ou  = $baseobject->attrs['ou'][0];
40         $ret              = tabs::save(TRUE);
41         $this->by_object['department']->save(true);
42         return($ret);
43       }
44     }else{
45       $this->dn         = $new_dn;
46       $baseobject->dn   = $this->dn;
47       $ret              = tabs::save(TRUE);
48       $baseobject->save(true);
49       $this->by_object['department']= $baseobject;
50       return($ret);
51     }
52   }
53 }
54   // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
55   ?>