summaryrefslogtreecommitdiffstats
path: root/library/Director/ProvidedHook/CubeLinks.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:31 +0000
commitf66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch)
treefbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/ProvidedHook/CubeLinks.php
parentInitial commit. (diff)
downloadicingaweb2-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/ProvidedHook/CubeLinks.php')
-rw-r--r--library/Director/ProvidedHook/CubeLinks.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/library/Director/ProvidedHook/CubeLinks.php b/library/Director/ProvidedHook/CubeLinks.php
new file mode 100644
index 0000000..2cb9559
--- /dev/null
+++ b/library/Director/ProvidedHook/CubeLinks.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Icinga\Module\Director\ProvidedHook;
+
+use Icinga\Data\Filter\Filter;
+use Icinga\Module\Cube\Cube;
+use Icinga\Module\Cube\Hook\ActionsHook;
+use Icinga\Module\Cube\Ido\IdoHostStatusCube;
+use Icinga\Web\View;
+
+class CubeLinks extends ActionsHook
+{
+ /**
+ * @inheritdoc
+ */
+ public function prepareActionLinks(Cube $cube, View $view)
+ {
+ if (! $cube instanceof IdoHostStatusCube) {
+ return;
+ }
+
+ $cube->finalizeInnerQuery();
+ $query = $cube->innerQuery()
+ ->reset('columns')
+ ->columns(array('host' => 'o.name1'))
+ ->reset('group');
+
+ $hosts = $cube->db()->fetchCol($query);
+
+ $count = count($hosts);
+ if ($count === 1) {
+ $url = 'director/host/edit';
+ $params = array('name' => $hosts[0]);
+
+ $title = $view->translate('Modify a host');
+ $description = sprintf(
+ $view->translate('This allows you to modify properties for "%s"'),
+ $hosts[0]
+ );
+ } else {
+ $params = null;
+
+ $filter = Filter::matchAny();
+ foreach ($hosts as $host) {
+ $filter->addFilter(
+ Filter::matchAny(Filter::expression('name', '=', $host))
+ );
+ }
+
+ $url = 'director/hosts/edit?' . $filter->toQueryString();
+
+ $title = sprintf($view->translate('Modify %d hosts'), $count);
+ $description = $view->translate(
+ 'This allows you to modify properties for all chosen hosts at once'
+ );
+ }
+
+ $this->addActionLink(
+ $this->makeUrl($url, $params),
+ $title,
+ $description,
+ 'wrench'
+ );
+ }
+}