From 5ca54bc9613edd4cd1ac178f6d3b681b88740ea4 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 21 Nov 2007 13:35:06 +0000 Subject: [PATCH] Fixed long ldap query when searching for used phones. Reduced queries to a single ldap search. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7846 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_terminalService.inc | 12 +++++------- plugins/admin/systems/class_workstationService.inc | 12 +++++------- plugins/gofon/phoneaccount/class_phoneAccount.inc | 12 +++++------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/plugins/admin/systems/class_terminalService.inc b/plugins/admin/systems/class_terminalService.inc index 881ec2b5c..ea2c8d7fe 100644 --- a/plugins/admin/systems/class_terminalService.inc +++ b/plugins/admin/systems/class_terminalService.inc @@ -183,14 +183,12 @@ class termservice extends plugin /* Eventually colorize phones */ $ldap->cd($this->config->current['BASE']); - foreach ($this->hardware_list as $cn => $desc){ - $ldap->search("(goFonHardware=$cn)", array('cn')); - if ($ldap->count() > 0){ - $ldap->fetch(); - if ($ldap->getDN() != $this->dn){ - $this->used_hardware[$cn]= $ldap->getDN(); + $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; } - } } $this->hardware_list["automatic"]= _("automatic"); diff --git a/plugins/admin/systems/class_workstationService.inc b/plugins/admin/systems/class_workstationService.inc index 757f0b933..8bb55fb52 100644 --- a/plugins/admin/systems/class_workstationService.inc +++ b/plugins/admin/systems/class_workstationService.inc @@ -162,14 +162,12 @@ class workservice extends plugin /* Eventually colorize phones */ $ldap->cd($this->config->current['BASE']); - foreach ($this->hardware_list as $cn => $desc){ - $ldap->search("(goFonHardware=$cn)", array('cn')); - if ($ldap->count() > 0){ - $ldap->fetch(); - if ($ldap->getDN() != $this->dn){ - $this->used_hardware[$cn]= $ldap->getDN(); + $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; } - } } if(preg_match("/\+/",$this->gotoXHsync)){ diff --git a/plugins/gofon/phoneaccount/class_phoneAccount.inc b/plugins/gofon/phoneaccount/class_phoneAccount.inc index 9aa3b1635..01abe960e 100644 --- a/plugins/gofon/phoneaccount/class_phoneAccount.inc +++ b/plugins/gofon/phoneaccount/class_phoneAccount.inc @@ -244,14 +244,12 @@ class phoneAccount extends plugin * so we must detect which phones are currently in use. */ $ldap->cd($this->config->current['BASE']); - foreach ($this->hardware_list as $cn => $desc){ - $ldap->search("(goFonHardware=$cn)", array('cn')); - if ($ldap->count() > 0){ - $ldap->fetch(); - if ($ldap->getDN() != $this->dn){ - $this->used_hardware[$cn]= $ldap->getDN(); + $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; } - } } $this->hardware_list["automatic"]= _("automatic"); ksort($this->hardware_list); -- 2.30.2