Code

updated removement
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 24 Jan 2006 09:03:14 +0000 (09:03 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 24 Jan 2006 09:03:14 +0000 (09:03 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2547 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_printGeneric.inc
plugins/admin/systems/class_terminalGeneric.inc

index ee8a25a8973e263b234fced8b5f13cd1b5c9e9fb..8c675f42c85cbb9b9bb99cc9e8891d22d29f146f 100644 (file)
@@ -429,24 +429,28 @@ class printgeneric extends plugin
 
   function remove_from_parent()
   {
-    $this->dn= preg_replace('/ou=workstations,/', 'ou=printers,', $this->dn);
-    $ldap= $this->config->get_ldap_link();
-    $ldap->rmdir($this->dn);
-    show_ldap_error($ldap->get_error());
-    $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 ();
+    if($this->initially_was_account){
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cat($this->dn);
+      if(count($ldap->fetch()) ){
+
+        $ldap->rmdir($this->dn);
+        show_ldap_error($ldap->get_error());
+        $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 ();
+        }
+      }
     }
   }
-
-  /* Save data to object */
-  function save_object()
+    /* Save data to object */
+    function save_object()
   {
     plugin::save_object();
 
index 86aa8966e1f5b0aee580440b29a899694c0d97c0..5c825dcaead8423c96fba623721c7baf0c7f3af0 100644 (file)
@@ -193,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 ();
+      }
     }
-
   }