From bda442275f9ecc4b12c1624d5da3eff0a3b78689 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 26 Sep 2006 11:38:12 +0000 Subject: [PATCH] Fixed faiProfile git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4782 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/fai/class_faiProfile.inc | 51 +++++++++++---------- plugins/admin/fai/class_faiProfileEntry.inc | 2 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/plugins/admin/fai/class_faiProfile.inc b/plugins/admin/fai/class_faiProfile.inc index 65871611b..21e9be99e 100644 --- a/plugins/admin/fai/class_faiProfile.inc +++ b/plugins/admin/fai/class_faiProfile.inc @@ -69,36 +69,37 @@ class faiProfile extends plugin } } - $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTable","FAIpackageList"); - - /* Build filter */ - $filter= ""; - foreach ($categories as $cat){ - $filter.= "(objectClass=$cat)"; + /* Search only in fai tree */ + $ObjectTypes = array( + "FAIpartitionTable" => array("OU"=>"ou=disk," , "CHKBOX"=>"ShowPartitions"), + "FAIpackageList" => array("OU"=>"ou=packages," , "CHKBOX"=>"ShowPackages"), + "FAIscript" => array("OU"=>"ou=scripts," , "CHKBOX"=>"ShowScripts"), + "FAIvariable" => array("OU"=>"ou=variables," , "CHKBOX"=>"ShowVariables"), + "FAIhook" => array("OU"=>"ou=hooks," , "CHKBOX"=>"ShowHooks"), +# "FAIprofile" => array("OU"=>"ou=profiles," , "CHKBOX"=>"ShowProfiles"), + "FAItemplate" => array("OU"=>"ou=templates," , "CHKBOX"=>"ShowTemplates")); + + $base= "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + if($_SESSION['faifilter']['branch']!="main"){ + $base = $_SESSION['faifilter']['branch']; } - - /* Get ldap connection */ - $base = $_SESSION['CurrentMainBase']; - $ldap->cd($base); - $sort = array(); - /* search all FAI classes */ - $ldap->search("(|$filter)",array("*")); - while($attrs = $ldap->fetch()){ + /* Get ldap connection */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($base); - /* Sort by categorie */ - foreach($categories as $cat){ - if(in_array($cat,$attrs['objectClass'])){ + /* Capture objects from given base */ + $result = array(); + foreach($ObjectTypes as $oc => $data){ + $ou = $data['OU'].$base; - /* Append entry */ - $this->FAIAllclasses[$attrs['cn'][0]][$cat]=$attrs; - - /* Create sort array, because the array above is a multidimensional array, and can't be sorted by php sorting functions*/ - $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; - } + $ldap->ls("(objectClass=".$oc.")",$ou,array("cn","objectClass","dn")); + while($attrs = $ldap->fetch()){ + $this->FAIAllclasses[$attrs['cn'][0]][$oc]=$attrs; + $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; } - } - + } + /* Sort the sort array */ //ksort($sort); diff --git a/plugins/admin/fai/class_faiProfileEntry.inc b/plugins/admin/fai/class_faiProfileEntry.inc index 64d325973..55dec8721 100644 --- a/plugins/admin/fai/class_faiProfileEntry.inc +++ b/plugins/admin/fai/class_faiProfileEntry.inc @@ -43,7 +43,7 @@ class faiProfileEntry extends plugin foreach($ObjectTypes as $oc => $data){ $ou = $data['OU'].$base; - $ldap->ls("(objectClass=".$oc.")",$ou,array("*")); + $ldap->ls("(objectClass=".$oc.")",$ou,array("cn","objectClass","dn")); while($res = $ldap->fetch()){ $result[] = $res; } -- 2.30.2