Ignore:
Timestamp:
12/18/09 11:14:24 (2 years ago)
Author:
CrawfordCurrie
Message:

Item2511: make the new plugin into a micro-module. This allows us to init the plugin without loading the rest of the MailerContrib, which would be an unreasonable thing to do unless we were really going to use it. Note that this approach may not work with pre-1.1 code if it is run with ASSERTs enabled, because of a wayward assert in Plugins.pm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm

    r5752 r5821  
    2727 
    2828our $VERSION = '$Rev$'; 
    29 our $RELEASE = '8 Dec 2009'; 
     29our $RELEASE = '18 Dec 2009'; 
    3030our $SHORTDESCRIPTION = 'Supports e-mail notification of changes'; 
    3131 
     
    3838    $Foswiki::cfg{MailerContrib}{EmailFilterIn} ||= 
    3939      $Foswiki::regex{emailAddrRegex}; 
    40 } 
    41  
    42 # Plugin init method, used to initialise handlers 
    43 sub initPlugin { 
    44     Foswiki::Func::registerRESTHandler('notify', \&_restNotify); 
    45     return 1; 
    46 } 
    47  
    48 # Run mailnotify using a rest handler 
    49 sub _restNotify { 
    50     my ( $session, $plugin, $verb, $response ) = @_; 
    51  
    52     if (!Foswiki::Func::isAnAdmin()) { 
    53         $response->header( -status  => 403, -type => 'text/plain' ); 
    54         $response->print("Only administrators can do that"); 
    55     } else { 
    56         # Don't use the $response; we want to see things happening 
    57         local $| = 1; # autoflush on 
    58         require CGI; 
    59         print CGI::header( -status => 200, -type => 'text/plain' ); 
    60         my $query = Foswiki::Func::getCgiQuery(); 
    61         my $nonews = $query->param('nonews'); 
    62         my $nochanges = $query->param('nochanges'); 
    63         my @exwebs = split(',', $query->param('excludewebs') || ''); 
    64         my @webs = split(',', $query->param('webs') || ''); 
    65         $verbose = 1; # watchen das blinken lights 
    66         mailNotify( \@webs, $verbose, \@exwebs, $nonews, $nochanges ); 
    67     } 
    68     return undef; 
    6940} 
    7041 
Note: See TracChangeset for help on using the changeset viewer.