ObjectTabs, Dashboard: fix small permission issues

...and show only tabs pointing to Dashboards with (allowed) Dashlets
This commit is contained in:
Thomas Gelf 2017-08-07 11:00:59 +02:00
parent 2acc6a2c07
commit 696390968d
3 changed files with 19 additions and 15 deletions

View File

@ -129,7 +129,9 @@ abstract class Dashboard extends Html implements Countable
$tabs = new Tabs();
foreach ($names as $name) {
$dashboard = Dashboard::loadByName($name, $this->getDb());
$tabs->add($name, $this->createTabForDashboard($dashboard));
if ($dashboard->isAvailable()) {
$tabs->add($name, $this->createTabForDashboard($dashboard));
}
}
return $tabs;

View File

@ -26,6 +26,6 @@ class ServiceSetsDashlet extends Dashlet
public function listRequiredPermissions()
{
return array('director/admin');
return array('director/service_sets');
}
}

View File

@ -18,10 +18,13 @@ class ObjectsTabs extends Tabs
$object = IcingaObject::createByType(substr($type, 0, -5));
}
$this->add('index', array(
'url' => sprintf('director/%ss', strtolower($type)),
'label' => $this->translate(ucfirst($type) . 's'),
));
// TODO: plural?
if ($auth->hasPermission("director/${type}s")) {
$this->add('index', array(
'url' => sprintf('director/%ss', strtolower($type)),
'label' => $this->translate(ucfirst($type) . 's'),
));
}
if ($object->getShortTableName() === 'command') {
$this->add('external', array(
@ -32,7 +35,7 @@ class ObjectsTabs extends Tabs
}
if ($auth->hasPermission('director/admin') || (
$object->getShortTableName() && $auth->hasPermission('director/notifications')
$object->getShortTableName() === 'notifications' && $auth->hasPermission('director/notifications')
)) {
if ($object->supportsApplyRules()) {
$this->add('applyrules', array(
@ -61,17 +64,16 @@ class ObjectsTabs extends Tabs
if ($auth->hasPermission('director/admin')) {
if ($object->supportsChoices()) {
$this->add('choices', array(
'url' => sprintf('director/templatechoices/%s', $type),
'url' => sprintf('director/templatechoices/%s', $type),
'label' => $this->translate('Choices')
));
}
if ($object->supportsSets()) {
$this->add('sets', array(
'url' => sprintf('director/%ss/sets', $type),
'label' => $this->translate('Sets')
));
}
}
if ($object->supportsSets() && $auth->hasPermission("director/${type}_sets")) {
$this->add('sets', array(
'url' => sprintf('director/%ss/sets', $type),
'label' => $this->translate('Sets')
));
}
}
}