Code

Apply patch from mba for #4170
[gosa.git] / trunk / gosa-plugins / fai / admin / fai / class_faiManagement.inc
index dc7bac243abd6934baefd076afe959f6b55c2624..c0114568aab192844a91429f03e9d619435b6b80 100644 (file)
@@ -326,8 +326,13 @@ class faiManagement extends plugin
           $this->dialog->set_acl_base($dn);
           $this->dialog->by_object[$type[1]]->remove_from_parent ();
           $this->dialog= FALSE;
-          $to_del = FAI::clean_up_releases($dn);
           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);
           }
@@ -365,7 +370,9 @@ class faiManagement extends plugin
         $ids = $this->list_get_selected_items();
         $to_delete = array();
         foreach($ids as $id){
-          $to_delete = array_merge($to_delete,$this->objects[$id]);
+          foreach($this->objects[$id] as $obj) {
+            array_push($to_delete, $obj);
+          }
         }
       } 
 
@@ -878,7 +885,7 @@ class faiManagement extends plugin
       if(preg_match("/c/",$acl)){
         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
         $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
-        $this->dialog->set_acl_base($this->base);
+        $this->dialog->set_acl_base($this->acl_base);
         $this->dialog->parent = &$this;
 
         $this->is_dialog = false;
@@ -905,7 +912,7 @@ class faiManagement extends plugin
 
         if(class_exists($a_setup[0])){
           $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
-          $this->dialog->set_acl_base($this->base);
+          $this->dialog->set_acl_base($this->acl_base);
           $this->dialog->by_object[$a_setup[1]]->cn = $name;
           $this->dialog->parent = &$this;
           $this->is_dialog = true;
@@ -969,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 */
+          $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;