DirectorObjectForm: add better status codes

This commit is contained in:
Thomas Gelf 2015-12-10 12:51:11 +01:00
parent 16c4bd4da8
commit 59028ebeb4
1 changed files with 7 additions and 0 deletions

View File

@ -497,7 +497,10 @@ abstract class DirectorObjectForm extends QuickForm
{ {
$object = $this->object(); $object = $this->object();
if ($object->hasBeenModified()) { if ($object->hasBeenModified()) {
if (! $object->hasBeenLoadedFromDb()) { if (! $object->hasBeenLoadedFromDb()) {
$this->setHttpResponseCode(201);
if ($object instanceof IcingaObject && $object->hasProperty('object_name')) { if ($object instanceof IcingaObject && $object->hasProperty('object_name')) {
$this->setSuccessUrl( $this->setSuccessUrl(
'director/' . strtolower($this->getObjectName()), 'director/' . strtolower($this->getObjectName()),
@ -513,8 +516,12 @@ abstract class DirectorObjectForm extends QuickForm
); );
$object->store($this->db); $object->store($this->db);
} else { } else {
if ($this->isApiRequest()) {
$this->setHttpResponseCode(304);
}
$msg = $this->translate('No action taken, object has not been modified'); $msg = $this->translate('No action taken, object has not been modified');
} }
$this->redirectOnSuccess($msg); $this->redirectOnSuccess($msg);
} }