Merge pull request #766 from eileenmcnaughton/test-fix
[civicrm-core.git] / api / v3 / GroupNesting.php
CommitLineData
6a488035
TO
1<?php
2// $Id$
3
4/*
5 +--------------------------------------------------------------------+
6 | CiviCRM version 4.3 |
7 +--------------------------------------------------------------------+
8 | Copyright CiviCRM LLC (c) 2004-2013 |
9 +--------------------------------------------------------------------+
10 | This file is a part of CiviCRM. |
11 | |
12 | CiviCRM is free software; you can copy, modify, and distribute it |
13 | under the terms of the GNU Affero General Public License |
14 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | |
16 | CiviCRM is distributed in the hope that it will be useful, but |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
19 | See the GNU Affero General Public License for more details. |
20 | |
21 | You should have received a copy of the GNU Affero General Public |
22 | License and the CiviCRM Licensing Exception along |
23 | with this program; if not, contact CiviCRM LLC |
24 | at info[AT]civicrm[DOT]org. If you have questions about the |
25 | GNU Affero General Public License or the licensing of CiviCRM, |
26 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
27 +--------------------------------------------------------------------+
28 */
29
30/**
31 * File for the CiviCRM APIv3 group nesting functions
32 *
33 * @package CiviCRM_APIv3
34 * @subpackage API_Group
35 *
36 * @copyright CiviCRM LLC (c) 2004-2013
37 * @version $Id: GroupNesting.php 21624 2009-08-07 22:02:55Z wmorgan $
38 *
39 */
40
6a488035
TO
41/**
42 * Provides group nesting record(s) given parent and/or child id.
43 *
44 * @param array $params an array containing at least child_group_id or parent_group_id
45 * {@getfields GroupNesting_get}
46 *
47 * @return array list of group nesting records
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 *
58 * @param array $params parameters array - allowed array keys include:
59 *
60 * @return array TBD
61 * {@getfields GroupNesting_create
62 * @todo Work out the return value.
63 */
64function civicrm_api3_group_nesting_create($params) {
65
66 CRM_Contact_BAO_GroupNesting::add($params['parent_group_id'], $params['child_group_id']);
67
68 // FIXME: CRM_Contact_BAO_GroupNesting requires some work
69 $result = array('is_error' => 0);
70 return civicrm_api3_create_success($result, $params);
71}
11e09c59
TO
72
73/**
6a488035
TO
74 * Adjust Metadata for Create action
75 *
76 * The metadata is used for setting defaults, documentation & validation
77 * @param array $params array or parameters determined by getfields
78 */
79function _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 parameters array - allowed array keys include:
88 * {@getfields GroupNesting_delete}
89 *
90 * @return array API Success or fail array
91 *
92 * @todo Work out the return value.
93 */
94function civicrm_api3_group_nesting_delete($params) {
95
96 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
97}
98