From 59d2c443914dc3d2bda67d4873f49c1c0f30781b Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 25 Oct 2007 08:24:40 +0000 Subject: [PATCH] Updated gotomasses, allow priority settings git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7650 594d385d-05f5-0310-b6e9-bd551577e9d8 --- html/images/prio_bottom.png | Bin 0 -> 840 bytes html/images/prio_decrease.png | Bin 0 -> 842 bytes html/images/prio_increase.png | Bin 0 -> 832 bytes html/images/prio_top.png | Bin 0 -> 834 bytes include/class_hostActionQueue.inc | 85 ++++++++++++++++++ .../addons/gotomasses/class_divListMasses.inc | 26 ++++-- .../addons/gotomasses/class_gotomasses.inc | 78 +++++++++++++++- 7 files changed, 178 insertions(+), 11 deletions(-) create mode 100644 html/images/prio_bottom.png create mode 100644 html/images/prio_decrease.png create mode 100644 html/images/prio_increase.png create mode 100644 html/images/prio_top.png diff --git a/html/images/prio_bottom.png b/html/images/prio_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..83920029a17678adedb48fafc18f7bae2b998a66 GIT binary patch literal 840 zcmV-O1GoH%P)(hF2{vTkg$oy4*7#bs2wN$!4=<0OPLt=~uqn?N|@~Jh-uY=fNl2?fgOy zA0PGe?(=@~^PN;h%ntZ{TmPxX_X*`(9@(BKvZ&?3IAN<~wnt!KWt|R`o`B5+Sco7cI(; z0^rcjKr3W5E>6J*UoW-l#YzqBxz{Dg^IpAN`sH`kBKHniYeFtfY2N;7h1Xj1SE0Vt zsV0Awx#L4sRO6G+ekxJ9wF%|*f+TTk!&hi(%=G9pN zkQ%!bM92%Nhc*m`+ZB)WHjN7v#f?RS%Y_(HLZY*b?Ugy3zx79Zb>f**<45KsK<@a^ z6589H%g;_+omLd@G&fvnP2JV4ZJL>PIFr9MX*cHfof^~ S_XfoP0000g>rhZ5qEN&3D*EXKJm_)%)^)-sk`D zyu5-Jkjv%tht8{QC1vwFLaJQ?UkcBD6m!RJB-96wfr4dO%g^}Y`QgFgGp)9kKI|!x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fB(@X00SVO&)47C(K{u*^5vOYi&b^pjh^p?b%+J3|=&0000< KMNUMnLSTX`bcYrI literal 0 HcmV?d00001 diff --git a/html/images/prio_top.png b/html/images/prio_top.png new file mode 100644 index 0000000000000000000000000000000000000000..93e74ffae0ef7154d1fc0133f51dbc0a64133003 GIT binary patch literal 834 zcmV-I1HJr-P)Zf#0wb=Hr7G3xQqSqY8QG_(J|cI<_gI=kX5bF4sl6HlV**vNxtu#UC5HwKkwbc z`##UhbI$V$o=`8kSAw4E+66KJ7+@BdN`JX?`O#Ui66|&-Bc6&JH!3))+PlNypuko> z#fqlBTq&a)XF!al$G24;6WHfoNYvW;Cu6a`gl_Lc8`vBzup#Qx>sXW?C?+#?a{0nd zjCnadp3DMBfCHmn_t)F{FYVc~Cb2#iY|7e}K#7MS(&4i;uGqe1-4H_lxc$B95P;>n zuAPwsV$ENcUOC}`QhOZ+Xf#0+S8*kzWwPw08UU5k2JvOK`Aiu z|DktY>0#)ZHUKhnEpoP0Z;E_&u?#@4%>#^(LRarDF4b0TJNgx5=3Dra?-wa9wJg*c zhMV~Spzl~c{!C^ro4B7GG@a)z7s)OKxV6yD$i`I}W9n9gUdQI>p)l#$D!R5Rkz@}u9Neh9nM*M-fvjFuggHBQ(5g8KsT1rwZ)3`%ijbW^J7;h z-u&l@*XX*g4Mg+az`CN^JYr;Uy+LTBy;;Y<^Gn>iaW9oh)mL)<19>(OwLSs_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; + } } -- 2.30.2