Merge pull request #4352 from colemanw/CRM-15450
[civicrm-core.git] / api / v3 / MailingGroup.php
CommitLineData
6a488035 1<?php
6a488035
TO
2
3/*
4 +--------------------------------------------------------------------+
731a0992 5 | CiviCRM version 4.5 |
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
6a488035
TO
40/**
41 * Handle an unsubscribe event
42 * @deprecated
43 *
44 * @param array $params
45 *
46 * @return array
47 */
48function civicrm_api3_mailing_group_event_unsubscribe($params) {
49 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
50}
51
52/**
53 * Handle a site-level unsubscribe event
bafd17fb 54 * @deprecated
6a488035
TO
55 *
56 * @param array $params
57 *
58 * @return array
59 */
60function civicrm_api3_mailing_group_event_domain_unsubscribe($params) {
61 $params['org_unsubscribe'] = 1;
62 return civicrm_api('mailing_event_unsubscribe', 'create', $params);
63}
64
65/**
66 * Handle a resubscription event
67 * @deprecated
68 *
69 * @param array $params
70 *
71 * @return array
72 */
73function civicrm_api3_mailing_group_event_resubscribe($params) {
74 return civicrm_api('mailing_event_resubscribe', 'create', $params);
75}
76
77/**
78 * Handle a subscription event
79 * @deprecated
80 *
81 * @param array $params
82 *
83 * @return array
84 */
85function civicrm_api3_mailing_group_event_subscribe($params) {
86 return civicrm_api('mailing_event_subscribe', 'create', $params);
87}
88
aa1b1481
EM
89/**
90 * @param $params
91 *
92 * @return array
93 */
6a488035
TO
94function civicrm_api3_mailing_group_getfields($params) {
95 $dao = _civicrm_api3_get_DAO('Subscribe');
6a488035
TO
96 $d = new $dao();
97 $fields = $d->fields();
98 $d->free();
99
100 $dao = _civicrm_api3_get_DAO('Unsubscribe');
6a488035
TO
101 $d = new $dao();
102 $fields = $fields + $d->fields();
103 $d->free();
104
bafd17fb
CW
105 // CRM-13830 - prevent the api wrapper from helping out with pseudoconstants
106 // Since these fields don't belong to this entity it will fail
107 foreach ($fields as &$field) {
108 unset($field['pseudoconstant']);
109 }
110
6a488035
TO
111 return civicrm_api3_create_success($fields);
112}
113