Merge pull request #18950 from MegaphoneJon/event-44
[civicrm-core.git] / api / v3 / GroupOrganization.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
a30c801b 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
a30c801b
TO
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 |
6a488035
TO
9 +--------------------------------------------------------------------+
10 */
11
12/**
c28e1768 13 * This api exposes the relationships between organizations and CiviCRM groups.
6a488035
TO
14 *
15 * @package CiviCRM_APIv3
6a488035
TO
16 */
17
6a488035 18/**
9d32e6f7 19 * Get group organization record/s.
6a488035 20 *
cf470720
TO
21 * @param array $params
22 * Name value pair of contact information.
6a488035 23 *
a6c01b45 24 * @return array
9d32e6f7 25 * list of groups, given contact subscribed to
6a488035
TO
26 */
27function civicrm_api3_group_organization_get($params) {
28 return _civicrm_api3_basic_get('CRM_Contact_DAO_GroupOrganization', $params);
29}
30
31/**
9d32e6f7 32 * Create group organization record.
6a488035 33 *
16b10e64 34 * @param array $params
cf470720 35 * Array.
6a488035
TO
36 *
37 * @return array
6a488035
TO
38 */
39function civicrm_api3_group_organization_create($params) {
40
1237d8d7 41 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'GroupOrganization');
6a488035
TO
42}
43
11e09c59 44/**
0aa0303c
EM
45 * Adjust Metadata for Create action.
46 *
47 * The metadata is used for setting defaults, documentation & validation.
1c88e578 48 *
cf470720 49 * @param array $params
b081365f 50 * Array of parameters determined by getfields.
6a488035
TO
51 */
52function _civicrm_api3_group_organization_create_spec(&$params) {
53 $params['organization_id']['api.required'] = 1;
54 $params['group_id']['api.required'] = 1;
55}
56
57/**
9d32e6f7 58 * Deletes an existing Group Organization.
6a488035
TO
59 *
60 * This API is used for deleting a Group Organization
61 *
cf470720
TO
62 * @param array $params
63 * With 'id' = ID of the Group Organization to be deleted.
6a488035 64 *
a6c01b45 65 * @return array
72b3a70c 66 * API Result
6a488035
TO
67 */
68function civicrm_api3_group_organization_delete($params) {
69
70 $result = CRM_Contact_BAO_GroupOrganization::deleteGroupOrganization($params['id']);
71 return $result ? civicrm_api3_create_success('Deleted Group Organization successfully') : civicrm_api3_create_error('Could not delete Group Organization');
72}