a030409a19eb786c50feaca6167931e6826dde50
[civicrm-core.git] / api / v3 / MessageTemplate.php
1 <?php
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 /**
28 * File for the CiviCRM APIv3 message_template functions
29 *
30 * @package CiviCRM_SEPA
31 *
32 */
33
34 /**
35 * Create message template.
36 *
37 * @param array $params
38 *
39 * @return array
40 * @throws \API_Exception
41 */
42 function civicrm_api3_message_template_create($params) {
43 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
44 }
45
46 /**
47 * Adjust Metadata for Create action.
48 *
49 * The metadata is used for setting defaults, documentation & validation.
50 *
51 * @param array $params
52 * Array or parameters determined by getfields.
53 */
54 function _civicrm_api3_message_template_create_spec(&$params) {
55 $params['msg_title']['api.required'] = 1;
56 $params['is_active']['api.default'] = TRUE;
57 /* $params['entity_id']['api.required'] = 1;
58 $params['entity_table']['api.default'] = "civicrm_contribution_recur";
59 $params['type']['api.default'] = "R";
60 */
61 }
62
63 /**
64 * @param array $params
65 *
66 * @return bool
67 * API result array
68 */
69 function civicrm_api3_message_template_delete($params) {
70 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
71 }
72
73 /**
74 * @param array $params
75 */
76 function _civicrm_api3_message_template_get_spec(&$params) {
77 }
78
79 /**
80 * Retrieve one or more message_template
81 *
82 * @param array $params
83 * An associative array of name/value pairs.
84 *
85 * @return array
86 * api result array
87 */
88 function civicrm_api3_message_template_get($params) {
89 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
90 }
91
92 /**
93 * Sends a template.
94 * @param array $params
95 */
96 function civicrm_api3_message_template_send($params) {
97 CRM_Core_BAO_MessageTemplates::sendTemplate($params);
98 }
99
100 /**
101 * Adjust Metadata for Create action.
102 *
103 * The metadata is used for setting defaults, documentation &
104 * validation.
105 *
106 * @param array $params
107 * Array or parameters determined by getfields.
108 */
109 function _civicrm_api3_message_template_send_spec(&$params) {
110 $params['messageTemplateID']['api.required'] = 1;
111 $params['messageTemplateID']['title'] = 'Message Template ID';
112 $params['contactId']['api.required'] = 1;
113 $params['contactId']['title'] = 'Contact ID';
114 $params['toEmail']['api.required'] = 1;
115 $params['toEmail']['title'] = 'To Email';
116 $params['toName']['api.required'] = 1;
117 $params['toName']['title'] = 'To Name';
118 }