X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Fplugins%2Fadmin%2Fdepartments%2Ftabs_department.inc;h=86f0acd65053e2613b59e6bfb7b7b2541b94a665;hb=698cb9465f35d82d587bcb73c21be149cbaabc13;hp=796bdffe60e9b77f868f8e59c4c561c30e0ff639;hpb=143b9c875338ccec9585cff03ca0d3f3d657df96;p=gosa.git diff --git a/gosa-core/plugins/admin/departments/tabs_department.inc b/gosa-core/plugins/admin/departments/tabs_department.inc index 796bdffe6..86f0acd65 100644 --- a/gosa-core/plugins/admin/departments/tabs_department.inc +++ b/gosa-core/plugins/admin/departments/tabs_department.inc @@ -1,16 +1,48 @@ base= $this->by_object['department']->base; + + /* Detect the base class (The classs which extends from department) + */ + foreach($this->by_object as $name => $object){ + if($object instanceOf department){ + $this->base_name = get_class($object); + break; + } + } + /* Add references/acls/snapshots */ $this->addSpecialTabs(); + $this->by_object['acl']->skipTagging= TRUE;; } function check($ignore_account= FALSE) @@ -19,31 +51,78 @@ class deptabs extends tabs } - function save($ignore_account= FALSE) + /*! \brief Check if the department must must be moved + return Boolean TRUE if we have to move the dep, else FALSE + */ + function am_i_moved() { - $baseobject= $this->by_object['department']; - $ou= preg_replace('/,/', '\,', $baseobject->ou); - $new_dn= @LDAP::convert('ou='.$ou.','.$baseobject->base); - - if($ignore_account){ - if ($this->dn != $new_dn && $this->dn != "new"){ - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - msg_dialog::display(_("LDAP error"), _("Moving LDAP tree failed: destination tree is a subtree of the source!"), ERROR_DIALOG); - }else{ - /* Prepare to be moved */ - $baseobject->recursive_move($this->dn, $new_dn); - $this->by_object['department'] = $baseobject; - return; - } - } + return(FALSE); + if($this->moved) return(FALSE); + $baseobject= &$this->by_object[$this->base_name]; + + $namingAttr = $baseobject->namingAttr; + $orig_namingAttr = $baseobject->orig_namingAttr; + + $value = preg_replace('/,/', '\,', $baseobject->$namingAttr); + $orig_value = preg_replace('/,/', '\,', $baseobject->$orig_namingAttr); + + $new_dn = @LDAP::convert($namingAttr.'='.$value.','.$baseobject->base); + $old_dn = @LDAP::convert($namingAttr.'='.$orig_value.','.$baseobject->orig_base); + + print_a(array($new_dn,$old_dn)); + + if ($this->dn != $new_dn && $this->dn != "new"){ + return(TRUE); + } + return(FALSE); + } + + + /*! \brief Checks if the department was moved successfully + @return Boolean TRUE if the dep was already moved. + */ + function move_done() + { + return($this->moved); + } + + + /*! \brief Initiate recursive move + */ + function move_me() + { + if(!$this->am_i_moved()) return; + $baseobject= &$this->by_object[$this->base_name]; + $ou = preg_replace('/,/', '\,', $baseobject->ou); + $new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base); + $old_ou = preg_replace('/,/', '\,', $baseobject->orig_ou); + $old_dn = @LDAP::convert('ou='.$ou.','.$baseobject->orig_base); + if ($this->dn != $new_dn && $this->dn != "new"){ + $baseobject->recursive_move($this->dn, $new_dn); + $this->moved= TRUE; } + } + + + function save($ignore_account= FALSE) + { + $baseobject= &$this->by_object[$this->base_name]; + + $namingAttr = $baseobject->namingAttr; + + $nAV = preg_replace('/,/', '\,', $baseobject->$namingAttr); + $new_dn = @LDAP::convert($namingAttr.'='.$nAV.','.$baseobject->base); + + /* Move group? */ + if ($this->dn != $new_dn && $this->dn != "new"){ + $baseobject->move($this->dn,$new_dn); + } + $this->dn= $new_dn; $baseobject->dn= $this->dn; - $this->by_object['department']= $baseobject; - return(tabs::save(TRUE)); + if (!$ignore_account){ + tabs::save(TRUE); + } }