Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | ||
13 | require_once 'CRM/Core/Page.php'; | |
14 | ||
15 | /** | |
16 | * The queue-runner page provides an interactive, web-based system | |
17 | * running the tasks in a queue and monitoring its progression. | |
18 | * | |
19 | * Do not link or redirect to this page directly -- go through | |
20 | * CRM_Queue_Runner::runAllViaWeb(). | |
21 | * | |
22 | * Note: The queue runner only requires 'access CiviCRM' permission. | |
23 | * To ensure that malicious parties don't use this feature to | |
24 | * run queues on the wrong schedule, the queue-runner has an | |
25 | * extra authorization step: it checks for a session variable named | |
26 | * $_SESSION['queueRunners][$qrid]. This variable is properly setup | |
27 | * if you use the CRM_Queue_Runner::runAllViaWeb() interface. | |
28 | */ | |
29 | class CRM_Queue_Page_Runner extends CRM_Core_Page { | |
30 | ||
31 | /** | |
32 | * | |
33 | * POST Param 'qrid': string, usually the name of the queue | |
34 | */ | |
4523a2f5 | 35 | public function run() { |
6a488035 TO |
36 | $qrid = CRM_Utils_Request::retrieve('qrid', 'String', $this, TRUE); |
37 | $runner = CRM_Queue_Runner::instance($qrid); | |
6a488035 | 38 | if (!is_object($runner)) { |
507bc932 | 39 | CRM_Core_Error::statusBounce(ts('Queue runner must be configured before execution.')); |
6a488035 TO |
40 | } |
41 | ||
42 | CRM_Utils_System::setTitle($runner->title); | |
be2fb01f | 43 | $this->assign('queueRunnerData', [ |
4523a2f5 TO |
44 | 'qrid' => $runner->qrid, |
45 | 'runNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/runNext', NULL, FALSE, NULL, FALSE), | |
46 | 'skipNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/skipNext', NULL, FALSE, NULL, FALSE), | |
47 | 'onEndAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/onEnd', NULL, FALSE, NULL, FALSE), | |
48 | 'completed' => 0, | |
49 | 'numberOfItems' => $runner->queue->numberOfItems(), | |
50 | 'buttons' => $runner->buttons, | |
be2fb01f | 51 | ]); |
6a488035 TO |
52 | |
53 | if ($runner->isMinimal) { | |
54 | // Render page header | |
9dc21423 | 55 | if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) { |
6a488035 TO |
56 | CRM_Utils_System::addHTMLHead($region->render('')); |
57 | } | |
58 | $smarty = CRM_Core_Smarty::singleton(); | |
59 | $content = $smarty->fetch('CRM/Queue/Page/Runner.tpl'); | |
60 | echo CRM_Utils_System::theme($content, $this->_print, TRUE); | |
61 | } | |
62 | else { | |
63 | parent::run(); | |
64 | } | |
65 | } | |
96025800 | 66 | |
6a488035 | 67 | } |