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']->MoveOu = $ou;
40 $this->dn = $this->dn;
41 $baseobject->dn = $this->dn;
42 $this->by_object['department']->ou = $baseobject->attrs['ou'][0];
43 $this->by_object['department'] = $baseobject;
44 return(tabs::save(TRUE));
45 }
46 }else{
47 $this->dn= $new_dn;
48 $baseobject->dn= $this->dn;
49 $this->by_object['department']= $baseobject;
50 return(tabs::save(TRUE));
51 }
52 }
53 }
54 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
55 ?>