You are here

function aggregator_save_item in Drupal 4

Same name and namespace in other branches
  1. 5 modules/aggregator/aggregator.module \aggregator_save_item()
  2. 6 modules/aggregator/aggregator.module \aggregator_save_item()
  3. 7 modules/aggregator/aggregator.processor.inc \aggregator_save_item()
1 call to aggregator_save_item()
aggregator_parse_feed in modules/aggregator.module

File

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

Code

function aggregator_save_item($edit) {
  if ($edit['iid'] && $edit['title']) {
    db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s' WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['iid']);
  }
  else {
    if ($edit['iid']) {
      db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
      db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']);
    }
    else {
      if ($edit['title'] && $edit['link']) {
        $edit['iid'] = db_next_id('{aggregator_item}_iid');
        db_query("INSERT INTO {aggregator_item} (iid, fid, title, link, author, description, timestamp) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d)", $edit['iid'], $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp']);

        // file the items in the categories indicated by the feed
        $categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
        while ($category = db_fetch_object($categories)) {
          db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $edit['iid']);
        }
      }
    }
  }
}