X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialChangePassword.php;h=41b3b2558f746d90d43197a8d61474ac996f828b;hb=66d0bc0527f6c04495be1605e5a28b9e7a8c033e;hp=230da6187026a8f28a2453fc2fbf31f56f326e56;hpb=ba4136b91af4885f217fa69befc57507a82483a1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialChangePassword.php b/includes/specials/SpecialChangePassword.php index 230da61870..41b3b2558f 100644 --- a/includes/specials/SpecialChangePassword.php +++ b/includes/specials/SpecialChangePassword.php @@ -26,7 +26,7 @@ * * @ingroup SpecialPage */ -class SpecialChangePassword extends SpecialPage { +class SpecialChangePassword extends UnlistedSpecialPage { public function __construct() { parent::__construct( 'ChangePassword' ); } @@ -35,44 +35,43 @@ class SpecialChangePassword extends SpecialPage { * Main execution point */ function execute( $par ) { - global $wgUser, $wgAuth, $wgOut, $wgRequest; - - if ( wfReadOnly() ) { - $wgOut->readOnlyPage(); - return; - } - - $this->mUserName = trim( $wgRequest->getVal( 'wpName' ) ); - $this->mOldpass = $wgRequest->getVal( 'wpPassword' ); - $this->mNewpass = $wgRequest->getVal( 'wpNewPassword' ); - $this->mRetype = $wgRequest->getVal( 'wpRetype' ); - $this->mDomain = $wgRequest->getVal( 'wpDomain' ); + global $wgAuth; $this->setHeaders(); $this->outputHeader(); - $wgOut->disallowUserJs(); - - if( !$wgRequest->wasPosted() && !$wgUser->isLoggedIn() ) { - $this->error( wfMsg( 'resetpass-no-info' ) ); + $this->getOutput()->disallowUserJs(); + + $request = $this->getRequest(); + $this->mUserName = trim( $request->getVal( 'wpName' ) ); + $this->mOldpass = $request->getVal( 'wpPassword' ); + $this->mNewpass = $request->getVal( 'wpNewPassword' ); + $this->mRetype = $request->getVal( 'wpRetype' ); + $this->mDomain = $request->getVal( 'wpDomain' ); + + $user = $this->getUser(); + if( !$request->wasPosted() && !$user->isLoggedIn() ) { + $this->error( $this->msg( 'resetpass-no-info' )->text() ); return; } - if( $wgRequest->wasPosted() && $wgRequest->getBool( 'wpCancel' ) ) { + if( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) { $this->doReturnTo(); return; } - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { + $this->checkReadOnly(); + + if( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'token' ) ) ) { try { - $wgAuth->setDomain( $this->mDomain ); + $this->mDomain = $wgAuth->getDomain(); if( !$wgAuth->allowPasswordChange() ) { - $this->error( wfMsg( 'resetpass_forbidden' ) ); + $this->error( $this->msg( 'resetpass_forbidden' )->text() ); return; } $this->attemptReset( $this->mNewpass, $this->mRetype ); - $wgOut->addWikiMsg( 'resetpass_success' ); - if( !$wgUser->isLoggedIn() ) { + $this->getOutput()->addWikiMsg( 'resetpass_success' ); + if( !$user->isLoggedIn() ) { LoginForm::setLoginToken(); $token = LoginForm::getLoginToken(); $data = array( @@ -81,12 +80,13 @@ class SpecialChangePassword extends SpecialPage { 'wpDomain' => $this->mDomain, 'wpLoginToken' => $token, 'wpPassword' => $this->mNewpass, - 'returnto' => $wgRequest->getVal( 'returnto' ), + 'returnto' => $request->getVal( 'returnto' ), ); - if( $wgRequest->getCheck( 'wpRemember' ) ) { + if( $request->getCheck( 'wpRemember' ) ) { $data['wpRemember'] = 1; } $login = new LoginForm( new FauxRequest( $data, true ) ); + $login->setContext( $this->getContext() ); $login->execute( null ); } $this->doReturnTo(); @@ -98,36 +98,33 @@ class SpecialChangePassword extends SpecialPage { } function doReturnTo() { - global $wgRequest, $wgOut; - $titleObj = Title::newFromText( $wgRequest->getVal( 'returnto' ) ); + $titleObj = Title::newFromText( $this->getRequest()->getVal( 'returnto' ) ); if ( !$titleObj instanceof Title ) { $titleObj = Title::newMainPage(); } - $wgOut->redirect( $titleObj->getFullURL() ); + $this->getOutput()->redirect( $titleObj->getFullURL() ); } function error( $msg ) { - global $wgOut; - $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $msg ) ); + $this->getOutput()->addHTML( Xml::element('p', array( 'class' => 'error' ), $msg ) ); } function showForm() { - global $wgOut, $wgUser, $wgRequest; + global $wgCookieExpiration; - $self = $this->getTitle(); + $user = $this->getUser(); if ( !$this->mUserName ) { - $this->mUserName = $wgUser->getName(); + $this->mUserName = $user->getName(); } $rememberMe = ''; - if ( !$wgUser->isLoggedIn() ) { - global $wgCookieExpiration, $wgLang; + if ( !$user->isLoggedIn() ) { $rememberMe = '