Mhutti1 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/257661

Change subject: Redirects annonomous user to login page from 
Special:Notifications
......................................................................

Redirects annonomous user to login page from Special:Notifications

Added code to redirect user and display a short message informing them of the 
need to login.

Change-Id: I2145bc1502dbd19d660302d9f19e0d4a2ad5ad50
Task: T118873
---
M Echo.php
M Hooks.php
M i18n/en.json
M includes/special/SpecialNotifications.php
4 files changed, 12 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/61/257661/1

diff --git a/Echo.php b/Echo.php
index c6f1408..cbbadc5 100644
--- a/Echo.php
+++ b/Echo.php
@@ -79,6 +79,7 @@
 $wgHooks['UserClearNewTalkNotification'][] = 
'EchoHooks::onUserClearNewTalkNotification';
 $wgHooks['ParserTestTables'][] = 'EchoHooks::onParserTestTables';
 $wgHooks['EmailUserComplete'][] = 'EchoHooks::onEmailUserComplete';
+$wgHooks['LoginFormValidErrorMessages'][] = 
'EchoHooks::onLoginFormValidErrorMessages';
 
 // Extension:UserMerge support
 $wgHooks['UserMergeAccountFields'][] = 'EchoHooks::onUserMergeAccountFields';
diff --git a/Hooks.php b/Hooks.php
index 00e4842..0a70db5 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -1070,4 +1070,11 @@
 
                return true;
        }
+       
+       //Sets custom login message for redirect from notification page
+       public static function onLoginFormValidErrorMessages( &$messages ) { 
+               $messages[] = 'echo-notification-loginrequired'; 
+               return true;
+       }
+       
 }
diff --git a/i18n/en.json b/i18n/en.json
index 204a0f3..7f6db13 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -52,6 +52,7 @@
        "echo-quotation-marks": "\"$1\"",
        "echo-api-failure": "Could not retrieve notifications. Please try 
again. (Error $1)",
        "echo-notification-placeholder": "There are no notifications.",
+       "echo-notification-loginrequired": "You must login to see 
notifications.",
        "notification-link-text-view-message": "View message",
        "notification-link-text-view-mention": "View mention",
        "notification-link-text-view-changes": "View changes",
diff --git a/includes/special/SpecialNotifications.php 
b/includes/special/SpecialNotifications.php
index a67090a..a6b0e85 100644
--- a/includes/special/SpecialNotifications.php
+++ b/includes/special/SpecialNotifications.php
@@ -20,16 +20,8 @@
 
                $user = $this->getUser();
                if ( $user->isAnon() ) {
-                       // return to this title upon login
-                       $returnTo = array( 'returnto' => 
$this->getPageTitle()->getPrefixedDBkey() );
-                       // the html message for anon users
-                       $anonMsgHtml = $this->msg(
-                               'echo-anon',
-                               SpecialPage::getTitleFor( 'Userlogin', 'signup' 
)->getFullURL( $returnTo ),
-                               SpecialPage::getTitleFor( 'Userlogin' 
)->getFullURL( $returnTo )
-                       )->parse();
-                       $out->addHTML( Html::rawElement( 'span', array( 'class' 
=> 'plainlinks' ), $anonMsgHtml ) );
-
+                       //Redirect to login page and inform user of the need to 
login
+                       $this->requireLogin( 'echo-notification-loginrequired' 
);
                        return;
                }
 
@@ -151,7 +143,7 @@
                        $echoSeenTime->setTime( wfTimestamp( TS_MW ) );
                } );
        }
-
+       
        /**
         * Build the subtitle (more info and preference links)
         * @return string HTML for the subtitle

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2145bc1502dbd19d660302d9f19e0d4a2ad5ad50
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mhutti1 <[email protected]>

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

Reply via email to