Changeset 12241
- Timestamp:
- 07/26/11 07:09:55 (10 months ago)
- Location:
- branches/Release01x01/MailerContrib
- Files:
-
- 1 deleted
- 8 edited
-
data/System/MailerContrib.txt (modified) (3 diffs)
-
lib/Foswiki/Contrib/MailerContrib.pm (modified) (5 diffs)
-
lib/Foswiki/Contrib/MailerContrib/Change.pm (modified) (2 diffs)
-
lib/Foswiki/Contrib/MailerContrib/Constants.pm (deleted)
-
lib/Foswiki/Contrib/MailerContrib/MANIFEST (modified) (1 diff)
-
lib/Foswiki/Contrib/MailerContrib/Subscription.pm (modified) (4 diffs)
-
lib/Foswiki/Contrib/MailerContrib/WebNotify.pm (modified) (9 diffs)
-
templates/mailnotify.tmpl (modified) (3 diffs)
-
test/unit/MailerContrib/MailerContribSuite.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x01/MailerContrib/data/System/MailerContrib.txt
r11306 r12241 192 192 | =PLAIN:middle= | Repeated in a plain text email for each changes | 193 193 | =PLAIN:after= | Section of a plain text email after the changes | 194 | =MailNotifyBody= | All the above are embedded in this. %<nop>HTML_TEXT% expands to the HTML obtained by expanding the =HTML:*= templates, and %<nop>PLAIN_TEXT% from the =PLAIN:*= templates. | 194 | =DIFF:before= | Section of a plain text email before the changes | 195 | =DIFF:middle= | Repeated in a plain text email for each changes | 196 | =DIFF:after= | Section of a plain text email after the changes | 197 | =MailNotifyBody= | All the above are embedded in this. %<nop>HTML_TEXT% expands to the HTML obtained by expanding the =HTML:*= templates, %<nop>PLAIN_TEXT% from the =PLAIN:*= templates, and %<nop>DIFF_TEXT from the =DIFF:*= templates%. | 195 198 The default template sends multipart emails containing both HTML and plaintext versions. 196 199 … … 251 254 | Release: | %$RELEASE% | 252 255 | Change History: | | 256 | 2.5.1 (25 Jul 2011) | Foswiki:Tasks/Item10980: fix case where interaction with SubscribePlugin could potentially break cached CGI (fcgid/mod_perl) | 257 | 2.5.0 (5 Apr 2011) | Foswiki:Tasks/Item9459: add DIFF template for improved change presentation | 253 258 | 2.4.4 (5 Apr 2011) | Foswiki:Tasks/Item10545: Fix overriding rules | 254 259 | 2.4.3 (30 Sep 2010) | Foswikitask:Item6011: document =-user= parameter and update examples in order to make fully functional on versions of Foswiki through 1.0.10; other documentation cleanup -- Foswiki:Main.WillNorris | … … 263 268 | 2.0.1 (23 Apr 2009) | Foswikitask:Item1501: Minor bug in logfile output fixed | 264 269 | 2.0.0 (03 Dec 2008) | Re-released for the Foswiki project | 265 | 15 Oct 2008 | TWikibug:Item: generalised code to enable Foswiki:Extensions.SubscribePlugin to delegate parsing to %TOPIC% - Foswiki:Main.SvenDowideit |266 | 14 Oct 2008 | TWikibug:Item6066: fixed issue for user mappings where cuid != login - Foswiki:Main.SvenDowideit |267 | 27 Aug 2008 | TWikibug:Item5949: fixed problem with unsubscribe that should result in an empty subscription |268 | 03 Aug 2008 | TWiki 4.2.1 release version |269 | 27 Jul 2008 | TWikibug:Item5776: Foswiki:Main.KennethLavrsen added note to warn against running multiple instances of mailnotify at the same time. |270 | 15 May 2008 | TWikibug:Item5232: Foswiki:Main.CrawfordCurrie added support for non-ascii alphanumerics in topic names to WebNotify. TWikibug:Item5630: Foswiki:Main.SvenDowideit fixed some spelling errors |271 | 25 Jan 2008 | TWikibug:Item4812: added TWiki:Main.BobGoldstein's noexpand patch for groups |272 | 2 Nov 2007 | TWikibug:Item4818: added quotes to support non-alphabetic and other wierd group names TWikibug:Item4887: corrected minor rendering error TWikibug:Item4917: removed dependence on symbolic web names |273 | 9 Sep 2007 | TWikibug:Item4326 workaround for possible error in !WebNotify API in old releases, Should not affect most users. |274 | 6 Sep 2007 | TWikibug:Item4488 doc tweaks |275 | 14550 | TWikibug:Item4461 - 'Changed' link now points to most recent changes, not the entire history |276 | 22 Jun 2007 | TWikibug:Item4284 - added access control checks and email filter |277 | 21 May 2007 | TWikibug:Item3969 - 8bit email fix (Foswiki:Main.WillNorris) |278 | 13623 | TWikibug:Item4014 no changes was resetting the notify time to 0. Thanks to TWiki:Main.JeffCrawford for nailing this down. |279 | 12496 | TWikibug:Item3415 mailnotify did not send notifications to intranet users because of wrong call to findUser. |280 | 11672 | Added newsletter support, after much harassment from Foswiki:Main.LynnwoodBrown |281 | 11534 | TWikibug:Item2153 Clarified docs. TWikibug:Item2698 Improved error reporting. |282 | 8808 | TWikibug:Item1654 mailnotify must enter the command_line context |283 | 8625 | TWikibug:Item1508 Making the dashes in the separatator clearer |284 | 8606 | TWikibug:Item1508 MailerContrib: Brushing up HTML mailnotify template |285 | 8602 | TWikibug:Item1508 MailerContrib: Cleaning up plaintext email template, removing TEXTAREA |286 | 8522 | TWikibug:Item1511 arguments to getScriptUrl in wrong order :-( |287 | 8434 | TWikibug:Item1465 Fix 'TWiki.' to '%TWIKIEB%.' |288 | 8398 | TWikibug:Item1460 polished up the comment a bit |289 | 8308 | TWikibug:Item1362 moving mailnotify cron script |290 | 7848 | TWikibug:Item1167 forced all mail operations to generate absolute URLs |291 | 7568 | TWikibug:tem910 use SCRIPTURL{view} instead of complex url expr |292 | 6864 | TWikibug:tem624 mailer templates moved the the right places |293 | 6861 | TWikibug:tem624 Added proper templates support for plain text mails |294 | 6809 | TWikibug:tem623 don't print anything if verbosity is switched off. |295 | 6659 | TWikibug:tem528 Updated MailerContrib. it's working and the sendmail parameter is used. |296 | 6474 | TWikibug:tem420 removed spurious remove_obsolete_locks from MailerContrib |297 | 5924 | TWikibug:tem153 fix mail URL-fixing scheme |298 | 5269 | Minor doc fixes |299 | 5266 | Doc tidy-ups, added filtering of _ webs, added obsolete lock script |300 | 5264 | Changed default to add web name to user name (I hope) |301 | 5263 | Minor doc tidyups |302 | 5261 | Documentation changes, and fixed to scan all webs. |303 | 5253 | runnable as CGI script, minor bugfixes, removed dependency on DBCacheContrib |304 | 5234 | Minor doc changes |305 | 5231 | Made a change an object, added unit tests to CVS, lots of testing. |306 | 4 March 2005 | 1.010 Dakar release ready. |307 | 12 Oct 2004 | 1.004 Added support for anti-subscriptions. Doc fixes from TWiki:Main.PeterThoeny. Bug fixes to permissions code. Back-off and retry if the mailer can't be reached (should really be in Net::sendEmail) |308 | 6 Oct 2004 | 1.003 Excluded _ webs from processing, added =bin/remove_obsolete_locks= for full reverse-compatibility |309 | 1 Oct 2004 | 1.002 Peter<nop>Thoeny provided additional documentation |310 | 27 Sep 2004 | 1.001 runnable as CGI script, minor bugfixes, removed dependency on DB<nop>CacheContrib |311 | 8 Sep 2004 | 1.000 Initial version |312 270 | Home: | http://foswiki.org/Extensions/%TOPIC% | 313 271 | Support: | http://foswiki.org/Support/%TOPIC% | -
branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm
r11306 r12241 28 28 29 29 our $VERSION = '$Rev$'; 30 our $RELEASE = '2. 4.4';30 our $RELEASE = '2.5.1'; 31 31 our $SHORTDESCRIPTION = 'Supports email notification of changes'; 32 32 … … 354 354 Foswiki::Func::popTopicContext(); 355 355 356 my $homeTopic = $Foswiki::cfg{HomeTopicName};357 358 my $before_html = Foswiki::Func::expandTemplate('HTML:before');359 my $middle_html = Foswiki::Func::expandTemplate('HTML:middle');360 my $after_html = Foswiki::Func::expandTemplate('HTML:after');361 362 my $before_plain = Foswiki::Func::expandTemplate('PLAIN:before');363 my $middle_plain = Foswiki::Func::expandTemplate('PLAIN:middle');364 my $after_plain = Foswiki::Func::expandTemplate('PLAIN:after');365 366 356 my $mailtmpl = Foswiki::Func::expandTemplate('MailNotifyBody'); 367 357 $mailtmpl = 368 Foswiki::Func::expandCommonVariables( $mailtmpl, $homeTopic, $web ); 358 Foswiki::Func::expandCommonVariables( 359 $mailtmpl, $Foswiki::cfg{HomeTopicName}, $web ); 369 360 if ( $Foswiki::cfg{RemoveImgInMailnotify} ) { 370 361 … … 377 368 378 369 foreach my $email ( keys %{$changeset} ) { 379 my $html = '';380 my $plain = '';381 foreach my $change ( sort { $a->{TIME} cmp $b->{TIME} }382 @{ $changeset->{$email} } )383 {384 385 $html .= $change->expandHTML($middle_html);386 $plain .= $change->expandPlain($middle_plain);387 }388 389 $plain =~ s/\($Foswiki::cfg{UsersWebName}\./\(/go;390 370 391 371 my $mail = $mailtmpl; 392 372 393 $mail =~ s/%EMAILTO%/$email/go; 394 $mail =~ s/%HTML_TEXT%/$before_html$html$after_html/go; 395 $mail =~ s/%PLAIN_TEXT%/$before_plain$plain$after_plain/go; 396 $mail =~ s/%LASTDATE%/$lastTime/geo; 397 $mail = Foswiki::Func::expandCommonVariables( $mail, $homeTopic, $web ); 373 $mail =~ s/%EMAILTO%/$email/g; 374 $mail =~ s/%(HTML|PLAIN|DIFF)_TEXT%/ 375 _generateChangeDetail($email, $changeset, $1, $web)/ge; 376 $mail =~ s/%LASTDATE%/$lastTime/ge; 398 377 399 378 my $base = $Foswiki::cfg{DefaultUrlHost} . $Foswiki::cfg{ScriptUrlPath}; … … 407 386 408 387 if ($error) { 409 print STDERR "Error sending mail for f$web: $error\n";388 print STDERR "Error sending mail for $web: $error\n"; 410 389 $report .= $error . "\n"; 411 390 } … … 418 397 419 398 return $report; 399 } 400 401 sub _generateChangeDetail { 402 my ($email, $changeset, $style, $web) = @_; 403 404 my @wns = Foswiki::Func::emailToWikiNames($email); 405 my @ep = ($Foswiki::cfg{HomeTopicName}, $web); 406 407 # If there is only one user with this email, we can load preferences 408 # for them by expanding preferences in the context of their home 409 # topic. 410 if ( scalar(@wns) == 1 && Foswiki::Func::topicExists( 411 $Foswiki::cfg{UsersWebName}, $wns[0]) 412 && defined &Foswiki::Meta::load ) { 413 my ($ww, $wt) = Foswiki::Func::normalizeWebTopicName(undef, $wns[0]); 414 my $userTopic = Foswiki::Meta->load( 415 $Foswiki::Plugins::SESSION, $ww, $wt); 416 my $uStyle = $userTopic->getPreference('PREFERRED_MAIL_CHANGE_FORMAT'); 417 $style = $uStyle if $uStyle && $uStyle =~ /^(HTML|PLAIN|DIFF)$/; 418 } 419 420 my $template = Foswiki::Func::expandTemplate($style.':middle'); 421 my $text = ''; 422 foreach my $change ( sort { $a->{TIME} cmp $b->{TIME} } 423 @{ $changeset->{$email} } ) { 424 if ($style eq 'HTML') { 425 $text .= Foswiki::Func::expandCommonVariables( 426 $change->expandHTML($template), @ep); 427 } elsif ($style eq 'PLAIN') { 428 $text .= Foswiki::Func::expandCommonVariables( 429 $change->expandPlain($template), @ep); 430 } elsif ($style eq 'DIFF') { 431 # Note: no macro expansion; this is a verbatim format 432 $text .= $change->expandDiff($template); 433 } 434 } 435 return 436 Foswiki::Func::expandCommonVariables( 437 Foswiki::Func::expandTemplate($style.':before'), @ep) 438 . $text 439 . Foswiki::Func::expandCommonVariables( 440 Foswiki::Func::expandTemplate($style.':after'), @ep); 420 441 } 421 442 -
branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/Change.pm
r7682 r12241 41 41 42 42 $this->{TIME} = $time; 43 ASSERT( $rev) if DEBUG;43 ASSERT(defined $rev) if DEBUG; 44 44 45 45 # rev at this change … … 193 193 194 194 $template =~ s/%TEXTHEAD%/$this->{TEXT_SUMMARY}/g; 195 196 $template =~ s/\($Foswiki::cfg{UsersWebName}\./\(/go; 197 198 return $template; 199 } 200 201 =begin TML 202 203 ---++ expandDiff() -> string 204 Generate a unified diff version of this change. 205 206 =cut 207 208 sub expandDiff { 209 my ($this, $template) = @_; 210 211 unless ($this->{TEXT_DIFF}) { 212 my $b = Foswiki::Meta->load( 213 $Foswiki::Plugins::SESSION, 214 $this->{WEB}, $this->{TOPIC}, $this->{CURR_REV}); 215 return '' unless ( $b->haveAccess('VIEW') ); 216 my $btext = $b->getEmbeddedStoreForm(); 217 $btext =~ s/^%META:TOPICINFO{.*}%$//; 218 219 return $btext if ($this->{BASE_REV} < 1); 220 221 my $a = Foswiki::Meta->load( 222 $Foswiki::Plugins::SESSION, 223 $this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}); 224 return '' unless ( $a->haveAccess('VIEW') ); 225 my $atext = $a->getEmbeddedStoreForm(); 226 $atext =~ s/^%META:TOPICINFO{.*}%$//; 227 228 require Foswiki::Merge; 229 my $blocks = Foswiki::Merge::simpleMerge( 230 $atext, $btext, qr/[\r\n]+/ ); 231 $this->{TEXT_DIFF} = '<verbatim>'.join("\n", @$blocks).'</verbatim>'; 232 } 233 234 my $tim = Foswiki::Time::formatTime( $this->{TIME} ); 235 236 $template =~ s/%AUTHOR%/$this->{AUTHOR}/g; 237 $template =~ s/%TIME%/$tim/g; 238 $template =~ s/%CUR_REV%/$this->{CURR_REV}/g; 239 $template =~ s/%BASE_REV%/$this->{BASE_REV}/g; 240 $template =~ s/%TOPICNAME%/$this->{TOPIC}/g; # deprecated DO NOT USE! 241 $template =~ s/%TOPIC%/$this->{TOPIC}/g; 242 my $frev = ''; 243 if ( $this->{CURR_REV} ) { 244 if ( $this->{CURR_REV} > 1 ) { 245 $frev = 'r' . $this->{BASE_REV} . '->r' . $this->{CURR_REV}; 246 } 247 else { 248 249 # new _since the last notification_ 250 $frev = 'NEW'; 251 } 252 } 253 $template =~ s/%REVISION%/$frev/g; 254 255 $template =~ s/%TEXTHEAD%/$this->{TEXT_DIFF}/g; 256 195 257 return $template; 196 258 } -
branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/MANIFEST
r11135 r12241 5 5 lib/Foswiki/Contrib/MailerContrib/Subscription.pm 0444 6 6 lib/Foswiki/Contrib/MailerContrib/Change.pm 0444 7 lib/Foswiki/Contrib/MailerContrib/Constants.pm 04448 7 lib/Foswiki/Contrib/MailerContrib/UpData.pm 0444 9 8 lib/Foswiki/Configure/Checkers/Plugins/MailerContribPlugin/Module.pm 0444 -
branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/Subscription.pm
r11306 r12241 17 17 use Assert; 18 18 19 use Foswiki::Contrib::MailerContrib::Constants; 19 # Always mail out this subscription, even if there have been no changes 20 use constant ALWAYS => 1; 21 # Always mail out the full topic, not just the changes 22 use constant FULL_TOPIC => 2; 23 # ? = FULL_TOPIC 24 # ! = FULL_TOPIC | ALWAYS 20 25 21 26 =begin TML … … 25 30 * =$childDepth= - Depth of children of $topic to notify changes 26 31 for. Defaults to 0 27 * =$options= - bitmask of Foswiki::Contrib::MailerContrib:: Constantsoptions32 * =$options= - bitmask of Foswiki::Contrib::MailerContrib::Subscription options 28 33 Create a new subscription. 29 34 … … 121 126 122 127 # Does the mode cover the other subscription? 123 return 0124 unless (125 ( $this->{options} & $tother->{options} ) == $tother->{options} );126 127 # * should win always.128 # ALWAYS covers (ALWAYS and not ALWAYS). 129 # FULL_TOPIC covers (FULL_TOPIC and not FULL_TOPIC) 130 return 0 unless ( $this->{options} & $tother->{options} ) == $tother->{options}; 131 132 # A * always covers if the options match 128 133 return 1 if ( $this->{topics} eq '*' ); 129 134 … … 155 160 my $this = shift; 156 161 157 if ( $this->{options} & 158 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ) 162 if ( $this->{options} & FULL_TOPIC ) 159 163 { 160 164 return '!' 161 if ( $this->{options} & 162 $Foswiki::Contrib::MailerContrib::Constants::ALWAYS ); 165 if ( $this->{options} & ALWAYS ); 163 166 return '?'; 164 167 } -
branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/WebNotify.pm
r7643 r12241 29 29 * =$web= - web name 30 30 * =$topic= - topic name 31 * =$noexpandgroups= - True will prevent expansion of group subscriptions 32 (False is best for checking subscriptions, but True is best for 33 writing results back to $topic) 31 * =$noexpandgroups= - True will prevent expansion of group subscriptions 32 (False is best for checking subscriptions, but True is best for 33 writing results back to $topic) 34 34 35 Create a new object by parsing the content of the given topic in the 35 36 given web. This is the normal way to load a %NOTIFYTOPIC% topic. If the … … 188 189 Return a string representation of this object, in %NOTIFYTOPIC% format. 189 190 190 Optional $subscribersOnlyparameter to only print the parsed subscription list.191 Optional =$subscribersOnly= parameter to only print the parsed subscription list. 191 192 Used when running a mailnotify, where printing out the entire WebNotify topic is confusing, 192 as it s different from the actual topic contents, but doesn't inform the user why.193 as it's different from the actual topic contents, but doesn't inform the user why. 193 194 194 195 =cut … … 254 255 !( 255 256 $subs->{options} & 256 $Foswiki::Contrib::MailerContrib::Constants::ALWAYS257 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS 257 258 ) 258 259 && $authors{$email} … … 260 261 261 262 if ( $subs->{options} & 262 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC263 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC 263 264 ) 264 265 { … … 302 303 next 303 304 unless ( $subs->{options} & 304 $Foswiki::Contrib::MailerContrib::Constants::ALWAYS );305 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS ); 305 306 unless ( $subscriber->isUnsubscribedFrom( $topic, $db ) ) { 306 307 my $emails = $subscriber->getEmailAddresses(); … … 339 340 # join \ terminated lines 340 341 $text =~ s/\\\r?\n//gs; 341 my $webRE = qr/(?:$Foswiki::cfg{UsersWebName}\.)?/ o;342 my $webRE = qr/(?:$Foswiki::cfg{UsersWebName}\.)?/; 342 343 foreach my $baseline ( split( /\r?\n/, $text ) ) { 343 344 my $line = … … 350 351 \s+\-\s+ 351 352 ($Foswiki::cfg{MailerContrib}{EmailFilterIn}+) 352 \s*$}x o353 \s*$}x 353 354 && $1 ne $Foswiki::cfg{DefaultUserWikiName} 354 355 ) … … 369 370 ) 370 371 \s*(:.*)?$ 371 }x o372 }x 372 373 && $1 ne $Foswiki::cfg{DefaultUserWikiName} 373 374 ) … … 433 434 my $opts = 0; 434 435 if ($options) { 435 $opts |= $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC;436 $opts |= Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC; 436 437 if ( $options =~ /!/ ) { 437 $opts |= $Foswiki::Contrib::MailerContrib::Constants::ALWAYS;438 $opts |= Foswiki::Contrib::MailerContrib::Subscription::ALWAYS; 438 439 } 439 440 } -
branches/Release01x01/MailerContrib/templates/mailnotify.tmpl
r7502 r12241 58 58 %TMPL:DEF{PLAIN:after}%%TMPL:END% 59 59 -------------------------------- 60 %TMPL:DEF{DIFF:before}%%TMPL:END% 61 -------------------------------- 62 %TMPL:DEF{DIFF:middle}%- %TOPIC% (%AUTHOR%, %TIME%) %REVISION% 63 %SCRIPTURL{"view"}%/%ENCODE{%WEB%}%/%ENCODE{%TOPIC%}% 64 %TEXTHEAD% 65 %TMPL:END% 66 -------------------------------- 67 %TMPL:DEF{DIFF:after}%%TMPL:END% 68 -------------------------------- 60 69 %TMPL:DEF{MailNotifyBody}%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%> 61 70 To: %EMAILTO% 62 71 Subject: %WIKITOOLNAME%.%WEB% - %MAKETEXT{"Automated notification of topic changes"}% 63 72 MIME-Version: 1.0 64 Content-Type: multipart/alternative; boundary="=_=0i0k0i0w0 tXuOi0E0A"73 Content-Type: multipart/alternative; boundary="=_=0i0k0i0w0s0o0fXuOi0E0A" 65 74 66 75 This is a multi-part message in MIME format. 67 --=_=0i0k0i0w0 tXuOi0E0A76 --=_=0i0k0i0w0s0o0fXuOi0E0A 68 77 Content-Type: text/plain; charset=%CHARSET%; format=flowed 69 78 Content-Transfer-Encoding: 8bit … … 80 89 %SCRIPTURL{"view"}%/%WEB%/%NOTIFYTOPIC% 81 90 82 --=_=0i0k0i0w0 tXuOi0E0A91 --=_=0i0k0i0w0s0o0fXuOi0E0A 83 92 Content-Type: text/html; charset=%CHARSET% 84 93 Content-Transfer-Encoding: 8bit … … 86 95 %HTML_TEXT% 87 96 88 --=_=0i0k0i0w0 tXuOi0E0A--97 --=_=0i0k0i0w0s0o0fXuOi0E0A-- 89 98 %TMPL:END% -
branches/Release01x01/MailerContrib/test/unit/MailerContrib/MailerContribSuite.pm
r11094 r12241 230 230 $meta, "Before\n${s}After" 231 231 ); 232 233 232 for my $testTopic ( keys %expectedRevs ) { 234 233 my $parent = 'WebHome'; … … 408 407 $this->assert( $s1->covers($s1) ); 409 408 410 my $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 0,411 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );409 my $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 0, 410 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 412 411 $this->assert( !$s1->covers($s2) ); 413 412 414 413 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 0, 415 $Foswiki::Contrib::MailerContrib::Constants::ALWAYS |416 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );414 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS | 415 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 417 416 $this->assert( $s1->covers($s2) ); 418 417 $this->assert( !$s2->covers($s1) ); 419 418 420 419 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( 'A*', 0, 421 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );420 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 422 421 $this->assert( $s1->covers($s2) ); 423 422 $this->assert( !$s2->covers($s1) ); 424 423 425 424 $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 1, 426 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );425 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 427 426 $this->assert( !$s1->covers($s2) ); 428 427 $this->assert( !$s2->covers($s1) ); 429 428 430 429 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( 'A*', 1, 431 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );430 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 432 431 $this->assert( $s1->covers($s2) ); 433 432 $this->assert( !$s2->covers($s1) ); 434 433 435 434 $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A*B', 1, 436 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );435 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 437 436 $this->assert( $s1->covers($s2) ); 438 437 $this->assert( !$s2->covers($s1) ); 439 438 440 439 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( 'AxB', 0, 441 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );440 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 442 441 $this->assert( !$s1->covers($s2) ); 443 442 $this->assert( $s2->covers($s1) ); … … 445 444 # * covers everything. 446 445 my $AStar = new Foswiki::Contrib::MailerContrib::Subscription( 'A*', 1, 447 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );446 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 448 447 my $Star = new Foswiki::Contrib::MailerContrib::Subscription( '*', 1, 449 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );448 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 450 449 $this->assert( $Star->covers($AStar) ); 451 450 $this->assert( !$AStar->covers($Star) ); … … 454 453 my $ChildrenOfWebHome = 455 454 new Foswiki::Contrib::MailerContrib::Subscription( 'WebHome', 2, 456 $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC );455 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 457 456 $this->assert( $Star->covers($ChildrenOfWebHome) ); 458 457 $this->assert( !$ChildrenOfWebHome->covers($Star) ); 458 459 # Special cases involving '*' and modes 460 $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 0, 461 0); 462 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 463 0 ); 464 $this->assert( $s1->covers($s2) ); 465 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 466 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 467 $this->assert( $s1->covers($s2) ); 468 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 469 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS ); 470 $this->assert( $s1->covers($s2) ); 471 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 472 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS | 473 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 474 $this->assert( $s1->covers($s2) ); 475 476 $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 0, 477 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS); 478 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 479 0 ); 480 $this->assert( !$s1->covers($s2) ); 481 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 482 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 483 $this->assert( !$s1->covers($s2) ); 484 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 485 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS ); 486 $this->assert( $s1->covers($s2) ); 487 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 488 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS | 489 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 490 $this->assert( $s1->covers($s2) ); 491 492 $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 0, 493 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC); 494 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 495 0 ); 496 $this->assert( !$s1->covers($s2) ); 497 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 498 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 499 $this->assert( $s1->covers($s2) ); 500 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 501 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS ); 502 $this->assert( !$s1->covers($s2) ); 503 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 504 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS | 505 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 506 $this->assert( $s1->covers($s2) ); 507 508 $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 0, 509 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS | 510 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC); 511 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 512 0 ); 513 $this->assert( !$s1->covers($s2) ); 514 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 515 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 516 $this->assert( !$s1->covers($s2) ); 517 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 518 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS ); 519 $this->assert( !$s1->covers($s2) ); 520 $s1 = new Foswiki::Contrib::MailerContrib::Subscription( '*', 0, 521 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS | 522 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 523 $this->assert( $s1->covers($s2) ); 459 524 } 460 525
Note: See TracChangeset
for help on using the changeset viewer.
