/[drupal]/contributions/modules/simplefeed/simplefeed_item.module
ViewVC logotype

Diff of /contributions/modules/simplefeed/simplefeed_item.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.51.2.19, Tue Oct 7 06:30:30 2008 UTC revision 1.51.2.20, Tue Oct 7 07:56:11 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: simplefeed_item.module,v 1.51.2.18 2008/10/07 05:34:33 m3avrck Exp $  // $Id: simplefeed_item.module,v 1.51.2.19 2008/10/07 06:30:30 m3avrck Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 282  function simplefeed_item_feed_expire() { Line 282  function simplefeed_item_feed_expire() {
282    
283    // delete all expired feed items, ignore $vid since we expire *every* feed item in one call, not specific ones    // delete all expired feed items, ignore $vid since we expire *every* feed item in one call, not specific ones
284    // note if a feed item has multiple revisions, any revision's expiration can trigger deletion of the entire node    // note if a feed item has multiple revisions, any revision's expiration can trigger deletion of the entire node
285    $items = db_query('SELECT n.nid FROM {node} n JOIN {simplefeed_feed_item} s ON n.vid = s.vid WHERE s.expires <> 0 AND s.expires <= (%d - n.created)', time());    // order by FID so we can keep track of stats per feed
286      $items = db_query('SELECT n.nid, s.fid FROM {node} n JOIN {simplefeed_feed_item} s ON n.vid = s.vid WHERE s.expires <> 0 AND s.expires <= (%d - n.created) ORDER BY s.fid', time());
287    
288    
289    while ($item = db_fetch_object($items)) {    while ($item = db_fetch_object($items)) {
290        if (!isset($fid)) {
291          $fid = $item->fid;
292          $count = 0;
293        }
294      node_delete($item->nid);      node_delete($item->nid);
295    
296        if (module_exists('simplefeed_stats')) {
297          $count++;
298          // if the feed changed
299          if ($fid != $item->fid) {
300            simplefeed_stats_updated_feed($count, $item->fid, 'expire');
301            $fid = $item->fid;
302            $count = 0;
303          }
304        }
305      }
306    
307      if (isset($fid) && module_exists('simplefeed_stats')) {
308        // record stats for last feed that expired
309        simplefeed_stats_updated_feed($count, $fid, 'expire');
310    }    }
311    
312    // if we actually deleted something    // if we actually deleted something
# Line 316  function simplefeed_item_feed_parse($pro Line 337  function simplefeed_item_feed_parse($pro
337    
338    for ($i = 0; $i < $max; $i++) {    for ($i = 0; $i < $max; $i++) {
339      $item = $feed->get_item($i);      $item = $feed->get_item($i);
340      if ($item->get_date('U') < $process_feed->checked) {      // don't import any items that are going to be expired right away
341        // never is 0 so can throw off this check so make sure it is higher
342        if (($item->get_date('U') < (time() - $process_feed->expires) && $process_feed->expires > 0) || $item->get_date('U') < $process_feed->checked) {
343        // ok we are done checking this feed        // ok we are done checking this feed
344        // any other items past this point are too old        // any other items past this point are too old
345        // SimplePie default sorts by date        // SimplePie default sorts by date
# Line 430  function simplefeed_item_feed_parse($pro Line 453  function simplefeed_item_feed_parse($pro
453      unset($item);      unset($item);
454    }    }
455    if (module_exists('simplefeed_stats')) {    if (module_exists('simplefeed_stats')) {
456       simplefeed_stats_updated_feed($count, $process_feed);      simplefeed_stats_updated_feed($count, $process_feed->nid);
457    }    }
458  }  }

Legend:
Removed from v.1.51.2.19  
changed lines
  Added in v.1.51.2.20

  ViewVC Help
Powered by ViewVC 1.1.2