Index: branches/wmf/1.17wmf1/includes/specials/SpecialUserlogin.php |
— | — | @@ -22,11 +22,24 @@ |
23 | 23 | */ |
24 | 24 | |
25 | 25 | /** |
| 26 | + * Constructor |
| 27 | + */ |
| 28 | +function wfSpecialUserlogin( $par = '' ) { |
| 29 | + global $wgRequest; |
| 30 | + if( session_id() == '' ) { |
| 31 | + wfSetupSession(); |
| 32 | + } |
| 33 | + |
| 34 | + $form = new LoginForm( $wgRequest, $par ); |
| 35 | + $form->execute(); |
| 36 | +} |
| 37 | + |
| 38 | +/** |
26 | 39 | * Implements Special:UserLogin |
27 | 40 | * |
28 | 41 | * @ingroup SpecialPage |
29 | 42 | */ |
30 | | -class LoginForm extends SpecialPage { |
| 43 | +class LoginForm { |
31 | 44 | |
32 | 45 | const SUCCESS = 0; |
33 | 46 | const NO_NAME = 1; |
— | — | @@ -43,42 +56,23 @@ |
44 | 57 | const NEED_TOKEN = 12; |
45 | 58 | const WRONG_TOKEN = 13; |
46 | 59 | |
47 | | - var $mUsername, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
48 | | - var $mAction, $mCreateaccount, $mCreateaccountMail; |
| 60 | + var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
| 61 | + var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword; |
49 | 62 | var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage; |
50 | 63 | var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS; |
51 | | - var $mType, $mReason, $mRealName; |
52 | | - var $mAbortLoginErrorMsg = 'login-abort-generic'; |
53 | 64 | |
54 | | - /** |
55 | | - * @var ExternalUser |
56 | | - */ |
57 | 65 | private $mExtUser = null; |
58 | 66 | |
59 | 67 | /** |
60 | | - * @param WebRequest $request |
| 68 | + * Constructor |
| 69 | + * @param $request WebRequest: a WebRequest object passed by reference |
| 70 | + * @param $par String: subpage parameter |
61 | 71 | */ |
62 | | - public function __construct( $request = null ) { |
63 | | - parent::__construct( 'Userlogin' ); |
64 | | - |
65 | | - if ( $request === null ) { |
66 | | - global $wgRequest; |
67 | | - $this->load( $wgRequest ); |
68 | | - } else { |
69 | | - $this->load( $request ); |
70 | | - } |
71 | | - } |
72 | | - |
73 | | - /** |
74 | | - * Loader |
75 | | - * |
76 | | - * @param $request WebRequest object |
77 | | - */ |
78 | | - function load( $request ) { |
| 72 | + function __construct( &$request, $par = '' ) { |
79 | 73 | global $wgAuth, $wgHiddenPrefs, $wgEnableEmail, $wgRedirectOnLogin; |
80 | 74 | |
81 | | - $this->mType = $request->getText( 'type' ); |
82 | | - $this->mUsername = $request->getText( 'wpName' ); |
| 75 | + $this->mType = ( $par == 'signup' ) ? $par : $request->getText( 'type' ); # Check for [[Special:Userlogin/signup]] |
| 76 | + $this->mName = $request->getText( 'wpName' ); |
83 | 77 | $this->mPassword = $request->getText( 'wpPassword' ); |
84 | 78 | $this->mRetype = $request->getText( 'wpRetype' ); |
85 | 79 | $this->mDomain = $request->getText( 'wpDomain' ); |
— | — | @@ -89,7 +83,9 @@ |
90 | 84 | $this->mPosted = $request->wasPosted(); |
91 | 85 | $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' ); |
92 | 86 | $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' ) |
93 | | - && $wgEnableEmail; |
| 87 | + && $wgEnableEmail; |
| 88 | + $this->mMailmypassword = $request->getCheck( 'wpMailmypassword' ) |
| 89 | + && $wgEnableEmail; |
94 | 90 | $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' ); |
95 | 91 | $this->mAction = $request->getVal( 'action' ); |
96 | 92 | $this->mRemember = $request->getCheck( 'wpRemember' ); |
— | — | @@ -109,9 +105,9 @@ |
110 | 106 | $this->mEmail = ''; |
111 | 107 | } |
112 | 108 | if( !in_array( 'realname', $wgHiddenPrefs ) ) { |
113 | | - $this->mRealName = $request->getText( 'wpRealName' ); |
| 109 | + $this->mRealName = $request->getText( 'wpRealName' ); |
114 | 110 | } else { |
115 | | - $this->mRealName = ''; |
| 111 | + $this->mRealName = ''; |
116 | 112 | } |
117 | 113 | |
118 | 114 | if( !$wgAuth->validDomain( $this->mDomain ) ) { |
— | — | @@ -127,15 +123,7 @@ |
128 | 124 | } |
129 | 125 | } |
130 | 126 | |
131 | | - public function execute( $par ) { |
132 | | - if ( session_id() == '' ) { |
133 | | - wfSetupSession(); |
134 | | - } |
135 | | - |
136 | | - if ( $par == 'signup' ) { # Check for [[Special:Userlogin/signup]] |
137 | | - $this->mType = 'signup'; |
138 | | - } |
139 | | - |
| 127 | + function execute() { |
140 | 128 | if ( !is_null( $this->mCookieCheck ) ) { |
141 | 129 | $this->onCookieRedirectCheck( $this->mCookieCheck ); |
142 | 130 | return; |
— | — | @@ -144,6 +132,8 @@ |
145 | 133 | return $this->addNewAccount(); |
146 | 134 | } elseif ( $this->mCreateaccountMail ) { |
147 | 135 | return $this->addNewAccountMailPassword(); |
| 136 | + } elseif ( $this->mMailmypassword ) { |
| 137 | + return $this->mailPassword(); |
148 | 138 | } elseif ( ( 'submitlogin' == $this->mAction ) || $this->mLoginattempt ) { |
149 | 139 | return $this->processLogin(); |
150 | 140 | } |
— | — | @@ -158,7 +148,7 @@ |
159 | 149 | global $wgOut; |
160 | 150 | |
161 | 151 | if ( $this->mEmail == '' ) { |
162 | | - $this->mainLoginForm( wfMsgExt( 'noemail', array( 'parsemag', 'escape' ), $this->mUsername ) ); |
| 152 | + $this->mainLoginForm( wfMsgExt( 'noemail', array( 'parsemag', 'escape' ), $this->mName ) ); |
163 | 153 | return; |
164 | 154 | } |
165 | 155 | |
— | — | @@ -177,6 +167,8 @@ |
178 | 168 | $u->addNewUserLogEntry( true, $this->mReason ); |
179 | 169 | |
180 | 170 | $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) ); |
| 171 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 172 | + $wgOut->setArticleRelated( false ); |
181 | 173 | |
182 | 174 | if( !$result->isGood() ) { |
183 | 175 | $this->mainLoginForm( wfMsg( 'mailerror', $result->getWikiText() ) ); |
— | — | @@ -235,7 +227,9 @@ |
236 | 228 | # Confirm that the account was created |
237 | 229 | $self = SpecialPage::getTitleFor( 'Userlogin' ); |
238 | 230 | $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); |
239 | | - $wgOut->addWikiMsg( 'accountcreatedtext', $u->getName() ); |
| 231 | + $wgOut->setArticleRelated( false ); |
| 232 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 233 | + $wgOut->addHTML( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) ); |
240 | 234 | $wgOut->returnToMain( false, $self ); |
241 | 235 | wfRunHooks( 'AddNewAccount', array( $u, false ) ); |
242 | 236 | $u->addNewUserLogEntry( false, $this->mReason ); |
— | — | @@ -264,8 +258,7 @@ |
265 | 259 | // create a local account and login as any domain user). We only need |
266 | 260 | // to check this for domains that aren't local. |
267 | 261 | if( 'local' != $this->mDomain && $this->mDomain != '' ) { |
268 | | - if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mUsername ) |
269 | | - || !$wgAuth->authenticate( $this->mUsername, $this->mPassword ) ) ) { |
| 262 | + if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) { |
270 | 263 | $this->mainLoginForm( wfMsg( 'wrongpassword' ) ); |
271 | 264 | return false; |
272 | 265 | } |
— | — | @@ -279,7 +272,7 @@ |
280 | 273 | # Request forgery checks. |
281 | 274 | if ( !self::getCreateaccountToken() ) { |
282 | 275 | self::setCreateaccountToken(); |
283 | | - $this->mainLoginForm( wfMsgExt( 'nocookiesfornew', array( 'parseinline' ) ) ); |
| 276 | + $this->mainLoginForm( wfMsgExt( 'nocookiesnew', array( 'parseinline' ) ) ); |
284 | 277 | return false; |
285 | 278 | } |
286 | 279 | |
— | — | @@ -300,7 +293,7 @@ |
301 | 294 | $wgOut->permissionRequired( 'createaccount' ); |
302 | 295 | return false; |
303 | 296 | } elseif ( $wgUser->isBlockedFromCreateAccount() ) { |
304 | | - $this->userBlockedMessage( $wgUser->isBlockedFromCreateAccount() ); |
| 297 | + $this->userBlockedMessage(); |
305 | 298 | return false; |
306 | 299 | } |
307 | 300 | |
— | — | @@ -311,7 +304,7 @@ |
312 | 305 | } |
313 | 306 | |
314 | 307 | # Now create a dummy user ($u) and check if it is valid |
315 | | - $name = trim( $this->mUsername ); |
| 308 | + $name = trim( $this->mName ); |
316 | 309 | $u = User::newFromName( $name, 'creatable' ); |
317 | 310 | if ( !is_object( $u ) ) { |
318 | 311 | $this->mainLoginForm( wfMsg( 'noname' ) ); |
— | — | @@ -332,14 +325,7 @@ |
333 | 326 | $valid = $u->getPasswordValidity( $this->mPassword ); |
334 | 327 | if ( $valid !== true ) { |
335 | 328 | if ( !$this->mCreateaccountMail ) { |
336 | | - if ( is_array( $valid ) ) { |
337 | | - $message = array_shift( $valid ); |
338 | | - $params = $valid; |
339 | | - } else { |
340 | | - $message = $valid; |
341 | | - $params = array( $wgMinimalPasswordLength ); |
342 | | - } |
343 | | - $this->mainLoginForm( wfMsgExt( $message, array( 'parsemag' ), $params ) ); |
| 329 | + $this->mainLoginForm( wfMsgExt( $valid, array( 'parsemag' ), $wgMinimalPasswordLength ) ); |
344 | 330 | return false; |
345 | 331 | } else { |
346 | 332 | # do not force a password for account creation by email |
— | — | @@ -447,7 +433,7 @@ |
448 | 434 | public function authenticateUserData() { |
449 | 435 | global $wgUser, $wgAuth, $wgMemc; |
450 | 436 | |
451 | | - if ( $this->mUsername == '' ) { |
| 437 | + if ( $this->mName == '' ) { |
452 | 438 | return self::NO_NAME; |
453 | 439 | } |
454 | 440 | |
— | — | @@ -470,7 +456,7 @@ |
471 | 457 | |
472 | 458 | $throttleCount = 0; |
473 | 459 | if ( is_array( $wgPasswordAttemptThrottle ) ) { |
474 | | - $throttleKey = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mUsername ) ); |
| 460 | + $throttleKey = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) ); |
475 | 461 | $count = $wgPasswordAttemptThrottle['count']; |
476 | 462 | $period = $wgPasswordAttemptThrottle['seconds']; |
477 | 463 | |
— | — | @@ -495,16 +481,16 @@ |
496 | 482 | // creates the user in the database. Until we load $wgUser, checking |
497 | 483 | // for user existence using User::newFromName($name)->getId() below |
498 | 484 | // will effectively be using stale data. |
499 | | - if ( $wgUser->getName() === $this->mUsername ) { |
500 | | - wfDebug( __METHOD__ . ": already logged in as {$this->mUsername}\n" ); |
| 485 | + if ( $wgUser->getName() === $this->mName ) { |
| 486 | + wfDebug( __METHOD__ . ": already logged in as {$this->mName}\n" ); |
501 | 487 | return self::SUCCESS; |
502 | 488 | } |
503 | 489 | |
504 | | - $this->mExtUser = ExternalUser::newFromName( $this->mUsername ); |
| 490 | + $this->mExtUser = ExternalUser::newFromName( $this->mName ); |
505 | 491 | |
506 | 492 | # TODO: Allow some magic here for invalid external names, e.g., let the |
507 | 493 | # user choose a different wiki name. |
508 | | - $u = User::newFromName( $this->mUsername ); |
| 494 | + $u = User::newFromName( $this->mName ); |
509 | 495 | if( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) { |
510 | 496 | return self::ILLEGAL; |
511 | 497 | } |
— | — | @@ -532,7 +518,7 @@ |
533 | 519 | |
534 | 520 | // Give general extensions, such as a captcha, a chance to abort logins |
535 | 521 | $abort = self::ABORTED; |
536 | | - if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$this->mAbortLoginErrorMsg ) ) ) { |
| 522 | + if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort ) ) ) { |
537 | 523 | return $abort; |
538 | 524 | } |
539 | 525 | |
— | — | @@ -593,9 +579,6 @@ |
594 | 580 | /** |
595 | 581 | * Attempt to automatically create a user on login. Only succeeds if there |
596 | 582 | * is an external authentication method which allows it. |
597 | | - * |
598 | | - * @param $user User |
599 | | - * |
600 | 583 | * @return integer Status code |
601 | 584 | */ |
602 | 585 | function attemptAutoCreate( $user ) { |
— | — | @@ -635,14 +618,6 @@ |
636 | 619 | } |
637 | 620 | } |
638 | 621 | |
639 | | - $abortError = ''; |
640 | | - if( !wfRunHooks( 'AbortAutoAccount', array( $user, &$abortError ) ) ) { |
641 | | - // Hook point to add extra creation throttles and blocks |
642 | | - wfDebug( "LoginForm::attemptAutoCreate: a hook blocked creation: $abortError\n" ); |
643 | | - $this->mAbortLoginErrorMsg = $abortError; |
644 | | - return self::ABORTED; |
645 | | - } |
646 | | - |
647 | 622 | wfDebug( __METHOD__ . ": creating account\n" ); |
648 | 623 | $this->initUser( $user, true ); |
649 | 624 | return self::SUCCESS; |
— | — | @@ -664,7 +639,7 @@ |
665 | 640 | self::clearLoginToken(); |
666 | 641 | |
667 | 642 | // Reset the throttle |
668 | | - $key = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mUsername ) ); |
| 643 | + $key = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) ); |
669 | 644 | global $wgMemc; |
670 | 645 | $wgMemc->delete( $key ); |
671 | 646 | |
— | — | @@ -682,7 +657,7 @@ |
683 | 658 | break; |
684 | 659 | |
685 | 660 | case self::NEED_TOKEN: |
686 | | - $this->mainLoginForm( wfMsgExt( 'nocookiesforlogin', array( 'parseinline' ) ) ); |
| 661 | + $this->mainLoginForm( wfMsgExt( 'nocookieslogin', array( 'parseinline' ) ) ); |
687 | 662 | break; |
688 | 663 | case self::WRONG_TOKEN: |
689 | 664 | $this->mainLoginForm( wfMsg( 'sessionfailure' ) ); |
— | — | @@ -696,9 +671,9 @@ |
697 | 672 | break; |
698 | 673 | case self::NOT_EXISTS: |
699 | 674 | if( $wgUser->isAllowed( 'createaccount' ) ) { |
700 | | - $this->mainLoginForm( wfMsgExt( 'nosuchuser', 'parseinline', $this->mUsername ) ); |
| 675 | + $this->mainLoginForm( wfMsgWikiHtml( 'nosuchuser', htmlspecialchars( $this->mName ) ) ); |
701 | 676 | } else { |
702 | | - $this->mainLoginForm( wfMsg( 'nosuchusershort', htmlspecialchars( $this->mUsername ) ) ); |
| 677 | + $this->mainLoginForm( wfMsg( 'nosuchusershort', htmlspecialchars( $this->mName ) ) ); |
703 | 678 | } |
704 | 679 | break; |
705 | 680 | case self::WRONG_PASS: |
— | — | @@ -718,11 +693,8 @@ |
719 | 694 | break; |
720 | 695 | case self::USER_BLOCKED: |
721 | 696 | $this->mainLoginForm( wfMsgExt( 'login-userblocked', |
722 | | - array( 'parsemag', 'escape' ), $this->mUsername ) ); |
| 697 | + array( 'parsemag', 'escape' ), $this->mName ) ); |
723 | 698 | break; |
724 | | - case self::ABORTED: |
725 | | - $this->mainLoginForm( wfMsg( $this->mAbortLoginErrorMsg ) ); |
726 | | - break; |
727 | 699 | default: |
728 | 700 | throw new MWException( 'Unhandled case value' ); |
729 | 701 | } |
— | — | @@ -731,11 +703,100 @@ |
732 | 704 | function resetLoginForm( $error ) { |
733 | 705 | global $wgOut; |
734 | 706 | $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $error ) ); |
735 | | - $reset = new SpecialChangePassword(); |
| 707 | + $reset = new SpecialResetpass(); |
736 | 708 | $reset->execute( null ); |
737 | 709 | } |
738 | 710 | |
739 | 711 | /** |
| 712 | + * @private |
| 713 | + */ |
| 714 | + function mailPassword() { |
| 715 | + global $wgUser, $wgOut, $wgAuth; |
| 716 | + |
| 717 | + if ( wfReadOnly() ) { |
| 718 | + $wgOut->readOnlyPage(); |
| 719 | + return false; |
| 720 | + } |
| 721 | + |
| 722 | + if( !$wgAuth->allowPasswordChange() ) { |
| 723 | + $this->mainLoginForm( wfMsg( 'resetpass_forbidden' ) ); |
| 724 | + return; |
| 725 | + } |
| 726 | + |
| 727 | + # Check against blocked IPs so blocked users can't flood admins |
| 728 | + # with password resets |
| 729 | + if( $wgUser->isBlocked() ) { |
| 730 | + $this->mainLoginForm( wfMsg( 'blocked-mailpassword' ) ); |
| 731 | + return; |
| 732 | + } |
| 733 | + |
| 734 | + # Check for hooks |
| 735 | + $error = null; |
| 736 | + if ( !wfRunHooks( 'UserLoginMailPassword', array( $this->mName, &$error ) ) ) { |
| 737 | + $this->mainLoginForm( $error ); |
| 738 | + return; |
| 739 | + } |
| 740 | + |
| 741 | + # If the user doesn't have a login token yet, set one. |
| 742 | + if ( !self::getLoginToken() ) { |
| 743 | + self::setLoginToken(); |
| 744 | + $this->mainLoginForm( wfMsg( 'sessionfailure' ) ); |
| 745 | + return; |
| 746 | + } |
| 747 | + |
| 748 | + # If the user didn't pass a login token, tell them we need one |
| 749 | + if ( !$this->mToken ) { |
| 750 | + $this->mainLoginForm( wfMsg( 'sessionfailure' ) ); |
| 751 | + return; |
| 752 | + } |
| 753 | + |
| 754 | + # Check against the rate limiter |
| 755 | + if( $wgUser->pingLimiter( 'mailpassword' ) ) { |
| 756 | + $wgOut->rateLimited(); |
| 757 | + return; |
| 758 | + } |
| 759 | + |
| 760 | + if ( $this->mName == '' ) { |
| 761 | + $this->mainLoginForm( wfMsg( 'noname' ) ); |
| 762 | + return; |
| 763 | + } |
| 764 | + $u = User::newFromName( $this->mName ); |
| 765 | + if( !$u instanceof User ) { |
| 766 | + $this->mainLoginForm( wfMsg( 'noname' ) ); |
| 767 | + return; |
| 768 | + } |
| 769 | + if ( 0 == $u->getID() ) { |
| 770 | + $this->mainLoginForm( wfMsgWikiHtml( 'nosuchuser', htmlspecialchars( $u->getName() ) ) ); |
| 771 | + return; |
| 772 | + } |
| 773 | + |
| 774 | + # Validate the login token |
| 775 | + if ( $this->mToken !== self::getLoginToken() ) { |
| 776 | + $this->mainLoginForm( wfMsg( 'sessionfailure' ) ); |
| 777 | + return; |
| 778 | + } |
| 779 | + |
| 780 | + # Check against password throttle |
| 781 | + if ( $u->isPasswordReminderThrottled() ) { |
| 782 | + global $wgPasswordReminderResendTime; |
| 783 | + # Round the time in hours to 3 d.p., in case someone is specifying |
| 784 | + # minutes or seconds. |
| 785 | + $this->mainLoginForm( wfMsgExt( 'throttled-mailpassword', array( 'parsemag' ), |
| 786 | + round( $wgPasswordReminderResendTime, 3 ) ) ); |
| 787 | + return; |
| 788 | + } |
| 789 | + |
| 790 | + $result = $this->mailPasswordInternal( $u, true, 'passwordremindertitle', 'passwordremindertext' ); |
| 791 | + if( $result->isGood() ) { |
| 792 | + $this->mainLoginForm( wfMsg( 'passwordsent', $u->getName() ), 'success' ); |
| 793 | + self::clearLoginToken(); |
| 794 | + } else { |
| 795 | + $this->mainLoginForm( $result->getWikiText( 'mailerror' ) ); |
| 796 | + } |
| 797 | + } |
| 798 | + |
| 799 | + |
| 800 | + /** |
740 | 801 | * @param $u User object |
741 | 802 | * @param $throttle Boolean |
742 | 803 | * @param $emailTitle String: message name of email title |
— | — | @@ -811,14 +872,9 @@ |
812 | 873 | global $wgUser; |
813 | 874 | # Run any hooks; display injected HTML |
814 | 875 | $injected_html = ''; |
815 | | - $welcome_creation_msg = 'welcomecreation'; |
816 | | - |
817 | 876 | wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) ); |
818 | | - |
819 | | - //let any extensions change what message is shown |
820 | | - wfRunHooks( 'BeforeWelcomeCreation', array( &$welcome_creation_msg, &$injected_html ) ); |
821 | | - |
822 | | - $this->displaySuccessfulLogin( $welcome_creation_msg, $injected_html ); |
| 877 | + |
| 878 | + $this->displaySuccessfulLogin( 'welcomecreation', $injected_html ); |
823 | 879 | } |
824 | 880 | |
825 | 881 | /** |
— | — | @@ -828,10 +884,9 @@ |
829 | 885 | global $wgOut, $wgUser; |
830 | 886 | |
831 | 887 | $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) ); |
832 | | - if( $msgname ){ |
833 | | - $wgOut->addWikiMsg( $msgname, $wgUser->getName() ); |
834 | | - } |
835 | | - |
| 888 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 889 | + $wgOut->setArticleRelated( false ); |
| 890 | + $wgOut->addWikiMsg( $msgname, $wgUser->getName() ); |
836 | 891 | $wgOut->addHTML( $injected_html ); |
837 | 892 | |
838 | 893 | if ( !empty( $this->mReturnTo ) ) { |
— | — | @@ -841,15 +896,9 @@ |
842 | 897 | } |
843 | 898 | } |
844 | 899 | |
845 | | - /** |
846 | | - * Output a message that informs the user that they cannot create an account because |
847 | | - * there is a block on them or their IP which prevents account creation. Note that |
848 | | - * User::isBlockedFromCreateAccount(), which gets this block, ignores the 'hardblock' |
849 | | - * setting on blocks (bug 13611). |
850 | | - * @param $block Block the block causing this error |
851 | | - */ |
852 | | - function userBlockedMessage( Block $block ) { |
853 | | - global $wgOut; |
| 900 | + /** */ |
| 901 | + function userBlockedMessage() { |
| 902 | + global $wgOut, $wgUser; |
854 | 903 | |
855 | 904 | # Let's be nice about this, it's likely that this feature will be used |
856 | 905 | # for blocking large numbers of innocent people, e.g. range blocks on |
— | — | @@ -860,19 +909,17 @@ |
861 | 910 | # out. |
862 | 911 | |
863 | 912 | $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) ); |
| 913 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 914 | + $wgOut->setArticleRelated( false ); |
864 | 915 | |
865 | | - $block_reason = $block->mReason; |
| 916 | + $ip = wfGetIP(); |
| 917 | + $blocker = User::whoIs( $wgUser->mBlock->mBy ); |
| 918 | + $block_reason = $wgUser->mBlock->mReason; |
| 919 | + |
866 | 920 | if ( strval( $block_reason ) === '' ) { |
867 | 921 | $block_reason = wfMsg( 'blockednoreason' ); |
868 | 922 | } |
869 | | - |
870 | | - $wgOut->addWikiMsg( |
871 | | - 'cantcreateaccount-text', |
872 | | - $block->getTarget(), |
873 | | - $block_reason, |
874 | | - $block->getBlocker()->getName() |
875 | | - ); |
876 | | - |
| 923 | + $wgOut->addWikiMsg( 'cantcreateaccount-text', $ip, $block_reason, $blocker ); |
877 | 924 | $wgOut->returnToMain( false ); |
878 | 925 | } |
879 | 926 | |
— | — | @@ -880,11 +927,10 @@ |
881 | 928 | * @private |
882 | 929 | */ |
883 | 930 | function mainLoginForm( $msg, $msgtype = 'error' ) { |
884 | | - global $wgUser, $wgOut, $wgHiddenPrefs; |
885 | | - global $wgEnableEmail, $wgEnableUserEmail; |
| 931 | + global $wgUser, $wgOut, $wgHiddenPrefs, $wgEnableEmail; |
886 | 932 | global $wgRequest, $wgLoginLanguageSelector; |
887 | 933 | global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration; |
888 | | - global $wgSecureLogin, $wgPasswordResetRoutes; |
| 934 | + global $wgSecureLogin; |
889 | 935 | |
890 | 936 | $titleObj = SpecialPage::getTitleFor( 'Userlogin' ); |
891 | 937 | |
— | — | @@ -896,7 +942,7 @@ |
897 | 943 | $wgOut->readOnlyPage(); |
898 | 944 | return; |
899 | 945 | } elseif ( $wgUser->isBlockedFromCreateAccount() ) { |
900 | | - $this->userBlockedMessage( $wgUser->isBlockedFromCreateAccount() ); |
| 946 | + $this->userBlockedMessage(); |
901 | 947 | return; |
902 | 948 | } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) { |
903 | 949 | $wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' ); |
— | — | @@ -904,11 +950,11 @@ |
905 | 951 | } |
906 | 952 | } |
907 | 953 | |
908 | | - if ( $this->mUsername == '' ) { |
| 954 | + if ( $this->mName == '' ) { |
909 | 955 | if ( $wgUser->isLoggedIn() ) { |
910 | | - $this->mUsername = $wgUser->getName(); |
| 956 | + $this->mName = $wgUser->getName(); |
911 | 957 | } else { |
912 | | - $this->mUsername = $wgRequest->getCookie( 'UserName' ); |
| 958 | + $this->mName = $wgRequest->getCookie( 'UserName' ); |
913 | 959 | } |
914 | 960 | } |
915 | 961 | |
— | — | @@ -950,12 +996,8 @@ |
951 | 997 | $template->set( 'link', '' ); |
952 | 998 | } |
953 | 999 | |
954 | | - $resetLink = $this->mType == 'signup' |
955 | | - ? null |
956 | | - : is_array( $wgPasswordResetRoutes ) && in_array( true, array_values( $wgPasswordResetRoutes ) ); |
957 | | - |
958 | 1000 | $template->set( 'header', '' ); |
959 | | - $template->set( 'name', $this->mUsername ); |
| 1001 | + $template->set( 'name', $this->mName ); |
960 | 1002 | $template->set( 'password', $this->mPassword ); |
961 | 1003 | $template->set( 'retype', $this->mRetype ); |
962 | 1004 | $template->set( 'email', $this->mEmail ); |
— | — | @@ -970,9 +1012,7 @@ |
971 | 1013 | $template->set( 'userealname', !in_array( 'realname', $wgHiddenPrefs ) ); |
972 | 1014 | $template->set( 'useemail', $wgEnableEmail ); |
973 | 1015 | $template->set( 'emailrequired', $wgEmailConfirmToEdit ); |
974 | | - $template->set( 'emailothers', $wgEnableUserEmail ); |
975 | 1016 | $template->set( 'canreset', $wgAuth->allowPasswordChange() ); |
976 | | - $template->set( 'resetlink', $resetLink ); |
977 | 1017 | $template->set( 'canremember', ( $wgCookieExpiration > 0 ) ); |
978 | 1018 | $template->set( 'usereason', $wgUser->isLoggedIn() ); |
979 | 1019 | $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) || $this->mRemember ); |
— | — | @@ -1013,24 +1053,22 @@ |
1014 | 1054 | $wgOut->setPageTitle( wfMsg( 'userloginnocreate' ) ); |
1015 | 1055 | } |
1016 | 1056 | |
| 1057 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 1058 | + $wgOut->setArticleRelated( false ); |
1017 | 1059 | $wgOut->disallowUserJs(); // just in case... |
1018 | 1060 | $wgOut->addTemplate( $template ); |
1019 | 1061 | } |
1020 | 1062 | |
1021 | 1063 | /** |
1022 | 1064 | * @private |
1023 | | - * |
1024 | | - * @param $user User |
1025 | | - * |
1026 | | - * @return Boolean |
1027 | 1065 | */ |
1028 | 1066 | function showCreateOrLoginLink( &$user ) { |
1029 | 1067 | if( $this->mType == 'signup' ) { |
1030 | | - return true; |
| 1068 | + return( true ); |
1031 | 1069 | } elseif( $user->isAllowed( 'createaccount' ) ) { |
1032 | | - return true; |
| 1070 | + return( true ); |
1033 | 1071 | } else { |
1034 | | - return false; |
| 1072 | + return( false ); |
1035 | 1073 | } |
1036 | 1074 | } |
1037 | 1075 | |
— | — | @@ -1148,9 +1186,9 @@ |
1149 | 1187 | function makeLanguageSelector() { |
1150 | 1188 | global $wgLang; |
1151 | 1189 | |
1152 | | - $msg = wfMessage( 'loginlanguagelinks' )->inContentLanguage(); |
1153 | | - if( !$msg->isBlank() ) { |
1154 | | - $langs = explode( "\n", $msg->text() ); |
| 1190 | + $msg = wfMsgForContent( 'loginlanguagelinks' ); |
| 1191 | + if( $msg != '' && !wfEmptyMsg( 'loginlanguagelinks', $msg ) ) { |
| 1192 | + $langs = explode( "\n", $msg ); |
1155 | 1193 | $links = array(); |
1156 | 1194 | foreach( $langs as $lang ) { |
1157 | 1195 | $lang = trim( $lang, '* ' ); |