diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Web/Tabs/ObjectsTabs.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/Web/Tabs/ObjectsTabs.php')
-rw-r--r-- | library/Director/Web/Tabs/ObjectsTabs.php | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/library/Director/Web/Tabs/ObjectsTabs.php b/library/Director/Web/Tabs/ObjectsTabs.php new file mode 100644 index 0000000..4f9e5a8 --- /dev/null +++ b/library/Director/Web/Tabs/ObjectsTabs.php @@ -0,0 +1,85 @@ +<?php + +namespace Icinga\Module\Director\Web\Tabs; + +use Icinga\Authentication\Auth; +use Icinga\Module\Director\Objects\IcingaObject; +use gipfl\Translation\TranslationHelper; +use gipfl\IcingaWeb2\Widget\Tabs; + +class ObjectsTabs extends Tabs +{ + use TranslationHelper; + + public function __construct($type, Auth $auth, $typeUrl) + { + $object = IcingaObject::createByType($type); + if ($object->isGroup()) { + $object = IcingaObject::createByType(substr($typeUrl, 0, -5)); + } + $shortName = $object->getShortTableName(); + + $plType = strtolower(preg_replace('/cys$/', 'cies', $shortName . 's')); + $plType = str_replace('_', '-', $plType); + if ($auth->hasPermission("director/${plType}")) { + $this->add('index', array( + 'url' => sprintf('director/%s', $plType), + 'label' => $this->translate(ucfirst($plType)), + )); + } + + if ($object->getShortTableName() === 'command') { + $this->add('external', array( + 'url' => sprintf('director/%s', strtolower($plType)), + 'urlParams' => ['type' => 'external_object'], + 'label' => $this->translate('External'), + )); + } + + if ($auth->hasPermission('director/admin') || ( + $object->getShortTableName() === 'notification' + && $auth->hasPermission('director/notifications') + ) || ( + $object->getShortTableName() === 'scheduled_downtime' + && $auth->hasPermission('director/scheduled-downtimes') + )) { + if ($object->supportsApplyRules()) { + $this->add('applyrules', array( + 'url' => sprintf('director/%s/applyrules', $plType), + 'label' => $this->translate('Apply') + )); + } + } + + if ($auth->hasPermission('director/admin') && $type !== 'zone') { + if ($object->supportsImports()) { + $this->add('templates', array( + 'url' => sprintf('director/%s/templates', $plType), + 'label' => $this->translate('Templates'), + )); + } + + if ($object->supportsGroups()) { + $this->add('groups', array( + 'url' => sprintf('director/%sgroups', $typeUrl), + 'label' => $this->translate('Groups') + )); + } + } + + if ($auth->hasPermission('director/admin')) { + if ($object->supportsChoices()) { + $this->add('choices', array( + '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), + 'label' => $this->translate('Sets') + )); + } + } +} |