From d9044203e75443f86783c1228dd8958cc1419041 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 9 Dec 2019 09:02:14 +0100 Subject: [PATCH] RoleForm: Use hook `ConfigFormEventsHook` --- application/forms/Security/RoleForm.php | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index a956fd0ce..d6f3d447b 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -3,12 +3,14 @@ namespace Icinga\Forms\Security; +use Icinga\Application\Hook\ConfigFormEventsHook; use Icinga\Application\Icinga; use Icinga\Application\Modules\Manager; use Icinga\Data\Filter\Filter; use Icinga\Forms\ConfigForm; use Icinga\Forms\RepositoryForm; use Icinga\Util\StringHelper; +use Icinga\Web\Notification; use Zend_Form_Element; /** @@ -384,4 +386,33 @@ class RoleForm extends RepositoryForm return strnatcmp($a, $b); }); } + + public function isValid($formData) + { + $valid = parent::isValid($formData); + + if ($valid && ConfigFormEventsHook::runIsValid($this) === false) { + foreach (ConfigFormEventsHook::getLastErrors() as $msg) { + $this->error($msg); + } + + $valid = false; + } + + return $valid; + } + + public function onSuccess() + { + if (parent::onSuccess() === false) { + return false; + } + + if (ConfigFormEventsHook::runOnSuccess($this) === false) { + Notification::error($this->translate( + 'Configuration successfully stored. Though, one or more module hooks failed to run.' + . ' See logs for details' + )); + } + } }