to add this field.
User.php stores and fetches the field, and has accessors for it.
User login allows setting the field on account creation.
The Preferences page allows changing the real name.
The labels are available for the real name, and the explanation of the email
field on login has been expanded to include an explanation of the real name
field, too.
Update script checks for the field, and adds it if it's missing.
var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
- var $mReset, $mPosted, $mToggles, $mSearchNs;
+ var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName;
function PreferencesForm( &$request ) {
global $wgLang;
$this->mMath = $request->getVal( 'wpMath' );
$this->mDate = $request->getVal( 'wpDate' );
$this->mUserEmail = $request->getVal( 'wpUserEmail' );
+ $this->mRealName = $request->getVal( 'wpRealName' );
$this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
$this->mNick = $request->getVal( 'wpNick' );
$this->mSearch = $request->getVal( 'wpSearch' );
$wgUser->setPassword( $this->mNewpass );
}
$wgUser->setEmail( $this->mUserEmail );
+ $wgUser->setRealName( $this->mRealName );
$wgUser->setOption( "nickname", $this->mNick );
$wgUser->setOption( "quickbar", $this->mQuickbar );
$wgUser->setOption( "skin", $this->mSkin );
$this->mOldpass = $this->mNewpass = $this->mRetypePass = "";
$this->mUserEmail = $wgUser->getEmail();
+ $this->mRealName = $wgUser->getRealName();
if ( 1 == $wgUser->getOption( "disablemail" ) ) { $this->mEmailFlag = 1; }
else { $this->mEmailFlag = 0; }
$this->mNick = $wgUser->getOption( "nickname" );
$tzGuess = wfMsg( "guesstimezone" );
$tzServerTime = wfMsg( "servertime" );
$yem = wfMsg( "youremail" );
+ $yrn = wfMsg( "yourrealname" );
$emf = wfMsg( "emailflag" );
$ynn = wfMsg( "yournick" );
$stt = wfMsg ( "stubthreshold" ) ;
# Email, etc.
#
$this->mUserEmail = wfEscapeHTML( $this->mUserEmail );
+ $this->mRealName = wfEscapeHTML( $this->mRealName );
$this->mNick = wfEscapeHTML( $this->mNick );
if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
else { $emfc = ""; }
$ps = $this->namespacesCheckboxes();
$wgOut->addHTML( "<fieldset>
+ <div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>
<div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>
<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" /> $emf</label></div>
<div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='12' /></label></div>
$this->mAction = $request->getVal( 'action' );
$this->mRemember = $request->getCheck( 'wpRemember' );
$this->mEmail = $request->getText( 'wpEmail' );
+ $this->mRealName = $request->getText( 'wpRealName' );
# When switching accounts, it sucks to get automatically logged out
if( $this->mReturnto == $wgLang->specialPage( "Userlogout" ) ) {
$u->addToDatabase();
$u->setPassword( $this->mPassword );
$u->setEmail( $this->mEmail );
+ $u->setRealName( $this->mRealName );
+
if ( $this->mRemember ) { $r = 1; }
else { $r = 0; }
$u->setOption( "rememberpassword", $r );
$ca = wfMsg( "createaccount" );
$cam = wfMsg( "createaccountmail" );
$ye = wfMsg( "youremail" );
+ $yrn = wfMsg( "yourrealname" );
$efl = wfMsg( "emailforlost" );
$mmp = wfMsg( "mailmypassword" );
$endText = wfMsg( "loginend" );
$encPassword = wfEscapeHTML( $this->mPassword );
$encRetype = wfEscapeHTML( $this->mRetype );
$encEmail = wfEscapeHTML( $this->mEmail );
+ $encRealName = wfEscapeHTML( $this->mRealName );
if ($wgUser->getID() != 0) {
$cambutton = "<input tabindex='6' type='submit' name=\"wpCreateaccountMail\" value=\"{$cam}\" />";
<tr>
<td align='right'>$ye:</td>
<td align='left'>
- <input tabindex='5' type='text' name=\"wpEmail\" value=\"{$encEmail}\" size='20' />
- </td><td align='left'>
- <input tabindex='6' type='submit' name=\"wpCreateaccount\" value=\"{$ca}\" />
+ <input tabindex='6' type='text' name=\"wpEmail\" value=\"{$encEmail}\" size='20' />
+ </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td align='right'>$yrn:</td>
+ <td align='left'>
+ <input tabindex='6' type='text' name=\"wpRealName\" value=\"{$encRealName}\" size='20' />
+ </td>
+ <td align='left'>
+ <input tabindex='7' type='submit' name=\"wpCreateaccount\" value=\"{$ca}\" />
$cambutton
</td></tr>");
}
/* private */ var $mBlockedby, $mBlockreason;
/* private */ var $mTouched;
/* private */ var $mCookiePassword;
+ /* private */ var $mRealName;
function User()
{
} # the following stuff is for non-anonymous users only
$sql = "SELECT user_name,user_password,user_newpassword,user_email," .
- "user_options,user_rights,user_touched FROM user WHERE user_id=" .
- "{$this->mId}";
+ "user_real_name,user_options,user_rights,user_touched " .
+ " FROM user WHERE user_id=" . $this->mId;
$res = wfQuery( $sql, DB_READ, "User::loadFromDatabase" );
if ( wfNumRows( $res ) > 0 ) {
$s = wfFetchObject( $res );
$this->mName = $s->user_name;
$this->mEmail = $s->user_email;
+ $this->mRealName = $s->user_real_name;
$this->mPassword = $s->user_password;
$this->mNewpassword = $s->user_newpassword;
$this->decodeOptions( $s->user_options );
$this->mEmail = $str;
}
+ function getRealName()
+ {
+ $this->loadFromDatabase();
+ return $this->mRealName;
+ }
+
+ function setRealName( $str )
+ {
+ $this->loadFromDatabase();
+ $this->mRealName = $str;
+ }
+
function getOption( $oname )
{
$this->loadFromDatabase();
"user_name= '" . wfStrencode( $this->mName ) . "', " .
"user_password= '" . wfStrencode( $this->mPassword ) . "', " .
"user_newpassword= '" . wfStrencode( $this->mNewpassword ) . "', " .
+ "user_real_name= '" . wfStrencode( $this->mRealName ) . "', " .
"user_email= '" . wfStrencode( $this->mEmail ) . "', " .
"user_options= '" . $this->encodeOptions() . "', " .
"user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', " .
function addToDatabase()
{
$sql = "INSERT INTO user (user_name,user_password,user_newpassword," .
- "user_email, user_rights, user_options) " .
+ "user_email, user_real_name, user_rights, user_options) " .
" VALUES ('" . wfStrencode( $this->mName ) . "', '" .
wfStrencode( $this->mPassword ) . "', '" .
wfStrencode( $this->mNewpassword ) . "', '" .
wfStrencode( $this->mEmail ) . "', '" .
+ wfStrencode( $this->mRealName ) . "', '" .
wfStrencode( implode( ",", $this->mRights ) ) . "', '" .
$this->encodeOptions() . "')";
wfQuery( $sql, DB_WRITE, "User::addToDatabase" );
"badretype" => "The passwords you entered do not match.",
"userexists" => "The user name you entered is already in use. Please choose a different name.",
"youremail" => "Your email*",
+"yourrealname" => "Your real name*",
"yournick" => "Your nickname (for signatures)",
-"emailforlost" => "* Entering an email address is optional. But it enables people to
-contact you through the website without you having to reveal your
-email address to them, and it also helps you if you forget your
-password.",
+"emailforlost" => "Fields marked with a star (*) are optional. Storing an email address enables people to contact you through the website without you having to reveal your
+email address to them, and it can be used to send you a new password if you forget it.<br /><br />Your real name, if you choose to provide it, will be used for giving you attribution for your work.",
"loginerror" => "Login error",
"nocookiesnew" => "The user account was created, but you are not logged in. {{SITENAME}} uses cookies to log in users. You have cookies disabled. Please enable them, then log in with your new username and password.",
"nocookieslogin" => "{{SITENAME}} uses cookies to log in users. You have cookies disabled. Please enable them and try again.",
--- /dev/null
+-- Add a 'real name' field where users can specify the name they want
+-- used for author attribution or other places that real names matter.
+
+ALTER TABLE user
+ ADD (user_real_name varchar(255) binary NOT NULL default '');
\ No newline at end of file
CREATE TABLE user (
user_id int(5) unsigned NOT NULL auto_increment,
user_name varchar(255) binary NOT NULL default '',
+ user_real_name varchar(255) binary NOT NULL default '',
user_rights tinyblob NOT NULL default '',
user_password tinyblob NOT NULL default '',
user_newpassword tinyblob NOT NULL default '',
}
}
+function do_user_real_name_update() {
+ global $wgDatabase;
+ if ( $wgDatabase->fieldExists( "user", "user_real_name" ) ) {
+ echo "...have user_real_name field in user table.\n";
+ } else {
+ echo "Adding user_real_name field to table user...";
+ dbsource( "maintenance/archives/patch-user-realname.sql" , $wgDatabase );
+ echo "ok\n";
+ }
+}
+
?>
\ No newline at end of file
do_linkscc_update();
do_hitcounter_update();
do_recentchanges_update();
+do_user_real_name_update();
initialiseMessages();