From: Chris Burgess Date: Sun, 2 Feb 2014 21:01:04 +0000 (+1300) Subject: CRM-14154. Add API method for "message_template", "send". X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f471d149da554bd0ca37b5c418758d7976932389;p=civicrm-core.git CRM-14154. Add API method for "message_template", "send". --- diff --git a/api/v3/MessageTemplate.php b/api/v3/MessageTemplate.php index 80fc3abe19..4d241fe9d6 100644 --- a/api/v3/MessageTemplate.php +++ b/api/v3/MessageTemplate.php @@ -32,7 +32,6 @@ * */ - /** * @access public */ @@ -66,9 +65,9 @@ function civicrm_api3_message_template_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - function _civicrm_api3_message_template_get_spec(&$params) { } + /** * Retrieve one or more message_template * @@ -87,3 +86,30 @@ function civicrm_api3_message_template_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } +/** + * Sends a template. + */ +function civicrm_api3_message_template_send($params) { + require_once 'CRM/Core/BAO/MessageTemplates.php'; + CRM_Core_BAO_MessageTemplates::sendTemplate($params); +} + +/** + * Adjust Metadata for Create action + * + * The metadata is used for setting defaults, documentation & + * validation. + * + * @param array $params array or parameters determined by getfields + */ +function _civicrm_api3_message_template_send_spec(&$params) { + $required = array( + 'messageTemplateID', + 'contactId', + 'toEmail', + 'toName', + ); + foreach ($required as $value) { + $params[$value]['api.required'] = 1; + } +}