r49953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49952‎ | r49953 | r49954 >
Date:14:07, 27 April 2009
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Merge email back into user profile, fix regression where you weren't warned that your email address required authentication.
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPreferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialPreferences.php
@@ -35,8 +35,14 @@
3636 'savedprefs'
3737 );
3838 }
 39+
 40+ if ( $wgRequest->getCheck( 'eauth' ) ) {
 41+ $wgOut->wrapWikiMsg( "<div class='error' style='clear: both;'>$1</div>",
 42+ 'eauthentsent', $wgUser->getName() );
 43+ }
3944
4045 $htmlForm = Preferences::getFormObject( $wgUser );
 46+ $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
4147
4248 $htmlForm->show();
4349 }
Index: trunk/phase3/includes/Preferences.php
@@ -16,7 +16,6 @@
1717 $defaultPreferences = array();
1818
1919 self::profilePreferences( $user, $defaultPreferences );
20 - self::emailPreferences( $user, $defaultPreferences );
2120 self::skinPreferences( $user, $defaultPreferences );
2221 self::mathPreferences( $user, $defaultPreferences );
2322 self::filesPreferences( $user, $defaultPreferences );
@@ -150,21 +149,7 @@
151150 'help-message' => 'prefs-help-realname',
152151 );
153152 }
154 -
155 - global $wgEmailConfirmToEdit;
156153
157 - $defaultPreferences['emailaddress'] =
158 - array(
159 - 'type' => 'text',
160 - 'default' => $user->getEmail(),
161 - 'section' => 'personal',
162 - 'label-message' => 'youremail',
163 - 'help-message' => $wgEmailConfirmToEdit
164 - ? 'prefs-help-email-required'
165 - : 'prefs-help-email',
166 - 'validation-callback' => array( 'Preferences', 'validateEmail' ),
167 - );
168 -
169154 global $wgAuth;
170155 if ($wgAuth->allowPasswordChange()) {
171156 global $wgUser; // For skin.
@@ -281,13 +266,23 @@
282267 'label-message' => 'tog-rememberpassword',
283268 'section' => 'personal',
284269 );
285 - }
286 -
287 - static function emailPreferences( $user, &$defaultPreferences ) {
288 - global $wgLang;
 270+
 271+ ## Email stuff
289272
290 - ## Email #######################################
291 - ## Email stuff
 273+ global $wgEmailConfirmToEdit;
 274+
 275+ $defaultPreferences['emailaddress'] =
 276+ array(
 277+ 'type' => 'text',
 278+ 'default' => $user->getEmail(),
 279+ 'section' => 'personal',
 280+ 'label-message' => 'youremail',
 281+ 'help-message' => $wgEmailConfirmToEdit
 282+ ? 'prefs-help-email-required'
 283+ : 'prefs-help-email',
 284+ 'validation-callback' => array( 'Preferences', 'validateEmail' ),
 285+ );
 286+
292287 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
293288
294289 if ( $wgEmailAuthentication ) {
@@ -317,7 +312,7 @@
318313 array(
319314 'type' => 'info',
320315 'raw' => true,
321 - 'section' => 'email',
 316+ 'section' => 'personal',
322317 'label-message' => 'prefs-emailconfirm-label',
323318 'default' => $emailauthenticated,
324319 );
@@ -330,13 +325,13 @@
331326 array(
332327 'type' => 'toggle',
333328 'invert' => true,
334 - 'section' => 'email',
 329+ 'section' => 'personal',
335330 'label-message' => 'allowemail',
336331 );
337332 $defaultPreferences['ccmeonemails'] =
338333 array(
339334 'type' => 'toggle',
340 - 'section' => 'email',
 335+ 'section' => 'personal',
341336 'label-message' => 'tog-ccmeonemails',
342337 );
343338 }
@@ -344,25 +339,25 @@
345340 $defaultPreferences['enotifwatchlistpages'] =
346341 array(
347342 'type' => 'toggle',
348 - 'section' => 'email',
 343+ 'section' => 'personal',
349344 'label-message' => 'tog-enotifwatchlistpages',
350345 );
351346 $defaultPreferences['enotifusertalkpages'] =
352347 array(
353348 'type' => 'toggle',
354 - 'section' => 'email',
 349+ 'section' => 'personal',
355350 'label-message' => 'tog-enotifusertalkpages',
356351 );
357352 $defaultPreferences['enotifminoredits'] =
358353 array(
359354 'type' => 'toggle',
360 - 'section' => 'email',
 355+ 'section' => 'personal',
361356 'label-message' => 'tog-enotifminoredits',
362357 );
363358 $defaultPreferences['enotifrevealaddr'] =
364359 array(
365360 'type' => 'toggle',
366 - 'section' => 'email',
 361+ 'section' => 'personal',
367362 'label-message' => 'tog-enotifrevealaddr'
368363 );
369364 }
@@ -1096,9 +1091,11 @@
10971092 }
10981093 }
10991094
1100 - static function tryFormSubmit( $formData ) {
 1095+ static function tryFormSubmit( $formData, $entryPoint = 'internal' ) {
11011096 global $wgUser, $wgEmailAuthentication, $wgEnableEmail;
11021097
 1098+ $result = true;
 1099+
11031100 // Filter input
11041101 foreach( array_keys($formData) as $name ) {
11051102 if ( isset(self::$saveFilters[$name]) ) {
@@ -1128,9 +1125,8 @@
11291126 $result = $wgUser->sendConfirmationMail();
11301127 if( WikiError::isError( $result ) ) {
11311128 return wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
1132 - } else {
1133 - // TODO return this somehow
1134 -# wfMsg( 'eauthentsent', $wgUser->getName() );
 1129+ } elseif ($entryPoint == 'ui') {
 1130+ $result = 'eauth';
11351131 }
11361132 }
11371133 } else {
@@ -1161,10 +1157,24 @@
11621158
11631159 $wgUser->saveSettings();
11641160
1165 - // Done
1166 - global $wgOut;
1167 - $wgOut->redirect( SpecialPage::getTitleFor( 'Preferences' )->getFullURL( 'success' ) );
 1161+ return $result;
 1162+ }
 1163+
 1164+ public static function tryUISubmit( $formData ) {
 1165+ $res = self::tryFormSubmit( $formData, 'ui' );
11681166
 1167+ if ($res) {
 1168+ $urlOptions = array( 'success' );
 1169+ if ($res)
 1170+ $urlOptions[] = 'eauth';
 1171+
 1172+ $queryString = implode( '&', $urlOptions );
 1173+
 1174+ $url = SpecialPage::getTitleFor( 'Preferences' )->getFullURL( $queryString );
 1175+ global $wgOut;
 1176+ $wgOut->redirect( $url );
 1177+ }
 1178+
11691179 return true;
11701180 }
11711181

Comments

#Comment by Brion VIBBER (talk | contribs)   17:49, 27 April 2009

Some remaining issues here...

  • We've lost visual distinctions such as framesets and subsection headings; some of the prefs pages feel very crowded now, and unrelated items sit next to each other such as 'remember my login' in the signature section
  • Should not show "A confirmation e-mail has been sent to the nominated e-mail address." when I've *cleared* the email field :)
  • Email pref boxes should be grayed out while there's not a confirmed email.
#Comment by Werdna (talk | contribs)   02:36, 28 April 2009

Should all be fixed now.

#Comment by Tim Starling (talk | contribs)   07:44, 22 May 2009

Don't mark your own changes as resolved, just give a link to the revision where you fixed it.

Status & tagging log