X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FUserMailer.php;h=8d1ed6812fa93c0191d9711c965a2759068e0825;hb=39142e28044c514fc2841ee78f811e63eaf3e636;hp=b9ce9e0574d14122fc5fc1c9c0772a61658b8352;hpb=904945eaeefe7febd6622e191494fb867d9df84e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/UserMailer.php b/includes/UserMailer.php index b9ce9e0574..8d1ed6812f 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -396,7 +396,7 @@ class UserMailer { */ 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(); /** @@ -421,8 +421,9 @@ class EmailNotification { * @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; @@ -493,12 +494,13 @@ class EmailNotification { 'summary' => $summary, 'minorEdit' => $minorEdit, 'oldid' => $oldid, - 'watchers' => $watchers + 'watchers' => $watchers, + 'pageStatus' => $pageStatus ); $job = new EnotifNotifyJob( $title, $params ); - $job->insert(); + JobQueueGroup::singleton()->push( $job ); } else { - $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers ); + $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $pageStatus ); } } @@ -516,7 +518,8 @@ class EmailNotification { * @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; @@ -536,6 +539,14 @@ class EmailNotification { $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; @@ -625,26 +636,27 @@ class EmailNotification { $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(); @@ -658,6 +670,7 @@ class EmailNotification { $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() ); @@ -670,11 +683,12 @@ class EmailNotification { $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 );