|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Menu; |
|
4
|
|
|
|
|
5
|
|
|
use App\Entity\User; |
|
6
|
|
|
use App\Repository\TimetableLessonRepositoryInterface; |
|
7
|
|
|
use App\Repository\WikiArticleRepositoryInterface; |
|
8
|
|
|
use App\Section\SectionResolverInterface; |
|
9
|
|
|
use App\Security\Voter\ExamVoter; |
|
10
|
|
|
use App\Security\Voter\ListsVoter; |
|
11
|
|
|
use App\Security\Voter\ResourceReservationVoter; |
|
12
|
|
|
use App\Security\Voter\StudentAbsenceVoter; |
|
13
|
|
|
use App\Security\Voter\WikiVoter; |
|
14
|
|
|
use App\Settings\StudentAbsenceSettings; |
|
15
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface; |
|
16
|
|
|
use Knp\Menu\FactoryInterface; |
|
17
|
|
|
use Knp\Menu\ItemInterface; |
|
18
|
|
|
use LightSaml\SpBundle\Security\Http\Authenticator\SamlToken; |
|
19
|
|
|
use SchulIT\CommonBundle\DarkMode\DarkModeManagerInterface; |
|
20
|
|
|
use SchulIT\CommonBundle\Helper\DateHelper; |
|
21
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
|
22
|
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; |
|
23
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
24
|
|
|
|
|
25
|
|
|
class Builder { |
|
26
|
|
|
public function __construct(private FactoryInterface $factory, private AuthorizationCheckerInterface $authorizationChecker, private WikiArticleRepositoryInterface $wikiRepository, private TimetableLessonRepositoryInterface $lessonRepository, private TokenStorageInterface $tokenStorage, private DateHelper $dateHelper, private TranslatorInterface $translator, private DarkModeManagerInterface $darkModeManager, private StudentAbsenceSettings $studentAbsenceSettings, private SectionResolverInterface $sectionResolver, private string $idpProfileUrl) |
|
27
|
|
|
{ |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
private function plansMenu(ItemInterface $menu): ItemInterface { |
|
31
|
|
|
$plans = $menu->addChild('plans.label') |
|
32
|
|
|
->setExtra('menu', 'plans') |
|
33
|
|
|
->setExtra('menu-container', '#submenu') |
|
34
|
|
|
->setExtra('icon', 'fa fa-school'); |
|
35
|
|
|
|
|
36
|
|
|
$plans->addChild('plans.timetable.label', [ |
|
37
|
|
|
'route' => 'timetable' |
|
38
|
|
|
]) |
|
39
|
|
|
->setExtra('icon', 'fa fa-clock'); |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
$plans->addChild('plans.substitutions.label', [ |
|
43
|
|
|
'route' => 'substitutions' |
|
44
|
|
|
]) |
|
45
|
|
|
->setExtra('icon', 'fas fa-random'); |
|
46
|
|
|
|
|
47
|
4 |
|
$plans->addChild('plans.exams.label', [ |
|
48
|
|
|
'route' => 'exams' |
|
49
|
|
|
]) |
|
50
|
|
|
->setExtra('icon', 'fas fa-edit'); |
|
51
|
|
|
|
|
52
|
4 |
|
$plans->addChild('plans.appointments.label', [ |
|
53
|
4 |
|
'route' => 'appointments' |
|
54
|
4 |
|
]) |
|
55
|
4 |
|
->setExtra('icon', 'far fa-calendar'); |
|
56
|
4 |
|
|
|
57
|
4 |
|
if($this->authorizationChecker->isGranted(ResourceReservationVoter::View)) { |
|
58
|
4 |
|
$plans->addChild('resources.reservations.label', [ |
|
59
|
4 |
|
'route' => 'resource_reservations' |
|
60
|
4 |
|
]) |
|
61
|
4 |
|
->setExtra('icon', 'fas fa-laptop-house'); |
|
62
|
4 |
|
} |
|
63
|
4 |
|
|
|
64
|
4 |
|
return $plans; |
|
65
|
|
|
} |
|
66
|
4 |
|
|
|
67
|
4 |
|
private function listsMenu(ItemInterface $menu): ItemInterface { |
|
68
|
4 |
|
$lists = $menu->addChild('lists.label') |
|
69
|
4 |
|
->setExtra('menu', 'lists') |
|
70
|
4 |
|
->setExtra('menu-container', '#submenu') |
|
71
|
|
|
->setExtra('icon', 'fas fa-list'); |
|
72
|
4 |
|
|
|
73
|
4 |
|
if($this->authorizationChecker->isGranted(ListsVoter::Tuitions)) { |
|
74
|
|
|
$lists->addChild('lists.tuitions.label', [ |
|
75
|
4 |
|
'route' => 'list_tuitions' |
|
76
|
|
|
]) |
|
77
|
|
|
->setExtra('icon', 'fas fa-chalkboard-teacher'); |
|
78
|
4 |
|
} |
|
79
|
4 |
|
|
|
80
|
|
|
|
|
81
|
4 |
|
if($this->authorizationChecker->isGranted(ListsVoter::StudyGroups)) { |
|
82
|
|
|
$lists->addChild('lists.study_groups.label', [ |
|
83
|
4 |
|
'route' => 'list_studygroups' |
|
84
|
4 |
|
]) |
|
85
|
|
|
->setExtra('icon', 'fas fa-users'); |
|
86
|
4 |
|
} |
|
87
|
|
|
|
|
88
|
4 |
|
if($this->authorizationChecker->isGranted(ListsVoter::Teachers)) { |
|
89
|
4 |
|
$lists->addChild('lists.teachers.label', [ |
|
90
|
|
|
'route' => 'list_teachers' |
|
91
|
4 |
|
]) |
|
92
|
|
|
->setExtra('icon', 'fas fa-user-tie'); |
|
93
|
4 |
|
} |
|
94
|
2 |
|
|
|
95
|
2 |
|
if($this->authorizationChecker->isGranted(ListsVoter::Privacy)) { |
|
96
|
|
|
$lists->addChild('lists.privacy.label', [ |
|
97
|
2 |
|
'route' => 'list_privacy' |
|
98
|
|
|
]) |
|
99
|
|
|
->setExtra('icon', 'fas fa-user-shield'); |
|
100
|
4 |
|
} |
|
101
|
|
|
|
|
102
|
|
|
return $lists; |
|
103
|
4 |
|
} |
|
104
|
4 |
|
|
|
105
|
4 |
|
private function wikiMenu(ItemInterface $menu): ItemInterface { |
|
106
|
4 |
|
$wiki = $menu->addChild('wiki.label', [ |
|
107
|
4 |
|
'route' => 'wiki' |
|
108
|
|
|
]) |
|
109
|
4 |
|
->setExtra('menu', 'wiki') |
|
110
|
2 |
|
->setExtra('icon', 'fab fa-wikipedia-w') |
|
111
|
2 |
|
->setExtra('menu-container', '#submenu'); |
|
112
|
|
|
|
|
113
|
2 |
|
foreach($this->wikiRepository->findAll() as $article) { |
|
114
|
|
|
if($article->isOnline() && $this->authorizationChecker->isGranted(WikiVoter::View, $article)) { |
|
115
|
|
|
$item = $wiki->addChild(sprintf('wiki.%s', $article->getUuid()), [ |
|
|
|
|
|
|
116
|
|
|
'label' => $article->getTitle(), |
|
117
|
4 |
|
'route' => 'show_wiki_article', |
|
118
|
2 |
|
'routeParameters' => [ |
|
119
|
2 |
|
'uuid' => (string)$article->getUuid(), |
|
120
|
|
|
] |
|
121
|
2 |
|
]) |
|
122
|
|
|
->setExtra('icon', !empty($article->getIcon()) ? $article->getIcon() : 'far fa-file'); |
|
123
|
|
|
} |
|
124
|
4 |
|
} |
|
125
|
4 |
|
|
|
126
|
4 |
|
return $wiki; |
|
127
|
|
|
} |
|
128
|
4 |
|
|
|
129
|
|
|
private function bookMenu(ItemInterface $menu): ItemInterface { |
|
130
|
|
|
$book = $menu->addChild('book.label', [ |
|
131
|
4 |
|
'route' => 'book' |
|
132
|
2 |
|
]) |
|
133
|
2 |
|
->setExtra('menu', 'book') |
|
134
|
|
|
->setExtra('icon', 'fas fa-book-open') |
|
135
|
2 |
|
->setExtra('menu-container', '#submenu'); |
|
136
|
|
|
|
|
137
|
|
|
$book->addChild('book.label', [ |
|
138
|
4 |
|
'route' => 'book' |
|
139
|
|
|
]) |
|
140
|
|
|
->setExtra('icon', 'fas fa-book-open'); |
|
141
|
4 |
|
|
|
142
|
4 |
|
$missing = $book->addChild('book.missing.label', [ |
|
143
|
4 |
|
'route' => 'missing_book_entries' |
|
144
|
|
|
]) |
|
145
|
4 |
|
->setExtra('icon', 'fas fa-times'); |
|
146
|
4 |
|
|
|
147
|
4 |
|
if($this->tokenStorage->getToken() === null) { |
|
148
|
|
|
return $book; |
|
149
|
4 |
|
} |
|
150
|
|
|
|
|
151
|
|
|
$user = $this->tokenStorage->getToken()->getUser(); |
|
152
|
|
|
$currentSection = $this->sectionResolver->getCurrentSection(); |
|
153
|
|
|
|
|
154
|
|
|
if($user instanceof User && $user->getTeacher() !== null && $currentSection !== null) { |
|
155
|
|
|
$count = $this->lessonRepository->countMissingByTeacher($user->getTeacher(), $currentSection->getStart(), $this->dateHelper->getToday()); |
|
|
|
|
|
|
156
|
|
|
$missing->setExtra('count', $count); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
$book->addChild('book.students.label', [ |
|
160
|
|
|
'route' => 'book_students' |
|
161
|
|
|
]) |
|
162
|
4 |
|
->setExtra('icon', 'fas fa-users'); |
|
163
|
|
|
|
|
164
|
|
|
$book->addChild('book.excuse_note.label', [ |
|
165
|
4 |
|
'route' => 'excuse_notes' |
|
166
|
4 |
|
]) |
|
167
|
4 |
|
->setExtra('icon', 'fas fa-pen-alt'); |
|
168
|
4 |
|
|
|
169
|
|
|
$book->addChild('book.export.label', [ |
|
170
|
|
|
'route' => 'book_export' |
|
171
|
4 |
|
]) |
|
172
|
|
|
->setExtra('icon', 'fas fa-download'); |
|
173
|
4 |
|
|
|
174
|
|
|
return $book; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
4 |
|
public function userMenu(array $options): ItemInterface { |
|
|
|
|
|
|
178
|
|
|
$menu = $this->factory->createItem('root') |
|
179
|
4 |
|
->setChildrenAttributes([ |
|
180
|
4 |
|
'class' => 'navbar-nav float-lg-right' |
|
181
|
|
|
]); |
|
182
|
4 |
|
|
|
183
|
4 |
|
if($this->tokenStorage->getToken() === null) { |
|
184
|
4 |
|
return $menu; |
|
185
|
4 |
|
} |
|
186
|
|
|
|
|
187
|
4 |
|
$user = $this->tokenStorage->getToken()->getUser(); |
|
188
|
4 |
|
|
|
189
|
|
|
if(!$user instanceof User) { |
|
190
|
4 |
|
return $menu; |
|
191
|
|
|
} |
|
192
|
4 |
|
|
|
193
|
4 |
|
$displayName = $user->getUsername(); |
|
194
|
|
|
|
|
195
|
4 |
|
$userMenu = $menu->addChild('user', [ |
|
196
|
4 |
|
'label' => $displayName |
|
197
|
|
|
]) |
|
198
|
4 |
|
->setExtra('icon', 'fa fa-user') |
|
199
|
4 |
|
->setExtra('menu', 'user') |
|
200
|
|
|
->setExtra('menu-container', '#submenu') |
|
201
|
4 |
|
->setExtra('pull-right', true); |
|
202
|
|
|
|
|
203
|
|
|
$userMenu->addChild('profile.overview.label', [ |
|
204
|
|
|
'route' => 'profile' |
|
205
|
|
|
]) |
|
206
|
4 |
|
->setExtra('icon', 'fas fa-user'); |
|
207
|
4 |
|
|
|
208
|
|
|
$userMenu->addChild('profile.label', [ |
|
209
|
4 |
|
'uri' => $this->idpProfileUrl |
|
210
|
|
|
]) |
|
211
|
4 |
|
->setLinkAttribute('target', '_blank') |
|
212
|
4 |
|
->setExtra('icon', 'fas fa-address-card'); |
|
213
|
|
|
|
|
214
|
|
|
$label = 'dark_mode.enable'; |
|
215
|
4 |
|
$icon = 'fas fa-moon'; |
|
216
|
4 |
|
|
|
217
|
|
|
if($this->darkModeManager->isDarkModeEnabled()) { |
|
218
|
4 |
|
$label = 'dark_mode.disable'; |
|
219
|
|
|
$icon = 'fas fa-sun'; |
|
220
|
|
|
} |
|
221
|
4 |
|
|
|
222
|
4 |
|
$userMenu->addChild($label, [ |
|
223
|
|
|
'route' => 'toggle_darkmode' |
|
224
|
4 |
|
]) |
|
225
|
|
|
->setExtra('icon', $icon); |
|
226
|
|
|
|
|
227
|
|
|
$menu->addChild('label.logout', [ |
|
228
|
|
|
'route' => 'logout', |
|
229
|
|
|
'label' => '' |
|
230
|
|
|
]) |
|
231
|
4 |
|
->setExtra('icon', 'fas fa-sign-out-alt') |
|
232
|
|
|
->setAttribute('title', $this->translator->trans('auth.logout')); |
|
233
|
|
|
|
|
234
|
|
|
return $menu; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
public function dataMenu(array $options = []): ItemInterface { |
|
|
|
|
|
|
238
|
4 |
|
$root = $this->factory->createItem('root'); |
|
239
|
|
|
|
|
240
|
|
|
if($this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
|
241
|
|
|
$root->addChild('admin.sections.label', [ |
|
242
|
|
|
'route' => 'admin_sections' |
|
243
|
|
|
]) |
|
244
|
|
|
->setExtra('icon', 'fas fa-sliders-h'); |
|
245
|
4 |
|
} |
|
246
|
|
|
|
|
247
|
|
|
if($this->authorizationChecker->isGranted('ROLE_DOCUMENTS_ADMIN')) { |
|
248
|
|
|
$root->addChild('admin.documents.label', [ |
|
249
|
|
|
'route' => 'admin_documents' |
|
250
|
|
|
]) |
|
251
|
|
|
->setExtra('icon', 'fas fa-file-alt'); |
|
252
|
4 |
|
} |
|
253
|
|
|
|
|
254
|
|
|
if($this->authorizationChecker->isGranted('ROLE_MESSAGE_CREATOR')) { |
|
255
|
|
|
$root->addChild('admin.messages.label', [ |
|
256
|
|
|
'route' => 'admin_messages' |
|
257
|
|
|
]) |
|
258
|
|
|
->setExtra('icon', 'fas fa-envelope-open-text'); |
|
259
|
4 |
|
} |
|
260
|
|
|
|
|
261
|
|
|
if($this->authorizationChecker->isGranted(ExamVoter::Manage)) { |
|
262
|
|
|
$root->addChild('admin.exams.label', [ |
|
263
|
|
|
'route' => 'admin_exams' |
|
264
|
|
|
]) |
|
265
|
|
|
->setExtra('icon', 'fas fa-pen'); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
if($this->authorizationChecker->isGranted('ROLE_APPOINTMENT_CREATOR')) { |
|
269
|
|
|
$root->addChild('admin.appointments.label', [ |
|
270
|
|
|
'route' => 'admin_appointments' |
|
271
|
|
|
]) |
|
272
|
|
|
->setExtra('icon', 'far fa-calendar'); |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
if($this->authorizationChecker->isGranted('ROLE_WIKI_ADMIN')) { |
|
276
|
4 |
|
$root->addChild('admin.wiki.label', [ |
|
277
|
|
|
'route' => 'admin_wiki' |
|
278
|
|
|
]) |
|
279
|
|
|
->setExtra('icon', 'fab fa-wikipedia-w'); |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
if($this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
|
283
|
|
|
$root->addChild('admin.timetable.label', [ |
|
284
|
|
|
'route' => 'admin_timetable' |
|
285
|
|
|
]) |
|
286
|
|
|
->setExtra('icon', 'far fa-clock'); |
|
287
|
|
|
|
|
288
|
|
|
$root->addChild('admin.resources.label', [ |
|
289
|
|
|
'route' => 'admin_resources' |
|
290
|
|
|
]) |
|
291
|
|
|
->setExtra('icon', 'fas fa-laptop-house'); |
|
292
|
|
|
|
|
293
|
4 |
|
$root->addChild('admin.teachers.label', [ |
|
294
|
|
|
'route' => 'admin_teachers' |
|
295
|
|
|
]) |
|
296
|
|
|
->setExtra('icon', 'fas fa-sort-alpha-down'); |
|
297
|
|
|
|
|
298
|
|
|
$root->addChild('admin.absence_types.label', [ |
|
299
|
|
|
'route' => 'admin_absence_types' |
|
300
|
|
|
]) |
|
301
|
4 |
|
->setExtra('icon', 'fas fa-user-times'); |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
4 |
|
if($this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
|
305
|
4 |
|
$root->addChild('admin.subjects.label', [ |
|
306
|
4 |
|
'route' => 'admin_subjects' |
|
307
|
4 |
|
]) |
|
308
|
|
|
->setExtra('icon', 'fas fa-graduation-cap'); |
|
309
|
|
|
|
|
310
|
4 |
|
$root->addChild('admin.displays.label', [ |
|
311
|
4 |
|
'route' => 'admin_displays' |
|
312
|
|
|
]) |
|
313
|
4 |
|
->setExtra('icon', 'fas fa-tv'); |
|
314
|
4 |
|
} |
|
315
|
4 |
|
|
|
316
|
4 |
|
if($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) { |
|
317
|
4 |
|
$root->addChild('admin.ea.label', [ |
|
318
|
|
|
'uri' => '/admin/ea' |
|
319
|
4 |
|
]) |
|
320
|
|
|
->setLinkAttribute('target', '_blank') |
|
321
|
4 |
|
->setExtra('icon', 'fas fa-tools'); |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
return $root; |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
public function toolsMenu(array $options = [ ]): ItemInterface { |
|
|
|
|
|
|
328
|
4 |
|
$root = $this->factory->createItem('root'); |
|
329
|
|
|
|
|
330
|
4 |
|
if($this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
|
331
|
|
|
$root->addChild('tools.grade_teacher_intersection.label', [ |
|
332
|
|
|
'route' => 'grade_tuition_teachers_intersection' |
|
333
|
|
|
]) |
|
334
|
|
|
->setExtra('icon', 'fas fa-random'); |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
return $root; |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
4 |
|
public function adminMenu(array $options): ItemInterface { |
|
|
|
|
|
|
341
|
|
|
$root = $this->factory->createItem('root') |
|
342
|
|
|
->setChildrenAttributes([ |
|
343
|
|
|
'class' => 'navbar-nav float-lg-right' |
|
344
|
|
|
]); |
|
345
|
|
|
|
|
346
|
|
|
$menu = $root->addChild('admin', [ |
|
347
|
4 |
|
'label' => '' |
|
348
|
|
|
]) |
|
349
|
|
|
->setExtra('icon', 'fa fa-cogs') |
|
350
|
4 |
|
->setAttribute('title', $this->translator->trans('admin.label')) |
|
351
|
4 |
|
->setExtra('menu', 'admin') |
|
352
|
4 |
|
->setExtra('menu-container', '#submenu') |
|
353
|
4 |
|
->setExtra('pull-right', true); |
|
354
|
|
|
|
|
355
|
|
|
$settingsMenu = $this->settingsMenu(); |
|
356
|
4 |
|
|
|
357
|
4 |
|
if($settingsMenu->offsetExists('settings') && count($settingsMenu['settings']->getChildren()) > 0) { |
|
358
|
|
|
$menu->addChild('admin.settings.label', [ |
|
359
|
4 |
|
'route' => 'admin_settings' |
|
360
|
4 |
|
]) |
|
361
|
4 |
|
->setExtra('icon', 'fas fa-wrench'); |
|
362
|
4 |
|
} |
|
363
|
4 |
|
|
|
364
|
|
|
$dataMenu = $this->dataMenu(); |
|
365
|
4 |
|
|
|
366
|
|
|
if($dataMenu->count() > 0) { |
|
367
|
|
|
$firstKey = array_key_first($dataMenu->getChildren()); |
|
368
|
|
|
$first = $dataMenu->getChildren()[$firstKey]; |
|
369
|
|
|
|
|
370
|
|
|
$menu->addChild('admin.label', [ |
|
371
|
|
|
'uri' => $first->getUri() |
|
372
|
|
|
]) |
|
373
|
|
|
->setExtra('icon', 'fas fa-school'); |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
$toolsMenu = $this->toolsMenu(); |
|
377
|
|
|
if($toolsMenu->count() > 0) { |
|
378
|
|
|
$firstKey = array_key_first($toolsMenu->getChildren()); |
|
379
|
|
|
$first = $toolsMenu->getChildren()[$firstKey]; |
|
380
|
|
|
|
|
381
|
|
|
$menu->addChild('tools.label', [ |
|
382
|
|
|
'uri' => $first->getUri() |
|
383
|
|
|
]) |
|
384
|
|
|
->setExtra('icon', 'fas fa-toolbox'); |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
if($this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
|
388
|
4 |
|
$menu->addChild('api.doc', [ |
|
389
|
|
|
'uri' => '/docs/api/import' |
|
390
|
|
|
]) |
|
391
|
4 |
|
->setExtra('icon', 'fas fa-code'); |
|
392
|
4 |
|
} |
|
393
|
4 |
|
|
|
394
|
4 |
|
return $root; |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
4 |
|
public function systemMenu(array $options): ItemInterface { |
|
|
|
|
|
|
398
|
4 |
|
$root = $this->factory->createItem('root') |
|
399
|
|
|
->setChildrenAttributes([ |
|
400
|
4 |
|
'class' => 'navbar-nav float-lg-right' |
|
401
|
4 |
|
]); |
|
402
|
4 |
|
|
|
403
|
4 |
|
$menu = $root->addChild('system', [ |
|
404
|
4 |
|
'label' => '' |
|
405
|
|
|
]) |
|
406
|
4 |
|
->setExtra('icon', 'fa fa-tools') |
|
407
|
|
|
->setExtra('menu', 'system') |
|
408
|
|
|
->setExtra('menu-container', '#submenu') |
|
409
|
|
|
->setExtra('pull-right', true) |
|
410
|
|
|
->setAttribute('title', $this->translator->trans('system.label')); |
|
411
|
|
|
|
|
412
|
|
|
if($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) { |
|
413
|
|
|
$menu->addChild('cron.label', [ |
|
414
|
|
|
'route' => 'admin_cronjobs' |
|
415
|
|
|
]) |
|
416
|
|
|
->setExtra('icon', 'fas fa-history'); |
|
417
|
|
|
|
|
418
|
|
|
$menu->addChild('logs.label', [ |
|
419
|
|
|
'route' => 'admin_logs' |
|
420
|
|
|
]) |
|
421
|
|
|
->setExtra('icon', 'fas fa-clipboard-list'); |
|
422
|
|
|
|
|
423
|
|
|
$menu->addChild('messenger.label', [ |
|
424
|
|
|
'route' => 'admin_messenger' |
|
425
|
|
|
]) |
|
426
|
|
|
->setExtra('icon', 'fas fa-envelope-open-text'); |
|
427
|
|
|
|
|
428
|
|
|
$menu->addChild('audit.label', [ |
|
429
|
|
|
'uri' => '/admin/audit' |
|
430
|
|
|
]) |
|
431
|
|
|
->setLinkAttribute('target', '_blank') |
|
432
|
|
|
->setExtra('icon', 'far fa-eye'); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
return $root; |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
public function importMenu(array $options = [ ]): ItemInterface { |
|
|
|
|
|
|
439
|
|
|
$root = $this->factory->createItem('root') |
|
440
|
|
|
->setChildrenAttributes([ |
|
441
|
|
|
'class' => 'navbar-nav float-lg-right' |
|
442
|
|
|
]); |
|
443
|
|
|
|
|
444
|
4 |
|
$menu = $root->addChild('import', [ |
|
445
|
|
|
'label' => '' |
|
446
|
|
|
]) |
|
447
|
4 |
|
->setExtra('icon', 'fas fa-upload') |
|
448
|
4 |
|
->setExtra('menu', 'import') |
|
449
|
4 |
|
->setExtra('menu-container', '#submenu') |
|
450
|
|
|
->setExtra('pull-right', true) |
|
451
|
4 |
|
->setAttribute('title', $this->translator->trans('import.label')); |
|
452
|
4 |
|
|
|
453
|
|
|
if($this->authorizationChecker->isGranted('ROLE_IMPORTER')) { |
|
454
|
4 |
|
$menu->addChild('import.settings.label', [ |
|
455
|
|
|
'route' => 'import_untis_settings' |
|
456
|
4 |
|
]) |
|
457
|
|
|
->setExtra('icon', 'fas fa-cogs'); |
|
458
|
|
|
|
|
459
|
4 |
|
$menu->addChild('import.substitutions.gpu.label', [ |
|
460
|
|
|
'route' => 'import_untis_substitutions_gpu' |
|
461
|
4 |
|
]) |
|
462
|
4 |
|
->setExtra('icon', 'fas fa-random'); |
|
463
|
|
|
|
|
464
|
4 |
|
$menu->addChild('import.substitutions.html.label', [ |
|
465
|
|
|
'route' => 'import_untis_substitutions_html' |
|
466
|
|
|
]) |
|
467
|
2 |
|
->setExtra('icon', 'fas fa-random'); |
|
468
|
|
|
|
|
469
|
|
|
$menu->addChild('import.exams.label', [ |
|
470
|
4 |
|
'route' => 'import_untis_exams' |
|
471
|
|
|
]) |
|
472
|
|
|
->setExtra('icon', 'fas fa-edit'); |
|
473
|
|
|
|
|
474
|
4 |
|
$menu->addChild('import.supervisions.label', [ |
|
475
|
4 |
|
'route' => 'import_untis_supervisions' |
|
476
|
|
|
]) |
|
477
|
4 |
|
->setExtra('icon', 'fas fa-eye'); |
|
478
|
4 |
|
|
|
479
|
|
|
$menu->addChild('import.rooms.label', [ |
|
480
|
4 |
|
'route' => 'import_untis_rooms' |
|
481
|
4 |
|
]) |
|
482
|
|
|
->setExtra('icon', 'fas fa-door-open'); |
|
483
|
4 |
|
|
|
484
|
4 |
|
$menu->addChild('import.timetable.html.label', [ |
|
485
|
|
|
'route' => 'import_untis_timetable_html' |
|
486
|
4 |
|
]) |
|
487
|
|
|
->setExtra('icon', 'far fa-clock'); |
|
488
|
4 |
|
} |
|
489
|
|
|
|
|
490
|
4 |
|
return $root; |
|
491
|
4 |
|
} |
|
492
|
1 |
|
|
|
493
|
1 |
|
public function settingsMenu(array $options = [ ]): ItemInterface { |
|
|
|
|
|
|
494
|
|
|
$root = $this->factory->createItem('root') |
|
495
|
1 |
|
->setChildrenAttributes([ |
|
496
|
3 |
|
'class' => 'navbar-nav float-lg-right' |
|
497
|
3 |
|
]); |
|
498
|
3 |
|
|
|
499
|
|
|
$menu = $root->addChild('settings', [ |
|
500
|
3 |
|
'label' => '' |
|
501
|
|
|
]) |
|
502
|
|
|
->setExtra('icon', 'fa fa-wrench') |
|
503
|
|
|
->setExtra('menu', 'settings') |
|
504
|
4 |
|
->setExtra('menu-container', '#submenu') |
|
505
|
|
|
->setExtra('pull-right', true) |
|
506
|
|
|
->setAttribute('title', $this->translator->trans('admin.settings.label')); |
|
507
|
4 |
|
|
|
508
|
4 |
|
if($this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
|
509
|
4 |
|
$menu->addChild('admin.settings.general.label', [ |
|
510
|
4 |
|
'route' => 'admin_settings_general' |
|
511
|
|
|
]); |
|
512
|
|
|
|
|
513
|
4 |
|
$menu->addChild('admin.settings.dashboard.label', [ |
|
514
|
|
|
'route' => 'admin_settings_dashboard' |
|
515
|
4 |
|
]); |
|
516
|
4 |
|
|
|
517
|
4 |
|
$menu->addChild('admin.settings.notifications.label', [ |
|
518
|
|
|
'route' => 'admin_settings_notifications' |
|
519
|
4 |
|
]); |
|
520
|
4 |
|
|
|
521
|
4 |
|
$menu->addChild('admin.settings.timetable.label', [ |
|
522
|
4 |
|
'route' => 'admin_settings_timetable' |
|
523
|
|
|
]); |
|
524
|
4 |
|
|
|
525
|
|
|
$menu->addChild('admin.settings.exams.label', [ |
|
526
|
|
|
'route' => 'admin_settings_exams' |
|
527
|
|
|
]); |
|
528
|
|
|
|
|
529
|
|
|
$menu->addChild('admin.settings.substitutions.label', [ |
|
530
|
|
|
'route' => 'admin_settings_substitutions' |
|
531
|
|
|
]); |
|
532
|
|
|
|
|
533
|
|
|
$menu->addChild('admin.settings.appointments.label', [ |
|
534
|
|
|
'route' => 'admin_settings_appointments' |
|
535
|
|
|
]); |
|
536
|
|
|
|
|
537
|
4 |
|
$menu->addChild('admin.settings.student_absences.label', [ |
|
538
|
|
|
'route' => 'admin_settings_absences' |
|
539
|
|
|
]); |
|
540
|
4 |
|
|
|
541
|
4 |
|
$menu->addChild('admin.settings.book.label', [ |
|
542
|
4 |
|
'route' => 'admin_settings_book' |
|
543
|
4 |
|
]); |
|
544
|
|
|
|
|
545
|
|
|
$menu->addChild('admin.settings.import.label', [ |
|
546
|
4 |
|
'route' => 'admin_settings_import' |
|
547
|
|
|
]); |
|
548
|
4 |
|
} |
|
549
|
|
|
|
|
550
|
4 |
|
return $root; |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
public function mainMenu(array $options) { |
|
|
|
|
|
|
554
|
4 |
|
$menu = $this->factory->createItem('root') |
|
555
|
|
|
->setChildrenAttribute('class', 'navbar-nav mr-auto'); |
|
556
|
4 |
|
|
|
557
|
|
|
$menu->addChild('dashboard.label', [ |
|
558
|
|
|
'route' => 'dashboard' |
|
559
|
|
|
]) |
|
560
|
4 |
|
->setExtra('icon', 'fa fa-home'); |
|
561
|
|
|
|
|
562
|
|
|
$menu->addChild('messages.overview.label', [ |
|
563
|
|
|
'route' => 'messages' |
|
564
|
|
|
]) |
|
565
|
|
|
->setExtra('icon', 'fas fa-envelope-open-text'); |
|
566
|
|
|
|
|
567
|
|
|
$plansMenu = $this->plansMenu($menu); |
|
568
|
|
|
$this->setFirstChildAsUri($plansMenu); |
|
569
|
|
|
$listsMenu = $this->listsMenu($menu); |
|
570
|
|
|
$this->setFirstChildAsUri($listsMenu); |
|
571
|
4 |
|
|
|
572
|
|
|
|
|
573
|
|
|
$menu->addChild('documents.label', [ |
|
574
|
|
|
'route' => 'documents' |
|
575
|
|
|
]) |
|
576
|
|
|
->setExtra('icon', 'fas fa-file-alt'); |
|
577
|
|
|
|
|
578
|
|
|
$this->wikiMenu($menu); |
|
579
|
|
|
|
|
580
|
|
|
if($this->studentAbsenceSettings->isEnabled() === true) { |
|
581
|
|
|
if($this->authorizationChecker->isGranted('ROLE_SICK_NOTE_VIEWER') |
|
582
|
|
|
|| $this->authorizationChecker->isGranted('ROLE_SICK_NOTE_CREATOR') |
|
583
|
|
|
|| $this->authorizationChecker->isGranted(StudentAbsenceVoter::New)) { |
|
584
|
|
|
$menu->addChild('student_absences.label', [ |
|
585
|
|
|
'route' => 'absences' |
|
586
|
|
|
]) |
|
587
|
|
|
->setExtra('icon', 'fas fa-user-times'); |
|
588
|
|
|
} |
|
589
|
|
|
} |
|
590
|
|
|
|
|
591
|
|
|
if($this->authorizationChecker->isGranted('ROLE_BOOK_VIEWER')) { |
|
592
|
|
|
$this->bookMenu($menu); |
|
593
|
|
|
} |
|
594
|
|
|
|
|
595
|
|
|
return $menu; |
|
596
|
|
|
} |
|
597
|
|
|
|
|
598
|
|
|
public function servicesMenu(): ItemInterface { |
|
599
|
|
|
$root = $this->factory->createItem('root') |
|
600
|
|
|
->setChildrenAttributes([ |
|
601
|
|
|
'class' => 'navbar-nav float-lg-right' |
|
602
|
|
|
]); |
|
603
|
|
|
|
|
604
|
|
|
$token = $this->tokenStorage->getToken(); |
|
605
|
|
|
|
|
606
|
|
|
if($token instanceof SamlToken) { |
|
607
|
|
|
$menu = $root->addChild('services', [ |
|
608
|
|
|
'label' => '' |
|
609
|
|
|
]) |
|
610
|
|
|
->setExtra('icon', 'fa fa-th') |
|
611
|
|
|
->setExtra('menu', 'services') |
|
612
|
|
|
->setExtra('pull-right', true) |
|
613
|
|
|
->setAttribute('title', $this->translator->trans('services.label')); |
|
614
|
|
|
|
|
615
|
|
|
foreach($token->getAttribute('services') as $service) { |
|
616
|
|
|
$item = $menu->addChild($service->name, [ |
|
617
|
|
|
'uri' => $service->url |
|
618
|
|
|
]) |
|
619
|
|
|
->setAttribute('title', $service->description) |
|
620
|
|
|
->setLinkAttribute('target', '_blank'); |
|
621
|
|
|
|
|
622
|
|
|
if(isset($service->icon) && !empty($service->icon)) { |
|
623
|
|
|
$item->setExtra('icon', $service->icon); |
|
624
|
|
|
} |
|
625
|
|
|
} |
|
626
|
|
|
} |
|
627
|
|
|
|
|
628
|
|
|
return $root; |
|
629
|
|
|
} |
|
630
|
|
|
|
|
631
|
|
|
private function setFirstChildAsUri(ItemInterface $root): ItemInterface { |
|
632
|
|
|
if(count($root->getChildren()) === 0) { |
|
633
|
|
|
return $root; |
|
634
|
|
|
} |
|
635
|
|
|
|
|
636
|
|
|
$firstKey = array_key_first($root->getChildren()); |
|
637
|
|
|
$firstItem = $root->getChildren()[$firstKey]; |
|
638
|
|
|
|
|
639
|
|
|
$root->setUri($firstItem->getUri()); |
|
640
|
|
|
|
|
641
|
|
|
return $root; |
|
642
|
|
|
} |
|
643
|
|
|
} |
|
644
|
|
|
|