configuration: add businessprocess to main menu

This commit is contained in:
Thomas Gelf 2016-12-09 14:32:47 +01:00
parent ce82446732
commit 2df97ef432

View file

@ -1,9 +1,44 @@
<?php
$section = $this->menuSection(N_('Overview'))
->add($this->translate('Business Processes'))
->setPriority(45)
->setUrl('businessprocess');
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
$this->providePermission('businessprocess/create', 'Allow to create new configs');
$this->providePermission('businessprocess/modify', 'Allow to modify processes');
$section = $this->menuSection(N_('Business Processes'), array(
'url' => 'businessprocess',
'icon' => 'sitemap',
'priority' => 46
));
try {
$storage = new LegacyStorage(
$this->getConfig()->getSection('global')
);
$prio = 0;
foreach ($storage->listProcesses() as $name) {
$prio++;
$meta = $storage->loadMetadata($name);
if ($meta->get('AddToMenu') === 'no') {
continue;
}
if ($prio > 5) {
$section->add(N_('Show all'), array(
'url' => 'businessprocess',
'priority' => $prio
));
break;
}
$section->add($meta->getTitle(), array(
'url' => 'businessprocess/process/show',
'urlParameters' => array('config' => $name),
'priority' => $prio
));
}
} catch (Exception $e) {
// Well... there is not much we could do here
}