From 940f992a19d7a8e12237c21daac74210ed1a8fef Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 29 May 2004 17:32:49 +0000 Subject: [PATCH] Per request, I've added code to disable setting the real name field on login or in user preferences. The field remains in the database, however, and classes such as User still use it. It's just hidden from the user interface. The configuration variable is $wgAllowRealName, which defaults to TRUE. Admins can set it to false if they need to. It was kind of a chop-shop job, but I'm pretty sure that clever hackers won't be able to force in a real name anywhere. I haven't yet made display of real names in the RDF optional; I figure that's a lower priority. --- includes/DefaultSettings.php | 4 ++++ includes/SpecialPreferences.php | 22 ++++++++++-------- includes/SpecialUserlogin.php | 41 +++++++++++++++++++++------------ 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 52eb0b1ef1..b72f52c73c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -390,6 +390,10 @@ $wgTidyOpts = ''; # See list of skins and their symbolic names in language/Language.php $wgDefaultSkin = "monobook"; +# Whether or not to allow real name fields. Defaults to true. + +$wgAllowRealName = true; + # Extensions $wgExtensionFunctions = array(); ?> diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 11696a02ef..010c15c6d0 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -14,7 +14,7 @@ class PreferencesForm { var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName; function PreferencesForm( &$request ) { - global $wgLang; + global $wgLang, $wgAllowRealName; $this->mQuickbar = $request->getVal( 'wpQuickbar' ); $this->mOldpass = $request->getVal( 'wpOldpass' ); @@ -27,7 +27,7 @@ class PreferencesForm { $this->mMath = $request->getVal( 'wpMath' ); $this->mDate = $request->getVal( 'wpDate' ); $this->mUserEmail = $request->getVal( 'wpUserEmail' ); - $this->mRealName = $request->getVal( 'wpRealName' ); + $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : ''; $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0; $this->mNick = $request->getVal( 'wpNick' ); $this->mSearch = $request->getVal( 'wpSearch' ); @@ -180,11 +180,11 @@ class PreferencesForm { /* private */ function resetPrefs() { - global $wgUser, $wgLang; + global $wgUser, $wgLang, $wgAllowRealName; $this->mOldpass = $this->mNewpass = $this->mRetypePass = ""; $this->mUserEmail = $wgUser->getEmail(); - $this->mRealName = $wgUser->getRealName(); + $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : ''; if ( 1 == $wgUser->getOption( "disablemail" ) ) { $this->mEmailFlag = 1; } else { $this->mEmailFlag = 0; } $this->mNick = $wgUser->getOption( "nickname" ); @@ -265,7 +265,8 @@ class PreferencesForm { /* private */ function mainPrefsForm( $err ) { global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates, $wgValidSkinNames; - + global $wgAllowRealName; + $wgOut->setPageTitle( wfMsg( "preferences" ) ); $wgOut->setArticleRelated( false ); $wgOut->setRobotpolicy( "noindex,nofollow" ); @@ -306,7 +307,7 @@ class PreferencesForm { $tzGuess = wfMsg( "guesstimezone" ); $tzServerTime = wfMsg( "servertime" ); $yem = wfMsg( "youremail" ); - $yrn = wfMsg( "yourrealname" ); + $yrn = ($wgAllowRealName) ? wfMsg( "yourrealname" ) : ''; $emf = wfMsg( "emailflag" ); $ynn = wfMsg( "yournick" ); $stt = wfMsg ( "stubthreshold" ) ; @@ -332,12 +333,15 @@ class PreferencesForm { $ps = $this->namespacesCheckboxes(); $wgOut->addHTML( "
- ".wfMsg('prefs-personal')." -
+ ".wfMsg('prefs-personal').""); + if ($wgAllowRealName) { + $wgOut->addHTML("
"); + } + $wgOut->addHTML("
\n" ); - + # Fields for changing password # $this->mOldpass = wfEscapeHTML( $this->mOldpass ); diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index c950ed5f15..e68f66e2e0 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -20,7 +20,7 @@ class LoginForm { var $mLoginattempt, $mRemember, $mEmail; function LoginForm( &$request ) { - global $wgLang; + global $wgLang, $wgAllowRealName; $this->mName = $request->getText( 'wpName' ); $this->mPassword = $request->getText( 'wpPassword' ); @@ -35,8 +35,12 @@ class LoginForm { $this->mAction = $request->getVal( 'action' ); $this->mRemember = $request->getCheck( 'wpRemember' ); $this->mEmail = $request->getText( 'wpEmail' ); - $this->mRealName = $request->getText( 'wpRealName' ); - + if ($wgAllowRealName) { + $this->mRealName = $request->getText( 'wpRealName' ); + } else { + $this->mRealName = ''; + } + # When switching accounts, it sucks to get automatically logged out if( $this->mReturnto == $wgLang->specialPage( "Userlogout" ) ) { $this->mReturnto = ""; @@ -301,7 +305,7 @@ class LoginForm { /* private */ function mainLoginForm( $err ) { global $wgUser, $wgOut, $wgLang; - global $wgDBname; + global $wgDBname, $wgAllowRealName; $le = wfMsg( "loginerror" ); $yn = wfMsg( "yourname" ); @@ -313,7 +317,11 @@ class LoginForm { $ca = wfMsg( "createaccount" ); $cam = wfMsg( "createaccountmail" ); $ye = wfMsg( "youremail" ); - $yrn = wfMsg( "yourrealname" ); + if ($wgAllowRealName) { + $yrn = wfMsg( "yourrealname" ); + } else { + $yrn = ''; + } $efl = wfMsg( "emailforlost" ); $mmp = wfMsg( "mailmypassword" ); $endText = wfMsg( "loginend" ); @@ -401,20 +409,23 @@ class LoginForm { $ye: - -   - - - $yrn: - - - - + "); + + if ($wgAllowRealName) { + $wgOut->addHTML("  + + $yrn: + + + "); + } + + $wgOut->addHTML(" $cambutton "); } - + $wgOut->addHTML("   -- 2.20.1