Merge remote-tracking branch 'origin/4.5' into 4.5-master-2015-02-24-17-24-05
[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/**
6a488035
TO
29 * APIv3 functions for registering/processing mailing group events.
30 *
c28e1768 31 * @deprecated
6a488035 32 * @package CiviCRM_APIv3
6a488035
TO
33 */
34
a14e9d08 35/**
22242c87
EM
36 * Declare deprecated functions.
37 *
a14e9d08 38 * @deprecated api notice
a6c01b45 39 * @return string
72b3a70c 40 * to indicate this entire api entity is deprecated
a14e9d08
CW
41 */
42function _civicrm_api3_mailing_group_deprecation() {
244bbdd8 43 return 'The MailingGroup api is deprecated. Use the mailing_event apis instead.';
a14e9d08
CW
44}
45
6a488035 46/**
9d32e6f7
EM
47 * Handle an unsubscribe event.
48 *
6a488035
TO
49 * @deprecated
50 *
51 * @param array $params
52 *
53 * @return array
54 */
55function civicrm_api3_mailing_group_event_unsubscribe($params) {
7e6e8bd6 56 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
6a488035
TO
57}
58
59/**
9d32e6f7
EM
60 * Handle a site-level unsubscribe event.
61 *
bafd17fb 62 * @deprecated
6a488035
TO
63 *
64 * @param array $params
65 *
66 * @return array
67 */
68function civicrm_api3_mailing_group_event_domain_unsubscribe($params) {
7e6e8bd6
TO
69 $params['org_unsubscribe'] = 1;
70 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
6a488035
TO
71}
72
73/**
d1b0d05e
EM
74 * Handle a re-subscription event.
75 *
6a488035
TO
76 * @deprecated
77 *
78 * @param array $params
79 *
80 * @return array
81 */
82function civicrm_api3_mailing_group_event_resubscribe($params) {
7e6e8bd6 83 return civicrm_api('mailing_event_resubscribe', 'create', $params);
6a488035
TO
84}
85
86/**
dc64d047
EM
87 * Handle a subscription event.
88 *
6a488035
TO
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 99/**
dc64d047
EM
100 * Create mailing group.
101 *
c23f45d3 102 * @param array $params
dc64d047 103 *
c23f45d3
EM
104 * @return array
105 * @throws \API_Exception
106 */
21eb0c57
TO
107function civicrm_api3_mailing_group_create($params) {
108 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
109}
110
aa1b1481 111/**
dc64d047
EM
112 * Get mailing group.
113 *
c490a46a 114 * @param array $params
aa1b1481
EM
115 *
116 * @return array
117 */
f27a0a8e 118function civicrm_api3_mailing_group_get($params) {
119 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
120}
121
c23f45d3 122/**
22242c87
EM
123 * Delete mailing group.
124 *
c23f45d3 125 * @param array $params
22242c87 126 *
c23f45d3
EM
127 * @return array
128 * @throws \API_Exception
129 */
130function civicrm_api3_mailing_group_delete($params) {
f27a0a8e 131 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
132}
133
c23f45d3 134/**
dc64d047
EM
135 * Get metadata for mailing group functions.
136 *
c23f45d3 137 * @param array $params
22242c87 138 *
c23f45d3
EM
139 * @return array
140 */
6a488035 141function civicrm_api3_mailing_group_getfields($params) {
7e6e8bd6
TO
142 $dao = _civicrm_api3_get_DAO('Subscribe');
143 $d = new $dao();
144 $fields = $d->fields();
145 $d->free();
6a488035 146
7e6e8bd6
TO
147 $dao = _civicrm_api3_get_DAO('Unsubscribe');
148 $d = new $dao();
149 $fields = $fields + $d->fields();
150 $d->free();
6a488035 151
7e6e8bd6
TO
152 // CRM-13830 - prevent the api wrapper from helping out with pseudoconstants
153 // Since these fields don't belong to this entity it will fail
154 foreach ($fields as &$field) {
155 unset($field['pseudoconstant']);
156 }
bafd17fb 157
244bbdd8 158 return civicrm_api3_create_success($fields, $params, 'MailingGroup', 'getfields');
6a488035 159}