r97864 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97863‎ | r97864 | r97865 >
Date:22:22, 22 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix used constants, simplify some returns

Documentation

Remove unused global
Modified paths:
  • /trunk/extensions/SignupAPI/includes/ApiSignup.php (modified) (history)
  • /trunk/extensions/SignupAPI/includes/SpecialUserSignup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SignupAPI/includes/ApiSignup.php
@@ -39,13 +39,13 @@
4040 wfSetupSession();
4141 }
4242
43 - $signupForm = new SignupForm( $req );
 43+ $signupForm = new SpecialUserSignup( $req );
4444
4545 global $wgCookiePrefix, $wgUser;
4646
4747 $signupRes = $signupForm->addNewAccountInternal();
4848 switch( $signupRes ) {
49 - case SignupForm::SUCCESS:
 49+ case SpecialUserSignup::SUCCESS:
5050 //$signupForm->initUser($signupForm->mUser);
5151
5252 wfRunHooks( 'AddNewAccount', array( $wgUser, false ) );
@@ -66,75 +66,75 @@
6767 $result['sessionid'] = session_id();
6868 break;
6969
70 - case SignupForm::INVALID_DOMAIN:
 70+ case SpecialUserSignup::INVALID_DOMAIN:
7171 $result['result'] = 'WrongPassword';
7272 $result['domain']= $signupForm->mDomain;
7373 break;
7474
75 - case SignupForm::READ_ONLY_PAGE:
 75+ case SpecialUserSignup::READ_ONLY_PAGE:
7676 $result['result'] = 'ReadOnlyPage';
7777 break;
7878
79 - case SignupForm::NO_COOKIES:
 79+ case SpecialUserSignup::NO_COOKIES:
8080 $result['result'] = 'NoCookies';
8181 break;
8282
83 - case SignupForm::NEED_TOKEN:
 83+ case SpecialUserSignup::NEED_TOKEN:
8484 $result['result'] = 'NeedToken';
8585 $result['token'] = $signupForm->getCreateaccountToken();
8686 $result['cookieprefix'] = $wgCookiePrefix;
8787 $result['sessionid'] = session_id();
8888 break;
8989
90 - case SignupForm::WRONG_TOKEN:
 90+ case SpecialUserSignup::WRONG_TOKEN:
9191 $result['result'] = 'WrongToken';
9292 break;
9393
94 - case SignupForm::INSUFFICIENT_PERMISSION:
 94+ case SpecialUserSignup::INSUFFICIENT_PERMISSION:
9595 $result['result'] = 'InsufficientPermission';
9696 break;
9797
98 - case SignupForm::CREATE_BLOCKED:
 98+ case SpecialUserSignup::CREATE_BLOCKED:
9999 $result['result'] = 'CreateBlocked';
100100 break;
101101
102 - case SignupForm::IP_BLOCKED:
 102+ case SpecialUserSignup::IP_BLOCKED:
103103 $result['result'] = 'IPBlocked';
104104 break;
105105
106 - case SignupForm::NO_NAME:
 106+ case SpecialUserSignup::NO_NAME:
107107 $result['result'] = 'NoName';
108108 break;
109109
110 - case SignupForm::USER_EXISTS:
 110+ case SpecialUserSignup::USER_EXISTS:
111111 $result['result'] = 'UserExists';
112112 break;
113113
114 - case SignupForm::WRONG_RETYPE:
 114+ case SpecialUserSignup::WRONG_RETYPE:
115115 $result['result'] = 'WrongRetype';
116116 break;
117117
118 - case SignupForm::INVALID_PASS:
 118+ case SpecialUserSignup::INVALID_PASS:
119119 $result['result'] = 'InvalidPass';
120120 break;
121121
122 - case SignupForm::NO_EMAIL:
 122+ case SpecialUserSignup::NO_EMAIL:
123123 $result['result'] = 'NoEmail';
124124 break;
125125
126 - case SignupForm::INVALID_EMAIL:
 126+ case SpecialUserSignup::INVALID_EMAIL:
127127 $result['result'] = 'InvalidEmail';
128128 break;
129129
130 - case SignupForm::BLOCKED_BY_HOOK:
 130+ case SpecialUserSignup::BLOCKED_BY_HOOK:
131131 $result['result'] = 'BlockedByHook';
132132 break;
133133
134 - case SignupForm::EXTR_DB_ERROR:
 134+ case SpecialUserSignup::EXTR_DB_ERROR:
135135 $result['result'] = 'ExternalDBError';
136136 break;
137137
138 - case SignupForm::THROTLLED:
 138+ case SpecialUserSignup::THROTLLED:
139139 $result['result'] = 'Throttled';
140140 break;
141141
Index: trunk/extensions/SignupAPI/includes/SpecialUserSignup.php
@@ -53,7 +53,7 @@
5454 var $mAction, $mCreateaccount, $mCreateaccountMail;
5555 var $mRemember, $mEmail, $mDomain, $mLanguage;
5656 var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS;
57 - var $mType, $mReason, $mRealName;
 57+ var $mType, $mReason, $mRealName, $mUsername;
5858 var $abortError = '';
5959 var $tempUser, $mConfirmationMailStatus, $mRunCookieRedirect, $mRunCreationConfirmation;
6060 var $mSourceAction, $mSourceNS, $msourceArticle;
@@ -198,9 +198,11 @@
199199
200200 /**
201201 * @private
 202+ *
 203+ * @param $tempUser User
202204 */
203 - function addNewAccount($tempUser) {
204 - global $wgUser, $wgEmailAuthentication, $wgOut;
 205+ function addNewAccount( $tempUser ) {
 206+ global $wgUser, $wgEmailAuthentication;
205207
206208 # If we showed up language selection links, and one was in use, be
207209 # smart (and sensible) and save that language as the user's preference
@@ -243,9 +245,9 @@
244246 * @private
245247 */
246248 function addNewAccountInternal() {
247 - global $wgUser, $wgOut;
 249+ global $wgUser;
248250 global $wgMemc, $wgAccountCreationThrottle;
249 - global $wgAuth, $wgMinimalPasswordLength;
 251+ global $wgAuth;
250252 global $wgEmailConfirmToEdit;
251253
252254 // If the user passes an invalid domain, something is fishy
@@ -266,7 +268,6 @@
267269 }
268270
269271 if ( wfReadOnly() ) {
270 -
271272 return self::READ_ONLY_PAGE;
272273 }
273274
@@ -646,7 +647,6 @@
647648 return;
648649 }
649650
650 -
651651 if ( $this->mUsername == '' ) {
652652 if ( $wgUser->isLoggedIn() ) {
653653 $this->mUsername = $wgUser->getName();
@@ -752,18 +752,12 @@
753753 /**
754754 * @private
755755 *
756 - * @param $tempUserser User
 756+ * @param $tempUser User
757757 *
758758 * @return Boolean
759759 */
760 - function showCreateOrLoginLink( &$tempUserser ) {
761 - if( $this->mType == 'signup' ) {
762 - return true;
763 - } elseif( $tempUserser->isAllowed( 'createaccount' ) ) {
764 - return true;
765 - } else {
766 - return false;
767 - }
 760+ function showCreateOrLoginLink( $tempUser ) {
 761+ return $this->mType == 'signup' || $tempUser->isAllowed( 'createaccount' );
768762 }
769763
770764 /**

Status & tagging log