e1556f54b305e2188de14b1afc2d9cb9e6b9d6f3
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,10);
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['BY_CLASS'] as $evt){
58 if(isset($evt['s_Queued_Action'])){
59 $this->event_tags[] = $evt['s_Queued_Action'];
60 }
61 }
62 }
65 function execute()
66 {
67 $smarty = get_smarty();
69 /************
70 * Handle posts
71 ************/
73 $s_entry = $s_action = "";
74 $arr = array(
76 "/^pause_/" => "pause",
77 "/^resume_/" => "resume",
78 "/^execute_process_/" => "execute_process",
79 "/^abort_process_/" => "abort_process",
81 "/^prio_up_/" => "prio_up",
82 "/^prio_down_/" => "prio_down",
84 "/^edit_task_/" => "edit",
85 "/^remove_task_/" => "remove",
86 "/^new_task_/" => "new_task");;
89 foreach($arr as $regex => $action){
90 foreach($_POST as $name => $value){
91 if(preg_match($regex,$name)){
92 $s_action = $action;
93 $s_entry = preg_replace($regex,"",$name);
94 $s_entry = preg_replace("/_(x|y)$/","",$s_entry);
95 }
96 }
97 }
99 /* Menu actions */
100 if(isset($_POST['menu_action']) && !empty($_POST['menu_action'])){
101 $s_action = $_POST['menu_action'];
102 }
104 /* Edit posted from list link */
105 if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){
106 $s_action = "edit";
107 $s_entry = $_GET['id'];
108 }
111 /************
112 * Handle Priority modifications
113 ************/
115 if(preg_match("/^prio_/",$s_action)){
116 switch($s_action){
117 case 'prio_down' : $this->update_priority($s_entry,"down");break;
118 case 'prio_up' : $this->update_priority($s_entry,"up");break;
119 }
120 }
122 /************
123 * Handle pause/resume/execute modifications
124 ************/
126 if(preg_match("/^resume/",$s_action) ||
127 preg_match("/^pause/",$s_action) ||
128 preg_match("/^abort_process/",$s_action) ||
129 preg_match("/^execute_process/",$s_action)){
131 switch($s_action){
132 case 'resume' : $this->resume_queue_entries (array($s_entry));break;
133 case 'pause' : $this->pause_queue_entries (array($s_entry));break;
134 case 'execute_process': $this->execute_queue_entries (array($s_entry));break;
135 case 'abort_process' : $this->abort_queue_entries (array($s_entry));break;
136 case 'resume_all' : $this->resume_queue_entries ($this->list_get_selected_items());break;
137 case 'pause_all' : $this->pause_queue_entries ($this->list_get_selected_items());break;
138 case 'execute_process_all': $this->execute_queue_entries ($this->list_get_selected_items());break;
139 case 'abort_process_all' : $this->abort_queue_entries ($this->list_get_selected_items());break;
141 default : trigger_error("Undefined action setting used (".$s_action.").");
142 }
143 if($this->o_queue->is_error()){
144 msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
145 }
146 }
148 /************
149 * ADD
150 ************/
152 if(preg_match("/^add_event_/",$s_action)){
153 $type = preg_replace("/^add_event_/","",$s_action);
154 if(isset($this->events['BY_CLASS'][$type])){
155 $e_data = $this->events['BY_CLASS'][$type];
156 $this->dialog = new $e_data['CLASS_NAME']($this->config);
157 }
158 }
160 /************
161 * EDIT
162 ************/
164 if($s_action == "edit"){
165 $id = $s_entry;
166 $type = FALSE;
167 if(isset($this->entries[$id])){
168 $event = $this->entries[$s_entry];
171 if($event['STATUS'] == "waiting" && isset($this->events['BY_QUEUED_ACTION'][$event['HEADERTAG']])){
172 $type = $this->events['BY_QUEUED_ACTION'][$event['HEADERTAG']];
173 $this->dialog = new $type['CLASS_NAME']($this->config,$event);
174 }
175 }
176 }
178 /************
179 * REMOVE
180 ************/
182 /* Remove multiple */
183 if($s_action == "remove_multiple" || $s_action == "remove"){
185 if(!$this->acl_is_removeable()){
186 msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
187 }else{
189 if($s_action == "remove"){
190 $ids = array($s_entry);
191 }else{
192 $ids = $this->list_get_selected_items();
193 }
195 if(count($ids)){
196 $ret = $this->o_queue->ids_exist($ids);
197 $ret = $this->o_queue->get_entries_by_id($ret);
199 $tmp = "";
200 foreach($ret as $task){
202 /* Only remove WAITING or ERROR entries */
203 if(in_array($task['STATUS'],array("waiting","error"))){
204 $this->ids_to_remove[] = $task['ID'];
205 if(isset($this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']])){
206 $evt = $this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']];
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";
276 foreach($this->events['BY_CLASS'] as $name => $event){
277 $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|add_event_".$name."\n";
278 }
279 if($this->acl_is_removeable()){
280 $s.= "..|---|\n";
281 $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'> "._("Remove")."|remove_multiple\n";
282 }
283 if(preg_match("/w/",$this->getacl(""))){
284 $s.= "..|---|\n";
285 $s.= "..|<img src='images/status_start.png' alt='' border='0' class='center'> "._("Resume all")."|resume_all\n";
286 $s.= "..|<img src='images/status_pause.png' alt='' border='0' class='center'> "._("Pause all")."|pause_all\n";
287 $s.= "..|<img src='images/small_error.png' alt='' border='0' class='center'> "._("Abort all")."|abort_process_all\n";
288 $s.= "..|<img src='images/rocket.png' alt='' border='0' class='center'> "._("Execute all")."|execute_process_all\n";
289 }
291 $divlist->SetDropDownHeaderMenu($s);
293 if($this->sort_dir == "up"){
294 $sort_img = "<img src='images/sort_up.png' alt='/\' border=0>";
295 }else{
296 $sort_img = "<img src='images/sort_down.png' alt='\/' border=0>";
297 }
299 if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;}
300 if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;}
301 if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;}
302 if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;}
304 /* Create divlist */
305 $divlist->SetListHeader("<input type='image' src='images/list_reload.png' title='"._("Reload")."'>");
307 $plug = $_GET['plug'];
308 $chk = "<input type='checkbox' id='select_all' name='select_all'
309 onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
311 /* set Page header */
312 $divlist->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
313 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TargetName'>"._("Target").$sort_img_1."</a>"));
314 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TaskID'>"._("Task").$sort_img_2."</a>",
315 "attach"=>"style='width:120px;'"));
316 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Schedule'>"._("Schedule").$sort_img_3."</a>",
317 "attach"=>"style='width:100px;'"));
318 $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Action'>"._("Status").$sort_img_4."</a>",
319 "attach"=>"style='width:80px;'"));
320 $divlist->AddHeader(array("string"=>_("Action"),
321 "attach"=>"style='border-right:0px;width:120px;'"));
324 /* Reload the list of entries */
325 $this->reload();
327 foreach($this->entries as $key => $task){
329 $prio_actions="";
330 $action = "";
332 /* If WAITING add priority action
333 */
334 if(in_array($task['STATUS'],array("waiting"))){
335 $prio_actions.= "<input class='center' type='image' src='images/prio_increase.png'
336 title='"._("Move up in execution queue")."' name='prio_up_".$key."'> ";
337 $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png'
338 title='"._("Move down in execution queue")."' name='prio_down_".$key."'> ";
339 }
341 /* If WAITING add pause action
342 */
343 if(in_array($task['STATUS'],array("waiting"))){
344 $prio_actions.= "<input class='center' type='image' src='images/status_pause.png'
345 title='"._("Pause job")."' name='pause_".$key."'> ";
346 }
348 /* If PAUSED add resume action
349 */
350 if(in_array($task['STATUS'],array("paused"))){
351 $prio_actions.= "<input class='center' type='image' src='images/status_start.png'
352 title='"._("Resume job")."' name='resume_".$key."'> ";
353 }
355 /* If PROCESSING add abort action
356 */
357 if(in_array($task['STATUS'],array("processing"))){
358 $prio_actions.= "<input class='center' type='image' src='images/small_error.png'
359 title='"._("Abort execution")."' name='abort_process_".$key."'>";
360 }
362 /* If PAUSED or WAITING add execution action
363 */
364 if(in_array($task['STATUS'],array("paused","waiting"))){
365 $prio_actions.= "<input class='center' type='image' src='images/rocket.png'
366 title='"._("Force execution now!")."' name='execute_process_".$key."'> ";
367 }
369 /* If PAUSED or WAITING add edit action
370 */
371 if(in_array($task['STATUS'],array("waiting"))){
372 $action.= "<input type='image' src='images/edit.png' name='edit_task_".$key."'
373 class='center' alt='"._("Edit")."'>";
374 }
376 /* If WAITING or ERROR add remove action
377 */
378 if( $this->acl_is_removeable() && in_array($task['STATUS'],array("waiting","error"))){
379 $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$key."'
380 class='center' alt='"._("Remove")."'>";
381 }
383 $color = "";
384 $display = $task['MACADDRESS'];
385 $display2= $task['HEADERTAG'];
387 /* Check if this event exists as Daemon class
388 * In this case, display a more accurate entry.
389 */
390 if(isset($this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']]['s_Menu_Name'])){
391 $event_type = $this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']];
392 $display2= $event_type['s_Menu_Name'];
394 if(strlen($display2) > 20){
395 $display2 = substr($display2,0,18)."...";
396 }
398 if(isset($event_type['ListImage']) && !empty($event_type['ListImage'])){
399 $display2 = $event_type['ListImage']." ".$display2;
400 }
401 }
403 $status = $task['STATUS'];
405 if($status == "waiting"){
406 $status = "<img class='center' src='images/clock.png' alt=''> "._("Waiting");
407 }
408 if($status == "error"){
409 $status = "<img class='center' src='images/false.png' alt=''> "._("Error");
410 }
412 /* Special handling for all entries that have
413 STATUS == "processing" && PROGRESS == NUMERIC
414 */
415 if($status == "processing" && isset($task['PROGRESS'])){
416 $percent = $task['PROGRESS'];
417 $status = "<img src='progress.php?x=80&y=13&p=".$percent."' alt='".$percent." %'>";
418 }
421 /* Create each field */
422 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$key."'>" ,
423 "attach" => "style='width:20px;".$color."'");
424 $field1 = array("string" => $display,
425 "attach" => "style='".$color."'");
426 $field1a= array("string" => $display2,
427 "attach" => "style='".$color.";width:120px;'");
428 $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'");
429 $field3 = array("string" => $status,"attach" => "style='".$color.";width:80px;'");
430 $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
431 $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4));
432 }
434 $smarty = get_smarty();
435 $smarty->assign("events",$this->events);
436 $smarty->assign("start",$this->start);
437 $smarty->assign("start_real", ($this->start + 1));
438 $smarty->assign("ranges", array("10" => "10",
439 "20" => "20",
440 "25" => "25",
441 "50" => "50",
442 "100"=> "100",
443 "200"=> "200",
444 "9999" => "*"));
446 $count = $this->o_queue->number_of_queued_entries();
447 $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range"));
448 $smarty->assign("range",$this->range);
449 $smarty->assign("div",$divlist->Draw());
450 return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
451 }
454 /*! \brief Move an entry up or down in the queue, by updating its execution timestamp
455 @param $id Integer The ID of the entry which should be updated.
456 @param $type String "up" / "down"
457 @return boolean TRUE in case of success else FALSE
458 */
459 public function update_priority($id,$type = "up")
460 {
461 if($type == "up"){
462 $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp DESC");
463 }else{
464 $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp ASC");
465 }
466 $last = array();
467 foreach($tmp as $entry){
468 if($entry['ID'] == $id){
469 if(count($last)){
470 $time = strtotime($last['TIMESTAMP']);
471 if($type == "up"){
472 $time ++;
473 }else{
474 $time --;
475 }
476 $time_str = date("YmdHis",$time);
477 return($this->o_queue->update_entries(array($id),array("timestamp" => $time_str)));
478 }else{
479 return(FALSE);
480 }
481 }
482 $last = $entry;
483 }
484 return(FALSE);
485 }
488 /*! \brief Resumes to status 'waiting'.
489 * @return Boolean TRUE in case of success, else FALSE.
490 */
491 private function resume_queue_entries($ids)
492 {
493 if(!count($ids)){
494 return;
495 }
497 /* Entries are resumed by setting the status to
498 * 'waiting'
499 */
500 $data = array("status" => "waiting");
502 /* Check if given ids are valid and check if the status
503 * allows resuming.
504 */
505 $update_ids = array();
506 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
507 if(isset($entry['STATUS']) && preg_match("/paused/",$entry['STATUS'])){
508 $update_ids[] = $entry['ID'];
509 }
510 }
512 /* Tell the daemon that we have entries to update.
513 */
514 if(count($update_ids)){
515 if(!$this->o_queue->update_entries($update_ids,$data)){
516 msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
517 return(FALSE);
518 }
519 }
520 return(TRUE);
521 }
524 /*! \brief Force queue job to be done as far as possible.
525 * @return Boolean TRUE in case of success, else FALSE.
526 */
527 private function execute_queue_entries($ids)
528 {
529 if(!count($ids)){
530 return;
531 }
533 /* Execution is forced by updating the status to
534 * waiting and setting the timestamp to current time.
535 */
536 $data = array( "timestamp" => date("YmdHis",time()),
537 "status" => "waiting");
539 /* Only allow execution of paused or waiting entries
540 */
541 $update_ids = array();
542 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
543 if(in_array($entry['STATUS'],array("paused","waiting"))){
544 $update_ids[] = $entry['ID'];
545 }
546 }
548 /* Tell the daemon that we want to update some entries
549 */
550 if(count($update_ids)){
551 if(!$this->o_queue->update_entries($update_ids,$data)){
552 msg_dialog::display(_("Error"), sprintf(_("Could not update queue entries.")) , ERROR_DIALOG);
553 return(FALSE);
554 }
555 }
556 return(TRUE);
557 }
560 /*! \brief Force queue job to be done as far as possible.
561 * @return Boolean TRUE in case of success, else FALSE.
562 */
563 private function abort_queue_entries($ids)
564 {
565 if(!count($ids)){
566 return;
567 }
569 /* Entries are paused by setting the status to
570 * something different from 'waiting'.
571 * We simply use 'paused'.
572 */
573 $data = array("status" => "paused");
575 /* Detect if the ids we got are valid and
576 * check if the status allows pausing.
577 */
578 $update_ids = array();
579 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
580 if(isset($entry['STATUS']) && preg_match("/processing/",$entry['STATUS'])){
581 if(isset($entry['MACADDRESS'])){
582 $update_ids[] = $entry['MACADDRESS'];
583 }else{
584 trigger_error("No mac address found in event.");
585 }
586 }
587 }
589 if(class_available("DaemonEvent_faireboot")){
590 $tmp = new DaemonEvent_faireboot($this->config);
591 $tmp->add_targets($update_ids);
592 if(!$this->o_queue->append($tmp)){
593 msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
594 return(FALSE);
595 }
596 }else{
597 msg_dialog::display(_("Error"),
598 sprintf(_("The Job could not be aborted, the '%s' event class was not found."),
599 "DaemonEvent_faireboot") , ERROR_DIALOG);
600 }
601 }
604 /*! \brief Pauses the specified queue entry from execution.
605 * @return Boolean TRUE in case of success, else FALSE.
606 */
607 private function pause_queue_entries($ids)
608 {
609 if(!count($ids)){
610 return;
611 }
613 /* Entries are paused by setting the status to
614 * something different from 'waiting'.
615 * We simply use 'paused'.
616 */
617 $data = array("status" => "paused");
619 /* Detect if the ids we got are valid and
620 * check if the status allows pausing.
621 */
622 $update_ids = array();
623 foreach($this->o_queue->get_entries_by_id($ids) as $entry){
624 if(isset($entry['STATUS']) && preg_match("/waiting/",$entry['STATUS'])){
625 $update_ids[] = $entry['ID'];
626 }
627 }
629 /* Tell the daemon that we want to update some entries
630 */
631 if(count($update_ids)){
632 if(!$this->o_queue->update_entries($update_ids,$data)){
633 msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
634 return(FALSE);
635 }
636 }
637 return(TRUE);
638 }
641 /*! \brief Request list of queued jobs.
642 * @return Returns an array of all queued jobs.
643 */
644 function reload()
645 {
647 /* Sort map html-post-name => daemon-col-name
648 */
649 $map = array(
650 "QueuePosition" => "id",
651 "Action" => "status",
652 "TaskID" => "headertag",
653 "TargetName" => "macaddress",
654 "Schedule" => "timestamp");
656 /* Create sort header
657 */
658 if(!isset($map[$this->sort_by])){
659 $sort = "id DESC";
660 }else{
661 $sort = $map[$this->sort_by];
662 if($this->sort_dir == "up"){
663 $sort.= " ASC";
664 }else{
665 $sort.= " DESC";
666 }
667 }
669 /* Get entries. */
670 $start = $this->start;
671 $stop = $this->range;
672 $entries = $this->o_queue->get_queued_entries($this->event_tags,$start,$stop,$sort);
673 if ($this->o_queue->is_error()){
674 msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
675 }
677 /* Assign entries by id.
678 */
679 $this->entries = array();
680 foreach($entries as $entry){
681 $this->entries[$entry['ID']]= $entry;
682 }
683 }
686 /*! \brief Handle post jobs, like sorting.
687 */
688 function save_object()
689 {
690 /* Check for sorting changes
691 */
692 $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID");
693 if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){
694 $sort = $_GET['sort'];
695 if($this->sort_by == $sort){
696 if($this->sort_dir == "up"){
697 $this->sort_dir = "down";
698 }else{
699 $this->sort_dir = "up";
700 }
701 }
702 $this->sort_by = $sort;
703 }
705 /* Range selection used? */
706 if(isset($_POST['range']) && is_numeric($_POST['range'])){
707 $this->range = $_POST['range'];
708 }
710 /* Page changed. */
711 if(isset($_GET['start'])){
712 $start = $_GET['start'];
713 if(is_numeric($start) || $start == 0){
714 $this->start = $start;
715 }
716 }
718 /* Check start stop and reset if necessary */
719 $count = $this->o_queue->number_of_queued_entries();
720 if($this->start >= $count){
721 $this->start = $count -1;
722 }
723 if($this->start < 0){
724 $this->start = 0;
725 }
726 }
729 function save()
730 {
731 // We do not save anything here.
732 }
735 /*! \brief Return a list of all selected items.
736 @return Array Returns an array containing all selected item ids.
737 */
738 function list_get_selected_items()
739 {
740 $ids = array();
741 foreach($_POST as $name => $value){
742 if(preg_match("/^item_selected_[0-9]*$/",$name)){
743 $id = preg_replace("/^item_selected_/","",$name);
744 $ids[$id] = $id;
745 }
746 }
747 return($ids);
748 }
751 static function plInfo()
752 {
753 return (array(
754 "plShortName" => _("System mass deployment"),
755 "plDescription" => _("Provide a mechanism to automatically activate a set of systems"),
756 "plSelfModify" => FALSE,
757 "plDepends" => array(),
758 "plPriority" => 0,
759 "plSection" => array("addon"),
760 "plCategory" => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))),
761 "plProvidedAcls" => array("Comment" => _("Description"))
762 ));
763 }
764 }
765 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
766 ?>