1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 class gotomasses extends plugin
24 {
25 /* Definitions */
26 var $plHeadline = "System deployment";
27 var $plDescription = "This does something";
29 /* attribute list for save action */
30 var $attributes= array();
31 var $objectclasses= array();
33 /* Queue tasks */
34 var $current = FALSE;
35 var $dialog = FALSE;
36 var $ids_to_remove = array();
37 var $divlist = NULL;
39 var $events = array();
40 var $event_tags = array();
42 var $sort_by = "Schedule";
43 var $sort_dir = "down";
44 var $entries = array();
45 var $range = 25;
46 var $start = 0;
48 function gotomasses(&$config, $dn= NULL)
49 {
50 /* Include config object */
51 $this->config= &$config;
52 $this->o_queue = new gosaSupportDaemon(TRUE,5);
53 $this->events = DaemonEvent::get_event_types( SYSTEM_EVENT);
55 /* Get tags that will be used in queue searches */
56 $this->event_tags = array("none");
57 foreach($this->events['SCHEDULED'] as $evt){
58 $this->event_tags[] = $evt['s_Queued_Action'];
59 }
60 }
63 function execute()
64 {
65 $smarty = get_smarty();
67 /************
68 * Handle posts
69 ************/
71 $s_entry = $s_action = "";
72 $arr = array(
74 "/^pause_/" => "pause",
75 "/^resume_/" => "resume",
76 "/^execute_process_/" => "execute_process",
77 "/^abort_process_/" => "abort_process",
79 "/^prio_up_/" => "prio_up",
80 "/^prio_down_/" => "prio_down",
82 "/^edit_task_/" => "edit",
83 "/^remove_task_/" => "remove",
84 "/^new_task_/" => "new_task");;
87 foreach($arr as $regex => $action){
88 foreach($_POST as $name => $value){
89 if(preg_match($regex,$name)){
90 $s_action = $action;
91 $s_entry = preg_replace($regex,"",$name);
92 $s_entry = preg_replace("/_(x|y)$/","",$s_entry);
93 }
94 }
95 }
97 /* Menu actions */
98 if(isset($_POST['menu_action']) && !empty($_POST['menu_action'])){
99 $s_action = $_POST['menu_action'];
100 }
102 /* Edit posted from list link */
103 if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){
104 $s_action = "edit";
105 $s_entry = $_GET['id'];
106 }
109 /************
110 * Handle Priority modifications
111 ************/
113 if(preg_match("/^prio_/",$s_action)){
114 switch($s_action){
115 case 'prio_down' : $this->update_priority($s_entry,"down");break;
116 case 'prio_up' : $this->update_priority($s_entry,"up");break;
117 }
118 }
120 /************
121 * Handle pause/resume/execute modifications
122 ************/
124 if(preg_match("/^resume/",$s_action) ||
125 preg_match("/^pause/",$s_action) ||
126 preg_match("/^abort_process/",$s_action) ||
127 preg_match("/^execute_process/",$s_action)){
129 switch($s_action){
130 case 'resume' : $this->resume_queue_entries (array($s_entry));break;
131 case 'pause' : $this->pause_queue_entries (array($s_entry));break;
132 case 'execute_process': $this->execute_queue_entries (array($s_entry));break;
133 case 'abort_process' : $this->abort_queue_entries (array($s_entry));break;
134 case 'resume_all' : $this->resume_queue_entries ($this->list_get_selected_items());break;
135 case 'pause_all' : $this->pause_queue_entries ($this->list_get_selected_items());break;
136 case 'execute_process_all': $this->execute_queue_entries ($this->list_get_selected_items());break;
137 case 'abort_process_all' : $this->abort_queue_entries ($this->list_get_selected_items());break;
139 default : trigger_error("Undefined action setting used (".$s_action.").");
140 }
141 if($this->o_queue->is_error()){
142 msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
143 }
144 }
146 /************
147 * ADD
148 ************/
150 if(preg_match("/^add_event_/",$s_action)){
151 $type = preg_replace("/^add_event_/","",$s_action);
152 if(isset($this->events['BY_CLASS'][$type])){
153 $e_data = $this->events['BY_CLASS'][$type];
154 $this->dialog = new $e_data['CLASS_NAME']($this->config);
155 }
156 }
158 /************
159 * EDIT
160 ************/
162 if($s_action == "edit"){
163 $id = $s_entry;
164 $type = FALSE;
165 if(isset($this->entries[$id])){
166 $event = $this->entries[$s_entry];
167 if($event['STATUS'] == "waiting" && isset($this->events['QUEUED'][$event['HEADERTAG']])){
168 $evt_name = $this->events['QUEUED'][$event['HEADERTAG']];
169 $type = $this->events['BY_CLASS'][$evt_name];
170 $this->dialog = new $type['CLASS_NAME']($this->config,$event);
171 }
172 }
173 }
175 /************
176 * REMOVE
177 ************/
179 /* Remove multiple */
180 if($s_action == "remove_multiple" || $s_action == "remove"){
182 if(!$this->acl_is_removeable()){
183 msg_dialog::display(_("Permission"), msgPool::permDelete(), ERROR_DIALOG);
184 }else{
186 if($s_action == "remove"){
187 $ids = array($s_entry);
188 }else{
189 $ids = $this->list_get_selected_items();
190 }
192 $this->ids_to_remove = array();
194 if(count($ids)){
195 $ret = $this->o_queue->ids_exist($ids);
196 $ret = $this->o_queue->get_entries_by_id($ret);
198 $tmp = "";
199 foreach($ret as $task){
201 /* Only remove WAITING or ERROR entries */
202 if(in_array($task['STATUS'],array("waiting","error"))){
203 $this->ids_to_remove[] = $task['ID'];
204 if(isset($this->events['QUEUED'][$task['HEADERTAG']])){
205 $evt_name = $this->events['QUEUED'][$task['HEADERTAG']];
206 $evt = $this->events['BY_CLASS'][$evt_name];
207 $tmp.= "\n".$task['ID']." - ".$evt['s_Menu_Name']." ".$task['MACADDRESS'];
208 }else{
209 $tmp.= "\n".$task['ID']." - ".$task['HEADERTAG']." ".$task['MACADDRESS'];
210 }
211 }
212 }
213 $smarty->assign("multiple", TRUE);
214 $smarty->assign("info",sprintf(_("You are about to remove the following actions from the GOsa support Daemon: %s"),"<pre>".$tmp."</pre>"));
215 $this->current = $s_entry;
216 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
217 }
218 }
219 }
221 /* Remove specified tasks */
222 if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){
223 $this->o_queue->remove_entries($this->ids_to_remove);
224 $this->save();
225 }
227 /* Remove aborted */
228 if(isset($_POST['delete_cancel'])){
229 $this->ids_to_remove = array();;
230 }
233 /************
234 * EDIT
235 ************/
237 /* Close dialog */
238 if(isset($_POST['save_event_dialog'])){
239 if(is_object($this->dialog)){
240 $this->dialog->save_object();
241 if(!$this->o_queue->append($this->dialog)){
242 msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
243 $this->o_queue->get_error()),ERROR_DIALOG);
244 }else{
245 $this->dialog = FALSE;
246 $this->current = -1;
247 }
248 }
249 }
252 /* Close dialog */
253 if(isset($_POST['abort_event_dialog'])){
254 $this->dialog = FALSE;
255 $this->current = -1;
256 }
258 /* Display dialogs if currently opened */
259 if(is_object($this->dialog)){
260 $this->dialog->save_object();
261 return($this->dialog->execute());
262 }
264 /************
265 * Handle Divlist
266 ************/
268 $divlist = new MultiSelectWindow($this->config,"gotoMasses",array("gotomasses"));
269 $divlist->SetInformation(_("This menu allows you to remove and change the properties of GOsa tasks."));
270 $divlist->SetSummary(_("List of queued jobs"));
271 $divlist->EnableCloseButton(FALSE);
272 $divlist->EnableSaveButton(FALSE);
273 $divlist->SetHeadpageMode();
274 $s = ".|"._("Actions")."|\n";
275 $s.= "..|<img src='images/list_new.png' alt='' border='0' class='center'> "._("Create")."\n";
277 foreach($this->events['SCHEDULED'] as $name => $event){
278 $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|add_event_".$name."\n";
279 }
280 if($this->acl_is_removeable()){
281 $s.= "..|---|\n";
282 $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'> "._("Remove")."|remove_multiple\n";
283 }
284 if(preg_match("/w/",$this->getacl(""))){
285 $s.= "..|---|\n";
286 $s.= "..|<img src='images/status_start.png' alt='' border='0' class='center'> "._("Resume")."|resume_all\n";
287 $s.= "..|<img src='images/status_pause.png' alt='' border='0' class='center'> "._("Pause")."|pause_all\n";
288 $s.= "..|<img src='images/small_error.png' alt='' border='0' class='center'> "._("Abort")."|abort_process_all\n";
289 $s.= "..|<img src='images/rocket.png' alt='' border='0' class='center'> "._("Execute")."|execute_process_all\n";
290 }
292 $divlist->SetDropDownHeaderMenu($s);
294 if($this->sort_dir == "up"){
295 $sort_img = "<img src='images/sort_up.png' alt='/\' border=0>";
296 }else{
297 $sort_img = "<img src='images/sort_down.png' alt='\/' border=0>";
298 }
300 if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;}
301 if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;}
302 if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;}
303 if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;}
305 /* Create divlist */
306 $divlist->SetListHeader("<input type='image' src='images/list_reload.png' title='"._("Reload")."'>");
308 $plug = $_GET['plug'];
309 $chk = "<input type='checkbox' id='select_all' name='select_all'
310 onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
312 /* set Page header */
313 $divlist->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
314 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TargetName'>"._("Target").$sort_img_1."</a>"));
315 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TaskID'>"._("Task").$sort_img_2."</a>",
316 "attach"=>"style='width:120px;'"));
317 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Schedule'>"._("Schedule").$sort_img_3."</a>",
318 "attach"=>"style='width:100px;'"));
319 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Action'>"._("Status").$sort_img_4."</a>",
320 "attach"=>"style='width:80px;'"));
321 $divlist->AddHeader(array("string"=>_("Action"),
322 "attach"=>"style='border-right:0px;width:120px;'"));
325 /* Reload the list of entries */
326 $this->reload();
328 foreach($this->entries as $key => $task){
330 $prio_actions="";
331 $action = "";
333 /* If WAITING add priority action
334 */
335 if(in_array($task['STATUS'],array("waiting"))){
336 $prio_actions.= "<input class='center' type='image' src='images/prio_increase.png'
337 title='"._("Move up in execution queue")."' name='prio_up_".$key."'> ";
338 $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png'
339 title='"._("Move down in execution queue")."' name='prio_down_".$key."'> ";
340 }
342 /* If WAITING add pause action
343 */
344 if(in_array($task['STATUS'],array("waiting"))){
345 $prio_actions.= "<input class='center' type='image' src='images/status_pause.png'
346 title='"._("Pause job")."' name='pause_".$key."'> ";
347 }
349 /* If PAUSED add resume action
350 */
351 if(in_array($task['STATUS'],array("paused"))){
352 $prio_actions.= "<input class='center' type='image' src='images/status_start.png'
353 title='"._("Resume job")."' name='resume_".$key."'> ";
354 }
356 /* If PROCESSING add abort action
357 */
358 if(in_array($task['STATUS'],array("processing"))){
359 $prio_actions.= "<input class='center' type='image' src='images/small_error.png'
360 title='"._("Abort execution")."' name='abort_process_".$key."'>";
361 }
363 /* If PAUSED or WAITING add execution action
364 */
365 if(in_array($task['STATUS'],array("paused","waiting"))){
366 $prio_actions.= "<input class='center' type='image' src='images/rocket.png'
367 title='"._("Force execution now!")."' name='execute_process_".$key."'> ";
368 }
370 /* If PAUSED or WAITING add edit action
371 */
372 if(in_array($task['STATUS'],array("waiting"))){
373 $action.= "<input type='image' src='images/edit.png' name='edit_task_".$key."'
374 class='center' alt='"._("Edit")."'>";
375 }
377 /* If WAITING or ERROR add remove action
378 */
379 if( $this->acl_is_removeable() && in_array($task['STATUS'],array("waiting","error"))){
380 $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$key."'
381 class='center' alt='"._("Remove")."'>";
382 }
384 $color = "";
385 $display = $task['MACADDRESS'];
386 $display2= $task['HEADERTAG'];
388 /* Check if this event exists as Daemon class
389 * In this case, display a more accurate entry.
390 */
391 if(isset($this->events['QUEUED'][$task['HEADERTAG']])){
392 $evt_name = $this->events['QUEUED'][$task['HEADERTAG']];
393 $event_type = $this->events['BY_CLASS'][$evt_name];
394 $display2 = $event_type['s_Menu_Name'];
396 if(strlen($display2) > 20){
397 $display2 = substr($display2,0,18)."...";
398 }
400 if(isset($event_type['ListImage']) && !empty($event_type['ListImage'])){
401 $display2 = $event_type['ListImage']." ".$display2;
402 }
403 }
405 $status = $task['STATUS'];
407 if($status == "waiting"){
408 $status = "<img class='center' src='images/clock.png' alt=''> "._("Waiting");
409 }
410 if($status == "error"){
411 $status = "<img class='center' src='images/false.png' alt=''> "._("Error");
412 }
414 /* Special handling for all entries that have
415 STATUS == "processing" && PROGRESS == NUMERIC
416 */
417 if($status == "processing" && isset($task['PROGRESS'])){
418 $percent = $task['PROGRESS'];
419 $status = "<img src='progress.php?x=80&y=13&p=".$percent."' alt='".$percent." %'>";
420 }
423 /* Create each field */
424 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$key."'>" ,
425 "attach" => "style='width:20px;".$color."'");
426 $field1 = array("string" => $display,
427 "attach" => "style='".$color."'");
428 $field1a= array("string" => $display2,
429 "attach" => "style='".$color.";width:120px;'");
430 $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'");
431 $field3 = array("string" => $status,"attach" => "style='".$color.";width:80px;'");
432 $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
433 $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4));
434 }
436 $smarty = get_smarty();
437 $smarty->assign("events",$this->events);
438 $smarty->assign("start",$this->start);
439 $smarty->assign("start_real", ($this->start + 1));
440 $smarty->assign("ranges", array("10" => "10",
441 "20" => "20",
442 "25" => "25",
443 "50" => "50",
444 "100"=> "100",
445 "200"=> "200",
446 "9999" => "*"));
448 $count = $this->o_queue->number_of_queued_entries();
449 $divlist->SetListFooter(range_selector($count, $this->start, $this->range,"range"));
450 $smarty->assign("range",$this->range);
451 $smarty->assign("div",$divlist->Draw());
452 return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
453 }
456 /*! \brief Move an entry up or down in the queue, by updating its execution timestamp
457 @param $id Integer The ID of the entry which should be updated.
458 @param $type String "up" / "down"
459 @return boolean TRUE in case of success else FALSE
460 */
461 public function update_priority($id,$type = "up")
462 {
463 if($type == "up"){
464 $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp DESC");
465 }else{
466 $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp ASC");
467 }
468 $last = array();
469 foreach($tmp as $entry){
470 if($entry['ID'] == $id){
471 if(count($last)){
472 $time = strtotime($last['TIMESTAMP']);
473 if($type == "up"){
474 $time ++;
475 }else{
476 $time --;
477 }
478 $time_str = date("YmdHis",$time);
479 return($this->o_queue->update_entries(array($id),array("timestamp" => $time_str)));
480 }else{
481 return(FALSE);
482 }
483 }
484 $last = $entry;
485 }
486 return(FALSE);
487 }
490 /*! \brief Resumes to status 'waiting'.
491 * @return Boolean TRUE in case of success, else FALSE.
492 */
493 private function resume_queue_entries($ids)
494 {
495 if(!count($ids)){
496 return;
497 }
499 /* Entries are resumed by setting the status to
500 * 'waiting'
501 */
502 $data = array("status" => "waiting");
504 /* Check if given ids are valid and check if the status
505 * allows resuming.
506 */
507 $update_ids = array();
508 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
509 if(isset($entry['STATUS']) && preg_match("/paused/",$entry['STATUS'])){
510 $update_ids[] = $entry['ID'];
511 }
512 }
514 /* Tell the daemon that we have entries to update.
515 */
516 if(count($update_ids)){
517 if(!$this->o_queue->update_entries($update_ids,$data)){
518 msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
519 return(FALSE);
520 }
521 }
522 return(TRUE);
523 }
526 /*! \brief Force queue job to be done as far as possible.
527 * @return Boolean TRUE in case of success, else FALSE.
528 */
529 private function execute_queue_entries($ids)
530 {
531 if(!count($ids)){
532 return;
533 }
535 /* Execution is forced by updating the status to
536 * waiting and setting the timestamp to current time.
537 */
538 $data = array( "timestamp" => date("YmdHis",time()),
539 "status" => "waiting");
541 /* Only allow execution of paused or waiting entries
542 */
543 $update_ids = array();
544 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
545 if(in_array($entry['STATUS'],array("paused","waiting"))){
546 $update_ids[] = $entry['ID'];
547 }
548 }
550 /* Tell the daemon that we want to update some entries
551 */
552 if(count($update_ids)){
553 if(!$this->o_queue->update_entries($update_ids,$data)){
554 msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entries.")) , ERROR_DIALOG);
555 return(FALSE);
556 }
557 }
558 return(TRUE);
559 }
562 /*! \brief Force queue job to be done as far as possible.
563 * @return Boolean TRUE in case of success, else FALSE.
564 */
565 private function abort_queue_entries($ids)
566 {
567 if(!count($ids)){
568 return;
569 }
571 /* Entries are paused by setting the status to
572 * something different from 'waiting'.
573 * We simply use 'paused'.
574 */
575 $data = array("status" => "paused");
577 /* Detect if the ids we got are valid and
578 * check if the status allows pausing.
579 */
580 $update_ids = array();
581 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
582 if(isset($entry['STATUS']) && preg_match("/processing/",$entry['STATUS'])){
583 if(isset($entry['MACADDRESS'])){
584 $update_ids[] = $entry['MACADDRESS'];
585 }else{
586 trigger_error("No mac address found in event.");
587 }
588 }
589 }
591 if(class_available("DaemonEvent_faireboot")){
592 $tmp = new DaemonEvent_faireboot($this->config);
593 $tmp->add_targets($update_ids);
594 $tmp->set_type(TRIGGERED_EVENT);
595 if(!$this->o_queue->append($tmp)){
596 msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
597 return(FALSE);
598 }
599 }else{
600 msg_dialog::display(_("Error"),
601 sprintf(_("The job could not be aborted, the required class '%s' was not found."),
602 "DaemonEvent_faireboot") , ERROR_DIALOG);
603 }
604 }
607 /*! \brief Pauses the specified queue entry from execution.
608 * @return Boolean TRUE in case of success, else FALSE.
609 */
610 private function pause_queue_entries($ids)
611 {
612 if(!count($ids)){
613 return;
614 }
616 /* Entries are paused by setting the status to
617 * something different from 'waiting'.
618 * We simply use 'paused'.
619 */
620 $data = array("status" => "paused");
622 /* Detect if the ids we got are valid and
623 * check if the status allows pausing.
624 */
625 $update_ids = array();
626 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
627 if(isset($entry['STATUS']) && preg_match("/waiting/",$entry['STATUS'])){
628 $update_ids[] = $entry['ID'];
629 }
630 }
632 /* Tell the daemon that we want to update some entries
633 */
634 if(count($update_ids)){
635 if(!$this->o_queue->update_entries($update_ids,$data)){
636 msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
637 return(FALSE);
638 }
639 }
640 return(TRUE);
641 }
644 /*! \brief Request list of queued jobs.
645 * @return Returns an array of all queued jobs.
646 */
647 function reload()
648 {
650 /* Sort map html-post-name => daemon-col-name
651 */
652 $map = array(
653 "QueuePosition" => "id",
654 "Action" => "status",
655 "TaskID" => "headertag",
656 "TargetName" => "macaddress",
657 "Schedule" => "timestamp");
659 /* Create sort header
660 */
661 if(!isset($map[$this->sort_by])){
662 $sort = "id DESC";
663 }else{
664 $sort = $map[$this->sort_by];
665 if($this->sort_dir == "up"){
666 $sort.= " ASC";
667 }else{
668 $sort.= " DESC";
669 }
670 }
672 /* Get entries. */
673 $start = $this->start;
674 $stop = $this->range;
675 $entries = $this->o_queue->get_queued_entries($this->event_tags,$start,$stop,$sort);
676 if ($this->o_queue->is_error()){
677 msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
678 }
680 /* Assign entries by id.
681 */
682 $this->entries = array();
683 foreach($entries as $entry){
684 $this->entries[$entry['ID']]= $entry;
685 }
686 }
689 /*! \brief Handle post jobs, like sorting.
690 */
691 function save_object()
692 {
693 /* Check for sorting changes
694 */
695 $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID");
696 if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){
697 $sort = $_GET['sort'];
698 if($this->sort_by == $sort){
699 if($this->sort_dir == "up"){
700 $this->sort_dir = "down";
701 }else{
702 $this->sort_dir = "up";
703 }
704 }
705 $this->sort_by = $sort;
706 }
708 /* Range selection used? */
709 if(isset($_POST['range']) && is_numeric($_POST['range'])){
710 $this->range = $_POST['range'];
711 }
713 /* Page changed. */
714 if(isset($_GET['start'])){
715 $start = $_GET['start'];
716 if(is_numeric($start) || $start == 0){
717 $this->start = $start;
718 }
719 }
721 /* Check start stop and reset if necessary */
722 $count = $this->o_queue->number_of_queued_entries();
723 if($this->start >= $count){
724 $this->start = $count -1;
725 }
726 if($this->start < 0){
727 $this->start = 0;
728 }
729 }
732 function save()
733 {
734 // We do not save anything here.
735 }
738 /*! \brief Return a list of all selected items.
739 @return Array Returns an array containing all selected item ids.
740 */
741 function list_get_selected_items()
742 {
743 $ids = array();
744 foreach($_POST as $name => $value){
745 if(preg_match("/^item_selected_[0-9]*$/",$name)){
746 $id = preg_replace("/^item_selected_/","",$name);
747 $ids[$id] = $id;
748 }
749 }
750 return($ids);
751 }
754 static function plInfo()
755 {
756 return (array(
757 "plShortName" => _("System mass deployment"),
758 "plDescription" => _("Provide a mechanism to automatically activate a set of systems"),
759 "plSelfModify" => FALSE,
760 "plDepends" => array(),
761 "plPriority" => 0,
762 "plSection" => array("addon"),
763 "plCategory" => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))),
764 "plProvidedAcls" => array("Comment" => _("Description"))
765 ));
766 }
767 }
768 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
769 ?>