= $this->translate('No announcements found.') ?>
diff --git a/application/controllers/AnnouncementsController.php b/application/controllers/AnnouncementsController.php index 513d8efe7..c72d36af1 100644 --- a/application/controllers/AnnouncementsController.php +++ b/application/controllers/AnnouncementsController.php @@ -27,10 +27,26 @@ class AnnouncementsController extends Controller ) ); - $repo = new AnnouncementIniRepository(); - $this->view->announcements = $repo - ->select(array('id', 'author', 'message', 'start', 'end')) - ->order('start', 'DESC'); + $announcements = (new AnnouncementIniRepository()) + ->select([ + 'id', + 'author', + 'message', + 'start', + 'end' + ]); + + $sortAndFilterColumns = [ + 'author' => $this->translate('Author'), + 'message' => $this->translate('Message'), + 'start' => $this->translate('Start'), + 'end' => $this->translate('End') + ]; + + $this->setupSortControl($sortAndFilterColumns, $announcements, ['start' => 'desc']); + $this->setupFilterControl($announcements, $sortAndFilterColumns, ['message']); + + $this->view->announcements = $announcements->fetchAll(); } /** diff --git a/application/forms/Announcement/AnnouncementForm.php b/application/forms/Announcement/AnnouncementForm.php index 2caaca0f4..0bc4713cb 100644 --- a/application/forms/Announcement/AnnouncementForm.php +++ b/application/forms/Announcement/AnnouncementForm.php @@ -13,6 +13,21 @@ use Icinga\Forms\RepositoryForm; */ class AnnouncementForm extends RepositoryForm { + protected function fetchEntry() + { + $entry = parent::fetchEntry(); + if ($entry !== false) { + if ($entry->start !== null) { + $entry->start = (new DateTime())->setTimestamp($entry->start); + } + if ($entry->end !== null) { + $entry->end = (new DateTime())->setTimestamp($entry->end); + } + } + + return $entry; + } + /** * {@inheritDoc} */ diff --git a/application/views/scripts/announcements/index.phtml b/application/views/scripts/announcements/index.phtml index 311cfd9da..9958a318b 100644 --- a/application/views/scripts/announcements/index.phtml +++ b/application/views/scripts/announcements/index.phtml @@ -1,6 +1,12 @@ - +compact): ?>
= $this->translate('No announcements found.') ?>