You are here

function protected_pages_send_email_validate in Protected Pages 7.2

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

Implements hook_validate().

File

./protected_pages.admin.inc, line 331
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);
}