Changeset 12241


Ignore:
Timestamp:
07/26/11 07:09:55 (10 months ago)
Author:
CrawfordCurrie
Message:

Item9459: Item10980: synch with trunk

Location:
branches/Release01x01/MailerContrib
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x01/MailerContrib/data/System/MailerContrib.txt

    r11306 r12241  
    192192| =PLAIN:middle= | Repeated in a plain text email for each changes | 
    193193| =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%. | 
    195198The default template sends multipart emails containing both HTML and plaintext versions. 
    196199 
     
    251254|  Release: | %$RELEASE% | 
    252255|  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 | 
    253258|  2.4.4 (5 Apr 2011) | Foswiki:Tasks/Item10545: Fix overriding rules | 
    254259|  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 | 
     
    263268|  2.0.1 (23 Apr 2009) | Foswikitask:Item1501: Minor bug in logfile output fixed | 
    264269|  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 | 
    312270|  Home: | http://foswiki.org/Extensions/%TOPIC% | 
    313271|  Support: | http://foswiki.org/Support/%TOPIC% | 
  • branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm

    r11306 r12241  
    2828 
    2929our $VERSION          = '$Rev$'; 
    30 our $RELEASE          = '2.4.4'; 
     30our $RELEASE          = '2.5.1'; 
    3131our $SHORTDESCRIPTION = 'Supports email notification of changes'; 
    3232 
     
    354354    Foswiki::Func::popTopicContext(); 
    355355 
    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  
    366356    my $mailtmpl = Foswiki::Func::expandTemplate('MailNotifyBody'); 
    367357    $mailtmpl = 
    368       Foswiki::Func::expandCommonVariables( $mailtmpl, $homeTopic, $web ); 
     358      Foswiki::Func::expandCommonVariables( 
     359          $mailtmpl, $Foswiki::cfg{HomeTopicName}, $web ); 
    369360    if ( $Foswiki::cfg{RemoveImgInMailnotify} ) { 
    370361 
     
    377368 
    378369    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; 
    390370 
    391371        my $mail = $mailtmpl; 
    392372 
    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; 
    398377 
    399378        my $base = $Foswiki::cfg{DefaultUrlHost} . $Foswiki::cfg{ScriptUrlPath}; 
     
    407386 
    408387        if ($error) { 
    409             print STDERR "Error sending mail forf $web: $error\n"; 
     388            print STDERR "Error sending mail for $web: $error\n"; 
    410389            $report .= $error . "\n"; 
    411390        } 
     
    418397 
    419398    return $report; 
     399} 
     400 
     401sub _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); 
    420441} 
    421442 
  • branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/Change.pm

    r7682 r12241  
    4141 
    4242    $this->{TIME} = $time; 
    43     ASSERT($rev) if DEBUG; 
     43    ASSERT(defined $rev) if DEBUG; 
    4444 
    4545    # rev at this change 
     
    193193 
    194194    $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 
     204Generate a unified diff version of this change. 
     205 
     206=cut 
     207 
     208sub 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 
    195257    return $template; 
    196258} 
  • branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/MANIFEST

    r11135 r12241  
    55lib/Foswiki/Contrib/MailerContrib/Subscription.pm 0444 
    66lib/Foswiki/Contrib/MailerContrib/Change.pm 0444 
    7 lib/Foswiki/Contrib/MailerContrib/Constants.pm 0444 
    87lib/Foswiki/Contrib/MailerContrib/UpData.pm 0444 
    98lib/Foswiki/Configure/Checkers/Plugins/MailerContribPlugin/Module.pm 0444 
  • branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/Subscription.pm

    r11306 r12241  
    1717use Assert; 
    1818 
    19 use Foswiki::Contrib::MailerContrib::Constants; 
     19# Always mail out this subscription, even if there have been no changes 
     20use constant ALWAYS => 1; 
     21# Always mail out the full topic, not just the changes 
     22use constant FULL_TOPIC => 2; 
     23# ? = FULL_TOPIC 
     24# ! = FULL_TOPIC | ALWAYS 
    2025 
    2126=begin TML 
     
    2530   * =$childDepth= - Depth of children of $topic to notify changes 
    2631     for. Defaults to 0 
    27    * =$options= - bitmask of Foswiki::Contrib::MailerContrib::Constants options 
     32   * =$options= - bitmask of Foswiki::Contrib::MailerContrib::Subscription options 
    2833Create a new subscription. 
    2934 
     
    121126 
    122127    # Does the mode cover the other subscription? 
    123     return 0 
    124       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 
    128133    return 1 if ( $this->{topics} eq '*' ); 
    129134 
     
    155160    my $this = shift; 
    156161 
    157     if ( $this->{options} & 
    158         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ) 
     162    if ( $this->{options} & FULL_TOPIC ) 
    159163    { 
    160164        return '!' 
    161           if ( $this->{options} & 
    162             $Foswiki::Contrib::MailerContrib::Constants::ALWAYS ); 
     165          if ( $this->{options} & ALWAYS ); 
    163166        return '?'; 
    164167    } 
  • branches/Release01x01/MailerContrib/lib/Foswiki/Contrib/MailerContrib/WebNotify.pm

    r7643 r12241  
    2929   * =$web= - web name 
    3030   * =$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      
    3435Create a new object by parsing the content of the given topic in the 
    3536given web. This is the normal way to load a %NOTIFYTOPIC% topic. If the 
     
    188189Return a string representation of this object, in %NOTIFYTOPIC% format. 
    189190 
    190 Optional $subscribersOnly parameter to only print the parsed subscription list. 
     191Optional =$subscribersOnly= parameter to only print the parsed subscription list. 
    191192Used when running a mailnotify, where printing out the entire WebNotify topic is confusing, 
    192 as its different from the actual topic contents, but doesn't inform the user why. 
     193as it's different from the actual topic contents, but doesn't inform the user why. 
    193194 
    194195=cut 
     
    254255                        !( 
    255256                            $subs->{options} & 
    256                             $Foswiki::Contrib::MailerContrib::Constants::ALWAYS 
     257                            Foswiki::Contrib::MailerContrib::Subscription::ALWAYS 
    257258                        ) 
    258259                        && $authors{$email} 
     
    260261 
    261262                    if ( $subs->{options} & 
    262                         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC 
     263                        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC 
    263264                      ) 
    264265                    { 
     
    302303        next 
    303304          unless ( $subs->{options} & 
    304             $Foswiki::Contrib::MailerContrib::Constants::ALWAYS ); 
     305            Foswiki::Contrib::MailerContrib::Subscription::ALWAYS ); 
    305306        unless ( $subscriber->isUnsubscribedFrom( $topic, $db ) ) { 
    306307            my $emails = $subscriber->getEmailAddresses(); 
     
    339340    # join \ terminated lines 
    340341    $text =~ s/\\\r?\n//gs; 
    341     my $webRE = qr/(?:$Foswiki::cfg{UsersWebName}\.)?/o; 
     342    my $webRE = qr/(?:$Foswiki::cfg{UsersWebName}\.)?/; 
    342343    foreach my $baseline ( split( /\r?\n/, $text ) ) { 
    343344        my $line = 
     
    350351                    \s+\-\s+ 
    351352                    ($Foswiki::cfg{MailerContrib}{EmailFilterIn}+) 
    352                     \s*$}xo 
     353                    \s*$}x 
    353354            && $1 ne $Foswiki::cfg{DefaultUserWikiName} 
    354355          ) 
     
    369370                       ) 
    370371                       \s*(:.*)?$ 
    371                   }xo 
     372                  }x 
    372373            && $1 ne $Foswiki::cfg{DefaultUserWikiName} 
    373374          ) 
     
    433434    my $opts = 0; 
    434435    if ($options) { 
    435         $opts |= $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC; 
     436        $opts |= Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC; 
    436437        if ( $options =~ /!/ ) { 
    437             $opts |= $Foswiki::Contrib::MailerContrib::Constants::ALWAYS; 
     438            $opts |= Foswiki::Contrib::MailerContrib::Subscription::ALWAYS; 
    438439        } 
    439440    } 
  • branches/Release01x01/MailerContrib/templates/mailnotify.tmpl

    r7502 r12241  
    5858%TMPL:DEF{PLAIN:after}%%TMPL:END% 
    5959-------------------------------- 
     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-------------------------------- 
    6069%TMPL:DEF{MailNotifyBody}%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%> 
    6170To: %EMAILTO% 
    6271Subject: %WIKITOOLNAME%.%WEB% - %MAKETEXT{"Automated notification of topic changes"}% 
    6372MIME-Version: 1.0 
    64 Content-Type: multipart/alternative; boundary="=_=0i0k0i0w0tXuOi0E0A" 
     73Content-Type: multipart/alternative; boundary="=_=0i0k0i0w0s0o0fXuOi0E0A" 
    6574 
    6675This is a multi-part message in MIME format. 
    67 --=_=0i0k0i0w0tXuOi0E0A 
     76--=_=0i0k0i0w0s0o0fXuOi0E0A 
    6877Content-Type: text/plain; charset=%CHARSET%; format=flowed 
    6978Content-Transfer-Encoding: 8bit 
     
    8089  %SCRIPTURL{"view"}%/%WEB%/%NOTIFYTOPIC% 
    8190 
    82 --=_=0i0k0i0w0tXuOi0E0A 
     91--=_=0i0k0i0w0s0o0fXuOi0E0A 
    8392Content-Type: text/html; charset=%CHARSET% 
    8493Content-Transfer-Encoding: 8bit 
     
    8695%HTML_TEXT% 
    8796 
    88 --=_=0i0k0i0w0tXuOi0E0A-- 
     97--=_=0i0k0i0w0s0o0fXuOi0E0A-- 
    8998%TMPL:END% 
  • branches/Release01x01/MailerContrib/test/unit/MailerContrib/MailerContribSuite.pm

    r11094 r12241  
    230230            $meta, "Before\n${s}After" 
    231231        ); 
    232  
    233232        for my $testTopic ( keys %expectedRevs ) { 
    234233            my $parent = 'WebHome'; 
     
    408407    $this->assert( $s1->covers($s1) ); 
    409408 
    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 ); 
    412411    $this->assert( !$s1->covers($s2) ); 
    413412 
    414413    $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 ); 
    417416    $this->assert( $s1->covers($s2) ); 
    418417    $this->assert( !$s2->covers($s1) ); 
    419418 
    420419    $s1 = new Foswiki::Contrib::MailerContrib::Subscription( 'A*', 0, 
    421         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     420        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    422421    $this->assert( $s1->covers($s2) ); 
    423422    $this->assert( !$s2->covers($s1) ); 
    424423 
    425424    $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A', 1, 
    426         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     425        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    427426    $this->assert( !$s1->covers($s2) ); 
    428427    $this->assert( !$s2->covers($s1) ); 
    429428 
    430429    $s1 = new Foswiki::Contrib::MailerContrib::Subscription( 'A*', 1, 
    431         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     430        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    432431    $this->assert( $s1->covers($s2) ); 
    433432    $this->assert( !$s2->covers($s1) ); 
    434433 
    435434    $s2 = new Foswiki::Contrib::MailerContrib::Subscription( 'A*B', 1, 
    436         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     435        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    437436    $this->assert( $s1->covers($s2) ); 
    438437    $this->assert( !$s2->covers($s1) ); 
    439438 
    440439    $s1 = new Foswiki::Contrib::MailerContrib::Subscription( 'AxB', 0, 
    441         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     440        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    442441    $this->assert( !$s1->covers($s2) ); 
    443442    $this->assert( $s2->covers($s1) ); 
     
    445444    # * covers everything. 
    446445    my $AStar = new Foswiki::Contrib::MailerContrib::Subscription( 'A*', 1, 
    447         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     446        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    448447    my $Star = new Foswiki::Contrib::MailerContrib::Subscription( '*', 1, 
    449         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     448        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    450449    $this->assert( $Star->covers($AStar) ); 
    451450    $this->assert( !$AStar->covers($Star) ); 
     
    454453    my $ChildrenOfWebHome = 
    455454      new Foswiki::Contrib::MailerContrib::Subscription( 'WebHome', 2, 
    456         $Foswiki::Contrib::MailerContrib::Constants::FULL_TOPIC ); 
     455        Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC ); 
    457456    $this->assert( $Star->covers($ChildrenOfWebHome) ); 
    458457    $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) ); 
    459524} 
    460525 
Note: See TracChangeset for help on using the changeset viewer.