* {@schema Core/Job.xml}
*/
function civicrm_api3_job_create($params) {
- require_once 'CRM/Utils/Rule.php';
-
if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) {
return civicrm_api3_create_error('Invalid value for job ID');
}
* @access public
*/
function civicrm_api3_job_delete($params) {
- require_once 'CRM/Utils/Rule.php';
if ($params['id'] != NULL && !CRM_Utils_Rule::integer($params['id'])) {
return civicrm_api3_create_error('Invalid value for job ID');
}
*
*/
function civicrm_api3_job_execute($params) {
- require_once 'CRM/Core/JobManager.php';
$facility = new CRM_Core_JobManager();
$facility->execute(FALSE);
*
*/
function civicrm_api3_job_geocode($params) {
-
- require_once 'CRM/Utils/Address/BatchUpdate.php';
$gc = new CRM_Utils_Address_BatchUpdate($params);
*
*/
function civicrm_api3_job_send_reminder($params) {
- require_once 'CRM/Core/BAO/ActionSchedule.php';
+ $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
+ if (!$lock->isAcquired()) {
+ return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
+ }
+
$result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params));
+ $lock->release();
if ($result['is_error'] == 0) {
return civicrm_api3_create_success();
*
*/
function civicrm_api3_job_mail_report($params) {
-
$result = CRM_Report_Utils_Report::processReport($params);
if ($result['is_error'] == 0) {
* @return array
*/
function civicrm_api3_job_process_sms($params) {
-
if (!CRM_Mailing_BAO_Mailing::processQueue('sms')) {
return civicrm_api3_create_error('Process Queue failed');
}
return civicrm_api3_create_success($values, $params, 'mailing', 'process');
}
}
+
/**
* Job to get mail responses from civimailing
*/
function civicrm_api3_job_fetch_bounces($params) {
- require_once 'CRM/Utils/Mail/EmailProcessor.php';
- require_once 'CRM/Core/Lock.php';
- $lock = new CRM_Core_Lock('EmailProcessor');
+ $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
if (!CRM_Utils_Mail_EmailProcessor::processBounces()) {
+ $lock->release();
return civicrm_api3_create_error('Process Bounces failed');
}
- // FIXME: processBounces doesn't return true/false on success/failure
- $values = array();
$lock->release();
+
+ // FIXME: processBounces doesn't return true/false on success/failure
+ $values = array();
return civicrm_api3_create_success($values, $params, 'mailing', 'bounces');
}
* Job to get mail and create activities
*/
function civicrm_api3_job_fetch_activities($params) {
- require_once 'CRM/Utils/Mail/EmailProcessor.php';
- require_once 'CRM/Core/Lock.php';
- $lock = new CRM_Core_Lock('EmailProcessor');
+ $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
- try {
- CRM_Utils_Mail_EmailProcessor::processActivities();
- $values = array( );
+
+ try {
+ CRM_Utils_Mail_EmailProcessor::processActivities();
+ $values = array( );
$lock->release();
- return civicrm_api3_create_success($values, $params,'mailing','activities');
- } catch (Exception $e) {
+ return civicrm_api3_create_success($values, $params,'mailing','activities');
+ } catch (Exception $e) {
$lock->release();
return civicrm_api3_create_error('Process Activities failed');
}
* @access public
*/
function civicrm_api3_job_process_participant($params) {
- require_once 'CRM/Event/BAO/ParticipantStatusType.php';
$result = CRM_Event_BAO_ParticipantStatusType::process($params);
if (!$result['is_error']) {
* @access public
*/
function civicrm_api3_job_process_membership($params) {
- require_once 'CRM/Member/BAO/Membership.php';
+ $lock = new CRM_Core_Lock('civimail.job.updateMembership');
+ if (!$lock->isAcquired()) {
+ return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
+ }
+
$result = CRM_Member_BAO_Membership::updateAllMembershipStatus();
+ $lock->release();
if ($result['is_error'] == 0) {
return civicrm_api3_create_success($result['messages']);
* @access public
*/
function civicrm_api3_job_process_respondent($params) {
- require_once 'CRM/Campaign/BAO/Survey.php';
$result = CRM_Campaign_BAO_Survey::releaseRespondent($params);
if ($result['is_error'] == 0) {
$mode = CRM_Utils_Array::value('mode', $params, 'safe');
$autoFlip = CRM_Utils_Array::value('auto_flip', $params, TRUE);
- require_once 'CRM/Dedupe/Merger.php';
$result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, $mode, $autoFlip);
if ($result['is_error'] == 0) {
*/
function civicrm_api3_job_run_payment_cron($params) {
- require_once 'CRM/Core/Payment.php';
-
// live mode
CRM_Core_Payment::handlePaymentMethod(
'PaymentCron',
* @access public
*/
function civicrm_api3_job_cleanup( $params ) {
- require_once 'CRM/Utils/Array.php';
-
$session = CRM_Utils_Array::value( 'session' , $params, true );
$tempTable = CRM_Utils_Array::value( 'tempTables', $params, true );
$jobLog = CRM_Utils_Array::value( 'jobLog' , $params, true );
$memCache = CRM_Utils_Array::value( 'memCache' , $params, false );
if ( $session || $tempTable || $prevNext ) {
- require_once 'CRM/Core/BAO/Cache.php';
CRM_Core_BAO_Cache::cleanup( $session, $tempTable, $prevNext );
}
* and use the cache
*/
function civicrm_api3_job_group_rebuild( $params ) {
+ $lock = new CRM_Core_Lock('civimail.job.groupRebuild');
+ if (!$lock->isAcquired()) {
+ return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
+ }
+
$limit = CRM_Utils_Array::value( 'limit', $params, 0 );
CRM_Contact_BAO_GroupContactCache::loadAll(null, $limit);
+ $lock->release();
+
return civicrm_api3_create_success();
}