Code

Updated Terminal and Workstation classes.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Feb 2008 14:52:16 +0000 (14:52 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Feb 2008 14:52:16 +0000 (14:52 +0000)
-Performance improvements

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9028 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/class_terminalService.inc
gosa-plugins/goto/admin/systems/goto/class_workstationService.inc

index a243f8882fd8a797c86b84414454ea052f6fe06d..79275276594a4c26442bb7ad5a7525651a2339c1 100644 (file)
@@ -186,32 +186,52 @@ class termservice extends plugin
     /* Load phone hardware list 
      */
     $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $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= "";
+    $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'];
       }
-      $this->hardware_list[$cn]= "$cn$description";
-    }
-
-
-
+    }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("phoneou"));
-
+    $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()){
-        $deps[] = $attrs['dn'];
+        foreach($deps_a as $allowed){
+            $to_add = preg_replace("/".get_ou('systemsou')."$/","",$allowed);
+            $deps[] = $to_add.$attrs['dn'];
+        }
       }
     }else{
 
@@ -231,7 +251,6 @@ class termservice extends plugin
       }
     }
     $this->hardware_list["automatic"]= _("automatic");
-
     ksort($this->hardware_list);
 
     /* Convert gotoLpdEnable 
index 87e9400b0e9fea13431d955e730abc0e9e653906..6d3809e42d1a845ffd70f47f60a038281b2fdee3 100644 (file)
@@ -146,29 +146,86 @@ class workservice extends plugin
 
     $this->orig_dn= $this->dn;
 
-    /* Load hardware list */
+
+
+
+
+
+
+
+
+
+    /* Load phone hardware list
+     */
     $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $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= "";
+    $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'];
       }
-      $this->hardware_list[$cn]= "$cn$description";
+    }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 */
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware'));
-    while($attrs = $ldap->fetch()){
+    $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;
         }
+      }
     }
+    $this->hardware_list["automatic"]= _("automatic");
+    ksort($this->hardware_list);
 
     if(preg_match("/\+/",$this->gotoXHsync)){
       $this->AutoSync = true;
@@ -176,9 +233,6 @@ class workservice extends plugin
       $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync);
     }
 
-    $this->hardware_list["automatic"]= _("automatic");
-    ksort($this->hardware_list);
-
     /* Load hardware list */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
@@ -308,7 +362,7 @@ class workservice extends plugin
     $smarty->assign ("goFonHardware", $this->goFonHardware);
 
     $perms = "";
-    if($this->acl_is_writeable("goFonHardware")){
+    if(!$this->acl_is_writeable("goFonHardware")){
       $perms = " disabled ";
     }