40 parent::__construct(
'ChangeEmail',
'editmyprivateinfo' );
51 return AuthManager::singleton()->allowsPropertyChange(
'emailaddress' );
60 $out->disallowUserJs();
62 parent::execute(
$par );
70 if ( !AuthManager::singleton()->allowsPropertyChange(
'emailaddress' ) ) {
78 if ( !MediaWikiServices::getInstance()
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',
106 'help-message' =>
'changeemail-newemail-help',
118 $form->
setId(
'mw-changeemail-form' );
137 $returnto = $request->getVal(
'returnto' );
138 $titleObj = $returnto !==
null ? Title::newFromText( $returnto ) :
null;
139 if ( !$titleObj instanceof
Title ) {
140 $titleObj = Title::newMainPage();
142 $query = $request->getVal(
'returntoquery' );
144 if ( $this->status->value ===
true ) {
145 $this->
getOutput()->redirect( $titleObj->getFullUrlForRedirect( $query ) );
146 } elseif ( $this->status->value ===
'eauth' ) {
147 # Notify user that a confirmation email has been sent...
148 $this->
getOutput()->wrapWikiMsg(
"<div class='error' style='clear: both;'>\n$1\n</div>",
161 if ( $newaddr !=
'' && !Sanitizer::validateEmail( $newaddr ) ) {
162 return Status::newFatal(
'invalidemailaddress' );
165 if ( $newaddr === $user->
getEmail() ) {
166 return Status::newFatal(
'changeemail-nochange' );
171 if ( $newaddr !==
'' && $user->
pingLimiter(
'changeemail' ) ) {
172 return Status::newFatal(
'actionthrottledtext' );
181 LoggerFactory::getInstance(
'authentication' )->info(
182 'Changing email address for {user} from {oldemail} to {newemail}', [
184 'oldemail' => $oldaddr,
185 'newemail' => $newaddr,
189 Hooks::run(
'PrefsEmailAudit', [ $user, $oldaddr, $newaddr ] );
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,...
getName()
Get the user name, or the IP of an anonymous user.
setEmailWithConfirmation( $str)
Set the user's e-mail address and a confirmation mail if needed.
pingLimiter( $action='edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
saveSettings()
Save this user's settings into the database.
getEmail()
Get the user's e-mail address.