Assign: add "is not set" operator

fixes #1436
This commit is contained in:
offsides 2018-03-20 11:29:29 -04:00 committed by Thomas Gelf
parent 69d3675b34
commit 38a56f68fe
4 changed files with 20 additions and 2 deletions

View File

@ -174,7 +174,7 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
$filter->setExpression(json_decode($filter->getExpression()));
}
if ($filter->getExpression() === true) {
if (($filter->getExpression() === true) || ($filter->getExpression() === false)) {
return '';
}
$dummy = IcingaObject::createByType($type);
@ -306,7 +306,8 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
'<=' => '<=',
'in' => 'in',
'contains' => 'contains',
'true' => 'is true (or set)',
'true' => 'is true (or set)',
'false' => 'is false (or not set)',
);
if ($filter === null) {
@ -318,6 +319,8 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
$expression = json_decode($filter->getExpression());
if ($expression === true) {
$sign = 'true';
} elseif ($expression === false) {
$sign = 'false';
} elseif (is_array($expression)) {
$sign = 'in';
} else {

View File

@ -15,6 +15,9 @@ before switching to a new version.
* FEATURE: Grant access to Service Set in a controlled way
* FIX: do not allow a user to create hosts he wouldn't be allowed to see #1451
### Icinga Configuration
* FEATURE: Add 'is false (or not set)' condition for apply rules (#1436)
### User Interface
* FEATURE: Admins have now access to JSON download links in many places
* FEATURE: Users equipped with related permissions can toggle "Show SQL" in the GUI

View File

@ -153,6 +153,12 @@ class AssignRenderer
if ($rawExpression === true) {
return $column;
}
if ($rawExpression === false) {
return sprintf(
'! %s',
$column
);
}
if (strpos($expression, '*') === false) {
return $this->renderEquals($column, $expression);
} else {

View File

@ -270,6 +270,12 @@ class DataFilter extends FormElement
'=',
json_encode(true)
);
} elseif ($entry['sign'] === 'false') {
return Filter::expression(
$entry['column'],
'=',
json_encode(false)
);
} elseif ($entry['sign'] === 'in') {
if (array_key_exists('value', $entry)) {
if (is_array($entry['value'])) {