From cb109c36f0802f00cb25a1f5c0a696dac44df0a1 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 10 Jul 2006 06:29:32 +0000 Subject: [PATCH] First update for FAI workstation FAI part git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4056 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/class_workstationStartup.inc | 70 ++++++------------- 1 file changed, 20 insertions(+), 50 deletions(-) diff --git a/plugins/admin/systems/class_workstationStartup.inc b/plugins/admin/systems/class_workstationStartup.inc index 7e13a94df..f783bfa9b 100644 --- a/plugins/admin/systems/class_workstationStartup.inc +++ b/plugins/admin/systems/class_workstationStartup.inc @@ -341,47 +341,22 @@ class workstartup extends plugin return($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release]); } - /* Create cache with all classes - */ - if((!isset($_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'])) || - (!is_array($_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'])) || - (count($_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES']) ==0 )){ - - /* Get ldap connection */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Get possible classes ... - This would be faste with some kind of caching ... - */ - $ldap->search("(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAIpartitionTable))",array("cn"),true); - /* Sort all entries, and attach elementtype. - * To be able to show the types in the listbox. - */ - while($attr = $ldap->fetch()){ - $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'][] = $attr; - } - } - - /* Walk through cache and get out what we need. - * - * Function od : "$this->generateDNSyn($release)" - * It returns an array like this one : - * array("ou=packges,ou=rc0.9.2,ou=siga,", - * "ou=scripts.. " - * ...); - * This helps us to select the correct classes for each release. - * It prevents errors like: 'siga' is selected as release, but all classes - * with ou='siga' in their dn are shown, also ou=rc...,ou=siga... - */ - $tmp2 = $this->generateDNSyn($release) ; - $test2 = array(); - foreach($_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'] as $attr){ - foreach($tmp2 as $dns){ - if(preg_match("/".$dns."/",$attr['dn'])){ - $test2[$attr['cn'][0]] = $attr['cn'][0]; - } - } + $test2 = array(); + $bb = $this->generateDNSyn($release).$_SESSION['CurrentMainBase']; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Get classes fpr given release */ + $p_classes = get_all_objects_for_given_base($bb, + "(|(objectClass=FAIpackageList)(objectClass=FAItemplate)". + "(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)". + "(objectClass=FAIprofile)(objectClass=FAIpartitionTable))"); + + /* Create list of classes */ + foreach($p_classes as $class){ + $ldap->cat($class['dn'],array("cn")); + $attr = $ldap->fetch(); + $test2[$attr['cn'][0]] = $attr['cn'][0]; } $_SESSION['getAvailableClassesForThisRelease_CACHE'][$release] = $test2; return($test2); @@ -767,19 +742,14 @@ class workstartup extends plugin $tmp = split("\/",$release); $tmp = array_reverse($tmp); - $base = ",ou=fai,"; - - $arr = array("scripts","hooks","disk","variables","templates","profiles","packages"); - + $base = "ou=fai,ou=configs,ou=systems,"; foreach($tmp as $departmentname){ $str .= ",ou=".$departmentname; } - $ret = array(); - foreach($arr as $ar){ - $ret[] = ",ou=".$ar.$str.$base; - } - return($ret); + $str = preg_replace("/^,/","",($str.",".$base)); + + return($str); } function getFAIdebianMirrors() -- 2.30.2