Automatically detect requirements in *.aff.html
[civicrm-core.git] / CRM / Queue / Page / Runner.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
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 */
35 public function run() {
36 $qrid = CRM_Utils_Request::retrieve('qrid', 'String', $this, TRUE);
37 $runner = CRM_Queue_Runner::instance($qrid);
38 if (!is_object($runner)) {
39 CRM_Core_Error::statusBounce('Queue runner must be configured before execution.');
40 }
41
42 CRM_Utils_System::setTitle($runner->title);
43 $this->assign('queueRunnerData', [
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,
51 ]);
52
53 if ($runner->isMinimal) {
54 // Render page header
55 if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) {
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 }
66
67 }