From 8d12f5709cb43224685155fa35efde7ddaa13abf Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Wed, 19 Jun 2024 20:50:23 +0300 Subject: [PATCH] pkp/pkp-lib#10061 Simplified code --- pages/admin/AdminHandler.php | 44 +++++++++++++----------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/pages/admin/AdminHandler.php b/pages/admin/AdminHandler.php index db41c7f1465..169cc4071a8 100644 --- a/pages/admin/AdminHandler.php +++ b/pages/admin/AdminHandler.php @@ -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'), + ]; } /**