Index: trunk/extensions/SignupAPI/includes/ApiValidateSignup.php |
— | — | @@ -19,51 +19,48 @@ |
20 | 20 | public function execute() { |
21 | 21 | $params = $this->extractRequestParams(); |
22 | 22 | |
23 | | - $result = array(); |
| 23 | + $result = array(); |
24 | 24 | |
25 | | - switch ( $params['field'] ) { |
26 | | - case "username": |
27 | | - $mUser = User::newFromName( $params['inputVal'], 'creatable' ); |
28 | | - if ( !is_object( $mUser ) ) { |
29 | | - $result['result'] = wfMsg( 'signupapi-noname' ); |
30 | | - $result['icon'] = 'MW-Icon-AlertMark.png'; |
31 | | - } |
| 25 | + switch ( $params['field'] ) { |
| 26 | + case "username": |
| 27 | + $mUser = User::newFromName( $params['inputVal'], 'creatable' ); |
| 28 | + if ( !is_object( $mUser ) ) { |
| 29 | + $result['result'] = wfMsg( 'signupapi-noname' ); |
| 30 | + $result['icon'] = 'MW-Icon-AlertMark.png'; |
| 31 | + } |
32 | 32 | |
33 | | - if ( 0 != $mUser->idForName() ) { |
34 | | - $result['result'] = wfMsg( 'signupapi-userexists' ); |
35 | | - $result['icon'] = "MW-Icon-NoMark.png"; |
36 | | - } |
| 33 | + if ( 0 != $mUser->idForName() ) { |
| 34 | + $result['result'] = wfMsg( 'signupapi-userexists' ); |
| 35 | + $result['icon'] = "MW-Icon-NoMark.png"; |
| 36 | + } else { |
| 37 | + $result['result'] = wfMsg( 'signupapi-ok' ); |
| 38 | + $result['icon'] = "MW-Icon-CheckMark.png"; |
| 39 | + } |
| 40 | + break; |
37 | 41 | |
38 | | - else { |
39 | | - $result['result'] = wfMsg( 'signupapi-ok' ); |
40 | | - $result['icon'] = "MW-Icon-CheckMark.png"; |
41 | | - } |
42 | | - break; |
| 42 | + case "email" : |
| 43 | + if ( $valid = User::isValidEmailAddr( $params['inputVal'] ) ) { |
| 44 | + $result['result']= wfMsg( 'signupapi-ok' ); |
| 45 | + $result['icon'] = "MW-Icon-CheckMark.png"; |
| 46 | + } else { |
| 47 | + $result['result']= wfMsg( 'signupapi-invalidemailaddress' ); |
| 48 | + $result['icon'] = "MW-Icon-NoMark.png"; |
| 49 | + } |
| 50 | + break; |
43 | 51 | |
44 | | - case "email" : |
45 | | - if ( $valid = User::isValidEmailAddr( $params['inputVal'] ) ) { |
46 | | - $result['result']= wfMsg( 'signupapi-ok' ); |
47 | | - $result['icon'] = "MW-Icon-CheckMark.png"; |
48 | | - } |
49 | | - else { |
50 | | - $result['result']= wfMsg( 'signupapi-invalidemailaddress' ); |
51 | | - $result['icon'] = "MW-Icon-NoMark.png"; |
52 | | - } |
53 | | - break; |
| 52 | + case "passwordlength" : |
| 53 | + global $wgMinimalPasswordLength; |
| 54 | + $result['result'] = $wgMinimalPasswordLength; |
| 55 | + break; |
54 | 56 | |
55 | | - case "passwordlength" : |
56 | | - global $wgMinimalPasswordLength; |
57 | | - $result['result'] = $wgMinimalPasswordLength; |
58 | | - break; |
| 57 | + default : |
| 58 | + ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$params['field']}" ); |
| 59 | + } |
59 | 60 | |
60 | | - default : |
61 | | - ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$params['field']}" ); |
62 | | - } |
| 61 | + $this->getResult()->addValue( null, 'signup', $result ); |
| 62 | + } |
63 | 63 | |
64 | | - $this->getResult()->addValue( null, 'signup', $result ); |
65 | | - } |
66 | | - |
67 | | - public function mustBePosted() { |
| 64 | + public function mustBePosted() { |
68 | 65 | return false; |
69 | 66 | } |
70 | 67 | |
— | — | @@ -73,7 +70,7 @@ |
74 | 71 | |
75 | 72 | public function getAllowedParams() { |
76 | 73 | return array( |
77 | | - 'field' => null, |
| 74 | + 'field' => null, |
78 | 75 | 'inputVal' => null, |
79 | 76 | 'password' => null, |
80 | 77 | 'retype' => null, |
— | — | @@ -100,8 +97,7 @@ |
101 | 98 | return array_merge( parent::getPossibleErrors(), array( |
102 | 99 | array( 'code' => 'WrongPassword', 'info' => 'Incorrect password entered. Please try again.' ), |
103 | 100 | array( 'code' => 'ReadOnlyPage', 'info' => 'Accounts cannot be created with read-only permissions' ), |
104 | | - array( 'code' => 'NoCookies', 'info' => 'The user account was not created, as we could not confirm its source. |
105 | | - Ensure you have cookies enabled, reload this page and try again.' ), |
| 101 | + array( 'code' => 'NoCookies', 'info' => 'The user account was not created, as we could not confirm its source. Ensure you have cookies enabled, reload this page and try again.' ), |
106 | 102 | array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your signup with the specified token' ), |
107 | 103 | array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ), |
108 | 104 | array( 'code' => 'InsufficientPermission', 'info' => 'You do not have sufficient permissions to create account' ), |
— | — | @@ -125,7 +121,7 @@ |
126 | 122 | ); |
127 | 123 | } |
128 | 124 | |
129 | | - public function getVersion() { |
| 125 | + public function getVersion() { |
130 | 126 | return __CLASS__ . ': $Id: validateSignup.php 91472 2011-07-05 18:43:51Z akshay $'; |
131 | 127 | } |
132 | 128 | |
Index: trunk/extensions/SignupAPI/includes/ApiSignup.php |
— | — | @@ -27,10 +27,10 @@ |
28 | 28 | 'wpRetype' => $params['retype'], |
29 | 29 | 'wpEmail' => $params['email'], |
30 | 30 | 'wpDomain' => $params['domain'], |
31 | | - 'wpReason' => $params['realname'], |
32 | | - 'wpSourceAction' => $params['source_action'], |
33 | | - 'wpSourceNS' => $params['source_ns'], |
34 | | - 'wpSourceArticle' => $params['source_article'], |
| 31 | + 'wpReason' => $params['realname'], |
| 32 | + 'wpSourceAction' => $params['source_action'], |
| 33 | + 'wpSourceNS' => $params['source_ns'], |
| 34 | + 'wpSourceArticle' => $params['source_article'], |
35 | 35 | 'wpRemember' => '' |
36 | 36 | ) ); |
37 | 37 | |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | } |
145 | 145 | |
146 | 146 | $this->getResult()->addValue( null, 'signup', $result ); |
147 | | - } |
| 147 | + } |
148 | 148 | |
149 | 149 | public function mustBePosted() { |
150 | 150 | return true; |
— | — | @@ -160,10 +160,10 @@ |
161 | 161 | 'retype' => null, |
162 | 162 | 'email' => null, |
163 | 163 | 'domain' => null, |
164 | | - 'realname' => null, |
165 | | - 'source_action' => null, |
166 | | - 'source_ns' => null, |
167 | | - 'source_article' => null, |
| 164 | + 'realname' => null, |
| 165 | + 'source_action' => null, |
| 166 | + 'source_ns' => null, |
| 167 | + 'source_article' => null, |
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
— | — | @@ -174,10 +174,10 @@ |
175 | 175 | 'retype' => 'Re-typed Password', |
176 | 176 | 'email' => 'Email ID(optional)', |
177 | 177 | 'domain' => 'Domain (optional)', |
178 | | - 'realname' => 'Real Name(optional)', |
179 | | - 'source_action' => 'Source Action', |
180 | | - 'source_ns' => 'Source Namespace ID', |
181 | | - 'source_article' => 'Source Article ID', |
| 178 | + 'realname' => 'Real Name(optional)', |
| 179 | + 'source_action' => 'Source Action', |
| 180 | + 'source_ns' => 'Source Namespace ID', |
| 181 | + 'source_article' => 'Source Article ID', |
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
— | — | @@ -198,7 +198,7 @@ |
199 | 199 | array( 'code' => 'WrongPassword', 'info' => 'Incorrect password entered. Please try again.' ), |
200 | 200 | array( 'code' => 'ReadOnlyPage', 'info' => 'Accounts cannot be created with read-only permissions' ), |
201 | 201 | array( 'code' => 'NoCookies', 'info' => 'The user account was not created, as we could not confirm its source. |
202 | | - Ensure you have cookies enabled, reload this page and try again.' ), |
| 202 | + Ensure you have cookies enabled, reload this page and try again.' ), |
203 | 203 | array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your signup with the specified token' ), |
204 | 204 | array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ), |
205 | 205 | array( 'code' => 'InsufficientPermission', 'info' => 'You do not have sufficient permissions to create account' ), |