Code

Added check to avoid multiple uploads of the same file
[gosa.git] / plugins / admin / systems / class_terminalGeneric.inc
index f3e3a901b3127e4c129b4817b810bfbb5eef0419..5c825dcaead8423c96fba623721c7baf0c7f3af0 100644 (file)
@@ -78,6 +78,7 @@ class termgeneric extends plugin
   {
        /* Call parent execute */
        plugin::execute();
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -192,22 +193,27 @@ class termgeneric extends plugin
 
   function remove_from_parent()
   {
+    
     $ldap= $this->config->get_ldap_link();
-    $ldap->rmdir($this->dn);
-    show_ldap_error($ldap->get_error());
-
-    /* Optionally execute a command after we're done */
-    $this->handle_post_events("remove");
-
-    /* Delete references to object groups */
-    $ldap->cd ($this->config->current['BASE']);
-    $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
-    while ($ldap->fetch()){
-      $og= new ogroup($this->config, $ldap->getDN());
-      unset($og->member[$this->dn]);
-      $og->save ();
+    $ldap->cd($this->dn);
+    $ldap->cat($this->dn);
+    if($ldap->count()){
+
+      $ldap->rmdir($this->dn);
+      show_ldap_error($ldap->get_error());
+
+      /* Optionally execute a command after we're done */
+      $this->handle_post_events("remove");
+
+      /* Delete references to object groups */
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+      while ($ldap->fetch()){
+        $og= new ogroup($this->config, $ldap->getDN());
+        unset($og->member[$this->dn]);
+        $og->save ();
+      }
     }
-
   }