From 2d8085bd15d094f3cf6136e11f6baded9f6de6e9 Mon Sep 17 00:00:00 2001 From: mech Date: Mon, 8 Mar 2021 23:03:20 +0100 Subject: [PATCH] Unset user-to-user email option when user emails are disabled When one of the $wgEnableEmail and $wgEnableUserEmail variables is false, "Email from other user" option should not be shown in preferences. Bug: T266087 Change-Id: I38e439b778d2679967776757d8e0d3b63519612e --- includes/EchoHooks.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/EchoHooks.php b/includes/EchoHooks.php index edf365630..988950b32 100644 --- a/includes/EchoHooks.php +++ b/includes/EchoHooks.php @@ -85,7 +85,8 @@ class EchoHooks implements RecentChange_saveHook { public static function initEchoExtension() { global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons, $wgEchoMentionStatusNotifications, $wgAllowArticleReminderNotification, $wgAPIModules, - $wgEchoWatchlistNotifications, $wgEchoSeenTimeCacheType, $wgMainStash; + $wgEchoWatchlistNotifications, $wgEchoSeenTimeCacheType, $wgMainStash, $wgEnableEmail, + $wgEnableUserEmail; // allow extensions to define their own event Hooks::run( 'BeforeCreateEchoEvent', @@ -109,6 +110,11 @@ class EchoHooks implements RecentChange_saveHook { unset( $wgEchoNotificationCategories['minor-watchlist'] ); } + // Only allow user email notifications when enabled + if ( !$wgEnableEmail || !$wgEnableUserEmail ) { + unset( $wgEchoNotificationCategories['emailuser'] ); + } + // Default $wgEchoSeenTimeCacheType to $wgMainStash if ( $wgEchoSeenTimeCacheType === null ) { $wgEchoSeenTimeCacheType = $wgMainStash;