From 82e79c810fe5c5779df748c2d673ae468bc51c8a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 17 Feb 2017 16:35:13 +0100 Subject: [PATCH] IcingaServiceSetForm: redirect to host services... ...when adding a set to a single host fixes #804 --- application/forms/IcingaServiceSetForm.php | 12 ++++++++++++ library/Director/Web/Form/DirectorObjectForm.php | 12 ++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/application/forms/IcingaServiceSetForm.php b/application/forms/IcingaServiceSetForm.php index d95e94c5..b695fee3 100644 --- a/application/forms/IcingaServiceSetForm.php +++ b/application/forms/IcingaServiceSetForm.php @@ -60,6 +60,18 @@ class IcingaServiceSetForm extends DirectorObjectForm ->addAssignmentElements(); } + protected function setObjectSuccessUrl() + { + if ($this->host) { + $this->setSuccessUrl( + 'director/host/services', + array('name' => $this->host->getObjectName()) + ); + } else { + parent::setObjectSuccessUrl(); + } + } + protected function setupHost() { $object = $this->object(); diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index 78542388..76a11ceb 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -496,14 +496,22 @@ abstract class DirectorObjectForm extends QuickForm } $msg = $this->translate('No action taken, object has not been modified'); } + + $this->setObjectSuccessUrl(); + $this->beforeSuccessfulRedirect(); + $this->redirectOnSuccess($msg); + } + + protected function setObjectSuccessUrl() + { + $object = $this->object(); + if ($object instanceof IcingaObject) { $this->setSuccessUrl( 'director/' . strtolower($this->getObjectShortClassName()), $object->getUrlParams() ); } - $this->beforeSuccessfulRedirect(); - $this->redirectOnSuccess($msg); } protected function beforeSuccessfulRedirect()