more comment fixes
[civicrm-core.git] / api / v3 / MailingGroup.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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * APIv3 functions for registering/processing mailing group events.
31 *
32 * @package CiviCRM_APIv3
33 * @subpackage API_MailerGroup
731a0992 34 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
35 * $Id$
36 *
37 */
38
a14e9d08
CW
39/**
40 * @deprecated api notice
a6c01b45 41 * @return string
72b3a70c 42 * to indicate this entire api entity is deprecated
a14e9d08
CW
43 */
44function _civicrm_api3_mailing_group_deprecation() {
45 return 'The mailing_group api is deprecated. Use the mailing_event apis instead.';
46}
47
6a488035 48/**
9d32e6f7
EM
49 * Handle an unsubscribe event.
50 *
6a488035
TO
51 * @deprecated
52 *
53 * @param array $params
54 *
55 * @return array
56 */
57function civicrm_api3_mailing_group_event_unsubscribe($params) {
7e6e8bd6 58 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
6a488035
TO
59}
60
61/**
9d32e6f7
EM
62 * Handle a site-level unsubscribe event.
63 *
bafd17fb 64 * @deprecated
6a488035
TO
65 *
66 * @param array $params
67 *
68 * @return array
69 */
70function civicrm_api3_mailing_group_event_domain_unsubscribe($params) {
7e6e8bd6
TO
71 $params['org_unsubscribe'] = 1;
72 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
6a488035
TO
73}
74
75/**
76 * Handle a resubscription event
77 * @deprecated
78 *
79 * @param array $params
80 *
81 * @return array
82 */
83function civicrm_api3_mailing_group_event_resubscribe($params) {
7e6e8bd6 84 return civicrm_api('mailing_event_resubscribe', 'create', $params);
6a488035
TO
85}
86
87/**
88 * Handle a subscription event
89 * @deprecated
90 *
91 * @param array $params
92 *
93 * @return array
94 */
95function civicrm_api3_mailing_group_event_subscribe($params) {
7e6e8bd6 96 return civicrm_api('mailing_event_subscribe', 'create', $params);
6a488035
TO
97}
98
c23f45d3
EM
99/**
100 * @param array $params
101 * @return array
102 * @throws \API_Exception
103 */
21eb0c57
TO
104function civicrm_api3_mailing_group_create($params) {
105 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
106}
107
aa1b1481 108/**
c490a46a 109 * @param array $params
aa1b1481
EM
110 *
111 * @return array
112 */
f27a0a8e 113function civicrm_api3_mailing_group_get($params) {
114 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
115}
116
c23f45d3
EM
117/**
118 * @param array $params
119 * @return array
120 * @throws \API_Exception
121 */
122function civicrm_api3_mailing_group_delete($params) {
f27a0a8e 123 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
124}
125
c23f45d3
EM
126/**
127 * @param array $params
128 * @return array
129 */
6a488035 130function civicrm_api3_mailing_group_getfields($params) {
7e6e8bd6
TO
131 $dao = _civicrm_api3_get_DAO('Subscribe');
132 $d = new $dao();
133 $fields = $d->fields();
134 $d->free();
6a488035 135
7e6e8bd6
TO
136 $dao = _civicrm_api3_get_DAO('Unsubscribe');
137 $d = new $dao();
138 $fields = $fields + $d->fields();
139 $d->free();
6a488035 140
7e6e8bd6
TO
141 // CRM-13830 - prevent the api wrapper from helping out with pseudoconstants
142 // Since these fields don't belong to this entity it will fail
143 foreach ($fields as &$field) {
144 unset($field['pseudoconstant']);
145 }
bafd17fb 146
77d80c9f 147 return civicrm_api3_create_success($fields, $params, 'mailing_group', 'getfields');
6a488035 148}