From: psc Date: Mon, 22 Jun 2009 10:30:15 +0000 (+0000) Subject: Revert 13752 because it might cause data loss X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5b43dcd187cfa64a137d52a1708a06e9662116fe;p=gosa.git Revert 13752 because it might cause data loss git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13754 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 ead485cb1..7cfb966cc 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc @@ -185,12 +185,10 @@ class FAI if(!$removed){ $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - $parent_dn = FAI::get_parent_object($Current_DN); /* Get some basic informations */ $parent_obj = FAI::get_parent_release_object($Current_DN); - /* Check whether parent object is removed, do not create object in this case */ - if(!empty($parent_obj) && !FAI::parent_is_removed($Current_DN)){ + if(!empty($parent_obj)){ $ldap->cat($parent_obj,array("*")); $attrs = FAI:: prepare_ldap_fetch_to_be_saved($ldap->fetch()); @@ -505,10 +503,7 @@ class FAI echo "Create an empty placeholder in follwing release ".$key; print_a($objectAttrs); } - /* Only save removed parent objects, not their children */ - if (FAI::is_parent_object($Current_DN)){ - FAI::save_FAI_object($key,$objectAttrs); - } + FAI::save_FAI_object($key,$objectAttrs); } } }else{ @@ -522,15 +517,11 @@ class FAI print_a($parent_attrs); } - /* Only update the freeze tag if the entry actually exists. */ - $ldap->cat($key); - if($ldap->count()){ - /* Append FAIstate tag to ensure that freezed objects stay freezed - */ - $rTag = FAI::get_release_tag(FAI::get_release_dn($key)); - $parent_attrs['FAIstate'] = $rTag; - FAI::save_FAI_object($key,$parent_attrs); - } + /* Append FAIstate tag to ensure that freezed objects stay freezed + */ + $rTag = FAI::get_release_tag(FAI::get_release_dn($key)); + $parent_attrs['FAIstate'] = $rTag; + FAI::save_FAI_object($key,$parent_attrs); } } @@ -1279,101 +1270,7 @@ class FAI } } - /* Returns true if this is a parent object, e.g. FAIpartitionTable, not FAIpartitionDisk */ - static function is_parent_object($dn) - { - global $config; - $Current_DN = $dn; - - /* special case partitions, as they don't start with cn= in their DN (schema bug?) */ - if (preg_match('/^FAIpartitionNr=/', $Current_DN)){ - return false; - } - - $parent_dn = preg_replace('/^cn=[^,.]*,/', '', $Current_DN); - if (preg_match('/^cn=/', $parent_dn)) { - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - $ldap->cat($parent_dn); - if($ldap->count()){ - return false; - } - }else{ - return true; - } - } - - /* Return a child objects, if there are any */ - static function get_child_objects($dn) - { - global $config; - $Current_DN = $dn; - - if (FAI::is_parent_object($Current_DN)){ - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - $ldap->search("(objectClass=FAIclass)",array("dn")); - while($attrs = $ldap->fetch()){ - $newdn=$attrs['dn']; - if(preg_match("/".preg_quote($Current_DN, '/')."/",$attrs['dn']) && $attrs['dn'] != $Current_DN){ - $children[] = $attrs['dn']; - } - } - }else{ - $children[] = array(); - } - return $children; - } - - /* Get the DN of the parent object; e.g. the FAIpartitionTable of a FAIpartitionDisk */ - static function get_parent_object($dn) - { - global $config; - $Current_DN = $dn; - - $tmp_dn = $Current_DN; - $parent_dn = $tmp_dn; - - /* special case partitions, as they don't start with cn= in their DN (schema bug?) */ - $tmp_dn = preg_replace('/^FAIpartitionNr=/', 'cn=', $tmp_dn); - while (preg_match('/^cn=/', $tmp_dn)){ - $parent_dn = $tmp_dn; - $tmp_dn = preg_replace('/^cn=[^,.]*,/', '', $parent_dn); - } - if ($parent_dn != $Current_DN){ - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - $ldap->cat($parent_dn); - - /* Check objectClasses and name to check if this is a release department */ - if($ldap->count()){ - return $parent_dn; - } - } - return ""; - } - - /* Check whether parent object is removed */ - static function parent_is_removed($dn) - { - global $config; - $Current_DN = $dn; - - $ldap = $config->get_ldap_link(); - $parent_dn = FAI::get_parent_object($Current_DN); - if ($parent_dn) { - $ldap->cd($config->current['BASE']); - $ldap->cat($parent_dn); - $parentObjectAttrs = FAI::prepare_ldap_fetch_to_be_saved($ldap->fetch()); - if(isset($parentObjectAttrs['FAIstate'][0])){ - if(preg_match("/removed$/",$parentObjectAttrs['FAIstate'][0])){ - return true; - } - } - } - return false; - } } diff --git a/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc index 1ff814304..4a20ab0e7 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -328,8 +328,6 @@ 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 */ - $to_del += FAI::get_child_objects($dn); foreach($to_del as $dn){ $ldap->rmdir_recursive($dn); }