Show
Ignore:
Timestamp:
04/06/05 22:09:03 (4 years ago)
Author:
ogawa
Message:

Now disables the plugin function if specified with lastn, days, recently_commented_on options. And if using in category or date-based archives, the plugin lists up only pinged entries which are included in targetted archives.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • recently-pinged-on/trunk/recently-pinged-on.pl

    r27 r29  
    11# A plugin for adding 'recently_pinged_on' option to MTEntries container 
    22# 
    3 # Release 0.12 (Feb 06, 2005) 
     3# Release 0.15 (Feb 12, 2005) 
    44# 
    55# This software is provided as-is. You may use it for commercial or  
     
    1414    require MT::Plugin; 
    1515    my $plugin = new MT::Plugin(); 
    16     $plugin->name("recently_pinged_on Plugin 0.12"); 
     16    $plugin->name("recently_pinged_on Plugin 0.15"); 
    1717    $plugin->description("Add 'recently_ping_on' option to MTEntries container"); 
    1818    $plugin->doc_link("http://as-is.net/hacks/2005/01/recently_pinged_on_plugin.html"); 
     
    2828sub hdlr_entries { 
    2929    my ($ctx, $args, $cond) = @_; 
     30    return &$mt_hdlr_entries(@_) 
     31        if $args->{lastn} || $args->{days} || $args->{recently_commented_on}; 
    3032    my $recently_pinged_on = $args->{recently_pinged_on} or 
    3133        return &$mt_hdlr_entries(@_); 
    3234 
    3335    my $blog_id = $ctx->stash('blog_id'); 
     36    my ($start, $end) = ($ctx->{current_timestamp}, 
     37                         $ctx->{current_timestamp_end}); 
     38    my $cat = $ctx->stash('archive_category'); 
    3439 
    3540    require MT::TBPing; 
     
    4550 
    4651        require MT::Trackback; 
     52        my $trackback = MT::Trackback->load($tb_id) or next; 
     53        my $entry_id = $trackback->entry_id or next; 
     54 
    4755        require MT::Entry; 
    48         my @args = ({ status => MT::Entry::RELEASE() }, 
    49                     { join => ['MT::Trackback', 'entry_id', { id => $tb_id }] }); 
    50         my $entry = MT::Entry->load(@args) or next; 
     56        my $entry = MT::Entry->load($entry_id) or next; 
     57 
     58        next if $entry->status != MT::Entry::RELEASE(); 
     59        next if $cat && !$entry->is_in_category($cat); 
     60        next if $start && $end && ($entry->created_on < $start || $entry->created_on > $end); 
     61 
    5162        push(@entries, $entry); 
    5263        last if ++$count == $recently_pinged_on;