42 parent::__construct(
'ChangeEmail',
'editmyprivateinfo' );
55 return $this->
getAuthManager()->allowsPropertyChange(
'emailaddress' );
64 $out->disallowUserJs();
66 parent::execute(
$par );
74 if ( !$this->
getAuthManager()->allowsPropertyChange(
'emailaddress' ) ) {
82 if ( !$this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) ) {
86 parent::checkExecutePermissions( $user );
95 'label-message' =>
'username',
96 'default' => $user->getName(),
100 'label-message' =>
'changeemail-oldemail',
101 'default' => $user->getEmail() ?: $this->
msg(
'changeemail-none' )->text(),
105 'label-message' =>
'changeemail-newemail',
108 'help-message' =>
'changeemail-newemail-help',
120 $form->
setId(
'mw-changeemail-form' );
139 $returnto = $request->getVal(
'returnto' );
140 $titleObj = $returnto !==
null ? Title::newFromText( $returnto ) :
null;
141 if ( !$titleObj instanceof
Title ) {
142 $titleObj = Title::newMainPage();
144 $query = $request->getVal(
'returntoquery',
'' );
146 if ( $this->status->value ===
true ) {
147 $this->
getOutput()->redirect( $titleObj->getFullUrlForRedirect( $query ) );
148 } elseif ( $this->status->value ===
'eauth' ) {
149 # Notify user that a confirmation email has been sent...
150 $this->
getOutput()->wrapWikiMsg(
"<div class='warningbox'>\n$1\n</div>",
163 if ( $newaddr !=
'' && !Sanitizer::validateEmail( $newaddr ) ) {
164 return Status::newFatal(
'invalidemailaddress' );
168 if ( $newaddr === $oldaddr ) {
169 return Status::newFatal(
'changeemail-nochange' );
172 if ( strlen( $newaddr ) > 255 ) {
173 return Status::newFatal(
'changeemail-maxlength' );
178 if ( $newaddr !==
'' && $user->
pingLimiter(
'changeemail' ) ) {
179 return Status::newFatal(
'actionthrottledtext' );
183 $status = $userLatest->setEmailWithConfirmation( $newaddr );
188 LoggerFactory::getInstance(
'authentication' )->info(
189 'Changing email address for {user} from {oldemail} to {newemail}', [
190 'user' => $userLatest->getName(),
191 'oldemail' => $oldaddr,
192 'newemail' => $newaddr,
196 $this->
getHookRunner()->onPrefsEmailAudit( $userLatest, $oldaddr, $newaddr );
198 $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.
__construct(AuthManager $authManager)
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.
AuthManager null $authManager
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.
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 primary DB via a locking read.