function _feedapi_update in FeedAPI 6
Same name and namespace in other branches
- 5 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 948 - Handle the submodules (for feed and item processing) Provide a basic management of feeds
Code
function _feedapi_update(&$node) {
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)) {
$url = isset($node->feed->url) ? $node->feed->url : $node->feedapi['feedapi_url'];
$node->feed = _feedapi_build_feed_object($node->type, $url);
_feedapi_insert($node);
return;
}
$old_vid = db_result(db_query_range("SELECT vid FROM {feedapi} WHERE nid = %d ORDER BY vid DESC", $node->nid, 0, 1));
if ($old_vid !== $node->vid) {
_feedapi_insert($node);
return;
}
// Only change next_refresh_time if refresh_time changed
// or if $next_refresh_time is FEEDAPI_CRON_NEVER_REFRESH.
$next_refresh_time = $old_config->feed->next_refresh_time;
if (isset($node->feedapi['refresh_time'])) {
if ($node->feedapi['refresh_time'] == FEEDAPI_CRON_NEVER_REFRESH) {
$next_refresh_time = FEEDAPI_CRON_NEVER_REFRESH;
}
elseif ($old_config->feed->settings['refresh_time'] != $node->feedapi['refresh_time'] || $next_refresh_time == FEEDAPI_CRON_NEVER_REFRESH) {
$next_refresh_time = time() + $node->feedapi['refresh_time'];
}
}
db_query("UPDATE {feedapi} SET\n url = '%s',\n feed_type = '%s',\n processors = '%s',\n parsers = '%s',\n link = '%s',\n next_refresh_time = %d\n WHERE vid = %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), isset($node->feed->link) ? $node->feed->link : '', $next_refresh_time, $node->vid);
// Store add on module's settings if user has permission to do so.
if (user_access('advanced feedapi options')) {
_feedapi_store_settings(array(
'vid' => $node->vid,
), $node->feedapi);
}
}
}