You are here

function newsletter_list_edit_validate in Newsletter 7

Same name and namespace in other branches
  1. 7.2 modules/list/includes/newsletter_list.admin.inc \newsletter_list_edit_validate()

File

includes/newsletter.admin.inc, line 780
Admin page callbacks for the newsletter module.

Code

function newsletter_list_edit_validate($form, &$form_state) {
  if ($form_state['values']['send_rate'] == 'Custom') {
    if (empty($form_state['values']['send_rate_custom'])) {
      form_set_error('send_rate_custom', t('You must set the custom send rate first.'));
    }
    elseif (!is_numeric($form_state['values']['send_rate_custom'])) {
      form_set_error('send_rate_custom', t('Custom send rate must be a number.'));
    }
  }

  // Ensure list title is unique
  if ($form['#list']->title != $form_state['values']['title'] || !isset($form_state['values']['nlid'])) {
    $existing = db_query('SELECT title FROM {newsletter_list} WHERE title = :title', array(
      'title' => $form_state['values']['title'],
    ))
      ->fetchField();
    if ($existing) {
      form_set_error('title', t('This list name already exists'));
    }
  }
}