From ed875b529753e63ddf91e8b776cd01f798a97f0b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 18 Sep 2015 15:58:20 +0200 Subject: [PATCH] NavigationConfigForm: Do not allow to delete parents refs #5600 --- application/forms/Navigation/NavigationConfigForm.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/application/forms/Navigation/NavigationConfigForm.php b/application/forms/Navigation/NavigationConfigForm.php index fafc665a8..661e66a64 100644 --- a/application/forms/Navigation/NavigationConfigForm.php +++ b/application/forms/Navigation/NavigationConfigForm.php @@ -376,6 +376,8 @@ class NavigationConfigForm extends ConfigForm * @param string $name * * @return $this + * + * @throws IcingaException In case the navigation item has still children */ public function delete($name) { @@ -384,6 +386,15 @@ class NavigationConfigForm extends ConfigForm throw new NotFoundError('No navigation item called "%s" found', $name); } + $children = $this->getFlattenedChildren($name); + if (! empty($children)) { + throw new IcingaException( + 'Unable to delete navigation item "%s". There are other items dependent from it: %s', + $name, + join(', ', $children) + ); + } + $config->removeSection($name); $this->setIniConfig($config); return $this;