mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
Add newlines to AnnouncementIniRepository.php
This commit is contained in:
parent
5ec14bdb9d
commit
1f5f610b04
@ -42,8 +42,10 @@ class AnnouncementIniRepository extends IniRepository
|
||||
if ($timestamp !== null) {
|
||||
$dateTime = new DateTime();
|
||||
$dateTime->setTimestamp($timestamp);
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -71,6 +73,7 @@ class AnnouncementIniRepository extends IniRepository
|
||||
if (! isset($new->id)) {
|
||||
$new->id = uniqid();
|
||||
}
|
||||
|
||||
if (! isset($new->hash)) {
|
||||
$announcement = new Announcement($new->toArray());
|
||||
$new->hash = $announcement->getHash();
|
||||
@ -105,11 +108,14 @@ class AnnouncementIniRepository extends IniRepository
|
||||
public function getEtag()
|
||||
{
|
||||
$file = $this->getDataSource('announcement')->getConfigFile();
|
||||
|
||||
if (@is_readable($file)) {
|
||||
$mtime = filemtime($file);
|
||||
$size = filesize($file);
|
||||
|
||||
return hash('crc32', $mtime . $size);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -121,6 +127,7 @@ class AnnouncementIniRepository extends IniRepository
|
||||
public function findActive()
|
||||
{
|
||||
$now = new DateTime();
|
||||
|
||||
$query = $this
|
||||
->select(array('hash', 'message'))
|
||||
->setFilter(new FilterAnd(array(
|
||||
@ -128,6 +135,7 @@ class AnnouncementIniRepository extends IniRepository
|
||||
Filter::expression('end', '>=', $now)
|
||||
)))
|
||||
->order('start');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
@ -139,20 +147,25 @@ class AnnouncementIniRepository extends IniRepository
|
||||
public function findNextActive()
|
||||
{
|
||||
$now = new DateTime();
|
||||
|
||||
$query = $this
|
||||
->select(array('start', 'end'))
|
||||
->setFilter(Filter::matchAny(array(
|
||||
Filter::expression('start', '>', $now), Filter::expression('end', '>', $now)
|
||||
)));
|
||||
|
||||
$refresh = null;
|
||||
|
||||
foreach ($query as $row) {
|
||||
$min = min($row->start->getTimestamp(), $row->end->getTimestamp());
|
||||
|
||||
if ($refresh === null) {
|
||||
$refresh = $min;
|
||||
} else {
|
||||
$refresh = min($refresh, $min);
|
||||
}
|
||||
}
|
||||
|
||||
return $refresh;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user