Merge branch '4.4' of https://github.com/civicrm/civicrm-core
[civicrm-core.git] / api / v3 / MessageTemplate.php
CommitLineData
4a092902
XD
1<?php
2// $Id$
3/*
4 +--------------------------------------------------------------------+
5 | Project60 version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright TTTP (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*/
27
28/**
63c9befe 29 * File for the CiviCRM APIv3 message_template functions
4a092902
XD
30 *
31 * @package CiviCRM_SEPA
32 *
33 */
34
4a092902
XD
35/**
36 * @access public
37 */
63c9befe 38function civicrm_api3_message_template_create($params) {
4a092902
XD
39 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
40}
41
42/**
43 * Adjust Metadata for Create action
8ef12e64 44 *
4a092902
XD
45 * The metadata is used for setting defaults, documentation & validation
46 * @param array $params array or parameters determined by getfields
47 */
63c9befe 48function _civicrm_api3_message_template_create_spec(&$params) {
4a092902
XD
49 $params['msg_title']['api.required'] = 1;
50 $params['is_active']['api.default'] = true;
51/* $params['entity_id']['api.required'] = 1;
52 $params['entity_table']['api.default'] = "civicrm_contribution_recur";
53 $params['type']['api.default'] = "R";
54*/
55}
56
57/**
58 * @param array $params
59 *
60 * @return boolean | error true if successfull, error otherwise
63c9befe 61 * {@getfields message_template_delete}
4a092902
XD
62 * @access public
63 */
63c9befe 64function civicrm_api3_message_template_delete($params) {
4a092902
XD
65 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
66}
67
63c9befe 68function _civicrm_api3_message_template_get_spec(&$params) {
4a092902 69}
f471d149 70
4a092902 71/**
63c9befe 72 * Retrieve one or more message_template
4a092902
XD
73 *
74 * @param array input parameters
75 *
76 *
77 * @example SepaCreditorGet.php Standard Get Example
78 *
79 * @param array $params an associative array of name/value pairs.
80 *
81 * @return array api result array
63c9befe 82 * {@getfields message_template_get}
4a092902
XD
83 * @access public
84 */
63c9befe 85function civicrm_api3_message_template_get($params) {
4a092902
XD
86 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
87}
88
f471d149
CB
89/**
90 * Sends a template.
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 *
102 * @param array $params array or parameters determined by getfields
103 */
104function _civicrm_api3_message_template_send_spec(&$params) {
105 $required = array(
106 'messageTemplateID',
107 'contactId',
108 'toEmail',
109 'toName',
110 );
111 foreach ($required as $value) {
112 $params[$value]['api.required'] = 1;
113 }
114}