jenkins-bot has submitted this change and it was merged.

Change subject: Include reason in user-rights notification body
......................................................................


Include reason in user-rights notification body

Bug: T126277
Depends-On: Ib9bb28a7a77602e3e729fd0bf13ab8259e15b006
Change-Id: I4941c4ba16ee95798767d858792090609b47b4e4
---
M Hooks.php
M i18n/en.json
M i18n/qqq.json
M includes/formatters/UserRightsPresentationModel.php
4 files changed, 11 insertions(+), 2 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  Siebrand: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/Hooks.php b/Hooks.php
index 5e4fb29..ae238ec 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -556,10 +556,11 @@
         * @param string[] $add strings corresponding to groups added
         * @param string[] $remove strings corresponding to groups removed
         * @param User|bool $performer
+        * @param string|bool $reason Reason given by the user changing the 
rights
         *
         * @return bool
         */
-       public static function onUserGroupsChanged( $user, $add, $remove, 
$performer ) {
+       public static function onUserGroupsChanged( $user, $add, $remove, 
$performer, $reason ) {
                if ( !$performer ) {
                        // TODO: Implement support for autopromotion
                        return true;
@@ -583,7 +584,8 @@
                                        'extra' => array(
                                                'user' => $user->getID(),
                                                'add' => $add,
-                                               'remove' => $remove
+                                               'remove' => $remove,
+                                               'reason' => $reason,
                                        ),
                                        'agent' => $performer,
                                )
diff --git a/i18n/en.json b/i18n/en.json
index b6e66b2..4ade982 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -98,6 +98,7 @@
        "notification-header-user-rights-add-only": "{{GENDER:$4|Your}} user 
rights were {{GENDER:$1|changed}}. You have been added to: $2.",
        "notification-header-user-rights-remove-only": "{{GENDER:$4|Your}} user 
rights were {{GENDER:$1|changed}}. You are no longer a member of: $2.",
        "notification-header-user-rights-add-and-remove": "{{GENDER:$6|Your}} 
user rights were {{GENDER:$1|changed}}. You have been added to: $2. You are no 
longer a member of: $4.",
+       "notification-body-user-rights": "$1",
        "notification-new-user": "Welcome to {{SITENAME}}, $1! We're glad 
you're here.",
        "notification-header-welcome": "{{GENDER:$2|Welcome}} to {{SITENAME}}, 
$1! We're glad {{GENDER:$2|you're}} here.",
        "notification-welcome-link": "",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 95a8987..820240b 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -119,6 +119,7 @@
        "notification-header-user-rights-add-only": "Notifications header 
message when a user is added to groups.  Parameters:\n* $1 - the raw username 
of the person who made the user rights change, can be used for GENDER 
support\n* $2 - a localized list of the groups that were added\n* $3 - the 
number of groups that were added, can be used for PLURAL\n* $4 - name of the 
user viewing the notification, can be used for GENDER",
        "notification-header-user-rights-remove-only": "Notifications header 
message when a user is removed from groups.  Parameters:\n* $1 - the raw 
username of the person who made the user rights change, can be used for GENDER 
support\n* $2 - a localized list of the groups that were removed\n* $3 - the 
number of groups that were removed, can be used for PLURAL\n* $4 - name of the 
user viewing the notification, can be used for GENDER",
        "notification-header-user-rights-add-and-remove": "Notifications header 
message when a user is added to groups and removed from groups.  Parameters:\n* 
$1 - the raw username of the person who made the user rights change, can be 
used for GENDER support\n* $2 - a localized list of the groups that were 
added\n* $4 - a localized list of the groups that were removed\n* $6 - name of 
the user viewing the notification, can be used for GENDER",
+       "notification-body-user-rights": "{{notranslate}}",
        "notification-new-user": "Text of the welcome notification. 
Parameters:\n* $1 - the name of the new user\nSee also:\n* 
{{msg-mw|Guidedtour-tour-gettingstarted-start-title}}",
        "notification-header-welcome": "Text of the welcome notification. 
Parameters:\n* $1 - the name of the new user.\nSee also:\n* 
{{msg-mw|Guidedtour-tour-gettingstarted-start-title}}",
        "notification-welcome-link": "{{notranslate}}",
diff --git a/includes/formatters/UserRightsPresentationModel.php 
b/includes/formatters/UserRightsPresentationModel.php
index a5fc38f..3782300 100644
--- a/includes/formatters/UserRightsPresentationModel.php
+++ b/includes/formatters/UserRightsPresentationModel.php
@@ -39,6 +39,11 @@
                }
        }
 
+       public function getBodyMessage() {
+               $reason = $this->event->getExtraParam( 'reason' );
+               return $reason ? $this->msg( 'notification-body-user-rights' 
)->params( $reason ) : false;
+       }
+
        private function getLocalizedGroupNames( $names ) {
                return array_map( function( $name ) {
                        $msg = $this->msg( 'group-' . $name );

-- 
To view, visit https://gerrit.wikimedia.org/r/269306
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4941c4ba16ee95798767d858792090609b47b4e4
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to