Code

Updated to handle actions
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 31 Jan 2008 16:24:58 +0000 (16:24 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 31 Jan 2008 16:24:58 +0000 (16:24 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8707 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc
gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc

index 9ac6d7d1f5278980aed38507e8c2a31d995b85ec..a94547aeecf20c94234b1b1b1924be4b934cd1ad 100644 (file)
@@ -48,10 +48,8 @@ class termgeneric extends plugin
   var $objectclasses= array("top", "gotoTerminal", "GOhard");
 
   var $mapActions   = array("reboot"          => "",
-                            "instant_update"  => "softupdate",
-                            "update"          => "sceduledupdate",
-                            "reinstall"       => "install",
                             "rescan"          => "",
+                            "wake"            => "",
                             "memcheck"        => "memcheck",
                             "sysinfo"         => "sysinfo");
 
@@ -168,77 +166,8 @@ class termgeneric extends plugin
       $this->is_account= !$this->is_account;
     }
 
-    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){
-
-      /* Set FAIstate */
-      if($this->fai_activated && $this->dn != "new"){
-        $ldap = $this->config->get_ldap_link();
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->cat($this->dn,array("objectClass"));
-        $res = $ldap->fetch();
-
-        $attrs = array();
-        $attrs['FAIstate'] = "";
-        if(isset($this->mapActions[$_POST['saction']])){
-          $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
-        }
-
-        for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
-          $attrs['objectClass'][] = $res['objectClass'][$i];
-        }
-
-        if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
-          $attrs['objectClass'][] = "FAIobject";
-        }
-
-        if($attrs['FAIstate'] == ""){
-#FIXME we should check if FAIobject is used anymore
-          $attrs['FAIstate'] = array();
-        }
-
-        $ldap->cd($this->dn);
-        $ldap->modify($attrs);
-        show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/generic (FAIstate) with dn '%s' failed."),$this->dn));
-      }
-
-      switch($_POST['saction']){
-        case 'wake':
-          $cmd= $this->config->search("termgeneric", "WAKECMD",array('tabs'));
-
-          if ($cmd == ""){
-            print_red(_("No WAKECMD definition found in your gosa.conf"));
-          } else {
-            exec ($cmd." ".$this->netConfigDNS->macAddress, $dummy, $retval);
-            if ($retval != 0){
-              print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
-            }
-          }
-          break;
-
-        case 'reboot':
-          $cmd= $this->config->search("termgeneric", "REBOOTCMD",array('tabs'));
-          if ($cmd == ""){
-            print_red(_("No REBOOTCMD definition found in your gosa.conf"));
-          } else {
-            exec ($cmd." ".$this->cn, $dummy, $retval);
-            if ($retval != 0){
-              print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
-            }
-          }
-          break;
-
-        case 'halt':
-          $cmd= $this->config->search("termgeneric", "HALTCMD",array('tabs'));
-          if ($cmd == ""){
-            print_red(_("No HALTCMD definition found in your gosa.conf"));
-          } else {
-            exec ($cmd." ".$this->cn, $dummy, $retval);
-            if ($retval != 0){
-              print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
-            }
-          }
-          break;
-      }
+    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->mapActions[$_POST['saction']])){
+           gosaSupportDaemon::send("gosa_trigger_action_".$_POST['saction'], $this->netConfigDNS->ipHostNumber, array("macAddress" => $this->netConfigDNS->macAddress));
     }
 
     /* Base select dialog */
index 8b31f43295040dfe5cdd245ef1c2afdc9ab47c92..b151d3a833f49ebe02c99ae384a06e34fcc9330e 100644 (file)
@@ -58,6 +58,7 @@ class workgeneric extends plugin
                             "update"          => "scheduledupdate",
                             "reinstall"       => "install",
                             "rescan"          => "",
+                            "wake"            => "",
                             "memcheck"        => "memcheck",
                             "sysinfo"         => "sysinfo");
 
@@ -180,15 +181,10 @@ class workgeneric extends plugin
       }
     }
 
-    if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate"))){
-      $cmd= $this->config->search("workgeneric", "ACTIONCMD",array('tabs'));
-      if ($cmd == ""){
-        print_red(_("No ACTIONCMD definition found in your gosa.conf"));
-      } else {
-        exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval);
-        if ($retval != 0){
-          print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
-        } elseif ($_POST['saction'] != "wake") {
+    if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){
+       gosaSupportDaemon::send("gosa_trigger_action_".$_POST['saction'], $this->netConfigDNS->ipHostNumber, array("macAddress" => $this->netConfigDNS->macAddress));
+
+        if ($_POST['saction'] != "wake") {
 
           /* Set FAIstate */
           if($this->fai_activated && $this->dn != "new"){
@@ -212,7 +208,7 @@ class workgeneric extends plugin
             }
 
             if($attrs['FAIstate'] == ""){
-#FIXME we should check if FAIobject is not used anymore
+             #FIXME we should check if FAIobject is not used anymore
               $attrs['FAIstate'] = array();
             }
 
@@ -223,7 +219,6 @@ class workgeneric extends plugin
           }
           $this->didAction= TRUE;
         }
-      }
     }
 
     /* Do we represent a valid terminal? */