Code

Updated Workstation
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_workstationService.inc
index fe3d0e5b34588213fc14ac97430422df93438b8e..1aae67b27c6a00f7cc8951f782b65ac444fdfb4f 100644 (file)
@@ -3,6 +3,7 @@
 class workservice extends plugin
 {
   var $gotoScannerEnable;
+
   /* Generic terminal attributes */
   var $gotoXMonitor= "";
   var $gotoXDriver= "";
@@ -26,7 +27,6 @@ class workservice extends plugin
   var $base= "";
   var $cn= "";
   var $orig_dn= "";
-  var $XMethods= array();
   var $XDrivers= array();
   var $XResolutions = array();
   var $MouseTypes= array();
@@ -36,8 +36,7 @@ class workservice extends plugin
 
 
   /* attribute list for save action */
-  var $attributes= array("gotoXMonitor",
-      "gotoXDriver", "gotoXResolution", "gotoXColordepth",
+  var $attributes= array("gotoXMonitor", "gotoXDriver", "gotoXResolution", "gotoXColordepth",
       "gotoXHsync", "gotoXVsync",
       "gotoScannerEnable", "gotoScannerClients",
       "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant",
@@ -107,7 +106,7 @@ class workservice extends plugin
                              "/dev/input/mice"  => "/dev/input/mice");
 
     /* Additional values will be extracted from CONFIG_DIR./keyboardLayouts */
-    $this->XKbLayouts= array ("de"=> "de","intl" =>"intl","us" =>"us");
+    $this->XKbLayouts = array("de"=> "de","en" =>"en", "es" => "es", "us" =>"us", "fr" => "fr");
     $this->XKbVariants= array ("nodeadkeys"=>"nodeadkeys", "basic"=>"basic");
 
     /* try to read additional keyboard layouts 
@@ -128,22 +127,11 @@ class workservice extends plugin
       }
     }
 
-    /* Initialize methods */
-    $this->XMethods["indirect"]= _("show chooser");
-    $this->XMethods["query"]= _("direct");
-    #$this->XMethods["squery"]= _("direct via ssh");
-    #$this->XMethods["nquery"]= _("direct via nx");
-    $this->XMethods["load"]= _("load balanced");
-    #$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->orig_dn= $this->dn;
 
     /* Load phone hardware list
      */
-    $tmp = get_sub_list("(objectClass=goFonHardware)","",array(get_ou("phoneou")),
+    $tmp = get_sub_list("(objectClass=goFonHardware)","",array(get_ou("phoneRDN")),
                   $this->config->current['BASE'],array("cn","description"), GL_NO_ACL_CHECK);
     foreach($tmp as $attrs){
       $cn= $attrs['cn'][0];
@@ -161,13 +149,13 @@ class workservice extends plugin
      */
     $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"));
+        get_ou("ogroupRDN"),
+        get_ou("serverRDN"),
+        get_ou("terminalRDN"),
+        get_ou("workstationRDN"),
+        get_ou("printerRDN"),
+        get_ou("componentRDN"),
+        get_ou("phoneRDN"));
 
     $tmp = get_sub_list("(goFonHardware=*)","",$deps_a,$this->config->current['BASE'],
         array('cn','dn','goFonHardware'),GL_NO_ACL_CHECK);
@@ -273,7 +261,7 @@ class workservice extends plugin
     }
 
     /* Arrays */ 
-    foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths",
+    foreach(array("XDrivers", "XResolutions", "XColordepths",
           "XKbModels", "XKbVariants",
           "MouseTypes", "MousePorts") as $val){
       $smarty->assign("$val", $this->$val);
@@ -359,7 +347,7 @@ class workservice extends plugin
   {
     plugin::save_object();
 
-    if((isset($_POST['gotoXDriver'])) && $this->acl_is_writeable("AutoSync")) {
+    if((isset($_POST['workservicePosted'])) && $this->acl_is_writeable("AutoSync")) {
       if(isset($_POST['AutoSync'])){
         $this->AutoSync = true;
       }else{
@@ -384,7 +372,9 @@ class workservice extends plugin
         $val= preg_replace ("/\s/", "", $this->gotoXVsync);
 
         if($this->acl_is_writeable("gotoXVsync")){
-          if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
+          if(empty($val)){
+            $message[]= msgPool::required(_("VSync"));
+          }elseif (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
             $message[]= msgPool::invalid(_("VSync"));
           } else{
             list($v1,$v2)= preg_split ("/[-+]/", $val);
@@ -399,7 +389,9 @@ class workservice extends plugin
         /* Check hsync for correct usage */
         $val= preg_replace ("/\s/", "", $this->gotoXHsync);
         if($this->acl_is_writeable("gotoXHsync")){
-          if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
+          if(empty($val)){
+            $message[]= msgPool::required(_("HSync"));
+          }elseif (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
             $message[]= msgPool::invalid(_("HSync"));
           } else{
             list($v1,$v2)= preg_split ("/[-+]/", $val);
@@ -448,63 +440,19 @@ class workservice extends plugin
     $ldap->cd($this->dn);
     $this->cleanup();
 
-    /* Send SI event to reload goto settings if some options have changed.
-     */
-    if(count($this->attrs) && class_available("DaemonEvent")){
-      $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
-
-      $o_queue = new gosaSupportDaemon();
-      if(isset($events['TRIGGERED']['DaemonEvent_goto_reload'])){
-        $evt = $events['TRIGGERED']['DaemonEvent_goto_reload'];
-        $macs = array();
-
-        /* Get list of macAddresses 
-         */
-        if(isset($this->parent->by_object['ogroup'])){
-
-          /* If we are an object group, add all member macs 
-           */
-          $p = $this->parent->by_object['ogroup'];
-          foreach($p->memberList as $dn => $obj){
-            if(preg_match("/".normalizePreg(get_ou("incomingou"))."/",$dn)) continue;
-            if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){
-              $macs[] = $p->objcache[$dn]['macAddress'];
-            }
-          }
-        }elseif(isset($this->parent->by_object['workgeneric']->netConfigDNS->macAddress)){
-
-          /* We are a workstation. Add current mac.
-           */
-          $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
-          if(!empty($mac) && !preg_match("/".normalizePreg(get_ou("incomingou"))."/",$this->orig_dn)){
-            $macs[] = $mac;
-          }          
-        }
 
-        /* Trigger event for all member objects 
-         */
-        if(count($macs)){
-          $tmp = new $evt['CLASS_NAME']($this->config);
-          $tmp->set_type(TRIGGERED_EVENT);
-          $tmp->add_targets($macs);
-          if(!$o_queue->append($tmp)){
-            msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
-          }
-        }
-      }
+    $ldap->modify ($this->attrs); 
+    new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
     }
+    $this->handle_post_events("modify");
 
     /* Send goto reload event to gosaSupportDaemon */
     if(count($this->attrs)){
       $this->send_goto_reload(); 
     }
 
-    $ldap->modify ($this->attrs); 
-    new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    if (!$ldap->success()){
-      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
-    }
-    $this->handle_post_events("modify");
   }
 
 
@@ -564,26 +512,50 @@ class workservice extends plugin
    */
   function send_goto_reload()
   {
-    $targets = array();
-    if(isset($this->parent) && ($this->parent instanceOf worktabs)){
-      $targets[] = $this->parent->by_object['workgeneric']->netConfigDNS->ipHostNumber;
-    }
-    if(isset($this->parent) && ($this->parent instanceOf ogrouptabs)){
-      $member = $this->parent->by_object['ogroup']->member;
-      $oc = $this->parent->by_object['ogroup']->objcache;
-      foreach($member as $mem){
-        if(isset($oc[$mem]['macAddress'])){
-          $targets[] = $oc[$mem]['macAddress']; 
+    if(count($this->attrs) && class_available("DaemonEvent")){
+      $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+      $o_queue = new gosaSupportDaemon();
+      if(isset($events['TRIGGERED']['DaemonEvent_goto_reload'])){
+        $evt = $events['TRIGGERED']['DaemonEvent_goto_reload'];
+        $macs = array();
+
+        /* Get list of macAddresses 
+         */
+        if(isset($this->parent->by_object['ogroup'])){
+
+          /* If we are an object group, add all member macs 
+           */
+          $p = $this->parent->by_object['ogroup'];
+          foreach($p->memberList as $dn => $obj){
+            if(preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$dn)) continue;
+            if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){
+              $macs[] = $p->objcache[$dn]['macAddress'];
+            }
+          }
+        }elseif(isset($this->parent->by_object['workgeneric']->netConfigDNS->macAddress)){
+
+          /* 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)){
+            $macs[] = $mac;
+          }          
+        }
+
+        /* Trigger event for all member objects 
+         */
+        if(count($macs)){
+          $tmp = new $evt['CLASS_NAME']($this->config);
+          $tmp->set_type(TRIGGERED_EVENT);
+          $target = $o_queue->get_host().":".$o_queue->get_port();
+          $tmp->add_targets(array($target));
+          $tmp->set_macs($macs);
+          if(!$o_queue->append($tmp,TRUE)){
+            msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+          }
         }
       }
     }
-    if(count($targets) && class_available("gosaSupportDaemon") && class_available("DaemonEvent_goto_reload")){
-      $o_g = new gosaSupportDaemon();
-      $evt = new DaemonEvent_goto_reload($this->config);
-      $evt -> set_type(TRIGGERED_EVENT);
-      $evt -> add_targets($targets);
-      $o_g->append($evt);
-    } 
   }