From e6d4dfc040bbe3cb80a2ce65b82493b557f751fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:48 +0200 Subject: Merging upstream version 1.11.1. Signed-off-by: Daniel Baumann --- application/forms/ImportRowModifierForm.php | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'application/forms/ImportRowModifierForm.php') diff --git a/application/forms/ImportRowModifierForm.php b/application/forms/ImportRowModifierForm.php index 9e53bd9..7033f4c 100644 --- a/application/forms/ImportRowModifierForm.php +++ b/application/forms/ImportRowModifierForm.php @@ -64,6 +64,41 @@ class ImportRowModifierForm extends DirectorObjectForm $error = $e->getMessage(); $mods = $this->optionalEnum([]); } + $this->addElement('YesNo', 'use_filter', [ + 'label' => $this->translate('Set based on filter'), + 'ignore' => true, + 'class' => 'autosubmit', + 'required' => true, + ]); + + if ($this->hasBeenSent()) { + $useFilter = $this->getSentValue('use_filter'); + if ($useFilter === null) { + $this->setElementValue('use_filter', $useFilter = 'n'); + } + } elseif ($object = $this->getObject()) { + $expression = $object->get('filter_expression'); + $useFilter = ($expression === null || strlen($expression) === 0) ? 'n' : 'y'; + $this->setElementValue('use_filter', $useFilter); + } else { + $this->setElementValue('use_filter', $useFilter = 'n'); + } + + if ($useFilter === 'y') { + $this->addElement('text', 'filter_expression', [ + 'label' => $this->translate('Filter Expression'), + 'description' => $this->translate( + 'This allows to filter for specific parts within the given source expression.' + . ' You are allowed to refer all imported columns. Examples: host=www* would' + . ' set this property only for rows imported with a host property starting' + . ' with "www". Complex example: host=www*&!(address=127.*|address6=::1).' + . ' Please note, that CIDR notation based matches are also supported: ' + . ' address=192.0.2.128/25| address=2001:db8::/32| address=::ffff:192.0.2.0/96' + ), + 'required' => true, + // TODO: validate filter + ]); + } $this->addElement('select', 'provider_class', [ 'label' => $this->translate('Modifier'), -- cgit v1.2.3