diff --git a/configuration.php b/configuration.php index 6d4b89a..e96a339 100644 --- a/configuration.php +++ b/configuration.php @@ -1,9 +1,44 @@ 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 +}