class CControllerNotificationsGet extends CController {
protected function init() {
$this->notifications = [];
$this->settings = getMessageSettings();
$ok_timeout = (int) timeUnitToSeconds(CSettingsHelper::get(CSettingsHelper::OK_PERIOD));
$timeout = (int) timeUnitToSeconds($this->settings['timeout']);
$this->settings['timeout'] = $timeout;
$this->settings['ok_timeout'] = min([$timeout, $ok_timeout]);
$this->settings['show_recovered'] = (bool) $this->settings['triggers.recovery'];
$this->settings['show_suppressed'] = (bool) $this->settings['show_suppressed'];
if (!$this->settings['triggers.severities']) {
$this->settings['enabled'] = true;
$this->timeout_time = time() - $this->settings['timeout'];
$this->time_from = max([$this->settings['last.clock'], $this->timeout_time]);
protected function checkInput() {
'known_eventids' => 'array_db events.eventid'
$ret = $this->validateInput($fields);
$this->setResponse(new CControllerResponseData(['main_block' => json_encode(['error' => true])]));
protected function checkPermissions() {
return (!CWebUser::isGuest() && $this->getUserType() >= USER_TYPE_ZABBIX_USER);
protected function doAction() {
if (!$this->settings['enabled']) {
$this->setResponse(new CControllerResponseData(['main_block' => $this->makeResponseData()]));
$this->known_eventids = array_flip($this->getInput('known_eventids', []));
$this->loadNotifications();
$this->setResponse(new CControllerResponseData(['main_block' => $this->makeResponseData()]));
protected function loadNotifications() {
'output' => ['eventid', 'r_eventid', 'objectid', 'severity', 'clock', 'r_clock', 'name'],
'source' => EVENT_SOURCE_TRIGGERS,
'object' => EVENT_OBJECT_TRIGGER,
'severities' => array_keys($this->settings['triggers.severities']),
'suppressed' => $this->settings['show_suppressed'] ? null : false,
'sortorder' => ZBX_SORT_DOWN,
'sortfield' => 'eventid',
$options += $this->settings['show_recovered']