From e1d95c29272ce8b78eb366517e668aa6f49736a2 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 10 Jul 2006 11:53:32 +0000 Subject: [PATCH] Fixed getBranch git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4074 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/functions_FAI.inc | 17 ++++++++++++++++- plugins/admin/fai/class_faiManagement.inc | 14 ++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/functions_FAI.inc b/include/functions_FAI.inc index a54100c03..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,26 @@ 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; diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index 26542a1ae..5b202b1aa 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -638,16 +638,14 @@ class faiManagement extends plugin $ret = array("main"=>"/"); $ldap = $this->config->get_ldap_link(); if(!$base){ - $base= "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + $base= $_SESSION['CurrentMainBase']; } - $ldap->ls("(objectClass=FAIbranch)",$base); - while($attrs = $ldap->fetch()){ - if((isset($attrs['ou']))&&($attrs['dn']!=$base)){ - $ret[$attrs['dn']]= $prefix.$attrs['ou'][0]; - $ret = array_merge($ret,$this->getBranches($attrs['dn'],"".$prefix.$attrs['ou'][0]."/")); - } + $tmp = get_all_releases_from_base($base,true); + foreach($tmp as $dn => $name){ + $ret[$dn]=$name; } - + echo $base; + print_a($ret); return ($ret); } -- 2.30.2