Code

Removed debug output
[gosa.git] / plugins / admin / departments / class_departmentGeneric.inc
index feda1d7fd0570d9fc44701220b6529422d629b72..c1ef6e11d3f79cbe72d45c8c033c54e1bf3be0cc 100644 (file)
@@ -97,7 +97,7 @@ class department extends plugin
                foreach($_POST as $name => $value){
                        if(preg_match("/^chooseBase/",$name) && $once){
                                $once = false;
-                               $this->dialog = new baseSelectDialog($this->config);
+                               $this->dialog = new baseSelectDialog($this->config,$this);
                                $this->dialog->setCurrentBase($this->base);
                        }
                }
@@ -167,7 +167,7 @@ class department extends plugin
                $ldap= $this->config->get_ldap_link();
                $ldap->cd ($this->dn);
                $ldap->recursive_remove();
-               show_ldap_error($ldap->get_error(), _("Removing department failed"));
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of department with dn '%s' failed."),$this->dn));
 
                /* Optionally execute a command after we're done */
                $this->handle_post_events('remove');
@@ -175,13 +175,6 @@ class department extends plugin
 
        function must_be_tagged()
        {
-    if((isset($this->attrs['gosaUnitTag'][0])) && ($this->is_administrational_unit)){
-      $this->must_be_tagged = false;
-    }elseif((!isset($this->attrs['gosaUnitTag'][0])) && (!$this->is_administrational_unit)){
-      $this->must_be_tagged = false;
-    }else{
-      $this->must_be_tagged = true;
-    }
                return $this->must_be_tagged;
        }
 
@@ -228,8 +221,8 @@ class department extends plugin
 
                /* Check for presence of this department */
                $ldap= $this->config->get_ldap_link();
-               $attrs= $ldap->cat ($this->dn, array('dn'));
-               if ($this->orig_dn == "new" && !($attrs === FALSE)){
+    $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
+    if ($this->orig_dn == "new" && $ldap->count()){
                        $message[]= _("Department with that 'Name' already exists.");
                } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
                        $message[]= _("Department with that 'Name' already exists.");
@@ -270,8 +263,9 @@ class department extends plugin
                if ($this->is_administrational_unit){
       if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){
                        $this->objectclasses[]= "gosaAdministrativeUnit";
-        $this->gosaUnitTag= "";
+                         $this->gosaUnitTag= "";
       }
+
                        if ($this->gosaUnitTag == ""){
 
                                /* It's unlikely, but check if already used... */
@@ -294,8 +288,6 @@ class department extends plugin
                                }
                                $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
                        }
-               } else {
-                       $this->gosaUnitTag= "";
                }
 
                plugin::save();
@@ -310,9 +302,9 @@ class department extends plugin
                                if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
                                        $tmp[]= $oc;
                                }
-        if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
-          $has_unit_tag= true;
-        }
+                               if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
+                                       $has_unit_tag= true;
+                               }
                        }
                        $this->attrs['objectClass']= $tmp;
 
@@ -336,13 +328,17 @@ class department extends plugin
                        $ldap->add($this->attrs);
                        $this->handle_post_events('add');
                }
-               show_ldap_error($ldap->get_error(), _("Saving department failed"));
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of department with dn '%s' failed."),$this->dn));
+
+    /* The parameter forces only to set must_be_tagged, and don't touch any objects 
+        This will be done later */
+    $this->tag_objects(true);
 
     /* Fix tagging if needed */
     if (!$this->is_administrational_unit){
       $this->handle_object_tagging();
     }
-
+    
     /* Optionally execute a command after we're done */
                $this->postcreate();
     return(true);
@@ -387,6 +383,7 @@ class department extends plugin
                } else {
                        $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
                }
+
                while ($attrs= $ldap->fetch()){
 
                        /* Skip self */