You are here

function _feedapi_aggregator_save in FeedAPI 5

Save the news item as an aggregator item

File

feedapi_aggregator/feedapi_aggregator.module, line 432

Code

function _feedapi_aggregator_save($feed_item, $feed_nid, $settings = array()) {
  if (empty($feed_item->options->original_url)) {
    $feed_item->options->original_url = $feed_item->options->guid;
  }
  if ($feed_item->title && $feed_item->options->original_url) {
    $feed_item->fiid = db_next_id('{feedapi_aggregator_item}_iid');
    db_query("INSERT INTO {feedapi_aggregator_item} (iid, feed_nid, title, link, author, description, timestamp, guid) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d, '%s')", $feed_item->fiid, $feed_nid, $feed_item->title, $feed_item->options->original_url, is_object($feed_item->options->original_author) ? $feed_item->options->original_author->name : $feed_item->options->original_author, $feed_item->description, $feed_item->options->timestamp, $feed_item->options->guid);

    // file the items in the categories indicated by the feed
    $categories = db_query('SELECT cid FROM {feedapi_aggregator_category_feed} WHERE feed_nid = %d', $feed_nid);
    while ($category = db_fetch_object($categories)) {
      db_query('INSERT INTO {feedapi_aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $feed_item->fiid);
    }
  }
  return $feed_item;
}