Merge pull request #15916 from civicrm/5.20
[civicrm-core.git] / api / v3 / GroupNesting.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * This api exposes CiviCRM GroupNesting.
14 *
15 * This defines parent/child relationships between nested groups.
16 *
17 * @package CiviCRM_APIv3
18 */
19
20 /**
21 * Provides group nesting record(s) given parent and/or child id.
22 *
23 * @param array $params
24 * An array containing at least child_group_id or parent_group_id.
25 *
26 * @return array
27 * list of group nesting records
28 */
29 function civicrm_api3_group_nesting_get($params) {
30 return _civicrm_api3_basic_get('CRM_Contact_DAO_GroupNesting', $params);
31 }
32
33 /**
34 * Creates group nesting record for given parent and child id.
35 *
36 * Parent and child groups need to exist.
37 *
38 * @param array $params
39 * Parameters array - allowed array keys include:.
40 *
41 * @return array
42 * API success array
43 */
44 function civicrm_api3_group_nesting_create($params) {
45 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'GroupNesting');
46 }
47
48 /**
49 * Adjust Metadata for Create action.
50 *
51 * The metadata is used for setting defaults, documentation & validation.
52 *
53 * @param array $params
54 * Array of parameters determined by getfields.
55 */
56 function _civicrm_api3_group_nesting_create_spec(&$params) {
57 $params['child_group_id']['api.required'] = 1;
58 $params['parent_group_id']['api.required'] = 1;
59 }
60
61 /**
62 * Removes specific nesting records.
63 *
64 * @param array $params
65 *
66 * @return array
67 * API Success or fail array
68 *
69 * @todo Work out the return value.
70 */
71 function civicrm_api3_group_nesting_delete($params) {
72 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
73 }