You are here

function simplenews_block_form_submit in Simplenews 7.2

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_block_form_submit()
  2. 6.2 includes/simplenews.subscription.inc \simplenews_block_form_submit()
  3. 6 simplenews.module \simplenews_block_form_submit()
  4. 7 includes/simplenews.subscription.inc \simplenews_block_form_submit()
1 string reference to 'simplenews_block_form_submit'
simplenews_block_form in includes/simplenews.subscription.inc
FAPI BLOCK subscription form.

File

includes/simplenews.subscription.inc, line 176
(Un)subscription and (un)subscription confirmation

Code

function simplenews_block_form_submit($form, &$form_state) {
  $newsletter_id = $form['#newsletter_id'];
  $account = simplenews_load_user_by_mail($form_state['values']['mail']);
  $confirm = simplenews_require_double_opt_in($newsletter_id, $account);
  switch ($form_state['values']['action']) {
    case 'subscribe':
      simplenews_subscribe($form_state['values']['mail'], $newsletter_id, $confirm, 'website');
      if ($confirm) {
        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('You have been subscribed.'));
      }
      break;
    case 'unsubscribe':
      simplenews_unsubscribe($form_state['values']['mail'], $newsletter_id, $confirm, 'website');
      if ($confirm) {
        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('You have been unsubscribed.'));
      }
      break;
  }
}