summaryrefslogtreecommitdiffstats
path: root/library/Director/Web/Tabs
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Web/Tabs')
-rw-r--r--library/Director/Web/Tabs/InfraTabs.php7
-rw-r--r--library/Director/Web/Tabs/MainTabs.php5
-rw-r--r--library/Director/Web/Tabs/ObjectTabs.php35
-rw-r--r--library/Director/Web/Tabs/ObjectsTabs.php58
4 files changed, 53 insertions, 52 deletions
diff --git a/library/Director/Web/Tabs/InfraTabs.php b/library/Director/Web/Tabs/InfraTabs.php
index 8a65c4e..ea7a0cc 100644
--- a/library/Director/Web/Tabs/InfraTabs.php
+++ b/library/Director/Web/Tabs/InfraTabs.php
@@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Web\Tabs;
use Icinga\Authentication\Auth;
use gipfl\Translation\TranslationHelper;
use gipfl\IcingaWeb2\Widget\Tabs;
+use Icinga\Module\Director\Auth\Permission;
class InfraTabs extends Tabs
{
@@ -24,21 +25,21 @@ class InfraTabs extends Tabs
{
$auth = $this->auth;
- if ($auth->hasPermission('director/audit')) {
+ if ($auth->hasPermission(Permission::AUDIT)) {
$this->add('activitylog', [
'label' => $this->translate('Activity Log'),
'url' => 'director/config/activities'
]);
}
- if ($auth->hasPermission('director/deploy')) {
+ if ($auth->hasPermission(Permission::DEPLOY)) {
$this->add('deploymentlog', [
'label' => $this->translate('Deployments'),
'url' => 'director/config/deployments'
]);
}
- if ($auth->hasPermission('director/admin')) {
+ if ($auth->hasPermission(Permission::ADMIN)) {
$this->add('infrastructure', [
'label' => $this->translate('Infrastructure'),
'url' => 'director/dashboard',
diff --git a/library/Director/Web/Tabs/MainTabs.php b/library/Director/Web/Tabs/MainTabs.php
index 5ea2e9b..48ffa7c 100644
--- a/library/Director/Web/Tabs/MainTabs.php
+++ b/library/Director/Web/Tabs/MainTabs.php
@@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Web\Tabs;
use gipfl\Translation\TranslationHelper;
use gipfl\IcingaWeb2\Widget\Tabs;
use Icinga\Authentication\Auth;
+use Icinga\Module\Director\Auth\Permission;
use Icinga\Module\Director\Web\Widget\Daemon\BackgroundDaemonState;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Health;
@@ -26,7 +27,7 @@ class MainTabs extends Tabs
'label' => $this->translate('Overview'),
'url' => 'director'
]);
- if ($this->auth->hasPermission('director/admin')) {
+ if ($this->auth->hasPermission(Permission::ADMIN)) {
$this->add('health', [
'label' => $this->translate('Health'),
'url' => 'director/health'
@@ -39,7 +40,7 @@ class MainTabs extends Tabs
public function render()
{
- if ($this->auth->hasPermission('director/admin')) {
+ if ($this->auth->hasPermission(Permission::ADMIN)) {
if ($this->getActiveName() !== 'health') {
$state = $this->getHealthState();
if ($state->isProblem()) {
diff --git a/library/Director/Web/Tabs/ObjectTabs.php b/library/Director/Web/Tabs/ObjectTabs.php
index cbd3f15..c355304 100644
--- a/library/Director/Web/Tabs/ObjectTabs.php
+++ b/library/Director/Web/Tabs/ObjectTabs.php
@@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Web\Tabs;
use Icinga\Authentication\Auth;
+use Icinga\Module\Director\Auth\Permission;
use Icinga\Module\Director\Objects\IcingaObject;
use gipfl\Translation\TranslationHelper;
use gipfl\IcingaWeb2\Widget\Tabs;
@@ -46,10 +47,10 @@ class ObjectTabs extends Tabs
protected function addTabsForNewObject()
{
$type = $this->type;
- $this->add('add', array(
+ $this->add('add', [
'url' => sprintf('director/%s/add', $type),
'label' => sprintf($this->translate('Add %s'), ucfirst($type)),
- ));
+ ]);
}
protected function addTabsForExistingObject()
@@ -59,14 +60,12 @@ class ObjectTabs extends Tabs
$object = $this->object;
$params = $object->getUrlParams();
- if (! $object->isExternal()
- || in_array($object->getShortTableName(), $this->allowedExternals)
- ) {
- $this->add('modify', array(
+ if (! $object->isExternal() || in_array($object->getShortTableName(), $this->allowedExternals)) {
+ $this->add('modify', [
'url' => sprintf('director/%s', $type),
'urlParams' => $params,
'label' => $this->translate(ucfirst($type))
- ));
+ ]);
}
if ($object->getShortTableName() === 'host') {
$this->add('services', [
@@ -76,19 +75,17 @@ class ObjectTabs extends Tabs
]);
}
- if ($auth->hasPermission('director/showconfig')) {
- if ($object->getShortTableName() !== 'service'
- || $object->get('service_set_id') === null
- ) {
- $this->add('render', array(
+ if ($auth->hasPermission(Permission::SHOW_CONFIG)) {
+ if ($object->getShortTableName() !== 'service' || $object->get('service_set_id') === null) {
+ $this->add('render', [
'url' => sprintf('director/%s/render', $type),
'urlParams' => $params,
'label' => $this->translate('Preview'),
- ));
+ ]);
}
}
- if ($auth->hasPermission('director/audit')) {
+ if ($auth->hasPermission(Permission::AUDIT)) {
$this->add('history', array(
'url' => sprintf('director/%s/history', $type),
'urlParams' => $params,
@@ -96,7 +93,7 @@ class ObjectTabs extends Tabs
));
}
- if ($auth->hasPermission('director/admin') && $this->hasFields()) {
+ if ($auth->hasPermission(Permission::ADMIN) && $this->hasFields()) {
$this->add('fields', array(
'url' => sprintf('director/%s/fields', $type),
'urlParams' => $params,
@@ -117,7 +114,7 @@ class ObjectTabs extends Tabs
if ($object->supportsRanges()) {
$this->add('ranges', [
- 'url' => "director/${type}/ranges",
+ 'url' => "director/{$type}/ranges",
'urlParams' => $params,
'label' => $this->translate('Ranges')
]);
@@ -138,11 +135,11 @@ class ObjectTabs extends Tabs
]);
}
- if ($object->getShortTableName() === 'host' && $auth->hasPermission('director/hosts')) {
+ if ($object->getShortTableName() === 'host' && $auth->hasPermission(Permission::HOSTS)) {
$this->add('agent', [
- 'url' => 'director/host/agent',
+ 'url' => 'director/host/agent',
'urlParams' => $params,
- 'label' => $this->translate('Agent')
+ 'label' => $this->translate('Agent')
]);
}
}
diff --git a/library/Director/Web/Tabs/ObjectsTabs.php b/library/Director/Web/Tabs/ObjectsTabs.php
index 4f9e5a8..9d2a737 100644
--- a/library/Director/Web/Tabs/ObjectsTabs.php
+++ b/library/Director/Web/Tabs/ObjectsTabs.php
@@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Web\Tabs;
use Icinga\Authentication\Auth;
+use Icinga\Module\Director\Auth\Permission;
use Icinga\Module\Director\Objects\IcingaObject;
use gipfl\Translation\TranslationHelper;
use gipfl\IcingaWeb2\Widget\Tabs;
@@ -21,65 +22,66 @@ class ObjectsTabs extends Tabs
$plType = strtolower(preg_replace('/cys$/', 'cies', $shortName . 's'));
$plType = str_replace('_', '-', $plType);
- if ($auth->hasPermission("director/${plType}")) {
- $this->add('index', array(
+ if ($auth->hasPermission("director/{$plType}")) {
+ $this->add('index', [
'url' => sprintf('director/%s', $plType),
'label' => $this->translate(ucfirst($plType)),
- ));
+ ]);
}
if ($object->getShortTableName() === 'command') {
- $this->add('external', array(
- 'url' => sprintf('director/%s', strtolower($plType)),
+ $this->add('external', [
+ 'url' => sprintf('director/%s', strtolower($plType)),
'urlParams' => ['type' => 'external_object'],
- 'label' => $this->translate('External'),
- ));
+ 'label' => $this->translate('External'),
+ ]);
}
- if ($auth->hasPermission('director/admin') || (
+ if ($auth->hasPermission(Permission::ADMIN)
+ || (
$object->getShortTableName() === 'notification'
- && $auth->hasPermission('director/notifications')
+ && $auth->hasPermission(Permission::NOTIFICATIONS)
) || (
$object->getShortTableName() === 'scheduled_downtime'
- && $auth->hasPermission('director/scheduled-downtimes')
+ && $auth->hasPermission(Permission::SCHEDULED_DOWNTIMES)
)) {
if ($object->supportsApplyRules()) {
- $this->add('applyrules', array(
- 'url' => sprintf('director/%s/applyrules', $plType),
+ $this->add('applyrules', [
+ 'url' => sprintf('director/%s/applyrules', $plType),
'label' => $this->translate('Apply')
- ));
+ ]);
}
}
- if ($auth->hasPermission('director/admin') && $type !== 'zone') {
+ if ($auth->hasPermission(Permission::ADMIN) && $type !== 'zone') {
if ($object->supportsImports()) {
- $this->add('templates', array(
- 'url' => sprintf('director/%s/templates', $plType),
+ $this->add('templates', [
+ 'url' => sprintf('director/%s/templates', $plType),
'label' => $this->translate('Templates'),
- ));
+ ]);
}
if ($object->supportsGroups()) {
- $this->add('groups', array(
- 'url' => sprintf('director/%sgroups', $typeUrl),
+ $this->add('groups', [
+ 'url' => sprintf('director/%sgroups', $typeUrl),
'label' => $this->translate('Groups')
- ));
+ ]);
}
}
- if ($auth->hasPermission('director/admin')) {
+ if ($auth->hasPermission(Permission::ADMIN)) {
if ($object->supportsChoices()) {
- $this->add('choices', array(
- 'url' => sprintf('director/templatechoices/%s', $shortName),
+ $this->add('choices', [
+ 'url' => sprintf('director/templatechoices/%s', $shortName),
'label' => $this->translate('Choices')
- ));
+ ]);
}
}
- if ($object->supportsSets() && $auth->hasPermission("director/${typeUrl}sets")) {
- $this->add('sets', array(
- 'url' => sprintf('director/%s/sets', $plType),
+ if ($object->supportsSets() && $auth->hasPermission("director/{$typeUrl}sets")) {
+ $this->add('sets', [
+ 'url' => sprintf('director/%s/sets', $plType),
'label' => $this->translate('Sets')
- ));
+ ]);
}
}
}