function simplenews_confirm_subscription in Simplenews 6
Same name and namespace in other branches
- 5 simplenews.module \simplenews_confirm_subscription()
- 6.2 includes/simplenews.subscription.inc \simplenews_confirm_subscription()
- 7.2 includes/simplenews.subscription.inc \simplenews_confirm_subscription()
- 7 includes/simplenews.subscription.inc \simplenews_confirm_subscription()
Menu callback: confirm the user's (un)subscription request
This function is called by clicking the confirm link in the confirmation email or the unsubscribe link in the footer of the newsletter. It handles both subscription and unsubscription.
See also
simplenews_confirm_removal_form()
1 string reference to 'simplenews_confirm_subscription'
- simplenews_menu in ./
simplenews.module - Implementation of hook_menu().
File
- ./
simplenews.subscription.inc, line 99 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_confirm_subscription($op1 = NULL, $op2 = NULL) {
$md5 = drupal_substr($op2, 0, 10);
list($snid, $tid) = explode('t', drupal_substr($op2, 10));
$result = db_query('SELECT snid, mail FROM {simplenews_subscriptions} WHERE snid = %d', $snid);
if (!($subs = db_fetch_object($result))) {
drupal_not_found();
return;
}
// Prevent search engines from indexing this page.
drupal_set_html_head('<meta name="robots" content="noindex" />');
if ($md5 == drupal_substr(md5($subs->mail . simplenews_private_key()), 0, 10)) {
$newsletter = taxonomy_get_term($tid);
if ($op1 == 'remove') {
return drupal_get_form('simplenews_confirm_removal_form', $subs->mail, $newsletter);
}
elseif ($op1 == 'add') {
return drupal_get_form('simplenews_confirm_add_form', $subs->mail, $newsletter);
}
}
// If md5 didn't match, do a not found.
drupal_not_found();
return;
}