Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
SpecialPasswordReset.php
Go to the documentation of this file.
1<?php
7namespaceMediaWiki\Specials;
8
9useMediaWiki\Exception\ErrorPageError;
10useMediaWiki\Exception\ThrottledError;
11useMediaWiki\HTMLForm\HTMLForm;
12useMediaWiki\MainConfigNames;
13useMediaWiki\SpecialPage\FormSpecialPage;
14useMediaWiki\Status\Status;
15useMediaWiki\User\PasswordReset;
16useMediaWiki\User\User;
17
27classSpecialPasswordResetextendsFormSpecialPage {
28privatePasswordReset $passwordReset;
29
30publicfunction__construct(PasswordReset $passwordReset ) {
31 parent::__construct('PasswordReset','editmyprivateinfo' );
32
33 $this->passwordReset = $passwordReset;
34 }
35
37publicfunctiondoesWrites() {
38returntrue;
39 }
40
42publicfunctionuserCanExecute(User $user ) {
43return $this->passwordReset->isAllowed( $user )->isGood();
44 }
45
46publicfunctioncheckExecutePermissions(User $user ) {
47 $status = Status::wrap( $this->passwordReset->isAllowed( $user ) );
48if ( !$status->isGood() ) {
49thrownewErrorPageError('internalerror', $status->getMessage() );
50 }
51
52 parent::checkExecutePermissions( $user );
53 }
54
58publicfunctionexecute($par ) {
59 $out = $this->getOutput();
60 $out->disallowUserJs();
61 parent::execute($par );
62 }
63
65protectedfunctiongetFormFields() {
66 $resetRoutes = $this->getConfig()->get(MainConfigNames::PasswordResetRoutes );
67 $a = [];
68if ( isset( $resetRoutes['username'] ) && $resetRoutes['username'] ) {
69 $a['Username'] = [
70'type' =>'user',
71'default' => $this->getRequest()->getSession()->suggestLoginUsername(),
72'label-message' =>'passwordreset-username',
73'excludetemp' =>true,
74 ];
75
76if ( $this->getUser()->isRegistered() ) {
77 $a['Username']['default'] = $this->getUser()->getName();
78 }
79 }
80
81if ( isset( $resetRoutes['email'] ) && $resetRoutes['email'] ) {
82 $a['Email'] = [
83'type' =>'email',
84'label-message' =>'passwordreset-email',
85 ];
86 }
87
88return $a;
89 }
90
92protectedfunctiongetDisplayFormat() {
93return'ooui';
94 }
95
96publicfunctionalterForm(HTMLForm $form ) {
97 $resetRoutes = $this->getConfig()->get(MainConfigNames::PasswordResetRoutes );
98
99 $form->setSubmitDestructive();
100
101 $form->addHiddenFields( $this->getRequest()->getValues('returnto','returntoquery' ) );
102
103 $i = 0;
104if ( isset( $resetRoutes['username'] ) && $resetRoutes['username'] ) {
105 $i++;
106 }
107if ( isset( $resetRoutes['email'] ) && $resetRoutes['email'] ) {
108 $i++;
109 }
110
111 $message = ( $i > 1 ) ?'passwordreset-text-many' :'passwordreset-text-one';
112
113 $form->setHeaderHtml( $this->msg( $message, $i )->parseAsBlock() );
114 $form->setSubmitTextMsg('mailmypassword' );
115 }
116
125publicfunctiononSubmit( array $data ) {
126 $username = $data['Username'] ??null;
127 $email = $data['Email'] ??null;
128
129 $result = Status::wrap(
130 $this->passwordReset->execute( $this->getUser(), $username, $email ) );
131
132if ( $result->hasMessage('actionthrottledtext' ) ) {
133thrownewThrottledError;
134 }
135
136// Show a message on the successful processing of the form.
137// This doesn't necessarily mean a reset email was sent.
138if ( $result->isGood() ) {
139 $output = $this->getOutput();
140
141// Information messages.
142 $output->addWikiMsg('passwordreset-success' );
143 $output->addWikiMsg('passwordreset-success-details-generic',
145
146// Confirmation of what the user has just submitted.
147 $info ="\n";
148if ( $username ) {
149 $info .="* " . $this->msg('passwordreset-username' ) .' '
150 .wfEscapeWikiText( $username ) ."\n";
151 }
152if ( $email ) {
153 $info .="* " . $this->msg('passwordreset-email' ) .' '
154 .wfEscapeWikiText( $email ) ."\n";
155 }
156 $output->addWikiMsg('passwordreset-success-info', $info );
157
158// Add a return to link to the main page.
159 $output->returnToMain();
160 }
161
162return $result;
163 }
164
169publicfunctionisListed() {
170if ( !$this->passwordReset->isEnabled()->isGood() ) {
171returnfalse;
172 }
173
174return parent::isListed();
175 }
176
178protectedfunctiongetGroupName() {
179return'login';
180 }
181}
182
187class_alias( SpecialPasswordReset::class,'SpecialPasswordReset' );
wfEscapeWikiText
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
DefinitionGlobalFunctions.php:1060
MediaWiki\Exception\ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
DefinitionErrorPageError.php:21
MediaWiki\Exception\ThrottledError
Show an error when the user hits a rate limit.
DefinitionThrottledError.php:16
MediaWiki\HTMLForm\HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
DefinitionHTMLForm.php:195
MediaWiki\HTMLForm\HTMLForm\setHeaderHtml
setHeaderHtml( $html, $section=null)
Set header HTML, inside the form.
DefinitionHTMLForm.php:936
MediaWiki\HTMLForm\HTMLForm\setSubmitTextMsg
setSubmitTextMsg( $msg)
Set the text for the submit button to a message.
DefinitionHTMLForm.php:1540
MediaWiki\HTMLForm\HTMLForm\addHiddenFields
addHiddenFields(array $fields)
Add an array of hidden fields to the output Array values are discarded for security reasons (per WebR...
DefinitionHTMLForm.php:1098
MediaWiki\HTMLForm\HTMLForm\setSubmitDestructive
setSubmitDestructive()
Identify that the submit button in the form has a destructive action.
DefinitionHTMLForm.php:1526
MediaWiki\MainConfigNames
A class containing constants representing the names of configuration variables.
DefinitionMainConfigNames.php:22
MediaWiki\MainConfigNames\PasswordReminderResendTime
const PasswordReminderResendTime
Name constant for the PasswordReminderResendTime setting, for use with Config::get()
DefinitionMainConfigNames.php:966
MediaWiki\MainConfigNames\PasswordResetRoutes
const PasswordResetRoutes
Name constant for the PasswordResetRoutes setting, for use with Config::get()
DefinitionMainConfigNames.php:2613
MediaWiki\SpecialPage\FormSpecialPage
Special page which uses an HTMLForm to handle processing.
DefinitionFormSpecialPage.php:26
MediaWiki\SpecialPage\FormSpecialPage\$par
string null $par
The subpage of the special page.
DefinitionFormSpecialPage.php:31
MediaWiki\SpecialPage\SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
DefinitionSpecialPage.php:884
MediaWiki\SpecialPage\SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
DefinitionSpecialPage.php:949
MediaWiki\SpecialPage\SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
DefinitionSpecialPage.php:864
MediaWiki\SpecialPage\SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
DefinitionSpecialPage.php:985
MediaWiki\SpecialPage\SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
DefinitionSpecialPage.php:874
MediaWiki\Specials\SpecialPasswordReset
Special page for requesting a password reset email.
DefinitionSpecialPasswordReset.php:27
MediaWiki\Specials\SpecialPasswordReset\isListed
isListed()
Hide the password reset page if resets are disabled.
DefinitionSpecialPasswordReset.php:169
MediaWiki\Specials\SpecialPasswordReset\execute
execute( $par)
DefinitionSpecialPasswordReset.php:58
MediaWiki\Specials\SpecialPasswordReset\onSubmit
onSubmit(array $data)
Process the form.
DefinitionSpecialPasswordReset.php:125
MediaWiki\Specials\SpecialPasswordReset\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
DefinitionSpecialPasswordReset.php:178
MediaWiki\Specials\SpecialPasswordReset\userCanExecute
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
DefinitionSpecialPasswordReset.php:42
MediaWiki\Specials\SpecialPasswordReset\doesWrites
doesWrites()
Indicates whether POST requests to this special page require write access to the wiki....
DefinitionSpecialPasswordReset.php:37
MediaWiki\Specials\SpecialPasswordReset\alterForm
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
DefinitionSpecialPasswordReset.php:96
MediaWiki\Specials\SpecialPasswordReset\getFormFields
getFormFields()
Get an HTMLForm descriptor array.array
DefinitionSpecialPasswordReset.php:65
MediaWiki\Specials\SpecialPasswordReset\getDisplayFormat
getDisplayFormat()
Get display format for the form.See HTMLForm documentation for available values.1....
DefinitionSpecialPasswordReset.php:92
MediaWiki\Specials\SpecialPasswordReset\checkExecutePermissions
checkExecutePermissions(User $user)
Called from execute() to check if the given user can perform this action.
DefinitionSpecialPasswordReset.php:46
MediaWiki\Specials\SpecialPasswordReset\__construct
__construct(PasswordReset $passwordReset)
DefinitionSpecialPasswordReset.php:30
MediaWiki\Status\Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
DefinitionStatus.php:44
MediaWiki\User\PasswordReset
Password reset helper for functionality shared by the web UI and the API.
DefinitionPasswordReset.php:35
MediaWiki\User\User
User class for the MediaWiki software.
DefinitionUser.php:109
MediaWiki\Specials

[8]ページ先頭

©2009-2025 Movatter.jp