Code

Make it resist to non existing objects
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 May 2006 08:56:13 +0000 (08:56 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 May 2006 08:56:13 +0000 (08:56 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3259 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_plugin.inc

index 81e317daa5d5f0daa22c1c1e5f06929000994f28..52a2a03792ba65b58a3cccc26b5d999efc037f2c 100644 (file)
@@ -909,18 +909,22 @@ class plugin
         echo "DEBUG: $dn is already tagged<br>";
         return;
       }
-      echo "DEBUG: Add tagging ($tag) to $dn.<br>";
-      $nattrs= array("gosaUnitTag" => $this->gosaUnitTag);
-      $nattrs['objectClass']= array();
-      for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
-        $oc= $attrs['objectClass'][$i];
-        if ($oc != "gosaAdministrativeUnitTag"){
-          $nattrs['objectClass'][]= $oc;
+      if (count($attrs)){
+        echo "DEBUG: Add tagging ($tag) to $dn.<br>";
+        $nattrs= array("gosaUnitTag" => $this->gosaUnitTag);
+        $nattrs['objectClass']= array();
+        for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
+          $oc= $attrs['objectClass'][$i];
+          if ($oc != "gosaAdministrativeUnitTag"){
+            $nattrs['objectClass'][]= $oc;
+          }
         }
+        $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
+        $ldap->cd($dn);
+        $ldap->modify($nattrs);
+      } else {
+        echo "DEBUG: not tagging ($tag) $dn - seems to have moved away<br>";
       }
-      $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
-      $ldap->cd($dn);
-      $ldap->modify($nattrs);
       
     } else {
       /* Remove objectclass and attribute */