function simplenews_subscriptions_admin_form_validate in Simplenews 6.2
Same name and namespace in other branches
- 7.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_validate()
- 7 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_validate()
FAPI ADMIN subscription form_validate.
1 string reference to 'simplenews_subscriptions_admin_form_validate'
- simplenews_subscriptions_admin_form in includes/
simplenews.subscription.inc - FAPI ADMIN subscription form.
File
- includes/
simplenews.subscription.inc, line 711 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscriptions_admin_form_validate($form, &$form_state) {
global $user;
if (isset($user->mail) && $user->mail == $form_state['values']['mail']) {
$account = $user;
}
else {
$account = (object) array(
'mail' => $form_state['values']['mail'],
);
}
$subscription = simplenews_get_subscription($account);
$valid_email = simplenews_valid_email_address($form_state['values']['mail']);
if (!$valid_email) {
form_set_error('mail', t('The email address you supplied is not valid.'));
}
$checked_newsletters = array_filter($form_state['values']['newsletters']);
if (!count($checked_newsletters) && $subscription->uid) {
form_set_error('newsletters', t('You must select at least one newsletter.'));
}
$languages = language_list('enabled');
if (!empty($form_state['values']['language']) && !isset($languages[1][$form_state['values']['language']])) {
form_set_error('language', t('Please choose a language from the list.'));
}
}