INFRA-132 - Batch 14 (g)
[civicrm-core.git] / api / v3 / MessageTemplate.php
CommitLineData
4a092902 1<?php
4a092902
XD
2/*
3 +--------------------------------------------------------------------+
4 | Project60 version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright TTTP (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25*/
26
27/**
63c9befe 28 * File for the CiviCRM APIv3 message_template functions
4a092902
XD
29 *
30 * @package CiviCRM_SEPA
31 *
32 */
33
4a092902 34/**
d0997921 35 * @param array $params
645ee340
EM
36 * @return array
37 * @throws \API_Exception
4a092902 38 */
63c9befe 39function civicrm_api3_message_template_create($params) {
4a092902
XD
40 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
41}
42
43/**
44 * Adjust Metadata for Create action
8ef12e64 45 *
4a092902 46 * The metadata is used for setting defaults, documentation & validation
cf470720
TO
47 * @param array $params
48 * Array or parameters determined by getfields.
4a092902 49 */
63c9befe 50function _civicrm_api3_message_template_create_spec(&$params) {
4a092902 51 $params['msg_title']['api.required'] = 1;
35671d00
TO
52 $params['is_active']['api.default'] = TRUE;
53 /* $params['entity_id']['api.required'] = 1;
4a092902
XD
54 $params['entity_table']['api.default'] = "civicrm_contribution_recur";
55 $params['type']['api.default'] = "R";
35671d00 56 */
4a092902
XD
57}
58
59/**
cf470720 60 * @param array $params
4a092902 61 *
ae5ffbb7
TO
62 * @return bool
63 * API result array
4a092902 64 */
63c9befe 65function civicrm_api3_message_template_delete($params) {
4a092902
XD
66 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
67}
68
aa1b1481 69/**
c490a46a 70 * @param array $params
aa1b1481 71 */
63c9befe 72function _civicrm_api3_message_template_get_spec(&$params) {
4a092902 73}
f471d149 74
4a092902 75/**
63c9befe 76 * Retrieve one or more message_template
4a092902 77 *
cf470720
TO
78 * @param array $params
79 * An associative array of name/value pairs.
4a092902 80 *
a6c01b45 81 * @return array
72b3a70c 82 * api result array
4a092902 83 */
63c9befe 84function civicrm_api3_message_template_get($params) {
4a092902
XD
85 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
86}
87
f471d149
CB
88/**
89 * Sends a template.
d0997921 90 * @param array $params
f471d149
CB
91 */
92function civicrm_api3_message_template_send($params) {
f471d149
CB
93 CRM_Core_BAO_MessageTemplates::sendTemplate($params);
94}
95
96/**
97 * Adjust Metadata for Create action
98 *
99 * The metadata is used for setting defaults, documentation &
100 * validation.
101 *
cf470720
TO
102 * @param array $params
103 * Array or parameters determined by getfields.
f471d149
CB
104 */
105function _civicrm_api3_message_template_send_spec(&$params) {
7385c761
EM
106 $params['messageTemplateID']['api.required'] = 1;
107 $params['messageTemplateID']['title'] = 'Message Template ID';
108 $params['contactId']['api.required'] = 1;
109 $params['contactId']['title'] = 'Contact ID';
110 $params['toEmail']['api.required'] = 1;
111 $params['toEmail']['title'] = 'To Email';
112 $params['toName']['api.required'] = 1;
113 $params['toName']['title'] = 'To Name';
f471d149 114}