You are here

function simplenews_subscriptions_admin_form_submit in Simplenews 7

Same name and namespace in other branches
  1. 6.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_submit()
  2. 7.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_submit()

FAPI ADMIN subscription form_submit.

1 string reference to 'simplenews_subscriptions_admin_form_submit'
simplenews_subscriptions_admin_form in includes/simplenews.subscription.inc
FAPI ADMIN subscription form.

File

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

Code

function simplenews_subscriptions_admin_form_submit($form, &$form_state) {
  $subscriber = simplenews_subscriber_load_by_mail($form_state['values']['mail']);

  // update subscriptions
  arsort($form_state['values']['newsletters'], SORT_NUMERIC);
  foreach ($form_state['values']['newsletters'] as $tid => $checked) {
    if ($checked) {
      simplenews_subscribe_user($form_state['values']['mail'], $tid, FALSE, 'website');
    }
    else {
      simplenews_unsubscribe_user($form_state['values']['mail'], $tid, FALSE, 'website');
    }
  }

  // update subscriber
  $data = array();
  $subscriber->activated = $form_state['values']['activated'];
  if (!$subscriber->uid) {
    if (isset($form_state['values']['language'])) {
      $subscriber->language = $form_state['values']['language'];
    }
  }
  simplenews_subscriber_save($subscriber);
  drupal_set_message(t('The newsletter subscriptions for %mail have been updated.', array(
    '%mail' => $form_state['values']['mail'],
  )));
}