Code

Added acls for printer glpi
[gosa.git] / plugins / admin / systems / class_terminalService.inc
index bff691c792723618864c0d3036414ee1641def49..7ffe10bce62b4bc5a08b6b1e693473e8f357a3dd 100644 (file)
@@ -36,7 +36,7 @@ class termservice extends plugin
   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", "vmware");
@@ -45,8 +45,8 @@ class termservice extends plugin
   var $XKbModels= array ();
   var $XKbLayouts= array ();
   var $XKbVariants= array ();
-  var $MouseTypes= array("AUTO", "ImPS/2", "PS/2", "Microsoft", "Logitech");
-  var $MousePorts= array("AUTO", "/dev/ttyS0", "/dev/ttyS1", "/dev/psaux", "/dev/input/mice");
+  var $MouseTypes= array();
+  var $MousePorts= array();
   var $gotoScannerModels= array();
   var $hardware_list= array();
   var $used_hardware= array();
@@ -62,12 +62,14 @@ 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")."]");
     
     $this->XResolutions= array(
-        "default"   =>  _("inherited")  ,
+        "default"   =>  "["._("inherited")."]"  ,
         "640x480"   =>  "640x480",
         "800x600"   =>  "800x600",
         "1024x768"  =>  "1024x768",
@@ -76,14 +78,32 @@ 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"),
+        "default"  => "["._("inherited")."]",
         "8"        => "8 " ._("bit"),
         "15"       => "15 "._("bit"),
         "16"       => "16 "._("bit"),
         "24"       => "24 "._("bit"));
 
-    $this->XKbModels['default']= _("inherited");
+    $this->XKbModels['default']= "["._("inherited")."]";
     foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex",
           "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless",
           "logiinetnav", "logiinternet", "macintosh", "microsoft",
@@ -93,8 +113,17 @@ class termservice extends plugin
     }
 
     /* 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->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
      */
@@ -164,6 +193,47 @@ class termservice extends plugin
 
     $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['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()
@@ -343,10 +413,47 @@ class termservice extends plugin
     $this->cleanup();
     $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error(), _("Saving terminal service information failed"));
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/service with dn '%s' failed."),$this->dn));
     $this->handle_post_events("modify");
   }
 
+
+/* Return plugin informations for acl handling */
+  function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Service"),
+          "plDescription" => _("Terminal service"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("terminal"),
+
+          "plProvidedAcls"=> array(
+            "gotoXMonitor"            => _("Monitor"),
+            "gotoXMethod"             => _("Method"),
+            "gotoXdmcpServer"         => _("Remote desktop"),
+            "gotoFontPath"            => _("Font path"),
+            "gotoXDriver"             => _("Gfx driver"),
+            "gotoXResolution"         => _("Gfx resolution"),
+            "gotoXColordepth"         => _("Gfx color depth"),
+            "gotoXHsync"              => _("Hsync"),
+            "gotoXVsync"              => _("Vsync"),
+            "gotoLpdEnable"           => _("Printer service enabled"),
+            "gotoLpdServer"           => _("Spool server"),
+            "gotoScannerEnable"       => _("Scanner enabled"),
+            "gotoScannerModel"        => _("Scanner model"),
+            "gotoScannerClients"      => _(""),
+            "gotoScannerBackend"      => _(""),
+            "gotoXKbModel"            => _("Keyboard model"),
+            "gotoXKbLayout"           => _("Keyboard layout"),
+            "gotoXKbVariant"          => _("Keyboard variant"),
+            "gotoXMouseType"          => _("Mouse type"),
+            "gotoXMouseport"          => _("Mouse port"),
+            "goFonHardware"           => _("Telephone hardware"))
+          ));
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: