39 parent::__construct(
'ChangeEmail',
'editmyprivateinfo' );
50 return MediaWikiServices::getInstance()->getAuthManager()
51 ->allowsPropertyChange(
'emailaddress' );
60 $out->disallowUserJs();
62 parent::execute(
$par );
70 $services = MediaWikiServices::getInstance();
71 if ( !$services->getAuthManager()->allowsPropertyChange(
'emailaddress' ) ) {
79 if ( !$services->getPermissionManager()
80 ->userHasRight( $this->getUser(),
'viewmyprivateinfo' )
85 parent::checkExecutePermissions( $user );
94 'label-message' =>
'username',
95 'default' => $user->getName(),
99 'label-message' =>
'changeemail-oldemail',
100 'default' => $user->getEmail() ?: $this->
msg(
'changeemail-none' )->text(),
104 'label-message' =>
'changeemail-newemail',
107 'help-message' =>
'changeemail-newemail-help',
119 $form->
setId(
'mw-changeemail-form' );
138 $returnto = $request->getVal(
'returnto' );
139 $titleObj = $returnto !==
null ? Title::newFromText( $returnto ) :
null;
140 if ( !$titleObj instanceof
Title ) {
141 $titleObj = Title::newMainPage();
143 $query = $request->getVal(
'returntoquery',
'' );
145 if ( $this->status->value ===
true ) {
146 $this->
getOutput()->redirect( $titleObj->getFullUrlForRedirect( $query ) );
147 } elseif ( $this->status->value ===
'eauth' ) {
148 # Notify user that a confirmation email has been sent...
149 $this->
getOutput()->wrapWikiMsg(
"<div class='error' style='clear: both;'>\n$1\n</div>",
162 if ( $newaddr !=
'' && !Sanitizer::validateEmail( $newaddr ) ) {
163 return Status::newFatal(
'invalidemailaddress' );
167 if ( $newaddr === $oldaddr ) {
168 return Status::newFatal(
'changeemail-nochange' );
171 if ( strlen( $newaddr ) > 255 ) {
172 return Status::newFatal(
'changeemail-maxlength' );
177 if ( $newaddr !==
'' && $user->
pingLimiter(
'changeemail' ) ) {
178 return Status::newFatal(
'actionthrottledtext' );
182 $status = $userLatest->setEmailWithConfirmation( $newaddr );
187 LoggerFactory::getInstance(
'authentication' )->info(
188 'Changing email address for {user} from {oldemail} to {newemail}', [
189 'user' => $userLatest->getName(),
190 'oldemail' => $oldaddr,
191 'newemail' => $newaddr,
195 $this->
getHookRunner()->onPrefsEmailAudit( $userLatest, $oldaddr, $newaddr );
197 $userLatest->saveSettings();
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.
Let users change their email address.
doesWrites()
Indicates whether this special page may perform database writes.
requiresUnblock()
Whether this action cannot be executed by a blocked user.
getDisplayFormat()
Get display format for the form.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
getFormFields()
Get an HTMLForm descriptor array.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
attemptChange(User $user, $newaddr)
checkExecutePermissions(User $user)
Called from execute() to check if the given user can perform this action.
execute( $par)
Main execution point.
getLoginSecurityLevel()
Tells if the special page does something security-sensitive and needs extra defense against a stolen ...
onSubmit(array $data)
Process the form on POST submission.
getName()
Get the name of this Special Page.
getOutput()
Get the OutputPage being used for this instance.
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
getUser()
Shortcut to get the User executing this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
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.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
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 master via a locking read.