Skip to content

Commit

Permalink
#10061 Simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jun 20, 2024
1 parent 97e98d3 commit fb5d781
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions pages/admin/AdminHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,34 +251,23 @@ 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;
// The multi context UI is also displayed when the journal has no contexts
$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 fb5d781

Please sign in to comment.