Index: trunk/phase3/includes/specials/SpecialUserlogin.php |
— | — | @@ -22,24 +22,11 @@ |
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 | | -/** |
39 | 26 | * Implements Special:UserLogin |
40 | 27 | * |
41 | 28 | * @ingroup SpecialPage |
42 | 29 | */ |
43 | | -class LoginForm { |
| 30 | +class LoginForm extends SpecialPage { |
44 | 31 | |
45 | 32 | const SUCCESS = 0; |
46 | 33 | const NO_NAME = 1; |
— | — | @@ -59,40 +46,51 @@ |
60 | 47 | var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
61 | 48 | var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword; |
62 | 49 | var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage; |
63 | | - var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS; |
| 50 | + var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS, $mRequest; |
64 | 51 | |
65 | 52 | private $mExtUser = null; |
66 | 53 | |
| 54 | + public function __construct( $request = null ) { |
| 55 | + if ( $request === null ) { |
| 56 | + global $wgRequest; |
| 57 | + $this->mRequest = $wgRequest; |
| 58 | + } else { |
| 59 | + $this->mRequest = $request; |
| 60 | + } |
| 61 | + |
| 62 | + parent::__construct( 'Userlogin' ); |
| 63 | + } |
| 64 | + |
67 | 65 | /** |
68 | | - * Constructor |
69 | | - * @param $request WebRequest: a WebRequest object passed by reference |
| 66 | + * Loader |
| 67 | + * |
70 | 68 | * @param $par String: subpage parameter |
71 | 69 | */ |
72 | | - function __construct( &$request, $par = '' ) { |
| 70 | + function load( $par ) { |
73 | 71 | global $wgAuth, $wgHiddenPrefs, $wgEnableEmail, $wgRedirectOnLogin; |
74 | 72 | |
75 | | - $this->mType = ( $par == 'signup' ) ? $par : $request->getText( 'type' ); # Check for [[Special:Userlogin/signup]] |
76 | | - $this->mName = $request->getText( 'wpName' ); |
77 | | - $this->mPassword = $request->getText( 'wpPassword' ); |
78 | | - $this->mRetype = $request->getText( 'wpRetype' ); |
79 | | - $this->mDomain = $request->getText( 'wpDomain' ); |
80 | | - $this->mReason = $request->getText( 'wpReason' ); |
81 | | - $this->mReturnTo = $request->getVal( 'returnto' ); |
82 | | - $this->mReturnToQuery = $request->getVal( 'returntoquery' ); |
83 | | - $this->mCookieCheck = $request->getVal( 'wpCookieCheck' ); |
84 | | - $this->mPosted = $request->wasPosted(); |
85 | | - $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' ); |
86 | | - $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' ) |
| 73 | + $this->mType = ( $par == 'signup' ) ? $par : $this->mRequest->getText( 'type' ); # Check for [[Special:Userlogin/signup]] |
| 74 | + $this->mName = $this->mRequest->getText( 'wpName' ); |
| 75 | + $this->mPassword = $this->mRequest->getText( 'wpPassword' ); |
| 76 | + $this->mRetype = $this->mRequest->getText( 'wpRetype' ); |
| 77 | + $this->mDomain = $this->mRequest->getText( 'wpDomain' ); |
| 78 | + $this->mReason = $this->mRequest->getText( 'wpReason' ); |
| 79 | + $this->mReturnTo = $this->mRequest->getVal( 'returnto' ); |
| 80 | + $this->mReturnToQuery = $this->mRequest->getVal( 'returntoquery' ); |
| 81 | + $this->mCookieCheck = $this->mRequest->getVal( 'wpCookieCheck' ); |
| 82 | + $this->mPosted = $this->mRequest->wasPosted(); |
| 83 | + $this->mCreateaccount = $this->mRequest->getCheck( 'wpCreateaccount' ); |
| 84 | + $this->mCreateaccountMail = $this->mRequest->getCheck( 'wpCreateaccountMail' ) |
87 | 85 | && $wgEnableEmail; |
88 | | - $this->mMailmypassword = $request->getCheck( 'wpMailmypassword' ) |
| 86 | + $this->mMailmypassword = $this->mRequest->getCheck( 'wpMailmypassword' ) |
89 | 87 | && $wgEnableEmail; |
90 | | - $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' ); |
91 | | - $this->mAction = $request->getVal( 'action' ); |
92 | | - $this->mRemember = $request->getCheck( 'wpRemember' ); |
93 | | - $this->mStickHTTPS = $request->getCheck( 'wpStickHTTPS' ); |
94 | | - $this->mLanguage = $request->getText( 'uselang' ); |
95 | | - $this->mSkipCookieCheck = $request->getCheck( 'wpSkipCookieCheck' ); |
96 | | - $this->mToken = ( $this->mType == 'signup' ) ? $request->getVal( 'wpCreateaccountToken' ) : $request->getVal( 'wpLoginToken' ); |
| 88 | + $this->mLoginattempt = $this->mRequest->getCheck( 'wpLoginattempt' ); |
| 89 | + $this->mAction = $this->mRequest->getVal( 'action' ); |
| 90 | + $this->mRemember = $this->mRequest->getCheck( 'wpRemember' ); |
| 91 | + $this->mStickHTTPS = $this->mRequest->getCheck( 'wpStickHTTPS' ); |
| 92 | + $this->mLanguage = $this->mRequest->getText( 'uselang' ); |
| 93 | + $this->mSkipCookieCheck = $this->mRequest->getCheck( 'wpSkipCookieCheck' ); |
| 94 | + $this->mToken = ( $this->mType == 'signup' ) ? $this->mRequest->getVal( 'wpCreateaccountToken' ) : $this->mRequest->getVal( 'wpLoginToken' ); |
97 | 95 | |
98 | 96 | if ( $wgRedirectOnLogin ) { |
99 | 97 | $this->mReturnTo = $wgRedirectOnLogin; |
— | — | @@ -100,12 +98,12 @@ |
101 | 99 | } |
102 | 100 | |
103 | 101 | if( $wgEnableEmail ) { |
104 | | - $this->mEmail = $request->getText( 'wpEmail' ); |
| 102 | + $this->mEmail = $this->mRequest->getText( 'wpEmail' ); |
105 | 103 | } else { |
106 | 104 | $this->mEmail = ''; |
107 | 105 | } |
108 | 106 | if( !in_array( 'realname', $wgHiddenPrefs ) ) { |
109 | | - $this->mRealName = $request->getText( 'wpRealName' ); |
| 107 | + $this->mRealName = $this->mRequest->getText( 'wpRealName' ); |
110 | 108 | } else { |
111 | 109 | $this->mRealName = ''; |
112 | 110 | } |
— | — | @@ -123,7 +121,13 @@ |
124 | 122 | } |
125 | 123 | } |
126 | 124 | |
127 | | - function execute() { |
| 125 | + public function execute( $par ) { |
| 126 | + if ( session_id() == '' ) { |
| 127 | + wfSetupSession(); |
| 128 | + } |
| 129 | + |
| 130 | + $this->load( $par ); |
| 131 | + |
128 | 132 | if ( !is_null( $this->mCookieCheck ) ) { |
129 | 133 | $this->onCookieRedirectCheck( $this->mCookieCheck ); |
130 | 134 | return; |
— | — | @@ -167,8 +171,6 @@ |
168 | 172 | $u->addNewUserLogEntry( true, $this->mReason ); |
169 | 173 | |
170 | 174 | $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) ); |
171 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
172 | | - $wgOut->setArticleRelated( false ); |
173 | 175 | |
174 | 176 | if( !$result->isGood() ) { |
175 | 177 | $this->mainLoginForm( wfMsg( 'mailerror', $result->getWikiText() ) ); |
— | — | @@ -227,8 +229,6 @@ |
228 | 230 | # Confirm that the account was created |
229 | 231 | $self = SpecialPage::getTitleFor( 'Userlogin' ); |
230 | 232 | $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); |
231 | | - $wgOut->setArticleRelated( false ); |
232 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
233 | 233 | $wgOut->addHTML( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) ); |
234 | 234 | $wgOut->returnToMain( false, $self ); |
235 | 235 | wfRunHooks( 'AddNewAccount', array( $u, false ) ); |
— | — | @@ -884,8 +884,6 @@ |
885 | 885 | global $wgOut, $wgUser; |
886 | 886 | |
887 | 887 | $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) ); |
888 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
889 | | - $wgOut->setArticleRelated( false ); |
890 | 888 | $wgOut->addWikiMsg( $msgname, $wgUser->getName() ); |
891 | 889 | $wgOut->addHTML( $injected_html ); |
892 | 890 | |
— | — | @@ -909,8 +907,6 @@ |
910 | 908 | # out. |
911 | 909 | |
912 | 910 | $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) ); |
913 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
914 | | - $wgOut->setArticleRelated( false ); |
915 | 911 | |
916 | 912 | $ip = wfGetIP(); |
917 | 913 | $blocker = User::whoIs( $wgUser->mBlock->mBy ); |
— | — | @@ -1057,8 +1053,6 @@ |
1058 | 1054 | $wgOut->setPageTitle( wfMsg( 'userloginnocreate' ) ); |
1059 | 1055 | } |
1060 | 1056 | |
1061 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1062 | | - $wgOut->setArticleRelated( false ); |
1063 | 1057 | $wgOut->disallowUserJs(); // just in case... |
1064 | 1058 | $wgOut->addTemplate( $template ); |
1065 | 1059 | } |
Index: trunk/phase3/includes/specials/SpecialResetpass.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | $data['wpRemember'] = 1; |
83 | 83 | } |
84 | 84 | $login = new LoginForm( new FauxRequest( $data, true ) ); |
85 | | - $login->execute(); |
| 85 | + $login->execute( null ); |
86 | 86 | } |
87 | 87 | $this->doReturnTo(); |
88 | 88 | } catch( PasswordError $e ) { |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | 'Listredirects' => array( 'SpecialPage', 'Listredirects' ), |
118 | 118 | |
119 | 119 | # Login/create account |
120 | | - 'Userlogin' => array( 'SpecialPage', 'Userlogin' ), |
| 120 | + 'Userlogin' => 'LoginForm', |
121 | 121 | 'CreateAccount' => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ), |
122 | 122 | |
123 | 123 | # Users and rights |