+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
/**
- * This api is used for triggering scheduled "cron" jobs.
+ * This api is used for working with scheduled "cron" jobs.
*
* @package CiviCRM_APIv3
*/
$facility->execute(FALSE);
// Always creates success - results are handled elsewhere.
- return civicrm_api3_create_success(1, $params);
+ return civicrm_api3_create_success(1, $params, 'Job');
}
/**
* @param array $params
*/
function _civicrm_api3_job_geocode_spec(&$params) {
- $params['start'] = array('title' => 'Start Date');
- $params['end'] = array('title' => 'End Date');
- $params['geocoding'] = array('title' => 'Geocode address?');
- $params['parse'] = array('title' => 'Parse street address?');
- $params['throttle'] = array('title' => 'Throttle? if enabled, geo-codes at a slow rate');
+ $params['start'] = array(
+ 'title' => 'Starting Contact ID',
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+ $params['end'] = array(
+ 'title' => 'Ending Contact ID',
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+ $params['geocoding'] = array(
+ 'title' => 'Geocode address?',
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
+ );
+ $params['parse'] = array(
+ 'title' => 'Parse street address?',
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
+ );
+ $params['throttle'] = array(
+ 'title' => 'Throttle?',
+ 'description' => 'If enabled, geo-codes at a slow rate',
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
+ );
}
/**
// in that case (ie. makes it non-configurable via the UI). Another approach would be to set a default of 0
// in the _spec function - but since that is a deprecated value it seems more contentious than this approach
$params['rowCount'] = 0;
- $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.core.ActionSchedule');
if (!$lock->isAcquired()) {
- return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
+ return civicrm_api3_create_error('Could not acquire lock, another ActionSchedule process is running');
}
$result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params), $params);
* @return array
*/
function civicrm_api3_job_process_mailing($params) {
+ $mailsProcessedOrig = CRM_Mailing_BAO_MailingJob::$mailsProcessed;
if (!CRM_Mailing_BAO_Mailing::processQueue()) {
return civicrm_api3_create_error('Process Queue failed');
}
else {
- $values = array();
- return civicrm_api3_create_success($values, $params, 'mailing', 'process');
+ $values = array(
+ 'processed' => CRM_Mailing_BAO_MailingJob::$mailsProcessed - $mailsProcessedOrig,
+ );
+ return civicrm_api3_create_success($values, $params, 'Job', 'process_mailing');
}
}
* @return array
*/
function civicrm_api3_job_process_sms($params) {
+ $mailsProcessedOrig = CRM_Mailing_BAO_MailingJob::$mailsProcessed;
+
if (!CRM_Mailing_BAO_Mailing::processQueue('sms')) {
return civicrm_api3_create_error('Process Queue failed');
}
else {
- $values = array();
- return civicrm_api3_create_success($values, $params, 'mailing', 'process');
+ $values = array(
+ 'processed' => CRM_Mailing_BAO_MailingJob::$mailsProcessed - $mailsProcessedOrig,
+ );
+ return civicrm_api3_create_success($values, $params, 'Job', 'process_sms');
}
}
* @return array
*/
function civicrm_api3_job_fetch_bounces($params) {
- $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
// FIXME: processBounces doesn't return true/false on success/failure
$values = array();
- return civicrm_api3_create_success($values, $params, 'mailing', 'bounces');
+ return civicrm_api3_create_success($values, $params, 'Job', 'fetch_bounces');
}
/**
* @return array
*/
function civicrm_api3_job_fetch_activities($params) {
- $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
CRM_Utils_Mail_EmailProcessor::processActivities();
$values = array();
$lock->release();
- return civicrm_api3_create_success($values, $params, 'mailing', 'activities');
+ return civicrm_api3_create_success($values, $params, 'Job', 'fetch_activities');
}
catch (Exception $e) {
$lock->release();
* true if success, else false
*/
function civicrm_api3_job_process_membership($params) {
- $lock = new CRM_Core_Lock('civimail.job.updateMembership');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.member.UpdateMembership');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another Membership Processing process is running');
}
$lock->release();
if ($result['is_error'] == 0) {
- return civicrm_api3_create_success($result['messages'], $params);
+ return civicrm_api3_create_success($result['messages'], $params, 'Job', 'process_membership');
}
else {
return civicrm_api3_create_error($result['messages']);
if (!$result) {
throw new API_Exception('Failed to disable all expired relationships.');
}
- return civicrm_api3_create_success(1, $params);
+ return civicrm_api3_create_success(1, $params, 'Job', 'disable_expired_relationships');
}
/**
* @throws \API_Exception
*/
function civicrm_api3_job_group_rebuild($params) {
- $lock = new CRM_Core_Lock('civimail.job.groupRebuild');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.core.GroupRebuild');
if (!$lock->isAcquired()) {
throw new API_Exception('Could not acquire lock, another EmailProcessor process is running');
}