Code

Removed show_ldap_error() calls
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_terminalService.inc
index ec1dd12ac71a0b3c76605c554262526fcfaab7ef..63fe1fce14b105c05e6f178ddf7524cc7c7bb075 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= "";
@@ -51,7 +46,7 @@ class termservice extends plugin
 
 
   /* attribute list for save action */
-  var $attributes= array("cn", "gotoLpdEnable", "gotoXMonitor", "gotoXMethod", "gotoXdmcpServer",
+  var $attributes= array("gotoLpdEnable", "gotoXMonitor", "gotoXMethod", "gotoXdmcpServer",
       "gotoXDriver", "gotoXResolution", "gotoXColordepth",
       "gotoXHsync", "gotoXVsync", "gotoLpdEnable", "gotoLpdServer",
       "gotoScannerEnable", "gotoScannerModel", "gotoScannerClients",
@@ -139,7 +134,7 @@ 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",
+    $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", 
@@ -166,7 +161,9 @@ class termservice extends plugin
 
     /* Terminal server methods 
      */
-    $this->XMethods["default"]= _("default");
+    if($this->is_ogroup_member){
+      $this->XMethods["default"]= _("inherited");
+    }
     $this->XMethods["xdmcp"]  = _("XDMCP");
     $this->XMethods["ldm"]    = _("LDM");
     $this->XMethods["rdp"]    = _("Windows RDP");
@@ -183,36 +180,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']);
@@ -342,8 +348,10 @@ class termservice extends plugin
      */ 
     $xdmcp_types =  $this->config->data['SERVERS']['TERMINAL_SESSION_TYPES'];
     $available_servers = array();
-    if(isset($xdmcp_types[strtoupper($this->gotoXMethod)])){
-      $available_servers = $xdmcp_types[strtoupper($this->gotoXMethod)];
+    foreach($xdmcp_types as $servername =>$supported_types){
+      if(in_array(strtoupper($this->gotoXMethod),$supported_types)){
+        $available_servers[]  = $servername;
+      }
     }
 
     /* Append additional information to invalid server selections.
@@ -430,6 +438,14 @@ 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);
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+    }
   }
 
 
@@ -504,15 +520,19 @@ class termservice extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
 
-    $xdmcp_types =  $this->config->data['SERVERS']['TERMINAL_SESSION_TYPES'];
-    $available_servers = array();
-    if(isset($xdmcp_types[strtoupper($this->gotoXMethod)])){
-      $available_servers = $xdmcp_types[strtoupper($this->gotoXMethod)];
-    }
-    foreach($this->selected_xdmcp_servers as $server){
-      if(!in_array($server,$available_servers)){
-        $message[] = _("Remote desktop settings contains servers that do not support the selected connection method.");
-        break;
+    if($this->gotoXMethod != "default"){
+      $xdmcp_types =  $this->config->data['SERVERS']['TERMINAL_SESSION_TYPES'];
+      $available_servers = array();
+      foreach($xdmcp_types as $servername =>$supported_types){
+        if(in_array(strtoupper($this->gotoXMethod),$supported_types)){
+          $available_servers[]  = $servername;
+        }
+      }
+      foreach($this->selected_xdmcp_servers as $server){
+        if(!in_array($server,$available_servers)){
+          $message[] = _("Remote desktop settings contains servers that do not support the selected connection method.");
+          break;
+        }
       }
     }
 
@@ -564,14 +584,16 @@ 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");
   }
 
 
   function getListOfXDrivers()
   {
-    $drivers = array("unknown" => "["._("unknown")."]");
+    $drivers = array("default" => "["._("unknown")."]");
 
     /* Generate a list of xdrivers from CONFIG_DIR/xdrivers */
     if (file_exists(CONFIG_DIR.'/xdrivers')){