Fix and Enhance:
authorJack D. Pond <jdpond@users.mediawiki.org>
Sun, 6 Mar 2011 05:39:41 +0000 (05:39 +0000)
committerJack D. Pond <jdpond@users.mediawiki.org>
Sun, 6 Mar 2011 05:39:41 +0000 (05:39 +0000)
1. Fix - previously unresolved possible return value (ABORTED) added to switch
2. Allows a message to be returned when status "ABORTED" instead of just one of existing generic messages.

includes/api/ApiLogin.php
includes/specials/SpecialUserlogin.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index 2bd773a..e223dab 100644 (file)
@@ -140,6 +140,11 @@ class ApiLogin extends ApiBase {
                                $result['result'] = 'Blocked';
                                break;
 
+                       case LoginForm::ABORTED:
+                               $result['result'] = 'Aborted';
+                               $result['reason'] =  $this->mAbortLoginErrorMsg;
+                               break;
+
                        default:
                                ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$authRes}" );
                }
index d13c49a..a82e25d 100644 (file)
@@ -47,6 +47,7 @@ class LoginForm extends SpecialPage {
        var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
        var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
        var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS;
+       var $mAbortLoginErrorMsg = 'login-abort-generic';
 
        private $mExtUser = null;
 
@@ -527,7 +528,7 @@ class LoginForm extends SpecialPage {
 
                // Give general extensions, such as a captcha, a chance to abort logins
                $abort = self::ABORTED;
-               if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort ) ) ) {
+               if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$this->mAbortLoginErrorMsg ) ) ) {
                        return $abort;
                }
 
@@ -707,6 +708,9 @@ class LoginForm extends SpecialPage {
                                $this->mainLoginForm( wfMsgExt( 'login-userblocked',
                                        array( 'parsemag', 'escape' ), $this->mUsername ) );
                                break;
+                       case self::ABORTED:
+                               $this->mainLoginForm( wfMsg( $this->mAbortLoginErrorMsg  ) );
+                               break;
                        default:
                                throw new MWException( 'Unhandled case value' );
                }
index c4ee837..9490956 100644 (file)
@@ -1153,6 +1153,7 @@ You may ignore this message, if this account was created in error.',
 'usernamehasherror'          => 'Username cannot contain hash characters',
 'login-throttled'            => 'You have made too many recent login attempts.
 Please wait before trying again.',
+'login-abort-generic'        => 'Your login was unsuccessful - Aborted',
 'loginlanguagelabel'         => 'Language: $1',
 'loginlanguagelinks'         => '* Deutsch|de
 * English|en
index 96fe2da..f516da9 100644 (file)
@@ -720,6 +720,7 @@ Parameters:
 *Parameter $3 is a password (randomly generated).
 *Parameter $4 is a URL to the wiki',
 'login-throttled'            => 'Error message shown at [[Special:UserLogin]] after 5 wrong passwords. The hardcoded waiting time is 300 seconds.',
+'login-abort-generic'        => 'The generic unsuccessful login message used unless otherwise specified by hook writers',
 
 # JavaScript password checks
 'password-strength'            => 'Indicator of [[w:Password strength|password strength]] shown when entering a new password (during user registration or password reset).
index 6247843..9a4c92f 100644 (file)
@@ -481,6 +481,7 @@ $wgMessageStructure = array(
                'createaccount-text',
                'usernamehasherror',
                'login-throttled',
+               'login-abort-generic',
                'loginlanguagelabel',
                'loginlanguagelinks',
                'suspicious-userlogout',