Send notifications on site reload and via XHR
This commit is contained in:
parent
4603219677
commit
296d8c7969
|
@ -1,10 +1,20 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Authentication\Manager as Auth;
|
||||
|
||||
if (Icinga\Authentication\Manager::getInstance()->isAuthenticated()): ?>
|
||||
if (Auth::getInstance()->isAuthenticated()): ?>
|
||||
<div id="header">
|
||||
<ul id="notifications"></ul>
|
||||
<ul id="notifications"><?php
|
||||
|
||||
$notifications = Notification::getInstance();
|
||||
if ($notifications->hasMessages()) {
|
||||
foreach ($notifications->getMessages() as $m) {
|
||||
echo '<li class="' . $m->type . '">' . $this->escape($m->message) . '</li>';
|
||||
}
|
||||
}
|
||||
?></ul>
|
||||
<div id="logo"><a href="<?= $this->href('/dashboard') ?>"><img src="<?= $this->href('img/logo_icinga-inv.png') ?>" class="logo" /></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -40,6 +40,7 @@ use Icinga\Application\Config;
|
|||
use Icinga\Util\Translator;
|
||||
use Icinga\Web\Widget\Tabs;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Logger\Logger;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\File\Pdf;
|
||||
|
@ -299,6 +300,14 @@ class ActionController extends Zend_Controller_Action
|
|||
if ($this->_request->isXmlHttpRequest() || $this->getParam('view') === 'compact') {
|
||||
$this->_helper->layout()->setLayout('inline');
|
||||
}
|
||||
|
||||
$notifications = Notification::getInstance();
|
||||
if ($this->_request->isXmlHttpRequest() && $notifications->hasMessages()) {
|
||||
foreach ($notifications->getMessages() as $m) {
|
||||
header('X-Icinga-Notification: ' . $m->type . ' ' . $m->message);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->view->title) {
|
||||
if (preg_match('~[\r\n]~', $this->view->title)) {
|
||||
// TODO: Innocent exception and error log for hack attempts
|
||||
|
|
Loading…
Reference in New Issue