X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Ffunctions_FAI.inc;h=4418a255ab267ccebaf5fcb4027e04a66cf426af;hb=e1d95c29272ce8b78eb366517e668aa6f49736a2;hp=09c1505145e98b1a51ae949f12b9c02d9a8d01ab;hpb=47d65a38a929844be94a58497cda60fdddae98d8;p=gosa.git diff --git a/include/functions_FAI.inc b/include/functions_FAI.inc index 09c150514..4418a255a 100644 --- a/include/functions_FAI.inc +++ b/include/functions_FAI.inc @@ -119,7 +119,12 @@ function get_FAI_departments($suffix = "") 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(); @@ -422,6 +427,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){ @@ -436,6 +442,7 @@ function prepare_ldap_fetch_to_be_saved($attrs) } +/* Save given attrs to specified dn*/ function save_FAI_object($dn,$attrs) { global $config; @@ -447,18 +454,48 @@ function save_FAI_object($dn,$attrs) $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;