Index: trunk/phase3/includes/specials/SpecialChangePassword.php |
— | — | @@ -91,6 +91,7 @@ |
92 | 92 | $data['wpRemember'] = 1; |
93 | 93 | } |
94 | 94 | $login = new LoginForm( new FauxRequest( $data, true ) ); |
| 95 | + $login->setContext( $this->getContext() ); |
95 | 96 | $login->execute( null ); |
96 | 97 | } |
97 | 98 | $this->doReturnTo(); |
Index: trunk/phase3/includes/specials/SpecialUserlogin.php |
— | — | @@ -56,17 +56,17 @@ |
57 | 57 | private $mExtUser = null; |
58 | 58 | |
59 | 59 | /** |
| 60 | + * @ var WebRequest |
| 61 | + */ |
| 62 | + private $mOverrideRequest = null; |
| 63 | + |
| 64 | + /** |
60 | 65 | * @param WebRequest $request |
61 | 66 | */ |
62 | 67 | public function __construct( $request = null ) { |
63 | 68 | parent::__construct( 'Userlogin' ); |
64 | 69 | |
65 | | - if ( $request === null ) { |
66 | | - global $wgRequest; |
67 | | - $this->load( $wgRequest ); |
68 | | - } else { |
69 | | - $this->load( $request ); |
70 | | - } |
| 70 | + $this->mOverrideRequest = $request; |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
— | — | @@ -132,6 +132,13 @@ |
133 | 133 | wfSetupSession(); |
134 | 134 | } |
135 | 135 | |
| 136 | + if ( $this->mOverrideRequest === null ) { |
| 137 | + $request = $this->getRequest(); |
| 138 | + } else { |
| 139 | + $request = $this->mOverrideRequest; |
| 140 | + } |
| 141 | + $this->load( $request ); |
| 142 | + |
136 | 143 | if ( $par == 'signup' ) { # Check for [[Special:Userlogin/signup]] |
137 | 144 | $this->mType = 'signup'; |
138 | 145 | } |
— | — | @@ -155,10 +162,8 @@ |
156 | 163 | * @private |
157 | 164 | */ |
158 | 165 | function addNewAccountMailPassword() { |
159 | | - global $wgOut; |
160 | | - |
161 | 166 | if ( $this->mEmail == '' ) { |
162 | | - $this->mainLoginForm( wfMsgExt( 'noemailcreate', array( 'parsemag', 'escape' ) ) ); |
| 167 | + $this->mainLoginForm( $this->msg( 'noemailcreate' )->escaped() ); |
163 | 168 | return; |
164 | 169 | } |
165 | 170 | |
— | — | @@ -176,13 +181,14 @@ |
177 | 182 | wfRunHooks( 'AddNewAccount', array( $u, true ) ); |
178 | 183 | $u->addNewUserLogEntry( true, $this->mReason ); |
179 | 184 | |
180 | | - $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) ); |
| 185 | + $out = $this->getOutput(); |
| 186 | + $out->setPageTitle( $this->msg( 'accmailtitle' )->text() ); |
181 | 187 | |
182 | 188 | if( !$result->isGood() ) { |
183 | | - $this->mainLoginForm( wfMsg( 'mailerror', $result->getWikiText() ) ); |
| 189 | + $this->mainLoginForm( $this->msg( 'mailerror', $result->getWikiText() )->text() ); |
184 | 190 | } else { |
185 | | - $wgOut->addWikiMsg( 'accmailtext', $u->getName(), $u->getEmail() ); |
186 | | - $wgOut->returnToMain( false ); |
| 191 | + $out->addWikiMsg( 'accmailtext', $u->getName(), $u->getEmail() ); |
| 192 | + $out->returnToMain( false ); |
187 | 193 | } |
188 | 194 | } |
189 | 195 | |
— | — | @@ -190,7 +196,7 @@ |
191 | 197 | * @private |
192 | 198 | */ |
193 | 199 | function addNewAccount() { |
194 | | - global $wgUser, $wgEmailAuthentication, $wgOut; |
| 200 | + global $wgUser, $wgEmailAuthentication, $wgLoginLanguageSelector; |
195 | 201 | |
196 | 202 | # Create the account and abort if there's a problem doing so |
197 | 203 | $u = $this->addNewAccountInternal(); |
— | — | @@ -200,18 +206,19 @@ |
201 | 207 | |
202 | 208 | # If we showed up language selection links, and one was in use, be |
203 | 209 | # smart (and sensible) and save that language as the user's preference |
204 | | - global $wgLoginLanguageSelector; |
205 | 210 | if( $wgLoginLanguageSelector && $this->mLanguage ) { |
206 | 211 | $u->setOption( 'language', $this->mLanguage ); |
207 | 212 | } |
208 | 213 | |
| 214 | + $out = $this->getOutput(); |
| 215 | + |
209 | 216 | # Send out an email authentication message if needed |
210 | 217 | if( $wgEmailAuthentication && Sanitizer::validateEmail( $u->getEmail() ) ) { |
211 | 218 | $status = $u->sendConfirmationMail(); |
212 | 219 | if( $status->isGood() ) { |
213 | | - $wgOut->addWikiMsg( 'confirmemail_oncreate' ); |
| 220 | + $out->addWikiMsg( 'confirmemail_oncreate' ); |
214 | 221 | } else { |
215 | | - $wgOut->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) ); |
| 222 | + $out->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) ); |
216 | 223 | } |
217 | 224 | } |
218 | 225 | |
— | — | @@ -221,15 +228,15 @@ |
222 | 229 | # If not logged in, assume the new account as the current one and set |
223 | 230 | # session cookies then show a "welcome" message or a "need cookies" |
224 | 231 | # message as needed |
225 | | - if( $wgUser->isAnon() ) { |
| 232 | + if( $this->getUser()->isAnon() ) { |
| 233 | + $u->setCookies(); |
226 | 234 | $wgUser = $u; |
227 | | - $wgUser->setCookies(); |
228 | 235 | // This should set it for OutputPage and the Skin |
229 | 236 | // which is needed or the personal links will be |
230 | 237 | // wrong. |
231 | | - RequestContext::getMain()->setUser( $u ); |
232 | | - wfRunHooks( 'AddNewAccount', array( $wgUser, false ) ); |
233 | | - $wgUser->addNewUserLogEntry(); |
| 238 | + $this->getContext()->setUser( $u ); |
| 239 | + wfRunHooks( 'AddNewAccount', array( $u, false ) ); |
| 240 | + $u->addNewUserLogEntry(); |
234 | 241 | if( $this->hasSessionCookie() ) { |
235 | 242 | return $this->successfulCreation(); |
236 | 243 | } else { |
— | — | @@ -237,10 +244,9 @@ |
238 | 245 | } |
239 | 246 | } else { |
240 | 247 | # Confirm that the account was created |
241 | | - $self = SpecialPage::getTitleFor( 'Userlogin' ); |
242 | | - $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); |
243 | | - $wgOut->addWikiMsg( 'accountcreatedtext', $u->getName() ); |
244 | | - $wgOut->returnToMain( false, $self ); |
| 248 | + $out->setPageTitle( $this->msg( 'accountcreated' )->text() ); |
| 249 | + $out->addWikiMsg( 'accountcreatedtext', $u->getName() ); |
| 250 | + $out->returnToMain( false, $this->getTitle() ); |
245 | 251 | wfRunHooks( 'AddNewAccount', array( $u, false ) ); |
246 | 252 | $u->addNewUserLogEntry( false, $this->mReason ); |
247 | 253 | return true; |
— | — | @@ -251,14 +257,12 @@ |
252 | 258 | * @private |
253 | 259 | */ |
254 | 260 | function addNewAccountInternal() { |
255 | | - global $wgUser, $wgOut, $wgRequest; |
256 | | - global $wgMemc, $wgAccountCreationThrottle; |
257 | | - global $wgAuth, $wgMinimalPasswordLength; |
258 | | - global $wgEmailConfirmToEdit; |
| 261 | + global $wgAuth, $wgMemc, $wgAccountCreationThrottle, |
| 262 | + $wgMinimalPasswordLength, $wgEmailConfirmToEdit; |
259 | 263 | |
260 | 264 | // If the user passes an invalid domain, something is fishy |
261 | 265 | if( !$wgAuth->validDomain( $this->mDomain ) ) { |
262 | | - $this->mainLoginForm( wfMsg( 'wrongpassword' ) ); |
| 266 | + $this->mainLoginForm( $this->msg( 'wrongpassword' )->text() ); |
263 | 267 | return false; |
264 | 268 | } |
265 | 269 | |
— | — | @@ -270,47 +274,46 @@ |
271 | 275 | if( 'local' != $this->mDomain && $this->mDomain != '' ) { |
272 | 276 | if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mUsername ) |
273 | 277 | || !$wgAuth->authenticate( $this->mUsername, $this->mPassword ) ) ) { |
274 | | - $this->mainLoginForm( wfMsg( 'wrongpassword' ) ); |
| 278 | + $this->mainLoginForm( $this->msg( 'wrongpassword' )->text() ); |
275 | 279 | return false; |
276 | 280 | } |
277 | 281 | } |
278 | 282 | |
279 | 283 | if ( wfReadOnly() ) { |
280 | | - $wgOut->readOnlyPage(); |
281 | | - return false; |
| 284 | + throw new ReadOnlyError; |
282 | 285 | } |
283 | 286 | |
284 | 287 | # Request forgery checks. |
285 | 288 | if ( !self::getCreateaccountToken() ) { |
286 | 289 | self::setCreateaccountToken(); |
287 | | - $this->mainLoginForm( wfMsgExt( 'nocookiesfornew', array( 'parseinline' ) ) ); |
| 290 | + $this->mainLoginForm( $this->msg( 'nocookiesfornew' )->parse() ); |
288 | 291 | return false; |
289 | 292 | } |
290 | 293 | |
291 | 294 | # The user didn't pass a createaccount token |
292 | 295 | if ( !$this->mToken ) { |
293 | | - $this->mainLoginForm( wfMsg( 'sessionfailure' ) ); |
| 296 | + $this->mainLoginForm( $this->msg( 'sessionfailure' )->text() ); |
294 | 297 | return false; |
295 | 298 | } |
296 | 299 | |
297 | 300 | # Validate the createaccount token |
298 | 301 | if ( $this->mToken !== self::getCreateaccountToken() ) { |
299 | | - $this->mainLoginForm( wfMsg( 'sessionfailure' ) ); |
| 302 | + $this->mainLoginForm( $this->msg( 'sessionfailure' )->text() ); |
300 | 303 | return false; |
301 | 304 | } |
302 | 305 | |
303 | 306 | # Check permissions |
304 | | - if ( !$wgUser->isAllowed( 'createaccount' ) ) { |
305 | | - $wgOut->permissionRequired( 'createaccount' ); |
| 307 | + $currentUser = $this->getUser(); |
| 308 | + if ( !$currentUser->isAllowed( 'createaccount' ) ) { |
| 309 | + throw new PermissionsError( 'createaccount' ); |
| 310 | + } elseif ( $currentUser->isBlockedFromCreateAccount() ) { |
| 311 | + $this->userBlockedMessage( $currentUser->isBlockedFromCreateAccount() ); |
306 | 312 | return false; |
307 | | - } elseif ( $wgUser->isBlockedFromCreateAccount() ) { |
308 | | - $this->userBlockedMessage( $wgUser->isBlockedFromCreateAccount() ); |
309 | | - return false; |
310 | 313 | } |
311 | 314 | |
312 | | - $ip = $wgRequest->getIP(); |
313 | | - if ( $wgUser->isDnsBlacklisted( $ip, true /* check $wgProxyWhitelist */ ) ) { |
314 | | - $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' ); |
| 315 | + $ip = $this->getRequest()->getIP(); |
| 316 | + if ( $currentUser->isDnsBlacklisted( $ip, true /* check $wgProxyWhitelist */ ) ) { |
| 317 | + $this->mainLoginForm( $this->msg( 'sorbs_create_account_reason' )->text() . ' (' . htmlspecialchars( $ip ) . ')' ); |
315 | 318 | return false; |
316 | 319 | } |
317 | 320 | |
— | — | @@ -318,17 +321,17 @@ |
319 | 322 | $name = trim( $this->mUsername ); |
320 | 323 | $u = User::newFromName( $name, 'creatable' ); |
321 | 324 | if ( !is_object( $u ) ) { |
322 | | - $this->mainLoginForm( wfMsg( 'noname' ) ); |
| 325 | + $this->mainLoginForm( $this->msg( 'noname' )->text() ); |
323 | 326 | return false; |
324 | 327 | } |
325 | 328 | |
326 | 329 | if ( 0 != $u->idForName() ) { |
327 | | - $this->mainLoginForm( wfMsg( 'userexists' ) ); |
| 330 | + $this->mainLoginForm( $this->msg( 'userexists' )->text() ); |
328 | 331 | return false; |
329 | 332 | } |
330 | 333 | |
331 | 334 | if ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) { |
332 | | - $this->mainLoginForm( wfMsg( 'badretype' ) ); |
| 335 | + $this->mainLoginForm( $this->msg( 'badretype' )->text() ); |
333 | 336 | return false; |
334 | 337 | } |
335 | 338 | |
— | — | @@ -343,7 +346,7 @@ |
344 | 347 | $message = $valid; |
345 | 348 | $params = array( $wgMinimalPasswordLength ); |
346 | 349 | } |
347 | | - $this->mainLoginForm( wfMsgExt( $message, array( 'parsemag' ), $params ) ); |
| 350 | + $this->mainLoginForm( $this->msg( $message, $params )->text() ); |
348 | 351 | return false; |
349 | 352 | } else { |
350 | 353 | # do not force a password for account creation by email |
— | — | @@ -355,12 +358,12 @@ |
356 | 359 | # if you need a confirmed email address to edit, then obviously you |
357 | 360 | # need an email address. |
358 | 361 | if ( $wgEmailConfirmToEdit && empty( $this->mEmail ) ) { |
359 | | - $this->mainLoginForm( wfMsg( 'noemailtitle' ) ); |
| 362 | + $this->mainLoginForm( $this->msg( 'noemailtitle' )->text() ); |
360 | 363 | return false; |
361 | 364 | } |
362 | 365 | |
363 | 366 | if( !empty( $this->mEmail ) && !Sanitizer::validateEmail( $this->mEmail ) ) { |
364 | | - $this->mainLoginForm( wfMsg( 'invalidemailaddress' ) ); |
| 367 | + $this->mainLoginForm( $this->msg( 'invalidemailaddress' )->text() ); |
365 | 368 | return false; |
366 | 369 | } |
367 | 370 | |
— | — | @@ -381,7 +384,7 @@ |
382 | 385 | if ( !wfRunHooks( 'exemptFromAccountCreationThrottle', array( $ip ) ) ) { |
383 | 386 | wfDebug( "LoginForm::exemptFromAccountCreationThrottle: a hook allowed account creation w/o throttle\n" ); |
384 | 387 | } else { |
385 | | - if ( ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) ) { |
| 388 | + if ( ( $wgAccountCreationThrottle && $currentUser->isPingLimitable() ) ) { |
386 | 389 | $key = wfMemcKey( 'acctcreate', 'ip', $ip ); |
387 | 390 | $value = $wgMemc->get( $key ); |
388 | 391 | if ( !$value ) { |
— | — | @@ -396,7 +399,7 @@ |
397 | 400 | } |
398 | 401 | |
399 | 402 | if( !$wgAuth->addUser( $u, $this->mPassword, $this->mEmail, $this->mRealName ) ) { |
400 | | - $this->mainLoginForm( wfMsg( 'externaldberror' ) ); |
| 403 | + $this->mainLoginForm( $this->msg( 'externaldberror' )->text() ); |
401 | 404 | return false; |
402 | 405 | } |
403 | 406 | |
— | — | @@ -485,13 +488,13 @@ |
486 | 489 | return self::WRONG_TOKEN; |
487 | 490 | } |
488 | 491 | |
489 | | - // Load $wgUser now, and check to see if we're logging in as the same |
490 | | - // name. This is necessary because loading $wgUser (say by calling |
491 | | - // getName()) calls the UserLoadFromSession hook, which potentially |
492 | | - // creates the user in the database. Until we load $wgUser, checking |
493 | | - // for user existence using User::newFromName($name)->getId() below |
| 492 | + // Load the current user now, and check to see if we're logging in as |
| 493 | + // the same name. This is necessary because loading the current user |
| 494 | + // (say by calling getName()) calls the UserLoadFromSession hook, which |
| 495 | + // potentially creates the user in the database. Until we load $wgUser, |
| 496 | + // checking for user existence using User::newFromName($name)->getId() below |
494 | 497 | // will effectively be using stale data. |
495 | | - if ( $wgUser->getName() === $this->mUsername ) { |
| 498 | + if ( $this->getUser()->getName() === $this->mUsername ) { |
496 | 499 | wfDebug( __METHOD__ . ": already logged in as {$this->mUsername}\n" ); |
497 | 500 | return self::SUCCESS; |
498 | 501 | } |
— | — | @@ -572,7 +575,7 @@ |
573 | 576 | // This should set it for OutputPage and the Skin |
574 | 577 | // which is needed or the personal links will be |
575 | 578 | // wrong. |
576 | | - RequestContext::getMain()->setUser( $u ); |
| 579 | + $this->getContext()->setUser( $u ); |
577 | 580 | |
578 | 581 | // Please reset throttle for successful logins, thanks! |
579 | 582 | if ( $throttleCount ) { |
— | — | @@ -581,7 +584,7 @@ |
582 | 585 | |
583 | 586 | if ( $isAutoCreated ) { |
584 | 587 | // Must be run after $wgUser is set, for correct new user log |
585 | | - wfRunHooks( 'AuthPluginAutoCreate', array( $wgUser ) ); |
| 588 | + wfRunHooks( 'AuthPluginAutoCreate', array( $u ) ); |
586 | 589 | } |
587 | 590 | |
588 | 591 | $retval = self::SUCCESS; |
— | — | @@ -641,9 +644,9 @@ |
642 | 645 | * @return integer Status code |
643 | 646 | */ |
644 | 647 | function attemptAutoCreate( $user ) { |
645 | | - global $wgAuth, $wgUser, $wgAutocreatePolicy; |
| 648 | + global $wgAuth, $wgAutocreatePolicy; |
646 | 649 | |
647 | | - if ( $wgUser->isBlockedFromCreateAccount() ) { |
| 650 | + if ( $this->getUser()->isBlockedFromCreateAccount() ) { |
648 | 651 | wfDebug( __METHOD__ . ": user is blocked from account creation\n" ); |
649 | 652 | return self::CREATE_BLOCKED; |
650 | 653 | } |
— | — | @@ -691,31 +694,34 @@ |
692 | 695 | } |
693 | 696 | |
694 | 697 | function processLogin() { |
695 | | - global $wgUser, $wgRequest, $wgLang; |
| 698 | + global $wgMemc, $wgLang; |
696 | 699 | |
697 | 700 | switch ( $this->authenticateUserData() ) { |
698 | 701 | case self::SUCCESS: |
699 | 702 | # We've verified now, update the real record |
700 | | - if( (bool)$this->mRemember != (bool)$wgUser->getOption( 'rememberpassword' ) ) { |
701 | | - $wgUser->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 ); |
702 | | - $wgUser->saveSettings(); |
| 703 | + $user = $this->getUser(); |
| 704 | + if( (bool)$this->mRemember != (bool)$user->getOption( 'rememberpassword' ) ) { |
| 705 | + $user->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 ); |
| 706 | + $user->saveSettings(); |
703 | 707 | } else { |
704 | | - $wgUser->invalidateCache(); |
| 708 | + $user->invalidateCache(); |
705 | 709 | } |
706 | | - $wgUser->setCookies(); |
| 710 | + $user->setCookies(); |
707 | 711 | self::clearLoginToken(); |
708 | 712 | |
709 | 713 | // Reset the throttle |
710 | | - $key = wfMemcKey( 'password-throttle', $wgRequest->getIP(), md5( $this->mUsername ) ); |
711 | | - global $wgMemc; |
| 714 | + $request = $this->getRequest(); |
| 715 | + $key = wfMemcKey( 'password-throttle', $request->getIP(), md5( $this->mUsername ) ); |
712 | 716 | $wgMemc->delete( $key ); |
713 | 717 | |
714 | 718 | if( $this->hasSessionCookie() || $this->mSkipCookieCheck ) { |
715 | 719 | /* Replace the language object to provide user interface in |
716 | 720 | * correct language immediately on this first page load. |
717 | 721 | */ |
718 | | - $code = $wgRequest->getVal( 'uselang', $wgUser->getOption( 'language' ) ); |
719 | | - $wgLang = Language::factory( $code ); |
| 722 | + $code = $request->getVal( 'uselang', $user->getOption( 'language' ) ); |
| 723 | + $userLang = Language::factory( $code ); |
| 724 | + $wgLang = $userLang; |
| 725 | + $this->getContext()->setLang( $userLang ); |
720 | 726 | return $this->successfulLogin(); |
721 | 727 | } else { |
722 | 728 | return $this->cookieRedirectCheck( 'login' ); |
— | — | @@ -723,48 +729,48 @@ |
724 | 730 | break; |
725 | 731 | |
726 | 732 | case self::NEED_TOKEN: |
727 | | - $this->mainLoginForm( wfMsgExt( 'nocookiesforlogin', array( 'parseinline' ) ) ); |
| 733 | + $this->mainLoginForm( $this->msg( 'nocookiesforlogin' )->parse() ); |
728 | 734 | break; |
729 | 735 | case self::WRONG_TOKEN: |
730 | | - $this->mainLoginForm( wfMsg( 'sessionfailure' ) ); |
| 736 | + $this->mainLoginForm( $this->msg( 'sessionfailure' )->text() ); |
731 | 737 | break; |
732 | 738 | case self::NO_NAME: |
733 | 739 | case self::ILLEGAL: |
734 | | - $this->mainLoginForm( wfMsg( 'noname' ) ); |
| 740 | + $this->mainLoginForm( $this->msg( 'noname' )->text() ); |
735 | 741 | break; |
736 | 742 | case self::WRONG_PLUGIN_PASS: |
737 | | - $this->mainLoginForm( wfMsg( 'wrongpassword' ) ); |
| 743 | + $this->mainLoginForm( $this->msg( 'wrongpassword' )->text() ); |
738 | 744 | break; |
739 | 745 | case self::NOT_EXISTS: |
740 | | - if( $wgUser->isAllowed( 'createaccount' ) ) { |
741 | | - $this->mainLoginForm( wfMsgExt( 'nosuchuser', 'parseinline', |
742 | | - wfEscapeWikiText( $this->mUsername ) ) ); |
| 746 | + if( $this->getUser()->isAllowed( 'createaccount' ) ) { |
| 747 | + $this->mainLoginForm( $this->msg( 'nosuchuser', |
| 748 | + wfEscapeWikiText( $this->mUsername ) )->parse() ); |
743 | 749 | } else { |
744 | | - $this->mainLoginForm( wfMsg( 'nosuchusershort', |
745 | | - wfEscapeWikiText( $this->mUsername ) ) ); |
| 750 | + $this->mainLoginForm( $this->msg( 'nosuchusershort', |
| 751 | + wfEscapeWikiText( $this->mUsername ) )->text() ); |
746 | 752 | } |
747 | 753 | break; |
748 | 754 | case self::WRONG_PASS: |
749 | | - $this->mainLoginForm( wfMsg( 'wrongpassword' ) ); |
| 755 | + $this->mainLoginForm( $this->msg( 'wrongpassword' )->text() ); |
750 | 756 | break; |
751 | 757 | case self::EMPTY_PASS: |
752 | | - $this->mainLoginForm( wfMsg( 'wrongpasswordempty' ) ); |
| 758 | + $this->mainLoginForm( $this->msg( 'wrongpasswordempty' )->text() ); |
753 | 759 | break; |
754 | 760 | case self::RESET_PASS: |
755 | | - $this->resetLoginForm( wfMsg( 'resetpass_announce' ) ); |
| 761 | + $this->resetLoginForm( $this->msg( 'resetpass_announce' )->text() ); |
756 | 762 | break; |
757 | 763 | case self::CREATE_BLOCKED: |
758 | | - $this->userBlockedMessage( $wgUser->mBlock ); |
| 764 | + $this->userBlockedMessage( $this->getUser()->mBlock ); |
759 | 765 | break; |
760 | 766 | case self::THROTTLED: |
761 | | - $this->mainLoginForm( wfMsg( 'login-throttled' ) ); |
| 767 | + $this->mainLoginForm( $this->msg( 'login-throttled' )->text() ); |
762 | 768 | break; |
763 | 769 | case self::USER_BLOCKED: |
764 | | - $this->mainLoginForm( wfMsgExt( 'login-userblocked', |
765 | | - array( 'parsemag', 'escape' ), $this->mUsername ) ); |
| 770 | + $this->mainLoginForm( $this->msg( 'login-userblocked', |
| 771 | + $this->mUsername )->escaped() ); |
766 | 772 | break; |
767 | 773 | case self::ABORTED: |
768 | | - $this->mainLoginForm( wfMsg( $this->mAbortLoginErrorMsg ) ); |
| 774 | + $this->mainLoginForm( $this->msg( $this->mAbortLoginErrorMsg )->text() ); |
769 | 775 | break; |
770 | 776 | default: |
771 | 777 | throw new MWException( 'Unhandled case value' ); |
— | — | @@ -772,9 +778,9 @@ |
773 | 779 | } |
774 | 780 | |
775 | 781 | function resetLoginForm( $error ) { |
776 | | - global $wgOut; |
777 | | - $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $error ) ); |
| 782 | + $this->getOutput()->addHTML( Xml::element('p', array( 'class' => 'error' ), $error ) ); |
778 | 783 | $reset = new SpecialChangePassword(); |
| 784 | + $reset->setContext( $this ); |
779 | 785 | $reset->execute( null ); |
780 | 786 | } |
781 | 787 | |
— | — | @@ -786,25 +792,26 @@ |
787 | 793 | * @return Status object |
788 | 794 | */ |
789 | 795 | function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) { |
790 | | - global $wgServer, $wgScript, $wgUser, $wgNewPasswordExpiry, $wgRequest; |
| 796 | + global $wgServer, $wgScript, $wgNewPasswordExpiry; |
791 | 797 | |
792 | 798 | if ( $u->getEmail() == '' ) { |
793 | 799 | return Status::newFatal( 'noemail', $u->getName() ); |
794 | 800 | } |
795 | | - $ip = $wgRequest->getIP(); |
| 801 | + $ip = $this->getRequest()->getIP(); |
796 | 802 | if( !$ip ) { |
797 | 803 | return Status::newFatal( 'badipaddress' ); |
798 | 804 | } |
799 | 805 | |
800 | | - wfRunHooks( 'User::mailPasswordInternal', array( &$wgUser, &$ip, &$u ) ); |
| 806 | + $currentUser = $this->getUser(); |
| 807 | + wfRunHooks( 'User::mailPasswordInternal', array( &$currentUser, &$ip, &$u ) ); |
801 | 808 | |
802 | 809 | $np = $u->randomPassword(); |
803 | 810 | $u->setNewpassword( $np, $throttle ); |
804 | 811 | $u->saveSettings(); |
805 | 812 | $userLanguage = $u->getOption( 'language' ); |
806 | | - $m = wfMsgExt( $emailText, array( 'parsemag', 'language' => $userLanguage ), $ip, $u->getName(), $np, |
807 | | - $wgServer . $wgScript, round( $wgNewPasswordExpiry / 86400 ) ); |
808 | | - $result = $u->sendMail( wfMsgExt( $emailTitle, array( 'parsemag', 'language' => $userLanguage ) ), $m ); |
| 813 | + $m = $this->msg( $emailText, $ip, $u->getName(), $np, $wgServer . $wgScript, |
| 814 | + round( $wgNewPasswordExpiry / 86400 ) )->inLanguage( $userLanguage )->text(); |
| 815 | + $result = $u->sendMail( $this->msg( $emailTitle )->inLanguage( $userLanguage )->text(), $m ); |
809 | 816 | |
810 | 817 | return $result; |
811 | 818 | } |
— | — | @@ -821,11 +828,10 @@ |
822 | 829 | * @private |
823 | 830 | */ |
824 | 831 | function successfulLogin() { |
825 | | - global $wgUser, $wgOut; |
826 | | - |
827 | 832 | # Run any hooks; display injected HTML if any, else redirect |
| 833 | + $currentUser = $this->getUser(); |
828 | 834 | $injected_html = ''; |
829 | | - wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) ); |
| 835 | + wfRunHooks( 'UserLoginComplete', array( &$currentUser, &$injected_html ) ); |
830 | 836 | |
831 | 837 | if( $injected_html !== '' ) { |
832 | 838 | $this->displaySuccessfulLogin( 'loginsuccess', $injected_html ); |
— | — | @@ -839,7 +845,7 @@ |
840 | 846 | if( $wgSecureLogin && !$this->mStickHTTPS ) { |
841 | 847 | $redirectUrl = preg_replace( '/^https:/', 'http:', $redirectUrl ); |
842 | 848 | } |
843 | | - $wgOut->redirect( $redirectUrl ); |
| 849 | + $this->getOutput()->redirect( $redirectUrl ); |
844 | 850 | } |
845 | 851 | } |
846 | 852 | |
— | — | @@ -850,12 +856,12 @@ |
851 | 857 | * @private |
852 | 858 | */ |
853 | 859 | function successfulCreation() { |
854 | | - global $wgUser; |
855 | 860 | # Run any hooks; display injected HTML |
| 861 | + $currentUser = $this->getUser(); |
856 | 862 | $injected_html = ''; |
857 | 863 | $welcome_creation_msg = 'welcomecreation'; |
858 | 864 | |
859 | | - wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) ); |
| 865 | + wfRunHooks( 'UserLoginComplete', array( &$currentUser, &$injected_html ) ); |
860 | 866 | |
861 | 867 | //let any extensions change what message is shown |
862 | 868 | wfRunHooks( 'BeforeWelcomeCreation', array( &$welcome_creation_msg, &$injected_html ) ); |
— | — | @@ -867,19 +873,18 @@ |
868 | 874 | * Display a "login successful" page. |
869 | 875 | */ |
870 | 876 | private function displaySuccessfulLogin( $msgname, $injected_html ) { |
871 | | - global $wgOut, $wgUser; |
872 | | - |
873 | | - $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) ); |
| 877 | + $out = $this->getOutput(); |
| 878 | + $out->setPageTitle( $this->msg( 'loginsuccesstitle' )->text() ); |
874 | 879 | if( $msgname ){ |
875 | | - $wgOut->addWikiMsg( $msgname, wfEscapeWikiText( $wgUser->getName() ) ); |
| 880 | + $out->addWikiMsg( $msgname, wfEscapeWikiText( $this->getUser()->getName() ) ); |
876 | 881 | } |
877 | 882 | |
878 | | - $wgOut->addHTML( $injected_html ); |
| 883 | + $out->addHTML( $injected_html ); |
879 | 884 | |
880 | 885 | if ( !empty( $this->mReturnTo ) ) { |
881 | | - $wgOut->returnToMain( null, $this->mReturnTo, $this->mReturnToQuery ); |
| 886 | + $out->returnToMain( null, $this->mReturnTo, $this->mReturnToQuery ); |
882 | 887 | } else { |
883 | | - $wgOut->returnToMain( null ); |
| 888 | + $out->returnToMain( null ); |
884 | 889 | } |
885 | 890 | } |
886 | 891 | |
— | — | @@ -891,8 +896,6 @@ |
892 | 897 | * @param $block Block the block causing this error |
893 | 898 | */ |
894 | 899 | function userBlockedMessage( Block $block ) { |
895 | | - global $wgOut; |
896 | | - |
897 | 900 | # Let's be nice about this, it's likely that this feature will be used |
898 | 901 | # for blocking large numbers of innocent people, e.g. range blocks on |
899 | 902 | # schools. Don't blame it on the user. There's a small chance that it |
— | — | @@ -901,56 +904,56 @@ |
902 | 905 | # evade it, but we'll leave that to their guilty conscience to figure |
903 | 906 | # out. |
904 | 907 | |
905 | | - $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) ); |
| 908 | + $out = $this->getOutput(); |
| 909 | + $out->setPageTitle( $this->msg( 'cantcreateaccounttitle' )->text() ); |
906 | 910 | |
907 | 911 | $block_reason = $block->mReason; |
908 | 912 | if ( strval( $block_reason ) === '' ) { |
909 | | - $block_reason = wfMsg( 'blockednoreason' ); |
| 913 | + $block_reason = $this->msg( 'blockednoreason' )->text(); |
910 | 914 | } |
911 | 915 | |
912 | | - $wgOut->addWikiMsg( |
| 916 | + $out->addWikiMsg( |
913 | 917 | 'cantcreateaccount-text', |
914 | 918 | $block->getTarget(), |
915 | 919 | $block_reason, |
916 | 920 | $block->getBlocker()->getName() |
917 | 921 | ); |
918 | 922 | |
919 | | - $wgOut->returnToMain( false ); |
| 923 | + $out->returnToMain( false ); |
920 | 924 | } |
921 | 925 | |
922 | 926 | /** |
923 | 927 | * @private |
924 | 928 | */ |
925 | 929 | function mainLoginForm( $msg, $msgtype = 'error' ) { |
926 | | - global $wgUser, $wgOut, $wgHiddenPrefs; |
927 | 930 | global $wgEnableEmail, $wgEnableUserEmail; |
928 | | - global $wgRequest, $wgLoginLanguageSelector; |
| 931 | + global $wgHiddenPrefs, $wgLoginLanguageSelector; |
929 | 932 | global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration; |
930 | 933 | global $wgSecureLogin, $wgPasswordResetRoutes; |
931 | 934 | |
932 | | - $titleObj = SpecialPage::getTitleFor( 'Userlogin' ); |
| 935 | + $titleObj = $this->getTitle(); |
| 936 | + $user = $this->getUser(); |
933 | 937 | |
934 | 938 | if ( $this->mType == 'signup' ) { |
935 | 939 | // Block signup here if in readonly. Keeps user from |
936 | 940 | // going through the process (filling out data, etc) |
937 | 941 | // and being informed later. |
938 | 942 | if ( wfReadOnly() ) { |
939 | | - $wgOut->readOnlyPage(); |
| 943 | + throw new ReadOnlyError; |
| 944 | + } elseif ( $user->isBlockedFromCreateAccount() ) { |
| 945 | + $this->userBlockedMessage( $user->isBlockedFromCreateAccount() ); |
940 | 946 | return; |
941 | | - } elseif ( $wgUser->isBlockedFromCreateAccount() ) { |
942 | | - $this->userBlockedMessage( $wgUser->isBlockedFromCreateAccount() ); |
| 947 | + } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $user, true ) )>0 ) { |
| 948 | + $this->getOutput()->showPermissionsErrorPage( $permErrors, 'createaccount' ); |
943 | 949 | return; |
944 | | - } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) { |
945 | | - $wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' ); |
946 | | - return; |
947 | 950 | } |
948 | 951 | } |
949 | 952 | |
950 | 953 | if ( $this->mUsername == '' ) { |
951 | | - if ( $wgUser->isLoggedIn() ) { |
952 | | - $this->mUsername = $wgUser->getName(); |
| 954 | + if ( $user->isLoggedIn() ) { |
| 955 | + $this->mUsername = $user->getName(); |
953 | 956 | } else { |
954 | | - $this->mUsername = $wgRequest->getCookie( 'UserName' ); |
| 957 | + $this->mUsername = $this->getRequest()->getCookie( 'UserName' ); |
955 | 958 | } |
956 | 959 | } |
957 | 960 | |
— | — | @@ -976,18 +979,16 @@ |
977 | 980 | $linkq .= $returnto; |
978 | 981 | } |
979 | 982 | |
980 | | - # Pass any language selection on to the mode switch link |
981 | | - if( $wgLoginLanguageSelector && $this->mLanguage ) { |
982 | | - $linkq .= '&uselang=' . $this->mLanguage; |
983 | | - } |
984 | | - |
985 | | - $link = '<a href="' . htmlspecialchars ( $titleObj->getLocalURL( $linkq ) ) . '">'; |
986 | | - $link .= wfMsgHtml( $linkmsg . 'link' ); # Calling either 'gotaccountlink' or 'nologinlink' |
987 | | - $link .= '</a>'; |
988 | | - |
989 | 983 | # Don't show a "create account" link if the user can't |
990 | | - if( $this->showCreateOrLoginLink( $wgUser ) ) { |
991 | | - $template->set( 'link', wfMsgExt( $linkmsg, array( 'parseinline', 'replaceafter' ), $link ) ); |
| 984 | + if( $this->showCreateOrLoginLink( $user ) ) { |
| 985 | + # Pass any language selection on to the mode switch link |
| 986 | + if( $wgLoginLanguageSelector && $this->mLanguage ) { |
| 987 | + $linkq .= '&uselang=' . $this->mLanguage; |
| 988 | + } |
| 989 | + $link = Html::element( 'a', array( 'href' => $titleObj->getLocalURL( $linkq ) ), |
| 990 | + $this->msg( $linkmsg . 'link' )->text() ); # Calling either 'gotaccountlink' or 'nologinlink' |
| 991 | + |
| 992 | + $template->set( 'link', $this->msg( $linkmsg )->rawParams( $link )->parse() ); |
992 | 993 | } else { |
993 | 994 | $template->set( 'link', '' ); |
994 | 995 | } |
— | — | @@ -1008,7 +1009,7 @@ |
1009 | 1010 | $template->set( 'action', $titleObj->getLocalURL( $q ) ); |
1010 | 1011 | $template->set( 'message', $msg ); |
1011 | 1012 | $template->set( 'messagetype', $msgtype ); |
1012 | | - $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() ); |
| 1013 | + $template->set( 'createemail', $wgEnableEmail && $user->isLoggedIn() ); |
1013 | 1014 | $template->set( 'userealname', !in_array( 'realname', $wgHiddenPrefs ) ); |
1014 | 1015 | $template->set( 'useemail', $wgEnableEmail ); |
1015 | 1016 | $template->set( 'emailrequired', $wgEmailConfirmToEdit ); |
— | — | @@ -1016,8 +1017,8 @@ |
1017 | 1018 | $template->set( 'canreset', $wgAuth->allowPasswordChange() ); |
1018 | 1019 | $template->set( 'resetlink', $resetLink ); |
1019 | 1020 | $template->set( 'canremember', ( $wgCookieExpiration > 0 ) ); |
1020 | | - $template->set( 'usereason', $wgUser->isLoggedIn() ); |
1021 | | - $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) || $this->mRemember ); |
| 1021 | + $template->set( 'usereason', $user->isLoggedIn() ); |
| 1022 | + $template->set( 'remember', $user->getOption( 'rememberpassword' ) || $this->mRemember ); |
1022 | 1023 | $template->set( 'cansecurelogin', ( $wgSecureLogin === true ) ); |
1023 | 1024 | $template->set( 'stickHTTPS', $this->mStickHTTPS ); |
1024 | 1025 | |
— | — | @@ -1043,17 +1044,17 @@ |
1044 | 1045 | // Use loginend-https for HTTPS requests if it's not blank, loginend otherwise |
1045 | 1046 | // Ditto for signupend |
1046 | 1047 | $usingHTTPS = WebRequest::detectProtocol() == 'https'; |
1047 | | - $loginendHTTPS = wfMessage( 'loginend-https' ); |
1048 | | - $signupendHTTPS = wfMessage( 'signupend-https' ); |
| 1048 | + $loginendHTTPS = $this->msg( 'loginend-https' ); |
| 1049 | + $signupendHTTPS = $this->msg( 'signupend-https' ); |
1049 | 1050 | if ( $usingHTTPS && !$loginendHTTPS->isBlank() ) { |
1050 | 1051 | $template->set( 'loginend', $loginendHTTPS->parse() ); |
1051 | 1052 | } else { |
1052 | | - $template->set( 'loginend', wfMessage( 'loginend' )->parse() ); |
| 1053 | + $template->set( 'loginend', $this->msg( 'loginend' )->parse() ); |
1053 | 1054 | } |
1054 | 1055 | if ( $usingHTTPS && !$signupendHTTPS->isBlank() ) { |
1055 | 1056 | $template->set( 'signupend', $signupendHTTPS->parse() ); |
1056 | 1057 | } else { |
1057 | | - $template->set( 'signupend', wfMessage( 'signupend' )->parse() ); |
| 1058 | + $template->set( 'signupend', $this->msg( 'signupend' )->parse() ); |
1058 | 1059 | } |
1059 | 1060 | |
1060 | 1061 | // Give authentication and captcha plugins a chance to modify the form |
— | — | @@ -1065,14 +1066,15 @@ |
1066 | 1067 | } |
1067 | 1068 | |
1068 | 1069 | // Changes the title depending on permissions for creating account |
1069 | | - if ( $wgUser->isAllowed( 'createaccount' ) ) { |
1070 | | - $wgOut->setPageTitle( wfMsg( 'userlogin' ) ); |
| 1070 | + $out = $this->getOutput(); |
| 1071 | + if ( $user->isAllowed( 'createaccount' ) ) { |
| 1072 | + $out->setPageTitle( $this->msg( 'userlogin' )->text() ); |
1071 | 1073 | } else { |
1072 | | - $wgOut->setPageTitle( wfMsg( 'userloginnocreate' ) ); |
| 1074 | + $out->setPageTitle( $this->msg( 'userloginnocreate' )->text() ); |
1073 | 1075 | } |
1074 | 1076 | |
1075 | | - $wgOut->disallowUserJs(); // just in case... |
1076 | | - $wgOut->addTemplate( $template ); |
| 1077 | + $out->disallowUserJs(); // just in case... |
| 1078 | + $out->addTemplate( $template ); |
1077 | 1079 | } |
1078 | 1080 | |
1079 | 1081 | /** |
— | — | @@ -1102,8 +1104,8 @@ |
1103 | 1105 | * @private |
1104 | 1106 | */ |
1105 | 1107 | function hasSessionCookie() { |
1106 | | - global $wgDisableCookieCheck, $wgRequest; |
1107 | | - return $wgDisableCookieCheck ? true : $wgRequest->checkSessionCookie(); |
| 1108 | + global $wgDisableCookieCheck; |
| 1109 | + return $wgDisableCookieCheck ? true : $this->getRequest()->checkSessionCookie(); |
1108 | 1110 | } |
1109 | 1111 | |
1110 | 1112 | /** |
— | — | @@ -1160,8 +1162,6 @@ |
1161 | 1163 | * @private |
1162 | 1164 | */ |
1163 | 1165 | function cookieRedirectCheck( $type ) { |
1164 | | - global $wgOut; |
1165 | | - |
1166 | 1166 | $titleObj = SpecialPage::getTitleFor( 'Userlogin' ); |
1167 | 1167 | $query = array( 'wpCookieCheck' => $type ); |
1168 | 1168 | if ( $this->mReturnTo ) { |
— | — | @@ -1169,7 +1169,7 @@ |
1170 | 1170 | } |
1171 | 1171 | $check = $titleObj->getFullURL( $query ); |
1172 | 1172 | |
1173 | | - return $wgOut->redirect( $check ); |
| 1173 | + return $this->getOutput()->redirect( $check ); |
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | /** |
— | — | @@ -1178,12 +1178,12 @@ |
1179 | 1179 | function onCookieRedirectCheck( $type ) { |
1180 | 1180 | if ( !$this->hasSessionCookie() ) { |
1181 | 1181 | if ( $type == 'new' ) { |
1182 | | - return $this->mainLoginForm( wfMsgExt( 'nocookiesnew', array( 'parseinline' ) ) ); |
| 1182 | + return $this->mainLoginForm( $this->msg( 'nocookiesnew' )->parse() ); |
1183 | 1183 | } elseif ( $type == 'login' ) { |
1184 | | - return $this->mainLoginForm( wfMsgExt( 'nocookieslogin', array( 'parseinline' ) ) ); |
| 1184 | + return $this->mainLoginForm( $this->msg( 'nocookieslogin' )->parse() ); |
1185 | 1185 | } else { |
1186 | 1186 | # shouldn't happen |
1187 | | - return $this->mainLoginForm( wfMsg( 'error' ) ); |
| 1187 | + return $this->mainLoginForm( $this->msg( 'error' )->text() ); |
1188 | 1188 | } |
1189 | 1189 | } else { |
1190 | 1190 | return $this->successfulLogin(); |
— | — | @@ -1194,7 +1194,7 @@ |
1195 | 1195 | * @private |
1196 | 1196 | */ |
1197 | 1197 | function throttleHit( $limit ) { |
1198 | | - $this->mainLoginForm( wfMsgExt( 'acct_creation_throttle_hit', array( 'parseinline' ), $limit ) ); |
| 1198 | + $this->mainLoginForm( $this->msg( 'acct_creation_throttle_hit' )->numParams( $limit )->parse() ); |
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | /** |
— | — | @@ -1204,9 +1204,7 @@ |
1205 | 1205 | * @return string |
1206 | 1206 | */ |
1207 | 1207 | function makeLanguageSelector() { |
1208 | | - global $wgLang; |
1209 | | - |
1210 | | - $msg = wfMessage( 'loginlanguagelinks' )->inContentLanguage(); |
| 1208 | + $msg = $this->msg( 'loginlanguagelinks' )->inContentLanguage(); |
1211 | 1209 | if( !$msg->isBlank() ) { |
1212 | 1210 | $langs = explode( "\n", $msg->text() ); |
1213 | 1211 | $links = array(); |
— | — | @@ -1217,7 +1215,8 @@ |
1218 | 1216 | $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) ); |
1219 | 1217 | } |
1220 | 1218 | } |
1221 | | - return count( $links ) > 0 ? wfMsgHtml( 'loginlanguagelabel', $wgLang->pipeList( $links ) ) : ''; |
| 1219 | + return count( $links ) > 0 ? $this->msg( 'loginlanguagelabel' )->rawParams( |
| 1220 | + $this->getLang()->pipeList( $links ) )->escaped() : ''; |
1222 | 1221 | } else { |
1223 | 1222 | return ''; |
1224 | 1223 | } |
— | — | @@ -1231,7 +1230,6 @@ |
1232 | 1231 | * @param $lang Language code |
1233 | 1232 | */ |
1234 | 1233 | function makeLanguageSelectorLink( $text, $lang ) { |
1235 | | - $self = SpecialPage::getTitleFor( 'Userlogin' ); |
1236 | 1234 | $attr = array( 'uselang' => $lang ); |
1237 | 1235 | if( $this->mType == 'signup' ) { |
1238 | 1236 | $attr['type'] = 'signup'; |
— | — | @@ -1240,7 +1238,7 @@ |
1241 | 1239 | $attr['returnto'] = $this->mReturnTo; |
1242 | 1240 | } |
1243 | 1241 | return Linker::linkKnown( |
1244 | | - $self, |
| 1242 | + $this->getTitle(), |
1245 | 1243 | htmlspecialchars( $text ), |
1246 | 1244 | array(), |
1247 | 1245 | $attr |