r97863 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97862‎ | r97863 | r97864 >
Date:22:16, 22 September 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Fix indenting, mixed spaces/tabs
Modified paths:
  • /trunk/extensions/SignupAPI/includes/ApiSignup.php (modified) (history)
  • /trunk/extensions/SignupAPI/includes/ApiValidateSignup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SignupAPI/includes/ApiValidateSignup.php
@@ -19,51 +19,48 @@
2020 public function execute() {
2121 $params = $this->extractRequestParams();
2222
23 - $result = array();
 23+ $result = array();
2424
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+ }
3232
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;
3741
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;
4351
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;
5456
55 - case "passwordlength" :
56 - global $wgMinimalPasswordLength;
57 - $result['result'] = $wgMinimalPasswordLength;
58 - break;
 57+ default :
 58+ ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$params['field']}" );
 59+ }
5960
60 - default :
61 - ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$params['field']}" );
62 - }
 61+ $this->getResult()->addValue( null, 'signup', $result );
 62+ }
6363
64 - $this->getResult()->addValue( null, 'signup', $result );
65 - }
66 -
67 - public function mustBePosted() {
 64+ public function mustBePosted() {
6865 return false;
6966 }
7067
@@ -73,7 +70,7 @@
7471
7572 public function getAllowedParams() {
7673 return array(
77 - 'field' => null,
 74+ 'field' => null,
7875 'inputVal' => null,
7976 'password' => null,
8077 'retype' => null,
@@ -100,8 +97,7 @@
10198 return array_merge( parent::getPossibleErrors(), array(
10299 array( 'code' => 'WrongPassword', 'info' => 'Incorrect password entered. Please try again.' ),
103100 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.' ),
106102 array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your signup with the specified token' ),
107103 array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ),
108104 array( 'code' => 'InsufficientPermission', 'info' => 'You do not have sufficient permissions to create account' ),
@@ -125,7 +121,7 @@
126122 );
127123 }
128124
129 - public function getVersion() {
 125+ public function getVersion() {
130126 return __CLASS__ . ': $Id: validateSignup.php 91472 2011-07-05 18:43:51Z akshay $';
131127 }
132128
Index: trunk/extensions/SignupAPI/includes/ApiSignup.php
@@ -27,10 +27,10 @@
2828 'wpRetype' => $params['retype'],
2929 'wpEmail' => $params['email'],
3030 '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'],
3535 'wpRemember' => ''
3636 ) );
3737
@@ -143,7 +143,7 @@
144144 }
145145
146146 $this->getResult()->addValue( null, 'signup', $result );
147 - }
 147+ }
148148
149149 public function mustBePosted() {
150150 return true;
@@ -160,10 +160,10 @@
161161 'retype' => null,
162162 'email' => null,
163163 '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,
168168 );
169169 }
170170
@@ -174,10 +174,10 @@
175175 'retype' => 'Re-typed Password',
176176 'email' => 'Email ID(optional)',
177177 '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',
182182 );
183183 }
184184
@@ -198,7 +198,7 @@
199199 array( 'code' => 'WrongPassword', 'info' => 'Incorrect password entered. Please try again.' ),
200200 array( 'code' => 'ReadOnlyPage', 'info' => 'Accounts cannot be created with read-only permissions' ),
201201 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.' ),
203203 array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your signup with the specified token' ),
204204 array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ),
205205 array( 'code' => 'InsufficientPermission', 'info' => 'You do not have sufficient permissions to create account' ),

Comments

#Comment by Nikerabbit (talk | contribs)   06:03, 23 September 2011

Some of the tabs are excessive, like

+						'field' => null,
 			'inputVal' => null
---
 			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.' ),
+																 Ensure you have cookies enabled, reload this page and try again.' ),
#Comment by Reedy (talk | contribs)   14:02, 23 September 2011

Yup, I look to have dealt with these in r97865, bar the last one, will commit that with something else later

Status & tagging log