From 06b6356de1b941e1853c650f8c53de60173cd56b Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 23 Jun 2018 11:17:56 +0200 Subject: [PATCH] Dashboard: show DB selection only for setups... ...with multiple DBs --- application/controllers/DashboardController.php | 9 ++++++--- library/Director/Web/Controller/Extension/DirectorDb.php | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 505bb753..2200448a 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -10,13 +10,16 @@ class DashboardController extends ActionController { protected function checkDirectorPermissions() { + // No special permissions required, override parent method } protected function addDbSelection() { - $form = new DbSelectorForm($this->Window(), $this->listAllowedDbResourceNames()); - $this->content()->add($form); - $form->handleRequest($this->getRequest()); + if ($this->isMultiDbSetup()) { + $form = new DbSelectorForm($this->Window(), $this->listAllowedDbResourceNames()); + $this->content()->add($form); + $form->handleRequest($this->getRequest()); + } } /** diff --git a/library/Director/Web/Controller/Extension/DirectorDb.php b/library/Director/Web/Controller/Extension/DirectorDb.php index f6e97036..4486af94 100644 --- a/library/Director/Web/Controller/Extension/DirectorDb.php +++ b/library/Director/Web/Controller/Extension/DirectorDb.php @@ -66,6 +66,11 @@ trait DirectorDb return preg_split('/\s*,\s*/', $string, -1, PREG_SPLIT_NO_EMPTY); } + protected function isMultiDbSetup() + { + return count($this->listAvailableDbResourceNames()) > 1; + } + /** * @return array */