You are here

function aggregator_form_feed_validate in Drupal 5

Same name and namespace in other branches
  1. 4 modules/aggregator.module \aggregator_form_feed_validate()
  2. 6 modules/aggregator/aggregator.admin.inc \aggregator_form_feed_validate()
  3. 7 modules/aggregator/aggregator.admin.inc \aggregator_form_feed_validate()

Validate aggregator_form_feed form submissions.

File

modules/aggregator/aggregator.module, line 474
Used to aggregate syndicated content (RSS, RDF, and Atom).

Code

function aggregator_form_feed_validate($form_id, $form_values) {
  if ($form_values['op'] == t('Submit')) {

    // Check for duplicate titles
    if (isset($form_values['fid'])) {
      $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = '%s' OR url = '%s') AND fid <> %d", $form_values['title'], $form_values['url'], $form_values['fid']);
    }
    else {
      $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url = '%s'", $form_values['title'], $form_values['url']);
    }
    while ($feed = db_fetch_object($result)) {
      if (strcasecmp($feed->title, $form_values['title']) == 0) {
        form_set_error('title', t('A feed named %feed already exists. Please enter a unique title.', array(
          '%feed' => $form_values['title'],
        )));
      }
      if (strcasecmp($feed->url, $form_values['url']) == 0) {
        form_set_error('url', t('A feed with this URL %url already exists. Please enter a unique URL.', array(
          '%url' => $form_values['url'],
        )));
      }
    }
  }
}