Cleanup api3 docblocks
[civicrm-core.git] / api / v3 / GroupNesting.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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 /**
29 * This api exposes CiviCRM group nesting.
30 *
31 * @package CiviCRM_APIv3
32 * @subpackage API_Group
33 *
34 */
35
36 /**
37 * Provides group nesting record(s) given parent and/or child id.
38 *
39 * @param array $params
40 * An array containing at least child_group_id or parent_group_id.
41 *
42 * @return array
43 * list of group nesting records
44 */
45 function civicrm_api3_group_nesting_get($params) {
46
47 return _civicrm_api3_basic_get('CRM_Contact_DAO_GroupNesting', $params);
48 }
49
50 /**
51 * Creates group nesting record for given parent and child id.
52 *
53 * Parent and child groups need to exist.
54 *
55 * @param array $params
56 * Parameters array - allowed array keys include:.
57 *
58 * @return array
59 * TBD
60 * @todo Work out the return value.
61 */
62 function civicrm_api3_group_nesting_create($params) {
63
64 CRM_Contact_BAO_GroupNesting::add($params['parent_group_id'], $params['child_group_id']);
65
66 // FIXME: CRM_Contact_BAO_GroupNesting requires some work
67 $result = array('is_error' => 0);
68 return civicrm_api3_create_success($result, $params);
69 }
70
71 /**
72 * Adjust Metadata for Create action.
73 *
74 * The metadata is used for setting defaults, documentation & validation.
75 *
76 * @param array $params
77 * Array or parameters determined by getfields.
78 */
79 function _civicrm_api3_group_nesting_create_spec(&$params) {
80 $params['child_group_id']['api.required'] = 1;
81 $params['parent_group_id']['api.required'] = 1;
82 }
83
84 /**
85 * Removes specific nesting records.
86 *
87 * @param array $params
88 * Parameters array - allowed array keys include:.
89 * {@getfields GroupNesting_delete}
90 *
91 * @return array
92 * API Success or fail array
93 *
94 * @todo Work out the return value.
95 */
96 function civicrm_api3_group_nesting_delete($params) {
97
98 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
99 }