MediaWiki 1.41.2
UserNotLoggedIn.php
Go to the documentation of this file.
1<?php
22
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( $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.
msg( $key, $fallback,... $params)
Get a message from i18n.
Parent class for all special pages.
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=[])