allowPropChange( 'emailaddress' ); } /** * Main execution point */ function execute( $par ) { global $wgAuth; $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); $out->disallowUserJs(); $out->addModules( 'mediawiki.special.changeemail' ); if ( !$wgAuth->allowPropChange( 'emailaddress' ) ) { $this->error( 'cannotchangeemail' ); return; } $user = $this->getUser(); $request = $this->getRequest(); if ( !$request->wasPosted() && !$user->isLoggedIn() ) { $this->error( 'changeemail-no-info' ); return; } if ( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) { $this->doReturnTo(); return; } $this->checkReadOnly(); $this->checkPermissions(); // This could also let someone check the current email address, so // require both permissions. if ( !$this->getUser()->isAllowed( 'viewmyprivateinfo' ) ) { throw new PermissionsError( 'viewmyprivateinfo' ); } $this->mPassword = $request->getVal( 'wpPassword' ); $this->mNewEmail = $request->getVal( 'wpNewEmail' ); if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'token' ) ) ) { $info = $this->attemptChange( $user, $this->mPassword, $this->mNewEmail ); if ( $info === true ) { $this->doReturnTo(); } elseif ( $info === 'eauth' ) { # Notify user that a confirmation email has been sent... $out->wrapWikiMsg( "
\n$1\n
", $msg ); } protected function showForm() { global $wgRequirePasswordforEmailChange; $user = $this->getUser(); $oldEmailText = $user->getEmail() ? $user->getEmail() : $this->msg( 'changeemail-none' )->text(); $this->getOutput()->addHTML( Xml::fieldset( $this->msg( 'changeemail-header' )->text() ) . Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'id' => 'mw-changeemail-form' ) ) . "\n" . Html::hidden( 'token', $user->getEditToken() ) . "\n" . Html::hidden( 'returnto', $this->getRequest()->getVal( 'returnto' ) ) . "\n" . $this->msg( 'changeemail-text' )->parseAsBlock() . "\n" . Xml::openElement( 'table', array( 'id' => 'mw-changeemail-table' ) ) . "\n" ); $items = array( array( 'wpName', 'username', 'text', $user->getName() ), array( 'wpOldEmail', 'changeemail-oldemail', 'text', $oldEmailText ), array( 'wpNewEmail', 'changeemail-newemail', 'email', $this->mNewEmail ), ); if ( $wgRequirePasswordforEmailChange ) { $items[] = array( 'wpPassword', 'changeemail-password', 'password', $this->mPassword ); } $this->getOutput()->addHTML( $this->pretty( $items ) . "\n" . "' . $this->getOutput()->parseInline( $status->getWikiText( 'mailerror' ) ) . '
' ); return false; } wfRunHooks( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) ); $user->saveSettings(); $wgAuth->updateExternalDB( $user ); return $status->value; } protected function getGroupName() { return 'users'; } }