From b20eb681c0bfe4ce70386bc70812d482f0388753 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 7 Sep 2015 13:44:46 +0200 Subject: [PATCH] api/forms: Use the first success notification as success message refs #9606 --- library/Icinga/Web/Form.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 4b53fa4f9..864f1d78e 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1116,10 +1116,16 @@ class Form extends Zend_Form if ($this->getIsApiTarget() || $this->getRequest()->isApiRequest()) { // API targets and API requests will never redirect but immediately respond w/ JSON-encoded // notifications - $messages = Notification::getInstance()->popMessages(); - // @TODO(el): Remove the type from the message + $notifications = Notification::getInstance()->popMessages(); + $message = null; + foreach ($notifications as $notification) { + if ($notification['type'] === Notification::SUCCESS) { + $message = $notification['message']; + break; + } + } $this->getResponse()->json() - ->setSuccessData(array('message' => array_pop($messages))) + ->setSuccessData($message !== null ? array('message' => $message) : null) ->sendResponse(); } elseif (! $frameUpload) { $this->getResponse()->redirectAndExit($this->getRedirectUrl());