* (bug 21503) There's now a "reason" field when creating account for other users
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 1 Aug 2010 10:42:53 +0000 (10:42 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 1 Aug 2010 10:42:53 +0000 (10:42 +0000)
RELEASE-NOTES
includes/User.php
includes/specials/SpecialUserlogin.php
includes/templates/Userlogin.php
languages/messages/MessagesEn.php

index c450da7..33ee8da 100644 (file)
@@ -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 <dfn> 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
index ad10fea..9c2a078 100644 (file)
@@ -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;
index 4c38583..f051110 100644 (file)
@@ -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' ) {
index c6a8ced..a36fa2c 100644 (file)
@@ -243,6 +243,16 @@ class UsercreateTemplate extends QuickTemplate {
                                                </div>
                                        </td>
                        <?php } ?>
+                       <?php if( $this->data['usereason'] ) { ?>
+                               </tr>
+                               <tr>
+                                       <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"
+                                                       value="<?php $this->text('reason') ?>" size='20' />
+                                       </td>
+                       <?php } ?>
                </tr>
                <?php if( $this->data['canremember'] ) { ?>
                <tr>
@@ -255,14 +265,14 @@ class UsercreateTemplate extends QuickTemplate {
                                        'wpRemember',
                                        'wpRemember',
                                        $this->data['remember'],
-                                       array( 'tabindex' => '7' )
+                                       array( 'tabindex' => '8' )
                                )
                                ?>
                        </td>
                </tr>
 <?php   }
 
-               $tabIndex = 8;
+               $tabIndex = 9;
                if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
                        foreach ( $this->data['extraInput'] as $inputItem ) { ?>
                <tr>
index c18ff51..b458d3a 100644 (file)
@@ -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.',