First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
131
sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php
Normal file
131
sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php
Normal file
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Queue_Page_AJAX
|
||||
*/
|
||||
class CRM_Queue_Page_AJAX {
|
||||
|
||||
/**
|
||||
* Run the next task and return status information.
|
||||
*
|
||||
* Outputs JSON: array(
|
||||
* is_error => bool,
|
||||
* is_continue => bool,
|
||||
* numberOfItems => int,
|
||||
* exception => htmlString
|
||||
* )
|
||||
*/
|
||||
public static function runNext() {
|
||||
$errorPolicy = new CRM_Queue_ErrorPolicy();
|
||||
$errorPolicy->call(function () {
|
||||
global $activeQueueRunner;
|
||||
$qrid = CRM_Utils_Request::retrieve('qrid', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'POST');
|
||||
$activeQueueRunner = CRM_Queue_Runner::instance($qrid);
|
||||
if (!is_object($activeQueueRunner)) {
|
||||
throw new Exception('Queue runner must be configured before execution.');
|
||||
}
|
||||
$result = $activeQueueRunner->runNext(TRUE);
|
||||
CRM_Queue_Page_AJAX::_return('runNext', $result);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the next task and return status information.
|
||||
*
|
||||
* Outputs JSON: array(
|
||||
* is_error => bool,
|
||||
* is_continue => bool,
|
||||
* numberOfItems => int,
|
||||
* exception => htmlString
|
||||
* )
|
||||
*/
|
||||
public static function skipNext() {
|
||||
$errorPolicy = new CRM_Queue_ErrorPolicy();
|
||||
$errorPolicy->call(function () {
|
||||
global $activeQueueRunner;
|
||||
$qrid = CRM_Utils_Request::retrieve('qrid', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'POST');
|
||||
$activeQueueRunner = CRM_Queue_Runner::instance($qrid);
|
||||
if (!is_object($activeQueueRunner)) {
|
||||
throw new Exception('Queue runner must be configured before execution.');
|
||||
}
|
||||
$result = $activeQueueRunner->skipNext(TRUE);
|
||||
CRM_Queue_Page_AJAX::_return('skipNext', $result);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the next task and return status information.
|
||||
*
|
||||
* Outputs JSON: array(
|
||||
* is_error => bool,
|
||||
* is_continue => bool,
|
||||
* numberOfItems => int,
|
||||
* exception => htmlString
|
||||
* )
|
||||
*/
|
||||
public static function onEnd() {
|
||||
$errorPolicy = new CRM_Queue_ErrorPolicy();
|
||||
$errorPolicy->call(function () {
|
||||
global $activeQueueRunner;
|
||||
$qrid = CRM_Utils_Request::retrieve('qrid', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'POST');
|
||||
$activeQueueRunner = CRM_Queue_Runner::instance($qrid);
|
||||
if (!is_object($activeQueueRunner)) {
|
||||
throw new Exception('Queue runner must be configured before execution. - onEnd');
|
||||
}
|
||||
$result = $activeQueueRunner->handleEnd(FALSE);
|
||||
CRM_Queue_Page_AJAX::_return('onEnd', $result);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Performing any view-layer filtering on result and send to client.
|
||||
*
|
||||
* @param string $op
|
||||
* @param array $result
|
||||
*/
|
||||
public static function _return($op, $result) {
|
||||
if ($result['is_error']) {
|
||||
if (is_object($result['exception'])) {
|
||||
CRM_Core_Error::debug_var("CRM_Queue_Page_AJAX_{$op}_error", CRM_Core_Error::formatTextException($result['exception']));
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
if ($config->backtrace || CRM_Core_Config::isUpgradeMode()) {
|
||||
$result['exception'] = CRM_Core_Error::formatHtmlException($result['exception']);
|
||||
}
|
||||
else {
|
||||
$result['exception'] = $result['exception']->getMessage();
|
||||
}
|
||||
}
|
||||
else {
|
||||
CRM_Core_Error::debug_var("CRM_Queue_Page_AJAX_{$op}_error", $result);
|
||||
}
|
||||
}
|
||||
CRM_Utils_JSON::output($result);
|
||||
}
|
||||
|
||||
}
|
83
sites/all/modules/civicrm/CRM/Queue/Page/Runner.php
Normal file
83
sites/all/modules/civicrm/CRM/Queue/Page/Runner.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
require_once 'CRM/Core/Page.php';
|
||||
|
||||
/**
|
||||
* The queue-runner page provides an interactive, web-based system
|
||||
* running the tasks in a queue and monitoring its progression.
|
||||
*
|
||||
* Do not link or redirect to this page directly -- go through
|
||||
* CRM_Queue_Runner::runAllViaWeb().
|
||||
*
|
||||
* Note: The queue runner only requires 'access CiviCRM' permission.
|
||||
* To ensure that malicious parties don't use this feature to
|
||||
* run queues on the wrong schedule, the queue-runner has an
|
||||
* extra authorization step: it checks for a session variable named
|
||||
* $_SESSION['queueRunners][$qrid]. This variable is properly setup
|
||||
* if you use the CRM_Queue_Runner::runAllViaWeb() interface.
|
||||
*/
|
||||
class CRM_Queue_Page_Runner extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
*
|
||||
* POST Param 'qrid': string, usually the name of the queue
|
||||
*/
|
||||
public function run() {
|
||||
$qrid = CRM_Utils_Request::retrieve('qrid', 'String', $this, TRUE);
|
||||
$runner = CRM_Queue_Runner::instance($qrid);
|
||||
if (!is_object($runner)) {
|
||||
CRM_Core_Error::fatal('Queue runner must be configured before execution.');
|
||||
}
|
||||
|
||||
CRM_Utils_System::setTitle($runner->title);
|
||||
$this->assign('queueRunnerData', array(
|
||||
'qrid' => $runner->qrid,
|
||||
'runNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/runNext', NULL, FALSE, NULL, FALSE),
|
||||
'skipNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/skipNext', NULL, FALSE, NULL, FALSE),
|
||||
'onEndAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/onEnd', NULL, FALSE, NULL, FALSE),
|
||||
'completed' => 0,
|
||||
'numberOfItems' => $runner->queue->numberOfItems(),
|
||||
'buttons' => $runner->buttons,
|
||||
));
|
||||
|
||||
if ($runner->isMinimal) {
|
||||
// Render page header
|
||||
if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) {
|
||||
CRM_Utils_System::addHTMLHead($region->render(''));
|
||||
}
|
||||
$smarty = CRM_Core_Smarty::singleton();
|
||||
$content = $smarty->fetch('CRM/Queue/Page/Runner.tpl');
|
||||
echo CRM_Utils_System::theme($content, $this->_print, TRUE);
|
||||
}
|
||||
else {
|
||||
parent::run();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue