Skip navigation
Help

aggregator_form_category_validate

6 aggregator.admin.inc aggregator_form_category_validate($form, &$form_state)
7 aggregator.admin.inc aggregator_form_category_validate($form, &$form_state)

Validate aggregator_form_feed form submissions.

File

drupal/modules/aggregator/aggregator.admin.inc, line 541
Admin 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'])));
    }
  }
}