Code

Added branches container for old stuff
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_terminalService.inc
index 2f8141c64aed94ae7f5b451d83b4e086aaf9068f..9b00eae13145f4f66320c7c8cfd10207fda155bf 100644 (file)
@@ -2,11 +2,6 @@
 
 class termservice 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");
-
   /* Generic terminal attributes */
   var $gotoLpdEnable= FALSE;
   var $gotoXMonitor= "";
@@ -100,8 +95,8 @@ class termservice extends plugin
           "1400x1050" =>  "1400x1050",
           "1600x1200" =>  "1600x1200");
 
-    if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){
-      $file = $this->config->data['MAIN']['RESOLUTION_HOOK'];
+    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);
@@ -112,7 +107,7 @@ class termservice extends plugin
           }
         }
       }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));
+        msg_dialog::display(_("Configuration error"), msgPool::cannotReadFile($file), WARNING_DIALOG);
       }
     }
 
@@ -139,12 +134,19 @@ class termservice extends plugin
     /* Additional values will be extracted from CONFIG_DIR.keyboardLayouts */
     $this->XKbLayouts = array("de"=> "de","intl" =>"intl","us" =>"us");
     $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
      */
@@ -185,36 +187,45 @@ class termservice extends plugin
 
     /* Load phone hardware list 
      */
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(objectClass=goFonHardware)", array('cn', 'description'));
-    while ($attrs= $ldap->fetch()){
+    $tmp = get_sub_list("(objectClass=goFonHardware)","",array(get_ou("phoneou")), 
+                  $this->config->current['BASE'],array("cn","description"), GL_NO_ACL_CHECK);
+    foreach($tmp as $attrs){
       $cn= $attrs['cn'][0];
+      $description= "";
       if (isset($attrs['description'])){
         $description= " - ".$attrs['description'][0];
-      } else {
-        $description= "";
       }
       $this->hardware_list[$cn]= "$cn$description";
     }
-
-    /* Eventually colorize phones */
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware'));
-    while($attrs = $ldap->fetch()){
-        $cn = $attrs['goFonHardware'][0];
-        if(isset($this->hardware_list[$cn])){
-          $this->used_hardware[$cn]= $cn;
-        }
-    }
     $this->hardware_list["automatic"]= _("automatic");
     ksort($this->hardware_list);
 
+    /* These departments may contain objects that have 
+        goFonHardware set. 
+     */
+    $deps_a = array(
+        get_people_ou(),
+        get_ou("ogroupou"),
+        get_ou("serverou"),
+        get_ou("terminalou"),
+        get_ou("workstationou"),
+        get_ou("printerou"),
+        get_ou("componentou"),
+        get_ou("phoneou"));
+
+    $tmp = get_sub_list("(goFonHardware=*)","",$deps_a,$this->config->current['BASE'],
+        array('cn','dn','goFonHardware'),GL_NO_ACL_CHECK);
+    foreach($tmp as $attrs){
+      $cn = $attrs['goFonHardware'][0];
+      if(isset($this->hardware_list[$cn])){
+        $this->used_hardware[$cn]= $cn;
+      }
+    }
+
     /* Convert gotoLpdEnable 
      */
     $this->gotoLpdEnable= preg_match("/yes/i",$this->gotoLpdEnable);
 
-
     /* Load hardware list */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
@@ -265,10 +276,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;
         }
       }
@@ -299,7 +310,7 @@ class termservice extends plugin
 
     /* Do we represent a valid terminal? */
     if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
+      $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\">&nbsp;<b>".
         _("This 'dn' has no terminal features.")."</b>";
       return ($display);
     }
@@ -434,12 +445,6 @@ class termservice extends plugin
   {
     new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs));
     $this->handle_post_events("remove");
-
-    plugin::remove_from_parent();
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
-    show_ldap_error($ldap->get_error(),_("Could not remove terminal service."));
   }
 
 
@@ -479,13 +484,12 @@ class termservice extends plugin
         /* Check vsync for correct usage */
         $val= preg_replace ("/\s/", "", $this->gotoXVsync);
         if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXVsync")){
-
-          $message[]= _("Please specify a valid VSync range.");
+          $message[]= msgPool::invalid(_("VSync range"));
         } elseif ($this->acl_is_writeable("gotoXVsync")){
           list($v1,$v2)= preg_split ("/[-+]/", $val);
           if ($v2 != ""){
             if ($v1 > $v2){
-              $message[]= _("Please specify a valid VSync range.");
+              $message[]= msgPool::invalid(_("VSync range"));
             }
           }
         }
@@ -493,13 +497,12 @@ class termservice extends plugin
         /* Check hsync for correct usage */
         $val= preg_replace ("/\s/", "", $this->gotoXHsync);
         if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXHsync")){
-
-          $message[]= _("Please specify a valid HSync range.");
+          $message[]= msgPool::invalid(_("HSync range"));
         } elseif ($this->acl_is_writeable("gotoXHsync")){
           list($v1,$v2)= preg_split ("/[-+]/", $val);
           if ($v2 != ""){
             if ($v1 > $v2){
-              $message[]= _("Please specify a valid HSync range.");
+              $message[]= msgPool::invalid(_("HSync range"));
             }
           }
         }
@@ -578,7 +581,9 @@ class termservice extends plugin
     $ldap->modify ($this->attrs); 
     new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/service with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+    }
     $this->handle_post_events("modify");
   }
 
@@ -598,7 +603,7 @@ class termservice extends plugin
     } else {
       foreach( array(
           "ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx",
-          "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc",  "nv", "nvidia",
+          "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") as $driver){
         $drivers[] = $driver;
@@ -627,8 +632,8 @@ class termservice extends plugin
             "gotoXDriver"             => _("Gfx driver"),
             "gotoXResolution"         => _("Gfx resolution"),
             "gotoXColordepth"         => _("Gfx color depth"),
-            "gotoXHsync"              => _("Hsync"),
-            "gotoXVsync"              => _("Vsync"),
+            "gotoXHsync"              => _("HSync"),
+            "gotoXVsync"              => _("VSync"),
             "AutoSync"                => _("Auto-Sync"),
             "gotoLpdEnable"           => _("Printer service enabled"),
             "gotoLpdServer"           => _("Spool server"),