From 0ef5e9d3ffe08b4f984d8e21e35cf728d0c72899 Mon Sep 17 00:00:00 2001 From: odain Date: Tue, 15 Nov 2022 09:49:36 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B05620=20-=20Hide=20the=20organization=20f?= =?UTF-8?q?ilter=20with=20a=20conf=20parameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config.class.inc.php | 12 +++- .../Layout/NavigationMenu/NavigationMenu.php | 21 ++++-- .../UI/Base/Layout/NavigationMenuTest.php | 67 +++++++++++++++++++ 3 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 test/application/UI/Base/Layout/NavigationMenuTest.php diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 414d15909..110675028 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1254,6 +1254,14 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ], + 'navigation_menu.show_organization_filter' => [ + 'type' => 'bool', + 'description' => 'Display organization filter in menu', + 'default' => true, + 'value' => true, + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ], 'quick_create.enabled' => [ 'type' => 'bool', 'description' => 'Whether or not the quick create is enabled', @@ -1885,7 +1893,7 @@ class Config } if (strlen($sNoise) > 0) { - // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack) + // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack) throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => ''.utils::EscapeHtml($sNoise, ENT_QUOTES).'')); } @@ -2695,7 +2703,7 @@ class ConfigPlaceholdersResolver } $sPattern = '/\%(env|server)\((\w+)\)(?:\?:(\w*))?\%/'; //3 capturing groups, ie `%env(HTTP_PORT)?:8080%` produce: `env` `HTTP_PORT` and `8080`. - + if (! preg_match_all($sPattern, $rawValue, $aMatchesCollection, PREG_SET_ORDER)) { return $rawValue; diff --git a/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php b/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php index 6229d755c..6dd7b91d6 100644 --- a/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php +++ b/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php @@ -19,7 +19,6 @@ namespace Combodo\iTop\Application\UI\Base\Layout\NavigationMenu; - use ApplicationContext; use ApplicationMenu; use appUserPreferences; @@ -196,7 +195,7 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut } return ''; } - + /** * @return array */ @@ -290,6 +289,14 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut } } + /** + * @return True if the silo selection is enabled, false otherwise + * @since 3.1.0 + */ + public function IsSiloSelectionEnabled() : bool { + return MetaModel::GetConfig()->Get('navigation_menu.show_organization_filter'); + } + /** * @return void * @throws \CoreException @@ -301,6 +308,10 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut $this->bHasSiloSelected = false; $this->sSiloLabel = null; + if (! $this->IsSiloSelectionEnabled()){ + return; + } + //TODO 3.0 Use components if we have the time to build select/autocomplete components before release // List of visible Organizations $iCount = 0; @@ -343,7 +354,7 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut $this->aSiloSelection['html'] = '
'; //