Merge pull request #4771 from pratikshad/CRM-15409
[civicrm-core.git] / api / v3 / MailingGroup.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
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
35 * @copyright CiviCRM LLC (c) 2004-2014
36 * $Id$
37 *
38 */
39
40 /**
41 * @deprecated api notice
42 * @return string to indicate this entire api entity is deprecated
43 */
44 function _civicrm_api3_mailing_group_deprecation() {
45 return 'The mailing_group api is deprecated. Use the mailing_event apis instead.';
46 }
47
48 /**
49 * Handle an unsubscribe event
50 * @deprecated
51 *
52 * @param array $params
53 *
54 * @return array
55 */
56 function civicrm_api3_mailing_group_event_unsubscribe($params) {
57 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
58 }
59
60 /**
61 * Handle a site-level unsubscribe event
62 * @deprecated
63 *
64 * @param array $params
65 *
66 * @return array
67 */
68 function civicrm_api3_mailing_group_event_domain_unsubscribe($params) {
69 $params['org_unsubscribe'] = 1;
70 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
71 }
72
73 /**
74 * Handle a resubscription event
75 * @deprecated
76 *
77 * @param array $params
78 *
79 * @return array
80 */
81 function civicrm_api3_mailing_group_event_resubscribe($params) {
82 return civicrm_api('mailing_event_resubscribe', 'create', $params);
83 }
84
85 /**
86 * Handle a subscription event
87 * @deprecated
88 *
89 * @param array $params
90 *
91 * @return array
92 */
93 function civicrm_api3_mailing_group_event_subscribe($params) {
94 return civicrm_api('mailing_event_subscribe', 'create', $params);
95 }
96
97 function civicrm_api3_mailing_group_create($params) {
98 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
99 }
100
101 /**
102 * @param array $params
103 *
104 * @return array
105 */
106 function civicrm_api3_mailing_group_get($params) {
107 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
108 }
109
110 function civicrm_api3_mailing_group_delete($params, $ids = array()) {
111 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
112 }
113
114 function civicrm_api3_mailing_group_getfields($params) {
115 $dao = _civicrm_api3_get_DAO('Subscribe');
116 $d = new $dao();
117 $fields = $d->fields();
118 $d->free();
119
120 $dao = _civicrm_api3_get_DAO('Unsubscribe');
121 $d = new $dao();
122 $fields = $fields + $d->fields();
123 $d->free();
124
125 // CRM-13830 - prevent the api wrapper from helping out with pseudoconstants
126 // Since these fields don't belong to this entity it will fail
127 foreach ($fields as &$field) {
128 unset($field['pseudoconstant']);
129 }
130
131 return civicrm_api3_create_success($fields, $params, 'mailing_group', 'getfields');
132 }