#!/usr/bin/perl -wT # # TWiki Collaboration Platform, http://TWiki.org/ # # Copyright (C) 1999-2003 Peter Thoeny, peter@thoeny.com # # For licensing info read license.txt file in the TWiki root. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details, published at # http://www.gnu.org/copyleft/gpl.html # Colas (http://colas.nahaboo.net) # modifications from mailnotify script from Dec 2001 release: # - email is now optional, is fetched from the user homepage # - webs not beginning by a capital letter are ignored ( _default, ...) # - no mail is sent to TWikiGuest # - if user is a group, recurses through its members # Set library paths in @INC, at compile time BEGIN { unshift @INC, '.'; require 'setlib.cfg'; } use TWiki; use TWiki::Net; use MailNotify; &main(); sub main { my $debug=1; my $test=0; my $keepmails=0; my @weblist=(); my $dataDir = &TWiki::getDataDir(); while ( $_=shift (@ARGV) ) { if (/^-q$/) { $debug=0; next; } if (/^-t$/) { $test=1; next; } if (/^-k$/) { my( $sec, $min, $hour, $mday, $mon, $year, $wday ) = gmtime( time ); $keepmails=sprintf("%.4u\-%.2u\-%.2u_%.2uh%.2u", 1900+$year, $mon+1, $mday, $hour, $min); next; } if (-d "$dataDir/$_") {push ( @weblist, $_); next; } } &TWiki::basicInitialize(); if ( $#weblist <0 ) { opendir( DIR, "$dataDir" ) or die "could not open $dataDir"; foreach ( grep !/^\.\.?$/, readdir DIR ) { if ( /^_/ ) { next; } if (-d "$dataDir/$_") { push ( @weblist, $_); next; } } closedir DIR; } $debug && print "TWiki mail notification for webs : ", join (" ", @weblist), "\n"; $debug && print "- to suppress all normal output: mailnotify -q\n"; $debug && print "- to test only (and send NO mail) : mailnotify -t\n"; foreach $web ( @weblist ) { # Only process webs with normal names, i.e. not starting with '_' if( &TWiki::isWebName($web) ) { &MailNotify::processWeb( $web , $debug, $test, $keepmails); # remove obsolete .lock files &TWiki::Store::removeObsoleteTopicLocks( $web ); } else { $debug && print "Skipped non wiki web : $web\n"; } } $debug && print "End TWiki mail notification\n"; }