From: hickert Date: Thu, 25 Oct 2007 08:24:40 +0000 (+0000) Subject: Updated gotomasses, allow priority settings X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=59d2c443914dc3d2bda67d4873f49c1c0f30781b;p=gosa.git Updated gotomasses, allow priority settings git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7650 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/html/images/prio_bottom.png b/html/images/prio_bottom.png new file mode 100644 index 000000000..83920029a Binary files /dev/null and b/html/images/prio_bottom.png differ diff --git a/html/images/prio_decrease.png b/html/images/prio_decrease.png new file mode 100644 index 000000000..377387415 Binary files /dev/null and b/html/images/prio_decrease.png differ diff --git a/html/images/prio_increase.png b/html/images/prio_increase.png new file mode 100644 index 000000000..d9d2de433 Binary files /dev/null and b/html/images/prio_increase.png differ diff --git a/html/images/prio_top.png b/html/images/prio_top.png new file mode 100644 index 000000000..93e74ffae Binary files /dev/null and b/html/images/prio_top.png differ diff --git a/include/class_hostActionQueue.inc b/include/class_hostActionQueue.inc index fd1c0fade..8f925f673 100644 --- a/include/class_hostActionQueue.inc +++ b/include/class_hostActionQueue.inc @@ -356,6 +356,91 @@ class hostActionQueue { return($this->s_error); } + public function max_entry_priority($id) + { + if(!$this->id_exists($id)){ + $this->set_error(sprintf(_("Can't set priority for ID '%s'. ID does not exist."),$id)); + } + $tmp = array(); + $tmp[]= $this->get_entry($id); + foreach($this->a_queue as $key => $entry){ + if($id != $entry['ID']){ + $tmp[] = $entry; + } + } + $this->a_queue=$tmp; + return($this->_save_data()); + } + + public function increase_entry_priority($id) + { + if(!$this->id_exists($id)){ + $this->set_error(sprintf(_("Can't set priority for ID '%s'. ID does not exist."),$id)); + } + $tmp = array(); + $skip = NULL; + $next = NULL; + foreach($this->a_queue as $key => $entry){ + if($next != NULL){ + if($id == $entry['ID']){ + $tmp[] = $entry; + $tmp[] = $next; + $next = NULL; + }else{ + $tmp[] = $next; + $next = $entry; + } + }else{ + $next = $entry; + } + } + if($next != NULL){ + $tmp[] = $next; + } + $this->a_queue=$tmp; + return($this->_save_data()); + } + + public function decrease_entry_priority($id) + { + if(!$this->id_exists($id)){ + $this->set_error(sprintf(_("Can't set priority for ID '%s'. ID does not exist."),$id)); + } + $tmp = array(); + $skip = NULL; + foreach($this->a_queue as $key => $entry){ + if($id != $entry['ID']){ + $tmp[] = $entry; + if($skip != NULL){ + $tmp[] = $skip; + $skip = NULL; + } + }else{ + $skip = $entry; + } + } + if($skip != NULL){ + $tmp[] = $skip; + } + $this->a_queue=$tmp; + return($this->_save_data()); + } + + public function min_entry_priority($id) + { + if(!$this->id_exists($id)){ + $this->set_error(sprintf(_("Can't set priority for ID '%s'. ID does not exist."),$id)); + } + $tmp = array(); + foreach($this->a_queue as $key => $entry){ + if($id != $entry['ID']){ + $tmp[] = $entry; + } + } + $tmp[]= $this->get_entry($id); + $this->a_queue=$tmp; + return($this->_save_data()); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/plugins/addons/gotomasses/class_divListMasses.inc b/plugins/addons/gotomasses/class_divListMasses.inc index ea4794b68..186f5c8b3 100644 --- a/plugins/addons/gotomasses/class_divListMasses.inc +++ b/plugins/addons/gotomasses/class_divListMasses.inc @@ -37,14 +37,16 @@ class divListMasses extends MultiSelectWindow /* set Page header */ $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - - $this->AddHeader(array("string"=>""._("Target")."")); - $this->AddHeader(array("string"=>""._("Schedule")."", + $this->AddHeader(array("string"=>""._("#")."", + "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>""._("Target")." / ". + ""._("Task")."")); + $this->AddHeader(array("string"=>""._("Schedule")."", "attach"=>"style='width:100px;'")); - $this->AddHeader(array("string"=>""._("Type")."", + $this->AddHeader(array("string"=>""._("Type")."", "attach"=>"style='width:80px;'")); $this->AddHeader(array("string"=>_("Action"), - "attach"=>"style='border-right:0px;width:40px;'")); + "attach"=>"style='border-right:0px;width:120px;'")); } function GenHeader() @@ -95,8 +97,14 @@ class divListMasses extends MultiSelectWindow continue; } - $id = $task['ID']; + $id = $task['ID']; + $queue_pos = $task['Queue_Position']; $color= "background-color: #".$task['color']; + + $prio_actions = " "; + $prio_actions.= " "; + $prio_actions.= " "; + $prio_actions.= " "; $action = ""; if($this->parent->acl_is_removeable()){ @@ -106,12 +114,14 @@ class divListMasses extends MultiSelectWindow $field0 = array("string" => "" , "attach" => "style='width:20px;'"); + /* Create each field */ + $field0a = array("string" => $queue_pos ,"attach" => "style='width:20px;'"); $field1 = array("string" => preg_replace(array("/%id%/","/%str%/"),array($id,$this->parent->target_to_string($task)),$edit_link), "attach" => "style='".$color."'"); $field2 = array("string" => $this->parent->time_to_string($task),"attach" => "style='".$color.";width:100px;'"); $field3 = array("string" => $this->parent->action_to_string($task),"attach" => "style='".$color.";width:80px;'"); - $field4 = array("string" => $action,"attach" => "style='".$color.";text-align:right;width:40px;border-right:0px;'"); - $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); + $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'"); + $this->AddElement(array($field0,$field0a,$field1,$field2,$field3,$field4)); } } diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc index ab5f436a2..74e81cb37 100644 --- a/plugins/addons/gotomasses/class_gotomasses.inc +++ b/plugins/addons/gotomasses/class_gotomasses.inc @@ -16,6 +16,9 @@ class gotomasses extends plugin var $ids_to_remove = array(); var $divlist = NULL; + var $sort_by = "QueuePosition"; + var $sort_dir= "up"; + function gotomasses(&$config, $dn= NULL) { /* Include config object */ @@ -33,7 +36,13 @@ class gotomasses extends plugin ************/ $s_entry = $s_action = ""; - $arr = array( "/^edit_task_/"=>"edit","/^remove_task_/"=>"remove", + $arr = array( + "/^prio_top_/" => "prio_top", + "/^prio_increase_/" => "prio_increase", + "/^prio_decrease_/" => "prio_decrease", + "/^prio_bottom_/" => "prio_bottom", + + "/^edit_task_/"=>"edit","/^remove_task_/"=>"remove", "/^new_task_/"=>"new_task","/^remove_multiple_task_/" => "remove_multiple"); foreach($arr as $regex => $action){ foreach($_POST as $name => $value){ @@ -51,6 +60,21 @@ class gotomasses extends plugin $s_entry = $_GET['id']; } + /************ + * REMOVE + ************/ + + if(preg_match("/^prio_/",$s_action)){ + + switch($s_action){ + 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; + default : trigger_error("Undefined priority setting used."); + } + } + /************ * REMOVE ************/ @@ -182,6 +206,7 @@ class gotomasses extends plugin return(FALSE); } + $queue_pos = 1; $tasks = array(); $ret = array(); while($entry = $this->o_queue->fetch()){ @@ -189,11 +214,46 @@ class gotomasses extends plugin if(!isset($tasks[$task])){ $tasks[$task] = dechex(rand(100,240)).dechex(rand(100,240)).dechex(rand(100,240)); } - + $entry['Queue_Position'] = $queue_pos; $entry['color'] = $tasks[$task]; $ret[]= $entry; + $queue_pos ++; + } + + /* Sort entries */ + $simple_map = array("QueuePosition" => "Queue_Position", + "Action" => "Action", + "TaskID" => "TASK_ID"); + $sort_arr = array(); + if(isset($simple_map[$this->sort_by])){ + foreach($ret as $id => $entry){ + $sort_arr[$entry[$simple_map[$this->sort_by]]][] = $id; + } } - return($ret); + if($this->sort_by == "TargetName"){ + foreach($ret as $id => $entry){ + $name = $this->target_to_string($entry); + $sort_arr[$name][] = $id; + } + } + if($this->sort_by == "Schedule"){ + foreach($ret as $id => $entry){ + $name = $entry['Minute'].$entry['Hour'].$entry['Day'].$entry['Month'].$entry['Weekday']; + $sort_arr[$name][] = $id; + } + } + if($this->sort_dir == "up"){ + ksort($sort_arr); + }else{ + krsort($sort_arr); + } + $ret2 = array(); + foreach($sort_arr as $key => $entries){ + foreach($entries as $entry_id){ + $ret2[] = $ret[$entry_id]; + } + } + return($ret2); } @@ -233,6 +293,18 @@ class gotomasses extends plugin function save_object() { $this->divlist->save_object(); + $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID"); + if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){ + $sort = $_GET['sort']; + if($this->sort_by == $sort){ + if($this->sort_dir == "up"){ + $this->sort_dir = "down"; + }else{ + $this->sort_dir = "up"; + } + } + $this->sort_by = $sort; + } }