Merge "Unsetting the email address for a user when the email address is invalidated."
[lhc/web/wiklou.git] / includes / api / ApiCreateAccount.php
index 7727b28..35bba17 100644 (file)
@@ -90,7 +90,6 @@ class ApiCreateAccount extends ApiBase {
                $result = array();
                if ( $status->isGood() ) {
                        // Success!
-                       global $wgEmailAuthentication;
                        $user = $status->getValue();
 
                        if ( $params['language'] ) {
@@ -106,7 +105,7 @@ class ApiCreateAccount extends ApiBase {
                                        'createaccount-title',
                                        'createaccount-text'
                                ) );
-                       } elseif ( $wgEmailAuthentication && Sanitizer::validateEmail( $user->getEmail() ) ) {
+                       } elseif ( $this->getConfig()->get( 'EmailAuthentication' ) && Sanitizer::validateEmail( $user->getEmail() ) ) {
                                // Send out an email authentication message if needed
                                $status->merge( $user->sendConfirmationMail() );
                        }
@@ -138,13 +137,13 @@ class ApiCreateAccount extends ApiBase {
                        // since not having the correct token is part of the normal
                        // flow of events.
                        $result['token'] = LoginForm::getCreateaccountToken();
-                       $result['result'] = 'needtoken';
+                       $result['result'] = 'NeedToken';
                } elseif ( !$status->isOK() ) {
                        // There was an error. Die now.
                        $this->dieStatus( $status );
                } elseif ( !$status->isGood() ) {
                        // Status is not good, but OK. This means warnings.
-                       $result['result'] = 'warning';
+                       $result['result'] = 'Warning';
 
                        // Add any warnings to the result
                        $warnings = $status->getErrorsByType( 'warning' );
@@ -157,7 +156,7 @@ class ApiCreateAccount extends ApiBase {
                        }
                } else {
                        // Everything was fine.
-                       $result['result'] = 'success';
+                       $result['result'] = 'Success';
                }
 
                // Give extensions a chance to modify the API result data
@@ -183,8 +182,6 @@ class ApiCreateAccount extends ApiBase {
        }
 
        public function getAllowedParams() {
-               global $wgEmailConfirmToEdit;
-
                return array(
                        'name' => array(
                                ApiBase::PARAM_TYPE => 'user',
@@ -195,7 +192,7 @@ class ApiCreateAccount extends ApiBase {
                        'token' => null,
                        'email' => array(
                                ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => $wgEmailConfirmToEdit
+                               ApiBase::PARAM_REQUIRED => $this->getConfig()->get( 'EmailConfirmToEdit' ),
                        ),
                        'realname' => null,
                        'mailpassword' => array(
@@ -229,9 +226,9 @@ class ApiCreateAccount extends ApiBase {
                        'createaccount' => array(
                                'result' => array(
                                        ApiBase::PROP_TYPE => array(
-                                               'success',
-                                               'warning',
-                                               'needtoken'
+                                               'Success',
+                                               'Warning',
+                                               'NeedToken'
                                        )
                                ),
                                'username' => array(
@@ -293,10 +290,9 @@ class ApiCreateAccount extends ApiBase {
                );
 
                // 'passwordtooshort' has parameters. :(
-               global $wgMinimalPasswordLength;
                $errors[] = array(
                        'code' => 'passwordtooshort',
-                       'info' => wfMessage( 'passwordtooshort', $wgMinimalPasswordLength )
+                       'info' => wfMessage( 'passwordtooshort', $this->getConfig()->get( 'MinimalPasswordLength' ) )
                                ->inLanguage( 'en' )->useDatabase( false )->parse()
                );