mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-09-24 10:48:29 +00:00
Merge "MinervaPermissions must respect $wgHideInterlanguageLinks config"
This commit is contained in:
commit
ab3fb1d148
|
@ -108,11 +108,18 @@ final class MinervaPagePermissions implements IMinervaPagePermissions {
|
|||
* @throws ConfigException
|
||||
*/
|
||||
public function isAllowed( $action ) {
|
||||
global $wgHideInterlanguageLinks;
|
||||
|
||||
// T206406: Enable "Talk" or "Discussion" button on Main page, also, not forgetting
|
||||
// the "switch-language" button. But disable "edit" and "watch" actions.
|
||||
if ( $this->title->isMainPage() ) {
|
||||
return ( in_array( $action, $this->config->get( 'MinervaPageActions' ) )
|
||||
&& ( $action === self::TALK || $action === self::SWITCH_LANGUAGE ) );
|
||||
if ( !in_array( $action, $this->config->get( 'MinervaPageActions' ) ) ) {
|
||||
return false;
|
||||
}
|
||||
if ( $action === self::SWITCH_LANGUAGE ) {
|
||||
return !$wgHideInterlanguageLinks;
|
||||
}
|
||||
return $action === self::TALK;
|
||||
}
|
||||
|
||||
if ( $action === self::HISTORY && $this->title->exists() ) {
|
||||
|
@ -138,6 +145,9 @@ final class MinervaPagePermissions implements IMinervaPagePermissions {
|
|||
}
|
||||
|
||||
if ( $action === self::SWITCH_LANGUAGE ) {
|
||||
if ( $wgHideInterlanguageLinks ) {
|
||||
return false;
|
||||
}
|
||||
$hasVariants = $this->title->getPageLanguage()->hasVariants();
|
||||
$hasLanguages = count( $this->output->getLanguageLinks() );
|
||||
|
||||
|
|
|
@ -151,6 +151,28 @@ class MinervaPagePermissionsTest extends MediaWikiTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* MediaWiki defines wgHideInterlanguageLinks which is default set to false, but some wikis
|
||||
* can set this config to true. Minerva page permissions must respect that
|
||||
* @covers ::isAllowed
|
||||
*/
|
||||
public function testGlobalHideLanguageLinksTakesPrecedenceOnMainPage() {
|
||||
$this->setMwGlobals( [ 'wgHideInterlanguageLinks' => true ] );
|
||||
$perms = $this->buildPermissionsObject( Title::newMainPage() );
|
||||
$this->assertFalse( $perms->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* MediaWiki defines wgHideInterlanguageLinks which is default set to false, but some wikis
|
||||
* can set this config to true. Minerva page permissions must respect that
|
||||
* @covers ::isAllowed
|
||||
*/
|
||||
public function testGlobalHideLanguageLinksTakesPrecedence() {
|
||||
$this->setMwGlobals( [ 'wgHideInterlanguageLinks' => true ] );
|
||||
$perms = $this->buildPermissionsObject( Title::newFromText( 'test' ) );
|
||||
$this->assertFalse( $perms->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* The "switch-language" page action is allowed when: v2 of the page action bar is enabled and
|
||||
* if the page has interlanguage links or if the <code>$wgMinervaAlwaysShowLanguageButton</code>
|
||||
|
|
Loading…
Reference in a new issue