Ignore:
Timestamp:
11/19/08 15:00:00 (4 years ago)
Author:
CrawfordCurrie
Message:

Item175: port a subset of the standard extensions over to the new namespace to make a working system with mixed TWiki and Foswiki plugins

Location:
trunk/MailerContrib/lib/Foswiki
Files:
1 edited
1 moved

Legend:

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

    r781 r811  
    22# 
    33# Copyright (C) 2004 Wind River Systems Inc. 
    4 # Copyright (C) 1999-2007 TWiki Contributors. 
    5 # All Rights Reserved. TWiki Contributors 
     4# Copyright (C) 1999-2007 Foswiki Contributors. 
     5# All Rights Reserved. Foswiki Contributors 
    66# are listed in the AUTHORS file in the root of this distribution. 
    77# NOTE: Please extend that file, not this notice. 
     
    2121=pod 
    2222 
    23 ---+ package TWiki::Contrib::MailerContrib::WebNotify 
     23---+ package Foswiki::Contrib::MailerContrib::WebNotify 
    2424Object that represents the contents of a %NOTIFYTOPIC% topic in a TWiki web. 
    2525 
    26 Note that =$TWiki::Plugins::SESSION= is used to find the TWiki session, and 
     26Note that =$Foswiki::Plugins::SESSION= is used to find the TWiki session, and 
    2727must be set up before this class is used. 
    2828 
    2929=cut 
    3030 
    31 package TWiki::Contrib::MailerContrib::WebNotify; 
     31package Foswiki::Contrib::MailerContrib::WebNotify; 
    3232 
    3333use strict; 
     
    3636use Assert; 
    3737 
    38 require TWiki::Func; 
    39 require TWiki::Contrib::MailerContrib; 
    40 require TWiki::Contrib::MailerContrib::Subscriber; 
    41 require TWiki::Contrib::MailerContrib::Subscription; 
     38require Foswiki::Func; 
     39require Foswiki::Contrib::MailerContrib; 
     40require Foswiki::Contrib::MailerContrib::Subscriber; 
     41require Foswiki::Contrib::MailerContrib::Subscription; 
    4242 
    4343=pod 
     
    6262 
    6363    # Ensure the contrib is initialised 
    64     TWiki::Contrib::MailerContrib::initContrib(); 
     64    Foswiki::Contrib::MailerContrib::initContrib(); 
    6565 
    6666    $this->{web} = $web; 
    67     $this->{topic} = $topic || $TWiki::cfg{NotifyTopicName} || 'WebNotify'; 
     67    $this->{topic} = $topic || $Foswiki::cfg{NotifyTopicName} || 'WebNotify'; 
    6868    $this->{pretext} = ''; 
    6969    $this->{posttext} = ''; 
     
    7171    $this->{noexpandgroups} = $noexpandgroups; 
    7272 
    73     if( TWiki::Func::topicExists( $web, $topic )) { 
     73    if( Foswiki::Func::topicExists( $web, $topic )) { 
    7474        $this->_load(); 
    7575    } 
     
    8989sub writeWebNotify { 
    9090    my $this = shift; 
    91     TWiki::Func::saveTopicText( 
     91    Foswiki::Func::saveTopicText( 
    9292        $this->{web}, 
    9393        $this->{topic}, 
     
    114114    unless ( $noAdd || defined( $subscriber )) { 
    115115        $subscriber = 
    116           new TWiki::Contrib::MailerContrib::Subscriber( $name ); 
     116          new Foswiki::Contrib::MailerContrib::Subscriber( $name ); 
    117117        $this->{subscribers}{$name} = $subscriber; 
    118118    } 
     
    151151    my @names = ($name); 
    152152    unless ($this->{noexpandgroups}) { 
    153         if (defined &TWiki::Func::eachGroupMember) { 
    154             my $it = TWiki::Func::eachGroupMember( $name ); 
     153        if (defined &Foswiki::Func::eachGroupMember) { 
     154            my $it = Foswiki::Func::eachGroupMember( $name ); 
    155155            if( $it ) { 
    156156                @names = (); 
     
    161161            } 
    162162        } else { 
    163             my $user = TWiki::User->new($this->{session}, '', $name); 
     163            my $user = Foswiki::User->new($this->{session}, '', $name); 
    164164            if ($user->isGroup) { 
    165165                @names = map {$_->wikiName} @{$user->groupMembers}; 
     
    170170    foreach my $n (@names) { 
    171171        my $subscriber = $this->getSubscriber( $n ); 
    172         my $sub = new TWiki::Contrib::MailerContrib::Subscription( 
     172        my $sub = new Foswiki::Contrib::MailerContrib::Subscription( 
    173173            $topics, $depth, $opts ); 
    174174        $subscriber->subscribe( $sub ); 
     
    193193    my @names = ( $name ); 
    194194    unless ($this->{noexpandgroups}) { 
    195         if (defined &TWiki::Func::eachGroupMember) { 
    196             my $it = TWiki::Func::eachGroupMember( $name ); 
     195        if (defined &Foswiki::Func::eachGroupMember) { 
     196            my $it = Foswiki::Func::eachGroupMember( $name ); 
    197197            if( $it ) { 
    198198                @names = (); 
     
    203203            } 
    204204        } else { 
    205             my $user = TWiki::User->new($this->{session}, '', $name); 
     205            my $user = Foswiki::User->new($this->{session}, '', $name); 
    206206            if ($user->isGroup) { 
    207207                @names = map {$_->wikiName} @{$user->groupMembers}; 
     
    212212    foreach my $n (@names) { 
    213213        my $subscriber = $this->getSubscriber( $n ); 
    214         my $sub = new TWiki::Contrib::MailerContrib::Subscription( 
     214        my $sub = new Foswiki::Contrib::MailerContrib::Subscription( 
    215215            $topics, $depth, 0 ); 
    216216        $subscriber->unsubscribe( $sub ); 
     
    247247 
    248248---++ processChange($change, $db, $changeSet, $seenSet, $allSet) 
    249    * =$change= - ref of a TWiki::Contrib::Mailer::Change 
    250    * =$db= - TWiki::Contrib::MailerContrib::UpData database of parent references 
     249   * =$change= - ref of a Foswiki::Contrib::Mailer::Change 
     250   * =$db= - Foswiki::Contrib::MailerContrib::UpData database of parent references 
    251251   * =$changeSet= - ref of a hash mapping emails to sets of changes 
    252252   * =$seenSet= - ref of a hash recording indices of topics already seen 
     
    264264    my $web = $change->{WEB}; 
    265265    my %authors = map { $_ => 1 } 
    266       @{TWiki::Contrib::MailerContrib::Subscriber::getEmailAddressesForUser( 
     266      @{Foswiki::Contrib::MailerContrib::Subscriber::getEmailAddressesForUser( 
    267267          $change->{author})}; 
    268268 
     
    272272        if ($subs && !$subscriber->isUnsubscribedFrom( $topic, $db )) { 
    273273 
    274             next unless TWiki::Func::checkAccessPermission( 
     274            next unless Foswiki::Func::checkAccessPermission( 
    275275                'VIEW', $name, undef, $topic, $this->{web}, undef ); 
    276276 
     
    306306---++ processCompulsory($topic, $db, \%allSet) 
    307307   * =$topic= - topic name 
    308    * =$db= - TWiki::Contrib::MailerContrib::UpData database of parent references 
     308   * =$db= - Foswiki::Contrib::MailerContrib::UpData database of parent references 
    309309   * =\%allSet= - ref of a hash that maps topics to email addresses for news subscriptions 
    310310 
     
    346346    my $this = shift; 
    347347 
    348     my ( $meta, $text ) = TWiki::Func::readTopic( 
     348    my ( $meta, $text ) = Foswiki::Func::readTopic( 
    349349        $this->{web}, $this->{topic} ); 
    350350    my $in_pre = 1; 
     
    354354    # join \ terminated lines 
    355355    $text =~ s/\\\r?\n//gs; 
    356     my $webRE = qr/(?:$TWiki::cfg{UsersWebName}\.)?/o; 
     356    my $webRE = qr/(?:$Foswiki::cfg{UsersWebName}\.)?/o; 
    357357    foreach my $baseline ( split ( /\r?\n/, $text )) { 
    358         my $line = TWiki::Func::expandCommonVariables( 
     358        my $line = Foswiki::Func::expandCommonVariables( 
    359359            $baseline, $this->{topic}, $this->{web}, $meta); 
    360         if( $line =~ /^\s+\*\s$webRE($TWiki::regex{wikiWordRegex})\s+\-\s+($TWiki::cfg{MailerContrib}{EmailFilterIn}+)\s*$/o 
    361               && $1 ne $TWiki::cfg{DefaultUserWikiName}) { 
     360        if( $line =~ /^\s+\*\s$webRE($Foswiki::regex{wikiWordRegex})\s+\-\s+($Foswiki::cfg{MailerContrib}{EmailFilterIn}+)\s*$/o 
     361              && $1 ne $Foswiki::cfg{DefaultUserWikiName}) { 
    362362            # Main.WikiName - email@domain (legacy format) 
    363363            $this->subscribe( $2, '*', 0, 0 ); 
    364364            $in_pre = 0; 
    365365        } 
    366         elsif ( $line =~ /^\s+\*\s$webRE($TWiki::regex{wikiWordRegex}|'.*?'|".*?"|$TWiki::cfg{MailerContrib}{EmailFilterIn})\s*(:.*)?$/o 
    367                   && $1 ne $TWiki::cfg{DefaultUserWikiName}) { 
     366        elsif ( $line =~ /^\s+\*\s$webRE($Foswiki::regex{wikiWordRegex}|'.*?'|".*?"|$Foswiki::cfg{MailerContrib}{EmailFilterIn})\s*(:.*)?$/o 
     367                  && $1 ne $Foswiki::cfg{DefaultUserWikiName}) { 
    368368            my $subscriber = $1; 
    369369            # Get the topic list from the last bracket matched. Have to do it 
     
    397397    $this->{topicSub} = \&_subscribeTopic; 
    398398     
    399     my $ret = TWiki::Contrib::MailerContrib::parsePageList($this, $who, $spec, $unsubscribe); 
     399    my $ret = Foswiki::Contrib::MailerContrib::parsePageList($this, $who, $spec, $unsubscribe); 
    400400    if ( $ret =~ m/\S/ ) { 
    401         TWiki::Func::writeWarning( 
     401        Foswiki::Func::writeWarning( 
    402402            "Badly formatted page list at $who: $spec"); 
    403403        return -1; 
     
    409409    my ( $this, $who, $unsubscribe, $webTopic, $options, $childDepth ) = @_; 
    410410     
    411     my ($web, $topic) = TWiki::Func::normalizeWebTopicName($this->{web}, $webTopic); 
     411    my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($this->{web}, $webTopic); 
    412412     
    413413#print STDERR "_subscribeTopic($topic)\n"; 
     
    438438    unless (defined $this->{nomail}{$name}) { 
    439439        $this->{nomail}{$name} = 1; 
    440         TWiki::Func::writeWarning( 
     440        Foswiki::Func::writeWarning( 
    441441            "Failed to find permitted email for '". 
    442442              $subscriber->stringify()."' when processing web '$web'"); 
Note: See TracChangeset for help on using the changeset viewer.