Code

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