]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/OpportunisticQM/OpportunisticQMPlugin.php
XSS vulnerability when remote-subscribing
[quix0rs-gnu-social.git] / plugins / OpportunisticQM / OpportunisticQMPlugin.php
1 <?php
2
3 class OpportunisticQMPlugin extends Plugin {
4     public $qmkey = false;
5     public $secs_per_action = 1; // total seconds to run script per action
6     public $rel_to_pageload = true;  // relative to pageload or queue start
7
8     public function onRouterInitialized($m)
9     {
10         $m->connect('main/runqueue', array('action' => 'runqueue'));
11     }
12
13     /**
14      * When the page has finished rendering, let's do some cron jobs
15      * if we have the time.
16      */
17     public function onEndActionExecute(Action $action)
18     {
19         if ($action instanceof RunqueueAction) {
20             return true;
21         }
22
23         global $_startTime;
24
25         $args = array(
26                     'qmkey' => common_config('opportunisticqm', 'qmkey'),
27                     'max_execution_time' => $this->secs_per_action,
28                     'started_at'      => $this->rel_to_pageload ? $_startTime : null,
29                 );
30         $qm = new OpportunisticQueueManager($args); 
31         $qm->runQueue();
32         return true;
33     }
34
35     public function onPluginVersion(array &$versions)
36     {
37         $versions[] = array('name' => 'OpportunisticQM',
38                             'version' => GNUSOCIAL_VERSION,
39                             'author' => 'Mikael Nordfeldth',
40                             'homepage' => 'http://www.gnu.org/software/social/',
41                             'description' =>
42                             // TRANS: Plugin description.
43                             _m('Opportunistic queue manager plugin for background processing.'));
44         return true;
45     }
46 }