From a4785ce8e737b5abdeb9df8c6baff6d0aad08d57 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 26 Nov 2008 11:47:39 +0000 Subject: [PATCH] Updated department handling. -Keep the structural object class of the source object. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13041 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../departments/class_countryGeneric.inc | 3 +- .../admin/departments/class_dcObject.inc | 3 +- .../departments/class_departmentGeneric.inc | 29 +++++++++++++++++-- .../class_departmentManagement.inc | 2 +- .../departments/class_localityGeneric.inc | 3 +- .../departments/class_organizationGeneric.inc | 3 +- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/gosa-core/plugins/admin/departments/class_countryGeneric.inc b/gosa-core/plugins/admin/departments/class_countryGeneric.inc index 36790bff4..1d51e6fe0 100644 --- a/gosa-core/plugins/admin/departments/class_countryGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_countryGeneric.inc @@ -24,7 +24,8 @@ class country extends department { /* attribute list for save action */ var $attributes = array( "c", "ou", "description"); - var $objectclasses = array("top", "country", "gosaDepartment"); + var $objectclasses = array("top", "gosaDepartment"); + var $structuralOC = array("country"); var $type ="c"; var $c =""; var $orgi_c =""; diff --git a/gosa-core/plugins/admin/departments/class_dcObject.inc b/gosa-core/plugins/admin/departments/class_dcObject.inc index 16de04c28..9c24f4737 100644 --- a/gosa-core/plugins/admin/departments/class_dcObject.inc +++ b/gosa-core/plugins/admin/departments/class_dcObject.inc @@ -24,7 +24,8 @@ class dcObject extends department { /* attribute list for save action */ var $attributes = array( "dc", "ou", "description"); - var $objectclasses = array("top", "dcObject", "gosaDepartment", "locality"); + var $objectclasses = array("top", "dcObject", "gosaDepartment"); + var $structuralOC = array("locality"); var $type = "dc"; var $dc = ""; var $orgi_dc = ""; diff --git a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc index b7d981530..105b479c6 100644 --- a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc @@ -47,14 +47,39 @@ 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{ + echo $dn; + $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; diff --git a/gosa-core/plugins/admin/departments/class_departmentManagement.inc b/gosa-core/plugins/admin/departments/class_departmentManagement.inc index 0637be02a..a6118c398 100644 --- a/gosa-core/plugins/admin/departments/class_departmentManagement.inc +++ b/gosa-core/plugins/admin/departments/class_departmentManagement.inc @@ -580,7 +580,7 @@ class departmentManagement extends plugin $types['organization']['TITLE'] = _("Organization"); $types['organization']['TPL'] = "organization.tpl"; - /* Organization + /* Department */ $types['organizationalUnit']['ACL'] = "department"; $types['organizationalUnit']['CLASS'] = "department"; diff --git a/gosa-core/plugins/admin/departments/class_localityGeneric.inc b/gosa-core/plugins/admin/departments/class_localityGeneric.inc index 3aecf1c19..288902e9f 100644 --- a/gosa-core/plugins/admin/departments/class_localityGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_localityGeneric.inc @@ -24,7 +24,8 @@ class locality extends department { /* attribute list for save action */ var $attributes = array("l", "description", "ou"); - var $objectclasses = array("top", "locality", "gosaDepartment"); + var $objectclasses = array("top", "gosaDepartment"); + var $structuralOC = array("locality"); var $description= ""; var $type = "l"; diff --git a/gosa-core/plugins/admin/departments/class_organizationGeneric.inc b/gosa-core/plugins/admin/departments/class_organizationGeneric.inc index 5a3e623ba..3ed574c08 100644 --- a/gosa-core/plugins/admin/departments/class_organizationGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_organizationGeneric.inc @@ -30,7 +30,8 @@ class organization extends department "postOfficeBox","postalCode", "postalAddress","physicalDeliveryOfficeName", "st","l","teletexTerminalIdentifier"); - var $objectclasses = array("top", "organization", "gosaDepartment"); + var $objectclasses = array("top", "gosaDepartment"); + var $structuralOC = array("organization"); /* Attributes */ -- 2.30.2