function aggregator_form_category_validate

7.x aggregator.admin.inc aggregator_form_category_validate($form, &$form_state)
5.x aggregator.module aggregator_form_category_validate($form_id, $form_values)
6.x aggregator.admin.inc aggregator_form_category_validate($form, &$form_state)

Form validation handler for aggregator_form_category().

See also

aggregator_form_category_submit()

File

drupal/modules/aggregator/aggregator.admin.inc, line 575
Administration page callbacks for the Aggregator module.

Code

function aggregator_form_category_validate($form, &$form_state) {
  if ($form_state['values']['op'] == t('Save')) {
    // Check for duplicate titles
    if (isset($form_state['values']['cid'])) {
      $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title AND cid <> :cid", array(':title' => $form_state['values']['title'], ':cid' => $form_state['values']['cid']))->fetchObject();
    }
    else {
      $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title", array(':title' => $form_state['values']['title']))->fetchObject();
    }
    if ($category) {
      form_set_error('title', t('A category named %category already exists. Enter a unique title.', array('%category' => $form_state['values']['title'])));
    }
  }
}