Changeset 2226 for trunk/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/ActionNotify.pm
- Timestamp:
- 01/29/09 13:35:57 (3 years ago)
- Location:
- trunk/ActionTrackerPlugin/lib/Foswiki
- Files:
-
- 1 edited
- 1 moved
-
. (moved) (moved from trunk/ActionTrackerPlugin/lib/TWiki)
-
Plugins/ActionTrackerPlugin/ActionNotify.pm (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/ActionNotify.pm
r1340 r2226 17 17 18 18 # This module contains the functionality of the bin/actionnotify script 19 package TWiki::Plugins::ActionTrackerPlugin::ActionNotify;19 package Foswiki::Plugins::ActionTrackerPlugin::ActionNotify; 20 20 21 21 use strict; … … 27 27 require Time::ParseDate; 28 28 29 require TWiki::Net;30 31 require TWiki::Attrs;32 33 require TWiki::Plugins::ActionTrackerPlugin::Action;34 require TWiki::Plugins::ActionTrackerPlugin::ActionSet;35 require TWiki::Plugins::ActionTrackerPlugin::Format;29 require Foswiki::Net; 30 31 require Foswiki::Attrs; 32 33 require Foswiki::Plugins::ActionTrackerPlugin::Action; 34 require Foswiki::Plugins::ActionTrackerPlugin::ActionSet; 35 require Foswiki::Plugins::ActionTrackerPlugin::Format; 36 36 37 37 my $wikiWordRE; 38 38 my $options; 39 39 40 require TWiki::Plugins::ActionTrackerPlugin::Options;40 require Foswiki::Plugins::ActionTrackerPlugin::Options; 41 41 42 42 # PUBLIC actionnotify script entry point. Reinitialises TWiki. … … 48 48 my $expr = shift; 49 49 50 my $twiki = new TWiki();50 my $twiki = new Foswiki(); 51 51 # Assign SESSION so that Func methods work 52 $ TWiki::Plugins::SESSION = $twiki;52 $Foswiki::Plugins::SESSION = $twiki; 53 53 54 54 if ( $expr =~ s/DEBUG//o ) { … … 64 64 my ( $webName, $expr, $debugMailer ) = @_; 65 65 66 $options = TWiki::Plugins::ActionTrackerPlugin::Options::load();66 $options = Foswiki::Plugins::ActionTrackerPlugin::Options::load(); 67 67 # Disable the state shortcut in mails 68 68 $options->{ENABLESTATESHORTCUT} = 0; 69 69 70 my $attrs = new TWiki::Attrs( $expr, 1 );70 my $attrs = new Foswiki::Attrs( $expr, 1 ); 71 71 my $hdr = $attrs->remove('header') || $options->{TABLEHEADER}; 72 72 my $bdy = $attrs->remove('format') || $options->{TABLEFORMAT}; … … 76 76 my $changes = $options->{NOTIFYCHANGES}; 77 77 78 my $format = new TWiki::Plugins::ActionTrackerPlugin::Format(78 my $format = new Foswiki::Plugins::ActionTrackerPlugin::Format( 79 79 $hdr, $bdy, $orient, $textform, $changes ); 80 80 … … 102 102 if ( !$attrs->isEmpty() ) { 103 103 # Get all the actions that match the search 104 $actions = TWiki::Plugins::ActionTrackerPlugin::ActionSet::allActionsInWebs( $webs, $attrs, 1 );104 $actions = Foswiki::Plugins::ActionTrackerPlugin::ActionSet::allActionsInWebs( $webs, $attrs, 1 ); 105 105 $actions->getActionees( \%people ); 106 106 } … … 130 130 131 131 if ( !defined( $mailaddr ) ) { 132 TWiki::Func::writeWarning( "No mail address found for $wikiname" );132 Foswiki::Func::writeWarning( "No mail address found for $wikiname" ); 133 133 $result .= "No mail address found for $wikiname<br />" if ( $debugMailer ); 134 134 next; … … 138 138 my $myActions; 139 139 if ( $actions ) { 140 my $ats = new TWiki::Attrs( "who=\"$wikiname\"", 1 );140 my $ats = new Foswiki::Attrs( "who=\"$wikiname\"", 1 ); 141 141 $myActions = $actions->search( $ats ); 142 142 } … … 147 147 if ( !defined( $actionsPerEmail{$email} )) { 148 148 $actionsPerEmail{$email} = 149 new TWiki::Plugins::ActionTrackerPlugin::ActionSet();149 new Foswiki::Plugins::ActionTrackerPlugin::ActionSet(); 150 150 } 151 151 $actionsPerEmail{$email}->concat( $myActions ); … … 195 195 $result .= $message; 196 196 } else { 197 my $error = TWiki::Func::sendEmail( $message );197 my $error = Foswiki::Func::sendEmail( $message ); 198 198 if ( $error ) { 199 199 $error = "ActionTrackerPlugin:ActionNotify: $error"; 200 TWiki::Func::writeWarning( $error );200 Foswiki::Func::writeWarning( $error ); 201 201 } 202 202 } … … 212 212 my ( $mailAddress ) = @_; 213 213 214 foreach my $web ( TWiki::Func::getListOfWebs( 'user' )) {214 foreach my $web ( Foswiki::Func::getListOfWebs( 'user' )) { 215 215 _loadWebNotify( $web, $mailAddress ); 216 216 } … … 223 223 224 224 # COVERAGE OFF safety net 225 if( ! TWiki::Func::webExists( $web ) ) {225 if( ! Foswiki::Func::webExists( $web ) ) { 226 226 my $error = 'ActionTrackerPlugin:ActionNotify: did not find web $web'; 227 TWiki::Func::writeWarning( $error );227 Foswiki::Func::writeWarning( $error ); 228 228 return; 229 229 } 230 230 # COVERAGE ON 231 231 232 my $topicname = $ TWiki::cfg{NotifyTopicName};233 return undef unless TWiki::Func::topicExists( $web, $topicname );232 my $topicname = $Foswiki::cfg{NotifyTopicName}; 233 return undef unless Foswiki::Func::topicExists( $web, $topicname ); 234 234 235 235 my $list = {}; 236 my $mainweb = TWiki::Func::getMainWebname();237 my $text = TWiki::Func::readTopicText( $web, $topicname, undef, 1 );236 my $mainweb = Foswiki::Func::getMainWebname(); 237 my $text = Foswiki::Func::readTopicText( $web, $topicname, undef, 1 ); 238 238 foreach my $line ( split( /\r?\n/, $text)) { 239 239 if ( $line =~ /^\s+\*\s([\w\.]+)\s+-\s+([\w\-\.\+]+\@[\w\-\.\+]+)/o ) { 240 240 my $who = $1; 241 241 my $addr = $2; 242 $who = TWiki::Plugins::ActionTrackerPlugin::Action::_canonicalName( $who );242 $who = Foswiki::Plugins::ActionTrackerPlugin::Action::_canonicalName( $who ); 243 243 if ( !defined( $mailAddress->{$who} )) { 244 TWiki::Func::writeWarning( 'ActionTrackerPlugin:ActionNotify: mail address for $who found in WebNotify' );244 Foswiki::Func::writeWarning( 'ActionTrackerPlugin:ActionNotify: mail address for $who found in WebNotify' ); 245 245 $mailAddress->{$who} = $addr; 246 246 } … … 259 259 } 260 260 my $addresses; 261 my $wikiWordRE = TWiki::Func::getRegularExpression('wikiWordRegex');262 my $webNameRE = TWiki::Func::getRegularExpression('webNameRegex');261 my $wikiWordRE = Foswiki::Func::getRegularExpression('wikiWordRegex'); 262 my $webNameRE = Foswiki::Func::getRegularExpression('webNameRegex'); 263 263 264 264 if ( $who =~ m/^([\w\-\.\+]+\@[\w\-\.\+]+)$/o ) { … … 282 282 # A legal topic wikiname 283 283 $who = 284 TWiki::Plugins::ActionTrackerPlugin::Action::_canonicalName( $who );284 Foswiki::Plugins::ActionTrackerPlugin::Action::_canonicalName( $who ); 285 285 $addresses = _getMailAddress( $who, $mailAddress ); 286 286 # Replaced by NKO … … 289 289 elsif ( $who =~ m/^($webNameRE)\.($wikiWordRE)$/o ) { 290 290 my( $inweb, $intopic ) = ( $1, $2 ); 291 $addresses = TWiki::Func::wikiToEmail($intopic); 292 291 $addresses = join(',', Foswiki::Func::wikinameToEmails($intopic)); 293 292 # LEGACY - Try and expand groups the old way 294 if( !$addresses && TWiki::Func::topicExists( $inweb, $intopic ) ) {293 if( !$addresses && Foswiki::Func::topicExists( $inweb, $intopic ) ) { 295 294 my $text = 296 TWiki::Func::readTopicText( $inweb, $intopic, undef, 1 );295 Foswiki::Func::readTopicText( $inweb, $intopic, undef, 1 ); 297 296 if ( $intopic =~ m/Group$/o ) { 298 297 # If it's a Group topic, match * Set GROUP = … … 324 323 $since, $mailaddr, $format ) = @_; 325 324 326 my $from = $ TWiki::cfg{WebMasterEmail} ||327 TWiki::Func::getPreferencesValue( 'WIKIWEBMASTER' ) || '';328 329 my $text = TWiki::Func::readTemplate( 'actionnotify' ) || <<'HERE';325 my $from = $Foswiki::cfg{WebMasterEmail} || 326 Foswiki::Func::getPreferencesValue( 'WIKIWEBMASTER' ) || ''; 327 328 my $text = Foswiki::Func::readTemplate( 'actionnotify' ) || <<'HERE'; 330 329 From: %EMAILFROM% 331 330 To: %EMAILTO% … … 352 351 if ( $actionsString ne '' ) { 353 352 $text =~ s/%ACTIONS_AS_STRING%/$actionsString/go; 354 my $asHTML = TWiki::Func::renderText( $actionsHTML );353 my $asHTML = Foswiki::Func::renderText( $actionsHTML ); 355 354 $text =~ s/%ACTIONS_AS_HTML%/$asHTML/go; 356 355 $text =~ s/%ACTIONS%(.*?)%END%/$1/gso; … … 360 359 361 360 if( $since ) { 362 $since = TWiki::Func::formatTime( $since );361 $since = Foswiki::Func::formatTime( $since ); 363 362 } else { 364 363 $since = ''; … … 368 367 if ( $changesString ne '' ) { 369 368 $text =~ s/%CHANGES_AS_STRING%/$changesString/go; 370 my $asHTML = TWiki::Func::renderText( $changesHTML );369 my $asHTML = Foswiki::Func::renderText( $changesHTML ); 371 370 $text =~ s/%CHANGES_AS_HTML%/$asHTML/go; 372 371 $text =~ s/%CHANGES%(.*?)%END%/$1/gso; … … 375 374 } 376 375 377 $text = TWiki::Func::expandCommonVariables( $text,378 $ TWiki::cfg{HomeTopicName} );376 $text = Foswiki::Func::expandCommonVariables( $text, 377 $Foswiki::cfg{HomeTopicName} ); 379 378 380 379 $text =~ s/<img src=.*?[^>]>/[IMG]/goi; # remove all images … … 382 381 # add the url host to any in-twiki urls that lack it 383 382 # SMELL: doesn't handle (undocumented) {ScriptUrlPaths} 384 my $sup = $ TWiki::cfg{ScriptUrlPath};383 my $sup = $Foswiki::cfg{ScriptUrlPath}; 385 384 $sup =~ s#/$##; 386 my $sun = TWiki::Func::getUrlHost() . $sup;385 my $sun = Foswiki::Func::getUrlHost() . $sup; 387 386 $text =~ s#href=\"$sup/#href=\"$sun/#ogi; 388 387 $text =~ s/<\/?nop( \/)?>//goi; … … 406 405 # Recover the rev at the previous date 407 406 my $oldrev = 408 TWiki::Func::getRevisionAtTime( $theWeb, $theTopic, $theDate );407 Foswiki::Func::getRevisionAtTime( $theWeb, $theTopic, $theDate ); 409 408 return unless defined( $oldrev ); 410 409 411 410 $oldrev =~ s/\d+\.(\d+)/$1/o; 412 411 # Recover the action set at that date 413 my $text = TWiki::Func::readTopicText( $theWeb, $theTopic, $oldrev, 1 );412 my $text = Foswiki::Func::readTopicText( $theWeb, $theTopic, $oldrev, 1 ); 414 413 415 414 my $oldActions = 416 TWiki::Plugins::ActionTrackerPlugin::ActionSet::load( $theWeb,415 Foswiki::Plugins::ActionTrackerPlugin::ActionSet::load( $theWeb, 417 416 $theTopic, $text ); 418 417 # Recover the current action set. 419 $text = TWiki::Func::readTopicText( $theWeb, $theTopic, undef, 1 );418 $text = Foswiki::Func::readTopicText( $theWeb, $theTopic, undef, 1 ); 420 419 my $currentActions = 421 TWiki::Plugins::ActionTrackerPlugin::ActionSet::load( $theWeb,420 Foswiki::Plugins::ActionTrackerPlugin::ActionSet::load( $theWeb, 422 421 $theTopic, $text ); 423 422 … … 434 433 sub _findChangesInWeb { 435 434 my ( $web, $topics, $theDate, $format, $notifications ) = @_; 436 my $actions = new TWiki::Plugins::ActionTrackerPlugin::ActionSet();437 438 my @tops = TWiki::Func::getTopicList( $web );435 my $actions = new Foswiki::Plugins::ActionTrackerPlugin::ActionSet(); 436 437 my @tops = Foswiki::Func::getTopicList( $web ); 439 438 my $grep = 440 TWiki::Func::searchInWebContent( '%ACTION{.*}%', $web, \@tops,439 Foswiki::Func::searchInWebContent( '%ACTION{.*}%', $web, \@tops, 441 440 { type => 'regex', 442 441 casesensitive => 1, … … 458 457 sub _findChangesInWebs { 459 458 my ( $webs, $topics, $date, $format, $notifications ) = @_; 460 my @weblist = grep { /^$webs$/ } TWiki::Func::getListOfWebs( 'user' );459 my @weblist = grep { /^$webs$/ } Foswiki::Func::getListOfWebs( 'user' ); 461 460 foreach my $web ( @weblist ) { 462 461 _findChangesInWeb( $web, $topics, $date,
Note: See TracChangeset
for help on using the changeset viewer.
