24 namespace MediaWiki\Specials;
53 parent::__construct(
'ChangeEmail',
'editmyprivateinfo' );
66 return $this->
getAuthManager()->allowsPropertyChange(
'emailaddress' );
75 $out->disallowUserJs();
76 $out->addModules(
'mediawiki.special.changeemail' );
77 parent::execute(
$par );
85 if ( !$this->
getAuthManager()->allowsPropertyChange(
'emailaddress' ) ) {
93 if ( !$this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) ) {
97 parent::checkExecutePermissions( $user );
106 'label-message' =>
'username',
111 'label-message' =>
'changeemail-oldemail',
112 'default' => $user->
getEmail() ?: $this->
msg(
'changeemail-none' )->text(),
116 'label-message' =>
'changeemail-newemail',
119 'help-message' =>
'changeemail-newemail-help',
129 $form->
setId(
'mw-changeemail-form' );
139 $this->status = $this->attemptChange( $this->
getUser(), $data[
'NewEmail'] );
141 return $this->status;
147 $returnTo = $request->getVal(
'returnto' );
149 if ( !$titleObj instanceof
Title ) {
152 $query = $request->getVal(
'returntoquery',
'' );
154 if ( $this->status->value ===
true ) {
155 $this->
getOutput()->redirect( $titleObj->getFullUrlForRedirect( $query ) );
156 } elseif ( $this->status->value ===
'eauth' ) {
157 # Notify user that a confirmation email has been sent...
161 $out->msg(
'eauthentsent', $this->getUser()->getName() )->parse()
175 private function attemptChange(
User $user, $newAddr ) {
181 if ( $newAddr === $oldAddr ) {
185 if ( strlen( $newAddr ) > 255 ) {
191 if ( $newAddr !==
'' && $user->
pingLimiter(
'changeemail' ) ) {
196 $status = $userLatest->setEmailWithConfirmation( $newAddr );
197 if ( !$status->
isGood() ) {
202 'Changing email address for {user} from {oldemail} to {newemail}', [
203 'user' => $userLatest->getName(),
204 'oldemail' => $oldAddr,
205 'newemail' => $newAddr,
209 $this->
getHookRunner()->onPrefsEmailAudit( $userLatest, $oldAddr, $newAddr );
211 $userLatest->saveSettings();
228 class_alias( SpecialChangeEmail::class,
'SpecialChangeEmail' );
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
An error page which can definitely be safely rendered using the OutputPage.
Special page which uses an HTMLForm to handle processing.
string null $par
The sub-page of the special page.
Show an error when a user tries to do something they do not have the necessary permissions for.
HTML sanitizer for MediaWiki.
static validateEmail( $addr)
Does a string look like an e-mail address?
getName()
Get the name of this Special Page.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
requireNamedUser( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in or is a temporary user, throws UserNotLoggedIn.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getRequest()
Get the WebRequest being used for this instance.
setAuthManager(AuthManager $authManager)
Set the injected AuthManager from the special page constructor.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
pingLimiter( $action='edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
getEmail()
Get the user's e-mail address.
getInstanceForUpdate()
Get a new instance of this user that was loaded from the primary DB via a locking read.