Index: trunk/phase3/includes/specials/SpecialPreferences.php |
— | — | @@ -35,8 +35,14 @@ |
36 | 36 | 'savedprefs' |
37 | 37 | ); |
38 | 38 | } |
| 39 | + |
| 40 | + if ( $wgRequest->getCheck( 'eauth' ) ) { |
| 41 | + $wgOut->wrapWikiMsg( "<div class='error' style='clear: both;'>$1</div>", |
| 42 | + 'eauthentsent', $wgUser->getName() ); |
| 43 | + } |
39 | 44 | |
40 | 45 | $htmlForm = Preferences::getFormObject( $wgUser ); |
| 46 | + $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) ); |
41 | 47 | |
42 | 48 | $htmlForm->show(); |
43 | 49 | } |
Index: trunk/phase3/includes/Preferences.php |
— | — | @@ -16,7 +16,6 @@ |
17 | 17 | $defaultPreferences = array(); |
18 | 18 | |
19 | 19 | self::profilePreferences( $user, $defaultPreferences ); |
20 | | - self::emailPreferences( $user, $defaultPreferences ); |
21 | 20 | self::skinPreferences( $user, $defaultPreferences ); |
22 | 21 | self::mathPreferences( $user, $defaultPreferences ); |
23 | 22 | self::filesPreferences( $user, $defaultPreferences ); |
— | — | @@ -150,21 +149,7 @@ |
151 | 150 | 'help-message' => 'prefs-help-realname', |
152 | 151 | ); |
153 | 152 | } |
154 | | - |
155 | | - global $wgEmailConfirmToEdit; |
156 | 153 | |
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 | | - |
169 | 154 | global $wgAuth; |
170 | 155 | if ($wgAuth->allowPasswordChange()) { |
171 | 156 | global $wgUser; // For skin. |
— | — | @@ -281,13 +266,23 @@ |
282 | 267 | 'label-message' => 'tog-rememberpassword', |
283 | 268 | 'section' => 'personal', |
284 | 269 | ); |
285 | | - } |
286 | | - |
287 | | - static function emailPreferences( $user, &$defaultPreferences ) { |
288 | | - global $wgLang; |
| 270 | + |
| 271 | + ## Email stuff |
289 | 272 | |
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 | + |
292 | 287 | global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication; |
293 | 288 | |
294 | 289 | if ( $wgEmailAuthentication ) { |
— | — | @@ -317,7 +312,7 @@ |
318 | 313 | array( |
319 | 314 | 'type' => 'info', |
320 | 315 | 'raw' => true, |
321 | | - 'section' => 'email', |
| 316 | + 'section' => 'personal', |
322 | 317 | 'label-message' => 'prefs-emailconfirm-label', |
323 | 318 | 'default' => $emailauthenticated, |
324 | 319 | ); |
— | — | @@ -330,13 +325,13 @@ |
331 | 326 | array( |
332 | 327 | 'type' => 'toggle', |
333 | 328 | 'invert' => true, |
334 | | - 'section' => 'email', |
| 329 | + 'section' => 'personal', |
335 | 330 | 'label-message' => 'allowemail', |
336 | 331 | ); |
337 | 332 | $defaultPreferences['ccmeonemails'] = |
338 | 333 | array( |
339 | 334 | 'type' => 'toggle', |
340 | | - 'section' => 'email', |
| 335 | + 'section' => 'personal', |
341 | 336 | 'label-message' => 'tog-ccmeonemails', |
342 | 337 | ); |
343 | 338 | } |
— | — | @@ -344,25 +339,25 @@ |
345 | 340 | $defaultPreferences['enotifwatchlistpages'] = |
346 | 341 | array( |
347 | 342 | 'type' => 'toggle', |
348 | | - 'section' => 'email', |
| 343 | + 'section' => 'personal', |
349 | 344 | 'label-message' => 'tog-enotifwatchlistpages', |
350 | 345 | ); |
351 | 346 | $defaultPreferences['enotifusertalkpages'] = |
352 | 347 | array( |
353 | 348 | 'type' => 'toggle', |
354 | | - 'section' => 'email', |
| 349 | + 'section' => 'personal', |
355 | 350 | 'label-message' => 'tog-enotifusertalkpages', |
356 | 351 | ); |
357 | 352 | $defaultPreferences['enotifminoredits'] = |
358 | 353 | array( |
359 | 354 | 'type' => 'toggle', |
360 | | - 'section' => 'email', |
| 355 | + 'section' => 'personal', |
361 | 356 | 'label-message' => 'tog-enotifminoredits', |
362 | 357 | ); |
363 | 358 | $defaultPreferences['enotifrevealaddr'] = |
364 | 359 | array( |
365 | 360 | 'type' => 'toggle', |
366 | | - 'section' => 'email', |
| 361 | + 'section' => 'personal', |
367 | 362 | 'label-message' => 'tog-enotifrevealaddr' |
368 | 363 | ); |
369 | 364 | } |
— | — | @@ -1096,9 +1091,11 @@ |
1097 | 1092 | } |
1098 | 1093 | } |
1099 | 1094 | |
1100 | | - static function tryFormSubmit( $formData ) { |
| 1095 | + static function tryFormSubmit( $formData, $entryPoint = 'internal' ) { |
1101 | 1096 | global $wgUser, $wgEmailAuthentication, $wgEnableEmail; |
1102 | 1097 | |
| 1098 | + $result = true; |
| 1099 | + |
1103 | 1100 | // Filter input |
1104 | 1101 | foreach( array_keys($formData) as $name ) { |
1105 | 1102 | if ( isset(self::$saveFilters[$name]) ) { |
— | — | @@ -1128,9 +1125,8 @@ |
1129 | 1126 | $result = $wgUser->sendConfirmationMail(); |
1130 | 1127 | if( WikiError::isError( $result ) ) { |
1131 | 1128 | 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'; |
1135 | 1131 | } |
1136 | 1132 | } |
1137 | 1133 | } else { |
— | — | @@ -1161,10 +1157,24 @@ |
1162 | 1158 | |
1163 | 1159 | $wgUser->saveSettings(); |
1164 | 1160 | |
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' ); |
1168 | 1166 | |
| 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 | + |
1169 | 1179 | return true; |
1170 | 1180 | } |
1171 | 1181 | |