| Index: trunk/phase3/includes/specials/SpecialChangePassword.php |
| — | — | @@ -35,34 +35,35 @@ |
| 36 | 36 | * Main execution point |
| 37 | 37 | */ |
| 38 | 38 | function execute( $par ) { |
| 39 | | - global $wgUser, $wgAuth, $wgOut, $wgRequest; |
| | 39 | + global $wgAuth; |
| 40 | 40 | |
| 41 | 41 | if ( wfReadOnly() ) { |
| 42 | | - $wgOut->readOnlyPage(); |
| 43 | | - return; |
| | 42 | + throw new ReadOnlyError; |
| 44 | 43 | } |
| 45 | 44 | |
| 46 | | - $this->mUserName = trim( $wgRequest->getVal( 'wpName' ) ); |
| 47 | | - $this->mOldpass = $wgRequest->getVal( 'wpPassword' ); |
| 48 | | - $this->mNewpass = $wgRequest->getVal( 'wpNewPassword' ); |
| 49 | | - $this->mRetype = $wgRequest->getVal( 'wpRetype' ); |
| 50 | | - $this->mDomain = $wgRequest->getVal( 'wpDomain' ); |
| | 45 | + $request = $this->getRequest(); |
| | 46 | + $this->mUserName = trim( $request->getVal( 'wpName' ) ); |
| | 47 | + $this->mOldpass = $request->getVal( 'wpPassword' ); |
| | 48 | + $this->mNewpass = $request->getVal( 'wpNewPassword' ); |
| | 49 | + $this->mRetype = $request->getVal( 'wpRetype' ); |
| | 50 | + $this->mDomain = $request->getVal( 'wpDomain' ); |
| 51 | 51 | |
| 52 | 52 | $this->setHeaders(); |
| 53 | 53 | $this->outputHeader(); |
| 54 | | - $wgOut->disallowUserJs(); |
| | 54 | + $this->getOutput()->disallowUserJs(); |
| 55 | 55 | |
| 56 | | - if( !$wgRequest->wasPosted() && !$wgUser->isLoggedIn() ) { |
| | 56 | + $user = $this->getUser(); |
| | 57 | + if( !$request->wasPosted() && !$user->isLoggedIn() ) { |
| 57 | 58 | $this->error( wfMsg( 'resetpass-no-info' ) ); |
| 58 | 59 | return; |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | | - if( $wgRequest->wasPosted() && $wgRequest->getBool( 'wpCancel' ) ) { |
| | 62 | + if( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) { |
| 62 | 63 | $this->doReturnTo(); |
| 63 | 64 | return; |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | | - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
| | 67 | + if( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'token' ) ) ) { |
| 67 | 68 | try { |
| 68 | 69 | $wgAuth->setDomain( $this->mDomain ); |
| 69 | 70 | if( !$wgAuth->allowPasswordChange() ) { |
| — | — | @@ -71,8 +72,8 @@ |
| 72 | 73 | } |
| 73 | 74 | |
| 74 | 75 | $this->attemptReset( $this->mNewpass, $this->mRetype ); |
| 75 | | - $wgOut->addWikiMsg( 'resetpass_success' ); |
| 76 | | - if( !$wgUser->isLoggedIn() ) { |
| | 76 | + $this->getOutput()->addWikiMsg( 'resetpass_success' ); |
| | 77 | + if( !$user->isLoggedIn() ) { |
| 77 | 78 | LoginForm::setLoginToken(); |
| 78 | 79 | $token = LoginForm::getLoginToken(); |
| 79 | 80 | $data = array( |
| — | — | @@ -81,9 +82,9 @@ |
| 82 | 83 | 'wpDomain' => $this->mDomain, |
| 83 | 84 | 'wpLoginToken' => $token, |
| 84 | 85 | 'wpPassword' => $this->mNewpass, |
| 85 | | - 'returnto' => $wgRequest->getVal( 'returnto' ), |
| | 86 | + 'returnto' => $request->getVal( 'returnto' ), |
| 86 | 87 | ); |
| 87 | | - if( $wgRequest->getCheck( 'wpRemember' ) ) { |
| | 88 | + if( $request->getCheck( 'wpRemember' ) ) { |
| 88 | 89 | $data['wpRemember'] = 1; |
| 89 | 90 | } |
| 90 | 91 | $login = new LoginForm( new FauxRequest( $data, true ) ); |
| — | — | @@ -98,36 +99,33 @@ |
| 99 | 100 | } |
| 100 | 101 | |
| 101 | 102 | function doReturnTo() { |
| 102 | | - global $wgRequest, $wgOut; |
| 103 | | - $titleObj = Title::newFromText( $wgRequest->getVal( 'returnto' ) ); |
| | 103 | + $titleObj = Title::newFromText( $this->getRequest()->getVal( 'returnto' ) ); |
| 104 | 104 | if ( !$titleObj instanceof Title ) { |
| 105 | 105 | $titleObj = Title::newMainPage(); |
| 106 | 106 | } |
| 107 | | - $wgOut->redirect( $titleObj->getFullURL() ); |
| | 107 | + $this->getOutput()->redirect( $titleObj->getFullURL() ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | function error( $msg ) { |
| 111 | | - global $wgOut; |
| 112 | | - $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $msg ) ); |
| | 111 | + $this->getOutput()->addHTML( Xml::element('p', array( 'class' => 'error' ), $msg ) ); |
| 113 | 112 | } |
| 114 | 113 | |
| 115 | 114 | function showForm() { |
| 116 | | - global $wgOut, $wgUser, $wgRequest; |
| | 115 | + global $wgCookieExpiration; |
| 117 | 116 | |
| 118 | | - $self = $this->getTitle(); |
| | 117 | + $user = $this->getUser(); |
| 119 | 118 | if ( !$this->mUserName ) { |
| 120 | | - $this->mUserName = $wgUser->getName(); |
| | 119 | + $this->mUserName = $user->getName(); |
| 121 | 120 | } |
| 122 | 121 | $rememberMe = ''; |
| 123 | | - if ( !$wgUser->isLoggedIn() ) { |
| 124 | | - global $wgCookieExpiration, $wgLang; |
| | 122 | + if ( !$user->isLoggedIn() ) { |
| 125 | 123 | $rememberMe = '<tr>' . |
| 126 | 124 | '<td></td>' . |
| 127 | 125 | '<td class="mw-input">' . |
| 128 | 126 | Xml::checkLabel( |
| 129 | | - wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ), |
| | 127 | + wfMsgExt( 'remembermypassword', 'parsemag', $this->getLang()->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ), |
| 130 | 128 | 'wpRemember', 'wpRemember', |
| 131 | | - $wgRequest->getCheck( 'wpRemember' ) ) . |
| | 129 | + $this->getRequest()->getCheck( 'wpRemember' ) ) . |
| 132 | 130 | '</td>' . |
| 133 | 131 | '</tr>'; |
| 134 | 132 | $submitMsg = 'resetpass_submit'; |
| — | — | @@ -136,17 +134,17 @@ |
| 137 | 135 | $oldpassMsg = 'oldpassword'; |
| 138 | 136 | $submitMsg = 'resetpass-submit-loggedin'; |
| 139 | 137 | } |
| 140 | | - $wgOut->addHTML( |
| | 138 | + $this->getOutput()->addHTML( |
| 141 | 139 | Xml::fieldset( wfMsg( 'resetpass_header' ) ) . |
| 142 | 140 | Xml::openElement( 'form', |
| 143 | 141 | array( |
| 144 | 142 | 'method' => 'post', |
| 145 | | - 'action' => $self->getLocalUrl(), |
| | 143 | + 'action' => $this->getTitle()->getLocalUrl(), |
| 146 | 144 | 'id' => 'mw-resetpass-form' ) ) . "\n" . |
| 147 | | - Html::hidden( 'token', $wgUser->editToken() ) . "\n" . |
| | 145 | + Html::hidden( 'token', $user->editToken() ) . "\n" . |
| 148 | 146 | Html::hidden( 'wpName', $this->mUserName ) . "\n" . |
| 149 | 147 | Html::hidden( 'wpDomain', $this->mDomain ) . "\n" . |
| 150 | | - Html::hidden( 'returnto', $wgRequest->getVal( 'returnto' ) ) . "\n" . |
| | 148 | + Html::hidden( 'returnto', $this->getRequest()->getVal( 'returnto' ) ) . "\n" . |
| 151 | 149 | wfMsgExt( 'resetpass_text', array( 'parse' ) ) . "\n" . |
| 152 | 150 | Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) ) . "\n" . |
| 153 | 151 | $this->pretty( array( |