Index: includes/User.php =================================================================== --- includes/User.php (revision 3068) +++ includes/User.php (working copy) @@ -69,6 +69,7 @@ 'enotifwatchlistpages', 'enotifusertalkpages', 'enotifminoredits', + 'enotifshowdiff', 'enotifrevealaddr', 'shownumberswatching', 'fancysig', Index: includes/UserMailer.php =================================================================== --- includes/UserMailer.php (revision 3068) +++ includes/UserMailer.php (working copy) @@ -205,6 +205,7 @@ # we use $wgEmergencyContact as sender's address global $wgUser, $wgEnotifWatchlist; global $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgShowUpdatedMarker; + global $wgEnotifShowDiff; $fname = 'UserMailer::notifyOnPageChange'; wfProfileIn( $fname ); @@ -298,7 +299,7 @@ # FIXME what do we do on failure ? } wfProfileOut( $fname ); - } # function NotifyOnChange + } # function NotifyOnPageChange /** * @private @@ -401,7 +402,7 @@ * @private */ function composeAndSendPersonalisedMail( $watchingUser ) { - global $wgLang; + global $wgLang, $wgTitle, $wgTmpDirectory, $wgEmailDiffCommand; // From the PHP manual: // Note: The to parameter cannot be an address in the form of "Something ". // The mail command will not parse this properly while talking with the MTA. @@ -417,6 +418,51 @@ $wgLang->timeanddate( $this->timestamp, true, false, $timecorrection ), $body); + ## Does this user require a diff? + if ($watchingUser->getOption('enotifshowdiff')) { + ## Have we created one yet? + if (! isset($this->diff)) { + ## New text: + $newrev = Revision::newFromTitle( $wgTitle ); + if (!$newrev) { + $this->diff = ''; ## An image for example + } + else { + $newtext = $newrev->getText(); + if (!$this->oldid) { + $this->diff = "This is a new page:\n$newtext\n"; + } + else { + $newfile = tempnam($wgTempDirectory, "mediawikidiff2"); + $fh = fopen($newfile, "w") or die("Could not open file $newfile"); + fputs($fh, "$newtext\n"); + fclose($fh); + + ## Old text: + $oldrev = Revision::newFromId( $this->oldid ); + $oldtext = $oldrev->getText(); + $oldfile = tempnam($wgTempDirectory, "mediawikidiff1"); + $fh = fopen($oldfile, "w") or die("Could not open file $oldfile"); + fputs($fh, "$oldtext\n"); + fclose($fh); + + $differ = tempnam($wgTempDirectory, "mediawikidiff3"); + $diffcom = str_replace( + array("OLDFILE","NEWFILE","DIFFFILE"), + array("$oldfile","$newfile","$differ"), + $wgEmailDiffCommand); + system($diffcom); + $difftext = file_get_contents($differ); + $this->diff = "\nVersion differences:\n$difftext\n"; + unlink($oldfile); unlink($newfile); unlink($differ); + } ## end if have an oldid + } ## end if have a newrev + } ## end if don't have a diff yet + } ## end user requires a diff + + $body = str_replace('$PAGEDIFF', isset($this->diff) ? $this->diff : '', $body); + + $error = userMailer( $to, $this->from, $this->subject, $body, $this->replyto ); return ($error == ''); } Index: includes/SpecialPreferences.php =================================================================== --- includes/SpecialPreferences.php (revision 3068) +++ includes/SpecialPreferences.php (working copy) @@ -455,7 +455,7 @@ global $wgUser, $wgOut, $wgLang, $wgContLang; global $wgAllowRealName, $wgImageLimits, $wgThumbLimits; global $wgDisableLangConversion; - global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits; + global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits,$wgEnotifShowDiff; global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress; global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication; global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth; @@ -487,6 +487,7 @@ $this->mUsedToggles[ 'enotifwatchlistpages' ] = true; $this->mUsedToggles[ 'enotifusertalkpages' ] = true; $this->mUsedToggles[ 'enotifminoredits' ] = true; + $this->mUsedToggles[ 'enotifshowdiff' ] = true; $this->mUsedToggles[ 'enotifrevealaddr' ] = true; $this->mUsedToggles[ 'uselivepreview' ] = true; @@ -526,6 +527,7 @@ $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : ''; $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : ''; $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : ''; + $enotifshowdiff = ($wgEnotifWatchlist && $wgEnotifShowDiff) ? $this->getToggle( 'enotifshowdiff' ) : ''; $prefs_help_email_enotif = ( $wgEnotifWatchlist || $wgEnotifUserTalk) ? ' ' . wfMsg('prefs-help-email-enotif') : ''; $prefs_help_realname = ''; @@ -685,6 +687,7 @@ $enotifrevealaddr. $enotifwatchlistpages. $enotifusertalkpages. + $enotifshowdiff. $enotifminoredits ); if ($wgEnableUserEmail) { $emf = wfMsg( 'allowemail' ); Index: includes/DefaultSettings.php =================================================================== --- includes/DefaultSettings.php (revision 3068) +++ includes/DefaultSettings.php (working copy) @@ -424,6 +424,12 @@ $wgEnableUserEmail = true; /** + * The command to create email diffs. + * @global string $wgEmailDiffCommand + */ +$wgEmailDiffCommand = "/usr/bin/diff -u OLDFILE NEWFILE | /usr/bin/tail +3 > DIFFFILE"; + +/** * SMTP Mode * For using a direct (authenticated) SMTP server connection. * Default to false or fill an array : @@ -1067,9 +1073,11 @@ $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) +$wgEnotifShowDiff = true; # UPO; if set, email notifications contain textual diffs +# # Attention: _every_ change on a user_talk page triggers a notification mail (if the user is not yet notified) + /** Show watching users in recent changes, watchlist and page history views */ $wgRCShowWatchingUsers = false; # UPO /** Show watching users in Page views */ @@ -1606,6 +1614,7 @@ 'enotifwatchlistpages' => 0, 'enotifusertalkpages' => 1, 'enotifminoredits' => 0, + 'enotifshowdiff' => 0, 'enotifrevealaddr' => 0, 'shownumberswatching' => 1, 'fancysig' => 0, Index: languages/messages/MessagesEn.php =================================================================== --- languages/messages/MessagesEn.php (revision 3068) +++ languages/messages/MessagesEn.php (working copy) @@ -358,6 +358,7 @@ 'tog-enotifwatchlistpages' => 'E-mail me when a page I\'m watching is changed', 'tog-enotifusertalkpages' => 'E-mail me when my user talk page is changed', 'tog-enotifminoredits' => 'E-mail me also for minor edits of pages', +'tog-enotifshowdiff' => 'Send a diff in the change email', 'tog-enotifrevealaddr' => 'Reveal my e-mail address in notification mails', 'tog-shownumberswatching' => 'Show the number of watching users', 'tog-fancysig' => 'Raw signatures (without automatic link)', @@ -1464,14 +1465,15 @@ 'created' => 'created', 'enotif_subject' => '{{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED by $PAGEEDITOR', 'enotif_lastvisited' => 'See $1 for all changes since your last visit.', -'enotif_body' => 'Dear $WATCHINGUSERNAME, +'enotif_body' => 'Dear $WATCHINGUSERNAME: -the {{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED on $PAGEEDITDATE by $PAGEEDITOR, see $PAGETITLE_URL for the current version. +The {{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED on $PAGEEDITDATE by $PAGEEDITOR, see $PAGETITLE_URL for the current version. $NEWPAGE Editor\'s summary: $PAGESUMMARY $PAGEMINOREDIT +$PAGEDIFF Contact the editor: mail: $PAGEEDITOR_EMAIL wiki: $PAGEEDITOR_WIKI