Code

Systems Workstation Startup
[gosa.git] / plugins / admin / systems / class_workstationService.inc
index 340091fdedc5de08054af2fec3aceaf9a404d6a4..a12ac099244755167392beb14dd4f5e2062d83a7 100644 (file)
@@ -2,11 +2,6 @@
 
 class workservice extends plugin
 {
 
 class workservice extends plugin
 {
-  /* CLI vars */
-  var $cli_summary= "Manage terminal service aspects";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   var $gotoScannerEnable;
   /* Generic terminal attributes */
   var $gotoXMonitor= "";
   var $gotoScannerEnable;
   /* Generic terminal attributes */
   var $gotoXMonitor= "";
@@ -58,12 +53,20 @@ class workservice extends plugin
   var $XKbLayouts       =array();
   var $XKbVariants      =array();
 
   var $XKbLayouts       =array();
   var $XKbVariants      =array();
 
-  function workservice ($config, $dn= NULL)
+  var $member_of_ogroup = FALSE;
+
+  function workservice ($config, $dn= NULL, $parent= NULL)
   {
   {
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
+
+    if(!isset($this->parent->by_object['ogroup'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn"));
+      $this->member_of_ogroup = $ldap->count() >= 1;
+    }
 
     $this->XResolutions= array( 
 
     $this->XResolutions= array( 
-        "default"   =>  "["._("inherited")."]",
         "640x480"   =>  "640x480",
         "800x600"   =>  "800x600",
         "1024x768"  =>  "1024x768",
         "640x480"   =>  "640x480",
         "800x600"   =>  "800x600",
         "1024x768"  =>  "1024x768",
@@ -90,17 +93,14 @@ class workservice extends plugin
       }
     }
 
       }
     }
 
-
     array_unshift($this->XDrivers, "["._("unknown")."]");
     array_unshift($this->XDrivers, "["._("unknown")."]");
-  
     $this->XColordepths= array( 
     $this->XColordepths= array( 
-        "default"  => "["._("inherited")."]", 
         "8"        => "8 " ._("bit"), 
         "15"       => "15 "._("bit"),      
         "16"       => "16 "._("bit"),   
         "24"       => "24 "._("bit"));
 
         "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",
     foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex",
           "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless",
           "logiinetnav", "logiinternet", "macintosh", "microsoft",
@@ -109,17 +109,16 @@ class workservice extends plugin
       $this->XKbModels[$type] = $type;
     }
 
       $this->XKbModels[$type] = $type;
     }
 
-    $this->MouseTypes= array("AUTO"     => "["._("inherited")."]", "ImPS/2"      =>"ImPS/2", 
-                             "PS/2"     => "PS/2",                "Microsoft"   =>"Microsoft", 
-                              "Logitech"=>"Microsoft");
+    $this->MouseTypes= array("ImPS/2" => "ImPS/2", "PS/2" => "PS/2", "Microsoft" => "Microsoft", 
+                              "Logitech" => "Logitech");
 
 
-    $this->MousePorts= array("AUTO"             => "["._("inherited")."]", "/dev/ttyS0"  =>"/dev/ttyS0", 
+    $this->MousePorts= array("/dev/ttyS0"  =>"/dev/ttyS0", 
                              "/dev/ttyS1"       => "/dev/ttyS1",          "/dev/psaux"  =>"/dev/psaux", 
                              "/dev/input/mice"  => "/dev/input/mice");
 
                              "/dev/ttyS1"       => "/dev/ttyS1",          "/dev/psaux"  =>"/dev/psaux", 
                              "/dev/input/mice"  => "/dev/input/mice");
 
-    /* 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");
+    /* Additional values will be extracted from CONFIG_DIR/gosa/keyboardLayouts */
+    $this->XKbLayouts= array ("de"=> "de","intl" =>"intl","us" =>"us");
+    $this->XKbVariants= array ("basic"=>"basic", "nodeadkeys"=>"nodeadkeys");
 
     /* try to read additional keyboard layouts 
      */
 
     /* try to read additional keyboard layouts 
      */
@@ -140,14 +139,13 @@ class workservice extends plugin
     }
 
     /* Initialize methods */
     }
 
     /* Initialize methods */
-    $this->XMethods["default"]= _("default");
     $this->XMethods["indirect"]= _("show chooser");
     $this->XMethods["query"]= _("direct");
     $this->XMethods["indirect"]= _("show chooser");
     $this->XMethods["query"]= _("direct");
-#$this->XMethods["squery"]= _("direct via ssh");
-#$this->XMethods["nquery"]= _("direct via nx");
+    #$this->XMethods["squery"]= _("direct via ssh");
+    #$this->XMethods["nquery"]= _("direct via nx");
     $this->XMethods["load"]= _("load balanced");
     $this->XMethods["load"]= _("load balanced");
-#$this->XMethods["sload"]= _("load balanced via ssh");
-#$this->XMethods["nload"]= _("load balanced via nx");
+    #$this->XMethods["sload"]= _("load balanced via ssh");
+    #$this->XMethods["nload"]= _("load balanced via nx");
     $this->XMethods["rdp"]= _("Windows RDP");
     $this->XMethods["citrix"]= _("ICA client");
 
     $this->XMethods["rdp"]= _("Windows RDP");
     $this->XMethods["citrix"]= _("ICA client");
 
@@ -187,6 +185,59 @@ class workservice extends plugin
 
     $this->hardware_list["automatic"]= _("automatic");
     ksort($this->hardware_list);
 
     $this->hardware_list["automatic"]= _("automatic");
     ksort($this->hardware_list);
+
+    /* 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= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions;
+            break;
+          case 'gotoXColordepth':
+            $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths;
+            break;
+          case 'gotoXKbModel':
+            $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels;
+            break;
+          case 'gotoXKbLayout':
+            $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts;
+            break;
+          case 'gotoXKbVariant':
+            $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants;
+            break;
+          case 'gotoXMouseType':
+            $this->MouseTypes= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes;
+            break;
+          case 'gotoXMouseport':
+            $this->MousePorts= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts;
+            break;
+        }
+
+      }
+
+    }
+
+    /* Workaround to fill in inherited values if we've specified an objectclass */
+    if (isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){
+      $this->XResolutions= array('default' => _("inherited"));
+      $this->XColordepths= array('default' => _("inherited"));
+      $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"));
+    }
   }
 
   function execute()
   }
 
   function execute()
