permissions: provide a few

This commit is contained in:
Thomas Gelf 2015-11-17 14:46:50 +01:00
parent 5484cfc887
commit 7fcef19c6e
4 changed files with 16 additions and 3 deletions

View file

@ -20,6 +20,8 @@ class ProcessController extends Controller
*/
public function createAction()
{
$this->assertPermission('businessprocess/create');
$this->setTitle($this->translate('Create a new business process'));
$this->tabsForCreate()->activate('create');

View file

@ -19,8 +19,6 @@ use Icinga\Module\Businessprocess\BusinessProcess;
<?php endif ?>
<a href="<?= $this->url('businessprocess/process/config', array('config' => $this->configName)) ?>" title="<?= $this->escape('Modify this process') ?>" data-base-target="_next"><?= $this->icon('wrench') ?></a>
<?php endif ?>
<a href="<?= $this->url('businessprocess/process/create') ?>" title="<?= $this->escape('Create a new business process configuration') ?>"><?= $this->icon('plus') ?></a>
</h1>
</div>
<?php endif ?>

View file

@ -5,3 +5,5 @@ $section = $this->menuSection(N_('Overview'))
->setPriority(45)
->setUrl('businessprocess');
$this->providePermission('businessprocess/create', 'Allow to create new configs');
$this->providePermission('businessprocess/modify', 'Allow to modify processes');

View file

@ -85,7 +85,14 @@ class Controller extends ModuleController
protected function loadBpConfig()
{
$storage = $this->storage();
$this->view->processList = $storage->listProcesses();
if ($this->hasPermission('businessprocess/create')) {
$this->view->processList = array_merge(
$storage->listProcesses(),
array('.new' => $this->translate('Create new configuration'))
);
} else {
$this->view->processList = $storage->listProcesses();
}
// No process found? Go to welcome page
if (empty($this->view->processList)) {
@ -97,6 +104,10 @@ class Controller extends ModuleController
key($this->view->processList)
);
if ($name === '.new') {
$this->redirectNow('businessprocess/process/create');
}
$modifications = $this->session()->get('modifications', array());
if (array_key_exists($name, $modifications)) {
$bp = $storage->loadFromString($name, $modifications[$name]);