diff --git a/application/forms/ConfigForm.php b/application/forms/ConfigForm.php index b5e614bac..4b3ead3e0 100644 --- a/application/forms/ConfigForm.php +++ b/application/forms/ConfigForm.php @@ -4,6 +4,7 @@ namespace Icinga\Forms; use Exception; +use Icinga\Application\Hook\ConfigFormEventsHook; use Icinga\Exception\ConfigurationError; use Zend_Form_Decorator_Abstract; use Icinga\Application\Config; @@ -52,6 +53,21 @@ class ConfigForm extends Form return $this; } + 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; + } + /** * {@inheritdoc} */ @@ -72,6 +88,13 @@ class ConfigForm extends Form } else { 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' + )); + } } /**