/**
* Produce the stock "please login to use the wiki" page
*/
public function loginToUse() {
global $wgUser, $wgTitle, $wgContLang;
if( $wgUser->isLoggedIn() ) {
$this->permissionRequired( 'read' );
return;
}
$skin = $wgUser->getSkin();
if($wgTitle->getNamespace() >= 100){
$usersNamespaces = $wgUser->getAllowedRNSes();
$usersNamespacesArray = explode("\n", $usersNamespaces);
$currentNamespace = Namespace::getCanonicalName($wgTitle->getNamespace());
if (!in_array($currentNamespace, $usersNamespacesArray)) {
$this->setPageTitle( wfMsg( 'noaccesstitle' ) );
$this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleFlag( false );
$this->addHTML( wfMsgHtml( 'noaccesstext') );
} else {
// Should never reach here.
}
} else {
$this->setPageTitle( wfMsg( 'loginreqtitle' ) );
$this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleFlag( false );
$loginTitle = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
$loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() );
$this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
$this->addHtml( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
# Don't return to the main page if the user can't read it
# otherwise we'll end up in a pointless loop
$mainPage = Title::newFromText( wfMsgForContent( 'mainpage' ) );
if( $mainPage->userCanRead() )
$this->returnToMain( true, $mainPage );
}
}