You are here

function protected_pages_send_email_validate in Protected Pages 7

Same name and namespace in other branches
  1. 7.2 protected_pages.admin.inc \protected_pages_send_email_validate()

Implements hook_validate().

File

./protected_pages.admin.inc, line 324
Provides page callbacks for configuration page.

Code

function protected_pages_send_email_validate($form, &$form_state) {
  $emails = explode(',', str_replace(array(
    "\r",
    "\n",
  ), ',', $form_state['values']['recipents']));
  foreach ($emails as $key => $email) {
    $email = trim($email);
    if ($email) {
      if (!valid_email_address($email)) {
        form_error($form['send_email_box']['recipents'], t('Invalid email address: @mail. Please correct this email.', array(
          '@mail' => $email,
        )));
        unset($emails[$key]);
      }
      else {
        $emails[$key] = $email;
      }
    }
    else {
      unset($emails[$key]);
    }
  }
  $form_state['validated_recipents'] = implode(', ', $emails);
}