Code

Make sure delete actions are properly cancelled by calling the
[gosa.git] / trunk / gosa-plugins / fai / admin / fai / class_faiManagement.inc
index 4a20ab0e7ab7eede35916161b873cf317123e6eb..3fd299e6bae458c1c3231a4709721bf075788856 100644 (file)
@@ -328,6 +328,11 @@ class faiManagement extends plugin
           $this->dialog= FALSE;
           FAI::save_release_changes_now();
           $to_del = FAI::clean_up_releases($dn);
+          /* Remove sub-objects (e.g. the variable key/value of a FAIvariable) from LDAP entirely */
+          $children = FAI::get_child_objects($dn);
+          if ($children) {
+            $to_del += $children;
+          }
           foreach($to_del as $dn){
             $ldap->rmdir_recursive($dn);
           }
@@ -352,7 +357,9 @@ class faiManagement extends plugin
      ****************/
 
     if ($s_action=="del_multiple" || 
-        $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "remove"){
+        $this->dialog instanceOf faiGroupHandle && 
+        $this->dialog->get_mode() == "remove" &&
+        !isset($_POST['delete_multiple_fai_object_cancel'])){
  
       /* Collect objects to delete and check if objects are freezed
        */ 
@@ -416,6 +423,7 @@ class faiManagement extends plugin
     if(isset($_POST['delete_multiple_fai_object_cancel'])){
       $this->remove_lock();
       $this->dns = array();
+      $this->dialog = FALSE;
     }
 
     /****************
@@ -971,6 +979,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 */
+          $ldap->cd($this->dn);
+          $ldap->search("(|(objectClass=FAIclass)(objectClass=FAIdebconfInfo))", 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;
@@ -1395,7 +1418,7 @@ class faiManagement extends plugin
       } 
       $res  = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);    
     }else{
-      $res  = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
+      $res  = FAI::get_all_objects_for_given_base($base,"(|(objectClass=FAIprofile)(objectClass=".$oc."))",TRUE);
     }
     $delete = array();
     $used   = array();