Code

Added queue entry start / stop
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 21 Jan 2008 15:01:09 +0000 (15:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 21 Jan 2008 15:01:09 +0000 (15:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8523 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_gosaSupportDaemon.inc
gosa-core/plugins/addons/gotomasses/class_divListMasses.inc
gosa-core/plugins/addons/gotomasses/class_gotomasses.inc

index 14f84f7c80c33d49429093305865911d1926709a..6d29cc6d170ae080e29f22231cc3aaf109add6d4 100644 (file)
@@ -259,6 +259,8 @@ class gosaSupportDaemon
    */
   public function update_entry($id,$entry)
   {
+    $this->b_error = FALSE;
+    $this->s_error = "";
     if(!is_numeric($id)){
       trigger_error("Requires an integer value as ID parameter.");
       return;
@@ -274,9 +276,6 @@ class gosaSupportDaemon
       $attr.="<".strtolower($name).">".$entry."</".strtolower($name).">\n";
     }
 
-    $this->b_error = FALSE;
-    $this->s_error = "";
-
     $xml_msg = "<xml> 
                   <header>gosa_update_status_jobdb_entry</header>
                   <where>
@@ -288,7 +287,6 @@ class gosaSupportDaemon
                 </xml>";
     $this->connect();
     if($this->is_connected){
-      echo $xml_msg;
       $this->o_sock->write($xml_msg);
       $str      = trim($this->o_sock->read());
       $entries = $this->xml_to_array($str);
index cc1dc8865b61ecb15f5a1691f66e4ad9340ce4a1..42d08b005ddc8918e845667ced52c850e5dbbc65 100644 (file)
@@ -65,10 +65,8 @@ class divListMasses extends MultiSelectWindow
 
     /* Add priority options */
     if(preg_match("/w/",$this->parent->getacl(""))){
-      $header .= "<input type='image' src='images/prio_top.png'       name='multiple_prio_top'      class='center'>&nbsp;";
-      $header .= "<input type='image' src='images/prio_increase.png'  name='multiple_prio_increase' class='center'>&nbsp;";
-      $header .= "<input type='image' src='images/prio_decrease.png'  name='multiple_prio_decrease' class='center'>&nbsp;";
-      $header .= "<input type='image' src='images/prio_bottom.png'    name='multiple_prio_bottom'   class='center'>&nbsp;";
+      $header .= "<input type='image' src='images/status_stop_all.png' name='stop_all' class='center'>&nbsp;";
+      $header .= "<input type='image' src='images/status_start_all.png' name='start_all' class='center'>&nbsp;";
     }
     $header .= "</div>";
     
@@ -118,10 +116,8 @@ class divListMasses extends MultiSelectWindow
       /* Create actions */
       $id         = $task['ID'];
       $queue_pos  = $id;
-      $prio_actions = "<input class='center' type='image' src='images/prio_top.png'      name='prio_top_".$id."'>&nbsp;";
-      $prio_actions.= "<input class='center' type='image' src='images/prio_increase.png' name='prio_increase_".$id."'>&nbsp;";
-      $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png' name='prio_decrease_".$id."'>&nbsp;";
-      $prio_actions.= "<input class='center' type='image' src='images/prio_bottom.png'   name='prio_bottom_".$id."'>&nbsp;";
+      $prio_actions = "<input class='center' type='image' src='images/status_stop_all.png' name='stop_".$id."'>&nbsp;";
+      $prio_actions.= "<input class='center' type='image' src='images/status_start_all.png' name='start_".$id."'>&nbsp;";
       $action = "<input type='image' src='images/edit.png' name='edit_task_".$id."' class='center' alt='"._("Edit")."'>";
       if($this->parent->acl_is_removeable()){
         $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$id."' class='center' alt='"._("Reomve")."'>";
index 9d08ad8fb07d8e8ec4f8893660dff4eb5acce362..2df2bd6b1a2ff9a1cc0a9a494576da085f072953 100644 (file)
@@ -38,15 +38,10 @@ class gotomasses extends plugin
 
     $s_entry = $s_action = "";
     $arr = array( 
-        "/^prio_top_/"      => "prio_top",
-        "/^prio_increase_/" => "prio_increase",
-        "/^prio_decrease_/" => "prio_decrease",
-        "/^prio_bottom_/"   => "prio_bottom",
-
-        "/^multiple_prio_top_/"      => "mprio_top",
-        "/^multiple_prio_increase_/" => "mprio_increase",
-        "/^multiple_prio_decrease_/" => "mprio_decrease",
-        "/^multiple_prio_bottom_/"   => "mprio_bottom",
+        "/^stop_/"      => "stop",
+        "/^stop_all/"  => "stop_all",
+        "/^start/"      => "start",
+        "/^start_all/"  => "start_all",
 
         "/^edit_task_/"             =>  "edit",
         "/^remove_task_/"           =>  "remove",
@@ -74,29 +69,19 @@ class gotomasses extends plugin
      * Handle Priority modifications  
      ************/
 
-    if(preg_match("/^mprio_/",$s_action) || preg_match("/^prio_/",$s_action)){
+    if(preg_match("/^start_/",$s_action) || preg_match("/^stop_/",$s_action)){
 
       switch($s_action){
-        case 'mprio_top'       : foreach($this->list_get_selected_items() as $id ){
-                                   $this->o_queue->max_entry_priority($id);
-                                 }
-                                 break;
-        case 'mprio_increase'  : foreach($this->list_get_selected_items() as $id ){
-                                   $this->o_queue->increase_entry_priority($id);
-                                 }
-                                 break;
-        case 'mprio_decrease'  : foreach($this->list_get_selected_items() as $id ){
-                                   $this->o_queue->decrease_entry_priority($id);
-                                 }
-                                 break;
-        case 'mprio_bottom'    : foreach($this->list_get_selected_items() as $id ){
-                                   $this->o_queue->min_entry_priority($id);
-                                 }
-                                 break;
-        case 'prio_top'       : $this->o_queue->max_entry_priority($s_entry);break;
-        case 'prio_increase'  : $this->o_queue->increase_entry_priority($s_entry);break;
-        case 'prio_decrease'  : $this->o_queue->decrease_entry_priority($s_entry);break;
-        case 'prio_bottom'    : $this->o_queue->min_entry_priority($s_entry);break;
+        case 'start_all'   :foreach($this->list_get_selected_items() as $id){
+                                $this->start_queue_entry($id);
+                            }
+                            break;
+        case 'start'       :$this->start_queue_entry($s_entry);break;
+        case 'stop_all'    :foreach($this->list_get_selected_items() as $id){
+                                $this->stop_queue_entry($id);
+                            }
+                            break;
+        case 'stop'        : $this->stop_queue_entry($s_entry);break;
         default : trigger_error("Undefined priority setting used.");
       }
       if($this->o_queue->is_error()){
@@ -226,6 +211,46 @@ class gotomasses extends plugin
   }
 
 
+  /*! \brief  Force queue job to be done as far as possible.
+   *  @return Boolean TRUE in case of success, else FALSE. 
+   */
+  private function start_queue_entry($id)
+  {
+    $attr = $this->o_queue->get_entry($id); 
+    if(is_array($attr)){
+      $data = array("timestamp" => date("YmdHis"),
+                    "status"  => "-");
+      if(!$this->o_queue->update_entry($id,$data)){
+        msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
+        return(FALSE);
+      }else{
+        return(FALSE);
+      }
+    }
+    return(FALSE);
+  }
+
+
+  /*! \brief Stops the specified queue entry from execution.
+   *  @return Boolean TRUE in case of success, else FALSE. 
+   */
+  private function stop_queue_entry($id)
+  {
+    $attr = $this->o_queue->get_entry($id); 
+    if(is_array($attr)){
+      $data = array("timestamp" => "20370101010000",
+                    "status"  => "stopped");
+      if(!$this->o_queue->update_entry($id,$data)){
+        msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
+        return(FALSE);
+      }else{
+        return(FALSE);
+      }
+    }
+    return(FALSE);
+  }
+
+
   /*! \brief  Request list of queued jobs.
    *  @return Returns an array of all queued jobs.
    */