Skip to content

Commit

Permalink
Fix sidebar permission check (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Jan 1, 2024
1 parent 046057b commit 63eae6a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions includes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,24 @@ public static function onCreateWikiStatePublic( $dbname ) {
}

public static function fnNewSidebarItem( $skin, &$bar ) {
$append = '';
$user = $skin->getUser();
$services = MediaWikiServices::getInstance();
$permissionManager = $services->getPermissionManager();
$userOptionsLookup = $services->getUserOptionsLookup();
if ( !$permissionManager->userHasRight( $user, 'managewiki' ) ) {
if ( !self::getConfig( 'ManageWikiForceSidebarLinks' ) && !$userOptionsLookup->getOption( $user, 'managewikisidebar', 0 ) ) {
return;
}
$append = '-view';
}

$hideSidebar = !self::getConfig( 'ManageWikiForceSidebarLinks' ) &&
!$userOptionsLookup->getOption( $user, 'managewikisidebar', 0 );

foreach ( (array)ManageWiki::listModules() as $module ) {
$append = '';
if ( !$permissionManager->userHasRight( $user, 'managewiki-' . $module ) ) {
if ( $hideSidebar ) {
continue;
}

$append = '-view';
}

$bar['managewiki-sidebar-header'][] = [
'text' => wfMessage( "managewiki-link-{$module}{$append}" )->plain(),
'id' => "managewiki{$module}link",
Expand Down

0 comments on commit 63eae6a

Please sign in to comment.