MediaWiki
REL1_34
UserNotLoggedIn.php
Go to the documentation of this file.
1
<?php
53
class
UserNotLoggedIn
extends
ErrorPageError
{
54
66
public
function
__construct
(
67
$reasonMsg =
'exception-nologin-text'
,
68
$titleMsg =
'exception-nologin'
,
69
$params
= []
70
) {
71
parent::__construct( $titleMsg, $reasonMsg,
$params
);
72
}
73
78
public
function
report
( $action = self::SEND_OUTPUT ) {
79
// If an unsupported message is used, don't try redirecting to Special:Userlogin,
80
// since the message may not be compatible.
81
if
( !in_array( $this->
msg
,
LoginHelper::getValidErrorMessages
() ) ) {
82
parent::report( $action );
83
return
;
84
}
85
86
// Message is valid. Redirect to Special:Userlogin
87
88
$context
= RequestContext::getMain();
89
90
$output =
$context
->getOutput();
91
$query =
$context
->getRequest()->getValues();
92
// Title will be overridden by returnto
93
unset( $query[
'title'
] );
94
// Redirect to Special:Userlogin
95
$output->redirect( SpecialPage::getTitleFor(
'Userlogin'
)->getFullURL( [
96
// Return to this page when the user logs in
97
'returnto'
=>
$context
->getTitle()->getFullText(),
98
'returntoquery'
=>
wfArrayToCgi
( $query ),
99
'warning'
=> $this->
msg
,
100
] ) );
101
102
if
( $action === self::SEND_OUTPUT ) {
103
$output->output();
104
}
105
}
106
}
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:347
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:27
ErrorPageError\$params
$params
Definition
ErrorPageError.php:30
LoginHelper\getValidErrorMessages
static getValidErrorMessages()
Returns an array of all valid error messages.
Definition
LoginHelper.php:37
MWException\msg
msg( $key, $fallback,... $params)
Get a message from i18n.
Definition
MWException.php:75
UserNotLoggedIn
Redirect a user to the login page.
Definition
UserNotLoggedIn.php:53
UserNotLoggedIn\report
report( $action=self::SEND_OUTPUT)
Redirect to Special:Userlogin if the specified message is compatible.
Definition
UserNotLoggedIn.php:78
UserNotLoggedIn\__construct
__construct( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', $params=[])
Definition
UserNotLoggedIn.php:66
$context
$context
Definition
load.php:45
includes
exception
UserNotLoggedIn.php
Generated on Fri Apr 5 2024 23:09:52 for MediaWiki by
1.9.8