Code

Fixed tagging.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 13 Jul 2006 06:00:14 +0000 (06:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 13 Jul 2006 06:00:14 +0000 (06:00 +0000)
The tagging method was called twice.
-The first call was ok.
-But the second call failed.
Because we have checked the objectClasses for gosaAdministrativeUnitTag, and the objectClasses wasn't present in this->attrs anymore
because cleanup from last save() call removed all objectClasses and so, $this->gosaUnitTag was set to "" to generate a new one.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4134 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/departments/class_departmentGeneric.inc

index 56476efcbf6138529ccc373e26cec58b12aee72d..525e9d2457fd5a2da41bc832b9675cfe72b052fc 100644 (file)
@@ -48,6 +48,7 @@ class department extends plugin
        var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
                        "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
        var $objectclasses= array("top", "gosaDepartment", "organizationalUnit");
+  var $initially_was_tagged = false;
 
        function department ($config, $dn)
        {
@@ -79,6 +80,7 @@ class department extends plugin
                /* Is administrational Unit? */
                if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
                        $this->is_administrational_unit= true;
+      $this->initially_was_tagged = true;
                }
        }
 
@@ -261,9 +263,15 @@ class department extends plugin
 
                /* Add tag objects if needed */
                if ($this->is_administrational_unit){
-      if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){
+
+      /* If this wasn't tagged before add oc an reset unit tag */
+      if(!$this->initially_was_tagged){
                        $this->objectclasses[]= "gosaAdministrativeUnit";
                          $this->gosaUnitTag= "";
+
+        /* It seams that this method is called twice, 
+            set this to true. to avoid adding this oc twice */
+        $this->initially_was_tagged = true;
       }
 
                        if ($this->gosaUnitTag == ""){
@@ -311,6 +319,7 @@ class department extends plugin
                        if(!$has_unit_tag && isset($this->attrs['gosaUnitTag'])){
                                $this->attrs['gosaUnitTag']= array();
                        }
+      $this->gosaUnitTag = "";
                }
 
                /* Write back to ldap */