Code

By default do not delete recursive
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 20 Jul 2009 11:58:56 +0000 (11:58 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 20 Jul 2009 11:58:56 +0000 (11:58 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13940 594d385d-05f5-0310-b6e9-bd551577e9d8

trunk/gosa-plugins/fai/admin/fai/class_FAI.inc
trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc

index 2922694972d0b5606474214f985d3be3fdfeef3d..bb0e295e55a0ed583d6507be4c2aead135166e3a 100644 (file)
@@ -569,8 +569,9 @@ class FAI
 
 
   /* this function will remove all unused (deleted) objects,
-     that have no parent object */
-  static function clean_up_releases($Current_DN)
+     that have no parent object. If $recursive is set to true,
+     also check sub releases. */
+  static function clean_up_releases($Current_DN, $recursive=true)
   {
     global $config;
     $ldap = $config->get_ldap_link();
@@ -586,11 +587,14 @@ class FAI
     /* We must also include the given release dn */
     $previous_releases[] = $base_release;
 
-    /* Merge parent, current and child releases into one big release to 
-       iterate over */
     $all_releases = $previous_releases;
-    foreach($sub_releases as $sub_release){
-      $all_releases[] = $sub_release;
+
+    if ($recursive) {
+      /* Merge parent, current and child releases into one big release to 
+         iterate over */
+      foreach($sub_releases as $sub_release){
+        $all_releases[] = $sub_release;
+      }
     }
 
     /* Walk through all releases */
index ecbfd736d2b8d5ff8f2b62d96eb4806c44fb0772..7f40c58b622ca2f8f96ce3bf2cb7aa12f3b9a4ff 100644 (file)
@@ -976,6 +976,21 @@ class faiManagement extends plugin
                        }else{
                                $this->dialog->save();
         FAI::save_release_changes_now();
+        $to_del = FAI::clean_up_releases($this->dn, false);
+        $ldap = $this->config->get_ldap_link();
+        $ldap->cd($this->dn);
+        foreach($to_del as $dn){
+          /* Only delete subobjects of the current FAI class */
+          $cn = $ldap->getCn($dn);
+          $ldap->search("cn=$cn", array('dn'));
+          if ($ldap->count()){
+            while($attrs = $ldap->fetch()){
+              if ($attrs['dn'] == $dn) {
+                $ldap->rmdir_recursive($dn);
+              }
+            }
+          }
+        }
         if (!isset($_POST['edit_apply'])){
           $this->remove_lock();
           $this->dialog=FALSE;