Per request, I've added code to disable setting the real name field on login
authorEvan Prodromou <evanprodromou@users.mediawiki.org>
Sat, 29 May 2004 17:32:49 +0000 (17:32 +0000)
committerEvan Prodromou <evanprodromou@users.mediawiki.org>
Sat, 29 May 2004 17:32:49 +0000 (17:32 +0000)
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
includes/SpecialPreferences.php
includes/SpecialUserlogin.php

index 52eb0b1..b72f52c 100644 (file)
@@ -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();
 ?>
index 11696a0..010c15c 100644 (file)
@@ -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( "<fieldset>
-               <legend>".wfMsg('prefs-personal')."</legend>
-               <div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>
+               <legend>".wfMsg('prefs-personal')."</legend>");
+               if ($wgAllowRealName) {
+                   $wgOut->addHTML("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
+               }
+               $wgOut->addHTML("
                <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>\n" );
-       
+
                # Fields for changing password
                #
                $this->mOldpass = wfEscapeHTML( $this->mOldpass );
index c950ed5..e68f66e 100644 (file)
@@ -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 {
        <td align='right'>$ye:</td>
        <td align='left'>
        <input tabindex='6' type='text' name=\"wpEmail\" value=\"{$encEmail}\" size='20' />
-       </td>
-        <td>&nbsp;</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'>
+       </td>");
+                   
+       if ($wgAllowRealName) {
+           $wgOut->addHTML("<td>&nbsp;</td>
+                             </tr><tr>
+                            <td align='right'>$yrn:</td>
+                            <td align='left'>
+                             <input tabindex='6' type='text' name=\"wpRealName\" value=\"{$encRealName}\" size='20' />
+                             </td>");
+       }
+                   
+       $wgOut->addHTML("<td align='left'>
        <input tabindex='7' type='submit' name=\"wpCreateaccount\" value=\"{$ca}\" />
        $cambutton
        </td></tr>");
                }
-
+           
                $wgOut->addHTML("
        <tr><td colspan='3'>&nbsp;</td></tr><tr>
        <td colspan='3' align='left'>