function simplenews_confirmation_get_changes_list in Simplenews 7
Same name and namespace in other branches
- 7.2 simplenews.module \simplenews_confirmation_get_changes_list()
Converts an array of subscription changes into descriptions.
Parameters
$subscriber: Simplenews subscriber object.
$changes: (Optional) Array of changes, each is an array with the keys action and tid. Defaults to $subscriber->changes, which contains the currently saved changes for the subscriber. No-op changes are removed from this array.
$langcode: (Optional) Specify the language of the description strings, defaults to the current language.
Return value
Array of description strings describing the changes.
2 calls to simplenews_confirmation_get_changes_list()
- simplenews_build_combined_mail in includes/
simplenews.mail.inc - Build subject and body of the subscribe confirmation email.
- simplenews_confirm_multi_form in includes/
simplenews.subscription.inc - Generate the confirm subscription form.
File
- ./
simplenews.module, line 2906 - Simplenews node handling, sent email, newsletter block and general hooks
Code
function simplenews_confirmation_get_changes_list($subscriber, &$changes = NULL, $langcode = NULL) {
if (empty($langcode)) {
global $language;
$langcode = $language->language;
}
if (empty($changes)) {
$changes = $subscriber->changes;
}
$changes_list = array();
foreach ($changes as $tid => $action) {
$subscribed = simplenews_user_is_subscribed($subscriber->mail, $tid);
// Get text for each possible combination.
if ($action == 'subscribe' && !$subscribed) {
$line = simplenews_subscription_confirmation_text('combined_line_subscribe_unsubscribed', $langcode);
}
elseif ($action == 'subscribe' && $subscribed) {
$line = simplenews_subscription_confirmation_text('combined_line_subscribe_subscribed', $langcode);
}
elseif ($action == 'unsubscribe' && !$subscribed) {
$line = simplenews_subscription_confirmation_text('combined_line_unsubscribe_unsubscribed', $langcode);
}
elseif ($action == 'unsubscribe' && $subscribed) {
$line = simplenews_subscription_confirmation_text('combined_line_unsubscribe_subscribed', $langcode);
}
$category_context = array(
'simplenews_subscriber' => $subscriber,
'category' => simplenews_category_load($tid),
);
$changes_list[$tid] = token_replace($line, $category_context, array(
'sanitize' => FALSE,
));
}
return $changes_list;
}