MediaWiki
master
UserNotLoggedIn.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\Context\RequestContext
;
22
use
MediaWiki\SpecialPage\SpecialPage
;
23
57
class
UserNotLoggedIn
extends
ErrorPageError
{
58
72
public
function
__construct
(
73
$reasonMsg =
'exception-nologin-text'
,
74
$titleMsg =
'exception-nologin'
,
75
$params
= []
76
) {
77
parent::__construct( $titleMsg, $reasonMsg,
$params
);
78
}
79
85
public
function
report
( $action = self::SEND_OUTPUT ) {
86
// If an unsupported message is used, don't try redirecting to Special:Userlogin,
87
// since the message may not be compatible.
88
if
( !in_array( $this->
msg
, LoginHelper::getValidErrorMessages() ) ) {
89
parent::report( $action );
90
return
;
91
}
92
93
// Message is valid. Redirect to Special:Userlogin
94
95
$context = RequestContext::getMain();
96
97
$output = $context->getOutput();
98
$query = $context->getRequest()->getValues();
99
// Title will be overridden by returnto
100
unset( $query[
'title'
] );
101
// Redirect to Special:Userlogin
102
$output->redirect( SpecialPage::getTitleFor(
'Userlogin'
)->getFullURL( [
103
// Return to this page when the user logs in
104
'returnto'
=> $context->getTitle()->getFullText(),
105
'returntoquery'
=>
wfArrayToCgi
( $query ),
106
'warning'
=> $this->
msg
,
107
] ) );
108
109
if
( $action === self::SEND_OUTPUT ) {
110
$output->output();
111
}
112
}
113
}
wfArrayToCgi
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
Definition
GlobalFunctions.php:338
$params
array $params
The job parameters.
Definition
UploadJobTrait.php:45
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:30
MWException\msg
msg( $key, $fallback,... $params)
Get a message from i18n.
Definition
MWException.php:86
MediaWiki\Context\RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition
RequestContext.php:66
MediaWiki\SpecialPage\SpecialPage
Parent class for all special pages.
Definition
SpecialPage.php:66
UserNotLoggedIn
Redirect a user to the login page.
Definition
UserNotLoggedIn.php:57
UserNotLoggedIn\report
report( $action=self::SEND_OUTPUT)
Redirect to Special:Userlogin if the specified message is compatible.
Definition
UserNotLoggedIn.php:85
UserNotLoggedIn\__construct
__construct( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', $params=[])
Definition
UserNotLoggedIn.php:72
includes
exception
UserNotLoggedIn.php
Generated on Tue Apr 23 2024 07:31:41 for MediaWiki by
1.10.0