Index: trunk/phase3/includes/api/ApiLogin.php |
— | — | @@ -1,11 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -/* |
| 4 | +/** |
5 | 5 | * Created on Sep 19, 2006 |
6 | 6 | * |
7 | 7 | * API for MediaWiki 1.8+ |
8 | 8 | * |
9 | | - * Copyright (C) 2006-2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com, |
| 9 | + * Copyright © 2006-2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com, |
10 | 10 | * Daniel Cannon (cannon dot danielc at gmail dot com) |
11 | 11 | * |
12 | 12 | * This program is free software; you can redistribute it and/or modify |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | |
28 | 28 | if ( !defined( 'MEDIAWIKI' ) ) { |
29 | 29 | // Eclipse helper - will be ignored in production |
30 | | - require_once ( 'ApiBase.php' ); |
| 30 | + require_once( 'ApiBase.php' ); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | class ApiLogin extends ApiBase { |
39 | 39 | |
40 | 40 | public function __construct( $main, $action ) { |
41 | | - parent :: __construct( $main, $action, 'lg' ); |
| 41 | + parent::__construct( $main, $action, 'lg' ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
— | — | @@ -48,15 +48,13 @@ |
49 | 49 | * user, or any other reason, the host is cached with an expiry |
50 | 50 | * and no log-in attempts will be accepted until that expiry |
51 | 51 | * is reached. The expiry is $this->mLoginThrottle. |
52 | | - * |
53 | | - * @access public |
54 | 52 | */ |
55 | 53 | public function execute() { |
56 | 54 | $params = $this->extractRequestParams(); |
57 | 55 | |
58 | | - $result = array (); |
| 56 | + $result = array(); |
59 | 57 | |
60 | | - $req = new FauxRequest( array ( |
| 58 | + $req = new FauxRequest( array( |
61 | 59 | 'wpName' => $params['name'], |
62 | 60 | 'wpPassword' => $params['password'], |
63 | 61 | 'wpDomain' => $params['domain'], |
— | — | @@ -70,7 +68,7 @@ |
71 | 69 | |
72 | 70 | $loginForm = new LoginForm( $req ); |
73 | 71 | switch ( $authRes = $loginForm->authenticateUserData() ) { |
74 | | - case LoginForm :: SUCCESS : |
| 72 | + case LoginForm::SUCCESS: |
75 | 73 | global $wgUser, $wgCookiePrefix; |
76 | 74 | |
77 | 75 | $wgUser->setOption( 'rememberpassword', 1 ); |
— | — | @@ -89,48 +87,48 @@ |
90 | 88 | $result['sessionid'] = session_id(); |
91 | 89 | break; |
92 | 90 | |
93 | | - case LoginForm :: NO_NAME : |
| 91 | + case LoginForm::NO_NAME: |
94 | 92 | $result['result'] = 'NoName'; |
95 | 93 | break; |
96 | 94 | |
97 | | - case LoginForm :: ILLEGAL : |
| 95 | + case LoginForm::ILLEGAL: |
98 | 96 | $result['result'] = 'Illegal'; |
99 | 97 | break; |
100 | 98 | |
101 | | - case LoginForm :: WRONG_PLUGIN_PASS : |
| 99 | + case LoginForm::WRONG_PLUGIN_PASS: |
102 | 100 | $result['result'] = 'WrongPluginPass'; |
103 | 101 | break; |
104 | 102 | |
105 | | - case LoginForm :: NOT_EXISTS : |
| 103 | + case LoginForm::NOT_EXISTS: |
106 | 104 | $result['result'] = 'NotExists'; |
107 | 105 | break; |
108 | | - |
109 | | - case LoginForm :: RESET_PASS : // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin - "The e-mailed temporary password should not be used for actual logins;" |
110 | | - case LoginForm :: WRONG_PASS : |
| 106 | + |
| 107 | + case LoginForm::RESET_PASS: // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin - "The e-mailed temporary password should not be used for actual logins;" |
| 108 | + case LoginForm::WRONG_PASS: |
111 | 109 | $result['result'] = 'WrongPass'; |
112 | 110 | break; |
113 | 111 | |
114 | | - case LoginForm :: EMPTY_PASS : |
| 112 | + case LoginForm::EMPTY_PASS: |
115 | 113 | $result['result'] = 'EmptyPass'; |
116 | 114 | break; |
117 | 115 | |
118 | | - case LoginForm :: CREATE_BLOCKED : |
| 116 | + case LoginForm::CREATE_BLOCKED: |
119 | 117 | $result['result'] = 'CreateBlocked'; |
120 | 118 | $result['details'] = 'Your IP address is blocked from account creation'; |
121 | 119 | break; |
122 | 120 | |
123 | | - case LoginForm :: THROTTLED : |
| 121 | + case LoginForm::THROTTLED: |
124 | 122 | global $wgPasswordAttemptThrottle; |
125 | 123 | $result['result'] = 'Throttled'; |
126 | 124 | $result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] ); |
127 | 125 | break; |
128 | | - |
129 | | - case LoginForm :: USER_BLOCKED : |
| 126 | + |
| 127 | + case LoginForm::USER_BLOCKED: |
130 | 128 | $result['result'] = 'Blocked'; |
131 | 129 | break; |
132 | 130 | |
133 | | - default : |
134 | | - ApiBase :: dieDebug( __METHOD__, "Unhandled case value: {$authRes}" ); |
| 131 | + default: |
| 132 | + ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$authRes}" ); |
135 | 133 | } |
136 | 134 | |
137 | 135 | $this->getResult()->addValue( null, 'login', $result ); |
— | — | @@ -145,7 +143,7 @@ |
146 | 144 | } |
147 | 145 | |
148 | 146 | public function getAllowedParams() { |
149 | | - return array ( |
| 147 | + return array( |
150 | 148 | 'name' => null, |
151 | 149 | 'password' => null, |
152 | 150 | 'domain' => null |
— | — | @@ -153,7 +151,7 @@ |
154 | 152 | } |
155 | 153 | |
156 | 154 | public function getParamDescription() { |
157 | | - return array ( |
| 155 | + return array( |
158 | 156 | 'name' => 'User Name', |
159 | 157 | 'password' => 'Password', |
160 | 158 | 'domain' => 'Domain (optional)' |
— | — | @@ -161,7 +159,7 @@ |
162 | 160 | } |
163 | 161 | |
164 | 162 | public function getDescription() { |
165 | | - return array ( |
| 163 | + return array( |
166 | 164 | 'This module is used to login and get the authentication tokens. ', |
167 | 165 | 'In the event of a successful log-in, a cookie will be attached', |
168 | 166 | 'to your session. In the event of a failed log-in, you will not ', |
— | — | @@ -169,9 +167,9 @@ |
170 | 168 | 'This is to prevent password guessing by automated password crackers.' |
171 | 169 | ); |
172 | 170 | } |
173 | | - |
| 171 | + |
174 | 172 | public function getPossibleErrors() { |
175 | | - return array_merge( parent::getPossibleErrors(), array ( |
| 173 | + return array_merge( parent::getPossibleErrors(), array( |
176 | 174 | array( 'code' => 'NoName', 'info' => 'You didn\'t set the lgname parameter' ), |
177 | 175 | array( 'code' => 'Illegal', 'info' => ' You provided an illegal username' ), |
178 | 176 | array( 'code' => 'NotExists', 'info' => ' The username you provided doesn\'t exist' ), |
— | — | @@ -181,8 +179,7 @@ |
182 | 180 | array( 'code' => 'CreateBlocked', 'info' => 'The wiki tried to automatically create a new account for you, but your IP address has been blocked from account creation' ), |
183 | 181 | array( 'code' => 'Throttled', 'info' => 'You\'ve logged in too many times in a short time' ), |
184 | 182 | array( 'code' => 'Blocked', 'info' => 'User is blocked' ), |
185 | | - ) ); |
186 | | -; |
| 183 | + ) ); |
187 | 184 | } |
188 | 185 | |
189 | 186 | protected function getExamples() { |