Commit | Line | Data |
---|---|---|
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 | ||
41 | require_once 'CRM/Contact/BAO/GroupNesting.php'; | |
42 | ||
43 | /** | |
44 | * Provides group nesting record(s) given parent and/or child id. | |
45 | * | |
46 | * @param array $params an array containing at least child_group_id or parent_group_id | |
47 | * {@getfields GroupNesting_get} | |
48 | * | |
49 | * @return array list of group nesting records | |
50 | */ | |
51 | function civicrm_api3_group_nesting_get($params) { | |
52 | ||
53 | return _civicrm_api3_basic_get('CRM_Contact_DAO_GroupNesting', $params); | |
54 | } | |
55 | ||
56 | /** | |
57 | * Creates group nesting record for given parent and child id. | |
58 | * Parent and child groups need to exist. | |
59 | * | |
60 | * @param array $params parameters array - allowed array keys include: | |
61 | * | |
62 | * @return array TBD | |
63 | * {@getfields GroupNesting_create | |
64 | * @todo Work out the return value. | |
65 | */ | |
66 | function 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 TO |
76 | * Adjust Metadata for Create action |
77 | * | |
78 | * The metadata is used for setting defaults, documentation & validation | |
79 | * @param array $params array or parameters determined by getfields | |
80 | */ | |
81 | function _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 | * | |
89 | * @param array $params parameters array - allowed array keys include: | |
90 | * {@getfields GroupNesting_delete} | |
91 | * | |
92 | * @return array 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 | } | |
100 |