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