## There are many more options for fine tuning available see
## /includes/DefaultSettings.php
## UPO means: this is also a user preference option
-\$wgEmailNotificationForUserTalkPages = $enotifusertalk; # UPO
-\$wgEmailNotificationForWatchlistPages = $enotifwatchlist; # UPO
+\$wgEnotifUserTalk = $enotifusertalk; # UPO
+\$wgEnotifWatchlist = $enotifwatchlist; # UPO
\$wgEmailAuthentication = $eauthent;
\$wgDBserver = \"{$slconf['DBserver']}\";
include_once( "UserMailer.php" );
$wgEnotif = new EmailNotification ();
- $wgEnotif->NotifyOnPageChange( $wgUser->getID(), $this->mTitle->getDBkey(), $this->mTitle->getNamespace(),$now, $summary, $me2, $oldid );
+ $wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
}
/**
global $wgUser;
if ($this->mTitle->getNamespace() == NS_USER_TALK &&
- $this->mTitle->getText() == $wgUser->getName()) {
+ $this->mTitle->getText() == $wgUser->getName())
+ {
require_once( 'UserTalkUpdate.php' );
$u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false );
} else {
if ( $rcObj->watched ) $link = '<strong>'.$link.'</strong>' ;
$r .= $link ;
- if ($rcObj->notificationtimestamp) {
- $r .= wfMsg( 'updatedmarker' );
- }
-
# Diff
$r .= ' (' ;
$r .= $rcObj->difflink ;
if ( $block[0]->watched ) $link = '<strong>'.$link.'</strong>' ;
$r .= $link ;
- if ($block[0]->notificationtimestamp) {
- $r .= wfMsg( 'updatedmarker' );
- }
-
$curIdEq = 'curid=' . $block[0]->mAttribs['rc_cur_id'];
if ( $block[0]->mAttribs['rc_type'] != RC_LOG ) {
# Changes
$articleLink = '<strong>'.$articleLink.'</strong>';
}
- if ($rc->notificationtimestamp) {
- $articleLink .= wfMsg( 'updatedmarker' );
- }
-
$s .= ' '.$articleLink;
wfProfileOut("$fname-page");
}
$rc->watched = $watched ;
$rc->link = $clink ;
$rc->timestamp = $time;
- $rc->notificationtimestamp = $baseRC->notificationtimestamp;
$rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
# Make "cur" and "diff" links
# Email notification settings
#
-/**
- * Program to run when the email is actually sent out. You might want to make
- * your server beep for example. Usermailer.php will make a system() call with
- * exactly that string as parameter.
- */
-# $wgEmailNotificationSystembeep = '/usr/bin/beep -f 4000 -l 20 &';
-$wgEmailNotificationSystembeep = '';
-
/** For email notification on page changes */
$wgPasswordSender = $wgEmergencyContact;
-# true: from PageEditor if s/he opted-in
+# true: from page editor if s/he opted-in
# false: Enotif mails appear to come from $wgEmergencyContact
-$wgEmailNotificationMailsSentFromPageEditor = false;
+$wgEnotifFromEditor = false;
// TODO move UPO to preferences probably ?
# If set to true, users get a corresponding option in their preferences and can choose to enable or disable at their discretion
# If set to false, the corresponding input form on the user preference page is suppressed
# It call this to be a "user-preferences-option (UPO)"
$wgEmailAuthentication = true; # UPO (if this is set to false, texts referring to authentication are suppressed)
-$wgEmailNotificationForWatchlistPages = false; # UPO
-$wgEmailNotificationForUserTalkPages = false; # UPO
-$wgEmailNotificationRevealPageEditorAddress = false; # UPO; reply-to address may be filled with page editor's address (if user allowed this in the preferences)
-$wgEmailNotificationForMinorEdits = true; # UPO; false: "minor edits" on pages do not trigger notification mails.
+$wgEnotifWatchlist = false; # UPO
+$wgEnotifUserTalk = false; # UPO
+$wgEnotifRevealEditorAddress = false; # UPO; reply-to address may be filled with page editor's address (if user allowed this in the preferences)
+$wgEnotifMinorEdits = true; # UPO; false: "minor edits" on pages do not trigger notification mails.
# # Attention: _every_ change on a user_talk page trigger a notification mail (if the user is not yet notified)
if ( $isConflict ) {
require_once( "DifferenceEngine.php" );
- $wgOut->WikiText( '==' . wfMsg( "yourdiff" ) . '==' );
+ $wgOut->addWikiText( '==' . wfMsg( "yourdiff" ) . '==' );
DifferenceEngine::showDiff( $this->textbox2, $this->textbox1,
wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
- $wgOut->WikiText( '==' . wfMsg( "yourtext" ) . '==' );
+ $wgOut->addWikiText( '==' . wfMsg( "yourtext" ) . '==' );
$wgOut->addHTML( "<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
. htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox2 ) ) .
"
wfProfileIn( "$fname-init" );
$this->initPage( $out );
- $this->mTitle = $wgTitle;
+ $this->mTitle =& $wgTitle;
$this->mUser =& $wgUser;
$tpl =& $this->setupTemplate( $this->template, 'skins' );
# User can come back through the confirmation URL to re-enable email.
$result = $wgUser->sendConfirmationMail();
if( WikiError::isError( $result ) ) {
- $error = wfMsg( 'mailerror', $result->getMessage() );
+ $error = wfMsg( 'mailerror', $result->toString() );
} else {
- $error = wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() );
+ $error = wfMsg( 'eauthentsent', $wgUser->getName() );
}
}
} else {
global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
global $wgLanguageNames, $wgDisableLangConversion;
- global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
- global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
+ global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
+ global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
global $wgContLanguageCode;
if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
if( $wgUser->getEmailAuthenticationTimestamp() ) {
$emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
- $disabled = '';
} else {
$skin = $wgUser->getSkin();
$emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
$skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ),
wfMsg( 'emailconfirmlink' ) );
- $disabled = ' '.wfMsg('disableduntilauthent');
}
} else {
$emailauthenticated = '';
- $disabled = false; // If it hasn't been set already the wiki will spew errors
}
if ($this->mUserEmail == '') {
- $disabled = ' '.wfMsg('disablednoemail');
+ $emailauthenticated = wfMsg( 'noemailprefs' );
}
$ps = $this->namespacesCheckboxes();
- $enotifwatchlistpages = ($wgEmailNotificationForWatchlistPages) ? $this->getToggle( 'enotifwatchlistpages', $disabled) : '';
- $enotifusertalkpages = ($wgEmailNotificationForUserTalkPages) ? $this->getToggle( 'enotifusertalkpages', $disabled) : '';
- $enotifminoredits = ($wgEmailNotificationForMinorEdits) ? $this->getToggle( 'enotifminoredits', $disabled) : '';
- $enotifrevealaddr = ($wgEmailNotificationRevealPageEditorAddress) ? $this->getToggle( 'enotifrevealaddr', $disabled) : '';
- $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
+ $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages' ) : '';
+ $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages' ) : '';
+ $enotifminoredits = ($wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits' ) : '';
+ $enotifrevealaddr = ($wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr' ) : '';
+ $prefs_help_email_enotif = ( $wgEnotifWatchlist || $wgEnotifUserTalk) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
$prefs_help_realname = '';
# </FIXME>
if ($wgEnableUserEmail) {
$emf = wfMsg( 'emailflag' );
$wgOut->addHTML(
- "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf.$disabled</label></div>" );
+ "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
}
$wgOut->addHTML( '</fieldset>' );
$hideOwn = $wgRequest->getBool( 'hideOwn' );
$id = $wgRequest->getArray( 'id' );
- if( $wgUser->getOption( 'enotifwatchlistpages' ) ) {
- $wgOut->addHTML( "<div class='enotifinfo'>\n" );
-
- $wgOut->addWikiText( wfMsg( 'email_notification_infotext' ) );
-
- $wgOut->addHTML( '<form action="' .
- $specialTitle->escapeLocalUrl( 'action=submit&magic=yes' ) .
- '" method="post"><input type="submit" name="dummy" value="' .
- htmlspecialchars( wfMsg( 'email_notification_reset' ) ) .
- '" /><input type="hidden" name="reset" value="all" /></form>' .
- "</div>\n\n" );
- }
-
$uid = $wgUser->getID();
if( $wgRequest->getVal( 'reset' ) == 'all' ) {
$wgUser->clearAllNotifications( $uid );
$nitems = $s->n;
if($nitems == 0) {
- $wgOut->addWikiText( wfMsg( 'nowatchlist' ) );
- return;
+ $wgOut->addWikiText( wfMsg( 'nowatchlist' ) );
+ return;
}
-
+
if ( is_null( $days ) ) {
$big = 1000;
if($nitems > $big) {
$npages = $s->n;
}
-
- if($wgRequest->getBool('magic')) {
+
+ if($wgRequest->getBool('edit')) {
$wgOut->addWikiText( wfMsg( 'watchlistcontains', $wgLang->formatNum( $nitems ) ) .
"\n\n" . wfMsg( 'watcheditlist' ) );
}
$andHideOwn = $hideOwn ? "AND (rev_user <> $uid)" : '';
+
+ # Show watchlist header
+ if( $wgUser->getOption( 'enotifwatchlistpages' ) ) {
+ $wgOut->addHTML( "<div class='enotifinfo'>\n" );
+
+ $wgOut->addWikiText( wfMsg( 'enotif_infotext' ) );
+
+ $wgOut->addHTML( '<form action="' .
+ $specialTitle->escapeLocalUrl( 'action=submit&edit=yes' ) .
+ '" method="post"><input type="submit" name="dummy" value="' .
+ htmlspecialchars( wfMsg( 'enotif_reset' ) ) .
+ '" /><input type="hidden" name="reset" value="all" /></form>' .
+ "</div>\n\n" );
+ }
+
$wgOut->addHTML( '<i>' . wfMsg( 'watchdetails',
$wgLang->formatNum( $nitems ), $wgLang->formatNum( $npages ), $y,
- $specialTitle->escapeLocalUrl( 'magic=yes' ) ) . "</i><br />\n" );
+ $specialTitle->escapeLocalUrl( 'edit=yes' ) ) . "</i><br />\n" );
$use_index = $dbr->useIndexClause( $x );
$sql = "SELECT
$rc->counter = $counter++;
if ($wgShowUpdatedMarker && $wgUser->getOption( 'showupdated' )) {
- $rc->notificationtimestamp = $obj->wl_notificationtimestamp;
+ $updated = $obj->wl_notificationtimestamp;
} else {
- $rc->notificationtimestamp = false;
+ $updated = false;
}
if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
$rc->numberofWatchingusers = 0;
}
- $s .= $list->recentChangesLine( $rc, true);
+ $s .= $list->recentChangesLine( $rc, $updated );
}
$s .= $list->endRecentChangesList();
var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
var $mDefaultNamespace; # Namespace index when there is no namespace
# Zero except in {{transclusion}} tags
+ var $mWatched; # Is $wgUser watching this page? NULL if unfilled, accessed through userIsWatching()
/**#@-*/
# Dont change the following, NS_MAIN is hardcoded in several place
# See bug #696
$this->mDefaultNamespace = NS_MAIN;
+ $this->mWatched = NULL;
}
/**
function userIsWatching() {
global $wgUser;
- if ( -1 == $this->mNamespace ) { return false; }
- if ( 0 == $wgUser->getID() ) { return false; }
-
- return $wgUser->isWatched( $this );
+ if ( is_null( $this->mWatched ) ) {
+ if ( -1 == $this->mNamespace || 0 == $wgUser->getID()) {
+ $this->mWatched = false;
+ } else {
+ $this->mWatched = $wgUser->isWatched( $this );
+ }
+ }
+ return $this->mWatched;
}
/**
* If e-notif e-mails are on, they will receive notification mails on
* the next change of the page if it's watched etc.
*/
- function clearNotification( $title ) {
- $userid = $this->getId();
+ function clearNotification( &$title ) {
+ global $wgUser;
+
+ $userid = $this->getID();
if ($userid==0)
return;
- $dbw =& wfGetDB( DB_MASTER );
- $success = $dbw->update( 'watchlist',
- array( /* SET */
- 'wl_notificationtimestamp' => 0
- ), array( /* WHERE */
- 'wl_title' => $title->getDBkey(),
- 'wl_namespace' => $title->getNamespace(),
- 'wl_user' => $this->getId()
- ), 'User::clearLastVisited'
- );
+
+ // Only update the timestamp if the page is being watched.
+ // The query to find out if it is watched is cached both in memcached and per-invocation,
+ // and when it does have to be executed, it can be on a slave
+ // If this is the user's newtalk page, we always update the timestamp
+ if ($title->getNamespace() == NS_USER_TALK &&
+ $title->getText() == $wgUser->getName())
+ {
+ $watched = true;
+ } elseif ( $this->getID() == $wgUser->getID() ) {
+ $watched = $title->userIsWatching();
+ } else {
+ $watched = true;
+ }
+
+ // If the page is watched by the user (or may be watched), update the timestamp on any
+ // any matching rows
+ if ( $watched ) {
+ $dbw =& wfGetDB( DB_MASTER );
+ $success = $dbw->update( 'watchlist',
+ array( /* SET */
+ 'wl_notificationtimestamp' => 0
+ ), array( /* WHERE */
+ 'wl_title' => $title->getDBkey(),
+ 'wl_namespace' => $title->getNamespace(),
+ 'wl_user' => $this->getID()
+ ), 'User::clearLastVisited'
+ );
+ }
}
/**#@-*/
require_once( 'WikiError.php' );
/**
- * Provide mail capabilities
- * @param string $string ????
- *
- * The function takes formats like "name <emailaddr>" into account, for which
- * the partial string "name" will be quoted-printable converted but not
- * "<emailaddr>".
- *
- * The php mail() function does not accept the email address partial string to
- * be quotedprintable, it does not accept inputs as
- * quotedprintable("name <emailaddr>") .
- *
- * case 1:
- * input: "name <emailaddr> rest"
- * output: "quoted-printable(name) <emailaddr>"
- *
- * case 2: (should not happen)
- * input: "<emailaddr> rest"
- * output: "<emailaddr>"
- *
- * case 3: (should not happen)
- * input: "name"
- * output: "quoted-printable(name)"
+ * Converts a string into a valid RFC 822 "phrase", such as is used for the sender name
*/
-function wfQuotedPrintable_name_and_emailaddr( $string ) {
-
- /* do not quote printable for email address string <emailaddr>, but only for the (leading) string, usually the name */
- if( preg_match( '/^([^<]*)?(<([A-z0-9_.-]+([A-z0-9_.-]+)*\@[A-z0-9_-]+([A-z0-9_.-]+)*([A-z.]{2,})+)>)?$/', $string, $part ) ) {
- wfDebug( "wfQuotedPrintable_name_and_emailaddr: '$string' " . serialize( $part ) . "\n" );
- if ( !isset($part[2]) ) return wfQuotedprintable($part[1]);
- return wfQuotedprintable($part[1]) . $part[2] ;
- } else {
- # What have we been given??
- wfDebug( "wfQuotedPrintable_name_and_emailaddr: got confused by '$string'\n" );
- return wfQuotedprintable( $string );
- }
+function wfRFC822Phrase( $phrase ) {
+ $phrase = strtr( $phrase, array( "\r" => '', "\n" => '', '"' => '' ) );
+ return '"' . $phrase . '"';
}
/**
function userMailer( $to, $from, $subject, $body, $replyto=false ) {
global $wgUser, $wgSMTP, $wgOutputEncoding, $wgErrorString, $wgEmergencyContact;
- $qto = wfQuotedPrintable_name_and_emailaddr( $to );
-
if (is_array( $wgSMTP )) {
require_once( 'Mail.php' );
$timestamp = time();
$headers['From'] = $from;
-/* removing to: field as it should be set by the send() function below
- UNTESTED - Hashar */
-// $headers['To'] = $qto;
-/* Reply-To:
- UNTESTED - Tom Gries */
- $headers['Reply-To'] = $replyto;
+ if ( $replyto ) {
+ $headers['Reply-To'] = $replyto;
+ }
$headers['Subject'] = $subject;
$headers['MIME-Version'] = '1.0';
$headers['Content-type'] = 'text/plain; charset='.$wgOutputEncoding;
"Content-type: text/plain; charset={$wgOutputEncoding}\n" .
"Content-Transfer-Encoding: 8bit\n" .
"X-Mailer: MediaWiki mailer\n".
- 'From:' . wfQuotedPrintable_name_and_emailaddr($from) . "\n";
+ 'From: ' . $from . "\n";
if ($replyto) {
- $headers .= 'Reply-To: '.wfQuotedPrintable_name_and_emailaddr($replyto)."\n";
+ $headers .= "Reply-To: $replyto\n";
}
$wgErrorString = '';
set_error_handler( 'mailErrorHandler' );
# added -f parameter, see PHP manual for the fifth parameter when using the mail function
- mail( wfQuotedPrintable_name_and_emailaddr($to), $subject, $body, $headers, "-f{$wgEmergencyContact}\n");
+ mail( $to, $subject, $body, $headers, "-f{$wgEmergencyContact}\n");
restore_error_handler();
+ if ( $wgErrorString ) {
+ wfDebug( "Error sending mail: $wgErrorString\n" );
+ }
return $wgErrorString;
}
}
* @access private
*/
var $to, $subject, $body, $replyto, $from;
+ var $user, $title, $timestamp, $summary, $minorEdit, $oldid;
+
/**#@-*/
/**
* @todo document
- * @param $currentUser
* @param $currentPage
* @param $currentNs
* @param $timestamp
* @param $currentMinorEdit
* @param $oldid (default: false)
*/
- function NotifyOnPageChange($currentUser, $currentPage, $currentNs, $timestamp, $currentSummary, $currentMinorEdit, $oldid=false) {
+ function notifyOnPageChange(&$title, $timestamp, $summary, $minorEdit, $oldid=false) {
# we use $wgEmergencyContact as sender's address
global $wgUser, $wgLang, $wgEmergencyContact;
- global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForMinorEdits;
- global $wgEmailNotificationSystembeep, $wgEmailNotificationForUserTalkPages;
- global $wgEmailNotificationRevealPageEditorAddress;
- global $wgEmailNotificationMailsSentFromPageEditor;
+ global $wgEnotifWatchlist, $wgEnotifMinorEdits;
+ global $wgEnotifUserTalk;
+ global $wgEnotifRevealEditorAddress;
+ global $wgEnotifFromEditor;
global $wgEmailAuthentication;
- global $beeped;
-
+
# The following code is only run, if several conditions are met:
# 1. EmailNotification for pages (other than user_talk pages) must be enabled
# 2. minor edits (changes) are only regarded if the global flag indicates so
- $isUserTalkPage = ($currentNs == NS_USER_TALK);
- $enotifusertalkpage = ($isUserTalkPage && $wgEmailNotificationForUserTalkPages);
- $enotifwatchlistpage = (!$isUserTalkPage && $wgEmailNotificationForWatchlistPages);
-
+ $isUserTalkPage = ($title->getNamespace() == NS_USER_TALK);
+ $enotifusertalkpage = ($isUserTalkPage && $wgEnotifUserTalk);
+ $enotifwatchlistpage = (!$isUserTalkPage && $wgEnotifWatchlist);
+
if ( ($enotifusertalkpage || $enotifwatchlistpage)
- && (!$currentMinorEdit || $wgEmailNotificationForMinorEdits) ) {
+ && (!$minorEdit || $wgEnotifMinorEdits) ) {
$dbr =& wfGetDB( DB_MASTER );
extract( $dbr->tableNames( 'watchlist' ) );
$sql = "SELECT wl_user FROM $watchlist
- WHERE wl_title='" . $dbr->strencode($currentPage)."' AND wl_namespace = " . $currentNs .
- " AND wl_user <>" . $currentUser . " AND wl_notificationtimestamp <= 1";
+ WHERE wl_title='" . $dbr->strencode($title->getDBkey()).
+ "' AND wl_namespace = " . $title->getNamespace() .
+ " AND wl_user <>" . $wgUser->getID() . " AND wl_notificationtimestamp <= 1";
$res = $dbr->query( $sql,'UserMailer::NotifyOnChange');
# if anyone is watching ... set up the email message text which is
# common for all receipients ...
if ( $dbr->numRows( $res ) > 0 ) {
-
- # This is a switch for one beep on the server when sending notification mails
- $beeped = false;
+ $this->user &= $wgUser;
+ $this->title =& $title;
+ $this->timestamp = $timestamp;
+ $this->summary = $summary;
+ $this->minorEdit = $minorEdit;
+ $this->oldid = $oldid;
- $article->mTimestamp = $timestamp;
- $article->mSummary = $currentSummary;
- $article->mMinorEdit = $currentMinorEdit;
- $article->mNamespace = $currentNs;
- $article->mTitle = $currentPage;
- $article->mOldid = $oldid;
-
- $mail = $this->composeCommonMailtext( $wgUser, $article );
+ $this->composeCommonMailtext();
$watchingUser = new User();
# ... now do for all watching users ... if the options fit
$watchingUser->setID($wuser->wl_user);
if ( ( $enotifwatchlistpage && $watchingUser->getOption('enotifwatchlistpages') ) ||
( $enotifusertalkpage && $watchingUser->getOption('enotifusertalkpages') )
- && (!$currentMinorEdit || ($wgEmailNotificationForMinorEdits && $watchingUser->getOption('enotifminoredits') ) )
+ && (!$minorEdit || ($wgEnotifMinorEdits && $watchingUser->getOption('enotifminoredits') ) )
&& ($watchingUser->isEmailConfirmed() ) ) {
# ... adjust remaining text and page edit time placeholders
# which needs to be personalized for each user
- $sent = $this->composeAndSendPersonalisedMail( $watchingUser, $mail, $article );
- /* the beep here beeps once when a watched-listed page is changed */
- if ($sent && !$beeped && ($wgEmailNotificationSystembeep != '') ) {
- $last_line = system($wgEmailNotificationSystembeep);
- $beeped=true;
- }
+ $this->composeAndSendPersonalisedMail( $watchingUser );
+
} # if the watching user has an email address in the preferences
# mark the changed watch-listed page with a timestamp, so that the page is listed with an "updated since your last visit" icon in the watch list, ...
# ... no matter, if the watching user has or has not indicated an email address in his/her preferences.
$dbw =& wfGetDB( DB_MASTER );
$succes = $dbw->update( 'watchlist',
array( /* SET */
- 'wl_notificationtimestamp' => $article->mTimestamp
+ 'wl_notificationtimestamp' => $timestamp
), array( /* WHERE */
- 'wl_title' => $currentPage,
- 'wl_namespace' => $currentNs,
+ 'wl_title' => $title->getDBkey(),
+ 'wl_namespace' => $title->getNamespace(),
'wl_user' => $wuser->wl_user
), 'UserMailer::NotifyOnChange'
);
} # for every watching user
} # if anyone is watching
- } # if $wgEmailNotificationForWatchlistPages = true
+ } # if $wgEnotifWatchlist = true
} # function NotifyOnChange
/**
- * @param User $pageeditorUser
- * @param Article $article
* @access private
*/
- function composeCommonMailtext( $pageeditorUser, $article ) {
- global $wgLang, $wgEmergencyContact;
- global $wgEmailNotificationRevealPageEditorAddress;
- global $wgEmailNotificationMailsSentFromPageEditor;
+ function composeCommonMailtext() {
+ global $wgLang, $wgUser, $wgEmergencyContact;
+ global $wgEnotifRevealEditorAddress;
+ global $wgEnotifFromEditor;
global $wgNoReplyAddress;
- $summary = ($article->mSummary == '') ? ' - ' : $article->mSummary;
- $medit = ($article->mMinorEdit) ? wfMsg( 'minoredit' ) : '';
+ $summary = ($this->summary == '') ? ' - ' : $this->summary;
+ $medit = ($this->minorEdit) ? wfMsg( 'minoredit' ) : '';
# You as the WikiAdmin and Sysops can make use of plenty of
# named variables when composing your notification emails while
# simply editing the Meta pages
- $to = wfMsg( 'email_notification_to' );
- $subject = wfMsg( 'email_notification_subject' );
- $body = wfMsg( 'email_notification_body' );
+ $to = wfMsgForContent( 'enotif_to' );
+ $subject = wfMsgForContent( 'enotif_subject' );
+ $body = wfMsgForContent( 'enotif_body' );
$from = ''; /* fail safe */
$replyto = ''; /* fail safe */
$keys = array();
# regarding the use of oldid as an indicator for the last visited version, see also
# http://bugzilla.wikipeda.org/show_bug.cgi?id=603 "Delete + undelete cycle doesn't preserve old_id"
# However, in the case of a new page which is already watched, we have no previous version to compare
- if( $article->mOldid ) {
- $keys['$NEWPAGE'] = wfMsg( 'email_notification_lastvisitedrevisiontext' );
- $keys['$OLDID'] = $article->mOldid;
+ if( $this->oldid ) {
+ $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited' );
+ $keys['$OLDID'] = $this->oldid;
+ $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' );
} else {
- $keys['$NEWPAGE'] = wfMsg( 'email_notification_newpagetext' );
+ $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_newpagetext' );
# clear $OLDID placeholder in the message template
$keys['$OLDID'] = '';
+ $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
}
$body = strtr( $body, $keys );
-
- $pagetitle = $article->mTitle;
- if( $article->mNamespace != NS_MAIN ) {
- $pagetitle = $wgLang->getNsText( $article->mNamespace ) . ':' . $pagetitle;
- }
- $subject = str_replace( '$PAGETITLE', str_replace( '_', ' ', $pagetitle ) , $subject);
+ $pagetitle = $this->title->getPrefixedText();
+
$keys['%24PAGETITLE_RAWURL'] = wfUrlencode( $pagetitle );
$keys['$PAGETITLE_RAWURL'] = wfUrlencode( $pagetitle );
$keys['%24PAGETITLE'] = $pagetitle; # needed for the {{localurl:$PAGETITLE}} in the messagetext, "$" appears here as "%24"
$keys['$PAGEMINOREDIT'] = $medit;
$keys['$PAGESUMMARY'] = $summary;
+ $subject = strtr( $subject, $keys );
# Reveal the page editor's address as REPLY-TO address only if
# the user has not opted-out and the option is enabled at the
# global configuration level.
- $name = $pageeditorUser->getName();
+ $name = $wgUser->getName();
$adminAddress = 'WikiAdmin <' . $wgEmergencyContact . '>';
- $editorAddress = $name . ' <' . $pageeditorUser->getEmail() . '>';
- if( $wgEmailNotificationRevealPageEditorAddress
- && ( $pageeditorUser->getEmail() != '' )
- && $pageeditorUser->getOption( 'enotifrevealaddr' ) ) {
- if( $wgEmailNotificationMailsSentFromPageEditor ) {
+ $editorAddress = wfRFC822Phrase( $name ) . ' <' . $wgUser->getEmail() . '>';
+ if( $wgEnotifRevealEditorAddress
+ && ( $wgUser->getEmail() != '' )
+ && $wgUser->getOption( 'enotifrevealaddr' ) ) {
+ if( $wgEnotifFromEditor ) {
$from = $editorAddress;
} else {
$from = $adminAddress;
$keys['$PAGEEDITORNAMEANDEMAILADDR'] = $replyto;
}
- if( $pageeditorUser->isIP( $name ) ) {
+ if( $wgUser->isIP( $name ) ) {
#real anon (user:xxx.xxx.xxx.xxx)
$anon = $name . ' (anonymous user)';
$anonUrl = wfUrlencode( $name ) . ' (anonymous user)';
$subject = str_replace('$PAGEEDITOR', $name, $subject);
$keys['$PAGEEDITOR_RAWURL'] = wfUrlencode( $name );
$keys['%24PAGEEDITOR_RAWURL'] = wfUrlencode( $name );
- $keys['%24PAGEEDITORE'] = $pageeditorUser->getTitleKey();
- $keys['$PAGEEDITORE'] = $pageeditorUser->getTitleKey();
+ $keys['%24PAGEEDITORE'] = $wgUser->getTitleKey();
+ $keys['$PAGEEDITORE'] = $wgUser->getTitleKey();
$keys['$PAGEEDITOR'] = $name;
}
$body = strtr( $body, $keys );
$this->to = $to;
$this->from = $from;
$this->replyto = $replyto;
- $this->subject = wfQuotedprintable($subject);
+ $this->subject = $subject;
$this->body = $body;
- return $this;
}
*
* @param User $watchingUser
* @param object $mail
- * @param Article $article
* @return bool
* @access private
*/
- function composeAndSendPersonalisedMail( $watchingUser, $mail, $article ) {
+ function composeAndSendPersonalisedMail( $watchingUser ) {
global $wgLang;
-
- $to = $watchingUser->getName() . ' <' . $watchingUser->getEmail() . '>';
- $body = str_replace( '$WATCHINGUSERNAME', $watchingUser->getName() , $mail->body );
+ // From the PHP manual:
+ // Note: The to parameter cannot be an address in the form of "Something <someone@example.com>".
+ // The mail command will not parse this properly while talking with the MTA.
+ $to = $watchingUser->getEmail();
+ $body = str_replace( '$WATCHINGUSERNAME', $watchingUser->getName() , $this->body );
$body = str_replace( '$WATCHINGUSEREMAILADDR', $watchingUser->getEmail(), $body );
$timecorrection = $watchingUser->getOption( 'timecorrection' );
# expressed in terms of individual local time of the notification
# recipient, i.e. watching user
$body = str_replace('$PAGEEDITDATE',
- $wgLang->timeanddate( $article->mTimestamp, true, false, $timecorrection ),
+ $wgLang->timeanddate( $this->timestamp, true, false, $timecorrection ),
$body);
- $error = userMailer( $to, $mail->from, $mail->subject, $body, $mail->replyto );
+ $error = userMailer( $to, $this->from, $this->subject, $body, $this->replyto );
return ($error == '');
}
*/
function addWatch() {
$fname = 'WatchedItem::addWatch';
+ wfProfileIn( $fname );
# REPLACE instead of INSERT because occasionally someone
# accidentally reloads a watch-add operation.
$dbw =& wfGetDB( DB_MASTER );
global $wgMemc;
$wgMemc->set( $this->watchkey(), 1 );
+ wfProfileOut( $fname );
return true;
}
function removeWatch() {
+ global $wgMemc;
$fname = 'WatchedItem::removeWatch';
+ $success = false;
$dbw =& wfGetDB( DB_MASTER );
$dbw->delete( 'watchlist',
array(
'wl_title' => $this->ti
), $fname
);
+ if ( $dbw->affectedRows() ) {
+ $success = true;
+ }
# the following code compensates the new behaviour, introduced by the
# enotif patch, that every single watched page needs now to be listed
);
if ( $dbw->affectedRows() ) {
- global $wgMemc;
+ $success = true;
+ }
+ if ( $success ) {
$wgMemc->set( $this->watchkey(), 0 );
- return true;
- } else {
- return false;
}
+ return $success;
}
/**
'imagesize' => 2,
'thumbsize' => 2,
'rememberpassword' => 0,
- 'enotifwatchlistpages' => 1,
+ 'enotifwatchlistpages' => 0,
'enotifusertalkpages' => 1,
'enotifminoredits' => 0,
'enotifrevealaddr' => 0,
'tog-previewontop' => 'Show preview before edit box',
'tog-previewonfirst' => 'Show preview on first edit',
'tog-nocache' => 'Disable page caching',
-'tog-enotifwatchlistpages' => 'Send me an email on page changes (remark: existing notification flags need to be cleared manually in the watchlist)',
-'tog-enotifusertalkpages' => 'Send me an email when my user talk page is changed (remark: existing notification flags need to be cleared manually in the watchlist)',
-'tog-enotifminoredits' => 'Send me an email also for minor edits of pages (which usually do not trigger notification mails)',
-'tog-enotifrevealaddr' => 'Reveal my email address in notification mails (when I change a page, it allows watching users to reply quickly to me)',
-'tog-shownumberswatching' => 'Show the number of watching users (in recent changes view, watchlist and article page footers)',
+'tog-enotifwatchlistpages' => 'Send me an email on page changes',
+'tog-enotifusertalkpages' => 'Send me an email when my user talk page is changed',
+'tog-enotifminoredits' => 'Send me an email also for minor edits of pages',
+'tog-enotifrevealaddr' => 'Reveal my email address in notification mails',
+'tog-shownumberswatching' => 'Show the number of watching users',
'tog-rcusemodstyle' => 'Show recent changes in UseMod style: only the most recent change of any page is listed.',
'tog-showupdated' => 'Show update marker ',
'tog-fancysig' => 'Raw signatures (without automatic link)',
You may wish to keep using your old password if you remember it or to set a new one.
{{SERVER}}{{localurl:Special:Userlogin|wpName=$3&wpPassword=$4&returnto=Special:Preferences}}",
-'noemail' => "There is no e-mail address recorded for user \"$1\".",
-'passwordsent' => "A temporary password has been sent to the e-mail address
-registered for \"$1\".
+'noemail' => "There is no e-mail address recorded for user \"$1\".",
+'passwordsent' => "A temporary password has been sent to the e-mail address registered for \"$1\".
Please log in again after you receive it.",
-'passwordsentforemailauthentication'
- => "A temporary password has been sent to the e-mail address newly
-registered for \"$1\".
-Please re-login with that for authentication purposes.",
-'loginend' => ' ',
-'mailerror' => "Error sending mail: $1",
+'eauthentsent' => "A confirmation email has been sent to the nominated email address.
+Before any other mail is sent to the account, you will have to follow the instructions in the email,
+to confirm that the account is actually yours.",
+'loginend' => ' ',
+'mailerror' => "Error sending mail: $1",
'acct_creation_throttle_hit' => 'Sorry, you have already created $1 accounts. You can\'t make any more.',
-'emailauthenticated' => 'Your email address was authenticated on $1.',
-'emailnotauthenticated' => 'Your email address is <strong>not yet authenticated</strong> and the advanced email features are disabled until authentication <strong>(d.u.a.)</strong>.',
+'emailauthenticated' => 'Your email address was authenticated on $1.',
+'emailnotauthenticated' => 'Your email address is <strong>not yet authenticated</strong>. No email
+will be sent for any of the following features.',
+'noemailprefs' => '<strong>No email address has been specified</strong>, the following
+features will not work.',
'emailconfirmlink' => 'Confirm your e-mail address',
-'invalidemailaddress' => 'The email address cannot be accepted as it appears to have an invalid format. Please enter a well-formatted address or empty that field.',
-'disableduntilauthent' => '<strong>(d.u.a.)</strong>',
-'disablednoemail' => '<strong>(disabled; no email address)</strong>',
+'invalidemailaddress' => 'The email address cannot be accepted as it appears to have an invalid
+format. Please enter a well-formatted address or empty that field.',
# Edit page toolbar
'bold_sample'=>'Bold text',
'wlshow' => 'Show',
'wlhide' => 'Hide',
-'updatedmarker' => '<span class=\'updatedmarker\'> updated (since my last visit) </span>',
-
-'email_notification_mailer' => '{{SITENAME}} Notification Mailer',
-'email_notification_infotext' => "Email notification is on.
-You will be notified by email when someone changes a page which is listed in your watchlist.",
-'email_notification_reset' => 'Reset all notification flags (set their status to "visited")',
-'email_notification_newpagetext'=> 'This is a new page.',
-'email_notification_to' => '$WATCHINGUSERNAME_QP <$WATCHINGUSEREMAILADDR>',
+'enotif_mailer' => '{{SITENAME}} Notification Mailer',
+'enotif_infotext' => "* Email notification is enabled
+* Pages which have been changed since you last visited them are shown in '''bold'''",
+'enotif_reset' => 'Mark all pages visited',
+'enotif_newpagetext'=> 'This is a new page.',
+'enotif_to' => '$WATCHINGUSERNAME_QP <$WATCHINGUSEREMAILADDR>',
'changed' => 'changed',
'created' => 'created',
-'email_notification_subject' => '{{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED by $PAGEEDITOR',
-'email_notification_lastvisitedrevisiontext' => 'See {{SERVER}}{{localurl:$PAGETITLE_RAWURL|diff=0&oldid=$OLDID}} for all changes since your last visit.',
-'email_notification_body' => 'Dear $WATCHINGUSERNAME,
+'enotif_subject' => '{{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED by $PAGEEDITOR',
+'enotif_lastvisited' => 'See {{SERVER}}{{localurl:$PAGETITLE_RAWURL|diff=0&oldid=$OLDID}} for all changes since your last visit.',
+'enotif_body' => 'Dear $WATCHINGUSERNAME,
the {{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED on $PAGEEDITDATE by $PAGEEDITOR,
see {{SERVER}}{{localurl:$PAGETITLE_RAWURL}} for the current version.
--
To change your watchlist settings, visit
-{{SERVER}}{{localurl:Special:Watchlist|magic=yes}}
+{{SERVER}}{{localurl:Special:Watchlist|edit=yes}}
Feedback and further assistance:
-{{SERVER}}{{localurl:WikiHelpdesk}}',
+{{SERVER}}{{localurl:Help:Contents}}',
# Delete/protect/revert
#