Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
39de6fd5 | 5 | | CiviCRM version 4.6 | |
6a488035 | 6 | +--------------------------------------------------------------------+ |
731a0992 | 7 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
11 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
12 | | under the terms of the GNU Affero General Public License | | |
13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
14 | | | | |
15 | | CiviCRM is distributed in the hope that it will be useful, but | | |
16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
18 | | See the GNU Affero General Public License for more details. | | |
19 | | | | |
20 | | You should have received a copy of the GNU Affero General Public | | |
21 | | License and the CiviCRM Licensing Exception along | | |
22 | | with this program; if not, contact CiviCRM LLC | | |
23 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
24 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
26 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * | |
31 | * APIv3 functions for registering/processing mailing group events. | |
32 | * | |
33 | * @package CiviCRM_APIv3 | |
34 | * @subpackage API_MailerGroup | |
731a0992 | 35 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
36 | * $Id$ |
37 | * | |
38 | */ | |
39 | ||
a14e9d08 CW |
40 | /** |
41 | * @deprecated api notice | |
a6c01b45 CW |
42 | * @return string |
43 | * to indicate this entire api entity is deprecated | |
a14e9d08 CW |
44 | */ |
45 | function _civicrm_api3_mailing_group_deprecation() { | |
46 | return 'The mailing_group api is deprecated. Use the mailing_event apis instead.'; | |
47 | } | |
48 | ||
6a488035 TO |
49 | /** |
50 | * Handle an unsubscribe event | |
51 | * @deprecated | |
52 | * | |
53 | * @param array $params | |
54 | * | |
55 | * @return array | |
56 | */ | |
57 | function civicrm_api3_mailing_group_event_unsubscribe($params) { | |
7e6e8bd6 | 58 | return civicrm_api('mailing_event_unsubscribe', 'create', $params); |
6a488035 TO |
59 | } |
60 | ||
61 | /** | |
62 | * Handle a site-level unsubscribe event | |
bafd17fb | 63 | * @deprecated |
6a488035 TO |
64 | * |
65 | * @param array $params | |
66 | * | |
67 | * @return array | |
68 | */ | |
69 | function civicrm_api3_mailing_group_event_domain_unsubscribe($params) { | |
7e6e8bd6 TO |
70 | $params['org_unsubscribe'] = 1; |
71 | return civicrm_api('mailing_event_unsubscribe', 'create', $params); | |
6a488035 TO |
72 | } |
73 | ||
74 | /** | |
75 | * Handle a resubscription event | |
76 | * @deprecated | |
77 | * | |
78 | * @param array $params | |
79 | * | |
80 | * @return array | |
81 | */ | |
82 | function civicrm_api3_mailing_group_event_resubscribe($params) { | |
7e6e8bd6 | 83 | return civicrm_api('mailing_event_resubscribe', 'create', $params); |
6a488035 TO |
84 | } |
85 | ||
86 | /** | |
87 | * Handle a subscription event | |
88 | * @deprecated | |
89 | * | |
90 | * @param array $params | |
91 | * | |
92 | * @return array | |
93 | */ | |
94 | function civicrm_api3_mailing_group_event_subscribe($params) { | |
7e6e8bd6 | 95 | return civicrm_api('mailing_event_subscribe', 'create', $params); |
6a488035 TO |
96 | } |
97 | ||
21eb0c57 TO |
98 | function civicrm_api3_mailing_group_create($params) { |
99 | return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
100 | } | |
101 | ||
aa1b1481 | 102 | /** |
c490a46a | 103 | * @param array $params |
aa1b1481 EM |
104 | * |
105 | * @return array | |
106 | */ | |
f27a0a8e | 107 | function civicrm_api3_mailing_group_get($params) { |
108 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
109 | } | |
110 | ||
f27a0a8e | 111 | function civicrm_api3_mailing_group_delete($params, $ids = array()) { |
112 | return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
113 | } | |
114 | ||
6a488035 | 115 | function civicrm_api3_mailing_group_getfields($params) { |
7e6e8bd6 TO |
116 | $dao = _civicrm_api3_get_DAO('Subscribe'); |
117 | $d = new $dao(); | |
118 | $fields = $d->fields(); | |
119 | $d->free(); | |
6a488035 | 120 | |
7e6e8bd6 TO |
121 | $dao = _civicrm_api3_get_DAO('Unsubscribe'); |
122 | $d = new $dao(); | |
123 | $fields = $fields + $d->fields(); | |
124 | $d->free(); | |
6a488035 | 125 | |
7e6e8bd6 TO |
126 | // CRM-13830 - prevent the api wrapper from helping out with pseudoconstants |
127 | // Since these fields don't belong to this entity it will fail | |
128 | foreach ($fields as &$field) { | |
129 | unset($field['pseudoconstant']); | |
130 | } | |
bafd17fb | 131 | |
77d80c9f | 132 | return civicrm_api3_create_success($fields, $params, 'mailing_group', 'getfields'); |
6a488035 | 133 | } |