Thomas Gelf ce1c6f3099 Objects: simplify default rendering zone handling
For existing installations this should only affect Timeperiods, as
they will now prefer the global zone. Also some custom zone settings
might now take effect while they have formerly been ignored.

fixes #12252
2016-07-28 15:44:42 +00:00

65 lines
1.5 KiB
PHP

<?php
namespace Icinga\Module\Director\Objects;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
class IcingaTimePeriod extends IcingaObject
{
protected $table = 'icinga_timeperiod';
protected $defaultProperties = array(
'id' => null,
'zone_id' => null,
'object_name' => null,
'object_type' => null,
'disabled' => 'n',
'display_name' => null,
'update_method' => null,
);
protected $supportsImports = true;
protected $supportsRanges = true;
protected $relations = array(
'zone' => 'IcingaZone',
);
/**
* Render update property
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
public function renderUpdate_method()
{
// @codingStandardsIgnoreEnd
return c::renderKeyValue('update', $this->update_method);
}
public function isActive($now = null)
{
if ($now === null) {
$now = time();
}
foreach ($this->ranges()->getRanges() as $range) {
if ($range->isActive($now)) {
return true;
}
}
// TODO: no range currently means (and renders) "never", Icinga behaves
// different. Figure out whether and how we should support this
return false;
}
protected function prefersGlobalZone()
{
return true;
}
}