/usr/share/php/Icinga/Data/Filter/FilterNot.php is in php-icinga 2.1.0-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Data\Filter;
class FilterNot extends FilterChain
{
protected $operatorName = 'NOT';
protected $operatorSymbol = '!'; // BULLSHIT
// TODO: Max count 1 or autocreate sub-and?
public function matches($row)
{
foreach ($this->filters() as $filter) {
if ($filter->matches($row)) {
return false;
}
}
return true;
}
public function andFilter(Filter $filter)
{
return Filter::matchAll($this, $filter);
}
public function orFilter(Filter $filter)
{
return Filter::matchAny($filter);
}
public function toQueryString()
{
$parts = array();
if (empty($this->filters)) {
return '';
}
foreach ($this->filters() as $filter) {
$parts[] = $filter->toQueryString();
}
if (count($parts) === 1) {
return '!' . $parts[0];
} else {
return '!(' . implode('&', $parts) . ')';
}
}
public function __toString()
{
if (count($this->filters) === 1) {
return '! ' . $this->filters[0];
}
return '! (' . implode('&', $this->filters) . ')';
}
}
|