From 3666c3752aaeb968b0c1b976e301c96136110a20 Mon Sep 17 00:00:00 2001 From: Liangent Date: Sun, 16 Dec 2012 19:18:24 +0800 Subject: [PATCH] (bug 22457) More natural flow for the "By e-mail" feature 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 | 4 +- includes/templates/Usercreate.php | 37 ++++++++++++------- languages/messages/MessagesEn.php | 2 +- resources/Resources.php | 3 ++ .../mediawiki.special.userLogin.signup.js | 10 +++++ 5 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 resources/mediawiki.special/mediawiki.special.userLogin.signup.js diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 098caaf96d..770027960a 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -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 ); diff --git a/includes/templates/Usercreate.php b/includes/templates/Usercreate.php index 6e1094f6c0..569200d26c 100644 --- a/includes/templates/Usercreate.php +++ b/includes/templates/Usercreate.php @@ -77,13 +77,27 @@ class UsercreateTemplate extends QuickTemplate { + + + data['createemail'] ) { + echo Xml::checkLabel( + wfMessage( 'createaccountmail' )->text(), + 'wpCreateaccountMail', + 'wpCreateaccountMail', + $this->data['createemailset'], + array( 'tabindex' => '2' ) + ); + } ?> + + + 'loginPassword', 'id' => 'wpPassword2', - 'tabindex' => '2', + 'tabindex' => '3', 'size' => '20' ) + User::passwordChangeInputAttribs() ); ?> @@ -98,20 +112,20 @@ class UsercreateTemplate extends QuickTemplate { msg( 'yourdomainname' ) ?> - + 'loginPassword', 'id' => 'wpRetype', - 'tabindex' => '4', + 'tabindex' => '5', 'size' => '20' ) + User::passwordChangeInputAttribs() ); ?> @@ -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' ) ); ?>
@@ -146,7 +160,7 @@ class UsercreateTemplate extends QuickTemplate {
msgWiki('prefs-help-realname'); ?> @@ -159,7 +173,7 @@ class UsercreateTemplate extends QuickTemplate { @@ -176,14 +190,14 @@ class UsercreateTemplate extends QuickTemplate { 'wpRemember', 'wpRemember', $this->data['remember'], - array( 'tabindex' => '8' ) + array( 'tabindex' => '9' ) ) ?> data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) { foreach ( $this->data['extraInput'] as $inputItem ) { ?> @@ -234,11 +248,6 @@ class UsercreateTemplate extends QuickTemplate { - data['createemail'] ) { ?> - - diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index e4da1dde8d..25798490d7 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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. diff --git a/resources/Resources.php b/resources/Resources.php index 9987ee1dca..3210af1d14 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 index 0000000000..bba426051e --- /dev/null +++ b/resources/mediawiki.special/mediawiki.special.userLogin.signup.js @@ -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' ); +} ); -- 2.20.1