function mailchimp_lists_execute_change in Mailchimp 7.2
Calls the appropriate API function, or adds to the queue, as appropriate.
@string $function - 'add', 'remove', or 'update'. Matches Queue operations. @mailchimp_lists $list - the list to update @string $mail - email address to update on the list @array $mergevars - merge variables array formatted for mailchimp API @account null $account - account that $mail came from, if non-anonymous call @mcapi_entity null &$mcapi - api object if loaded, to avoid extra API calls @queue null &$queue - the cron queue. If passed, this will force use of cron.
Return value
<boolean> Indicates whether the operation was successful.
4 calls to mailchimp_lists_execute_change()
- mailchimp_lists_process_subscribe_form_choices in modules/
mailchimp_lists/ mailchimp_lists.module - Processor for various list form submissions.
- mailchimp_lists_queue_existing in modules/
mailchimp_lists/ mailchimp_lists.module - Queue existing users in a list. Optionally, queue users to remove.
- mailchimp_lists_user_delete in modules/
mailchimp_lists/ mailchimp_lists.module - Implements hook_user_delete().
- mailchimp_lists_user_sync in modules/
mailchimp_lists/ mailchimp_lists.module - Update a user's setting in all required lists or add to cron queue.
File
- modules/
mailchimp_lists/ mailchimp_lists.module, line 677 - Mailchimp lists module.
Code
function mailchimp_lists_execute_change($function, $list, $mail, $mergevars = NULL, $account = NULL, $mcapi = NULL, &$queue = NULL) {
// If cron is enabled for this list, queue the function.
if ($list->settings['cron'] || isset($queue)) {
if (!isset($queue)) {
$queue = DrupalQueue::get(MAILCHIMP_QUEUE_CRON);
$queue
->createQueue();
}
$queue
->createItem(array(
'uid' => isset($account) ? $account->uid : NULL,
'email' => $mail,
'list_id' => $list->id,
'op' => $function,
'groupings' => isset($mergevars['GROUPINGS']) ? $mergevars['GROUPINGS'] : NULL,
));
$ret = TRUE;
}
else {
if (empty($mcapi)) {
$mcapi = mailchimp_get_api_object();
}
switch ($function) {
case 'add':
$ret = mailchimp_subscribe_user($list, $mail, $mergevars, TRUE, $mcapi);
break;
case 'remove':
$ret = mailchimp_unsubscribe_user($list, $mail, TRUE, $mcapi);
break;
case 'update':
$ret = mailchimp_update_user($list, $mail, $mergevars, TRUE, $mcapi);
break;
}
}
return $ret;
}