From e18916242811b4c121c1be74805780a3ceab5d1d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Sun, 22 May 2016 16:08:14 +0200 Subject: [PATCH] RestrictionForm: Drop redundant properties.. ..while still retaining nested restrictions. refs #3075 --- .../forms/Configuration/RestrictionForm.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/icingaweb2-module-elasticarmor/application/forms/Configuration/RestrictionForm.php b/lib/icingaweb2-module-elasticarmor/application/forms/Configuration/RestrictionForm.php index c323d7b..9593688 100644 --- a/lib/icingaweb2-module-elasticarmor/application/forms/Configuration/RestrictionForm.php +++ b/lib/icingaweb2-module-elasticarmor/application/forms/Configuration/RestrictionForm.php @@ -391,6 +391,14 @@ public function getValues($suppressArrayNotation = false) $values['exclude'] = array_map('trim', explode(',', $values['exclude'])); } + if ($this->restrictionMode === static::MODE_UPDATE) { + $currentState = $this->extract($this->data, $this->restrictionPath); + unset($currentState['include']); + unset($currentState['exclude']); + unset($currentState['permissions']); + $values = array_merge($currentState, $values); + } + $this->inject($this->data, $this->restrictionPath, $values); } @@ -473,11 +481,7 @@ protected function inject(array &$data, array $path, array $restriction) if (! empty($path)) { $this->inject($data[$key], $path, $restriction); } elseif (is_numeric($key)) { - if (isset($data[$key])) { - $data[$key] = array_merge($data[$key], $restriction); - } else { - $data[$key] = $restriction; - } + $data[$key] = $restriction; } else { $data[$key][] = $restriction; }