Code

Added check to avoid multiple uploads of the same file
[gosa.git] / plugins / admin / systems / class_terminalGeneric.inc
index 124f61bd17ece318ccd11bb176ebefac23568a52..5c825dcaead8423c96fba623721c7baf0c7f3af0 100644 (file)
@@ -76,6 +76,9 @@ class termgeneric extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -157,7 +160,10 @@ class termgeneric extends plugin
         $servername = $tmp3[0];
         $nfsname    = $tmp3[1];  
 
-        $path       = $tmp[4];  
+        $path ="";
+        if(isset($tmp[4])){
+          $path       = $tmp[4];  
+        }
 
         $tmp2[$servername.":".$path]= $servername.":".$path; 
       }else{
@@ -187,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 ();
+      }
     }
-
   }