Code

Updated terminal template
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_workstationService.inc
index 6196913603eced98f9665ca62e60f15af43383c1..9db68641561576e5e4ec24b1f022ded8c97342b6 100644 (file)
@@ -3,7 +3,6 @@
 class workservice extends plugin
 {
   var $gotoScannerEnable;
-  var $gotoLpdEnable = array();
 
   /* Generic terminal attributes */
   var $gotoXMonitor= "";
@@ -37,8 +36,7 @@ class workservice extends plugin
 
 
   /* attribute list for save action */
-  var $attributes= array("gotoXMonitor","gotoLpdEnable",
-      "gotoXDriver", "gotoXResolution", "gotoXColordepth",
+  var $attributes= array("gotoXMonitor", "gotoXDriver", "gotoXResolution", "gotoXColordepth",
       "gotoXHsync", "gotoXVsync",
       "gotoScannerEnable", "gotoScannerClients",
       "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant",
@@ -63,21 +61,12 @@ class workservice extends plugin
         "1400x1050" =>  "1400x1050", 
         "1600x1200" =>  "1600x1200");
 
-    /* Load gotoLpdEnable 
-     */
-    $this->gotoLpdEnable = array();
-    if(isset($this->attrs['gotoLpdEnable']['count'])){
-      for($i = 0 ; $i < $this->attrs['gotoLpdEnable']['count']; $i ++){
-        $this->gotoLpdEnable[] = $this->attrs['gotoLpdEnable'][$i];
-      }
-    }
-
     if($this->config->get_cfg_value("resolutions") != ""){
       $file = $this->config->get_cfg_value("resolutions");
 
       if(is_readable($file)){
         $str = file_get_contents($file);
-        $lines = split("\n",$str);
+        $lines = preg_split("/\n/",$str);
         foreach($lines as $line){
           $line = trim($line);
           if(!empty($line)){
@@ -109,12 +98,18 @@ class workservice extends plugin
       $this->XKbModels[$type] = $type;
     }
 
-    $this->MouseTypes= array("ImPS/2" => "ImPS/2", "PS/2" => "PS/2", "Microsoft" => "Microsoft", 
-                              "Logitech" => "Logitech","explorerps/2"=>"explorerps/2",);
+    $this->MouseTypes= array("auto" => "auto",
+                             "explorerps/2" => "explorerps/2",
+                             "ImPS/2" => "ImPS/2",
+                             "PS/2" => "PS/2",
+                             "Microsoft" => "Microsoft",
+                             "Logitech" => "Logitech");
 
-    $this->MousePorts= array("/dev/ttyS0"  =>"/dev/ttyS0", 
-                             "/dev/ttyS1"       => "/dev/ttyS1",          "/dev/psaux"  =>"/dev/psaux", 
-                             "/dev/input/mice"  => "/dev/input/mice");
+    $this->MousePorts= array("/dev/input/mice" => "/dev/input/mice",
+                             "/dev/mouse" => "/dev/mouse",
+                             "/dev/psaux" => "/dev/psaux",
+                             "/dev/ttyS0" => "/dev/ttyS0",
+                             "/dev/ttyS1" => "/dev/ttyS1");
 
     /* Additional values will be extracted from CONFIG_DIR./keyboardLayouts */
     $this->XKbLayouts = array("de"=> "de","en" =>"en", "es" => "es", "us" =>"us", "fr" => "fr");
@@ -125,11 +120,11 @@ class workservice extends plugin
     if(file_exists(CONFIG_DIR."/keyboardLayouts")){
       if(is_readable(CONFIG_DIR."/keyboardLayouts")){
         $str = file_get_contents(CONFIG_DIR."/keyboardLayouts");
-        $tmp = split("\n",$str);
+        $tmp = preg_split("/\n/",$str);
         foreach($tmp as $entry){
           if((!empty($entry)) && (!preg_match("/^#/",$entry))){
             $entry = trim($entry);
-            $tmp2 = split ("\:",$entry);
+            $tmp2 = explode(":",$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;  
@@ -189,7 +184,7 @@ class workservice extends plugin
     $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
     if ($ldap->count() == 1){
       $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout",
-                  "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport");
+                  "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport", "gotoXDriver");
       $attrs= $ldap->fetch();
 
       foreach ($map as $name){
@@ -198,6 +193,9 @@ class workservice extends plugin
         }
         
         switch ($name){
+          case 'gotoXDriver':
+            $this->XDrivers= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XDrivers;
+            break;
           case 'gotoXResolution':
             $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions;
             break;
@@ -214,10 +212,10 @@ class workservice extends plugin
             $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants;
             break;
           case 'gotoXMouseType':
-            $this->MouseTypes= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes;
+            $this->MouseTypes= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes;
             break;
           case 'gotoXMouseport':
-            $this->MousePorts= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts;
+            $this->MousePorts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts;
             break;
         }
 
@@ -233,8 +231,8 @@ class workservice extends plugin
       $this->XKbModels= array('default' => _("inherited"));
       $this->XKbLayouts= array('default' => _("inherited"));
       $this->XKbVariants= array('default' => _("inherited"));
-      $this->MouseTypes= array('AUTO' => _("inherited"));
-      $this->MousePorts= array('AUTO' => _("inherited"));
+      $this->MouseTypes= array('default' => _("inherited"));
+      $this->MousePorts= array('default' => _("inherited"));
     }
   }
 
@@ -262,40 +260,6 @@ class workservice extends plugin
       }
     }
 
-
-    /**********
-      gotoLpdEnable 
-     **********/
-    if(isset($_POST['gotoLpdEnable_Close'])){
-      $this->dialog = NULL;
-    }
-
-    if(isset($_POST['gotoLpdEnable_Ok'])){
-      $this->dialog->save_object();
-      $msgs = $this->dialog->check();
-      if(count($msgs)) {
-        msg_dialog::displayChecks($msgs);
-      }else{
-        $this->gotoLpdEnable = $this->dialog->save();
-        $this->dialog = NULL;
-      }
-    }
-
-    if(isset($_POST['gotoLpdEnable_Edit'])){
-      $this->dialog = new gotoLpdEnable($this->config,$this->gotoLpdEnable,$this);
-    }
-
-    if($this->dialog instanceof plugin){
-      $this->dialog->save_object();
-      return($this->dialog->execute());
-    }
-
-
-    /**********
-      Ende: gotoLpdEnable 
-     **********/
-
-
     /* Show main page */
     $smarty= get_smarty();
 
@@ -331,7 +295,6 @@ class workservice extends plugin
     foreach(array("gotoXHsync", "gotoXVsync") as $val){
       $smarty->assign($val, $this->$val);
     }
-    $smarty->assign("staticAddress", "");
 
     /* Checkboxes */
     foreach(array("gotoScannerEnable") as $val){
@@ -417,13 +380,17 @@ class workservice extends plugin
         $val= preg_replace ("/\s/", "", $this->gotoXVsync);
 
         if($this->acl_is_writeable("gotoXVsync")){
-          if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
+          if(empty($val)){
+            $message[]= msgPool::required(_("VSync"));
+          }elseif (!preg_match ("/^\d+(\.\d+)?([+-]\d+(\.\d+)?)?$/", $val)){
             $message[]= msgPool::invalid(_("VSync"));
           } else{
-            list($v1,$v2)= preg_split ("/[-+]/", $val);
-            if ($v2 != ""){
-              if ($v1 > $v2){
-                $message[]= msgPool::invalid(_("VSync"));
+            if (!preg_match('/^\d+$/', $val)){
+              list($v1,$v2)= preg_split ("/[-+]/", $val);
+              if ($v2 != ""){
+                if ($v1 > $v2){
+                  $message[]= msgPool::invalid(_("VSync"));
+                }
               }
             }
           }
@@ -432,13 +399,17 @@ class workservice extends plugin
         /* Check hsync for correct usage */
         $val= preg_replace ("/\s/", "", $this->gotoXHsync);
         if($this->acl_is_writeable("gotoXHsync")){
-          if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
+          if(empty($val)){
+            $message[]= msgPool::required(_("HSync"));
+          }elseif (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
             $message[]= msgPool::invalid(_("HSync"));
           } else{
-            list($v1,$v2)= preg_split ("/[-+]/", $val);
-            if ($v2 != ""){
-              if ($v1 > $v2){
-                $message[]= msgPool::invalid(_("HSync"));
+            if (!preg_match('/^\d+$/', $val)){
+              list($v1,$v2)= preg_split ("/[-+]/", $val);
+              if ($v2 != ""){
+                if ($v1 > $v2){
+                  $message[]= msgPool::invalid(_("HSync"));
+                }
               }
             }
           }
@@ -513,8 +484,13 @@ class workservice extends plugin
           "i128", "i740", "i810", "intel", "imstt", "mga", "neomagic", "newport", "nsc",  "nv", "nvidia",
           "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion",
           "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware");
+    } 
+    $tmp = array();
+    foreach($drivers as $name){
+      $tmp[$name] = $name;
     }
-    return($drivers);
+
+    return($tmp);
   }
 
 
@@ -539,7 +515,6 @@ class workservice extends plugin
             "gotoXVsync"            => _("VSync"),
             "AutoSync"              => _("Use DDC"),
             "gotoScannerEnable"     => _("Scanner enabled"),
-            "gotoLpdEnable"         => _("Printer enabled"),
             "gotoXKbModel"          => _("Keyboard model"),
             "gotoXKbLayout"         => _("Keyboard layout"),
             "gotoXKbVariant"        => _("Keyboard variant"),
@@ -569,7 +544,7 @@ class workservice extends plugin
            */
           $p = $this->parent->by_object['ogroup'];
           foreach($p->memberList as $dn => $obj){
-            if(preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$dn)) continue;
+            if(preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/",$dn)) continue;
             if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){
               $macs[] = $p->objcache[$dn]['macAddress'];
             }
@@ -579,7 +554,7 @@ class workservice extends plugin
           /* We are a workstation. Add current mac.
            */
           $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
-          if(!empty($mac) && !preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$this->orig_dn)){
+          if(!empty($mac) && !preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/",$this->orig_dn)){
             $macs[] = $mac;
           }          
         }