3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
14 * APIv3 functions for registering/processing mailing group events.
16 * @package CiviCRM_APIv3
20 * Unsubscribe from mailing group.
22 * @param array $params
23 * Array per getfields metadata.
28 function civicrm_api3_mailing_event_unsubscribe_create($params) {
30 $job = $params['job_id'];
31 $queue = $params['event_queue_id'];
32 $hash = $params['hash'];
33 if (empty($params['org_unsubscribe'])) {
34 $groups = CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_mailing($job, $queue, $hash);
36 CRM_Mailing_Event_BAO_Unsubscribe
::send_unsub_response($queue, $groups, FALSE, $job);
37 return civicrm_api3_create_success($params);
41 $unsubs = CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_domain($job, $queue, $hash);
43 return civicrm_api3_create_error('Domain Queue event could not be found');
46 CRM_Mailing_Event_BAO_Unsubscribe
::send_unsub_response($queue, NULL, TRUE, $job);
47 return civicrm_api3_create_success($params);
50 return civicrm_api3_create_error('Queue event could not be found');
54 * Adjust Metadata for Create action.
56 * The metadata is used for setting defaults, documentation & validation.
58 * @param array $params
59 * Array of parameters determined by getfields.
61 function _civicrm_api3_mailing_event_unsubscribe_create_spec(&$params) {
64 'title' => 'Mailing Job ID',
65 'type' => CRM_Utils_Type
::T_INT
,
69 'title' => 'Mailing Hash',
70 'type' => CRM_Utils_Type
::T_STRING
,
72 $params['event_queue_id'] = [
74 'title' => 'Mailing Queue ID',
75 'type' => CRM_Utils_Type
::T_INT
,