-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfiguration.php
76 lines (55 loc) · 2.61 KB
/
configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/** @var \Icinga\Application\Modules\Module $this */
use Icinga\Application\Config;
use Icinga\Application\Icinga;
use Icinga\Authentication\Auth;
use Icinga\Data\Filter\FilterEqual;
use Icinga\Data\Filter\FilterMatch;
use Icinga\Data\Filter\FilterOr;
use Icinga\Module\Customdashboards\MappingIniRepository;
$this->provideConfigTab('config/moduleconfig', array(
'title' => $this->translate('Module Configuration'),
'label' => $this->translate('Module Configuration'),
'url' => 'moduleconfig'
));
$icon = Config::module('customdashboards', "config")->get('settings', 'menu_icon') != null ?
trim(Config::module('customdashboards', "config")->get('settings', 'menu_icon'), "") : "dashboard";
$priority = Config::module('customdashboards', "config")->get('settings', 'priority') != null ?
trim(Config::module('customdashboards', "config")->get('settings', 'priority'), "") : 15;
$name = Config::module('customdashboards', "config")->get('settings', 'menu_name') != null ?
trim(Config::module('customdashboards', "config")->get('settings', 'menu_name'), "") : "CUSTOM";
$section = $this->menuSection($name, [
'url' => "navigation/dashboard?name=$name",
'icon' => $icon,
'priority' => $priority
]);
$this->provideConfigTab('config/mapping', array(
'title' => $this->translate('Configuration'),
'label' => $this->translate('Configuration'),
'url' => 'mapping'
));
$auth = Auth::getInstance();
if ($auth->isAuthenticated() && !Icinga::app()->isCli()) {
$this->providePermission('customdashboards/mapping', $this->translate('allow access to mapping'));
$isAuthor = ((new MappingIniRepository())->select()->where('author',$auth->getUser()->getUsername())->count() > 0);
if($auth->hasPermission('customdashboards/mapping') || $isAuthor ){
$section->add(N_('Mapping'))
->setUrl('customdashboards/mapping')
->setPriority(30);
}
$mappings = (new MappingIniRepository())->select()->fetchAll();
foreach ($mappings as $mapping) {
$permission = 'customdashboards/mapping/' . $mapping->name;
if($mapping->enabled){
$this->providePermission($permission, $this->translate('allow access to mapping') . " " . $mapping->name);
if($auth->hasPermission($permission) || $mapping->author == $auth->getUser()->getUsername()){
$section->add($mapping->name, array(
'url' => 'customdashboards/custom-dashboard',
'urlParameters' => array('pane' => $mapping->name),
'priority' => $mapping->priority,
));
}
}
}
}
?>