Code

Updated filtering again
[gosa.git] / plugins / admin / systems / class_terminalService.inc
index 76c58af78831a3f7983c40b96d84787ae5e17e2f..86b22049bfd5334333b7f9b7ec59aaaf872ad8e7 100644 (file)
@@ -32,10 +32,7 @@ class termservice extends plugin
   var $cn= "";
   var $orig_dn= "";
   var $XMethods= array();
-  var $XDrivers= array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev",
-      "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc",  "nv",
-      "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion",
-      "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware");
+  var $XDrivers= array();
   var $XResolutions= array();
   var $XColordepths= array();
   var $XKbModels= array ();
@@ -61,7 +58,9 @@ class termservice extends plugin
   function termservice ($config, $dn= NULL, $parent= NULL)
   {
     plugin::plugin ($config, $dn, $parent);
-    
+   
+    /* Get list of available xdrivers */
+    $this->XDrivers = $this->getListOfXDrivers();
     array_unshift($this->XDrivers, "["._("unknown")."]");
     
     $this->XResolutions= array(
@@ -177,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");
@@ -196,7 +193,7 @@ class termservice extends plugin
       /* Load hardware list */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))");
+    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
     if ($ldap->count() == 1){
       $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout",
                   "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport");
@@ -452,6 +449,27 @@ class termservice extends plugin
     $this->handle_post_events("modify");
   }
 
+
+  function getListOfXDrivers()
+  {
+    $drivers = array();
+
+    /* Generate a list of xdrivers from CONFIG_DIR/xdrivers */
+    if (file_exists(CONFIG_DIR.'/xdrivers')){
+      $xdrivers = file (CONFIG_DIR.'/xdrivers');
+      foreach ($xdrivers as $line){
+        if (!preg_match ("/^#/", $line)){
+          $drivers[]= trim($line);
+        }
+      }
+    } else {
+      $drivers = array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx",
+          "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc",  "nv", "nvidia",
+          "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion",
+          "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware");
+    }
+    return($drivers);
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: