Code

Updated tabs to show inherit instead of default
[gosa.git] / plugins / admin / systems / class_terminalService.inc
index 043846474e144ca717e229f07ac672c10717894e..27caf1a013c288a7e02c2fe58108c2ab3e064ab3 100644 (file)
@@ -31,26 +31,22 @@ class termservice extends plugin
   var $goFonHardware= "automatic";
 
   /* Needed values and lists */
+  var $ignore_account= TRUE;
   var $base= "";
   var $cn= "";
   var $orig_dn= "";
   var $XMethods= array();
-  var $XDrivers= array("unknown", "ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev",
+  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");
-  var $XResolutions= array("default", "640x480", "800x600", "1024x768", "1152x864", "1280x1024",
-      "1400x1050", "1600x1200");
-  var $XColordepths= array("default", "8", "15", "16", "24");
-  var $XKbModels= array ("default", "btc9000", "chicony", "compaq", "dell", "dell101", "everex",
-      "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless",
-      "logiinetnav", "logiinternet", "macintosh", "microsoft",
-      "microsoftpro", "omnikey101", "pc101", "pc102", "pc104",
-      "pc105", "rapidaccess", "rapidaccess2", "winbook");
-  var $XKbLayouts= array ("default", "de", "intl", "us");
-  var $XKbVariants= array ("default", "nodeadkeys", "basic");
-  var $MouseTypes= array("AUTO", "ImPS/2", "PS/2", "Microsoft", "Logitech");
-  var $MousePorts= array("AUTO", "/dev/ttyS0", "/dev/ttyS1", "/dev/psaux", "/dev/input/mice");
+      "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware");
+  var $XResolutions= array();
+  var $XColordepths= array();
+  var $XKbModels= array ();
+  var $XKbLayouts= array ();
+  var $XKbVariants= array ();
+  var $MouseTypes= array();
+  var $MousePorts= array();
   var $gotoScannerModels= array();
   var $hardware_list= array();
   var $used_hardware= array();
@@ -69,6 +65,65 @@ class termservice extends plugin
   function termservice ($config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
+    
+    array_unshift($this->XDrivers, "["._("unknown")."]");
+    
+    $this->XResolutions= array(
+        "default"   =>  "["._("inherited")."]"  ,
+        "640x480"   =>  "640x480",
+        "800x600"   =>  "800x600",
+        "1024x768"  =>  "1024x768",
+        "1152x864"  =>  "1152x864",
+        "1280x1024" =>  "1280x1024",
+        "1400x1050" =>  "1400x1050",
+        "1600x1200" =>  "1600x1200");
+
+    $this->XColordepths= array(
+        "default"  => "["._("inherited")."]",
+        "8"        => "8 " ._("bit"),
+        "15"       => "15 "._("bit"),
+        "16"       => "16 "._("bit"),
+        "24"       => "24 "._("bit"));
+
+    $this->XKbModels['default']= "["._("inherited")."]";
+    foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex",
+          "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless",
+          "logiinetnav", "logiinternet", "macintosh", "microsoft",
+          "microsoftpro", "omnikey101", "pc101", "pc102", "pc104",
+          "pc105", "rapidaccess", "rapidaccess2", "winbook") as $type){
+      $this->XKbModels[$type] = $type;
+    }
+
+    /* Additional values will be extracted from /etc/gosa/keyboardLayouts */
+    $this->XKbLayouts= array ("default"=>"["._("inherited")."]","de"=> "de","intl" =>"intl","us" =>"us");
+    $this->XKbVariants= array ("default"=>"["._("inherited")."]", "nodeadkeys"=>"nodeadkeys", "basic"=>"basic");
+
+    $this->MouseTypes= array( "AUTO"      =>  "["._("inherited")."]" ,  "ImPS/2"      => "ImPS/2", 
+                              "PS/2"      =>  "PS/2"                 ,  "Microsoft"   => "Microsoft", 
+                              "Logitech"  =>  "Logitech");
+
+    $this->MousePorts= array("AUTO"             =>"["._("inherited")."]"   , "/dev/ttyS0"  => "/dev/ttyS0", 
+                             "/dev/ttyS1"       => "/dev/ttyS1"            , "/dev/psaux"  => "/dev/psaux", 
+                             "/dev/input/mice"  =>"/dev/input/mice");
+
+    /* try to read additional keyboard layouts
+     */
+    if(file_exists(CONFIG_DIR."/keyboardLayouts")){
+      if(is_readable(CONFIG_DIR."/keyboardLayouts")){
+        $str = file_get_contents(CONFIG_DIR."/keyboardLayouts");
+        $tmp = split("\n",$str);
+        foreach($tmp as $entry){
+          if((!empty($entry)) && (!preg_match("/^#/",$entry))){
+            $entry = trim($entry);
+            $tmp2 = split ("\:",$entry);
+            $la =   trim($tmp2[0]);   // What would be saved to ldap
+            $da =   trim($tmp2[1]);   // This wis displayed in the listbox
+            $this->XKbLayouts [ $la] = $da;
+          }
+        }
+      }
+    }
 
     /* Load scanner models */
     $fcontents = file ($this->config->basedir."/include/scanner.inc");
@@ -124,6 +179,9 @@ class termservice extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -131,7 +189,7 @@ class termservice extends plugin
 
     /* Do we represent a valid terminal? */
     if (!$this->is_account && $this->parent == NULL){
-      $display= "<img src=\"images/stop.png\" align=center>&nbsp;<b>".
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
         _("This 'dn' has no terminal features.")."</b>";
       return ($display);
     }
@@ -141,10 +199,13 @@ class termservice extends plugin
 
     /* Arrays */ 
     foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths",
-          "gotoScannerModels", "XKbModels", "XKbLayouts", "XKbVariants",
+          "gotoScannerModels", "XKbModels","XKbVariants",
           "MouseTypes", "MousePorts") as $val){
       $smarty->assign("$val", $this->$val);
     }
+    $smarty->assign("XKbLayouts",   $this->XKbLayouts);
+    $smarty->assign("XKbLayoutKeys",array_flip($this->XKbLayouts));
+  
     $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']);
     $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']);
     $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
@@ -165,6 +226,7 @@ class termservice extends plugin
       $smarty->assign($val, $this->$val);
       $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
+    $smarty->assign("staticAddress", "");
 
     /* Checkboxes */
     foreach(array("gotoLpdEnable", "gotoScannerEnable") as $val){
@@ -199,14 +261,11 @@ class termservice extends plugin
     $smarty->assign ("gotoXMonitor", $this->gotoXMonitor);
 
     /* Show main page */
-    return($smarty->fetch (get_template_path('service.tpl', TRUE)));
+    return($smarty->fetch (get_template_path('terminalService.tpl', TRUE)));
   }
 
   function remove_from_parent()
   {
-    $ldap= $this->config->get_ldap_link();
-    $ldap->rmdir($this->dn);
-    show_ldap_error($ldap->get_error());
     $this->handle_post_events("remove");
   }
 
@@ -233,7 +292,8 @@ class termservice extends plugin
   /* Check supplied data */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
 
     /* Default entries can use blank hsync/vsync entries */
     if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){
@@ -291,8 +351,10 @@ class termservice extends plugin
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
-    show_ldap_error($ldap->get_error());
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    show_ldap_error($ldap->get_error(), _("Saving terminal service information failed"));
     $this->handle_post_events("modify");
   }