X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Fplugins%2Fadmin%2Fdepartments%2Fclass_departmentGeneric.inc;h=78e514f1e2af041e3b302cd4d85cb3c5cc4e9713;hb=10100c5c8d92e45a0719bc321a3767f65966d9d7;hp=e851984322288ea4f5b5a4a2355e27b20b6d345b;hpb=d9a99d65c0a2747863478c63ad60fa9d9fd075b0;p=gosa.git diff --git a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc index e85198432..78e514f1e 100644 --- a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc @@ -36,7 +36,7 @@ class department extends plugin var $gosaUnitTag= ""; var $view_logged = FALSE; - var $type ="ou"; + var $type ="organizationalUnit"; var $namingAttr = "ou"; /* Headpage attributes */ @@ -47,14 +47,38 @@ class department extends plugin /* attribute list for save action */ var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress", "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag"); - var $objectclasses= array("top", "gosaDepartment", "organizationalUnit"); - var $initially_was_tagged = false; + /* Do not append the structural object classes here, they are added dynamically in the constructor */ + var $objectclasses= array("top", "gosaDepartment"); + var $structuralOC = array("organizationalUnit"); + + var $initially_was_tagged = false; var $orig_base = ""; var $orig_ou = ""; function department (&$config, $dn) { + /* Add the default structural obejct class 'locality' if this is a new entry + */ + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + if($dn == "" || $dn == "new" || !$ldap->dn_exists($dn)){ + $this->objectclasses = array_merge($this->structuralOC,$this->objectclasses); + }else{ + $ldap->cat($dn, array("structuralObjectClass")); + $attrs= $ldap->fetch(); + if(isset($attrs['structuralObjectClass']['count'])){ + for($i = 0 ; $i < $attrs['structuralObjectClass']['count'] ; $i++){ + $this->objectclasses[] = $attrs['structuralObjectClass'][$i]; + } + }else{ + + /* Could not detect structural object class for this object, fall back to the default 'locality' + */ + $this->objectclasses = array_merge($this->structuralOC,$this->objectclasses); + } + } + $this->objectclasses = array_unique($this->objectclasses); plugin::plugin($config, $dn); $this->is_account= TRUE; @@ -159,9 +183,8 @@ class department extends plugin }else{ $tmp = array(); foreach($bases as $dn=>$base){ - $fixed = str_replace("/","\\",$this->dn); /* Only attach departments which are not a subtree of this one */ - if(!preg_match("/".$fixed."/",$dn)){ + if(!preg_match("/".preg_quote($this->dn)."/",$dn)){ $tmp[$dn]=$base; } } @@ -186,7 +209,7 @@ class department extends plugin $dep_types = departmentManagement::get_support_departments(); $tpl =""; foreach($dep_types as $key => $data){ - if($data['ATTR'] == $this->type){ + if($data['OC'] == $this->type){ $tpl = $data['TPL']; break; } @@ -254,15 +277,15 @@ class department extends plugin /* Save tagging flag */ if ($this->acl_is_writeable("gosaUnitTag")){ - if (isset($_POST['gosaUnitTag'])){ + if (isset($_POST['is_administrational_unit'])){ $this->is_administrational_unit= true; } else { $this->is_administrational_unit= false; } } - /* If this is the root directory service entry (rootDSE) - then avoid changing the naming attribute of this entry. + /* If this is the root directory service entry then avoid + changing the naming attribute of this entry. */ if($this->dn == $this->config->current['BASE']){ $this->$nA = $old_nA; @@ -369,20 +392,18 @@ class department extends plugin $this->skipTagging = TRUE; plugin::save(); - /* Remove tag information if needed */ if (!$this->is_administrational_unit && $this->initially_was_tagged){ $tmp= array(); /* Remove gosaAdministrativeUnit from this plugin */ - $has_unit_tag= false; foreach($this->attrs['objectClass'] as $oc){ + if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){ + continue; + } if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){ $tmp[]= $oc; } - if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){ - $has_unit_tag= true; - } } $this->attrs['objectClass']= $tmp; $this->attrs['gosaUnitTag']= array(); @@ -433,7 +454,7 @@ class department extends plugin
'; - echo "'; - echo ""; + echo "