From a3a97eb41361b68f887e8200c5935d39a6b42d3f Mon Sep 17 00:00:00 2001 From: psc Date: Fri, 16 Oct 2009 13:30:26 +0000 Subject: [PATCH] Bugfix for Trac #2870 - Filter servers by the unittag of the user - Filter classes by the unittag of the user by generating a list of bad classes and comparing the classes to it. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@14596 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/goto/class_workstationStartup.inc | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc b/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc index 0e372ddef..146062909 100644 --- a/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc +++ b/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc @@ -1044,6 +1044,44 @@ class workstartup extends plugin )); } + /* Function to find bad classes */ + function update_bad_classes($release) + { + + if(!isset($this->cache['BAD_CLASSES'][$release])) { + /* Find "bad" classes */ + $ui = get_userinfo(); + $ldap = $this->config->get_ldap_link(); + + /* Convert release name to a valid ldap uri component */ + $release_components = split('/', $release); + $release_components = array_reverse($release_components); + for($i=0;$iconfig->current['BASE']); + + /* Build a list of all fai classes, that don't have the unittag of the user + * and are not freezed or removed. The classes will be filtered by this + * list. Its needed to specify each objectClass (FAIpackageList etc.) because + * FAIClass would match sub-objects, too, which would lead to an array that + * is much bigger then needed */ + $filter = sprintf('(&(|(objectClass=FAItemplate)(objectClass=FAIpackageList)(objectClass=FAIprofile)(objectClass=FAIscript)(objectClass=FAIpartitionTable)(objectClass=FAIHook)(objectClass=FAIvariable)(objectClass=FAItemplate))(&(!(gosaUnitTag=%s))(&(!(FAIstate=*removed*))(!(FAIstate=*freeze*)))))', $ui->gosaUnitTag); + $ldap->cd($base); + $ldap->search(sprintf("$filter", $ui->gosaUnitTag)); + + $this->cache['BAD_CLASSES'][$release] = array(); + while ($entry = $ldap->fetch()) { + $classname = $entry['cn'][0]; + if (!in_array($classname, $this->cache['BAD_CLASSES'][$release])) { + array_push($this->cache['BAD_CLASSES'][$release], $classname); + } + } + } + } /* Updates release dns * and reads all classes for the current release, @@ -1072,7 +1110,15 @@ class workstartup extends plugin return; }else{ + $base = $this->config->current['BASE']; + $ldap = $this->config->get_ldap_link(); foreach($servers as $server){ + /* Dont show servers that have a different unittag as the user*/ + $ui = get_userinfo(); + if ($ui->gosaUnitTag != $server['TAG']) { + continue; + } + $rel = $server['FAI_RELEASE']; $this->cache['SERVERS']['auto'][$rel] = $rel; $this->cache['SERVERS'][$server['SERVER']][$rel] = $rel; @@ -1133,6 +1179,13 @@ class workstartup extends plugin }else{ foreach($classes as $class){ $classname = $class['CLASS']; + $this->update_bad_classes($release); + if(isset($this->cache['BAD_CLASSES'][$release])){ + /* Skip classes that are in the array of bad classes */ + if (in_array($classname, $this->cache['BAD_CLASSES'][$release])) { + continue; + } + } if (!isset($this->cache['CLASSES'][$release][$classname])) { $this->cache['CLASSES'][$release][$classname] = array(); } -- 2.30.2