From 5170726319b88244ef3c530a75189a4b4cea4895 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 1 Aug 2010 10:42:53 +0000 Subject: [PATCH] * (bug 21503) There's now a "reason" field when creating account for other users --- RELEASE-NOTES | 1 + includes/User.php | 20 +++++++++++++------- includes/specials/SpecialUserlogin.php | 7 +++++-- includes/templates/Userlogin.php | 14 ++++++++++++-- languages/messages/MessagesEn.php | 1 + 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c450da7a91..33ee8da527 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -121,6 +121,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Non-file pages can no longer be moved to the file namespace, nor vice versa. * (bug 671) The element has been whitelisted in user input. * (bug 24563) Entries on Special:WhatLinksHere now have a link to their history +* (bug 21503) There's now a "reason" field when creating account for other users === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive diff --git a/includes/User.php b/includes/User.php index ad10fea272..9c2a078fa2 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3571,28 +3571,34 @@ class User { /** * Add a newuser log entry for this user + * * @param $byEmail Boolean: account made by email? + * @param $reason String: user supplied reason */ - public function addNewUserLogEntry( $byEmail = false ) { - global $wgUser, $wgNewUserLog; + public function addNewUserLogEntry( $byEmail = false, $reason = '' ) { + global $wgUser, $wgContLang, $wgNewUserLog; if( empty( $wgNewUserLog ) ) { return true; // disabled } if( $this->getName() == $wgUser->getName() ) { $action = 'create'; - $message = ''; } else { $action = 'create2'; - $message = $byEmail - ? wfMsgForContent( 'newuserlog-byemail' ) - : ''; + if ( $byEmail ) { + if ( $reason === '' ) { + $reason = wfMsgForContent( 'newuserlog-byemail' ); + } else { + $reason = $wgContLang->commaList( array( + $reason, wfMsgForContent( 'newuserlog-byemail' ) ) ); + } + } } $log = new LogPage( 'newusers' ); $log->addEntry( $action, $this->getUserPage(), - $message, + $reason, array( $this->getId() ) ); return true; diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 4c38583f97..f051110a92 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -76,6 +76,7 @@ class LoginForm { $this->mPassword = $request->getText( 'wpPassword' ); $this->mRetype = $request->getText( 'wpRetype' ); $this->mDomain = $request->getText( 'wpDomain' ); + $this->mReason = $request->getText( 'wpReason' ); $this->mReturnTo = $request->getVal( 'returnto' ); $this->mReturnToQuery = $request->getVal( 'returntoquery' ); $this->mCookieCheck = $request->getVal( 'wpCookieCheck' ); @@ -162,7 +163,7 @@ class LoginForm { $result = $this->mailPasswordInternal( $u, false, 'createaccount-title', 'createaccount-text' ); wfRunHooks( 'AddNewAccount', array( $u, true ) ); - $u->addNewUserLogEntry(); + $u->addNewUserLogEntry( true, $this->mReason ); $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); @@ -230,7 +231,7 @@ class LoginForm { $wgOut->addHTML( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) ); $wgOut->returnToMain( false, $self ); wfRunHooks( 'AddNewAccount', array( $u, false ) ); - $u->addNewUserLogEntry(); + $u->addNewUserLogEntry( false, $this->mReason ); return true; } } @@ -1008,6 +1009,7 @@ class LoginForm { $template->set( 'email', $this->mEmail ); $template->set( 'realname', $this->mRealName ); $template->set( 'domain', $this->mDomain ); + $template->set( 'reason', $this->mReason ); $template->set( 'action', $titleObj->getLocalUrl( $q ) ); $template->set( 'message', $msg ); @@ -1018,6 +1020,7 @@ class LoginForm { $template->set( 'emailrequired', $wgEmailConfirmToEdit ); $template->set( 'canreset', $wgAuth->allowPasswordChange() ); $template->set( 'canremember', ( $wgCookieExpiration > 0 ) ); + $template->set( 'usereason', $wgUser->isLoggedIn() ); $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember ); if ( $this->mType == 'signup' ) { diff --git a/includes/templates/Userlogin.php b/includes/templates/Userlogin.php index c6a8ced41c..a36fa2c533 100644 --- a/includes/templates/Userlogin.php +++ b/includes/templates/Userlogin.php @@ -243,6 +243,16 @@ class UsercreateTemplate extends QuickTemplate { + data['usereason'] ) { ?> + + + + + + + data['canremember'] ) { ?> @@ -255,14 +265,14 @@ class UsercreateTemplate extends QuickTemplate { 'wpRemember', 'wpRemember', $this->data['remember'], - array( 'tabindex' => '7' ) + array( 'tabindex' => '8' ) ) ?> data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) { foreach ( $this->data['extraInput'] as $inputItem ) { ?> diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index c18ff516b8..b458d3ab04 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1063,6 +1063,7 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].', 'gotaccount' => 'Already have an account? $1.', 'gotaccountlink' => 'Log in', 'createaccountmail' => 'By e-mail', +'createaccountreason' => 'Reason:', 'badretype' => 'The passwords you entered do not match.', 'userexists' => 'Username entered already in use. Please choose a different name.', -- 2.20.1