From: hickert Date: Thu, 6 Jul 2006 08:44:34 +0000 (+0000) Subject: Fixed multirelease behavior, will manage all sub release not only the first found. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e054d4a7f561b252a1bcd4f2c1284b0e45f55cf7;p=gosa.git Fixed multirelease behavior, will manage all sub release not only the first found. Better handle for object removement. Fixed debug output git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4034 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/functions_FAI.inc b/include/functions_FAI.inc index 15d18f373..f565c07d1 100644 --- a/include/functions_FAI.inc +++ b/include/functions_FAI.inc @@ -134,7 +134,7 @@ function get_all_releases_from_base($dn) !!!!!!! No functionality just output */ -function prepare_to_save_FAI_object($Current_DN,$objectAttrs) +function prepare_to_save_FAI_object($Current_DN,$objectAttrs,$removed = false) { /* Get ldap object */ global $config; @@ -155,6 +155,32 @@ function prepare_to_save_FAI_object($Current_DN,$objectAttrs) $is_new = false; } + /* if parameter removed is true, we have to add FAIstate to the current attrs + FAIstate should end with ...|removed after this operation */ + if($removed ){ + $ldap->cat($Current_DN); + + if((!$ldap->count()) && !empty($parent_obj)){ + $ldap->cat($parent_obj); + } + if(!$ldap->count()){ + + echo "Error can't remove this object ".$Current_DN; + return; + + }else{ + + $objectAttrs = prepare_ldap_fetch_to_be_saved($ldap->fetch()); + if(isset($objectAttrs['FAIstate'][0])){ + if(!preg_match("/removed$/",$objectAttrs['FAIstate'][0])){ + $objectAttrs['FAIstate'][0] .= "|removed"; + } + }else{ + $objectAttrs['FAIstate'][0] = "|removed"; + } + } + } + /* Check if this a leaf release or not */ if(count($following_releases) == 0 ){ @@ -183,14 +209,14 @@ function prepare_to_save_FAI_object($Current_DN,$objectAttrs) echo "Saving main object".$Current_DN; print_a($objectAttrs); - - $key = $r[key($r)]; - echo "Saving parent to following release ".$key; - print_a($parent_attrs); - + save_FAI_object($Current_DN,$objectAttrs); - save_FAI_object($key,$parent_attrs); + foreach($r as $key){ + echo "Saving parent to following release ".$key; + print_a($parent_attrs); + save_FAI_object($key,$parent_attrs); + } }else{ echo "Saving main object".$Current_DN; @@ -198,24 +224,27 @@ function prepare_to_save_FAI_object($Current_DN,$objectAttrs) save_FAI_object($Current_DN,$objectAttrs); - $key = $r[key($r)]; - echo "Create an empty placeholder in follwing release ".$key; if(isset($objectAttrs['FAIstate'])){ $objectAttrs['FAIstate'] .= "|removed"; }else{ $objectAttrs['FAIstate'] = "|removed"; } - print_a($objectAttrs); - save_FAI_object($key,$objectAttrs); + + foreach($r as $key ){ + echo "Create an empty placeholder in follwing release ".$key; + print_a($objectAttrs); + save_FAI_object($key,$objectAttrs); + } } }else{ /* check if we must patch the follwing release */ if(!empty($r)){ - $key = $r[key($r)]; - echo "Copy current objects original attributes to next release ".$key; - print_a($parent_attrs); - save_FAI_object($key,$parent_attrs); + foreach($r as $key ){ + echo "Copy current objects original attributes to next release ".$key; + print_a($parent_attrs); + save_FAI_object($key,$parent_attrs); + } } echo "Saving current object".$parent_obj; @@ -227,11 +256,6 @@ function prepare_to_save_FAI_object($Current_DN,$objectAttrs) echo "Error they must be equal : ".$parent_obj."
and
".$Current_DN."
"; } } - unset($r[key($r)]); - echo "
the result will be inherited by ."; - foreach($r as $release => $value){ - echo "
  : ".$release.""; - } } echo "
.--------------------------------------------------------------------.
"; } @@ -281,11 +305,11 @@ function get_following_releases_that_inherit_this_object($dn) $base_release = get_release_dn($dn); /* Get previous release dns */ - $sub_releases = get_sub_releases_of_this_release($base_release,true); + $sub_releases = get_sub_releases_of_this_release($base_release); /* Get dn suffix. Example "FAIvairableEntry=keksdose,FAIvariable=Keksregal," */ $dn_suffix = str_ireplace($base_release,"",$dn); - + /* Check if given object also exists whitin one of these releases */ foreach($sub_releases as $p_release => $name){ @@ -294,7 +318,7 @@ function get_following_releases_that_inherit_this_object($dn) $ldap->cat($check_dn,array("dn","objectClass")); if($ldap->count()){ - return($ret); + //return($ret); }else{ $ret[$check_dn]=$check_dn; }