mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-26 11:19:16 +02:00
Icinga 2.5 moved a few default templates from ITL to the core itself and deprecated directly setting execute & similar properties. This change will break config deployment for 2.4.x environments without 'include <itl>', but this would rarely be the case. This commit also changed how we work with inherited properties to render the right object type based on 'execute' if none is set (but got inherited). fixes #12443 fixes #12543
71 lines
1.6 KiB
PHP
71 lines
1.6 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 '';
|
|
}
|
|
|
|
protected function renderObjectHeader()
|
|
{
|
|
return parent::renderObjectHeader()
|
|
. ' import "legacy-timeperiod"' . "\n";
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|