Skip to content

Commit

Permalink
User: Drop method loadNavigationConfig()
Browse files Browse the repository at this point in the history
refs #10246
  • Loading branch information
Johannes Meyer committed Sep 30, 2015
1 parent befbc6c commit 037fee2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
6 changes: 2 additions & 4 deletions application/forms/Navigation/NavigationConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ public function edit($name, array $data)
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()
Expand Down Expand Up @@ -537,8 +536,7 @@ public function unshare($name, $parent = null)
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) {
Expand Down
22 changes: 3 additions & 19 deletions library/Icinga/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,22 +479,6 @@ public function can($requiredPermission)
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
*
Expand All @@ -504,12 +488,12 @@ public function loadNavigationConfig()
*/
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;
}
Expand All @@ -525,7 +509,7 @@ public function getNavigation($type)
);
}
} else {
$navigation = Navigation::fromConfig($config->select()->where('type', $type));
$navigation = Navigation::fromConfig($config);
}

return $navigation;
Expand Down

0 comments on commit 037fee2

Please sign in to comment.