From: Eileen Date: Wed, 22 Jan 2014 01:39:37 +0000 (+0000) Subject: CRM-14108 add scheduled reminder id as a params on scheduled job X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=73f3e293f7307c7fb0a0f848b21458602a2638c4;p=civicrm-core.git CRM-14108 add scheduled reminder id as a params on scheduled job ---------------------------------------- ---------------------------------------- * CRM-14108: Add Param for id to scheduled reminders http://issues.civicrm.org/jira/browse/CRM-14108 --- diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 5bfedcecdc..de6cc66947 100755 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -755,10 +755,13 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL } } - static function buildRecipientContacts($mappingID, $now) { + static function buildRecipientContacts($mappingID, $now, $params = array()) { $actionSchedule = new CRM_Core_DAO_ActionSchedule(); $actionSchedule->mapping_id = $mappingID; $actionSchedule->is_active = 1; + if(!empty($params)) { + _civicrm_api3_dao_set_filter($actionSchedule, $params, FALSE, 'ActionSchedule'); + } $actionSchedule->find(); while ($actionSchedule->fetch()) { @@ -1157,12 +1160,12 @@ WHERE m.owner_membership_id IS NOT NULL AND return NULL; } - static function processQueue($now = NULL) { + static function processQueue($now = NULL, $params = array()) { $now = $now ? CRM_Utils_Time::setTime($now) : CRM_Utils_Time::getTime(); $mappings = self::getMapping(); foreach ($mappings as $mappingID => $mapping) { - self::buildRecipientContacts($mappingID, $now); + self::buildRecipientContacts($mappingID, $now, $params); self::sendMailings($mappingID, $now); } diff --git a/api/v3/Job.php b/api/v3/Job.php index 06316253c6..1c07ac6515 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -190,7 +190,7 @@ function civicrm_api3_job_send_reminder($params) { 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)); + $result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params), $params); $lock->release(); if ($result['is_error'] == 0) { @@ -200,7 +200,20 @@ function civicrm_api3_job_send_reminder($params) { return civicrm_api3_create_error($result['messages']); } } - +/** + * Adjust metadata for "send_reminder" action + * + * The metadata is used for setting defaults, documentation & validation + * @param array $params array or parameters determined by getfields + */ +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( + 'type' => CRM_Utils_Type::T_INT, + 'title' => 'Action Schedule ID' + ); +} /** * Execute a specific report instance and send the output via email *