From: S Page Date: Tue, 9 Jul 2013 04:35:43 +0000 (-0700) Subject: Form improvements when creating another's account X-Git-Tag: 1.31.0-rc.0~19169^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=db139892723554407ae10d5028fa54300aa58487;p=lhc%2Fweb%2Fwiklou.git Form improvements when creating another's account Detect a logged-in user creating an account for someone else and change messages: * heading is "Enter the new account information below." * username placeholder is "Enter the username", not "Enter your username" * email field placeholder is "Enter email address" not "Enter your ..." * submit button is "Create another account" Also improve JS when e-mail password is checked to remove the password fields (otherwise the form still submits them and browser prompts to remember password). Bug: 47792 Change-Id: I00e0d21d63bf32ad691ea3a27523298478e2d45c --- diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index b1a123e63b..6e557f3a59 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -1153,6 +1153,12 @@ class LoginForm extends SpecialPage { $template->set( 'cansecurelogin', ( $wgSecureLogin === true ) ); $template->set( 'stickHTTPS', $this->mStickHTTPS ); + if ( $this->mType === 'signup' && $user->isLoggedIn() ) { + $template->set( 'createAnother', true ); + } else { + $template->set( 'createAnother', false ); + } + if ( $this->mType == 'signup' ) { if ( !self::getCreateaccountToken() ) { self::setCreateaccountToken(); diff --git a/includes/templates/Usercreate.php b/includes/templates/Usercreate.php index c066da95f8..c7a0014693 100644 --- a/includes/templates/Usercreate.php +++ b/includes/templates/Usercreate.php @@ -56,7 +56,12 @@ class UsercreateTemplate extends BaseTemplate { } ?>
-

msg( 'createacct-join' ); ?>

+

+ msg( $this->data['createAnother'] ? + 'createacct-another-join' : 'createacct-join' ); + ?> +

html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?> @@ -77,15 +82,17 @@ class UsercreateTemplate extends BaseTemplate { getMsg( 'createacct-helpusername' )->parse(); ?> - data['name'], 'text', array( + data['name'], 'text', array( 'class' => 'mw-input loginText', 'id' => 'wpName2', 'tabindex' => '1', 'size' => '20', 'required', - 'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text(), - 'autofocus' - ) ); ?> + 'placeholder' => $this->getMsg( $this->data['createAnother'] ? + 'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(), + ) ); + ?>
data['createemail'] ) { ?> @@ -155,7 +162,8 @@ class UsercreateTemplate extends BaseTemplate { 'id' => 'wpEmail', 'tabindex' => '6', 'size' => '20', - 'placeholder' => $this->getMsg( 'createacct-email-ph' )->text() + 'placeholder' => $this->getMsg( $this->data['createAnother'] ? + 'createacct-another-email-ph' : 'createacct-email-ph' )->text() ) + ( $this->data['emailrequired'] ? array() : array( 'required' => '' ) ) ); ?> @@ -243,9 +251,17 @@ class UsercreateTemplate extends BaseTemplate { $tabIndex++; ?>
- + getMsg( $this->data['createAnother'] ? + 'createacct-another-submit' : 'createacct-submit' ), + 'submit', + array( + 'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-primary", + 'id' => 'wpCreateaccount', + 'tabindex' => $tabIndex++ + ) ); + ?>
haveData( 'uselang' ) ) { ?> haveData( 'token' ) ) { ?> diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 6926036956..29a4333874 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1099,6 +1099,7 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].', 'yourname' => 'Username:', 'userlogin-yourname' => 'Username', 'userlogin-yourname-ph' => 'Enter your username', +'createacct-another-username-ph' => 'Enter the username', 'createacct-helpusername' => '', # do not translate or duplicate this message to other languages 'yourpassword' => 'Password:', 'userlogin-yourpassword' => 'Password', @@ -1135,9 +1136,11 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].', 'helplogin-url' => 'Help:Logging in', 'userlogin-helplink' => '[[{{MediaWiki:helplogin-url}}|Help with logging in]]', 'createacct-join' => 'Enter your information below.', +'createacct-another-join' => 'Enter the new account\'s information below.', 'createacct-emailrequired' => 'Email address', 'createacct-emailoptional' => 'Email address (optional)', 'createacct-email-ph' => 'Enter your email address', +'createacct-another-email-ph' => 'Enter email address', 'createaccountmail' => 'Use a temporary random password and send it to the email address specified below', 'createacct-realname' => 'Real name (optional)', 'createaccountreason' => 'Reason:', @@ -1147,6 +1150,7 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].', 'createacct-imgcaptcha-help' => '', # do not translate or duplicate this message to other languages 'createacct-imgcaptcha-ph' => 'Enter the text you see above', 'createacct-submit' => 'Create your account', +'createacct-another-submit' => 'Create another account', 'createacct-benefit-heading' => '{{SITENAME}} is made by people like you.', 'createacct-benefit-icon1' => 'icon-edits', # do not translate or duplicate this message to other languages 'createacct-benefit-head1' => '{{NUMBEROFEDITS}}', # do not translate or duplicate this message to other languages diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 0145b00e32..d8919c1e1d 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -1074,6 +1074,7 @@ See examples: [[Special:UserLogin]] and [{{canonicalurl:Special:UserLogin|type=s 'userlogin-yourname-ph' => 'Placeholder text in login & create account form field. See example: [[Special:UserLogin]] and [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]', +'createacct-another-username-ph' => 'Placeholder text in create account form field when one user creates an account for another.', 'yourpassword' => 'In user preferences {{Identical|Password}}', @@ -1178,7 +1179,8 @@ See also: '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]', -'createacct-emailrequired' => 'Label in vertical-layout create account form for email field when it is required. +'createacct-another-join' => 'Subheading of create account form when one user creates an account for another.', +'createacct-emailrequired' => 'Label in create account form for email field when it is required. See also: * {{msg-mw|Createacct-emailoptional}} @@ -1192,6 +1194,7 @@ See also: 'createacct-email-ph' => 'Placeholder in vertical-layout create account form for email field. See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]', +'createacct-another-email-ph' => 'Placeholder in create account form for email field when one user creates an account for another.', 'createaccountmail' => 'The label for the checkbox for creating a new account and sending the new password to the specified e-mail address directly, as used on [[Special:UserLogin/signup]] when one user creates an account for another (if creating accounts by e-mail is allowed). See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]', @@ -1211,6 +1214,7 @@ See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?t 'createacct-submit' => 'Submit button on vertical-layout create account form. See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]', +'createacct-another-submit' => 'Submit button on create account form when one user creates an account for another.', 'createacct-benefit-heading' => 'In vertical-layout create account form, the heading for the section describing the benefits of creating an account. See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 23e48ca429..21025fd060 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -447,6 +447,7 @@ $wgMessageStructure = array( 'yourname', 'userlogin-yourname', 'userlogin-yourname-ph', + 'createacct-another-username-ph', 'createacct-helpusername', 'yourpassword', 'userlogin-yourpassword', @@ -483,9 +484,11 @@ $wgMessageStructure = array( 'helplogin-url', 'userlogin-helplink', 'createacct-join', + 'createacct-another-join', 'createacct-emailrequired', 'createacct-emailoptional', 'createacct-email-ph', + 'createacct-another-email-ph', 'createaccountmail', 'createacct-realname', 'createaccountreason', @@ -495,6 +498,7 @@ $wgMessageStructure = array( 'createacct-imgcaptcha-help', 'createacct-imgcaptcha-ph', 'createacct-submit', + 'createacct-another-submit', 'createacct-benefit-heading', 'createacct-benefit-icon1', 'createacct-benefit-head1', diff --git a/resources/mediawiki.special/mediawiki.special.createAccount.js b/resources/mediawiki.special/mediawiki.special.createAccount.js index 2cd562584e..f67615b75a 100644 --- a/resources/mediawiki.special/mediawiki.special.createAccount.js +++ b/resources/mediawiki.special/mediawiki.special.createAccount.js @@ -10,15 +10,20 @@ var $emailLabel = $( 'label[for="wpEmail"]' ), originalText = $emailLabel.text(), requiredText = mw.message( 'createacct-emailrequired' ).text(), - $createByMailCheckbox = $( '#wpCreateaccountMail' ); + $createByMailCheckbox = $( '#wpCreateaccountMail' ), + $beforePwds = $( '.mw-row-password:first' ).prev(), + $pwds; function updateForCheckbox() { var checked = $createByMailCheckbox.prop( 'checked' ); if ( checked ) { - $( '.mw-row-password' ).hide(); + $pwds = $( '.mw-row-password' ).detach(); $emailLabel.text( requiredText ); } else { - $( '.mw-row-password' ).show(); + if ( $pwds ) { + $beforePwds.after( $pwds ); + $pwds = null; + } $emailLabel.text( originalText ); } }