-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfiguration.php
More file actions
124 lines (103 loc) · 3.11 KB
/
configuration.php
File metadata and controls
124 lines (103 loc) · 3.11 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
// SPDX-FileCopyrightText: 2023 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
use Icinga\Application\Modules\Module;
use Icinga\Authentication\Auth;
/** @var Module $this */
$section = $this->menuSection(
N_('Notifications'),
[
'icon' => 'bell-alt',
'priority' => 52
]
);
$auth = Auth::getInstance();
$authenticated = $auth->getUser() !== null;
$configLandingPage = null;
if ($authenticated) {
if ($auth->hasPermission('notifications/config/schedules')) {
$configLandingPage = 'notifications/schedules';
} elseif ($auth->hasPermission('notifications/config/event-rules')) {
$configLandingPage = 'notifications/event-rules';
} elseif ($auth->hasPermission('notifications/config/contacts')) {
$configLandingPage = 'notifications/contacts';
}
}
$section->add(
N_('Open Incidents'),
[
'icon' => 'th-list',
'description' => $this->translate('Open Incidents'),
'url' => 'notifications/incidents?incident.severity!=ok',
'priority' => 10
]
);
if ($configLandingPage !== null) {
$section->add(
N_('Configuration'),
[
'icon' => 'wrench',
'description' => $this->translate('Configuration'),
'url' => $configLandingPage,
'priority' => 30
]
);
}
$this->providePermission(
'notifications/config/schedules',
$this->translate('Allow to configure schedules')
);
$this->providePermission(
'notifications/config/event-rules',
$this->translate('Allow to configure event rules')
);
$this->providePermission(
'notifications/config/contacts',
$this->translate('Allow to configure contacts and contact groups')
);
$this->providePermission(
'notifications/view/contacts',
$this->translate('Allow to view contacts')
);
$this->providePermission(
'notifications/api',
$this->translate('Allow to modify configuration via API')
);
//$this->provideRestriction(
// 'notifications/filter/objects',
// $this->translate('Restrict access to the objects that match the filter')
//);
$this->provideConfigTab(
'database',
[
'title' => $this->translate('Database'),
'label' => $this->translate('Database'),
'url' => 'config/database'
]
);
$this->provideConfigTab(
'channels',
[
'title' => $this->translate('Channels'),
'label' => $this->translate('Channels'),
'url' => 'channels'
]
);
$this->provideConfigTab(
'sources',
[
'title' => $this->translate('Sources'),
'label' => $this->translate('Sources'),
'url' => 'sources'
]
);
$this->provideJsFile('schedule.js');
$cssDirectory = $this->getCssDir();
$cssFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(
$cssDirectory,
RecursiveDirectoryIterator::CURRENT_AS_PATHNAME | RecursiveDirectoryIterator::SKIP_DOTS
));
foreach ($cssFiles as $path) {
$this->provideCssFile(ltrim(substr($path, strlen($cssDirectory)), DIRECTORY_SEPARATOR));
}
$this->provideJsFile('notifications.js');