WatchAction: Add 'returnto' and 'returntoquery' to the login link
authorkonarak <konarak.11@gmail.com>
Fri, 4 Apr 2014 08:35:28 +0000 (14:05 +0530)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 6 Apr 2014 01:07:46 +0000 (01:07 +0000)
Bug: 60594
Change-Id: Ic8c0ea5b203c63f9273992cb70bfb06c0d461311

includes/actions/WatchAction.php
languages/i18n/en.json
languages/i18n/qqq.json

index e1b5d52..2c7502e 100644 (file)
@@ -82,7 +82,14 @@ class WatchAction extends FormAction {
        protected function checkCanExecute( User $user ) {
                // Must be logged in
                if ( $user->isAnon() ) {
-                       throw new ErrorPageError( 'watchnologin', 'watchnologintext' );
+                       $loginreqlink = Linker::linkKnown(
+                               SpecialPage::getTitleFor( 'Userlogin' ),
+                               $this->msg( 'loginreqlink' )->escaped(),
+                               array(),
+                               array( 'returnto' => $this->getPageTitle(), 'returntoquery' => 'action=' . $this->getName() )
+                       );
+                       $reasonMsg = $this->msg( 'watchlistanontext' )->rawParams( $loginreqlink );
+                       throw new UserNotLoggedIn( $reasonMsg, 'watchnologin' );
                }
 
                return parent::checkCanExecute( $user );
index 9031b96..5379a7c 100644 (file)
     "nowatchlist": "You have no items on your watchlist.",
     "watchlistanontext": "Please $1 to view or edit items on your watchlist.",
     "watchnologin": "Not logged in",
-    "watchnologintext": "You must be [[Special:UserLogin|logged in]] to modify your watchlist.",
     "addwatch": "Add to watchlist",
     "addedwatchtext": "The page \"[[:$1]]\" has been added to your [[Special:Watchlist|watchlist]].\nFuture changes to this page and its associated talk page will be listed there.",
     "removewatch": "Remove from watchlist",
index 5b3c939..dddee1f 100644 (file)
     "nowatchlist": "Displayed when there is no pages in the watchlist.",
     "watchlistanontext": "Parameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description",
     "watchnologin": "Used as error page title.\n\nThe error message for this title is:\n* {{msg-mw|Watchnologintext}}\n{{Identical|Not logged in}}",
-    "watchnologintext": "Used as error message.\n\nThe title for this error is {{msg-mw|Watchnologin}}.",
     "addwatch": "Link to a dialog box, displayed at the end of the list of categories at the foot of each page.\n\nSee also:\n* {{msg-mw|Removewatch}}",
     "addedwatchtext": "Explanation shown when clicking on the {{msg-mw|Watch}} tab. Parameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Addedwatch}}",
     "removewatch": "Link to a dialog box, displayed at the end of the list of categories at the foot of each page.\n\nSee also:\n* {{msg-mw|Addwatch}}",