Code

Updated preg_matches
[gosa.git] / plugins / admin / systems / class_terminalService.inc
index 27caf1a013c288a7e02c2fe58108c2ab3e064ab3..305c732248b287b472f48e8f32c2548339779504 100644 (file)
@@ -62,9 +62,9 @@ class termservice extends plugin
   var $objectclasses= array("GOhard");
 
 
-  function termservice ($config, $dn= NULL)
+  function termservice ($config, $dn= NULL, $parent= NULL)
   {
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
     
     array_unshift($this->XDrivers, "["._("unknown")."]");
     
@@ -78,6 +78,24 @@ class termservice extends plugin
         "1400x1050" =>  "1400x1050",
         "1600x1200" =>  "1600x1200");
 
+    if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){
+      $file = $this->config->data['MAIN']['RESOLUTION_HOOK'];
+
+      if(is_readable($file)){
+        $str = file_get_contents($file);
+        $lines = split("\n",$str);
+        foreach($lines as $line){
+          $line = trim($line);
+          if(!empty($line)){
+            $this->XResolutions[$line]=$line;
+          }
+        }
+        //natcasesort($this->gotoXResolutions);
+      }else{
+        print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file));
+      }
+    }
+
     $this->XColordepths= array(
         "default"  => "["._("inherited")."]",
         "8"        => "8 " ._("bit"),
@@ -175,6 +193,49 @@ class termservice extends plugin
 
     $this->hardware_list["automatic"]= _("automatic");
     ksort($this->hardware_list);
+
+    /* Convert gotoLpdEnable */
+    $this->gotoLpdEnable= preg_match("/yes/",$this->gotoLpdEnable);
+
+      /* Load hardware list */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))");
+    if ($ldap->count() == 1){
+      $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout",
+                  "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport");
+      $attrs= $ldap->fetch();
+
+      foreach ($map as $name){
+        if (!isset($attrs[$name][0])){
+          continue;
+        }
+
+        switch ($name){
+          case 'gotoXResolution':
+            $this->XResolutions['default'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+          case 'gotoXColordepth':
+            $this->XColordepths['default'] =  _("inherited").' ['.$attrs[$name][0].' '._('Bit').']';
+            break;
+          case 'gotoXKbModel':
+            $this->XKbModels['default'] =  _("inherited").' ['.$attrs[$name][0].']';
+            break;
+          case 'gotoXKbLayout':
+            $this->XKbLayouts['default'] =  _("inherited").' ['.$attrs[$name][0].']';
+            break;
+          case 'gotoXKbVariant':
+            $this->XKbVariants['default'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+          case 'gotoXMouseType':
+            $this->MouseTypes['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+          case 'gotoXMouseport':
+            $this->MousePorts['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+        }
+      }
+    }
   }
 
   function execute()
@@ -335,6 +396,9 @@ class termservice extends plugin
   /* Save to LDAP */
   function save()
   {
+    /* Convert to string */
+    $this->gotoLpdEnable= $this->gotoLpdEnable?"Yes":"No";
+
     plugin::save();
 
     /* Strip out 'default' values */