| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.6 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
| 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 | +--------------------------------------------------------------------+ |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * APIv3 functions for registering/processing mailing group events. |
| 30 | * |
| 31 | * @deprecated |
| 32 | * @package CiviCRM_APIv3 |
| 33 | */ |
| 34 | |
| 35 | /** |
| 36 | * Declare deprecated functions. |
| 37 | * |
| 38 | * @deprecated api notice |
| 39 | * @return string |
| 40 | * to indicate this entire api entity is deprecated |
| 41 | */ |
| 42 | function _civicrm_api3_mailing_group_deprecation() { |
| 43 | return 'The MailingGroup api is deprecated. Use the mailing_event apis instead.'; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Handle an unsubscribe event. |
| 48 | * |
| 49 | * @deprecated |
| 50 | * |
| 51 | * @param array $params |
| 52 | * |
| 53 | * @return array |
| 54 | */ |
| 55 | function civicrm_api3_mailing_group_event_unsubscribe($params) { |
| 56 | return civicrm_api('mailing_event_unsubscribe', 'create', $params); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Handle a site-level unsubscribe event. |
| 61 | * |
| 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 re-subscription event. |
| 75 | * |
| 76 | * @deprecated |
| 77 | * |
| 78 | * @param array $params |
| 79 | * |
| 80 | * @return array |
| 81 | */ |
| 82 | function civicrm_api3_mailing_group_event_resubscribe($params) { |
| 83 | return civicrm_api('mailing_event_resubscribe', 'create', $params); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Handle a subscription event. |
| 88 | * |
| 89 | * @deprecated |
| 90 | * |
| 91 | * @param array $params |
| 92 | * |
| 93 | * @return array |
| 94 | */ |
| 95 | function civicrm_api3_mailing_group_event_subscribe($params) { |
| 96 | return civicrm_api('mailing_event_subscribe', 'create', $params); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Create mailing group. |
| 101 | * |
| 102 | * @param array $params |
| 103 | * |
| 104 | * @return array |
| 105 | * @throws \API_Exception |
| 106 | */ |
| 107 | function civicrm_api3_mailing_group_create($params) { |
| 108 | return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Get mailing group. |
| 113 | * |
| 114 | * @param array $params |
| 115 | * |
| 116 | * @return array |
| 117 | */ |
| 118 | function civicrm_api3_mailing_group_get($params) { |
| 119 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Delete mailing group. |
| 124 | * |
| 125 | * @param array $params |
| 126 | * |
| 127 | * @return array |
| 128 | * @throws \API_Exception |
| 129 | */ |
| 130 | function civicrm_api3_mailing_group_delete($params) { |
| 131 | return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Get metadata for mailing group functions. |
| 136 | * |
| 137 | * @param array $params |
| 138 | * |
| 139 | * @return array |
| 140 | */ |
| 141 | function civicrm_api3_mailing_group_getfields($params) { |
| 142 | $dao = _civicrm_api3_get_DAO('Subscribe'); |
| 143 | $d = new $dao(); |
| 144 | $fields = $d->fields(); |
| 145 | $d->free(); |
| 146 | |
| 147 | $dao = _civicrm_api3_get_DAO('Unsubscribe'); |
| 148 | $d = new $dao(); |
| 149 | $fields = $fields + $d->fields(); |
| 150 | $d->free(); |
| 151 | |
| 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 | } |
| 157 | |
| 158 | return civicrm_api3_create_success($fields, $params, 'MailingGroup', 'getfields'); |
| 159 | } |