Code

Added special states like "Waiting for activation" and "Hardware detection"
[gosa.git] / gosa-plugins / goto / addons / goto / class_gotomasses.inc
index ee55782d20ee56026188069097dee14f7d165a24..bc0668db9323c3d93983b3998a50787349bd3fce 100644 (file)
@@ -49,15 +49,13 @@ class gotomasses extends plugin
   {
     /* Include config object */
     $this->config= &$config;
-    $this->o_queue = new gosaSupportDaemon(TRUE,10);
+    $this->o_queue = new gosaSupportDaemon(TRUE,5);
     $this->events  = DaemonEvent::get_event_types( SYSTEM_EVENT);
 
     /* Get tags that will be used in queue searches */
     $this->event_tags = array("none");
-    foreach($this->events['BY_CLASS'] as $evt){
-      if(isset($evt['s_Queued_Action'])){
-        $this->event_tags[] = $evt['s_Queued_Action'];
-      }
+    foreach($this->events['SCHEDULED'] as $evt){
+      $this->event_tags[] = $evt['s_Queued_Action'];
     }
   }
 
@@ -182,7 +180,7 @@ class gotomasses extends plugin
     if($s_action == "remove_multiple" || $s_action == "remove"){
 
       if(!$this->acl_is_removeable()){
-        msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
+        msg_dialog::display(_("Permission"), msgPool::permDelete(), ERROR_DIALOG);
       }else{
 
         if($s_action == "remove"){
@@ -191,6 +189,8 @@ class gotomasses extends plugin
           $ids = $this->list_get_selected_items();
         }
 
+        $this->ids_to_remove = array();
+
         if(count($ids)){
           $ret = $this->o_queue->ids_exist($ids);
           $ret = $this->o_queue->get_entries_by_id($ret);
@@ -211,7 +211,7 @@ class gotomasses extends plugin
             }
           }
           $smarty->assign("multiple", TRUE); 
-          $smarty->assign("info",sprintf(_("You are about to remove the following actions from the GOsa support Daemon: %s"),"<pre>".$tmp."</pre>"));
+          $smarty->assign("info",msgPool::deleteInfo("<pre>".$tmp."</pre>"));
           $this->current = $s_entry;
           return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
         }
@@ -220,6 +220,27 @@ class gotomasses extends plugin
 
     /* Remove specified tasks */
     if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){
+
+      /* Reboot hosts with not yet startet installations and timestamps in the past 
+       */
+      timezone::get_default_timezone();
+      foreach($this->ids_to_remove as $id){
+        $entry = $this->o_queue->get_entries_by_id(array($id));
+        if(isset($entry['ANSWER1'])){
+          $entry = $entry['ANSWER1'];
+          if( $entry['STATUS'] == "wating" && 
+              $entry['HEADERTAG'] == "trigger_action_reinstall"){
+            $evt = new DaemonEvent_reinstall($this->config,$entry);
+            if($evt->get_timestamp(FALSE)  < time()){
+              $r_evt = new DaemonEvent_localboot($this->config);
+              $r_evt->add_targets(array($entry['MACADDRESS']));
+              $r_evt->set_type(TRIGGERED_EVENT);
+              $this->o_queue->append($r_evt);
+            }
+          }
+        }
+      }
+
       $this->o_queue->remove_entries($this->ids_to_remove);
       $this->save();
     }
@@ -239,8 +260,7 @@ class gotomasses extends plugin
       if(is_object($this->dialog)){
         $this->dialog->save_object();
         if(!$this->o_queue->append($this->dialog)){
-          msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
-                $this->o_queue->get_error()),ERROR_DIALOG);
+          msg_dialog::display(_("Service infrastructure"),msgPool::siError($this->o_queue->get_error()),ERROR_DIALOG);
         }else{
           $this->dialog = FALSE; 
           $this->current = -1;
@@ -283,10 +303,10 @@ class gotomasses extends plugin
     }
     if(preg_match("/w/",$this->getacl(""))){
       $s.= "..|---|\n";
-      $s.= "..|<img src='images/status_start.png' alt='' border='0' class='center'>&nbsp;"._("Resume all")."|resume_all\n";
-      $s.= "..|<img src='images/status_pause.png' alt='' border='0' class='center'>&nbsp;"._("Pause all")."|pause_all\n";
-      $s.= "..|<img src='images/small_error.png'  alt='' border='0' class='center'>&nbsp;"._("Abort all")."|abort_process_all\n";
-      $s.= "..|<img src='images/rocket.png'       alt='' border='0' class='center'>&nbsp;"._("Execute all")."|execute_process_all\n";
+      $s.= "..|<img src='images/status_start.png' alt='' border='0' class='center'>&nbsp;"._("Resume")."|resume_all\n";
+      $s.= "..|<img src='images/status_pause.png' alt='' border='0' class='center'>&nbsp;"._("Pause")."|pause_all\n";
+      $s.= "..|<img src='images/small_error.png'  alt='' border='0' class='center'>&nbsp;"._("Abort")."|abort_process_all\n";
+      $s.= "..|<img src='images/rocket.png'       alt='' border='0' class='center'>&nbsp;"._("Execute")."|execute_process_all\n";
     }
 
     $divlist->SetDropDownHeaderMenu($s);
@@ -416,9 +436,20 @@ class gotomasses extends plugin
        */
       if($status == "processing" && isset($task['PROGRESS'])){
         $percent = $task['PROGRESS'];
-        $status = "<img src='progress.php?x=80&amp;y=13&amp;p=".$percent."' alt='".$percent."&nbsp;%'>";
-      }
 
+        /* Show activation? */
+        if ($percent == "goto-activation"){
+          $status = "<img class='center' src='images/status_stopped.png' alt=''>&nbsp;"._("Activation");
+
+        /* Show hardware detect? */
+        } elseif ($percent == "goto-hardware-detection") {
+          $status = "<img class='center' src='images/hardware.png' alt=''>&nbsp;"._("Detection");
+
+        /* Real percent */
+        } else {
+          $status = "<img src='progress.php?x=80&amp;y=13&amp;p=".$percent."' alt='".$percent."&nbsp;%'>";
+        }
+      }
 
       /* Create each field */
       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$key."'>" ,
@@ -446,7 +477,8 @@ class gotomasses extends plugin
                                     "9999" => "*"));
 
     $count = $this->o_queue->number_of_queued_entries();
-    $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range"));
+    if(!$count) $count = $this->range;
+    $divlist->SetListFooter(range_selector($count, $this->start, $this->range,"range"));
     $smarty->assign("range",$this->range);
     $smarty->assign("div",$divlist->Draw());
     return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
@@ -591,13 +623,14 @@ class gotomasses extends plugin
     if(class_available("DaemonEvent_faireboot")){
       $tmp = new DaemonEvent_faireboot($this->config);
       $tmp->add_targets($update_ids);
+      $tmp->set_type(TRIGGERED_EVENT);
       if(!$this->o_queue->append($tmp)){
         msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
         return(FALSE);
       }
     }else{
       msg_dialog::display(_("Error"),
-          sprintf(_("The Job could not be aborted, the '%s' event class was not found."),
+          sprintf(_("The job could not be aborted, the required class '%s' was not found."),
             "DaemonEvent_faireboot") , ERROR_DIALOG);
     }
   }