function simplenews_subscriptions_page_form_submit in Simplenews 7.2
Same name and namespace in other branches
- 6.2 includes/simplenews.subscription.inc \simplenews_subscriptions_page_form_submit()
- 7 includes/simplenews.subscription.inc \simplenews_subscriptions_page_form_submit()
FAPI PAGE subscription form_submit.
2 string references to 'simplenews_subscriptions_page_form_submit'
- simplenews_subscriptions_multi_block_form in includes/
simplenews.subscription.inc - FAPI MULTI BLOCK subscription form.
- simplenews_subscriptions_page_form in includes/
simplenews.subscription.inc - FAPI PAGE subscription form.
File
- includes/
simplenews.subscription.inc, line 320 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscriptions_page_form_submit($form, &$form_state) {
$mail = $form_state['values']['mail'];
$account = simplenews_load_user_by_mail($mail);
// Group confirmation mails as necessary and configured.
simplenews_confirmation_combine(TRUE);
switch ($form_state['values']['op']) {
case t('Update'):
// We first subscribe, then unsubscribe. This prevents deletion of subscriptions
// when unsubscribed from the
arsort($form_state['values']['newsletters'], SORT_NUMERIC);
foreach ($form_state['values']['newsletters'] as $newsletter_id => $checked) {
if ($checked) {
simplenews_subscribe($mail, $newsletter_id, FALSE, 'website');
}
else {
simplenews_unsubscribe($mail, $newsletter_id, FALSE, 'website');
}
}
drupal_set_message(t('The newsletter subscriptions for %mail have been updated.', array(
'%mail' => $form_state['values']['mail'],
)));
break;
case t('Subscribe'):
foreach ($form_state['values']['newsletters'] as $newsletter_id => $checked) {
if ($checked) {
$confirm = simplenews_require_double_opt_in($newsletter_id, $account);
simplenews_subscribe($mail, $newsletter_id, $confirm, 'website');
}
}
if (simplenews_confirmation_send_combined()) {
drupal_set_message(t('You will receive a confirmation e-mail shortly containing further instructions on how to complete your subscription.'));
}
else {
drupal_set_message(t('The newsletter subscriptions for %mail have been updated.', array(
'%mail' => $form_state['values']['mail'],
)));
}
break;
case t('Unsubscribe'):
foreach ($form_state['values']['newsletters'] as $newsletter_id => $checked) {
if ($checked) {
$confirm = simplenews_require_double_opt_in($newsletter_id, $account);
simplenews_unsubscribe($mail, $newsletter_id, $confirm, 'website');
}
}
if (simplenews_confirmation_send_combined()) {
drupal_set_message(t('You will receive a confirmation e-mail shortly containing further instructions on how to cancel your subscription.'));
}
else {
drupal_set_message(t('The newsletter subscriptions for %mail have been updated.', array(
'%mail' => $form_state['values']['mail'],
)));
}
break;
}
}