You are here

function _feedapi_node_expire in FeedAPI 5

Same name and namespace in other branches
  1. 6 feedapi_node/feedapi_node.module \_feedapi_node_expire()

Check for expired items, pass them to the item_expire function

@TO DO Add cron timeout checking here, there may be too many items (nodes) to delete

We implement the same logic as a db query. The old code is

if (isset($item->arrived) || isset($item->timestamp)) { $diff = abs(time() - (isset($item->timestamp) ? $item->timestamp : $item->timestamp)); if ($diff > $settings['items_delete']) { ................ } }

File

feedapi_node/feedapi_node.module, line 213
Handle how the feed items are represented as a content Handle the processing of the feed items

Code

function _feedapi_node_expire($feed, $settings) {
  $count = 0;
  if ($settings['items_delete'] > FEEDAPI_NEVER_DELETE_OLD) {
    $timexpire = time() - $settings['items_delete'];

    // @ TODO Review this query conditions
    $result = db_query("SELECT * FROM {feedapi_node_item} fn JOIN {feedapi_node_item_feed} ff ON ff.feed_item_nid = fn.nid WHERE ff.feed_nid = %d AND ( (fn.timestamp > 0 AND fn.timestamp < %d) OR (fn.timestamp = 0 AND fn.arrived > 0 AND fn.arrived < %d) )", $feed->nid, $timexpire, $timexpire);
    while ($item = db_fetch_object($result)) {

      // We callback feedapi for deleting
      feedapi_expire_item($feed, $item);
      $count++;
    }
  }
  return $count;
}