X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmail%2FEmailNotification.php;h=4d176fb0bcc2d45d786e1e6a273df31edc0a4d9e;hb=c05e0f7d945ca411aec6e24f9d9e69517cd37f8d;hp=73610329377a3cabf90b45d819f1a458a0275bc7;hpb=592c19692e8bd1218e9e58c89116566dccce0315;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 7361032937..4d176fb0bc 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -129,7 +129,10 @@ class EmailNotification { if ( $watchers === [] && !count( $wgUsersNotifiedOnAllChanges ) ) { $sendEmail = false; // Only send notification for non minor edits, unless $wgEnotifMinorEdits - if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) { + if ( !$minorEdit || ( $wgEnotifMinorEdits && !MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $editor, 'nominornewtalk' ) ) + ) { $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK ); if ( $wgEnotifUserTalk && $isUserTalkPage @@ -173,13 +176,23 @@ class EmailNotification { * @param string $pageStatus * @throws MWException */ - public function actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, - $oldid, $watchers, $pageStatus = 'changed' ) { + public function actuallyNotifyOnPageChange( + $editor, + $title, + $timestamp, + $summary, + $minorEdit, + $oldid, + $watchers, + $pageStatus = 'changed' + ) { # we use $wgPasswordSender as sender's address global $wgUsersNotifiedOnAllChanges; global $wgEnotifWatchlist, $wgBlockDisablesLogin; global $wgEnotifMinorEdits, $wgEnotifUserTalk; + $messageCache = MediaWikiServices::getInstance()->getMessageCache(); + # 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 @@ -204,13 +217,16 @@ class EmailNotification { $userTalkId = false; - if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) { + if ( !$minorEdit || ( $wgEnotifMinorEdits && !MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $editor, 'nominornewtalk' ) ) + ) { if ( $wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) { $targetUser = User::newFromName( $title->getText() ); - $this->compose( $targetUser, self::USER_TALK ); + $this->compose( $targetUser, self::USER_TALK, $messageCache ); $userTalkId = $targetUser->getId(); } @@ -229,7 +245,7 @@ class EmailNotification { && !( $wgBlockDisablesLogin && $watchingUser->getBlock() ) && Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) { - $this->compose( $watchingUser, self::WATCHLIST ); + $this->compose( $watchingUser, self::WATCHLIST, $messageCache ); } } } @@ -241,7 +257,7 @@ class EmailNotification { continue; } $user = User::newFromName( $name ); - $this->compose( $user, self::ALL_CHANGES ); + $this->compose( $user, self::ALL_CHANGES, $messageCache ); } $this->sendMails(); @@ -288,8 +304,9 @@ class EmailNotification { /** * Generate the generic "this page has been changed" e-mail text. + * @param MessageCache $messageCache */ - private function composeCommonMailtext() { + private function composeCommonMailtext( MessageCache $messageCache ) { global $wgPasswordSender, $wgNoReplyAddress; global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress; global $wgEnotifImpersonal, $wgEnotifUseRealName; @@ -374,7 +391,7 @@ class EmailNotification { $body = wfMessage( 'enotif_body' )->inContentLanguage()->plain(); $body = strtr( $body, $keys ); - $body = MessageCache::singleton()->transform( $body, false, null, $this->title ); + $body = $messageCache->transform( $body, false, null, $this->title ); $this->body = wordwrap( strtr( $body, $postTransformKeys ), 72 ); # Reveal the page editor's address as REPLY-TO address only if @@ -406,12 +423,13 @@ class EmailNotification { * Call sendMails() to send any mails that were queued. * @param User $user * @param string $source + * @param MessageCache $messageCache */ - private function compose( $user, $source ) { + private function compose( $user, $source, MessageCache $messageCache ) { global $wgEnotifImpersonal; if ( !$this->composed_common ) { - $this->composeCommonMailtext(); + $this->composeCommonMailtext( $messageCache ); } if ( $wgEnotifImpersonal ) {