Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins/MailerContribPlugin.pm |
Statements | Executed 11 statements in 357µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 14µs | 26µs | BEGIN@4 | Foswiki::Plugins::MailerContribPlugin::
1 | 1 | 1 | 10µs | 33µs | initPlugin | Foswiki::Plugins::MailerContribPlugin::
1 | 1 | 1 | 9µs | 13µs | BEGIN@5 | Foswiki::Plugins::MailerContribPlugin::
0 | 0 | 0 | 0s | 0s | _restNotify | Foswiki::Plugins::MailerContribPlugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Plugins::MailerContribPlugin; | ||||
3 | |||||
4 | 2 | 28µs | 2 | 39µs | # spent 26µs (14+13) within Foswiki::Plugins::MailerContribPlugin::BEGIN@4 which was called:
# once (14µs+13µs) by Foswiki::Plugin::BEGIN@2.24 at line 4 # spent 26µs making 1 call to Foswiki::Plugins::MailerContribPlugin::BEGIN@4
# spent 13µs making 1 call to strict::import |
5 | 2 | 318µs | 2 | 18µs | # spent 13µs (9+4) within Foswiki::Plugins::MailerContribPlugin::BEGIN@5 which was called:
# once (9µs+4µs) by Foswiki::Plugin::BEGIN@2.24 at line 5 # spent 13µs making 1 call to Foswiki::Plugins::MailerContribPlugin::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 1 | 600ns | our $VERSION = '2.82'; | ||
8 | 1 | 200ns | our $RELEASE = '2.82'; | ||
9 | 1 | 200ns | our $SHORTDESCRIPTION = 'Supports e-mail notification of changes'; | ||
10 | 1 | 200ns | our $NO_PREFS_IN_TOPIC = 1; | ||
11 | |||||
12 | # Plugin init method, used to initialise handlers | ||||
13 | # spent 33µs (10+23) within Foswiki::Plugins::MailerContribPlugin::initPlugin which was called:
# once (10µs+23µs) by Foswiki::Plugin::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Plugin.pm:257] at line 250 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm | ||||
14 | 1 | 3µs | 1 | 23µs | Foswiki::Func::registerRESTHandler( # spent 23µs making 1 call to Foswiki::Func::registerRESTHandler |
15 | 'notify', \&_restNotify, | ||||
16 | authenticate => 1, | ||||
17 | validate => 1, | ||||
18 | http_allow => 'POST', | ||||
19 | description => | ||||
20 | 'Allow administrators to run the mailNotify process from the web.', | ||||
21 | ); | ||||
22 | 1 | 4µs | return 1; | ||
23 | } | ||||
24 | |||||
25 | # Run mailnotify using a rest handler | ||||
26 | sub _restNotify { | ||||
27 | my ( $session, $plugin, $verb, $response ) = @_; | ||||
28 | |||||
29 | if ( !Foswiki::Func::isAnAdmin() ) { | ||||
30 | $response->header( -status => 403, -type => 'text/plain' ); | ||||
31 | $response->print("Only administrators can do that"); | ||||
32 | } | ||||
33 | else { | ||||
34 | |||||
35 | # Don't use the $response; we want to see things happening | ||||
36 | local $| = 1; # autoflush on | ||||
37 | require CGI; | ||||
38 | print CGI::header( -status => 200, -type => 'text/plain' ); | ||||
39 | |||||
40 | my $query = Foswiki::Func::getCgiQuery(); | ||||
41 | my %options = ( | ||||
42 | verbose => 1, | ||||
43 | news => 1, | ||||
44 | changes => 1, | ||||
45 | reset => 1, | ||||
46 | mail => 1 | ||||
47 | ); | ||||
48 | |||||
49 | if ( $query->param('q') ) { | ||||
50 | $options{verbose} = 0; | ||||
51 | } | ||||
52 | if ( $query->param('nonews') ) { | ||||
53 | $options{news} = 0; | ||||
54 | } | ||||
55 | if ( $query->param('nochanges') ) { | ||||
56 | $options{changes} = 0; | ||||
57 | } | ||||
58 | if ( $query->param('noreset') ) { | ||||
59 | $options{reset} = 0; | ||||
60 | } | ||||
61 | if ( $query->param('nomail') ) { | ||||
62 | $options{mail} = 0; | ||||
63 | } | ||||
64 | |||||
65 | my @exwebs = split( ',', $query->param('excludewebs') || '' ); | ||||
66 | my @webs = split( ',', $query->param('webs') || '' ); | ||||
67 | |||||
68 | require Foswiki::Contrib::MailerContrib; | ||||
69 | Foswiki::Contrib::MailerContrib::mailNotify( \@webs, \@exwebs, | ||||
70 | %options ); | ||||
71 | } | ||||
72 | return undef; | ||||
73 | } | ||||
74 | |||||
75 | 1 | 3µs | 1; | ||
76 | __END__ |