From 555eca2ca8e7ade49f0bae666192c749c4728407 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 21 Nov 2007 13:31:11 +0000 Subject: [PATCH] Fixed Phone usage detection - is 100 time faster now. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7845 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 04ccf2ea8..e38f27b14 100644 --- a/plugins/admin/systems/class_terminalService.inc +++ b/plugins/admin/systems/class_terminalService.inc @@ -176,14 +176,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 51982ff1f..d28da8158 100644 --- a/plugins/admin/systems/class_workstationService.inc +++ b/plugins/admin/systems/class_workstationService.inc @@ -156,14 +156,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 8a22f9e53..6c8310959 100644 --- a/plugins/gofon/phoneaccount/class_phoneAccount.inc +++ b/plugins/gofon/phoneaccount/class_phoneAccount.inc @@ -236,14 +236,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