Code

Fixed images in FAI list
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_terminalService.inc
index d987e441f2af948bb6ee531f082559d8f81e0dbc..360054533daadc85a204f2a33386a8c3ad761dc9 100644 (file)
@@ -90,6 +90,7 @@ class termservice extends plugin
         $this->gotoLpdEnable[] = $this->attrs['gotoLpdEnable'][$i];
       }
     }
+    $this->gotoLpdEnable_dialog = new gotoLpdEnable($this->config,$this->gotoLpdEnable,$this); 
 
     /* Get list of available xdrivers */
     $this->XDrivers = $this->getListOfXDrivers();
@@ -109,7 +110,7 @@ class termservice extends plugin
       $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)){
@@ -144,23 +145,30 @@ class termservice extends plugin
     /* Additional values will be extracted from CONFIG_DIR.keyboardLayouts */
     $this->XKbLayouts = array("de"=> "de","en" =>"en", "es" => "es", "us" =>"us", "fr" => "fr");
     $this->XKbVariants= array("nodeadkeys"=>"nodeadkeys", "basic"=>"basic");
-    $this->MouseTypes = array("ImPS/2"=>"ImPS/2","PS/2"=>"PS/2", "explorerps/2"=>"explorerps/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->MouseTypes= array("auto" => "auto", 
+                             "explorerps/2" => "explorerps/2",
+                             "ImPS/2" => "ImPS/2",
+                             "PS/2" => "PS/2", 
+                             "Microsoft" => "Microsoft",
+                             "Logitech" => "Logitech",);
+
+    $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");
 
     /* 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);
+        $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;
@@ -233,7 +241,7 @@ class termservice extends plugin
         "gotoXColordepth", 
         "gotoXKbModel", 
         "gotoXKbLayout",
-#        "gotoXDriver",
+        "gotoXDriver",
         "gotoXdmcpServer",
         "gotoXKbVariant",
         "gotoXMouseType", 
@@ -248,9 +256,9 @@ class termservice extends plugin
         }
 
         switch ($name){
-#         case 'gotoXDriver': 
-#           $this->XDrivers = array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XDrivers;
-#           break;
+         case 'gotoXDriver': 
+           $this->XDrivers = array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XDrivers;
+           break;
           case 'gotoXMethod': 
             $this->XMethods = array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XMethods;
             if(isset($attrs['gotoXdmcpServer'])){
@@ -275,10 +283,10 @@ class termservice 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;
         }
       }
@@ -314,41 +322,9 @@ class termservice extends plugin
       return ($display);
     }
 
-
-    /**********
-      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();
+    $smarty->assign("gotoLpdEnable_dialog", $this->gotoLpdEnable_dialog->execute());
 
     /* Assign acls */
     $tmp= $this->plInfo();
@@ -428,7 +404,6 @@ class termservice extends plugin
     foreach(array("gotoXHsync", "gotoXVsync") as $val){
       $smarty->assign($val, $this->$val);
     }
-    $smarty->assign("staticAddress", "");
 
     /* Checkboxes */
     foreach(array("gotoScannerEnable") as $val){
@@ -485,6 +460,13 @@ class termservice extends plugin
   {
     plugin::save_object();
 
+    $this->gotoLpdEnable_dialog->save_object();
+    if($this->gotoLpdEnable_dialog->is_account){
+      $this->gotoLpdEnable = $this->gotoLpdEnable_dialog->save();
+    }else{
+      $this->gotoLpdEnable = array();
+    }
+
     /* Save checkbox state */
     if (isset ($_POST['gotoXMethod'])){
       foreach (array("gotoScannerEnable") as $val){
@@ -548,6 +530,7 @@ class termservice extends plugin
   {
     /* Call common method to give check the hook */
     $message= plugin::check();
+    $message = array_merge($message,$this->gotoLpdEnable_dialog->check());
 
     if($this->gotoXMethod != "default"){
       $xdmcp_types =  $this->config->data['SERVERS']['TERMINAL_SESSION_TYPES'];
@@ -642,7 +625,12 @@ class termservice extends plugin
         $drivers[] = $driver;
       }
     }
-    return($drivers);
+
+    $tmp = array();
+    foreach($drivers as $name){
+      $tmp[$name] = $name;
+    }
+    return($tmp);
   }
 
   function send_goto_reload()
@@ -662,7 +650,7 @@ class termservice 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'];
             }
@@ -672,7 +660,7 @@ class termservice 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;
           }
         }
@@ -694,6 +682,19 @@ class termservice extends plugin
   }
 
 
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+
+    $source_o = new termservice ($this->config, $source['dn']);
+
+    foreach(array("gotoXdmcpServer","selected_xdmcp_servers") as $attr){
+      $this->$attr = $source_o->$attr;
+    }
+  }
+
+
+
   /* Return plugin informations for acl handling */
   static function plInfo()
   {
@@ -717,8 +718,8 @@ class termservice extends plugin
             "gotoXHsync"              => _("HSync"),
             "gotoXVsync"              => _("VSync"),
             "AutoSync"                => _("Auto-Sync"),
-            "gotoLpdServer"           => _("Spool server"),
             "gotoScannerEnable"       => _("Scanner enabled"),
+            "gotoLpdEnable"           => _("Printer enabled"),
             "gotoXKbModel"            => _("Keyboard model"),
             "gotoXKbLayout"           => _("Keyboard layout"),
             "gotoXKbVariant"          => _("Keyboard variant"),