Skip to content

Commit

Permalink
pkp#10061 Simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jun 19, 2024
1 parent 97e98d3 commit 8d12f57
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions pages/admin/AdminHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,34 +251,22 @@ public function settings($args, $request)
*/
private function siteSettingsAvailability(): array
{
$tabs = array_fill_keys([
'siteSetup',
'siteAppearance',
'sitePlugins',
'siteConfig',
'siteInfo',
'languages',
'navigationMenus',
'highlights',
'bulkEmails',
'siteTheme',
'siteAppearanceSetup',
'statistics',
'announcements',
], true);

$tabs['announcements'] = (bool) Config::getVar('features', 'site_announcements');
$tabs['highlights'] = (bool) Config::getVar('features', 'highlights');

$isSingleContextSite = Services::get('context')->getCount() < 2;
if ($isSingleContextSite) {
$multipleContextTabs = ['siteSetup', 'languages', 'bulkEmails', 'statistics'];
foreach ($multipleContextTabs as $tab) {
$tabs[$tab] = false;
}
}

return $tabs;
$isMultiContextSite = Services::get('context')->getCount() >= 1;
return [
'siteSetup' => true,
'languages' => true,
'bulkEmails' => true,
'statistics' => true,
'siteAppearance' => $isMultiContextSite,
'sitePlugins' => $isMultiContextSite,
'siteConfig' => $isMultiContextSite,
'siteInfo' => $isMultiContextSite,
'navigationMenus' => $isMultiContextSite,
'highlights' => $isMultiContextSite && Config::getVar('features', 'highlights'),
'siteTheme' => $isMultiContextSite,
'siteAppearanceSetup' => $isMultiContextSite,
'announcements' => $isMultiContextSite && Config::getVar('features', 'site_announcements'),
];
}

/**
Expand Down

0 comments on commit 8d12f57

Please sign in to comment.