http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90788
Revision: 90788
Author: reedy
Date: 2011-06-25 19:29:15 +0000 (Sat, 25 Jun 2011)
Log Message:
-----------
Fixup whitespace, remove unused globals
Modified Paths:
--------------
trunk/extensions/SignupAPI/includes/APISignup.php
trunk/extensions/SignupAPI/includes/SpecialUserSignup.php
Modified: trunk/extensions/SignupAPI/includes/APISignup.php
===================================================================
--- trunk/extensions/SignupAPI/includes/APISignup.php 2011-06-25 19:27:53 UTC
(rev 90787)
+++ trunk/extensions/SignupAPI/includes/APISignup.php 2011-06-25 19:29:15 UTC
(rev 90788)
@@ -11,11 +11,11 @@
* @ingroup API
*/
class ApiSignup extends ApiBase {
-
+
public function __construct( $main, $action ) {
parent::__construct( $main, $action);
}
-
+
public function execute() {
$params = $this->extractRequestParams();
@@ -29,31 +29,31 @@
'wpDomain' => $params['domain'],
'wpRemember' => ''
) );
-
+
// Init session if necessary
if ( session_id() == '' ) {
wfSetupSession();
}
-
+
$signupForm = new SignupForm( $req );
-
- global $wgCookiePrefix, $wgUser, $wgAccountCreationThrottle;
-
+
+ global $wgCookiePrefix, $wgUser;
+
$signupRes = $signupForm->addNewAccountInternal();
switch( $signupRes ) {
case SignupForm::SUCCESS:
$signupForm->initUser();
-
+
wfRunHooks( 'AddNewAccount', array( $wgUser,
false ) );
# Run any hooks; display injected HTML
$injected_html = '';
$welcome_creation_msg = 'welcomecreation';
-
+
wfRunHooks( 'UserLoginComplete', array(
&$wgUser, &$injected_html ) );
-
+
//let any extensions change what message is
shown
wfRunHooks( 'BeforeWelcomeCreation', array(
&$welcome_creation_msg, &$injected_html ) );
-
+
$result['result'] = 'Success';
$result['lguserid'] = intval( $wgUser->getId()
);
$result['lgusername'] = $wgUser->getName();
@@ -61,94 +61,94 @@
$result['cookieprefix'] = $wgCookiePrefix;
$result['sessionid'] = session_id();
break;
-
+
case SignupForm::INVALID_DOMAIN:
$result['result'] = 'WrongPassword';
$result['domain']= $signupForm->mDomain;
break;
-
+
case SignupForm::READ_ONLY_PAGE:
$result['result'] = 'ReadOnlyPage';
break;
-
+
case SignupForm::NO_COOKIES:
$result['result'] = 'NoCookies';
break;
-
+
case SignupForm::NEED_TOKEN:
$result['result'] = 'NeedToken';
$result['token'] =
$signupForm->getCreateaccountToken();
$result['cookieprefix'] = $wgCookiePrefix;
$result['sessionid'] = session_id();
break;
-
+
case SignupForm::WRONG_TOKEN:
$result['result'] = 'WrongToken';
break;
-
+
case SignupForm::INSUFFICIENT_PERMISSION:
$result['result'] = 'InsufficientPermission';
break;
-
+
case SignupForm::CREATE_BLOCKED:
$result['result'] = 'CreateBlocked';
break;
-
+
case SignupForm::IP_BLOCKED:
$result['result'] = 'IPBlocked';
break;
-
+
case SignupForm::NO_NAME:
$result['result'] = 'NoName';
break;
-
+
case SignupForm::USER_EXISTS:
$result['result'] = 'UserExists';
break;
-
+
case SignupForm::WRONG_RETYPE:
$result['result'] = 'WrongRetype';
break;
-
+
case SignupForm::INVALID_PASS:
$result['result'] = 'InvalidPass';
break;
-
+
case SignupForm::NO_EMAIL:
$result['result'] = 'NoEmail';
break;
-
+
case SignupForm::INVALID_EMAIL:
$result['result'] = 'InvalidEmail';
break;
-
+
case SignupForm::BLOCKED_BY_HOOK:
$result['result'] = 'BlockedByHook';
break;
-
+
case SignupForm::EXTR_DB_ERROR:
$result['result'] = 'ExternalDBError';
break;
-
+
case SignupForm::THROTLLED:
$result['result'] = 'Throttled';
break;
-
+
default:
ApiBase::dieDebug( __METHOD__, "Unhandled case
value: {$signupRes}" );
}
-
- $this->getResult()->addValue( null, 'signup', $result );
+
+ $this->getResult()->addValue( null, 'signup', $result );
}
-
+
public function mustBePosted() {
return true;
}
-
+
public function isReadMode() {
return false;
}
-
+
public function getAllowedParams() {
return array(
'name' => null,
@@ -168,9 +168,9 @@
'domain' => 'Domain (optional)',
);
}
-
-
+
+
public function getDescription() {
return array(
'This module validates the parameters posted by the
signup form.',
@@ -215,7 +215,6 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-
+
}
-
-
\ No newline at end of file
+
Modified: trunk/extensions/SignupAPI/includes/SpecialUserSignup.php
===================================================================
--- trunk/extensions/SignupAPI/includes/SpecialUserSignup.php 2011-06-25
19:27:53 UTC (rev 90787)
+++ trunk/extensions/SignupAPI/includes/SpecialUserSignup.php 2011-06-25
19:29:15 UTC (rev 90788)
@@ -29,7 +29,7 @@
class SignupForm extends SpecialPage {
const SUCCESS = 0;
- const NO_NAME = 1;
+ const NO_NAME = 1;
const CREATE_BLOCKED = 2;
const NEED_TOKEN = 3;
const WRONG_TOKEN = 4;
@@ -82,7 +82,7 @@
* @param $request WebRequest object
*/
function load( $request ) {
- global $wgAuth, $wgHiddenPrefs, $wgEnableEmail,
$wgRedirectOnLogin;
+ global $wgAuth, $wgHiddenPrefs, $wgEnableEmail;
$this->mType = $request->getText( 'type' );
$this->mUsername = $request->getText( 'wpName' );
@@ -102,9 +102,9 @@
$this->mStickHTTPS = $request->getCheck( 'wpStickHTTPS' );
$this->mLanguage = $request->getText( 'uselang' );
$this->mSkipCookieCheck = $request->getCheck(
'wpSkipCookieCheck' );
-
+
//Decide whether login or signup request
-
+
$this->mToken = $request->getVal( 'wpCreateaccountToken' );
if( $wgEnableEmail ) {
@@ -112,7 +112,7 @@
} else {
$this->mEmail = '';
}
-
+
if( !in_array( 'realname', $wgHiddenPrefs ) ) {
$this->mRealName = $request->getText( 'wpRealName' );
} else {
@@ -142,7 +142,7 @@
return $this->processSignup();
} elseif ( $this->mCreateaccountMail ) {
return $this->addNewAccountMailPassword();
- }
+ }
}
$this->mainSignupForm( '' );
}
@@ -262,13 +262,13 @@
// to check this for domains that aren't local.
if( 'local' != $this->mDomain && $this->mDomain != '' ) {
if( !$wgAuth->canCreateAccounts() && (
!$wgAuth->userExists( $this->mUsername )
- || !$wgAuth->authenticate( $this->mUsername,
$this->mPassword ) ) ) {
+ || !$wgAuth->authenticate( $this->mUsername,
$this->mPassword ) ) ) {
return self::INVALID_DOMAIN;
}
}
if ( wfReadOnly() ) {
-
+
return self::READ_ONLY_PAGE;
}
@@ -284,7 +284,7 @@
}
# Validate the createaccount token
- if ( $this->mToken !== self::getCreateaccountToken() ) {
+ if ( $this->mToken !== self::getCreateaccountToken() ) {
return self::WRONG_TOKEN;
}
@@ -332,9 +332,9 @@
if ( $wgEmailConfirmToEdit && empty( $this->mEmail ) ) {
return self::NO_EMAIL;
}
-
+
# if email is provided then validate it
- if( !empty( $this->mEmail ) && !User::isValidEmailAddr(
$this->mEmail ) ) {
+ if( !empty( $this->mEmail ) && !Sanitizer::validateEmail(
$this->mEmail ) ) {
return self::INVALID_EMAIL;
}
@@ -413,15 +413,14 @@
return $mUser;
}
-
function processSignup() {
global $wgUser, $wgOut;
-
+
switch ( $this->addNewAccountInternal() ) {
case self::SUCCESS:
//$this->initUser( $mUser, false );
//$this->addNewAccount($mUser);
- break;
+ break;
case self::INVALID_DOMAIN:
$this->mainSignupForm( wfMsg( 'wrongpassword' )
);
break;
@@ -488,8 +487,6 @@
}
}
-
-
/**
* @param $mUser User object
* @param $throttle Boolean
@@ -522,8 +519,6 @@
return $result;
}
-
-
/**
* Run any hooks registered for logins, then display a message welcoming
* the user.
@@ -535,12 +530,12 @@
# Run any hooks; display injected HTML
$injected_html = '';
$welcome_creation_msg = 'welcomecreation';
-
+
wfRunHooks( 'UserLoginComplete', array( &$wgUser,
&$injected_html ) );
-
+
//let any extensions change what message is shown
wfRunHooks( 'BeforeWelcomeCreation', array(
&$welcome_creation_msg, &$injected_html ) );
-
+
$this->displaySuccessfulCreation( $welcome_creation_msg,
$injected_html );
}
@@ -575,7 +570,7 @@
$block_reason,
$block->getBlocker()->getName()
);
-
+
$wgOut->returnToMain( false );
}
@@ -585,28 +580,27 @@
function mainSignupForm( $msg, $msgtype = 'error' ) {
global $wgUser, $wgOut, $wgHiddenPrefs;
global $wgEnableEmail, $wgEnableUserEmail;
- global $wgRequest, $wgLoginLanguageSelector;
+ global $wgLoginLanguageSelector;
global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
global $wgSecureLogin, $wgPasswordResetRoutes;
$titleObj = SpecialPage::getTitleFor( 'Usersignup' );
-
- // Block signup here if in readonly. Keeps user from
- // going through the process (filling out data, etc)
- // and being informed later.
- if ( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
- $this->userBlockedMessage(
$wgUser->isBlockedFromCreateAccount() );
- return;
- } elseif ( count( $permErrors =
$titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) {
- $wgOut->showPermissionsErrorPage( $permErrors,
'createaccount' );
- return;
- }
-
+ // Block signup here if in readonly. Keeps user from
+ // going through the process (filling out data, etc)
+ // and being informed later.
+ if ( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
+ $this->userBlockedMessage(
$wgUser->isBlockedFromCreateAccount() );
+ return;
+ } elseif ( count( $permErrors =
$titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) {
+ $wgOut->showPermissionsErrorPage( $permErrors,
'createaccount' );
+ return;
+ }
+
if ( $this->mUsername == '' ) {
if ( $wgUser->isLoggedIn() ) {
$this->mUsername = $wgUser->getName();
@@ -615,13 +609,11 @@
}
}
-
$template = new UsercreateTemplate();
$q = 'action=submitlogin&type=signup';
$linkq = 'type=login';
$linkmsg = 'gotaccount';
-
-
+
if ( !empty( $this->mReturnTo ) ) {
$returnto = '&returnto=' . wfUrlencode(
$this->mReturnTo );
if ( !empty( $this->mReturnToQuery ) ) {
@@ -677,13 +669,11 @@
$template->set( 'cansecurelogin', ( $wgSecureLogin === true ) );
$template->set( 'stickHTTPS', $this->mStickHTTPS );
-
if ( !self::getCreateaccountToken() ) {
self::setCreateaccountToken();
}
$template->set( 'token', self::getCreateaccountToken() );
-
-
+
# Prepare language selection links as needed
if( $wgLoginLanguageSelector ) {
$template->set( 'languages',
$this->makeLanguageSelector() );
@@ -693,9 +683,8 @@
// Give authentication and captcha plugins a chance to modify
the form
$wgAuth->modifyUITemplate( $template, $this->mType );
-
+
wfRunHooks( 'UserCreateForm', array( &$template ) );
-
// Changes the title depending on permissions for creating
account
if ( $wgUser->isAllowed( 'createaccount' ) ) {
@@ -803,7 +792,7 @@
*
* @return string
*/
-
+
function makeLanguageSelector() {
global $wgLang;
@@ -849,7 +838,7 @@
$attr
);
}
-
+
/**
* Display a "login successful" page.
*/
@@ -860,7 +849,7 @@
if( $msgname ){
$wgOut->addWikiMsg( $msgname, $wgUser->getName() );
}
-
+
$wgOut->addHTML( $injected_html );
if ( !empty( $this->mReturnTo ) ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs