From c461b8d6fd9d879dc75daa372118b5795018e141 Mon Sep 17 00:00:00 2001 From: Dayllan Maza Date: Wed, 10 Jul 2019 13:47:07 -0400 Subject: [PATCH] Add mute preferences link to the tools menu A link to Special:Mute is added to the tools menu on the sidebar if the user is logged in and a registered relevant-user* is found Mute preferences link will not be shown if $wgEnableSpecialMute is false * From Skin::getRelevantUser: Special pages like Special:Contributions mark the user which they are relevant to so that things like the toolbox can display the information they usually are only able to display on a user's userpage and talkpage. Bug: T218270 Change-Id: I89eb8373963d28d52a026b60aa42d1c64b31b7c6 --- includes/skins/BaseTemplate.php | 2 +- includes/skins/SkinTemplate.php | 8 ++++++++ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index 6d108e8ec4..cd79259e5e 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -85,7 +85,7 @@ abstract class BaseTemplate extends QuickTemplate { $toolbox['feeds']['links'][$key]['class'] = 'feedlink'; } } - foreach ( [ 'contributions', 'log', 'blockip', 'emailuser', + foreach ( [ 'contributions', 'log', 'blockip', 'emailuser', 'mute', 'userrights', 'upload', 'specialpages' ] as $special ) { if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) { diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 5d6197e7ac..364e4fcbd0 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -1278,6 +1278,7 @@ class SkinTemplate extends Skin { $nav_urls['contributions'] = false; $nav_urls['log'] = false; $nav_urls['blockip'] = false; + $nav_urls['mute'] = false; $nav_urls['emailuser'] = false; $nav_urls['userrights'] = false; @@ -1355,6 +1356,13 @@ class SkinTemplate extends Skin { } if ( !$user->isAnon() ) { + if ( $this->getUser()->isRegistered() && $this->getConfig()->get( 'EnableSpecialMute' ) ) { + $nav_urls['mute'] = [ + 'text' => $this->msg( 'mute-preferences' )->text(), + 'href' => self::makeSpecialUrlSubpage( 'Mute', $rootUser ) + ]; + } + $sur = new UserrightsPage; $sur->setContext( $this->getContext() ); $canChange = $sur->userCanChangeRights( $user ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 0da5c5fc45..0f401213bc 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -4206,6 +4206,7 @@ "specialmute-error-email-preferences": "You must confirm your email address before you can mute a user. You may do so from [[Special:Preferences]].", "specialmute-email-footer": "To manage email preferences for {{BIDI:$2}} please visit <$1>.", "specialmute-login-required": "Please log in to change your mute preferences.", + "mute-preferences": "Mute preferences", "revid": "revision $1", "pageid": "page ID $1", "interfaceadmin-info": "$1\n\nPermissions for editing of sitewide CSS/JS/JSON files were recently separated from the editinterface right. If you do not understand why you are getting this error, see [[mw:MediaWiki_1.32/interface-admin]].", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 6ba308b1ce..965f1633b1 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -4415,6 +4415,7 @@ "specialmute-error-email-preferences": "Error displayed when the user has not confirmed their email address.", "specialmute-email-footer": "Email footer in plain text linking to [[Special:Mute]] preselecting the sender to manage muting options.\n* $1 - Url linking to [[Special:Mute]].\n* $2 - The user sending the email.", "specialmute-login-required": "Error displayed when a user tries to access [[Special:Mute]] before logging in.", + "mute-preferences": "Link in the sidebar to manage muting preferences for a user. It links to [[Special:Mute]] with the user in context as the subpage.", "revid": "Used to format a revision ID number in text. Parameters:\n* $1 - Revision ID number.\n{{Identical|Revision}}", "pageid": "Used to format a page ID number in text. Parameters:\n* $1 - Page ID number.", "interfaceadmin-info": "Part of the error message shown when someone with the editinterface right but without the appropriate editsite* right tries to edit a sitewide CSS/JSON/JS page.", -- 2.20.1