Merge pull request #6378 from johanv/CRM-15991-permission_delete_relationship
[civicrm-core.git] / api / v3 / MessageTemplate.php
index 07b77ba2520fcae4af7da27065308cea0d3b8ce5..07a6cfd3d730ad1cba9456648794a9931174a5dd 100644 (file)
@@ -1,11 +1,11 @@
 <?php
-// $Id$
 /*
  +--------------------------------------------------------------------+
- | Project60 version 4.3                                              |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright TTTP (c) 2004-2013                                       |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | CiviCRM is free software; you can copy, modify, and distribute it  |
  | under the terms of the GNU Affero General Public License           |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
- * File for the CiviCRM APIv3 message_template functions
- *
- * @package CiviCRM_SEPA
+ * This api exposes CiviCRM message_template.
  *
+ * @package CiviCRM_APIv3
  */
 
 /**
- * @access public
+ * Create message template.
+ *
+ * @param array $params
+ *
+ * @return array
+ * @throws \API_Exception
  */
 function civicrm_api3_message_template_create($params) {
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
 /**
- * Adjust Metadata for Create action
+ * Adjust Metadata for Create action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
  *
- * The metadata is used for setting defaults, documentation & validation
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Array of parameters determined by getfields.
  */
 function _civicrm_api3_message_template_create_spec(&$params) {
   $params['msg_title']['api.required'] = 1;
-  $params['is_active']['api.default'] = true;
-/*  $params['entity_id']['api.required'] = 1;
+  $params['is_active']['api.default'] = TRUE;
+  /*  $params['entity_id']['api.required'] = 1;
   $params['entity_table']['api.default'] = "civicrm_contribution_recur";
   $params['type']['api.default'] = "R";
-*/
+   */
 }
 
 /**
- * @param  array  $params
+ * Delete message template.
+ *
+ * @param array $params
  *
- * @return boolean | error  true if successfull, error otherwise
- * {@getfields message_template_delete}
- * @access public
+ * @return bool
+ *   API result array
  */
 function civicrm_api3_message_template_delete($params) {
   return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
 /**
- * @param $params
+ * Adjust metadata for message_template get action.
+ *
+ * @param array $params
  */
 function _civicrm_api3_message_template_get_spec(&$params) {
+  // fetch active records by default
+  $params['is_active']['api.default'] = 1;
 }
 
 /**
- * Retrieve one or more message_template
- *
- * @param  array input parameters
- *
+ * Retrieve one or more message_template.
  *
- * @example SepaCreditorGet.php Standard Get Example
+ * @param array $params
+ *   Array of name/value pairs.
  *
- * @param  array $params  an associative array of name/value pairs.
- *
- * @return  array api result array
- * {@getfields message_template_get}
- * @access public
+ * @return array
+ *   API result array.
  */
 function civicrm_api3_message_template_get($params) {
   return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
@@ -91,6 +97,8 @@ function civicrm_api3_message_template_get($params) {
 
 /**
  * Sends a template.
+ *
+ * @param array $params
  */
 function civicrm_api3_message_template_send($params) {
   // Change external param names to internal ones
@@ -117,63 +125,78 @@ function civicrm_api3_message_template_send($params) {
 }
 
 /**
- * Adjust Metadata for Create action
+ * Adjust Metadata for Create action.
  *
  * The metadata is used for setting defaults, documentation &
  * validation.
  *
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Array of parameters determined by getfields.
  */
 function _civicrm_api3_message_template_send_spec(&$params) {
   $params['id']['description'] = 'ID of the template';
   $params['id']['title'] = 'Message Template ID';
   $params['id']['api.aliases'] = array('messageTemplateID', 'message_template_id');
+  $params['id']['type'] = CRM_Utils_Type::T_INT;
 
   $params['option_group_name']['description'] = 'option group name of the template (required if no id supplied)';
   $params['option_group_name']['title'] = 'Option Group Name';
   $params['option_group_name']['api.aliases'] = array('groupName');
+  $params['option_group_name']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['option_value_name']['description'] = 'option value name of the template (required if no id supplied)';
   $params['option_value_name']['title'] = 'Option Value Name';
   $params['option_value_name']['api.aliases'] = array('valueName');
+  $params['option_value_name']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['contact_id']['description'] = 'contact id if contact tokens are to be replaced';
   $params['contact_id']['title'] = 'Contact ID';
   $params['contact_id']['api.aliases'] = array('contactId');
+  $params['contact_id']['type'] = CRM_Utils_Type::T_INT;
 
   $params['template_params']['description'] = 'additional template params (other than the ones already set in the template singleton)';
   $params['template_params']['title'] = 'Template Params';
   $params['template_params']['api.aliases'] = array('tplParams');
+  // FIXME: Type??
 
   $params['from']['description'] = 'the From: header';
   $params['from']['title'] = 'From';
+  $params['from']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['to_name']['description'] = 'the recipient’s name';
   $params['to_name']['title'] = 'Recipient Name';
   $params['to_name']['api.aliases'] = array('toName');
+  $params['to_name']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['to_email']['description'] = 'the recipient’s email - mail is sent only if set';
   $params['to_email']['title'] = 'Recipient Email';
   $params['to_email']['api.aliases'] = array('toEmail');
+  $params['to_email']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['cc']['description'] = 'the Cc: header';
   $params['cc']['title'] = 'CC';
+  $params['cc']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['bcc']['description'] = 'the Bcc: header';
   $params['bcc']['title'] = 'BCC';
+  $params['bcc']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['reply_to']['description'] = 'the Reply-To: header';
   $params['reply_to']['title'] = 'Reply To';
   $params['reply_to']['api.aliases'] = array('replyTo');
+  $params['reply_to']['type'] = CRM_Utils_Type::T_STRING;
 
   $params['attachments']['description'] = 'email attachments';
   $params['attachments']['title'] = 'Attachments';
+  // FIXME: Type??
 
   $params['is_test']['description'] = 'whether this is a test email (and hence should include the test banner)';
   $params['is_test']['title'] = 'Is Test';
   $params['is_test']['api.aliases'] = array('isTest');
+  $params['is_test']['type'] = CRM_Utils_Type::T_BOOLEAN;
 
   $params['pdf_filename']['description'] = 'filename of optional PDF version to add as attachment (do not include path)';
   $params['pdf_filename']['title'] = 'PDF Filename';
   $params['pdf_filename']['api.aliases'] = array('PDFFilename');
+  $params['pdf_filename']['type'] = CRM_Utils_Type::T_STRING;
 }