X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Ffunctions_FAI.inc;h=7bae51a105c77df6227b2f6ccc81b7aaf20d0141;hb=d424533eb17cc34c2a8d6f9047bef89aff5af763;hp=69fb3146476dc8f30158e64a00dd2e3c5d1a7498;hpb=276a0d3ee2826f1d32ceeb43085c387598230534;p=gosa.git diff --git a/include/functions_FAI.inc b/include/functions_FAI.inc index 69fb31464..7bae51a10 100644 --- a/include/functions_FAI.inc +++ b/include/functions_FAI.inc @@ -78,24 +78,6 @@ function get_all_objects_for_given_base($Current_DN,$filter,$detailed = false) } - -/* Return the object defining ObjectClass e.g. FAIscriptEntry */ -function get_FAI_type($attr) -{ - $arr = array( "FAIprofile","FAIpartitionTable", "FAIpartitionDisk","FAIpartitionEntry","FAIhook","FAIhookEntry", - "FAIscriptEntry","FAIscript","FAIvariable","FAIvariableEntry","FAIpackageList","FAItemplate", - "FAItemplateEntry","FAIdebconfInfo","FAIrepository","FAIrepositoryServer","FAIbranch","FAIreleaseTag"); - foreach($arr as $name){ - if(in_array($name,$attr['objectClass'])){ - preg_match(""); - return($name); - } - } - if(DEBUG_FAI_FUNC) { echo "Not found"; } - return(""); -} - - /* Return all relevant FAI departments */ function get_FAI_departments($suffix = "") { @@ -116,18 +98,27 @@ function get_FAI_departments($suffix = "") /* Return all releases within the given base */ -function get_all_releases_from_base($dn) +function get_all_releases_from_base($dn,$appendedName=false) { global $config; - $base = "ou=fai,ou=configs,ou=systems,".$dn; + + if(!preg_match("/ou=fai,ou=configs,ou=systems,/",$dn)){ + $base = "ou=fai,ou=configs,ou=systems,".$dn; + }else{ + $base = $dn; + } $res = array(); $ldap = $config->get_ldap_link(); $ldap->cd($base); $ldap->search("(objectClass=FAIbranch)",array("ou","dn")); while($attrs = $ldap->fetch()){ - $res[$attrs['dn']] = $attrs['ou'][0]; - } + if($appendedName){ + $res[$attrs['dn']] = convert_department_dn(preg_replace("/,ou=fai,ou=configs,ou=system.*$/","",$attrs['dn'])); + }else{ + $res[$attrs['dn']] = $attrs['ou'][0]; + } + } return($res); } @@ -165,6 +156,18 @@ function prepare_to_save_FAI_object($Current_DN,$objectAttrs,$removed = false) /* Detect differences in attribute arrays */ function array_diff_FAI($ar1,$ar2) { + + if((!isset($ar1['description'])) || (isset($ar1['description']) && (count($ar1['description']) == 0))){ + $ar1['description'] = ""; + } + if((!isset($ar2['description'])) || (isset($ar2['description']) && (count($ar2['description']) == 0))){ + $ar2['description'] = ""; + } + + if(count($ar1) != count($ar2)) { + return (true); + } + foreach($ar1 as $key1 => $val1){ if((is_array($val1)) && (count($val1)==1)){ @@ -176,6 +179,8 @@ function array_diff_FAI($ar1,$ar2) $ar2[$key1] = $ar2[$key1][0]; } } + ksort($ar1); + ksort($ar2); if(count( array_diff($ar1,$ar2))){ return(true); }else{ @@ -238,7 +243,7 @@ function save_release_changes_now() }else{ $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 ){ @@ -414,6 +419,7 @@ function clean_up_releases($Current_DN) } +/* Remove numeric index and 'count' from ldap->fetch result */ function prepare_ldap_fetch_to_be_saved($attrs) { foreach($attrs as $key => $value){ @@ -428,6 +434,7 @@ function prepare_ldap_fetch_to_be_saved($attrs) } +/* Save given attrs to specified dn*/ function save_FAI_object($dn,$attrs) { global $config; @@ -435,17 +442,52 @@ function save_FAI_object($dn,$attrs) $ldap->cd($config->current['BASE']); $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $dn)); $ldap->cd($dn); - + $ldap->cat($dn,array("dn")); if($ldap->count()){ + + /* Remove FAIstate*/ + if(!isset($attrs['FAIstate'])){ + $attrs['FAIstate'] = array(); + } + $ldap->modify($attrs); }else{ + + /* Unset description if empty */ + if(empty($attrs['description'])){ + unset($attrs['description']); + } + $ldap->add($attrs); } show_ldap_error($ldap->get_error(),sprintf(_("Release management failed, can't save '%s'"),$dn)); } +/* Return FAIstate freeze branch or "" for specified release department */ +function get_release_tag($dn) +{ + global $config; + $ldap = $config->get_ldap_link(); + $ldap->cd($dn); + $ldap->cat($dn,array("FAIstate")); + + if($ldap->count()){ + + $attr = $ldap->fetch(); + if(isset($attr['FAIstate'][0])){ + if(preg_match("/freeze/",$attr['FAIstate'][0])){ + return("freeze"); + }elseif(preg_match("/branch/",$attr['FAIstate'][0])){ + return("branch"); + } + } + } + return(""); +} + + function get_following_releases_that_inherit_this_object($dn) { global $config;