MediaWiki  1.34.0
UserNotLoggedIn.php
Go to the documentation of this file.
1 <?php
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 
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 }
UserNotLoggedIn
Redirect a user to the login page.
Definition: UserNotLoggedIn.php:53
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:83
$output
$output
Definition: SyntaxHighlight.php:335
MWException\msg
msg( $key, $fallback,... $params)
Get a message from i18n.
Definition: MWException.php:75
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:431
$context
$context
Definition: load.php:45
ErrorPageError\$params
$params
Definition: ErrorPageError.php:30
UserNotLoggedIn\__construct
__construct( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', $params=[])
Definition: UserNotLoggedIn.php:66
UserNotLoggedIn\report
report( $action=self::SEND_OUTPUT)
Redirect to Special:Userlogin if the specified message is compatible.
Definition: UserNotLoggedIn.php:78
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
LoginHelper\getValidErrorMessages
static getValidErrorMessages()
Returns an array of all valid error messages.
Definition: LoginHelper.php:37
ErrorPageError\$msg
$msg
Definition: ErrorPageError.php:30
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