Code

Updated gosaSupportDaemon.
[gosa.git] / gosa-core / include / class_plugin.inc
index a09efa033416924911aef656e5204e7da69386d0..89642ff57d9b66df0757447e42d714e02fd5ad27 100644 (file)
@@ -88,6 +88,7 @@ class plugin
 
   /* Save unit tags */
   var $gosaUnitTag= "";
+  var $skipTagging= FALSE;
 
   /*!
     \brief Used standard values
@@ -212,7 +213,7 @@ class plugin
           unset($this->saved_attributes[$index]);
           continue;
         }
-        if ($this->saved_attributes[$index]["count"] == 1){
+        if (isset($this->saved_attributes[$index][0]) || $this->saved_attributes[$index]["count"] == 1){
           $tmp= $this->saved_attributes[$index][0];
           unset($this->saved_attributes[$index]);
           $this->saved_attributes[$index]= $tmp;
@@ -358,7 +359,7 @@ class plugin
     }
 
     /* Handle tagging */
-    $this->tag_attrs(&$this->attrs);
+    $this->tag_attrs($this->attrs);
   }
 
 
@@ -817,7 +818,7 @@ class plugin
   {
     /* Rename dn in possible object groups */
     $ldap= $this->config->get_ldap_link();
-    $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.vLDAP::prepare4filter($src_dn).'))',
+    $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::prepare4filter($src_dn).'))',
         array('cn'));
     while ($attrs= $ldap->fetch()){
       $og= new ogroup($this->config, $ldap->getDN());
@@ -855,6 +856,11 @@ class plugin
 
   function move($src_dn, $dst_dn)
   {
+    /* Do not copy if only upper- lowercase has changed */
+    if(strtolower($src_dn) == strtolower($dst_dn)){
+      return(TRUE);
+    }
+
     /* Copy source to destination */
     if (!$this->copy($src_dn, $dst_dn)){
       return (FALSE);
@@ -887,31 +893,11 @@ class plugin
       return (FALSE);
     }
 
-    /* Perform a search for all objects to be moved */
-    $objects= array();
-    $ldap->cd($src_dn);
-    $ldap->search("(objectClass=*)", array("dn"));
-    while($attrs= $ldap->fetch()){
-      $dn= $attrs['dn'];
-      $objects[$dn]= strlen($dn);
-    }
-
-    /* Sort objects by indent level */
-    asort($objects);
-    reset($objects);
-
-    /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
-    foreach ($objects as $object => $len){
-      $src= $object;
-      $dst= preg_replace("/$src_dn$/", "$dst_dn", $object);
-      if (!$this->copy($src, $dst)){
-        return (FALSE);
-      }
-    }
+    $this->copy($src_dn, $dst_dn);
 
     /* Remove src_dn */
     $ldap->cd($src_dn);
-    $ldap->recursive_remove();
+    $ldap->recursive_remove($src_dn);
     return (TRUE);
   }
 
@@ -979,8 +965,16 @@ class plugin
     }
   }
 
-  function tag_attrs($at, $dn= "", $tag= "", $show= false)
+  function tag_attrs(&$at, $dn= "", $tag= "", $show= false)
   {
+    /* Skip tagging? 
+       If this is called from departmentGeneric, we have to skip this
+        tagging procedure. 
+     */
+    if($this->skipTagging){
+      return;
+    }
+
     /* No dn? Self-operation... */
     if ($dn == ""){
       $dn= $this->dn;
@@ -1019,14 +1013,14 @@ class plugin
     }
 
     /* Remove tags that may already be here... */
-    remove_objectClass("gosaAdministrativeUnitTag", &$at);
+    remove_objectClass("gosaAdministrativeUnitTag", $at);
     if (isset($at['gosaUnitTag'])){
         unset($at['gosaUnitTag']);
     }
 
     /* Set tag? */
     if ($tag != ""){
-      add_objectClass("gosaAdministrativeUnitTag", &$at);
+      add_objectClass("gosaAdministrativeUnitTag", $at);
       $at['gosaUnitTag']= $tag;
     }
   }