From 037fee298ba3b94f5df733480db5a6e24fb14b58 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 30 Sep 2015 11:38:14 +0200 Subject: [PATCH] User: Drop method loadNavigationConfig() refs #10246 --- .../forms/Navigation/NavigationConfigForm.php | 6 ++--- library/Icinga/User.php | 22 +++---------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/application/forms/Navigation/NavigationConfigForm.php b/application/forms/Navigation/NavigationConfigForm.php index 905ef95c6..a02653720 100644 --- a/application/forms/Navigation/NavigationConfigForm.php +++ b/application/forms/Navigation/NavigationConfigForm.php @@ -401,8 +401,7 @@ class NavigationConfigForm extends ConfigForm if ($ownerName === $this->getUser()->getUsername()) { $exists = $this->getUserConfig()->hasSection($name); } else { - $owner = new User($ownerName); - $exists = $owner->loadNavigationConfig()->hasSection($name); + $exists = Config::navigation($itemConfig->type, $ownerName)->hasSection($name); } } else { $exists = (bool) $this->getShareConfig() @@ -537,8 +536,7 @@ class NavigationConfigForm extends ConfigForm if (! $itemConfig->owner || $itemConfig->owner === $this->getUser()->getUsername()) { $config = $this->getUserConfig(); } else { - $owner = new User($itemConfig->owner); - $config = $owner->loadNavigationConfig(); + $config = Config::navigation($itemConfig->type, $itemConfig->owner); } foreach ($children as $child) { diff --git a/library/Icinga/User.php b/library/Icinga/User.php index 114e59755..7451747e7 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -479,22 +479,6 @@ class User return false; } - /** - * Load and return this user's navigation configuration - * - * @return Config - */ - public function loadNavigationConfig() - { - return Config::fromIni( - Config::resolvePath('preferences') - . DIRECTORY_SEPARATOR - . $this->getUsername() - . DIRECTORY_SEPARATOR - . 'navigation.ini' - ); - } - /** * Load and return this user's configured navigation of the given type * @@ -504,12 +488,12 @@ class User */ public function getNavigation($type) { - $config = $this->loadNavigationConfig(); + $config = Config::navigation($type === 'dashboard-pane' ? 'dashlet' : $type); $config->getConfigObject()->setKeyColumn('name'); if ($type === 'dashboard-pane') { $panes = array(); - foreach ($config->select()->where('type', 'dashlet') as $dashletName => $dashletConfig) { + foreach ($config as $dashletName => $dashletConfig) { // TODO: Throw ConfigurationError if pane or url is missing $panes[$dashletConfig->pane][$dashletName] = $dashletConfig->url; } @@ -525,7 +509,7 @@ class User ); } } else { - $navigation = Navigation::fromConfig($config->select()->where('type', $type)); + $navigation = Navigation::fromConfig($config); } return $navigation;