From 24ffd911c3d84a3db0e0fb4bc7b6bea29dae0aea Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sun, 3 Aug 2014 17:27:07 -0700 Subject: [PATCH] SpecialPasswordReset: Use Config instead of globals Change-Id: I017fb8b636771902c3b50c5588e6ae3d5db70688 --- includes/specials/SpecialPasswordReset.php | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/includes/specials/SpecialPasswordReset.php b/includes/specials/SpecialPasswordReset.php index c60b347543..3061c85b12 100644 --- a/includes/specials/SpecialPasswordReset.php +++ b/includes/specials/SpecialPasswordReset.php @@ -62,9 +62,10 @@ class SpecialPasswordReset extends FormSpecialPage { } protected function getFormFields() { - global $wgPasswordResetRoutes, $wgAuth; + global $wgAuth; + $resetRoutes = $this->getConfig()->get( 'PasswordResetRoutes' ); $a = array(); - if ( isset( $wgPasswordResetRoutes['username'] ) && $wgPasswordResetRoutes['username'] ) { + if ( isset( $resetRoutes['username'] ) && $resetRoutes['username'] ) { $a['Username'] = array( 'type' => 'text', 'label-message' => 'passwordreset-username', @@ -75,14 +76,14 @@ class SpecialPasswordReset extends FormSpecialPage { } } - if ( isset( $wgPasswordResetRoutes['email'] ) && $wgPasswordResetRoutes['email'] ) { + if ( isset( $resetRoutes['email'] ) && $resetRoutes['email'] ) { $a['Email'] = array( 'type' => 'email', 'label-message' => 'passwordreset-email', ); } - if ( isset( $wgPasswordResetRoutes['domain'] ) && $wgPasswordResetRoutes['domain'] ) { + if ( isset( $resetRoutes['domain'] ) && $resetRoutes['domain'] ) { $domains = $wgAuth->domainList(); $a['Domain'] = array( 'type' => 'select', @@ -103,7 +104,7 @@ class SpecialPasswordReset extends FormSpecialPage { } public function alterForm( HTMLForm $form ) { - global $wgPasswordResetRoutes; + $resetRoutes = $this->getConfig()->get( 'PasswordResetRoutes' ); $form->setDisplayFormat( 'vform' ); // Turn the old-school line around the form off. @@ -115,13 +116,13 @@ class SpecialPasswordReset extends FormSpecialPage { $form->addHiddenFields( $this->getRequest()->getValues( 'returnto', 'returntoquery' ) ); $i = 0; - if ( isset( $wgPasswordResetRoutes['username'] ) && $wgPasswordResetRoutes['username'] ) { + if ( isset( $resetRoutes['username'] ) && $resetRoutes['username'] ) { $i++; } - if ( isset( $wgPasswordResetRoutes['email'] ) && $wgPasswordResetRoutes['email'] ) { + if ( isset( $resetRoutes['email'] ) && $resetRoutes['email'] ) { $i++; } - if ( isset( $wgPasswordResetRoutes['domain'] ) && $wgPasswordResetRoutes['domain'] ) { + if ( isset( $resetRoutes['domain'] ) && $resetRoutes['domain'] ) { $i++; } @@ -222,19 +223,16 @@ class SpecialPasswordReset extends FormSpecialPage { // Check against password throttle foreach ( $users as $user ) { if ( $user->isPasswordReminderThrottled() ) { - global $wgPasswordReminderResendTime; # Round the time in hours to 3 d.p., in case someone is specifying # minutes or seconds. return array( array( 'throttled-mailpassword', - round( $wgPasswordReminderResendTime, 3 ) + round( $this->getConfig()->get( 'PasswordReminderResendTime' ), 3 ) ) ); } } - global $wgNewPasswordExpiry; - // All the users will have the same email address if ( $firstUser->getEmail() == '' ) { // This won't be reachable from the email route, so safe to expose the username @@ -273,7 +271,7 @@ class SpecialPasswordReset extends FormSpecialPage { $passwordBlock, count( $passwords ), '<' . Title::newMainPage()->getCanonicalURL() . '>', - round( $wgNewPasswordExpiry / 86400 ) + round( $this->getConfig()->get( 'NewPasswordExpiry' ) / 86400 ) ); $title = $this->msg( 'passwordreset-emailtitle' ); @@ -320,11 +318,12 @@ class SpecialPasswordReset extends FormSpecialPage { } protected function canChangePassword( User $user ) { - global $wgPasswordResetRoutes, $wgEnableEmail, $wgAuth; + global $wgAuth; + $resetRoutes = $this->getConfig()->get( 'PasswordResetRoutes' ); // Maybe password resets are disabled, or there are no allowable routes - if ( !is_array( $wgPasswordResetRoutes ) || - !in_array( true, array_values( $wgPasswordResetRoutes ) ) + if ( !is_array( $resetRoutes ) || + !in_array( true, array_values( $resetRoutes ) ) ) { return 'passwordreset-disabled'; } @@ -335,7 +334,7 @@ class SpecialPasswordReset extends FormSpecialPage { } // Maybe email features have been disabled - if ( !$wgEnableEmail ) { + if ( !$this->getConfig()->get( 'EnableEmail' ) ) { return 'passwordreset-emaildisabled'; } -- 2.20.1