Code

Removed debug output
[gosa.git] / plugins / admin / departments / class_departmentGeneric.inc
index f31c70f338708d8f36c233a0736a686aded17e2a..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();
-               $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
-               if ($this->orig_dn == "new" && $ldap->count()){
+    $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.");
@@ -260,17 +253,19 @@ class department extends plugin
                return $message;
        }
 
-  
-  /* Prepare Unit tag */
-  function prepare_unit_tag()
-  {
+
+       /* Save to LDAP */
+       function save()
+       {
                $ldap= $this->config->get_ldap_link();
+
                /* Add tag objects if needed */
                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... */
@@ -293,17 +288,8 @@ class department extends plugin
                                }
                                $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
                        }
-               }else{
-      $this->gosaUnitTag = "";
-    }
-  }
-
+               }
 
-       /* Save to LDAP */
-       function save()
-       {
-               $ldap= $this->config->get_ldap_link();
-    $this->prepare_unit_tag();
                plugin::save();
 
                /* Remove tag information if needed */
@@ -316,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;
 
@@ -342,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);
@@ -376,8 +366,6 @@ class department extends plugin
        /* Tag objects to have the gosaAdministrativeUnitTag */
        function tag_objects($OnlySetTagFlag = false)
        {
-    $this->prepare_unit_tag();
-
     if(!$OnlySetTagFlag){
       $smarty= get_smarty();
       echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
@@ -395,6 +383,7 @@ class department extends plugin
                } else {
                        $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
                }
+
                while ($attrs= $ldap->fetch()){
 
                        /* Skip self */