Code

Updated gotomasses
[gosa.git] / gosa-plugins / goto / addons / gotomasses / class_gotomasses.inc
1 <?php
3 class gotomasses extends plugin
4 {
5   /* Definitions */
6   var $plHeadline     = "System deployment";
7   var $plDescription  = "This does something";
9   /* attribute list for save action */
10   var $attributes= array();
11   var $objectclasses= array();
13   /* Queue tasks */
14   var $current        = FALSE;
15   var $dialog         = FALSE;
16   var $ids_to_remove  = array();
17   var $divlist        = NULL;
19   var $events         = array();
20   var $event_tags     = array();
22   var $sort_by  = "Schedule";
23   var $sort_dir = "down";
24   var $entries  = array();
25   var $range    = 25;
26   var $start    = 0;
28   function gotomasses(&$config, $dn= NULL)
29   {
30     /* Include config object */
31     $this->config= &$config;
32     $this->o_queue = new gosaSupportDaemon(TRUE,10);
33     $this->events  = DaemonEvent::get_event_types( USER_EVENT | SYSTEM_EVENT);
35     /* Get tags that will be used in queue searches */
36     foreach($this->events['BY_CLASS'] as $evt){
37       if(isset($evt['s_Queued_Action'])){
38         $this->event_tags[] = $evt['s_Queued_Action'];
39       }
40     }
41   }
44   function execute()
45   {
46     $smarty = get_smarty();
47  
48     /************
49      * Handle posts 
50      ************/
51     
52     $s_entry = $s_action = "";
53     $arr = array( 
55         "/^pause_/"           => "pause",
56         "/^resume_/"          => "resume",
57         "/^execute_process_/" => "execute_process",
58         "/^abort_process_/"   => "abort_process",
60         "/^prio_up_/"     => "prio_up",
61         "/^prio_down_/"   => "prio_down",
63         "/^edit_task_/"             =>  "edit",
64         "/^remove_task_/"           =>  "remove",
65         "/^new_task_/"              =>  "new_task");;
68     foreach($arr as $regex => $action){
69       foreach($_POST as $name => $value){
70         if(preg_match($regex,$name)){
71           $s_action = $action;
72           $s_entry  = preg_replace($regex,"",$name);
73           $s_entry  = preg_replace("/_(x|y)$/","",$s_entry);
74         }
75       }
76     }
78     /* Menu actions */
79     if(isset($_POST['menu_action']) && !empty($_POST['menu_action'])){
80       $s_action = $_POST['menu_action'];
81     }
82     
83     /* Edit posted from list link */
84     if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){
85       $s_action = "edit";
86       $s_entry = $_GET['id'];
87     }
90     /************
91      * Handle Priority modifications  
92      ************/
94     if(preg_match("/^prio_/",$s_action)){
95       switch($s_action){
96         case 'prio_down'  : $this->update_priority($s_entry,"down");break;
97         case 'prio_up'    : $this->update_priority($s_entry,"up");break;
98       }
99     }
101     /************
102      * Handle pause/resume/execute modifications  
103      ************/
105     if(preg_match("/^resume/",$s_action) || 
106        preg_match("/^pause/",$s_action) || 
107        preg_match("/^abort_process/",$s_action) || 
108        preg_match("/^execute_process/",$s_action)){
110       switch($s_action){
111         case 'resume'         : $this->resume_queue_entries   (array($s_entry));break; 
112         case 'pause'          : $this->pause_queue_entries    (array($s_entry));break; 
113         case 'execute_process': $this->execute_queue_entries  (array($s_entry));break; 
114         case 'abort_process'  : $this->abort_queue_entries    (array($s_entry));break; 
115         case 'resume_all'         : $this->resume_queue_entries   ($this->list_get_selected_items());break; 
116         case 'pause_all'          : $this->pause_queue_entries    ($this->list_get_selected_items());break; 
117         case 'execute_process_all': $this->execute_queue_entries  ($this->list_get_selected_items());break; 
118         case 'abort_process_all'  : $this->abort_queue_entries    ($this->list_get_selected_items());break; 
120         default : trigger_error("Undefined action setting used (".$s_action.").");
121       }
122       if($this->o_queue->is_error()){
123         msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
124       }
125     }
127     /************
128      * ADD 
129      ************/
130   
131     if(preg_match("/^add_event_/",$s_action)){
132       $type = preg_replace("/^add_event_/","",$s_action);
133       if(isset($this->events['BY_CLASS'][$type])){
134         $e_data = $this->events['BY_CLASS'][$type];
135         $this->dialog = new $e_data['CLASS_NAME']($this->config);
136       }
137     }
139     /************
140      * EDIT
141      ************/
143     if($s_action == "edit"){  
144       $id =  $s_entry;
145       $type = FALSE;
146       if(isset($this->entries[$id])){
147         $event = $this->entries[$s_entry];
148       
149         
150         if($event['STATUS'] == "waiting" && isset($this->events['BY_QUEUED_ACTION'][$event['HEADERTAG']])){
151           $type = $this->events['BY_QUEUED_ACTION'][$event['HEADERTAG']];
152           $this->dialog = new $type['CLASS_NAME']($this->config,$event);
153         }
154       }
155     }
157     /************
158      * REMOVE 
159      ************/
161     /* Remove multiple */
162     if($s_action == "remove_multiple" || $s_action == "remove"){
164       if(!$this->acl_is_removeable()){
165         msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
166       }else{
168         if($s_action == "remove"){
169           $ids = array($s_entry);
170         }else{
171           $ids = $this->list_get_selected_items();
172         }
174         if(count($ids)){
175           $ret = $this->o_queue->ids_exist($ids);
176           $ret = $this->o_queue->get_entries_by_id($ret);
178           $tmp = "";
179           foreach($ret as $task){
181             /* Only remove WAITING or ERROR entries */
182             if(in_array($task['STATUS'],array("waiting","error"))){
183               $this->ids_to_remove[] = $task['ID'];
184               if(isset($this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']])){
185                 $evt = $this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']];
186                 $tmp.= "\n".$task['ID']." - ".$evt['s_Menu_Name']."&nbsp;".$task['MACADDRESS'];
187               }else{
188                 $tmp.= "\n".$task['ID']." - ".$task['HEADERTAG']."&nbsp;".$task['MACADDRESS'];
189               }
190             }
191           }
192           $smarty->assign("multiple", TRUE); 
193           $smarty->assign("info",sprintf(_("You are about to remove the following actions from the GOsa support Daemon: %s"),"<pre>".$tmp."</pre>"));
194           $this->current = $s_entry;
195           return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
196         }
197       }
198     }
200     /* Remove specified tasks */
201     if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){
202       $this->o_queue->remove_entries($this->ids_to_remove);
203       $this->save();
204     }
206     /* Remove aborted */
207     if(isset($_POST['delete_cancel'])){
208       $this->ids_to_remove = array();;
209     }
212     /************
213      * EDIT 
214      ************/
216     /* Close dialog */
217     if(isset($_POST['save_event_dialog'])){
218       if(is_object($this->dialog)){
219         $this->dialog->save_object();
220         if(!$this->o_queue->append($this->dialog)){
221           msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
222                 $this->o_queue->get_error()),ERROR_DIALOG);
223         }else{
224           $this->dialog = FALSE; 
225           $this->current = -1;
226         } 
227       }
228     }
231     /* Close dialog */
232     if(isset($_POST['abort_event_dialog'])){
233       $this->dialog = FALSE;
234       $this->current = -1;
235     }
237     /* Display dialogs if currently opened */
238     if(is_object($this->dialog)){
239       $this->dialog->save_object();
240       return($this->dialog->execute());
241     }
243     /************
244      * Handle Divlist 
245      ************/
247     $divlist = new MultiSelectWindow($this->config,"gotoMasses",array("gotomasses"));
248     $divlist->SetInformation(_("This menu allows you to remove and change the properties of GOsa tasks."));
249     $divlist->SetSummary(_("List of queued jobs"));
250     $divlist->EnableCloseButton(FALSE);
251     $divlist->EnableSaveButton(FALSE);
252     $divlist->SetHeadpageMode();
253     $s = ".|"._("Actions")."|\n";
254     $s.= "..|<img src='images/list_new.png' alt='' border='0' class='center'>&nbsp;"._("Create")."\n";
255     foreach($this->events['BY_CLASS'] as $name =>  $event){
256       $s.= "...|".$event['MenuImage']."&nbsp;".$event['s_Menu_Name']."|add_event_".$name."\n";
257     }
258     if($this->acl_is_removeable()){
259       $s.= "..|---|\n";
260       $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'>&nbsp;"._("Remove")."|remove_multiple\n";
261     }
262     if(preg_match("/w/",$this->getacl(""))){
263       $s.= "..|---|\n";
264       $s.= "..|<img src='images/status_start.png' alt='' border='0' class='center'>&nbsp;"._("Resume all")."|resume_all\n";
265       $s.= "..|<img src='images/status_pause.png' alt='' border='0' class='center'>&nbsp;"._("Pause all")."|pause_all\n";
266       $s.= "..|<img src='images/small_error.png'  alt='' border='0' class='center'>&nbsp;"._("Abort all")."|abort_process_all\n";
267       $s.= "..|<img src='images/rocket.png'       alt='' border='0' class='center'>&nbsp;"._("Execute all")."|execute_process_all\n";
268     }
270     $divlist->SetDropDownHeaderMenu($s);
272     if($this->sort_dir == "up"){
273       $sort_img = "<img src='images/sort_up.png' alt='/\' border=0>";
274     }else{
275       $sort_img = "<img src='images/sort_down.png' alt='\/' border=0>";
276     }
278     if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;}
279     if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;}
280     if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;}
281     if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;}
283     /* Create divlist */
284     $divlist->SetListHeader("<input type='image' src='images/list_reload.png' title='"._("Reload")."'>");
286     $plug  = $_GET['plug'];
287     $chk = "<input type='checkbox' id='select_all' name='select_all'
288                onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
290     /* set Page header */
291     $divlist->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
292     $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=TargetName'>"._("Target").$sort_img_1."</a>"));
293     $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=TaskID'>"._("Task").$sort_img_2."</a>",
294                                       "attach"=>"style='width:120px;'"));
295     $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Schedule'>"._("Schedule").$sort_img_3."</a>",
296                                       "attach"=>"style='width:100px;'"));
297     $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Action'>"._("Status").$sort_img_4."</a>",
298                                       "attach"=>"style='width:80px;'"));
299     $divlist->AddHeader(array("string"=>_("Action"),
300                                       "attach"=>"style='border-right:0px;width:120px;'"));
303     /* Reload the list of entries */
304     $this->reload();
306     foreach($this->entries as $key => $task){
308       $prio_actions="";
309       $action = "";
311       /* If WAITING add priority action
312        */  
313       if(in_array($task['STATUS'],array("waiting"))){
314         $prio_actions.= "<input class='center' type='image' src='images/prio_increase.png' 
315           title='"._("Move up in execution queue")."' name='prio_up_".$key."'>&nbsp;";
316         $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png' 
317           title='"._("Move down in execution queue")."' name='prio_down_".$key."'>&nbsp;";
318       }
319     
320       /* If WAITING add pause action
321        */  
322       if(in_array($task['STATUS'],array("waiting"))){
323         $prio_actions.= "<input class='center' type='image' src='images/status_pause.png' 
324           title='"._("Pause job")."' name='pause_".$key."'>&nbsp;";
325       }
327       /* If PAUSED add resume action
328        */  
329       if(in_array($task['STATUS'],array("paused"))){
330         $prio_actions.= "<input class='center' type='image' src='images/status_start.png' 
331           title='"._("Resume job")."' name='resume_".$key."'>&nbsp;";
332       }
334       /* If PROCESSING add abort action
335        */  
336       if(in_array($task['STATUS'],array("processing"))){
337         $prio_actions.= "<input class='center' type='image' src='images/small_error.png' 
338           title='"._("Abort execution")."' name='abort_process_".$key."'>";
339       }
341       /* If PAUSED or WAITING add execution action
342        */  
343       if(in_array($task['STATUS'],array("paused","waiting"))){
344         $prio_actions.= "<input class='center' type='image' src='images/rocket.png' 
345           title='"._("Force execution now!")."' name='execute_process_".$key."'>&nbsp;";
346       }
348       /* If PAUSED or WAITING add edit action
349        */  
350       if(in_array($task['STATUS'],array("waiting"))){
351         $action.= "<input type='image' src='images/edit.png' name='edit_task_".$key."' 
352           class='center' alt='"._("Edit")."'>";
353       }
355       /* If WAITING or ERROR add remove action
356        */  
357       if( $this->acl_is_removeable() && in_array($task['STATUS'],array("waiting","error"))){
358         $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$key."' 
359           class='center' alt='"._("Remove")."'>";
360       }
362       $color = "";
363       $display = $task['MACADDRESS'];
364       $display2= $task['HEADERTAG'];
365      
366       /* Check if this event exists as Daemon class 
367        * In this case, display a more accurate entry.
368        */ 
369       if(isset($this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']]['s_Menu_Name'])){
370         $event_type = $this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']];
371         $display2= $event_type['s_Menu_Name'];
373         if(strlen($display2) > 20){
374           $display2 = substr($display2,0,18)."...";
375         }
377         if(isset($event_type['ListImage']) && !empty($event_type['ListImage'])){
378           $display2 = $event_type['ListImage']."&nbsp;".$display2;
379         }
380       } 
382       $status = $task['STATUS'];
383   
384       if($status == "waiting"){
385         $status = "<img class='center' src='images/clock.png' alt=''>&nbsp;"._("Waiting");
386       }
387       if($status == "error"){
388         $status = "<img class='center' src='images/false.png' alt=''>&nbsp;"._("Error");
389       }
391       /* Special handling for all entries that have 
392           STATUS == "processing" && PROGRESS == NUMERIC
393        */
394       if($status == "processing" && isset($task['PROGRESS'])){
395         $percent = $task['PROGRESS'];
396         $status = "<img src='progress.php?x=80&amp;y=13&amp;p=".$percent."' alt='".$percent."&nbsp;%'>";
397       }
400       /* Create each field */
401       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$key."'>" ,
402                       "attach" => "style='width:20px;".$color."'");
403       $field1 = array("string" => $display,
404                       "attach" => "style='".$color."'");
405       $field1a= array("string" => $display2,
406                       "attach" => "style='".$color.";width:120px;'");
407       $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'");
408       $field3 = array("string" => $status,"attach" => "style='".$color.";width:80px;'");
409       $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
410       $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4));
411     }
413     $smarty = get_smarty();
414     $smarty->assign("events",$this->events);
415     $smarty->assign("start",$this->start);
416     $smarty->assign("start_real", ($this->start + 1));
417     $smarty->assign("ranges", array("10" => "10",
418                                     "20" => "20",
419                                     "25" => "25",
420                                     "50" => "50",
421                                     "100"=> "100",
422                                     "200"=> "200",
423                                     "9999" => "*"));
425     $count = $this->o_queue->number_of_queued_entries();
426     $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range"));
427     $smarty->assign("range",$this->range);
428     $smarty->assign("div",$divlist->Draw());
429     return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
430   }
433   /*! \brief  Move an entry up or down in the queue, by updating its execution timestamp  
434       @param  $id     Integer  The ID of the entry which should be updated.
435       @param  $type   String   "up" / "down"
436       @return boolean TRUE in case of success else FALSE
437   */
438   public function update_priority($id,$type = "up")
439   {
440     if($type == "up"){
441       $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp DESC");
442     }else{
443       $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp ASC");
444     }
445     $last = array();
446     foreach($tmp as $entry){
447       if($entry['ID'] == $id){
448         if(count($last)){
449           $time = strtotime($last['TIMESTAMP']);
450           if($type == "up"){
451             $time ++;
452           }else{
453             $time --;
454           }
455           $time_str = date("YmdHis",$time); 
456           return($this->o_queue->update_entries(array($id),array("timestamp" => $time_str)));
457         }else{
458           return(FALSE);
459         }
460       }
461       $last = $entry;
462     }
463     return(FALSE);
464   }
467   /*! \brief  Resumes to status 'waiting'.
468    *  @return Boolean TRUE in case of success, else FALSE. 
469    */
470   private function resume_queue_entries($ids)
471   {
472     if(!count($ids)){
473       return;
474     }
476     /* Entries are resumed by setting the status to 
477      *  'waiting'
478      */
479     $data = array("status"    => "waiting");
480   
481     /* Check if given ids are valid and check if the status
482      *  allows resuming.
483      */
484     $update_ids = array();
485     foreach($this->o_queue->get_entries_by_id($ids) as $entry){
486       if(isset($entry['STATUS']) && preg_match("/paused/",$entry['STATUS'])){
487         $update_ids[] = $entry['ID'];
488       }
489     }
491     /* Tell the daemon that we have entries to update.
492      */
493     if(count($update_ids)){
494       if(!$this->o_queue->update_entries($update_ids,$data)){
495         msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
496         return(FALSE);
497       }
498     }
499     return(TRUE);
500   }
503   /*! \brief  Force queue job to be done as far as possible.
504    *  @return Boolean TRUE in case of success, else FALSE.
505    */
506   private function execute_queue_entries($ids)
507   {
508     if(!count($ids)){
509       return;
510     }
512     /* Execution is forced by updating the status to 
513      *  waiting and setting the timestamp to current time.
514      */
515     $data = array(  "timestamp" => date("YmdHis",time()), 
516                     "status"    => "waiting");
518     /* Only allow execution of paused or waiting entries 
519      */
520     $update_ids = array();
521     foreach($this->o_queue->get_entries_by_id($ids) as $entry){
522       if(in_array($entry['STATUS'],array("paused","waiting"))){
523         $update_ids[] = $entry['ID'];
524       }
525     }
527     /* Tell the daemon that we want to update some entries
528      */
529     if(count($update_ids)){
530       if(!$this->o_queue->update_entries($update_ids,$data)){
531         msg_dialog::display(_("Error"), sprintf(_("Could not update queue entries.")) , ERROR_DIALOG);
532         return(FALSE);
533       }
534     }
535     return(TRUE);
536   }
539   /*! \brief  Force queue job to be done as far as possible.
540    *  @return Boolean TRUE in case of success, else FALSE.
541    */
542   private function abort_queue_entries($ids)
543   {
544     if(!count($ids)){
545       return;
546     }
548     /* Entries are paused by setting the status to
549      *  something different from 'waiting'.
550      * We simply use 'paused'.
551      */
552     $data = array("status"    => "paused");
554     /* Detect if the ids we got are valid and
555      *  check if the status allows pausing.
556      */
557     $update_ids = array();
558     foreach($this->o_queue->get_entries_by_id($ids) as $entry){
559       if(isset($entry['STATUS']) && preg_match("/processing/",$entry['STATUS'])){
560         if(isset($entry['MACADDRESS'])){
561           $update_ids[] = $entry['MACADDRESS'];
562         }else{
563           trigger_error("No mac address found in event.");
564         }
565       }
566     }
568     if(class_available("DaemonEvent_faireboot")){
569       $tmp = new DaemonEvent_faireboot($this->config);
570       $tmp->add_targets($update_ids);
571       if(!$this->o_queue->append($tmp)){
572         msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
573         return(FALSE);
574       }
575     }else{
576       msg_dialog::display(_("Error"),
577           sprintf(_("The Job could not be aborted, the '%s' event class was not found."),
578             "DaemonEvent_faireboot") , ERROR_DIALOG);
579     }
580   }
583   /*! \brief Pauses the specified queue entry from execution.
584    *  @return Boolean TRUE in case of success, else FALSE. 
585    */
586   private function pause_queue_entries($ids)
587   {
588     if(!count($ids)){
589       return;
590     }
592     /* Entries are paused by setting the status to 
593      *  something different from 'waiting'.
594      * We simply use 'paused'.
595      */   
596     $data = array("status"    => "paused");
598     /* Detect if the ids we got are valid and
599      *  check if the status allows pausing.
600      */ 
601     $update_ids = array();
602     foreach($this->o_queue->get_entries_by_id($ids) as $entry){
603       if(isset($entry['STATUS']) && preg_match("/waiting/",$entry['STATUS'])){
604         $update_ids[] = $entry['ID'];
605       }
606     }
608     /* Tell the daemon that we want to update some entries
609      */
610     if(count($update_ids)){
611       if(!$this->o_queue->update_entries($update_ids,$data)){
612         msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
613         return(FALSE);
614       }
615     }
616     return(TRUE);
617   }
620   /*! \brief  Request list of queued jobs.
621    *  @return Returns an array of all queued jobs.
622    */
623   function reload()
624   {
626     /* Sort map   html-post-name => daemon-col-name
627      */
628     $map = array(
629         "QueuePosition" => "id",
630         "Action"        => "status",
631         "TaskID"        => "headertag",
632         "TargetName"    => "macaddress",
633         "Schedule"      => "timestamp");
635     /* Create sort header 
636      */
637     if(!isset($map[$this->sort_by])){
638       $sort = "id DESC";
639     }else{
640       $sort   = $map[$this->sort_by]; 
641       if($this->sort_dir == "up"){
642         $sort.= " ASC";
643       }else{
644         $sort.= " DESC";
645       }
646     }
647      
648     /* Get entries. */ 
649     $start  = $this->start; 
650     $stop   = $this->range;
651     $entries = $this->o_queue->get_queued_entries($this->event_tags,$start,$stop,$sort);
652     if ($this->o_queue->is_error()){
653       msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
654     }
656     /* Assign entries by id.
657      */
658     $this->entries = array();
659     foreach($entries as $entry){
660       $this->entries[$entry['ID']]= $entry;
661     }
662   }
665   /*! \brief  Handle post jobs, like sorting.
666    */
667   function save_object()
668   {
669     /* Check for sorting changes 
670      */
671     $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID");
672     if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){
673       $sort = $_GET['sort'];
674       if($this->sort_by == $sort){
675         if($this->sort_dir == "up"){
676           $this->sort_dir = "down";
677         }else{
678           $this->sort_dir = "up";
679         }
680       }
681       $this->sort_by = $sort;
682     }
684     /* Range selection used? */
685     if(isset($_POST['range']) && is_numeric($_POST['range'])){
686       $this->range = $_POST['range'];
687     }
688     
689     /* Page changed. */
690     if(isset($_GET['start'])){
691       $start = $_GET['start'];
692       if(is_numeric($start) || $start == 0){
693         $this->start = $start;
694       }
695     }
697     /* Check start stop and reset if necessary */
698     $count = $this->o_queue->number_of_queued_entries();
699     if($this->start >= $count){
700       $this->start = $count -1;
701     }
702     if($this->start < 0){
703       $this->start = 0;
704     }
705   }
708   function save()
709   {
710     // We do not save anything here.
711   }
714   /*! \brief  Return a list of all selected items.
715     @return Array   Returns an array containing all selected item ids.
716    */
717   function list_get_selected_items()
718   {
719     $ids = array();
720     foreach($_POST as $name => $value){
721       if(preg_match("/^item_selected_[0-9]*$/",$name)){
722         $id   = preg_replace("/^item_selected_/","",$name);
723         $ids[$id] = $id;
724       }
725     }
726     return($ids);
727   }
730   static function plInfo()
731   {
732     return (array(
733           "plShortName"   => _("System mass deployment"),
734           "plDescription" => _("Provide a mechanism to automatically activate a set of systems"),
735           "plSelfModify"  => FALSE,
736           "plDepends"     => array(),
737           "plPriority"    => 0,
738           "plSection"     => array("addon"),
739           "plCategory"    => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))),
740           "plProvidedAcls" => array("Comment"   => _("Description")) 
741           ));
742   }
744 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
745 ?>