* @ingroup SpecialPage
*/
class SpecialChangeEmail extends UnlistedSpecialPage {
+
+ /**
+ * Users password
+ * @var string
+ */
+ protected $mPassword;
+
+ /**
+ * Users new email address
+ * @var string
+ */
+ protected $mNewEmail;
+
public function __construct() {
parent::__construct( 'ChangeEmail' );
}
+ /**
+ * @return Bool
+ */
function isListed() {
global $wgAuth;
return $wgAuth->allowPropChange( 'emailaddress' );
$this->showForm();
}
+ /**
+ * @param $type string
+ */
protected function doReturnTo( $type = 'hard' ) {
$titleObj = Title::newFromText( $this->getRequest()->getVal( 'returnto' ) );
if ( !$titleObj instanceof Title ) {
}
}
+ /**
+ * @param $msg string
+ */
protected function error( $msg ) {
$this->getOutput()->wrapWikiMsg( "<p class='error'>\n$1\n</p>", $msg );
}
protected function showForm() {
+ global $wgRequirePasswordforEmailChange;
$user = $this->getUser();
$oldEmailText = $user->getEmail()
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" .
- $this->pretty( array(
- array( 'wpName', 'username', 'text', $user->getName() ),
- array( 'wpOldEmail', 'changeemail-oldemail', 'text', $oldEmailText ),
- array( 'wpNewEmail', 'changeemail-newemail', 'input', $this->mNewEmail ),
- array( 'wpPassword', 'yourpassword', 'password', $this->mPassword ),
- ) ) . "\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', 'input', $this->mNewEmail ),
+ );
+ if ( $wgRequirePasswordforEmailChange ) {
+ $items[] = array( 'wpPassword', 'yourpassword', 'password', $this->mPassword );
+ }
+
+ $this->getOutput()->addHTML(
+ $this->pretty( $items ) .
+ "\n" .
"<tr>\n" .
"<td></td>\n" .
'<td class="mw-input">' .
);
}
+ /**
+ * @param $fields array
+ * @return string
+ */
protected function pretty( $fields ) {
$out = '';
foreach ( $fields as $list ) {
}
/**
+ * @param $user User
+ * @param $pass string
+ * @param $newaddr string
* @return bool|string true or string on success, false on failure
*/
protected function attemptChange( User $user, $pass, $newaddr ) {
return false;
}
- if ( !$user->checkTemporaryPassword( $pass ) && !$user->checkPassword( $pass ) ) {
+ global $wgRequirePasswordforEmailChange;
+ if ( $wgRequirePasswordforEmailChange && !$user->checkTemporaryPassword( $pass ) && !$user->checkPassword( $pass ) ) {
$this->error( 'wrongpassword' );
return false;
}