Code

Fixed long ldap query when searching for used phones.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 Nov 2007 13:35:06 +0000 (13:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 Nov 2007 13:35:06 +0000 (13:35 +0000)
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
plugins/admin/systems/class_workstationService.inc
plugins/gofon/phoneaccount/class_phoneAccount.inc

index 881ec2b5ced03258dff77a11b02c004ed9f37038..ea2c8d7fe049ebe90180beb5ea89c7d21e0891eb 100644 (file)
@@ -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");
index 757f0b9338d98c7db5cf7d0cd0325c694e0c40c5..8bb55fb52dc1c3d36bf1e0b68979e55ffd355444 100644 (file)
@@ -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)){
index 9aa3b1635cbe078817ebb4df34345bce4b9e1031..01abe960e7ba95efdc439762127a07f30c3ac5a8 100644 (file)
@@ -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);