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