(bug 22457) More natural flow for the "By e-mail" feature
authorLiangent <liangent@gmail.com>
Sun, 16 Dec 2012 11:18:24 +0000 (19:18 +0800)
committerLiangent <liangent@gmail.com>
Sat, 12 Jan 2013 08:19:32 +0000 (16:19 +0800)
This feature is on Special:Userlogin/signup to allow a random new
password to be sent to expected account owner on assisted signup.

It uses JavaScript to hide the password & retype password fields when a
logged-in user creates an account (for someone else) and checks the by
e-mail feature.

Change-Id: I7bf57eef64fea19a8237f997019e0b2bfdf401b3

includes/specials/SpecialUserlogin.php
includes/templates/Usercreate.php
languages/messages/MessagesEn.php
resources/Resources.php
resources/mediawiki.special/mediawiki.special.userLogin.signup.js [new file with mode: 0644]

index 098caaf..7700279 100644 (file)
@@ -95,9 +95,9 @@ class LoginForm extends SpecialPage {
                $this->mReason = $request->getText( 'wpReason' );
                $this->mCookieCheck = $request->getVal( 'wpCookieCheck' );
                $this->mPosted = $request->wasPosted();
-               $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' );
                $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' )
                                                                        && $wgEnableEmail;
+               $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' ) && !$this->mCreateaccountMail;
                $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' );
                $this->mAction = $request->getVal( 'action' );
                $this->mRemember = $request->getCheck( 'wpRemember' );
@@ -1044,6 +1044,7 @@ class LoginForm extends SpecialPage {
                        $q = 'action=submitlogin&type=signup';
                        $linkq = 'type=login';
                        $linkmsg = 'gotaccount';
+                       $this->getOutput()->addModules( 'mediawiki.special.userlogin.signup' );
                } else {
                        $template = new UserloginTemplate();
                        $q = 'action=submitlogin&type=login';
@@ -1083,6 +1084,7 @@ class LoginForm extends SpecialPage {
                $template->set( 'name', $this->mUsername );
                $template->set( 'password', $this->mPassword );
                $template->set( 'retype', $this->mRetype );
+               $template->set( 'createemailset', $this->mCreateaccountMail );
                $template->set( 'email', $this->mEmail );
                $template->set( 'realname', $this->mRealName );
                $template->set( 'domain', $this->mDomain );
index 6e1094f..569200d 100644 (file)
@@ -77,13 +77,27 @@ class UsercreateTemplate extends QuickTemplate {
                        </td>
                </tr>
                <tr>
+                       <td></td>
+                       <td class="mw-input">
+                               <?php if( $this->data['createemail'] ) {
+                                       echo Xml::checkLabel(
+                                               wfMessage( 'createaccountmail' )->text(),
+                                               'wpCreateaccountMail',
+                                               'wpCreateaccountMail',
+                                               $this->data['createemailset'],
+                                               array( 'tabindex' => '2' )
+                                       );
+                               } ?>
+                       </td>
+               </tr>
+               <tr class="mw-row-password">
                        <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
                        <td class="mw-input">
 <?php
                        echo Html::input( 'wpPassword', null, 'password', array(
                                'class' => 'loginPassword',
                                'id' => 'wpPassword2',
-                               'tabindex' => '2',
+                               'tabindex' => '3',
                                'size' => '20'
                        ) + User::passwordChangeInputAttribs() ); ?>
                        </td>
@@ -98,20 +112,20 @@ class UsercreateTemplate extends QuickTemplate {
                        <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
                        <td class="mw-input">
                                <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
-                                       tabindex="3">
+                                       tabindex="4">
                                        <?php echo $doms ?>
                                </select>
                        </td>
                </tr>
        <?php } ?>
-               <tr>
+               <tr class="mw-row-password">
                        <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
                        <td class="mw-input">
                                <?php
                echo Html::input( 'wpRetype', null, 'password', array(
                        'class' => 'loginPassword',
                        'id' => 'wpRetype',
-                       'tabindex' => '4',
+                       'tabindex' => '5',
                        'size' => '20'
                ) + User::passwordChangeInputAttribs() ); ?>
                        </td>
@@ -124,7 +138,7 @@ class UsercreateTemplate extends QuickTemplate {
                echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
                        'class' => 'loginText',
                        'id' => 'wpEmail',
-                       'tabindex' => '5',
+                       'tabindex' => '6',
                        'size' => '20'
                ) ); ?>
                                        <div class="prefsectiontip">
@@ -146,7 +160,7 @@ class UsercreateTemplate extends QuickTemplate {
                                        <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
                                        <td class="mw-input">
                                                <input type='text' class='loginText' name="wpRealName" id="wpRealName"
-                                                       tabindex="6"
+                                                       tabindex="7"
                                                        value="<?php $this->text('realname') ?>" size='20' />
                                                <div class="prefsectiontip">
                                                        <?php $this->msgWiki('prefs-help-realname'); ?>
@@ -159,7 +173,7 @@ class UsercreateTemplate extends QuickTemplate {
                                        <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
                                        <td class="mw-input">
                                                <input type='text' class='loginText' name="wpReason" id="wpReason"
-                                                       tabindex="7"
+                                                       tabindex="8"
                                                        value="<?php $this->text('reason') ?>" size='20' />
                                        </td>
                        <?php } ?>
@@ -176,14 +190,14 @@ class UsercreateTemplate extends QuickTemplate {
                                        'wpRemember',
                                        'wpRemember',
                                        $this->data['remember'],
-                                       array( 'tabindex' => '8' )
+                                       array( 'tabindex' => '9' )
                                )
                                ?>
                        </td>
                </tr>
 <?php   }
 
-               $tabIndex = 9;
+               $tabIndex = 10;
                if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
                        foreach ( $this->data['extraInput'] as $inputItem ) { ?>
                <tr>
@@ -234,11 +248,6 @@ class UsercreateTemplate extends QuickTemplate {
                                <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
                                        tabindex="<?php echo $tabIndex++; ?>"
                                        value="<?php $this->msg('createaccount') ?>" />
-                               <?php if( $this->data['createemail'] ) { ?>
-                               <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
-                                       tabindex="<?php echo $tabIndex++; ?>"
-                                       value="<?php $this->msg('createaccountmail') ?>" />
-                               <?php } ?>
                        </td>
                </tr>
        </table>
index e4da1dd..2579849 100644 (file)
@@ -1094,7 +1094,7 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].',
 'gotaccount'                 => 'Already have an account? $1.',
 'gotaccountlink'             => 'Log in',
 'userlogin-resetlink'        => 'Forgotten your login details?',
-'createaccountmail'          => 'By e-mail',
+'createaccountmail'          => 'Use a temporary random password and send it to the e-mail address specified below',
 'createaccountreason'        => 'Reason:',
 'badretype'                  => 'The passwords you entered do not match.',
 'userexists'                 => 'Username entered already in use.
index 9987ee1..3210af1 100644 (file)
@@ -922,6 +922,9 @@ return array(
                ),
                'dependencies' => array( 'mediawiki.libs.jpegmeta', 'mediawiki.util' ),
        ),
+       'mediawiki.special.userlogin.signup' => array(
+               'scripts' => 'resources/mediawiki.special/mediawiki.special.userLogin.signup.js',
+       ),
        'mediawiki.special.javaScriptTest' => array(
                'scripts' => 'resources/mediawiki.special/mediawiki.special.javaScriptTest.js',
                'messages' => array_merge( Skin::getSkinNameMessages(), array(
diff --git a/resources/mediawiki.special/mediawiki.special.userLogin.signup.js b/resources/mediawiki.special/mediawiki.special.userLogin.signup.js
new file mode 100644 (file)
index 0000000..bba4260
--- /dev/null
@@ -0,0 +1,10 @@
+/**
+ * JavaScript for Special:UserLogin/signup
+ */
+jQuery( document ).ready( function ( $ ) {
+       $( '#wpCreateaccountMail' )
+               .on( 'change', function() {
+                       $( '.mw-row-password' ).toggle( !$( this ).attr( 'checked' ) );
+               } )
+               .trigger( 'change' );
+} );