Code

Fixed image path
[gosa.git] / plugins / admin / systems / class_workstationGeneric.inc
index 062073468667b4b0858da34b2ebe4ccfc5be636c..33a49bcb040347a9de0ab30398f0989b91ac99b5 100644 (file)
@@ -8,7 +8,7 @@ class workgeneric extends plugin
   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
 
   /* Generic terminal attributes */
-  var $gotoMode= "disabled";
+  var $gotoMode= "locked";
   var $gotoSyslogServer= "";
   var $gotoNtpServer= "";
   var $gotoSndModule= "";
@@ -25,6 +25,8 @@ class workgeneric extends plugin
   var $ghGfxAdapter= "-";
   var $ghSoundAdapter= "-";
   var $gotoLastUser= "-";
+  var $FAIscript="";
+  var $didAction= FALSE;
 
   /* Needed values and lists */
   var $base= "";
@@ -40,8 +42,8 @@ class workgeneric extends plugin
   var $attributes= array("gotoMode", "macAddress", "gotoSyslogServer", "gotoNtpServer",
       "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
       "ghCpuType", "ghMemSize", "ghUsbSupport", "ipHostNumber",
-      "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l");
-  var $objectclasses= array("top", "gotoWorkstation", "GOhard");
+      "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript");
+  var $objectclasses= array("top", "gotoWorkstation", "GOhard","FAIobject");
 
   function workgeneric ($config, $dn= NULL)
   {
@@ -50,7 +52,7 @@ class workgeneric extends plugin
     /* Load available modes */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd ($this->config->current['BASE']);
-    $ldap->search ("(objectClass=gotoInstallProfile)");
+    $ldap->search ("(objectClass=gotoInstallProfile)",array("cn"));
     while ($attrs= $ldap->fetch()){
       $this->modes[]= $attrs["cn"][0];
     }
@@ -65,9 +67,10 @@ class workgeneric extends plugin
       }
     }
 
-    $this->modes["disabled"]= _("disabled");
-    $this->modes["text"]= _("text");
-    $this->modes["graphic"]= _("graphic");
+    $this->modes["active"]= _("Activated");
+    $this->modes["locked"]= _("Locked");
+    $this->modes["memcheck"]= _("Memory test");
+    $this->modes["sysinfo"]= _("System analysis");
 
     /* Set base */
     if ($this->dn == "new"){
@@ -83,48 +86,25 @@ class workgeneric extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
     }
 
     if (isset($_POST['action'])){
-      switch($_POST['saction']){
-        case 'wake':
-          $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD");
-          if ($cmd == ""){
-            print_red(_("No WAKECMD definition found in your gosa.conf"));
-          } else {
-            exec ($cmd." ".$this->macAddress, $dummy, $retval);
-            if ($retval != 0){
-              print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
-            }
-          }
-          break;
-
-        case 'reboot':
-          $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD");
-          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= search_config($this->config->data['TABS'], "terminfo", "HALTCMD");
-          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;
+      $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD");
+      if ($cmd == ""){
+        print_red(_("No ACTIONCMD definition found in your gosa.conf"));
+      } else {
+        exec ($cmd." ".$this->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval);
+        if ($retval != 0){
+          print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
+        } else {
+          $this->didAction= TRUE;
+        }
       }
     }
 
@@ -148,9 +128,15 @@ class workgeneric extends plugin
 
     /* Offline */
     if ($retval == 0){
-      $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot")));
+      $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
+                                       "instant_update" => _("Instant update"),
+                                       "update" => _("Scheduled update"),
+                                       "reinstall" => _("Reinstall"),
+                                       "rescan" => _("Rescan hardware")));
     } else {
-      $smarty->assign("actions", array("wake" => _("Wake up")));
+      $smarty->assign("actions", array("wake" => _("Wake up"),
+                                       "reinstall" => _("Reinstall"),
+                                       "update" => _("Scheduled update")));
     }
     /* Arrays */
     $smarty->assign("modes", $this->modes);
@@ -160,7 +146,6 @@ class workgeneric extends plugin
 
     /* Variables */
     foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
-
       $smarty->assign($val."_select", $this->$val);
       $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
@@ -284,19 +269,20 @@ class workgeneric extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
-      $this->handle_post_events("add");
+      if(!$this->didAction){
+        $this->handle_post_events("add");
+      }
     } else {
       if ($this->orig_dn != $this->dn){
         $this->move($this->orig_dn, $this->dn);
       }
       $ldap->cd($this->dn);
       $ldap->modify($this->attrs);
-      $this->handle_post_events("modify");
+      if(!$this->didAction){
+        $this->handle_post_events("modify");
+      }
     }
     show_ldap_error($ldap->get_error());
-
-    /* Optionally execute a command after we're done */
-    $this->postcreate();
   }
 
 }