diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index 431f987f..2d9deb3d 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -189,4 +189,13 @@ class IcingaService extends IcingaObject { return $this->getResolvedProperty('check_command_id') !== null; } + + public function getOnDeleteUrl() + { + if ($this->host_id) { + return 'director/host/services?name=' . rawurlencode($this->host); + } else { + return parent::getOnDeleteUrl(); + } + } } diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index cd1eaffe..1e3df209 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -752,15 +752,16 @@ abstract class DirectorObjectForm extends QuickForm ); } + if ($object instanceof IcingaObject && $object->hasProperty('object_name')) { + $url = $object->getOnDeleteUrl(); + } else { + $url = $this->getSuccessUrl()->without( + array('field_id', 'argument_id') + ); + } + if ($object->delete()) { - // fields? $this->setSuccessUrl($this->getSuccessUrl()->without($key)); - if ($object instanceof IcingaObject && $object->hasProperty('object_name')) { - $this->setSuccessUrl('director/' . strtolower($object->getShortTableName()) . 's'); - } else { - $this->setSuccessUrl($this->getSuccessUrl()->without( - array('field_id', 'argument_id') - )); - } + $this->setSuccessUrl($url); } // TODO: show object name and so $this->redirectOnSuccess($msg);