4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
30 * File for the CiviCRM APIv3 note functions
32 * @package CiviCRM_APIv3
33 * @subpackage API_Note
35 * @copyright CiviCRM LLC (c) 2004-2014
36 * @version $Id: Note.php 30879 2010-11-22 15:45:55Z shot $
41 * Files required for this package
47 * This API is used for creating a note.
48 * Required parameters : entity_id AND note
50 * @param array $params
51 * An associative array of name/value property values of civicrm_note.
52 * {@getfields note_create}
57 * @example NoteCreate.php Create example
61 function civicrm_api3_note_create($params) {
62 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
66 * Adjust Metadata for Create action
68 * The metadata is used for setting defaults, documentation & validation
69 * @param array $params
70 * Array or parameters determined by getfields.
72 function _civicrm_api3_note_create_spec(&$params) {
73 $params['entity_table']['api.default'] = "civicrm_contact";
74 $params['modified_date']['api.default'] = "now";
75 $params['note']['api.required'] = 1;
76 $params['entity_id']['api.required'] = 1;
80 * Deletes an existing note
82 * This API is used for deleting a note
84 * @param array $params
85 * Including id of the note to be deleted.
86 * {@getfields note_delete}
91 function civicrm_api3_note_delete($params) {
93 $result = new CRM_Core_BAO_Note();
94 return $result->del($params['id']) ?
civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting Note');
98 * Retrieve a specific note, given a set of input params
100 * @param array $params
104 * array of properties,
105 * if error an array with an error id and error message
106 * {@getfields note_get}
110 function civicrm_api3_note_get($params) {
112 return _civicrm_api3_basic_get('CRM_Core_BAO_Note', $params);
116 * Adjust Metadata for Get action
118 * The metadata is used for setting defaults, documentation & validation
119 * @param array $params
120 * Array or parameters determined by getfields.
122 function _civicrm_api3_note_get_spec(&$params) {
123 $params['entity_table']['api.default'] = "civicrm_contact";
127 * Get all descendents of given note
129 * @param array $params
130 * Associative array; only required 'id' parameter is used.
133 * Nested associative array beginning with direct children of given note.
135 function &civicrm_api3_note_tree_get($params) {
137 civicrm_api3_verify_mandatory($params, NULL, array('id'));
139 if (!is_numeric($params['id'])) {
140 return civicrm_api3_create_error(ts("Invalid note ID"));
142 if (!isset($params['max_depth'])) {
143 $params['max_depth'] = 0;
145 if (!isset($params['snippet'])) {
146 $params['snippet'] = FALSE;
148 $noteTree = CRM_Core_BAO_Note
::getNoteTree($params['id'], $params['max_depth'], $params['snippet']);
149 return civicrm_api3_create_success($noteTree, $params);