MediaWiki
1.41.2
UserNotLoggedIn.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\SpecialPage\SpecialPage
;
22
56
class
UserNotLoggedIn
extends
ErrorPageError
{
57
71
public
function
__construct
(
72
$reasonMsg =
'exception-nologin-text'
,
73
$titleMsg =
'exception-nologin'
,
74
$params = []
75
) {
76
parent::__construct( $titleMsg, $reasonMsg,
$params
);
77
}
78
84
public
function
report
( $action = self::SEND_OUTPUT ) {
85
// If an unsupported message is used, don't try redirecting to Special:Userlogin,
86
// since the message may not be compatible.
87
if
( !in_array( $this->
msg
, LoginHelper::getValidErrorMessages() ) ) {
88
parent::report( $action );
89
return
;
90
}
91
92
// Message is valid. Redirect to Special:Userlogin
93
94
$context = RequestContext::getMain();
95
96
$output = $context->getOutput();
97
$query = $context->getRequest()->getValues();
98
// Title will be overridden by returnto
99
unset( $query[
'title'
] );
100
// Redirect to Special:Userlogin
101
$output->redirect( SpecialPage::getTitleFor(
'Userlogin'
)->getFullURL( [
102
// Return to this page when the user logs in
103
'returnto'
=> $context->getTitle()->getFullText(),
104
'returntoquery'
=>
wfArrayToCgi
( $query ),
105
'warning'
=> $this->
msg
,
106
] ) );
107
108
if
( $action === self::SEND_OUTPUT ) {
109
$output->output();
110
}
111
}
112
}
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:340
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:30
ErrorPageError\$params
$params
Definition
ErrorPageError.php:33
MWException\msg
msg( $key, $fallback,... $params)
Get a message from i18n.
Definition
MWException.php:86
MediaWiki\SpecialPage\SpecialPage
Parent class for all special pages.
Definition
SpecialPage.php:65
UserNotLoggedIn
Redirect a user to the login page.
Definition
UserNotLoggedIn.php:56
UserNotLoggedIn\report
report( $action=self::SEND_OUTPUT)
Redirect to Special:Userlogin if the specified message is compatible.
Definition
UserNotLoggedIn.php:84
UserNotLoggedIn\__construct
__construct( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', $params=[])
Definition
UserNotLoggedIn.php:71
includes
exception
UserNotLoggedIn.php
Generated on Thu Jun 27 2024 15:41:51 for MediaWiki by
1.10.0