Menu: show Director DB resource (if not default)
This commit is contained in:
parent
35acda4865
commit
b7ed665d35
|
@ -1,5 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
|
use Icinga\Web\Window;
|
||||||
|
|
||||||
$this->providePermission('director/api', $this->translate('Allow to access the director API'));
|
$this->providePermission('director/api', $this->translate('Allow to access the director API'));
|
||||||
$this->providePermission('director/audit', $this->translate('Allow to access the full audit log'));
|
$this->providePermission('director/audit', $this->translate('Allow to access the full audit log'));
|
||||||
$this->providePermission(
|
$this->providePermission(
|
||||||
|
@ -73,9 +77,34 @@ $this->provideConfigTab('config', array(
|
||||||
'title' => 'Configuration',
|
'title' => 'Configuration',
|
||||||
'url' => 'settings'
|
'url' => 'settings'
|
||||||
));
|
));
|
||||||
|
$mainTitle = N_('Icinga Director');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$app = Icinga::app();
|
||||||
|
if ($app->isWeb()) {
|
||||||
|
$request = $app->getRequest();
|
||||||
|
$id = $request->getHeader('X-Icinga-WindowId');
|
||||||
|
if ($id !== false) {
|
||||||
|
$window = new Window($id);
|
||||||
|
/** @var \Icinga\Web\Session\SessionNamespace $session */
|
||||||
|
$session = $window->getSessionNamespace('director');
|
||||||
|
$dbName = $session->get('db_resource');
|
||||||
|
if ($dbName && $dbName !== $this->getConfig()->get('db', 'resource')) {
|
||||||
|
$dbName = ucfirst(str_replace('_', ' ', $dbName));
|
||||||
|
if (stripos($dbName, 'Director') === false) {
|
||||||
|
$dbName = 'Director: ' . $dbName;
|
||||||
|
}
|
||||||
|
$mainTitle = $dbName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// There isn't much we can do, we don't want to break the menu
|
||||||
|
$mainTitle .= ' (?!)';
|
||||||
|
}
|
||||||
|
|
||||||
$section = $this->menuSection(
|
$section = $this->menuSection(
|
||||||
N_('Icinga Director')
|
$mainTitle
|
||||||
)->setUrl('director')->setPriority(60)->setIcon(
|
)->setUrl('director')->setPriority(60)->setIcon(
|
||||||
'cubes'
|
'cubes'
|
||||||
)->setRenderer(array(
|
)->setRenderer(array(
|
||||||
|
|
Loading…
Reference in New Issue