IcingaTimePeriodRangeForm: store period, not range
This commit is contained in:
parent
e4ed5eb04d
commit
cce1e96854
|
@ -38,4 +38,44 @@ class IcingaTimePeriodRangeForm extends DirectorObjectForm
|
|||
$this->period = $period;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function onSuccess()
|
||||
{
|
||||
$object = $this->object();
|
||||
if ($object->hasBeenModified()) {
|
||||
$this->period->ranges()->setRange(
|
||||
$this->getValue('timeperiod_key'),
|
||||
$this->getValue('timeperiod_value')
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->period->hasBeenModified()) {
|
||||
if (! $object->hasBeenLoadedFromDb()) {
|
||||
|
||||
$this->setHttpResponseCode(201);
|
||||
}
|
||||
$msg = sprintf(
|
||||
$object->hasBeenLoadedFromDb()
|
||||
? $this->translate('The %s has successfully been stored')
|
||||
: $this->translate('A new %s has successfully been created'),
|
||||
$this->translate($this->getObjectName())
|
||||
);
|
||||
|
||||
$this->period->store($this->db);
|
||||
|
||||
} else {
|
||||
if ($this->isApiRequest()) {
|
||||
$this->setHttpResponseCode(304);
|
||||
}
|
||||
$msg = $this->translate('No action taken, object has not been modified');
|
||||
}
|
||||
if ($object instanceof IcingaObject) {
|
||||
$this->setSuccessUrl(
|
||||
'director/' . strtolower($this->getObjectName()),
|
||||
$object->getUrlParams()
|
||||
);
|
||||
}
|
||||
|
||||
$this->redirectOnSuccess($msg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue