r3746 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r3745‎ | r3746 | r3747 >
Date:17:32, 29 May 2004
Author:evanprodromou
Status:old
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/includes/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPreferences.php
@@ -14,7 +14,7 @@
1515 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName;
1616
1717 function PreferencesForm( &$request ) {
18 - global $wgLang;
 18+ global $wgLang, $wgAllowRealName;
1919
2020 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
2121 $this->mOldpass = $request->getVal( 'wpOldpass' );
@@ -27,7 +27,7 @@
2828 $this->mMath = $request->getVal( 'wpMath' );
2929 $this->mDate = $request->getVal( 'wpDate' );
3030 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
31 - $this->mRealName = $request->getVal( 'wpRealName' );
 31+ $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : '';
3232 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
3333 $this->mNick = $request->getVal( 'wpNick' );
3434 $this->mSearch = $request->getVal( 'wpSearch' );
@@ -180,11 +180,11 @@
181181
182182 /* private */ function resetPrefs()
183183 {
184 - global $wgUser, $wgLang;
 184+ global $wgUser, $wgLang, $wgAllowRealName;
185185
186186 $this->mOldpass = $this->mNewpass = $this->mRetypePass = "";
187187 $this->mUserEmail = $wgUser->getEmail();
188 - $this->mRealName = $wgUser->getRealName();
 188+ $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
189189 if ( 1 == $wgUser->getOption( "disablemail" ) ) { $this->mEmailFlag = 1; }
190190 else { $this->mEmailFlag = 0; }
191191 $this->mNick = $wgUser->getOption( "nickname" );
@@ -265,7 +265,8 @@
266266 /* private */ function mainPrefsForm( $err )
267267 {
268268 global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates, $wgValidSkinNames;
269 -
 269+ global $wgAllowRealName;
 270+
270271 $wgOut->setPageTitle( wfMsg( "preferences" ) );
271272 $wgOut->setArticleRelated( false );
272273 $wgOut->setRobotpolicy( "noindex,nofollow" );
@@ -306,7 +307,7 @@
307308 $tzGuess = wfMsg( "guesstimezone" );
308309 $tzServerTime = wfMsg( "servertime" );
309310 $yem = wfMsg( "youremail" );
310 - $yrn = wfMsg( "yourrealname" );
 311+ $yrn = ($wgAllowRealName) ? wfMsg( "yourrealname" ) : '';
311312 $emf = wfMsg( "emailflag" );
312313 $ynn = wfMsg( "yournick" );
313314 $stt = wfMsg ( "stubthreshold" ) ;
@@ -332,12 +333,15 @@
333334 $ps = $this->namespacesCheckboxes();
334335
335336 $wgOut->addHTML( "<fieldset>
336 - <legend>".wfMsg('prefs-personal')."</legend>
337 - <div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>
 337+ <legend>".wfMsg('prefs-personal')."</legend>");
 338+ if ($wgAllowRealName) {
 339+ $wgOut->addHTML("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
 340+ }
 341+ $wgOut->addHTML("
338342 <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>
339343 <div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" /> $emf</label></div>
340344 <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='12' /></label></div>\n" );
341 -
 345+
342346 # Fields for changing password
343347 #
344348 $this->mOldpass = wfEscapeHTML( $this->mOldpass );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -390,6 +390,10 @@
391391 # See list of skins and their symbolic names in language/Language.php
392392 $wgDefaultSkin = "monobook";
393393
 394+# Whether or not to allow real name fields. Defaults to true.
 395+
 396+$wgAllowRealName = true;
 397+
394398 # Extensions
395399 $wgExtensionFunctions = array();
396400 ?>
Index: trunk/phase3/includes/SpecialUserlogin.php
@@ -20,7 +20,7 @@
2121 var $mLoginattempt, $mRemember, $mEmail;
2222
2323 function LoginForm( &$request ) {
24 - global $wgLang;
 24+ global $wgLang, $wgAllowRealName;
2525
2626 $this->mName = $request->getText( 'wpName' );
2727 $this->mPassword = $request->getText( 'wpPassword' );
@@ -35,8 +35,12 @@
3636 $this->mAction = $request->getVal( 'action' );
3737 $this->mRemember = $request->getCheck( 'wpRemember' );
3838 $this->mEmail = $request->getText( 'wpEmail' );
39 - $this->mRealName = $request->getText( 'wpRealName' );
40 -
 39+ if ($wgAllowRealName) {
 40+ $this->mRealName = $request->getText( 'wpRealName' );
 41+ } else {
 42+ $this->mRealName = '';
 43+ }
 44+
4145 # When switching accounts, it sucks to get automatically logged out
4246 if( $this->mReturnto == $wgLang->specialPage( "Userlogout" ) ) {
4347 $this->mReturnto = "";
@@ -301,7 +305,7 @@
302306 /* private */ function mainLoginForm( $err )
303307 {
304308 global $wgUser, $wgOut, $wgLang;
305 - global $wgDBname;
 309+ global $wgDBname, $wgAllowRealName;
306310
307311 $le = wfMsg( "loginerror" );
308312 $yn = wfMsg( "yourname" );
@@ -313,7 +317,11 @@
314318 $ca = wfMsg( "createaccount" );
315319 $cam = wfMsg( "createaccountmail" );
316320 $ye = wfMsg( "youremail" );
317 - $yrn = wfMsg( "yourrealname" );
 321+ if ($wgAllowRealName) {
 322+ $yrn = wfMsg( "yourrealname" );
 323+ } else {
 324+ $yrn = '';
 325+ }
318326 $efl = wfMsg( "emailforlost" );
319327 $mmp = wfMsg( "mailmypassword" );
320328 $endText = wfMsg( "loginend" );
@@ -401,20 +409,23 @@
402410 <td align='right'>$ye:</td>
403411 <td align='left'>
404412 <input tabindex='6' type='text' name=\"wpEmail\" value=\"{$encEmail}\" size='20' />
405 - </td>
406 - <td>&nbsp;</td>
407 - </tr>
408 - <tr>
409 - <td align='right'>$yrn:</td>
410 - <td align='left'>
411 - <input tabindex='6' type='text' name=\"wpRealName\" value=\"{$encRealName}\" size='20' />
412 - </td>
413 - <td align='left'>
 413+ </td>");
 414+
 415+ if ($wgAllowRealName) {
 416+ $wgOut->addHTML("<td>&nbsp;</td>
 417+ </tr><tr>
 418+ <td align='right'>$yrn:</td>
 419+ <td align='left'>
 420+ <input tabindex='6' type='text' name=\"wpRealName\" value=\"{$encRealName}\" size='20' />
 421+ </td>");
 422+ }
 423+
 424+ $wgOut->addHTML("<td align='left'>
414425 <input tabindex='7' type='submit' name=\"wpCreateaccount\" value=\"{$ca}\" />
415426 $cambutton
416427 </td></tr>");
417428 }
418 -
 429+
419430 $wgOut->addHTML("
420431 <tr><td colspan='3'>&nbsp;</td></tr><tr>
421432 <td colspan='3' align='left'>

Status & tagging log