You are here

function _feedapi_update in FeedAPI 5

Same name and namespace in other branches
  1. 6 feedapi.module \_feedapi_update()

Update feed data of an existing feed

1 call to _feedapi_update()
feedapi_nodeapi in ./feedapi.module
Implementation of hook_nodeapi().

File

./feedapi.module, line 913
Handle the submodules (for feed and item processing) Provide a basic management of feeds

Code

function _feedapi_update(&$node, $teaser, $page) {
  if (isset($node->feed)) {
    $old_config = node_load($node->nid);

    // In that case this feed has never have feed data. Should be created then, this is not really an update
    if (!is_numeric($old_config->feed->nid)) {
      $node->feed = _feedapi_build_feed_object($node->type, $node->feed->url);
      _feedapi_insert($node, 'insert', $teaser, $page);
      return;
    }
    db_query("UPDATE {feedapi} SET url = '%s', feed_type = '%s', processors = '%s', parsers = '%s', link = '%s' WHERE nid = %d", isset($node->feed->url) ? $node->feed->url : $node->feedapi['feedapi_url'], isset($node->feed->feed_type) ? $node->feed->feed_type : '', isset($node->feed->processors) ? serialize($node->feed->processors) : serialize($old_config->feed->processors), isset($node->feed->parsers) ? serialize($node->feed->parsers) : serialize($old_config->feed->parsers), $node->feed->options->link, $node->nid);

    // Store add on module's settings if user has permission to do so.
    if (user_access('advanced feedapi options')) {
      _feedapi_store_settings(array(
        'nid' => $node->nid,
      ), $node->feedapi);
    }
  }
}