parent::__construct( 'ChangeEmail', 'editmyprivateinfo' );
}
+ public function doesWrites() {
+ return true;
+ }
+
/**
* @return bool
*/
protected function getFormFields() {
$user = $this->getUser();
- $fields = array(
- 'Name' => array(
+ $fields = [
+ 'Name' => [
'type' => 'info',
'label-message' => 'username',
'default' => $user->getName(),
- ),
- 'OldEmail' => array(
+ ],
+ 'OldEmail' => [
'type' => 'info',
'label-message' => 'changeemail-oldemail',
'default' => $user->getEmail() ?: $this->msg( 'changeemail-none' )->text(),
- ),
- 'NewEmail' => array(
+ ],
+ 'NewEmail' => [
'type' => 'email',
'label-message' => 'changeemail-newemail',
'autofocus' => true,
'help-message' => 'changeemail-newemail-help',
- ),
- );
+ ],
+ ];
if ( $this->getConfig()->get( 'RequirePasswordforEmailChange' ) ) {
- $fields['Password'] = array(
+ $fields['Password'] = [
'type' => 'password',
'label-message' => 'changeemail-password'
- );
+ ];
}
return $fields;
return Status::newFatal( 'changeemail-nochange' );
}
- $throttleCount = LoginForm::incLoginThrottle( $user->getName() );
- if ( $throttleCount === true ) {
+ $throttleInfo = LoginForm::incrementLoginThrottle( $user->getName() );
+ if ( $throttleInfo ) {
$lang = $this->getLanguage();
- $throttleInfo = $this->getConfig()->get( 'PasswordAttemptThrottle' );
return Status::newFatal(
'changeemail-throttled',
- $lang->formatDuration( $throttleInfo['seconds'] )
+ $lang->formatDuration( $throttleInfo['wait'] )
);
}
return Status::newFatal( 'wrongpassword' );
}
- if ( $throttleCount ) {
- LoginForm::clearLoginThrottle( $user->getName() );
- }
+ LoginForm::clearLoginThrottle( $user->getName() );
$oldaddr = $user->getEmail();
$status = $user->setEmailWithConfirmation( $newaddr );
return $status;
}
- Hooks::run( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) );
+ Hooks::run( 'PrefsEmailAudit', [ $user, $oldaddr, $newaddr ] );
$user->saveSettings();