Code

Fixed Phone usage detection - is 100 time faster now.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 Nov 2007 13:31:11 +0000 (13:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 Nov 2007 13:31:11 +0000 (13:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7845 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_terminalService.inc
plugins/admin/systems/class_workstationService.inc
plugins/gofon/phoneaccount/class_phoneAccount.inc

index 04ccf2ea805efbe4f07770f0dd3de10fee61639c..e38f27b14f1cb3e6fee0d3565ef971e48ab75d8d 100644 (file)
@@ -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");
index 51982ff1f7d2e3384742c9ee2bc808869bceda72..d28da81585d24c54400bb6e7214666b9bad2bd19 100644 (file)
@@ -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)){
index 8a22f9e530ffa778dfb8274bfbbd184b06ec5600..6c831095918747fd57e86d778c787002ca38fbd5 100644 (file)
@@ -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);