From 9168fb6ebd9f2096e495f266b79d192ad5482863 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 22 Feb 2008 06:49:37 +0000 Subject: [PATCH] Updated terminal and workstation service. - Use get_sub_list now, which is faster than searching the whole ldap. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9038 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/goto/class_terminalService.inc | 91 +++++----------- .../systems/goto/class_workstationService.inc | 101 +++++------------- 2 files changed, 56 insertions(+), 136 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc index 792752765..b10f71c08 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc @@ -185,79 +185,44 @@ class termservice extends plugin /* Load phone hardware list */ - $ldap= $this->config->get_ldap_link(); - $deps = array(); - $ou = preg_replace("/,.*$/","",get_ou("phoneou")); - if(!empty($ou)){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=organizationalUnit)(".$ou."))",array("dn")); - while($attrs = $ldap->fetch()){ - $deps[] = $attrs['dn']; - } - }else{ - - /* Phone ou seems to be empty, fall back to overall base . - */ - $deps[] = $this->config->current['BASE']; - } - foreach($deps as $dep){ - $ldap->cd($dep); - $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); - while ($attrs= $ldap->fetch()){ - $cn= $attrs['cn'][0]; - if (isset($attrs['description'])){ - $description= " - ".$attrs['description'][0]; - } else { - $description= ""; - } - $this->hardware_list[$cn]= "$cn$description"; - } - } - - /* Eventually colorize phones */ - $deps = array(); - $ou = preg_replace("/,.*$/","",get_ou("systemsou")); - $deps_a = array(get_ou("ogroupou"), - get_ou("serverou"), - get_ou("terminalou"), - get_ou("workstationou"), - get_ou("printerou"), - get_ou("componentou"), - get_ou("phoneou")); - if(!empty($ou)){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=organizationalUnit)(".$ou."))",array("dn")); - while($attrs = $ldap->fetch()){ - foreach($deps_a as $allowed){ - $to_add = preg_replace("/".get_ou('systemsou')."$/","",$allowed); - $deps[] = $to_add.$attrs['dn']; - } + $tmp = get_sub_list("(objectClass=goFonHardware)","",array(get_ou("phoneou")), + $this->config->current['BASE'],array("cn","description"), GL_NO_ACL_CHECK); + foreach($tmp as $attrs){ + $cn= $attrs['cn'][0]; + $description= ""; + if (isset($attrs['description'])){ + $description= " - ".$attrs['description'][0]; } - }else{ - - /* Phone ou seems to be empty, fall back to overall base . - */ - $deps[] = $this->config->current['BASE']; + $this->hardware_list[$cn]= "$cn$description"; } + $this->hardware_list["automatic"]= _("automatic"); + ksort($this->hardware_list); - foreach($deps as $dep){ - $ldap->cd($dep); - $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); - while($attrs = $ldap->fetch()){ - $cn = $attrs['goFonHardware'][0]; - if(isset($this->hardware_list[$cn])){ - $this->used_hardware[$cn]= $cn; - } + /* These departments may contain objects that have + goFonHardware set. + */ + $deps_a = array( + get_ou("ogroupou"), + get_ou("serverou"), + get_ou("terminalou"), + get_ou("workstationou"), + get_ou("printerou"), + get_ou("componentou"), + get_ou("phoneou")); + + $tmp = get_sub_list("(goFonHardware=*)","",$deps_a,$this->config->current['BASE'], + array('cn','dn','goFonHardware'),GL_NO_ACL_CHECK); + foreach($tmp as $attrs){ + $cn = $attrs['goFonHardware'][0]; + if(isset($this->hardware_list[$cn])){ + $this->used_hardware[$cn]= $cn; } } - $this->hardware_list["automatic"]= _("automatic"); - ksort($this->hardware_list); /* Convert gotoLpdEnable */ $this->gotoLpdEnable= preg_match("/yes/i",$this->gotoLpdEnable); - /* Load hardware list */ $ldap= $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc index 6d3809e42..8b25d23f9 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc @@ -146,86 +146,41 @@ class workservice extends plugin $this->orig_dn= $this->dn; - - - - - - - - - /* Load phone hardware list */ - $ldap= $this->config->get_ldap_link(); - $deps = array(); - $ou = preg_replace("/,.*$/","",get_ou("phoneou")); - if(!empty($ou)){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=organizationalUnit)(".$ou."))",array("dn")); - while($attrs = $ldap->fetch()){ - $deps[] = $attrs['dn']; - } - }else{ - - /* Phone ou seems to be empty, fall back to overall base . - */ - $deps[] = $this->config->current['BASE']; - } - foreach($deps as $dep){ - $ldap->cd($dep); - $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); - while ($attrs= $ldap->fetch()){ - $cn= $attrs['cn'][0]; - if (isset($attrs['description'])){ - $description= " - ".$attrs['description'][0]; - } else { - $description= ""; - } - $this->hardware_list[$cn]= "$cn$description"; + $tmp = get_sub_list("(objectClass=goFonHardware)","",array(get_ou("phoneou")), + $this->config->current['BASE'],array("cn","description"), GL_NO_ACL_CHECK); + foreach($tmp as $attrs){ + $cn= $attrs['cn'][0]; + $description= ""; + if (isset($attrs['description'])){ + $description= " - ".$attrs['description'][0]; } + $this->hardware_list[$cn]= "$cn$description"; } + $this->hardware_list["automatic"]= _("automatic"); + ksort($this->hardware_list); - - - /* Eventually colorize phones */ - $deps = array(); - $ou = preg_replace("/,.*$/","",get_ou("systemsou")); - $deps_a = array(get_ou("ogroupou"), - get_ou("serverou"), - get_ou("terminalou"), - get_ou("workstationou"), - get_ou("printerou"), - get_ou("componentou"), - get_ou("phoneou")); - if(!empty($ou)){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=organizationalUnit)(".$ou."))",array("dn")); - while($attrs = $ldap->fetch()){ - foreach($deps_a as $allowed){ - $to_add = preg_replace("/".get_ou('systemsou')."$/","",$allowed); - $deps[] = $to_add.$attrs['dn']; - } - } - }else{ - - /* Phone ou seems to be empty, fall back to overall base . - */ - $deps[] = $this->config->current['BASE']; - } - - foreach($deps as $dep){ - $ldap->cd($dep); - $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); - while($attrs = $ldap->fetch()){ - $cn = $attrs['goFonHardware'][0]; - if(isset($this->hardware_list[$cn])){ - $this->used_hardware[$cn]= $cn; - } + /* These departments may contain objects that have + goFonHardware set. + */ + $deps_a = array( + get_ou("ogroupou"), + get_ou("serverou"), + get_ou("terminalou"), + get_ou("workstationou"), + get_ou("printerou"), + get_ou("componentou"), + get_ou("phoneou")); + + $tmp = get_sub_list("(goFonHardware=*)","",$deps_a,$this->config->current['BASE'], + array('cn','dn','goFonHardware'),GL_NO_ACL_CHECK); + foreach($tmp as $attrs){ + $cn = $attrs['goFonHardware'][0]; + if(isset($this->hardware_list[$cn])){ + $this->used_hardware[$cn]= $cn; } } - $this->hardware_list["automatic"]= _("automatic"); - ksort($this->hardware_list); if(preg_match("/\+/",$this->gotoXHsync)){ $this->AutoSync = true; -- 2.30.2