* (bug 36053) Log in "returnto" feature forgets query parameters if no
title parameter was specified.
* (bug 42410) API action=edit now returns correct timestamp for the new edit.
+* (bug 14901) Email notification mistakes log action for new page creation.
=== API changes in 1.21 ===
* prop=revisions can now report the contentmodel and contentformat, see docs/contenthandler.txt.
$user: user that watched
$page: WikiPage object that was watched
+'UpdateUserMailerFormattedPageStatus': before notification email gets sent
+$formattedPageStatus: list of valid page states
+
'UploadForm:initial': before the upload form is generated
$form: UploadForm object
You might set the member-variables $uploadFormTextTop and
* lang the interwiki prefix, automatically set in save()
* oldSize text size before the change
* newSize text size after the change
+ * pageStatus status of the page: created, deleted, moved, restored, changed
*
* temporary: not stored in the database
* notificationtimestamp
$this->mAttribs['rc_timestamp'],
$this->mAttribs['rc_comment'],
$this->mAttribs['rc_minor'],
- $this->mAttribs['rc_last_oldid'] );
+ $this->mAttribs['rc_last_oldid'],
+ $this->mExtra['pageStatus'] );
}
}
}
'lastTimestamp' => $lastTimestamp,
'oldSize' => $oldSize,
'newSize' => $newSize,
+ 'pageStatus' => 'changed'
);
$rc->save();
return $rc;
'prefixedDBkey' => $title->getPrefixedDBkey(),
'lastTimestamp' => 0,
'oldSize' => 0,
- 'newSize' => $size
+ 'newSize' => $size,
+ 'pageStatus' => 'created'
);
$rc->save();
return $rc;
$type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '' ) {
global $wgRequest;
+ ## Get pageStatus for email notification
+ switch ( $type . '-' . $action ) {
+ case 'delete-delete':
+ $pageStatus = 'deleted';
+ break;
+ case 'move-move':
+ case 'move-move_redir':
+ $pageStatus = 'moved';
+ break;
+ case 'delete-restore':
+ $pageStatus = 'restored';
+ break;
+ case 'upload-upload':
+ $pageStatus = 'created';
+ break;
+ case 'upload-overwrite':
+ default:
+ $pageStatus = 'changed';
+ break;
+ }
+
$rc = new RecentChange;
$rc->mTitle = $target;
$rc->mPerformer = $user;
'prefixedDBkey' => $title->getPrefixedDBkey(),
'lastTimestamp' => 0,
'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
+ 'pageStatus' => $pageStatus,
'actionCommentIRC' => $actionCommentIRC
);
return $rc;
*/
class EmailNotification {
protected $subject, $body, $replyto, $from;
- protected $timestamp, $summary, $minorEdit, $oldid, $composed_common;
+ protected $timestamp, $summary, $minorEdit, $oldid, $composed_common, $pageStatus;
protected $mailTargets = array();
/**
* @param $summary
* @param $minorEdit
* @param $oldid (default: false)
+ * @param $pageStatus (default: 'changed')
*/
- public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false ) {
+ public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false, $pageStatus = 'changed' ) {
global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker, $wgEnotifMinorEdits,
$wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk;
'summary' => $summary,
'minorEdit' => $minorEdit,
'oldid' => $oldid,
- 'watchers' => $watchers
+ 'watchers' => $watchers,
+ 'pageStatus' => $pageStatus
);
$job = new EnotifNotifyJob( $title, $params );
$job->insert();
} else {
- $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers );
+ $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $pageStatus );
}
}
* @param $oldid int Revision ID
* @param $watchers array of user IDs
*/
- public function actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers ) {
+ public function actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit,
+ $oldid, $watchers, $pageStatus = 'changed' ) {
# we use $wgPasswordSender as sender's address
global $wgEnotifWatchlist;
global $wgEnotifMinorEdits, $wgEnotifUserTalk;
$this->oldid = $oldid;
$this->editor = $editor;
$this->composed_common = false;
+ $this->pageStatus = $pageStatus;
+
+ $formattedPageStatus = array( 'deleted', 'created', 'moved', 'restored', 'changed' );
+
+ wfRunHooks( 'UpdateUserMailerFormattedPageStatus', array( &$formattedPageStatus ) );
+ if ( !in_array( $this->pageStatus, $formattedPageStatus ) ) {
+ throw new MWException( 'Not a valid page status!' );
+ }
$userTalkId = false;
$keys = array();
$postTransformKeys = array();
+ $pageTitleUrl = $this->title->getCanonicalUrl();
+ $pageTitle = $this->title->getPrefixedText();
if ( $this->oldid ) {
// Always show a link to the diff which triggered the mail. See bug 32210.
- $keys['$NEWPAGE'] = wfMessage( 'enotif_lastdiff',
+ $keys['$NEWPAGE'] = "\n\n" . wfMessage( 'enotif_lastdiff',
$this->title->getCanonicalUrl( 'diff=next&oldid=' . $this->oldid ) )
->inContentLanguage()->text();
+
if ( !$wgEnotifImpersonal ) {
// For personal mail, also show a link to the diff of all changes
// since last visited.
- $keys['$NEWPAGE'] .= " \n" . wfMessage( 'enotif_lastvisited',
+ $keys['$NEWPAGE'] .= "\n\n" . wfMessage( 'enotif_lastvisited',
$this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ) )
->inContentLanguage()->text();
}
$keys['$OLDID'] = $this->oldid;
- $keys['$CHANGEDORCREATED'] = wfMessage( 'changed' )->inContentLanguage()->text();
} else {
- $keys['$NEWPAGE'] = wfMessage( 'enotif_newpagetext' )->inContentLanguage()->text();
# clear $OLDID placeholder in the message template
$keys['$OLDID'] = '';
- $keys['$CHANGEDORCREATED'] = wfMessage( 'created' )->inContentLanguage()->text();
+ $keys['$NEWPAGE'] = '';
}
$keys['$PAGETITLE'] = $this->title->getPrefixedText();
$keys['$PAGEEDITOR'] = wfMessage( 'enotif_anon_editor', $this->editor->getName() )
->inContentLanguage()->text();
$keys['$PAGEEDITOR_EMAIL'] = wfMessage( 'noemailtitle' )->inContentLanguage()->text();
+
} else {
$keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
$emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() );
$postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
# Now build message's subject and body
+ $this->subject = wfMessage( 'enotif_subject_' . $this->pageStatus )->inContentLanguage()
+ ->params( $pageTitle, $keys['$PAGEEDITOR'] )->escaped();
- $subject = wfMessage( 'enotif_subject' )->inContentLanguage()->plain();
- $subject = strtr( $subject, $keys );
- $subject = MessageCache::singleton()->transform( $subject, false, null, $this->title );
- $this->subject = strtr( $subject, $postTransformKeys );
+ $keys['$PAGEINTRO'] = wfMessage( 'enotif_body_intro_' . $this->pageStatus )
+ ->inContentLanguage()->params( $pageTitle, $keys['$PAGEEDITOR'], $pageTitleUrl )
+ ->escaped();
$body = wfMessage( 'enotif_body' )->inContentLanguage()->plain();
$body = strtr( $body, $keys );
$this->params['summary'],
$this->params['minorEdit'],
$this->params['oldid'],
- $this->params['watchers']
+ $this->params['watchers'],
+ $this->params['pageStatus']
);
return true;
}
'unwatching' => 'Unwatching...',
'watcherrortext' => 'An error occurred while changing your watchlist settings for "$1".',
-'enotif_mailer' => '{{SITENAME}} notification mailer',
-'enotif_reset' => 'Mark all pages visited',
-'enotif_newpagetext' => 'This is a new page.',
-'enotif_impersonal_salutation' => '{{SITENAME}} user',
-'changed' => 'changed',
-'created' => 'created',
-'enotif_subject' => '{{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED by $PAGEEDITOR',
-'enotif_lastvisited' => 'See $1 for all changes since your last visit.',
-'enotif_lastdiff' => 'See $1 to view this change.',
-'enotif_anon_editor' => 'anonymous user $1',
-'enotif_body' => 'Dear $WATCHINGUSERNAME,
-
+'enotif_mailer' => '{{SITENAME}} notification mailer',
+'enotif_reset' => 'Mark all pages visited',
+'enotif_impersonal_salutation' => '{{SITENAME}} user',
+
+'enotif_subject_deleted' => '{{SITENAME}} page $1 has been deleted by {{gender:$2|$2}}',
+'enotif_subject_created' => '{{SITENAME}} page $1 has been created by {{gender:$2|$2}}',
+'enotif_subject_moved' => '{{SITENAME}} page $1 has been moved by {{gender:$2|$2}}',
+'enotif_subject_restored' => '{{SITENAME}} page $1 has been restored by {{gender:$2|$2}}',
+'enotif_subject_changed' => '{{SITENAME}} page $1 has been changed by {{gender:$2|$2}}',
+'enotif_body_intro_deleted' => 'The {{SITENAME}} page $1 has been deleted on $PAGEEDITDATE by {{gender:$2|$2}}, see $3 for the current revision.',
+'enotif_body_intro_created' => 'The {{SITENAME}} page $1 has been created on $PAGEEDITDATE by {{gender:$2|$2}}, see $3 for the current revision.',
+'enotif_body_intro_moved' => 'The {{SITENAME}} page $1 has been moved on $PAGEEDITDATE by {{gender:$2|$2}}, see $3 for the current revision.',
+'enotif_body_intro_restored' => 'The {{SITENAME}} page $1 has been restored on $PAGEEDITDATE by {{gender:$2|$2}}, see $3 for the current revision.',
+'enotif_body_intro_changed' => 'The {{SITENAME}} page $1 has been changed on $PAGEEDITDATE by {{gender:$2|$2}}, see $3 for the current revision.',
+
+'enotif_lastvisited' => 'See $1 for all changes since your last visit.',
+'enotif_lastdiff' => 'See $1 to view this change.',
+'enotif_anon_editor' => 'anonymous user $1',
-The {{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED on $PAGEEDITDATE by $PAGEEDITOR, see $PAGETITLE_URL for the current revision.
+'enotif_body' => 'Dear $WATCHINGUSERNAME,
-$NEWPAGE
+$PAGEINTRO $NEWPAGE
Editor\'s summary: $PAGESUMMARY $PAGEMINOREDIT
mail: $PAGEEDITOR_EMAIL
wiki: $PAGEEDITOR_WIKI
-There will be no other notifications in case of further changes unless you visit this page.
-You could also reset the notification flags for all your watched pages on your watchlist.
+There will be no other notifications in case of further changes unless you visit this page. You could also reset the notification flags for all your watched pages on your watchlist.
Your friendly {{SITENAME}} notification system
'enotif_reset' => "This should be translated as \"Mark all pages '''as''' visited\".",
'enotif_newpagetext' => 'Part of text of a notification e-mail sent when a watched page has been created. See [[File:Screenshot_MediaWiki_e-mail_notifier.PNG|150px|right]]',
-'changed' => 'Possible value for $CHANGEDORCREATED in {{msg|enotif_subject}} and {{msg|enotif_body}}.',
-'created' => 'Possible value for $CHANGEDORCREATED in {{msg|enotif_subject}} and {{msg|enotif_body}}.',
-'enotif_subject' => '$CHANGEDORCREATED can be one of {{msg|changed}} and {{msg|created}}. Can also be {{msg-mw|blog-added}} or {{msg-mw|blog-edited}} from Wikia.',
+
+'enotif_subject_deleted' => 'Email notification subject for deleted pages, $1 is page title, $2 is page editor.',
+'enotif_subject_created' => 'Email notification subject for new pages, $1 is page title, $2 is page editor.',
+'enotif_subject_moved' => 'Email notification subject for pages that get moved, $1 is page title, $2 is page editor.',
+'enotif_subject_restored' => 'Email notification subject for pages that get restored, $1 is page title, $2 is page editor.',
+'enotif_subject_changed' => 'Email notification subject for pages that get changed, $1 is page title, $2 is page editor.',
+
+'enotif_body_intro_deleted' => 'Email notification body intro text for deleted pages, $1 is the page title, $2 is the page editor, $3 is page url.',
+'enotif_body_intro_created' => 'Email notification body intro text for new pages, $1 is the page title, $2 is the page editor, $3 is page url.',
+'enotif_body_intro_moved' => 'Email notification body intro for pages that get moved, $1 is the page title, $2 is the page editor, $3 is page url.',
+'enotif_body_intro_restored' => 'Email notification body intro for pages that get restored, $1 is the page title, $2 is the page editor, $3 is page url.',
+'enotif_body_intro_changed' => 'Email notification body intro for pages that get changed, $1 is the page title, $2 is the page editor, $3 is page url.',
+
'enotif_lastvisited' => '$1 is a URL address.',
'enotif_lastdiff' => 'E-mail notification text to the latest page differences. Parameters:
* $1 is a link to a diff, shown as a plain link.',
'enotif_anon_editor' => 'User name in an e-mail notification when referring to an anonymous user. Parameters:
* $1 is the anonymous user name (i.e. an IP address).',
-'enotif_body' => 'Text of a notification e-mail sent when a watched page has been edited or deleted.[[File:Screenshot_MediaWiki_e-mail_notifier.PNG|150px|right]]
-* <tt>$CHANGEDORCREATED</tt> can be one of {{msg-mw|changed}}, {{msg-mw|created}}, or {{msg-mw|deleted}}. Can also be {{msg-mw|blog-added}} or {{msg-mw|blog-edited}} from Wikia.',
+'enotif_body' => 'Text of a notification e-mail sent when a watched page has been created, edited, deleted, moved or restored. [[File:Screenshot_MediaWiki_e-mail_notifier.PNG|150px|right]]
+
+$PAGETITLE_URL is the full URL for the page acted on. $PAGEINTRO has the possible values of {{msg|enotif_body_intro_deleted}}, {{msg|enotif_body_intro_created}}, {{msg|enotif_body_intro_moved}}, {{msg|enotif_body_intro_restored}}, {{msg|enotif_body_intro_changed}}
+$NEWPAGE has the possible values of {{msg|enotif_newpagetext}}, {{msg|enotif_lastvisited}}, or {{msg|enotif_lastdiff}}',
# Delete
'confirm' => 'Submit button text for protection confirmation
'enotif' => array(
'enotif_mailer',
'enotif_reset',
- 'enotif_newpagetext',
'enotif_impersonal_salutation',
- 'changed',
- 'created',
- 'enotif_subject',
+ 'enotif_subject_deleted',
+ 'enotif_subject_created',
+ 'enotif_subject_moved',
+ 'enotif_subject_restored',
+ 'enotif_subject_changed',
+ 'enotif_body_intro_deleted',
+ 'enotif_body_intro_created',
+ 'enotif_body_intro_moved',
+ 'enotif_body_intro_restored',
+ 'enotif_body_intro_changed',
'enotif_lastvisited',
'enotif_lastdiff',
'enotif_anon_editor',