Code

Updated department handling.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Nov 2008 11:47:39 +0000 (11:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Nov 2008 11:47:39 +0000 (11:47 +0000)
-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

gosa-core/plugins/admin/departments/class_countryGeneric.inc
gosa-core/plugins/admin/departments/class_dcObject.inc
gosa-core/plugins/admin/departments/class_departmentGeneric.inc
gosa-core/plugins/admin/departments/class_departmentManagement.inc
gosa-core/plugins/admin/departments/class_localityGeneric.inc
gosa-core/plugins/admin/departments/class_organizationGeneric.inc

index 36790bff4b332790e84d20941526d3ae80281af2..1d51e6fe070315187b1ecd8208e9049839c3b4dd 100644 (file)
@@ -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 ="";
index 16de04c28bce22ffe8f4e1c726dabc319d7e5ea0..9c24f47376a41795ffe392394cbaf6e37bf25f86 100644 (file)
@@ -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    = "";
index b7d98153095ecf137c496e768ad80d82ae59a3e9..105b479c6b4fecd5710b62bce6cc2920705c5a24 100644 (file)
@@ -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;
index 0637be02a0ef01bf45fb7634f148f776ed3dc0ff..a6118c39866d7910e23000106502e931450b339c 100644 (file)
@@ -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";
index 3aecf1c19cd7b64cbbb903955870cb7cf65c3750..288902e9f0e1180fccd3250ae7cec409c67cd13e 100644 (file)
@@ -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";
index 5a3e623ba943789b7e4442d3e5d7e3cedfca8c5d..3ed574c082cedd11e6e50784dde0905d2809bd47 100644 (file)
@@ -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 
    */