From: psc Date: Mon, 20 Jul 2009 11:58:56 +0000 (+0000) Subject: By default do not delete recursive X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=db4b849762ed6b7b7d155443a1ea204386d491db;p=gosa.git By default do not delete recursive git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13940 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc b/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc index 292269497..bb0e295e5 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc @@ -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 */ diff --git a/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc index ecbfd736d..7f40c58b6 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -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;