jenkins-bot has submitted this change and it was merged.
Change subject: Pref for showing notifications
......................................................................
Pref for showing notifications
If this pref is turned off, we revert to the old orange bar talk
page notifications. Depends on core change Ifc8fbaf8.
Bug: 46550
Change-Id: If21f3aac51e484c5e077c7f4b5a2218e8b71ed2a
---
M Echo.i18n.php
M Echo.php
M Hooks.php
M includes/DiscussionParser.php
4 files changed, 27 insertions(+), 14 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Echo.i18n.php b/Echo.i18n.php
index 395a9e2..1113606 100644
--- a/Echo.i18n.php
+++ b/Echo.i18n.php
@@ -26,7 +26,7 @@
'echo-pref-email-frequency-immediately' => 'Individual notifications as
they come in',
'echo-pref-email-frequency-daily' => 'A daily summary of notifications',
'echo-pref-email-frequency-weekly' => 'A weekly summary of
notifications',
- 'echo-pref-notify-hide-link' => 'Hide the link and badge for
notifications in my toolbar',
+ 'echo-pref-notify-show-link' => 'Show notifications in my toolbar',
// Dismiss interface
'echo-dismiss-button' => 'Dismiss',
@@ -224,7 +224,7 @@
'echo-pref-email-frequency-immediately' => 'Option for users who want
to receive email for each notification as it occurs',
'echo-pref-email-frequency-daily' => 'Option for users who want to
receive a daily digest of email notifications',
'echo-pref-email-frequency-weekly' => 'Option for users who want to
receive a weekly digest of email notifications',
- 'echo-pref-notify-hide-link' => "Label for a preference which disables
the 'Notifications' link in the header and associated fly-out panel",
+ 'echo-pref-notify-show-link' => "Label for a preference which enables
the 'Notifications' link in the header and associated fly-out panel",
'echo-dismiss-button' => 'Text for the button that dismisses a
notification type. Keep this short.
{{Identical|Dismiss}}',
'echo-dismiss-message' => 'Message asking the user if they want to turn
off all notifications of a certain type. Parameters:
diff --git a/Echo.php b/Echo.php
index 0e422b3..f969917 100644
--- a/Echo.php
+++ b/Echo.php
@@ -346,7 +346,7 @@
);
// Enable notifications for all logged in users by default
-$wgDefaultUserOptions['echo-notify-link'] = 'true';
+$wgDefaultUserOptions['echo-notify-show-link'] = true;
// By default, send emails for each notification as they come in
$wgDefaultUserOptions['echo-email-frequency'] = EchoHooks::EMAIL_IMMEDIATELY;
diff --git a/Hooks.php b/Hooks.php
index 9c40549..ed58e45 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -368,6 +368,13 @@
'columns' => $columns,
'remove-options' => $removeOptions,
);
+
+ // Show fly-out display prefs
+ $preferences['echo-notify-show-link'] = array(
+ 'type' => 'toggle',
+ 'label-message' => 'echo-pref-notify-show-link',
+ 'section' => 'echo/displaynotifications',
+ );
return true;
}
@@ -508,7 +515,7 @@
*/
static function beforePageDisplay( $out, $skin ) {
$user = $out->getUser();
- if ( $user->isLoggedIn() && !$user->getOption(
'echo-notify-hide-link' ) ) {
+ if ( $user->isLoggedIn() && $user->getOption(
'echo-notify-show-link' ) ) {
// Load the module for the Notifications flyout
$out->addModules( array( 'ext.echo.overlay' ) );
}
@@ -526,7 +533,7 @@
static function onPersonalUrls( &$personal_urls, &$title ) {
global $wgUser, $wgEchoShowFullNotificationsLink;
// Add a "My notifications" item to personal URLs
- if ( $wgUser->isAnon() || $wgUser->getOption(
'echo-notify-hide-link' ) ) {
+ if ( $wgUser->isAnon() || !$wgUser->getOption(
'echo-notify-show-link' ) ) {
return true;
}
@@ -613,18 +620,22 @@
/**
* Handler for ArticleEditUpdateNewTalk hook.
* @see
http://www.mediawiki.org/wiki/Manual:Hooks/ArticleEditUpdateNewTalk
- * @param $page WikiPage The WikiPage object of the talk page being
updated
- * @return bool
+ * @param &$page WikiPage The WikiPage object of the talk page being
updated
+ * @param $recipient User The user who's talk page was edited
+ * @return bool Should return false to prevent the orange notification
bar
+ * or true to allow the orange notification bar
*/
- static function abortNewTalkNotification( $page ) {
- global $wgUser, $wgEchoNotifications;
+ static function abortNewTalkNotification( &$page, $recipient ) {
+ global $wgEchoNotifications;
// If the user has the notifications flyout turned on and is
receiving
- // notifications for talk page messages, disable the
yellow-bar-style notice.
- if ( !$wgUser->getOption( 'echo-notify-hide-link' )
- && isset( $wgEchoNotifications['edit-user-talk'] ) )
- {
+ // notifications for talk page messages, disable the
orange-bar-style notice.
+ if ( $recipient->getOption( 'echo-notify-show-link' )
+ && isset( $wgEchoNotifications['edit-user-talk'] )
+ ) {
+ // hide orange bar
return false;
} else {
+ // show orange bar
return true;
}
}
diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php
index b56fff4..0e08b65 100644
--- a/includes/DiscussionParser.php
+++ b/includes/DiscussionParser.php
@@ -76,7 +76,9 @@
if ( !$createdEvents && $title->getNamespace() == NS_USER_TALK
) {
$notifyUser = User::newFromName( $title->getText() );
- if ( $notifyUser && $notifyUser->getID() ) {
+ // If the recipient is a valid non-anonymous user and
hasn't turned
+ // off thier notifications, generate a talk page post
Echo notification.
+ if ( $notifyUser && $notifyUser->getID() &&
$notifyUser->getOption( 'echo-notify-show-link' ) ) {
EchoEvent::create( array(
'type' => 'edit-user-talk',
'title' => $title,
--
To view, visit https://gerrit.wikimedia.org/r/56536
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If21f3aac51e484c5e077c7f4b5a2218e8b71ed2a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Lwelling <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Nikerabbit <[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