diff --git a/gosa-core/plugins/admin/departments/tabs_department.inc b/gosa-core/plugins/admin/departments/tabs_department.inc
index 4788b8accb42d7532e918e4295dceaca5fd6d0f6..dcb1fef10b1c98730c351b5c5cd4f4481841df55 100644 (file)
{
var $base= "";
var $moved = FALSE;
{
var $base= "";
var $moved = FALSE;
+ var $base_name = "department";
- function deptabs($config, $data, $dn,$category)
+ function deptabs($config, $data, $dn,$category,$hide_refs = FALSE, $hide_acls = FALSE)
{
{
- tabs::tabs($config, $data, $dn,$category);
- $this->base= $this->by_object['department']->base;
+ tabs::tabs($config, $data, $dn,$category,$hide_refs, $hide_acls);
+
+ /* 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();
/* Add references/acls/snapshots */
$this->addSpecialTabs();
}
}
+ /*! \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()
{
function am_i_moved()
{
+ return(FALSE);
if($this->moved) return(FALSE);
if($this->moved) return(FALSE);
- $baseobject= &$this->by_object['department'];
- $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);
+ $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);
+
if ($this->dn != $new_dn && $this->dn != "new"){
return(TRUE);
}
return(FALSE);
}
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);
}
function move_done()
{
return($this->moved);
}
+ /*! \brief Initiate recursive move
+ */
function move_me()
{
if(!$this->am_i_moved()) return;
function move_me()
{
if(!$this->am_i_moved()) return;
- $baseobject= &$this->by_object['department'];
+ $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);
$ou = preg_replace('/,/', '\,', $baseobject->ou);
$new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base);
$old_ou = preg_replace('/,/', '\,', $baseobject->orig_ou);
function save($ignore_account= FALSE)
{
function save($ignore_account= FALSE)
{
- $baseobject= &$this->by_object['department'];
- $ou = preg_replace('/,/', '\,', $baseobject->ou);
- $new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base);
+ $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);
+ }
+
+ /* Update department cache.
+ */
+ if($this->dn != $new_dn){
+ global $config;
+ $config->get_departments();
+ }
+
+
$this->dn= $new_dn;
$baseobject->dn= $this->dn;
if (!$ignore_account){
$this->dn= $new_dn;
$baseobject->dn= $this->dn;
if (!$ignore_account){