[icinga-checkins] icinga.org: icingaweb2-module-director/feature/nested-apply-rules-12033: DataFilter: json_en/decode when passing to form

git at icinga.org git at icinga.org
Sun Oct 23 06:25:33 CEST 2016


Module: icingaweb2-module-director
Branch: feature/nested-apply-rules-12033
Commit: 24478ede12cc83d6d7c3aeaef321559781f4e9b8
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=24478ede12cc83d6d7c3aeaef321559781f4e9b8

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sun Oct 23 03:14:52 2016 +0000

DataFilter: json_en/decode when passing to form

---

 application/views/helpers/FormDataFilter.php     |    2 ++
 library/Director/Web/Form/Element/DataFilter.php |    8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/application/views/helpers/FormDataFilter.php b/application/views/helpers/FormDataFilter.php
index 169e1c6..a348b73 100644
--- a/application/views/helpers/FormDataFilter.php
+++ b/application/views/helpers/FormDataFilter.php
@@ -154,7 +154,9 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
         if ($filter) {
             // TODO: Make this configurable
             $type = 'host';
+            $filter = clone($filter);
 
+            $filter->setExpression(json_decode($filter->getExpression()));
             $dummy = IcingaObject::createByType($type);
             $col = $filter->getColumn();
             if ($dummy->hasProperty($col)) {
diff --git a/library/Director/Web/Form/Element/DataFilter.php b/library/Director/Web/Form/Element/DataFilter.php
index 2c45d4b..c75fdee 100644
--- a/library/Director/Web/Form/Element/DataFilter.php
+++ b/library/Director/Web/Form/Element/DataFilter.php
@@ -231,7 +231,7 @@ class DataFilter extends FormElement
             return Filter::expression(
                 $entry['column'],
                 '=',
-                true
+                json_encode(true)
             );
         } elseif ($entry['sign'] === 'in') {
             if (array_key_exists('value', $entry)) {
@@ -248,13 +248,15 @@ class DataFilter extends FormElement
             return Filter::expression(
                 $entry['column'],
                 '=',
-                $value
+                json_encode($value)
             );
         } else {
+            $value = array_key_exists('value', $entry) ? $entry['value'] : null;
+
             return Filter::expression(
                 $entry['column'],
                 $entry['sign'],
-                array_key_exists('value', $entry) ? $entry['value'] : null
+                json_encode($value)
             );
         }
     }



More information about the icinga-checkins mailing list