From: hickert Date: Tue, 19 Feb 2008 09:29:35 +0000 (+0000) Subject: Updated gotomasses. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a442e14fea1864082d418cc8ed16259dd33a4d2e;p=gosa.git Updated gotomasses. -Allow priority updates now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8948 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc b/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc index 75b40f62f..57a094eb8 100644 --- a/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc +++ b/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc @@ -18,7 +18,7 @@ class gotomasses extends plugin var $sort_by = "Schedule"; var $sort_dir = "down"; - + var $entries = array(); var $range = 25; var $start = 0; @@ -40,10 +40,13 @@ class gotomasses extends plugin $s_entry = $s_action = ""; $arr = array( - "/^stop_/" => "stop", - "/^stop_all/" => "stop_all", - "/^start_/" => "start", - "/^start_all/" => "start_all", + "/^stop_/" => "stop", + "/^stop_all/" => "stop_all", + "/^start_/" => "start", + "/^start_all/" => "start_all", + + "/^prio_up_/" => "prio_up", + "/^prio_down_/" => "prio_down", "/^edit_task_/" => "edit", "/^remove_task_/" => "remove", @@ -71,6 +74,19 @@ class gotomasses extends plugin * Handle Priority modifications ************/ + if(preg_match("/^prio_/",$s_action)){ + + switch($s_action){ + + case 'prio_down' : $this->update_priority($s_entry,"down");break; + case 'prio_up' : $this->update_priority($s_entry,"up");break; + } + } + + /************ + * Handle start/stop modifications + ************/ + if(preg_match("/^start/",$s_action) || preg_match("/^stop/",$s_action)){ switch($s_action){ @@ -245,11 +261,15 @@ class gotomasses extends plugin "attach"=>"style='border-right:0px;width:120px;'")); - $entries = $this->get_queued_entries(); + /* Reload the list of entries */ + $this->reload(); + + foreach($this->entries as $key => $task){ - foreach($entries as $key => $task){ - $prio_actions = " "; + $prio_actions = " "; + $prio_actions.= " "; + $prio_actions.= " "; $prio_actions.= " "; $action = "o_queue->get_queued_entries(-1,-1,"timestamp DESC"); + }else{ + $tmp = $this->o_queue->get_queued_entries(-1,-1,"timestamp ASC"); + } + $last = array(); + foreach($tmp as $entry){ + if($entry['ID'] == $id){ + if(count($last)){ + $time = strtotime($last['TIMESTAMP']); + if($type == "up"){ + $time ++; + }else{ + $time --; + } + $time_str = date("YmdHis",$time); + return($this->o_queue->update_entries(array($id),array("timestamp" => $time_str))); + }else{ + return(FALSE); + } + } + $last = $entry; + } + return(FALSE); + } + + /*! \brief Force queue job to be done as far as possible. * @return Boolean TRUE in case of success, else FALSE. */ @@ -337,7 +391,7 @@ class gotomasses extends plugin /*! \brief Request list of queued jobs. * @return Returns an array of all queued jobs. */ - function get_queued_entries() + function reload() { $map = array( "QueuePosition" => "id", @@ -359,20 +413,19 @@ class gotomasses extends plugin $start = $this->start; $stop = $this->range; + $entries = $this->o_queue->get_queued_entries($start,$stop,$sort); - if(!is_array($entries) || !isset($entries['XML']) || !is_array($entries['XML'])){ + if(!is_array($entries)){ if ($this->o_queue->get_error()){ msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "

".$this->o_queue->get_error()), ERROR_DIALOG); } return(array()); } - $ret = array(); - foreach($entries['XML'] as $entry){ - $task = $entry['ID']; - $ret[]= $entry; + $this->entries = array(); + foreach($entries as $entry){ + $this->entries[]= $entry; } - return($ret); }