mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
DirectorObjectForm: implement generic deletion
This commit is contained in:
parent
4d72e315f2
commit
071cf627d2
@ -488,6 +488,33 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
|
|
||||||
|
$object = $this->object();
|
||||||
|
|
||||||
|
if ($this->shouldBeDeleted()) {
|
||||||
|
$key = $object->getKeyName();
|
||||||
|
if ($object instanceof IcingaObject) {
|
||||||
|
$msg = sprintf(
|
||||||
|
'%s "%s" has been removed',
|
||||||
|
$this->translate($this->getObjectName()),
|
||||||
|
$object->object_name
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$msg = sprintf(
|
||||||
|
'%s has been removed',
|
||||||
|
$this->translate($this->getObjectName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($object->delete()) {
|
||||||
|
// fields? $this->setSuccessUrl($this->getSuccessUrl()->without($key));
|
||||||
|
if ($object instanceof IcingaObject) {
|
||||||
|
$this->setSuccessUrl('director/' . $object->getShortTableName() . 's');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO: show object name and so
|
||||||
|
$this->redirectOnSuccess($msg);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->hasBeenSent()) {
|
if ($this->hasBeenSent()) {
|
||||||
$post = $this->getRequest()->getPost();
|
$post = $this->getRequest()->getPost();
|
||||||
foreach ($post as $key => $value) {
|
foreach ($post as $key => $value) {
|
||||||
@ -498,8 +525,6 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$object = $this->object();
|
|
||||||
|
|
||||||
if ($object instanceof IcingaObject) {
|
if ($object instanceof IcingaObject) {
|
||||||
if (! $object->hasBeenLoadedFromDb() && $object->hasProperty('object_type')) {
|
if (! $object->hasBeenLoadedFromDb() && $object->hasProperty('object_type')) {
|
||||||
$object->object_type = $this->objectType;
|
$object->object_type = $this->objectType;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user