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

Change subject: Show orange alert and provide hook
......................................................................


Show orange alert and provide hook

Show orange alert for all notification types in the edit-user-talk
category and provide a hook to enable other extensions to prevent
the orange alert from appearing.

Bug: T137954
Change-Id: I0b49c3a5eb0a027f8839ab86e77c527357907dd0
---
M Hooks.php
M includes/NotifUser.php
M includes/model/Notification.php
3 files changed, 15 insertions(+), 7 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Hooks.php b/Hooks.php
index 3caf0bc..09a98b6 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -957,9 +957,11 @@
                if ( $wgEchoNewMsgAlert && $user->getOption( 'echo-show-alert' )
                        && $user->getNewtalk() && 
!$user->getTalkPage()->equals( $title )
                ) {
-                       $personal_urls['mytalk']['text'] = $sk->msg( 
'echo-new-messages' )->text();
-                       $personal_urls['mytalk']['class'] = array( 
'mw-echo-alert' );
-                       $sk->getOutput()->addModuleStyles( 
'ext.echo.styles.alert' );
+                       if ( Hooks::run( 'BeforeDisplayOrangeAlert', array( 
$user, $title ) ) ) {
+                               $personal_urls['mytalk']['text'] = $sk->msg( 
'echo-new-messages' )->text();
+                               $personal_urls['mytalk']['class'] = array( 
'mw-echo-alert' );
+                               $sk->getOutput()->addModuleStyles( 
'ext.echo.styles.alert' );
+                       }
                }
 
                return true;
diff --git a/includes/NotifUser.php b/includes/NotifUser.php
index e7d6ded..745c284 100644
--- a/includes/NotifUser.php
+++ b/includes/NotifUser.php
@@ -148,7 +148,6 @@
         */
        public function getTalkNotificationCacheKey() {
                global $wgEchoConfig;
-
                return wfMemcKey( 'echo-new-talk-notification', 
$this->mUser->getId(), $wgEchoConfig['version'] );
        }
 
@@ -365,7 +364,10 @@
                        // After this 'mark read', is there any unread 
edit-user-talk
                        // remaining?  If not, we should clear the newtalk flag.
                        if ( $this->mUser->getNewtalk() ) {
-                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, array( 
'edit-user-talk' ), null, DB_MASTER );
+                               $attributeManager = 
EchoAttributeManager::newFromGlobalVars();
+                               $categoryMap = 
$attributeManager->getEventsByCategory();
+                               $usertalkTypes = $categoryMap['edit-user-talk'];
+                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, 
null, DB_MASTER );
                                if ( count( $unreadEditUserTalk ) === 0 ) {
                                        $this->mUser->setNewtalk( false );
                                }
@@ -394,7 +396,10 @@
                        // After this 'mark unread', is there any unread 
edit-user-talk?
                        // If so, we should add the edit-user-talk flag
                        if ( !$this->mUser->getNewtalk() ) {
-                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, array( 
'edit-user-talk' ), null, DB_MASTER );
+                               $attributeManager = 
EchoAttributeManager::newFromGlobalVars();
+                               $categoryMap = 
$attributeManager->getEventsByCategory();
+                               $usertalkTypes = $categoryMap['edit-user-talk'];
+                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, 
null, DB_MASTER );
                                if ( count( $unreadEditUserTalk ) > 0 ) {
                                        $this->mUser->setNewtalk( true );
                                }
diff --git a/includes/model/Notification.php b/includes/model/Notification.php
index 3114969..a94b665 100644
--- a/includes/model/Notification.php
+++ b/includes/model/Notification.php
@@ -142,8 +142,9 @@
 
                $notifMapper->insert( $this );
 
-               if ( $this->event->getType() === 'edit-user-talk' ) {
+               if ( $this->event->getCategory() === 'edit-user-talk' ) {
                        $notifUser->flagCacheWithNewTalkNotification();
+                       $this->mUser->setNewTalk( true );
                }
                Hooks::run( 'EchoCreateNotificationComplete', array( $this ) );
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0b49c3a5eb0a027f8839ab86e77c527357907dd0
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Kmuthu <kmu...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to