MediaWiki REL1_39
UserNotLoggedIn.php
Go to the documentation of this file.
1<?php
55
69 public function __construct(
70 $reasonMsg = 'exception-nologin-text',
71 $titleMsg = 'exception-nologin',
72 $params = []
73 ) {
74 parent::__construct( $titleMsg, $reasonMsg, $params );
75 }
76
82 public function report( $action = self::SEND_OUTPUT ) {
83 // If an unsupported message is used, don't try redirecting to Special:Userlogin,
84 // since the message may not be compatible.
85 if ( !in_array( $this->msg, LoginHelper::getValidErrorMessages() ) ) {
86 parent::report( $action );
87 return;
88 }
89
90 // Message is valid. Redirect to Special:Userlogin
91
92 $context = RequestContext::getMain();
93
94 $output = $context->getOutput();
95 $query = $context->getRequest()->getValues();
96 // Title will be overridden by returnto
97 unset( $query['title'] );
98 // Redirect to Special:Userlogin
99 $output->redirect( SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( [
100 // Return to this page when the user logs in
101 'returnto' => $context->getTitle()->getFullText(),
102 'returntoquery' => wfArrayToCgi( $query ),
103 'warning' => $this->msg,
104 ] ) );
105
106 if ( $action === self::SEND_OUTPUT ) {
107 $output->output();
108 }
109 }
110}
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
An error page which can definitely be safely rendered using the OutputPage.
static getValidErrorMessages()
Returns an array of all valid error messages.
msg( $key, $fallback,... $params)
Get a message from i18n.
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,...
Redirect a user to the login page.
report( $action=self::SEND_OUTPUT)
Redirect to Special:Userlogin if the specified message is compatible.
__construct( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', $params=[])