You are here

function simplenews_node_tab_send_form_validate in Simplenews 6.2

Same name and namespace in other branches
  1. 7.2 includes/simplenews.admin.inc \simplenews_node_tab_send_form_validate()
  2. 7 includes/simplenews.admin.inc \simplenews_node_tab_send_form_validate()

Simplenews tab form validate callback

File

./simplenews.module, line 455
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_node_tab_send_form_validate($form, &$form_state) {
  $values = $form_state['values'];
  if (isset($values['simplenews']['send']) && $values['simplenews']['send'] == SIMPLENEWS_COMMAND_SEND_TEST) {
    if (!empty($values['simplenews']['test_address'])) {
      $mails = explode(',', $values['simplenews']['test_address']);
      foreach ($mails as $mail) {
        $mail = trim($mail);
        if ($mail == '') {
          form_set_error('simplenews][test_address', t('Test email address is empty.'));
        }
        elseif (!simplenews_valid_email_address($mail)) {
          form_set_error('simplenews][test_address', t('Invalid email address %mail.', array(
            '%mail' => $mail,
          )));
        }
      }
    }
    else {
      form_set_error('simplenews][test_address', t('Missing test email address.'));
    }
  }
}