2019-10-16 10:46:38 -04:00
|
|
|
<?php
|
|
|
|
|
|
2020-03-13 03:38:01 -04:00
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
2019-11-04 19:07:30 -05:00
|
|
|
namespace Icinga\Module\Icingadb\Model;
|
2019-10-16 10:46:38 -04:00
|
|
|
|
2024-01-23 02:43:02 -05:00
|
|
|
use DateTime;
|
2025-06-05 10:56:46 -04:00
|
|
|
use ipl\Orm\Behavior\BoolCast;
|
2019-11-22 09:56:07 -05:00
|
|
|
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
|
2022-05-19 10:28:45 -04:00
|
|
|
use ipl\Orm\Behavior\Binary;
|
2023-05-30 10:05:11 -04:00
|
|
|
use ipl\Orm\Behavior\MillisecondTimestamp;
|
2019-10-16 10:46:38 -04:00
|
|
|
use ipl\Orm\Behaviors;
|
|
|
|
|
use ipl\Orm\Model;
|
|
|
|
|
use ipl\Orm\Relations;
|
|
|
|
|
|
2024-01-23 02:43:02 -05:00
|
|
|
/**
|
|
|
|
|
* @property string $id
|
|
|
|
|
* @property string $environment_id
|
|
|
|
|
* @property string $object_type
|
|
|
|
|
* @property string $host_id
|
|
|
|
|
* @property ?string $service_id
|
|
|
|
|
* @property string $name_checksum
|
|
|
|
|
* @property string $properties_checksum
|
|
|
|
|
* @property string $name
|
|
|
|
|
* @property string $author
|
|
|
|
|
* @property string $text
|
|
|
|
|
* @property string $entry_type
|
|
|
|
|
* @property DateTime $entry_time
|
|
|
|
|
* @property bool $is_persistent
|
|
|
|
|
* @property bool $is_sticky
|
|
|
|
|
* @property ?DateTime $expire_time
|
|
|
|
|
* @property ?string $zone_id
|
|
|
|
|
*/
|
2019-10-16 10:46:38 -04:00
|
|
|
class Comment extends Model
|
|
|
|
|
{
|
|
|
|
|
public function getTableName()
|
|
|
|
|
{
|
|
|
|
|
return 'comment';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getKeyName()
|
|
|
|
|
{
|
|
|
|
|
return 'id';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getColumns()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'environment_id',
|
|
|
|
|
'object_type',
|
|
|
|
|
'host_id',
|
|
|
|
|
'service_id',
|
|
|
|
|
'name_checksum',
|
|
|
|
|
'properties_checksum',
|
|
|
|
|
'name',
|
|
|
|
|
'author',
|
|
|
|
|
'text',
|
|
|
|
|
'entry_type',
|
|
|
|
|
'entry_time',
|
|
|
|
|
'is_persistent',
|
2019-11-04 09:48:21 -05:00
|
|
|
'is_sticky',
|
2019-10-16 10:46:38 -04:00
|
|
|
'expire_time',
|
|
|
|
|
'zone_id'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 09:34:01 -04:00
|
|
|
public function getColumnDefinitions()
|
2020-11-02 10:07:24 -05:00
|
|
|
{
|
|
|
|
|
return [
|
2022-07-11 11:31:53 -04:00
|
|
|
'environment_id' => t('Environment Id'),
|
|
|
|
|
'object_type' => t('Object Type'),
|
|
|
|
|
'host_id' => t('Host Id'),
|
|
|
|
|
'service_id' => t('Service Id'),
|
2020-11-02 10:07:24 -05:00
|
|
|
'name_checksum' => t('Comment Name Checksum'),
|
|
|
|
|
'properties_checksum' => t('Comment Properties Checksum'),
|
|
|
|
|
'name' => t('Comment Name'),
|
|
|
|
|
'author' => t('Comment Author'),
|
|
|
|
|
'text' => t('Comment Text'),
|
|
|
|
|
'entry_type' => t('Comment Type'),
|
|
|
|
|
'entry_time' => t('Comment Entry Time'),
|
|
|
|
|
'is_persistent' => t('Comment Is Persistent'),
|
|
|
|
|
'is_sticky' => t('Comment Is Sticky'),
|
|
|
|
|
'expire_time' => t('Comment Expire Time'),
|
2022-07-11 11:31:53 -04:00
|
|
|
'zone_id' => t('Zone Id')
|
2020-11-02 10:07:24 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 04:20:49 -05:00
|
|
|
public function getSearchColumns()
|
|
|
|
|
{
|
|
|
|
|
return ['text'];
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 09:58:53 -05:00
|
|
|
public function getDefaultSort()
|
2019-11-04 10:40:30 -05:00
|
|
|
{
|
2019-12-11 09:58:53 -05:00
|
|
|
return 'comment.entry_time desc';
|
2019-11-04 10:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2019-10-16 10:46:38 -04:00
|
|
|
public function createBehaviors(Behaviors $behaviors)
|
|
|
|
|
{
|
|
|
|
|
$behaviors->add(new BoolCast([
|
2019-11-04 09:48:21 -05:00
|
|
|
'is_persistent',
|
|
|
|
|
'is_sticky'
|
2019-10-16 10:46:38 -04:00
|
|
|
]));
|
|
|
|
|
|
2023-05-30 10:05:11 -04:00
|
|
|
$behaviors->add(new MillisecondTimestamp([
|
2019-10-16 10:46:38 -04:00
|
|
|
'entry_time',
|
|
|
|
|
'expire_time'
|
|
|
|
|
]));
|
2019-11-22 09:56:07 -05:00
|
|
|
|
2022-03-29 09:27:18 -04:00
|
|
|
$behaviors->add(new Binary([
|
|
|
|
|
'id',
|
|
|
|
|
'environment_id',
|
|
|
|
|
'host_id',
|
|
|
|
|
'service_id',
|
|
|
|
|
'name_checksum',
|
|
|
|
|
'properties_checksum',
|
|
|
|
|
'zone_id'
|
|
|
|
|
]));
|
2022-06-29 10:31:40 -04:00
|
|
|
|
|
|
|
|
$behaviors->add(new ReRoute([
|
|
|
|
|
'hostgroup' => 'host.hostgroup',
|
|
|
|
|
'servicegroup' => 'service.servicegroup'
|
|
|
|
|
]));
|
2019-10-16 10:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createRelations(Relations $relations)
|
|
|
|
|
{
|
|
|
|
|
$relations->belongsTo('environment', Environment::class);
|
|
|
|
|
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
|
|
|
|
|
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
|
2020-01-17 10:31:27 -05:00
|
|
|
$relations->belongsTo('zone', Zone::class);
|
2019-10-16 10:46:38 -04:00
|
|
|
}
|
|
|
|
|
}
|