3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * File for the CiviCRM APIv3 note functions
31 * @package CiviCRM_APIv3
32 * @subpackage API_Note
34 * @copyright CiviCRM LLC (c) 2004-2014
35 * @version $Id: Note.php 30879 2010-11-22 15:45:55Z shot $
41 * This API is used for creating a note.
42 * Required parameters : entity_id AND note
44 * @param array $params
45 * An associative array of name/value property values of civicrm_note.
46 * {@getfields note_create}
51 function civicrm_api3_note_create($params) {
52 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
56 * Adjust Metadata for Create action.
58 * The metadata is used for setting defaults, documentation & validation.
60 * @param array $params
61 * Array or parameters determined by getfields.
63 function _civicrm_api3_note_create_spec(&$params) {
64 $params['entity_table']['api.default'] = "civicrm_contact";
65 $params['modified_date']['api.default'] = "now";
66 $params['note']['api.required'] = 1;
67 $params['entity_id']['api.required'] = 1;
71 * Deletes an existing note.
73 * This API is used for deleting a note
75 * @param array $params
76 * Including id of the note to be deleted.
80 function civicrm_api3_note_delete($params) {
82 $result = new CRM_Core_BAO_Note();
83 return $result->del($params['id']) ?
civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting Note');
87 * Retrieve a specific note or notes, given a set of input params.
89 * @param array $params
93 * array of properties,
94 * if error an array with an error id and error message
96 function civicrm_api3_note_get($params) {
98 return _civicrm_api3_basic_get('CRM_Core_BAO_Note', $params);
102 * Adjust Metadata for Get action.
104 * The metadata is used for setting defaults, documentation & validation.
106 * @param array $params
107 * Array or parameters determined by getfields.
109 function _civicrm_api3_note_get_spec(&$params) {
110 $params['entity_table']['api.default'] = "civicrm_contact";
114 * Get all descendants of given note.
116 * @param array $params
117 * array; only required 'id' parameter is used.
120 * Nested associative array beginning with direct children of given note.
122 function &civicrm_api3_note_tree_get($params) {
124 civicrm_api3_verify_mandatory($params, NULL, array('id'));
126 if (!is_numeric($params['id'])) {
127 return civicrm_api3_create_error(ts("Invalid note ID"));
129 if (!isset($params['max_depth'])) {
130 $params['max_depth'] = 0;
132 if (!isset($params['snippet'])) {
133 $params['snippet'] = FALSE;
135 $noteTree = CRM_Core_BAO_Note
::getNoteTree($params['id'], $params['max_depth'], $params['snippet']);
136 return civicrm_api3_create_success($noteTree, $params);