@@ -274,10 +325,14 @@ class workservice extends plugin
 
     if($this->AutoSync){
       $smarty->assign("AutoSyncCHK"," checked ");
 
     if($this->AutoSync){
       $smarty->assign("AutoSyncCHK"," checked ");
+      $smarty->assign("hiddenState"," disabled ");
     }else{
       $smarty->assign("AutoSyncCHK"," ");
     }else{
       $smarty->assign("AutoSyncCHK"," ");
+      $smarty->assign("hiddenState","");
     }
 
     }
 
+    $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
+
     /* Show main page */
     return($smarty->fetch (get_template_path('workstationService.tpl',TRUE,dirname(__FILE__))));
   }
     /* Show main page */
     return($smarty->fetch (get_template_path('workstationService.tpl',TRUE,dirname(__FILE__))));
   }
@@ -292,7 +347,11 @@ class workservice extends plugin
   {
     plugin::save_object();
 
   {
     plugin::save_object();
 
-    if(isset($_POST['gotoXHsync'])){
+    if(isset($_POST["inheritAll"])){
+      $this->set_everything_to_inherited();
+    }
+
+    if(isset($_POST['gotoXDriver']) && chkacl($this->acl,"AutoSync") == ""){
       if(isset($_POST['AutoSync'])){
         $this->AutoSync = true;
       }else{
       if(isset($_POST['AutoSync'])){
         $this->AutoSync = true;
       }else{
@@ -310,36 +369,41 @@ class workservice extends plugin
     /* Default entries can use blank hsync/vsync entries */
     if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){
 
     /* Default entries can use blank hsync/vsync entries */
     if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){
 
-      /* Check vsync for correct usage */
-      $val= preg_replace ("/\s/", "", $this->gotoXVsync);
-      if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)
-          && chkacl ($this->acl, "gotoXVsync") == ""){
-
-        $message[]= _("Please specify a valid VSync range.");
-      } elseif (chkacl ($this->acl, "gotoXVsync") == ""){
-        list($v1,$v2)= preg_split ("/[-+]/", $val);
-        if ($v2 != ""){
-          if ($v1 > $v2){
-            $message[]= _("Please specify a valid VSync range.");
+      /* But only if no auto sync is enabled... */
+      if (!$this->AutoSync){
+
+        /* Check vsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXVsync);
+        if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)
+            && chkacl ($this->acl, "gotoXVsync") == ""){
+
+          $message[]= _("Please specify a valid VSync range.");
+        } elseif (chkacl ($this->acl, "gotoXVsync") == ""){
+          list($v1,$v2)= preg_split ("/[-+]/", $val);
+          if ($v2 != ""){
+            if ($v1 > $v2){
+              $message[]= _("Please specify a valid VSync range.");
+            }
           }
         }
           }
         }
-      }
 
 
-      /* Check hsync for correct usage */
-      $val= preg_replace ("/\s/", "", $this->gotoXHsync);
-      if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)
-          && chkacl ($this->acl, "gotoXHsync") == ""){
-
-        $message[]= _("Please specify a valid HSync range.");
-      } elseif (chkacl ($this->acl, "gotoXHsync") == ""){
-        list($v1,$v2)= preg_split ("/[-+]/", $val);
-        if ($v2 != ""){
-          if ($v1 > $v2){
-            $message[]= _("Please specify a valid HSync range.");
+        /* Check hsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXHsync);
+        if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)
+            && chkacl ($this->acl, "gotoXHsync") == ""){
+
+          $message[]= _("Please specify a valid HSync range.");
+        } elseif (chkacl ($this->acl, "gotoXHsync") == ""){
+          list($v1,$v2)= preg_split ("/[-+]/", $val);
+          if ($v2 != ""){
+            if ($v1 > $v2){
+              $message[]= _("Please specify a valid HSync range.");
+            }
           }
         }
       }
     }
           }
         }
       }
     }
+
     return ($message);
   }
 
     return ($message);
   }
 
@@ -366,8 +430,8 @@ class workservice extends plugin
     }
 
     if($this->AutoSync){
     }
 
     if($this->AutoSync){
-      $this->attrs['gotoXHsync'] = preg_replace("/-/","+",$this->attrs['gotoXHsync']) ;
-      $this->attrs['gotoXVsync'] = preg_replace("/-/","+",$this->attrs['gotoXVsync']) ;
+      $this->attrs['gotoXHsync'] = "30+55";
+      $this->attrs['gotoXVsync'] = "50+70";
     }
 
     /* Write back to ldap */
     }
 
     /* Write back to ldap */
@@ -380,6 +444,19 @@ class workservice extends plugin
     $this->handle_post_events("modify");
   }
 
     $this->handle_post_events("modify");
   }
 
+  
+  function set_everything_to_inherited()
+  {
+      $this->gotoXKbLayout = "default";
+      $this->gotoXKbModel = "default";
+      $this->gotoXKbVariant = "default";      
+
+      $this->gotoXDriver ="default";
+      $this->gotoXResolution ="default";
+      $this->gotoXColordepth ="default";
+      $this->gotoXMouseType ="default";
+      $this->gotoXMouseport ="default";
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: