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 deptabs extends tabs
24 {
25 var $base= "";
26 var $moved = FALSE;
27 var $base_name = "department";
29 function deptabs($config, $data, $dn,$category)
30 {
31 tabs::tabs($config, $data, $dn,$category);
33 /* Detect the base class (The classs which extends from department)
34 */
35 $class = "department";
36 foreach($this->by_object as $name => $object){
37 if($object instanceOf department){
38 $this->base_name = get_class($object);
39 break;
40 }
41 }
44 /* Add references/acls/snapshots */
45 $this->addSpecialTabs();
46 $this->by_object['acl']->skipTagging= TRUE;;
47 }
49 function check($ignore_account= FALSE)
50 {
51 return (tabs::check(TRUE));
52 }
55 /*! \brief Check if the department must must be moved
56 return Boolean TRUE if we have to move the dep, else FALSE
57 */
58 function am_i_moved()
59 {
60 return(FALSE);
61 if($this->moved) return(FALSE);
62 $baseobject= &$this->by_object[$this->base_name];
64 $namingAttr = $baseobject->namingAttr;
65 $orig_namingAttr = $baseobject->orig_namingAttr;
67 $value = preg_replace('/,/', '\,', $baseobject->$namingAttr);
68 $orig_value = preg_replace('/,/', '\,', $baseobject->$orig_namingAttr);
70 $new_dn = @LDAP::convert($namingAttr.'='.$value.','.$baseobject->base);
71 $old_dn = @LDAP::convert($namingAttr.'='.$orig_value.','.$baseobject->orig_base);
73 print_a(array($new_dn,$old_dn));
75 if ($this->dn != $new_dn && $this->dn != "new"){
76 return(TRUE);
77 }
78 return(FALSE);
79 }
82 /*! \brief Checks if the department was moved successfully
83 @return Boolean TRUE if the dep was already moved.
84 */
85 function move_done()
86 {
87 return($this->moved);
88 }
91 /*! \brief Initiate recursive move
92 */
93 function move_me()
94 {
95 if(!$this->am_i_moved()) return;
96 $baseobject= &$this->by_object[$this->base_name];
97 $ou = preg_replace('/,/', '\,', $baseobject->ou);
98 $new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base);
99 $old_ou = preg_replace('/,/', '\,', $baseobject->orig_ou);
100 $old_dn = @LDAP::convert('ou='.$ou.','.$baseobject->orig_base);
101 if ($this->dn != $new_dn && $this->dn != "new"){
102 $baseobject->recursive_move($this->dn, $new_dn);
103 $this->moved= TRUE;
104 }
105 }
108 function save($ignore_account= FALSE)
109 {
110 $baseobject= &$this->by_object[$this->base_name];
112 $namingAttr = $baseobject->namingAttr;
114 $nAV = preg_replace('/,/', '\,', $baseobject->$namingAttr);
115 $new_dn = @LDAP::convert($namingAttr.'='.$nAV.','.$baseobject->base);
117 /* Move group? */
118 if ($this->dn != $new_dn && $this->dn != "new"){
119 $baseobject->move($this->dn,$new_dn);
120 }
122 $this->dn= $new_dn;
123 $baseobject->dn= $this->dn;
124 if (!$ignore_account){
125 tabs::save(TRUE);
126 }
127 }
130 }
131 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
132 ?>