+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Job');
}
+/**
+ * Adjust metadata for clone spec action.
+ *
+ * @param array $spec
+ */
+function _civicrm_api3_job_clone_spec(&$spec) {
+ $spec['id']['title'] = 'Job ID to clone';
+ $spec['id']['type'] = CRM_Utils_Type::T_INT;
+ $spec['id']['api.required'] = 1;
+ $spec['is_active']['title'] = 'Job is Active?';
+ $spec['is_active']['type'] = CRM_Utils_Type::T_BOOLEAN;
+ $spec['is_active']['api.required'] = 0;
+}
+
+/**
+ * Clone Job.
+ *
+ * @param array $params
+ *
+ * @return array
+ * @throws \API_Exception
+ * @throws \CiviCRM_API3_Exception
+ */
+function civicrm_api3_job_clone($params) {
+ if (empty($params['id'])) {
+ throw new API_Exception("Mandatory key(s) missing from params array: id field is required");
+ }
+ $id = $params['id'];
+ unset($params['id']);
+ $params['last_run'] = 'null';
+ $params['scheduled_run_date'] = 'null';
+ $newJobDAO = CRM_Core_BAO_Job::copy($id, $params);
+ return civicrm_api3('Job', 'get', ['id' => $newJobDAO->id]);
+}
+
/**
* Retrieve one or more job.
*
* @param array $params
*/
function _civicrm_api3_job_geocode_spec(&$params) {
- $params['start'] = array(
+ $params['start'] = [
'title' => 'Starting Contact ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['end'] = array(
+ ];
+ $params['end'] = [
'title' => 'Ending Contact ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['geocoding'] = array(
+ ];
+ $params['geocoding'] = [
'title' => 'Geocode address?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['parse'] = array(
+ ];
+ $params['parse'] = [
'title' => 'Parse street address?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['throttle'] = array(
+ ];
+ $params['throttle'] = [
'title' => 'Throttle?',
'description' => 'If enabled, geo-codes at a slow rate',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
function _civicrm_api3_job_send_reminder(&$params) {
//@todo this function will now take all fields in action_schedule as params
// as it is calling the api fn to set the filters - update getfields to reflect
- $params['id'] = array(
+ $params['id'] = [
'type' => CRM_Utils_Type::T_INT,
'title' => 'Action Schedule ID',
- );
+ ];
}
/**
* Execute a specific report instance and send the output via email.
* Array of parameters determined by getfields.
*/
function _civicrm_api3_job_update_greeting_spec(&$params) {
- $params['ct'] = array(
+ $params['ct'] = [
'api.required' => 1,
'title' => 'Contact Type',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['gt'] = array(
+ ];
+ $params['gt'] = [
'api.required' => 1,
'title' => 'Greeting Type',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
/**
return civicrm_api3_create_error('Process Queue failed');
}
else {
- $values = array(
+ $values = [
'processed' => CRM_Mailing_BAO_MailingJob::$mailsProcessed - $mailsProcessedOrig,
- );
+ ];
return civicrm_api3_create_success($values, $params, 'Job', 'process_mailing');
}
}
return civicrm_api3_create_error('Process Queue failed');
}
else {
- $values = array(
+ $values = [
'processed' => CRM_Mailing_BAO_MailingJob::$mailsProcessed - $mailsProcessedOrig,
- );
+ ];
return civicrm_api3_create_success($values, $params, 'Job', 'process_sms');
}
}
* @param array $params
*/
function _civicrm_api3_job_fetch_bounces_spec(&$params) {
- $params['is_create_activities'] = array(
+ $params['is_create_activities'] = [
'api.default' => 0,
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Create activities for replies?'),
- );
+ ];
}
/**
try {
CRM_Utils_Mail_EmailProcessor::processActivities();
- $values = array();
+ $values = [];
$lock->release();
return civicrm_api3_create_success($values, $params, 'Job', 'fetch_activities');
}
function civicrm_api3_job_process_batch_merge($params) {
$rule_group_id = CRM_Utils_Array::value('rule_group_id', $params);
if (!$rule_group_id) {
- $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', array(
+ $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', [
'contact_type' => 'Individual',
'used' => 'Unsupervised',
'return' => 'id',
- 'options' => array('limit' => 1),
- ));
+ 'options' => ['limit' => 1],
+ ]);
}
$rgid = CRM_Utils_Array::value('rgid', $params);
$gid = CRM_Utils_Array::value('gid', $params);
$mode = CRM_Utils_Array::value('mode', $params, 'safe');
- $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, array()), CRM_Utils_Array::value('check_permissions', $params));
+ $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, []), CRM_Utils_Array::value('check_permissions', $params));
return civicrm_api3_create_success($result, $params);
}
* @param $params
*/
function _civicrm_api3_job_process_batch_merge_spec(&$params) {
- $params['rule_group_id'] = array(
+ $params['rule_group_id'] = [
'title' => 'Dedupe rule group id, defaults to Contact Unsupervised rule',
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('rgid'),
- );
- $params['gid'] = array(
+ 'api.aliases' => ['rgid'],
+ ];
+ $params['gid'] = [
'title' => 'group id',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['mode'] = array(
+ ];
+ $params['mode'] = [
'title' => 'Mode',
'description' => 'helps decide how to behave when there are conflicts. A \'safe\' value skips the merge if there are no conflicts. Does a force merge otherwise.',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['auto_flip'] = array(
+ ];
+ $params['auto_flip'] = [
'title' => 'Auto Flip',
'description' => 'let the api decide which contact to retain and which to delete?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
'PaymentCron',
array_merge(
$params,
- array(
+ [
'caller' => 'api',
- )
+ ]
)
);
'PaymentCron',
array_merge(
$params,
- array(
+ [
'mode' => 'test',
- )
+ ]
)
);
}
$session = CRM_Utils_Array::value('session', $params, TRUE);
$tempTable = CRM_Utils_Array::value('tempTables', $params, TRUE);
$jobLog = CRM_Utils_Array::value('jobLog', $params, TRUE);
+ $expired = CRM_Utils_Array::value('expiredDbCache', $params, TRUE);
$prevNext = CRM_Utils_Array::value('prevNext', $params, TRUE);
$dbCache = CRM_Utils_Array::value('dbCache', $params, FALSE);
$memCache = CRM_Utils_Array::value('memCache', $params, FALSE);
$tplCache = CRM_Utils_Array::value('tplCache', $params, FALSE);
$wordRplc = CRM_Utils_Array::value('wordRplc', $params, FALSE);
- if ($session || $tempTable || $prevNext) {
- CRM_Core_BAO_Cache::cleanup($session, $tempTable, $prevNext);
+ if ($session || $tempTable || $prevNext || $expired) {
+ CRM_Core_BAO_Cache::cleanup($session, $tempTable, $prevNext, $expired);
}
if ($jobLog) {