Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | ||
29 | require_once 'CRM/Core/Page.php'; | |
30 | ||
31 | /** | |
32 | * The queue-runner page provides an interactive, web-based system | |
33 | * running the tasks in a queue and monitoring its progression. | |
34 | * | |
35 | * Do not link or redirect to this page directly -- go through | |
36 | * CRM_Queue_Runner::runAllViaWeb(). | |
37 | * | |
38 | * Note: The queue runner only requires 'access CiviCRM' permission. | |
39 | * To ensure that malicious parties don't use this feature to | |
40 | * run queues on the wrong schedule, the queue-runner has an | |
41 | * extra authorization step: it checks for a session variable named | |
42 | * $_SESSION['queueRunners][$qrid]. This variable is properly setup | |
43 | * if you use the CRM_Queue_Runner::runAllViaWeb() interface. | |
44 | */ | |
45 | class CRM_Queue_Page_Runner extends CRM_Core_Page { | |
46 | ||
47 | /** | |
48 | * | |
49 | * POST Param 'qrid': string, usually the name of the queue | |
50 | */ | |
4523a2f5 | 51 | public function run() { |
6a488035 TO |
52 | $qrid = CRM_Utils_Request::retrieve('qrid', 'String', $this, TRUE); |
53 | $runner = CRM_Queue_Runner::instance($qrid); | |
6a488035 TO |
54 | if (!is_object($runner)) { |
55 | CRM_Core_Error::fatal('Queue runner must be configured before execution.'); | |
56 | } | |
57 | ||
58 | CRM_Utils_System::setTitle($runner->title); | |
59 | $this->assign('queueRunnerData', array( | |
4523a2f5 TO |
60 | 'qrid' => $runner->qrid, |
61 | 'runNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/runNext', NULL, FALSE, NULL, FALSE), | |
62 | 'skipNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/skipNext', NULL, FALSE, NULL, FALSE), | |
63 | 'onEndAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/onEnd', NULL, FALSE, NULL, FALSE), | |
64 | 'completed' => 0, | |
65 | 'numberOfItems' => $runner->queue->numberOfItems(), | |
66 | 'buttons' => $runner->buttons, | |
67 | )); | |
6a488035 TO |
68 | |
69 | if ($runner->isMinimal) { | |
70 | // Render page header | |
9dc21423 | 71 | if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) { |
6a488035 TO |
72 | CRM_Utils_System::addHTMLHead($region->render('')); |
73 | } | |
74 | $smarty = CRM_Core_Smarty::singleton(); | |
75 | $content = $smarty->fetch('CRM/Queue/Page/Runner.tpl'); | |
76 | echo CRM_Utils_System::theme($content, $this->_print, TRUE); | |
77 | } | |
78 | else { | |
79 | parent::run(); | |
80 | } | |
81 | } | |
96025800 | 82 | |
6a488035 | 83 | } |