mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Don't let the user schedule illogical host or service downtimes
refs #10847
This commit is contained in:
parent
242cdab754
commit
66bdae81ac
@ -61,6 +61,22 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm
|
||||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
$end = $this->getValue('end')->getTimestamp();
|
||||
if ($end <= $this->getValue('start')->getTimestamp()) {
|
||||
$endElement = $this->_elements['end'];
|
||||
$endElement->setValue($endElement->getValue()->format($endElement->getFormat()));
|
||||
$endElement->addError($this->translate('The end time must be greater than the start time'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = new DateTime;
|
||||
if ($end <= $now->getTimestamp()) {
|
||||
$endElement = $this->_elements['end'];
|
||||
$endElement->setValue($endElement->getValue()->format($endElement->getFormat()));
|
||||
$endElement->addError($this->translate('A downtime must not be in the past'));
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->objects as $object) {
|
||||
/** @var \Icinga\Module\Monitoring\Object\Host $object */
|
||||
if (($childHostsEl = $this->getElement('child_hosts')) !== null) {
|
||||
|
@ -197,6 +197,22 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
|
||||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
$end = $this->getValue('end')->getTimestamp();
|
||||
if ($end <= $this->getValue('start')->getTimestamp()) {
|
||||
$endElement = $this->_elements['end'];
|
||||
$endElement->setValue($endElement->getValue()->format($endElement->getFormat()));
|
||||
$endElement->addError($this->translate('The end time must be greater than the start time'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = new DateTime;
|
||||
if ($end <= $now->getTimestamp()) {
|
||||
$endElement = $this->_elements['end'];
|
||||
$endElement->setValue($endElement->getValue()->format($endElement->getFormat()));
|
||||
$endElement->addError($this->translate('A downtime must not be in the past'));
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->objects as $object) {
|
||||
/** @var \Icinga\Module\Monitoring\Object\Service $object */
|
||||
$downtime = new ScheduleServiceDowntimeCommand();
|
||||
|
Loading…
x
Reference in New Issue
Block a user