Changeset 1677

Show
Ignore:
Timestamp:
10/12/05 12:39:52
Author:
miyagawa
Message:

Add Action and template

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • SpamSubmission/trunk/SpamSubmission.pl

    r1676 r1677  
    2828sub instance { $plugin } 
    2929 
     30sub init_app { 
     31    my $plugin = shift; 
     32    $plugin->SUPER::init_app(@_); 
     33    my($app) = @_; 
     34 
     35    return unless $app->isa('MT::App::CMS'); 
     36 
     37    $app->add_itemset_action({ 
     38        type => 'comment', 
     39        key  => 'spam_submission_comment', 
     40        label => 'Report SPAM Comment(s)', 
     41        code => sub { $plugin->submit_spams_action('MT::Comment', @_) }, 
     42    }); 
     43 
     44    $app->add_itemset_action({ 
     45        type => 'ping', 
     46        key  => 'spam_submission_ping', 
     47        label => 'Report SPAM TrackBack(s)', 
     48        code => sub { $plugin->submit_spams_action('MT::TBPing', @_) }, 
     49    }); 
     50} 
     51 
     52sub submit_spams_action { 
     53    my $plugin = shift; 
     54    my($class, $app) = @_; 
     55    my @obj = map $class->load($_), $app->param('id'); 
     56    my @urls; 
     57    for my $obj (@obj) { 
     58        push @urls, uniq(find_uris($obj->all_text)); 
     59    } 
     60    submit_spams(\@urls) if @urls; 
     61    $app->build_page($plugin->load_tmpl('results.tmpl'), { urls => [ map { +{value => $_} } @urls ], return_url => $app->return_uri }); 
     62} 
     63 
    3064sub uniq { 
    3165    my @list = @_; 
     
    4175    *{$class . "::junk"} = sub { 
    4276        my $obj = shift; 
     77        my $config = MT::Plugin::SpamSubmission->instance->get_config_hash; 
    4378        my @urls = uniq(find_uris($obj->all_text)); 
    4479        submit_spams(\@urls); 
     
    76111        if ($xml =~ m!<error>(.*)</error>!) { 
    77112            MT::log("error: $1"); 
    78         } else { 
    79             MT::log("success"); 
    80113        } 
    81114    } else {