summaryrefslogtreecommitdiffstats
path: root/application/forms/Events/AckFilterForm.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:43:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:43:29 +0000
commita9b77c01caef9ae7a2c84e2333d28ceb028cf4d3 (patch)
tree4a77cd3e323c37b0e5b3d7578b9718cdf1a89262 /application/forms/Events/AckFilterForm.php
parentInitial commit. (diff)
downloadicingaweb2-module-eventdb-a9b77c01caef9ae7a2c84e2333d28ceb028cf4d3.tar.xz
icingaweb2-module-eventdb-a9b77c01caef9ae7a2c84e2333d28ceb028cf4d3.zip
Adding upstream version 1.3.0.upstream/1.3.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/forms/Events/AckFilterForm.php')
-rw-r--r--application/forms/Events/AckFilterForm.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/application/forms/Events/AckFilterForm.php b/application/forms/Events/AckFilterForm.php
new file mode 100644
index 0000000..829c6ce
--- /dev/null
+++ b/application/forms/Events/AckFilterForm.php
@@ -0,0 +1,80 @@
+<?php
+/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
+
+namespace Icinga\Module\Eventdb\Forms\Events;
+
+use Icinga\Data\Filter\Filter;
+use Icinga\Web\Form;
+
+class AckFilterForm extends Form
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function init()
+ {
+ $this->setAttrib('class', 'inline ack-filter-form');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function addSubmitButton()
+ {
+ if ((bool) $this->getRequest()->getUrl()->getParams()->get('ack', true)) {
+ $icon = 'ok';
+ $title = $this->translate('Hide acknowledged events');
+ } else {
+ $icon = 'cancel';
+ $title = $this->translate('Show also acknowledged events');
+ }
+
+ $this->addElements(array(
+ array(
+ 'button',
+ 'btn_submit',
+ array(
+ 'class' => 'link-button spinner',
+ 'decorators' => array(
+ 'ViewHelper',
+ array('HtmlTag', array('tag' => 'div', 'class' => 'control-group form-controls'))
+ ),
+ 'escape' => false,
+ 'ignore' => true,
+ 'label' => $this->getView()->icon($icon) . $this->translate('Ack'),
+ 'type' => 'submit',
+ 'title' => $title,
+ 'value' => $this->translate('Ack')
+ )
+ )
+ ));
+
+ return $this;
+ }
+
+ public function onSuccess()
+ {
+ $redirect = clone $this->getRequest()->getUrl();
+ $params = $redirect->getParams();
+ $modifyFilter = $params->shift('modifyFilter');
+ $columns = $params->shift('columns');
+ if (! (bool) $this->getRequest()->getUrl()->getParams()->get('ack', true)) {
+ $params->remove('ack');
+ } else {
+ $redirect->setQueryString(
+ Filter::fromQueryString($redirect->getQueryString())
+ ->andFilter(Filter::expression('ack', '=', 0))
+ ->toQueryString()
+ );
+ }
+ $params = $redirect->getParams();
+ if ($modifyFilter) {
+ $params->add('modifyFilter');
+ }
+ if ($columns) {
+ $params->add('columns', $columns);
+ }
+ $this->setRedirectUrl($redirect);
+ return true;
+ }
+}