Special:UserLogin UI improvements when user is logged in
authorMatmaRex <matma.rex@gmail.com>
Sat, 24 Aug 2013 20:37:58 +0000 (22:37 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 6 Oct 2013 19:00:26 +0000 (21:00 +0200)
* Show a warning about being already logged in above login form
* Show a button pointing to signup form with suitable explanation

Also changed some internal template stuff (s/createAnother/loggedin/).

Bug: 53306
Change-Id: I1672ee09330c231110c4db310a645d1382cc0b59

includes/specials/SpecialUserlogin.php
includes/templates/Usercreate.php
includes/templates/Userlogin.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc
resources/mediawiki.special/mediawiki.special.userLogin.css

index 7a93ade..2b60ca2 100644 (file)
@@ -1167,12 +1167,8 @@ class LoginForm extends SpecialPage {
                $template->set( 'remember', $user->getOption( 'rememberpassword' ) || $this->mRemember );
                $template->set( 'cansecurelogin', ( $wgSecureLogin === true ) );
                $template->set( 'stickhttps', (int)$this->mStickHTTPS );
-
-               if ( $this->mType === 'signup' && $user->isLoggedIn() ) {
-                       $template->set( 'createAnother', true );
-               } else {
-                       $template->set( 'createAnother', false );
-               }
+               $template->set( 'loggedin', $user->isLoggedIn() );
+               $template->set( 'loggedinuser', $user->getName() );
 
                if ( $this->mType == 'signup' ) {
                        if ( !self::getCreateaccountToken() ) {
@@ -1231,9 +1227,7 @@ class LoginForm extends SpecialPage {
         * @return bool
         */
        private function showCreateOrLoginLink( &$user ) {
-               if ( $user->isLoggedIn() ) {
-                       return false;
-               } elseif ( $this->mType == 'signup' ) {
+               if ( $this->mType == 'signup' ) {
                        return true;
                } elseif ( $user->isAllowed( 'createaccount' ) ) {
                        return true;
index 3d848cf..50dfaec 100644 (file)
@@ -58,7 +58,7 @@ class UsercreateTemplate extends BaseTemplate {
 <div id="userloginForm">
 <h2 class="createaccount-join">
        <?php
-       $this->msg( $this->data['createAnother'] ?
+       $this->msg( $this->data['loggedin'] ?
                'createacct-another-join' : 'createacct-join' );
        ?>
 </h2>
@@ -89,7 +89,7 @@ class UsercreateTemplate extends BaseTemplate {
                                'tabindex' => '1',
                                'size' => '20',
                                'required',
-                               'placeholder' => $this->getMsg( $this->data['createAnother'] ?
+                               'placeholder' => $this->getMsg( $this->data['loggedin'] ?
                                        'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(),
                        ) );
                        ?>
@@ -162,7 +162,7 @@ class UsercreateTemplate extends BaseTemplate {
                                        'id' => 'wpEmail',
                                        'tabindex' => '6',
                                        'size' => '20',
-                                       'placeholder' => $this->getMsg( $this->data['createAnother'] ?
+                                       'placeholder' => $this->getMsg( $this->data['loggedin'] ?
                                                'createacct-another-email-ph' : 'createacct-email-ph' )->text()
                                ) + ( $this->data['emailrequired'] ? array() : array( 'required' => '' ) ) );
                        ?>
@@ -175,7 +175,7 @@ class UsercreateTemplate extends BaseTemplate {
                                        tabindex="7"
                                        value="<?php $this->text( 'realname' ); ?>" size='20' />
                                <div class="prefsectiontip">
-                                       <?php $this->msgWiki( $this->data['createAnother'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
+                                       <?php $this->msgWiki( $this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
                                </div>
                        </div>
                <?php }
@@ -253,7 +253,7 @@ class UsercreateTemplate extends BaseTemplate {
                <div class="mw-submit">
                        <?php
                        echo Html::input( 'wpCreateaccount',
-                               $this->getMsg( $this->data['createAnother'] ?
+                               $this->getMsg( $this->data['loggedin'] ?
                                        'createacct-another-submit' : 'createacct-submit' ),
                                'submit',
                                array(
index 39091ef..202ec55 100644 (file)
@@ -39,6 +39,11 @@ class UserloginTemplate extends BaseTemplate {
        ?>
 <div id="userloginForm">
 <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
+       <?php if ( $this->data['loggedin'] ) { ?>
+               <div class="warningbox">
+                       <?php echo $this->getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?>
+               </div>
+       <?php } ?>
        <section class="mw-form-header">
                <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
        </section>
@@ -164,9 +169,15 @@ class UserloginTemplate extends BaseTemplate {
                        <?php echo $this->getMsg( 'userlogin-helplink' )->parse(); ?>
                </div>
                <?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
-                       <div id="mw-createaccount-cta">
-                               <h3 id="mw-userloginlink"><?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-constructive"><?php $this->msg( 'userlogin-joinproject' ); ?></a></h3>
-                       </div>
+                       <?php if ( $this->data['loggedin'] ) { ?>
+                               <div id="mw-createaccount-another">
+                                       <h3 id="mw-userloginlink"><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button"><?php $this->msg( 'userlogin-createanother' ); ?></a></h3>
+                               </div>
+                       <?php } else { ?>
+                               <div id="mw-createaccount-cta">
+                                       <h3 id="mw-userloginlink"><?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-constructive"><?php $this->msg( 'userlogin-joinproject' ); ?></a></h3>
+                               </div>
+                       <?php } ?>
                <?php } ?>
 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
index 3dedbb9..faaccd2 100644 (file)
@@ -1134,6 +1134,9 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].',
 'userlogin-resetpassword-link'    => 'Reset your password',
 'helplogin-url'                   => 'Help:Logging in',
 'userlogin-helplink'              => '[[{{MediaWiki:helplogin-url}}|Help with logging in]]',
+'userlogin-loggedin'              => 'You are already logged in as {{GENDER:$1|$1}}.
+Use the form below to log in as another user.',
+'userlogin-createanother'         => 'Create another account',
 'createacct-join'                 => 'Enter your information below.',
 'createacct-another-join'         => "Enter the new account's information below.",
 'createacct-emailrequired'        => 'Email address',
index 72fe747..0ffbcee 100644 (file)
@@ -1353,6 +1353,11 @@ See example: [[Special:UserLogin]]
 
 See also:
 * {{msg-mw|Helplogin-url}}',
+'userlogin-loggedin' => 'Used instead of the form on [[Special:UserLogin]] when the current user is already logged in.
+
+Parameters:
+* $1 - user name (used for display and for gender support)',
+'userlogin-createanother' => 'Button on [[Special:UserLogin]] shown when the current user is already logged in.',
 'createacct-join' => 'Subheading of vertical-layout create account form encouraging user to join the wiki.
 
 See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]',
index 01976f4..ca3a4f5 100644 (file)
@@ -485,6 +485,8 @@ $wgMessageStructure = array(
                'userlogin-resetpassword-link',
                'helplogin-url',
                'userlogin-helplink',
+               'userlogin-loggedin',
+               'userlogin-createanother',
                'createacct-join',
                'createacct-another-join',
                'createacct-emailrequired',
index 312f811..24c8d77 100644 (file)
 #mw-createaccount-cta {
        width: 20em;
        height: 10em;
-       text-align: center;
        /* @embed */
        background: url(images/glyph-people-large.png) no-repeat 50%;
        margin: 0 auto;
 }
 
-#mw-createaccount-cta h3 {
+#mw-createaccount-cta h3,
+#mw-createaccount-another h3 {
        font-size: 0.9em;
        font-weight: normal;
        text-align: center;
+}
+
+#mw-createaccount-cta h3 {
        padding-top: 4em;
 }