Passed
Pull Request — master (#6879)
by Yannick
09:21
created

IndexBlocksController::getItemsGradebook()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\Controller\Admin;
8
9
use AppPlugin;
10
use Chamilo\CoreBundle\Controller\BaseController;
11
use Chamilo\CoreBundle\Entity\Page;
12
use Chamilo\CoreBundle\Entity\PageCategory;
13
use Chamilo\CoreBundle\Entity\SequenceResource;
14
use Chamilo\CoreBundle\Event\AbstractEvent;
15
use Chamilo\CoreBundle\Event\AdminBlockDisplayedEvent;
16
use Chamilo\CoreBundle\Event\Events;
17
use Chamilo\CoreBundle\Helpers\AccessUrlHelper;
18
use Chamilo\CoreBundle\Helpers\AuthenticationConfigHelper;
19
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
20
use Chamilo\CoreBundle\Repository\PageCategoryRepository;
21
use Chamilo\CoreBundle\Repository\PageRepository;
22
use Chamilo\CoreBundle\Repository\PluginRepository;
23
use Chamilo\CoreBundle\Settings\SettingsManager;
24
use Plugin;
25
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
26
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
27
use Symfony\Component\HttpFoundation\JsonResponse;
28
use Symfony\Component\Routing\Attribute\Route;
29
use Symfony\Component\Serializer\SerializerInterface;
30
use Symfony\Contracts\Translation\TranslatorInterface;
31
32
#[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_SESSION_MANAGER')")]
33
#[Route('/admin/index', name: 'admin_index_blocks')]
34
class IndexBlocksController extends BaseController
35
{
36
    private bool $isAdmin = false;
37
    private bool $isSessionAdmin = false;
38
    private bool $isLdapActive;
39
40
    public function __construct(
41
        private readonly TranslatorInterface $translator,
42
        private readonly SettingsManager $settingsManager,
43
        private readonly PageRepository $pageRepository,
44
        private readonly PageCategoryRepository $pageCategoryRepository,
45
        private readonly SerializerInterface $serializer,
46
        private readonly EventDispatcherInterface $eventDispatcher,
47
        private readonly PluginRepository $pluginRepository,
48
        private readonly AccessUrlHelper $accessUrlHelper,
49
        private readonly AccessUrlRepository $accessUrlRepository,
50
        AuthenticationConfigHelper $authConfigHelper,
51
    ) {
52
        $this->isLdapActive = $authConfigHelper->getLdapConfig()['enabled'];
53
    }
54
55
    public function __invoke(): JsonResponse
56
    {
57
        $this->isAdmin = $this->isGranted('ROLE_ADMIN');
58
        $this->isSessionAdmin = $this->isGranted('ROLE_SESSION_MANAGER');
59
60
        $json = [];
61
62
        $adminBlockEvent = new AdminBlockDisplayedEvent($json, AbstractEvent::TYPE_PRE);
63
64
        $this->eventDispatcher->dispatch($adminBlockEvent, Events::ADMIN_BLOCK_DISPLAYED);
65
66
        $json = $adminBlockEvent->getData();
67
68
        $json['users'] = [
69
            'id' => 'block-admin-users',
70
            'searchUrl' => '/main/admin/user_list.php',
71
            'editable' => $this->isAdmin,
72
            'items' => $this->getItemsUsers(),
73
            'extraContent' => $this->getExtraContent('block-admin-users'),
74
        ];
75
76
        if ($this->isAdmin) {
77
            $json['courses'] = [
78
                'id' => 'block-admin-courses',
79
                'searchUrl' => '/main/admin/course_list.php',
80
                'editable' => true,
81
                'items' => $this->getItemsCourses(),
82
                'extraContent' => $this->getExtraContent('block-admin-courses'),
83
            ];
84
85
            $json['platform'] = [
86
                'id' => 'block-admin-platform',
87
                'searchUrl' => $this->generateUrl('chamilo_platform_settings_search'),
88
                'editable' => true,
89
                'items' => $this->getItemsPlatform(),
90
                'extraContent' => $this->getExtraContent('block-admin-platform'),
91
            ];
92
93
            /* Settings */
94
            $json['settings'] = [
95
                'id' => 'block-admin-settings',
96
                'editable' => false,
97
                'items' => $this->getItemsSettings(),
98
                'extraContent' => $this->getExtraContent('block-admin-settings'),
99
            ];
100
101
            // Skills
102
            if ('true' === $this->settingsManager->getSetting('skill.allow_skills_tool')) {
103
                $json['skills'] = [
104
                    'id' => 'block-admin-skills',
105
                    'editable' => false,
106
                    'items' => $this->getItemsSkills(),
107
                    'extraContent' => $this->getExtraContent('block-admin-skills'),
108
                ];
109
            }
110
111
            if ('true' === $this->settingsManager->getSetting('gradebook.gradebook_dependency')) {
112
                $json['gradebook'] = [
113
                    'id' => 'block-admin-gradebook',
114
                    'editable' => false,
115
                    'items' => $this->getItemsGradebook(),
116
                    'extraContent' => $this->getExtraContent('block-admin-gradebook'),
117
                ];
118
            }
119
120
            // Data protection
121
            if ('true' !== $this->settingsManager->getSetting('privacy.disable_gdpr')) {
122
                $json['data_privacy'] = [
123
                    'id' => 'block-admin-privacy',
124
                    'editable' => false,
125
                    'items' => $this->getItemsPrivacy(),
126
                    'extraContent' => $this->getExtraContent('block-admin-privacy'),
127
                ];
128
            }
129
130
            $json['security'] = [
131
                'id' => 'block-admin-security',
132
                'editable' => false,
133
                'items' => $this->getItemsSecurity(),
134
                'extraContent' => $this->getExtraContent('block-admin-security'),
135
            ];
136
137
            /* Chamilo.org */
138
            $json['chamilo'] = [
139
                'id' => 'block-admin-chamilo',
140
                'editable' => false,
141
                'items' => $this->getItemsChamilo(),
142
                'extraContent' => $this->getExtraContent('block-admin-chamilo'),
143
            ];
144
145
            $json['plugins'] = [
146
                'id' => 'block-admin-plugins',
147
                'editable' => false,
148
                'items' => $this->getItemsPlugins(),
149
            ];
150
151
            /* Health check */
152
            $json['health_check'] = [
153
                'id' => 'block-admin-health-check',
154
                'editable' => false,
155
                'items' => $this->getItemsHealthCheck(),
156
            ];
157
        }
158
159
        /* Sessions */
160
        $json['sessions'] = [
161
            'id' => 'block-admin-sessions',
162
            'searchUrl' => '/main/session/session_list.php',
163
            'editable' => $this->isAdmin,
164
            'items' => $this->getItemsSessions(),
165
            'extraContent' => $this->getExtraContent('block-admin-sessions'),
166
        ];
167
168
        $adminBlockEvent = new AdminBlockDisplayedEvent($json, AbstractEvent::TYPE_POST);
169
170
        $this->eventDispatcher->dispatch($adminBlockEvent, Events::ADMIN_BLOCK_DISPLAYED);
171
172
        $json = $adminBlockEvent->getData();
173
174
        return $this->json($json);
175
    }
176
177
    private function getItemsSecurity(): array
178
    {
179
        return [
180
            [
181
                'class' => 'item-security-login-attempts',
182
                'url' => $this->generateUrl('admin_security_login_attempts'),
183
                'label' => $this->translator->trans('Login attempts'),
184
            ],
185
        ];
186
    }
187
188
    private function getItemsUsers(): array
189
    {
190
        $items = [];
191
        $items[] = [
192
            'class' => 'item-user-list',
193
            'url' => '/main/admin/user_list.php',
194
            'label' => $this->translator->trans('User list'),
195
        ];
196
        $items[] = [
197
            'class' => 'item-user-add',
198
            'url' => '/main/admin/user_add.php',
199
            'label' => $this->translator->trans('Add a user'),
200
        ];
201
202
        if ($this->isAdmin) {
203
            $items[] = [
204
                'class' => 'item-user-export',
205
                'url' => '/main/admin/user_export.php',
206
                'label' => $this->translator->trans('Export users list'),
207
            ];
208
            $items[] = [
209
                'class' => 'item-user-import',
210
                'url' => '/main/admin/user_import.php',
211
                'label' => $this->translator->trans('Import users list'),
212
            ];
213
            $items[] = [
214
                'class' => 'item-user-import-update',
215
                'url' => '/main/admin/user_update_import.php',
216
                'label' => $this->translator->trans('Edit users list'),
217
            ];
218
            $items[] = [
219
                'class' => 'item-user-import-anonymize',
220
                'url' => '/main/admin/user_anonymize_import.php',
221
                'label' => $this->translator->trans('Anonymise users list'),
222
            ];
223
224
            if ($this->isLdapActive) {
225
                $items[] = [
226
                    'class' => 'item-user-ldap-list',
227
                    'url' => '/main/admin/ldap_users_list.php',
228
                    'label' => $this->translator->trans('Import LDAP users into the platform'),
229
                ];
230
            }
231
232
            $items[] = [
233
                'class' => 'item-user-field',
234
                'url' => '/main/admin/extra_fields.php?'.http_build_query(['type' => 'user']),
235
                'label' => $this->translator->trans('Profiling'),
236
            ];
237
            $items[] = [
238
                'class' => 'item-user-groups',
239
                'url' => '/main/admin/usergroups.php',
240
                'label' => $this->translator->trans('Classes'),
241
            ];
242
243
            if ('true' === $this->settingsManager->getSetting('admin.show_link_request_hrm_user')) {
244
                $items[] = [
245
                    'class' => 'item-user-linking-requests',
246
                    'url' => '/main/admin/user_linking_requests.php',
247
                    'label' => $this->translator->trans('Student linking requests'),
248
                ];
249
            }
250
        } else {
251
            $items[] = [
252
                'class' => 'item-user-import',
253
                'url' => '/main/admin/user_import.php',
254
                'label' => $this->translator->trans('Import users list'),
255
            ];
256
            $items[] = [
257
                'class' => 'item-user-groups',
258
                'url' => '/main/admin/usergroups.php',
259
                'label' => $this->translator->trans('Classes'),
260
            ];
261
262
            if ('true' === $this->settingsManager->getSetting('session.limit_session_admin_role')) {
263
                $items = array_filter($items, function (array $item) {
264
                    $urls = [
265
                        '/main/admin/user_list.php',
266
                        '/main/admin/user_add.php',
267
                    ];
268
269
                    return \in_array($item['url'], $urls, true);
270
                });
271
            }
272
273
            if ('true' === $this->settingsManager->getSetting('session.limit_session_admin_list_users')) {
274
                $items = array_filter($items, function (array $item): bool {
275
                    $urls = [
276
                        '/main/admin/user_list.php',
277
                    ];
278
279
                    return !\in_array($item['url'], $urls, true);
280
                });
281
            }
282
283
            if ('true' === $this->settingsManager->getSetting('session.allow_session_admin_extra_access')) {
284
                $items[] = [
285
                    'class' => 'item-user-import-update',
286
                    'url' => '/main/admin/user_update_import.php',
287
                    'label' => $this->translator->trans('Edit users list'),
288
                ];
289
                $items[] = [
290
                    'class' => 'item-user-export',
291
                    'url' => '/main/admin/user_export.php',
292
                    'label' => $this->translator->trans('Export users list'),
293
                ];
294
            }
295
        }
296
297
        return array_values($items);
298
    }
299
300
    private function getExtraContent(string $title): ?array
301
    {
302
        /** @var Page|null $page */
303
        $page = $this->pageRepository->findOneBy(['title' => $title]);
304
305
        $pageJsonld = $this->serializer->serialize($page, 'jsonld', ['groups' => ['adminblock:read']]);
306
        $pageArray = json_decode($pageJsonld, true);
307
308
        if ($page) {
309
            return $pageArray;
310
        }
311
312
        /** @var PageCategory $category */
313
        $category = $this->pageCategoryRepository->findOneBy(['title' => $title]);
314
        $categoryJsonld = $this->serializer->serialize($category, 'jsonld', ['groups' => ['page:read']]);
315
        $categoryArray = json_decode($categoryJsonld, true);
316
317
        if (empty($categoryArray)) {
318
            return [];
319
        }
320
321
        return [
322
            'category' => $categoryArray['@id'],
323
        ];
324
    }
325
326
    private function getItemsCourses(): array
327
    {
328
        $items = [];
329
        $items[] = [
330
            'class' => 'item-course-list',
331
            'url' => '/main/admin/course_list.php',
332
            'label' => $this->translator->trans('Course list'),
333
        ];
334
        $items[] = [
335
            'class' => 'item-course-add',
336
            'url' => '/main/admin/course_add.php',
337
            'label' => $this->translator->trans('Add course'),
338
        ];
339
340
        if ('true' === $this->settingsManager->getSetting('course.course_validation')) {
341
            $items[] = [
342
                'class' => 'item-course-request',
343
                'url' => '/main/admin/course_request_review.php',
344
                'label' => $this->translator->trans('Review incoming course requests'),
345
            ];
346
            $items[] = [
347
                'class' => 'item-course-request-accepted',
348
                'url' => '/main/admin/course_request_accepted.php',
349
                'label' => $this->translator->trans('Accepted course requests'),
350
            ];
351
            $items[] = [
352
                'class' => 'item-course-request-rejected',
353
                'url' => '/main/admin/course_request_rejected.php',
354
                'label' => $this->translator->trans('Rejected course requests'),
355
            ];
356
        }
357
358
        $items[] = [
359
            'class' => 'item-course-export',
360
            'url' => '/main/admin/course_export.php',
361
            'label' => $this->translator->trans('Export courses'),
362
        ];
363
        $items[] = [
364
            'class' => 'item-course-import',
365
            'url' => '/main/admin/course_import.php',
366
            'label' => $this->translator->trans('Import courses list'),
367
        ];
368
        $items[] = [
369
            'class' => 'item-course-category',
370
            'url' => '/main/admin/course_category.php',
371
            'label' => $this->translator->trans('Course categories'),
372
        ];
373
        $items[] = [
374
            'class' => 'item-course-subscription',
375
            'url' => '/main/admin/subscribe_user2course.php',
376
            'label' => $this->translator->trans('Add a user to a course'),
377
        ];
378
        $items[] = [
379
            'class' => 'item-course-subscription-import',
380
            'url' => '/main/admin/course_user_import.php',
381
            'label' => $this->translator->trans('Import users list'),
382
        ];
383
        // $items[] = [
384
        //    'url'=>'course_intro_pdf_import.php',
385
        //    'label' => $this->translator->$this->trans('Import PDF introductions into courses'),
386
        // ];
387
388
        if ('true' === $this->settingsManager->getSetting('gradebook.gradebook_enable_grade_model')) {
389
            $items[] = [
390
                'class' => 'item-grade-model',
391
                'url' => '/main/admin/grade_models.php',
392
                'label' => $this->translator->trans('Grading model'),
393
            ];
394
        }
395
396
        if ($this->isLdapActive) {
397
            $items[] = [
398
                'class' => 'item-course-subscription-ldap',
399
                'url' => '/main/admin/ldap_import_students.php',
400
                'label' => $this->translator->trans('Import LDAP users into a course'),
401
            ];
402
        }
403
404
        $items[] = [
405
            'class' => 'item-course-field',
406
            'url' => '/main/admin/extra_fields.php?'.http_build_query(['type' => 'course']),
407
            'label' => $this->translator->trans('Manage extra fields for courses'),
408
        ];
409
        $items[] = [
410
            'class' => 'item-question-bank',
411
            'url' => '/main/admin/questions.php',
412
            'label' => $this->translator->trans('Questions'),
413
        ];
414
        $items[] = [
415
            'class' => 'item-resource-sequence',
416
            'url' => '/main/admin/resource_sequence.php?'.http_build_query(['type' => SequenceResource::COURSE_TYPE]),
417
            'label' => $this->translator->trans('Resources sequencing'),
418
        ];
419
420
        return $items;
421
    }
422
423
    private function getItemsPlatform(): array
424
    {
425
        $items = [];
426
        $items[] = [
427
            'class' => 'item-setting-list',
428
            'url' => $this->generateUrl('admin_settings'),
429
            'label' => $this->translator->trans('Configuration settings'),
430
        ];
431
        $items[] = [
432
            'class' => 'item-language-list',
433
            'url' => '/main/admin/languages.php',
434
            'label' => $this->translator->trans('Languages'),
435
        ];
436
        $items[] = [
437
            'class' => 'item-plugin-list',
438
            'url' => '/main/admin/settings.php?'.http_build_query(['category' => 'Plugins']),
439
            'label' => $this->translator->trans('Plugins'),
440
        ];
441
        $items[] = [
442
            'class' => 'item-region-list',
443
            'url' => '/main/admin/settings.php?'.http_build_query(['category' => 'Regions']),
444
            'label' => $this->translator->trans('Regions'),
445
        ];
446
        $items[] = [
447
            'class' => 'item-global-announcement',
448
            'url' => '/main/admin/system_announcements.php',
449
            'label' => $this->translator->trans('Portal news'),
450
        ];
451
        $items[] = [
452
            'class' => 'item-global-agenda',
453
            'route' => ['name' => 'CCalendarEventList', 'query' => ['type' => 'global']],
454
            'label' => $this->translator->trans('Global agenda'),
455
        ];
456
        $items[] = [
457
            'class' => 'item-agenda-reminders',
458
            'url' => '/main/admin/import_course_agenda_reminders.php',
459
            'label' => $this->translator->trans('Import course events'),
460
        ];
461
        $items[] = [
462
            'class' => 'item-pages-list',
463
            'route' => ['name' => 'PageList'],
464
            'label' => $this->translator->trans('Pages'),
465
        ];
466
        /*
467
         * Disabled until differentiated with Pages, and reviewed - see GH#6404
468
        $items[] = [
469
            'class' => 'item-page-layouts',
470
            'route' => ['name' => 'PageLayoutList'],
471
            'label' => $this->translator->trans('Page layouts'),
472
        ];
473
        */
474
        $items[] = [
475
            'class' => 'item-registration-page',
476
            'url' => '/main/auth/registration.php?'.http_build_query(['create_intro_page' => 1]),
477
            'label' => $this->translator->trans('Setting the registration page'),
478
        ];
479
        $items[] = [
480
            'class' => 'item-stats',
481
            'url' => '/main/admin/statistics/index.php',
482
            'label' => $this->translator->trans('Statistics'),
483
        ];
484
        $items[] = [
485
            'class' => 'item-stats-report',
486
            'url' => '/main/my_space/company_reports.php',
487
            'label' => $this->translator->trans('Reports'),
488
        ];
489
        $items[] = [
490
            'class' => 'item-teacher-time-report',
491
            'url' => '/main/admin/teacher_time_report.php',
492
            'label' => $this->translator->trans('Teachers time report'),
493
        ];
494
495
        if (api_get_configuration_value('chamilo_cms')) {
496
            $items[] = [
497
                'class' => 'item-cms',
498
                'url' => api_get_path(WEB_PATH).'web/app_dev.php/administration/dashboard',
499
                'label' => $this->translator->trans('CMS'),
500
            ];
501
        }
502
503
        /* Event settings */
504
505
        $items[] = [
506
            'class' => 'item-field',
507
            'url' => '/main/admin/extra_field_list.php',
508
            'label' => $this->translator->trans('Extra fields'),
509
        ];
510
511
        if (api_is_global_platform_admin()) {
512
            $items[] = [
513
                'class' => 'item-access-url',
514
                'url' => '/main/admin/access_urls.php',
515
                'label' => $this->translator->trans('Configure multiple access URL'),
516
            ];
517
        }
518
519
        if ('true' === api_get_plugin_setting('dictionary', 'enable_plugin_dictionary')) {
520
            $items[] = [
521
                'class' => 'item-dictionary',
522
                'url' => api_get_path(WEB_PLUGIN_PATH).'Dictionary/terms.php',
523
                'label' => $this->translator->trans('Dictionary'),
524
            ];
525
        }
526
527
        if ('true' === $this->settingsManager->getSetting('registration.allow_terms_conditions', true)) {
528
            $items[] = [
529
                'class' => 'item-terms-and-conditions',
530
                'route' => ['name' => 'TermsConditionsList'],
531
                'label' => $this->translator->trans('Terms and Conditions'),
532
            ];
533
        }
534
535
        $items[] = [
536
            'class' => 'item-mail-template',
537
            'url' => '/main/mail_template/list.php',
538
            'label' => $this->translator->trans('Mail templates'),
539
        ];
540
541
        if ('true' === api_get_setting('platform.notification_event')) {
542
            $items[] = [
543
                'class' => 'item-notification-list',
544
                'url' => '/main/notification_event/list.php',
545
                'label' => $this->translator->trans('Notifications'),
546
            ];
547
        }
548
549
        $allowJustification = 'true' === api_get_plugin_setting('justification', 'tool_enable');
550
551
        if ($allowJustification) {
552
            $items[] = [
553
                'class' => 'item-justification-list',
554
                'url' => api_get_path(WEB_PLUGIN_PATH).'Justification/list.php',
555
                'label' => $this->translator->trans('Justification'),
556
            ];
557
        }
558
559
        $items[] = [
560
            'class' => 'item-lti-admin',
561
            'url' => $this->generateUrl('chamilo_lti_admin'),
562
            'label' => $this->translator->trans('External tools (LTI)'),
563
        ];
564
565
        $items[] = [
566
            'class' => 'item-contact-category-admin',
567
            'url' => $this->generateUrl('chamilo_contact_category_index'),
568
            'label' => $this->translator->trans('Contact form categories'),
569
        ];
570
571
        $items[] = [
572
            'class' => 'item-system-template-admin',
573
            'url' => '/main/admin/settings.php?'.http_build_query(['category' => 'Templates']),
574
            'label' => $this->translator->trans('System templates'),
575
        ];
576
577
        return $items;
578
    }
579
580
    private function getItemsSettings(): array
581
    {
582
        $items = [];
583
        $items[] = [
584
            'class' => 'item-cleanup-temp-uploads',
585
            'url' => '/admin/cleanup-temp-uploads',
586
            'label' => $this->translator->trans('Clean temporary files'),
587
        ];
588
589
        $items[] = [
590
            'class' => 'item-special-export',
591
            'url' => '/main/admin/special_exports.php',
592
            'label' => $this->translator->trans('Special exports'),
593
        ];
594
        /*$items[] = [
595
            'url' => '/main/admin/periodic_export.php',
596
            'label' => $this->translator->$this->trans('Periodic export'),
597
        ];*/
598
        $items[] = [
599
            'class' => 'item-system-status',
600
            'url' => '/main/admin/system_status.php',
601
            'label' => $this->translator->trans('System status'),
602
        ];
603
        if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
604
            $items[] = [
605
                'class' => 'item-data-filler',
606
                'url' => '/main/admin/filler.php',
607
                'label' => $this->translator->trans('Data filler'),
608
            ];
609
        }
610
611
        if (is_dir(api_get_path(SYS_TEST_PATH))) {
612
            $items[] = [
613
                'class' => 'item-email-tester',
614
                'url' => '/main/admin/email_tester.php',
615
                'label' => $this->translator->trans('E-mail tester'),
616
            ];
617
        }
618
619
        $items[] = [
620
            'class' => 'item-ticket-system',
621
            'url' => '/main/ticket/tickets.php',
622
            'label' => $this->translator->trans('Tickets'),
623
        ];
624
625
        $items[] = [
626
            'url' => '/main/session/cron_status.php',
627
            'label' => $this->translator->trans('Update session status'),
628
        ];
629
630
        $items[] = [
631
            'class' => 'item-colors',
632
            'route' => ['name' => 'AdminConfigurationColors'],
633
            'label' => $this->translator->trans('Colors'),
634
        ];
635
636
        $items[] = [
637
            'class' => 'item-file-info',
638
            'url' => '/admin/files_info',
639
            'label' => $this->translator->trans('File info'),
640
        ];
641
642
        $items[] = [
643
            'class' => 'item-resources-info',
644
            'url' => '/admin/resources_info',
645
            'label' => $this->translator->trans('Resources by type'),
646
        ];
647
648
        return $items;
649
    }
650
651
    private function getItemsSkills(): array
652
    {
653
        $items = [];
654
        $items[] = [
655
            'class' => 'item-skill-wheel',
656
            'route' => ['name' => 'SkillWheel'],
657
            'label' => $this->translator->trans('Skills wheel'),
658
        ];
659
        $items[] = [
660
            'class' => 'item-skill-import',
661
            'url' => '/main/skills/skills_import.php',
662
            'label' => $this->translator->trans('Skills import'),
663
        ];
664
        $items[] = [
665
            'class' => 'item-skill-list',
666
            'url' => '/main/skills/skill_list.php',
667
            'label' => $this->translator->trans('Manage skills'),
668
        ];
669
        $items[] = [
670
            'class' => 'item-skill-level',
671
            'url' => '/main/skills/skill.php',
672
            'label' => $this->translator->trans('Manage skills levels'),
673
        ];
674
675
        $items[] = [
676
            'class' => 'item-skill-ranking',
677
            'url' => '/main/social/skills_ranking.php',
678
            'label' => $this->translator->trans('Skills ranking'),
679
        ];
680
        $items[] = [
681
            'class' => 'item-skill-gradebook',
682
            'url' => '/main/skills/skills_gradebook.php',
683
            'label' => $this->translator->trans('Skills and assessments'),
684
        ];
685
686
        /*$items[] = [
687
            'url' => '/main/admin/skill_badge.php',
688
            'label' => $this->translator->trans('Badges'),
689
        ];*/
690
691
        return $items;
692
    }
693
694
    private function getItemsGradebook(): array
695
    {
696
        $items = [];
697
        $items[] = [
698
            'class' => 'item-gradebook-list',
699
            'url' => '/main/admin/gradebook_list.php',
700
            'label' => $this->translator->trans('List'),
701
        ];
702
703
        return $items;
704
    }
705
706
    private function getItemsPrivacy(): array
707
    {
708
        $items = [];
709
        $items[] = [
710
            'class' => 'item-privacy-consent',
711
            'url' => '/main/admin/user_list_consent.php',
712
            'label' => $this->translator->trans('User list'),
713
        ];
714
        $items[] = [
715
            'class' => 'item-gdpr-parties',
716
            'route' => ['name' => 'ThirdPartyManager'],
717
            'label' => $this->translator->trans('Third parties (GDPR)'),
718
        ];
719
720
        return $items;
721
    }
722
723
    private function getItemsChamilo(): array
724
    {
725
        $languageInterface = api_get_language_isocode();
726
727
        $items = [];
728
        $items[] = [
729
            'class' => 'item-software-homepage',
730
            'url' => 'https://chamilo.org/',
731
            'label' => $this->translator->trans('Chamilo homepage'),
732
        ];
733
734
        // Custom linking to user guides in the existing languages
735
        /*$guideLinks = [
736
            'french' => 'v/1.11.x-fr/',
737
            'spanish' => 'v/1.11.x-es/',
738
            'dutch' => 'v/1.11.x-nl/',
739
            'galician' => 'v/1.11.x-ga/',
740
        ];*/
741
742
        $guideLink = 'https://docs.chamilo.org/';
743
744
        /*if (!empty($guideLinks[$languageInterface])) {
745
            $guideLink .= $guideLinks[$languageInterface];
746
        }*/
747
748
        $items[] = [
749
            'class' => 'item-user-guides',
750
            'url' => $guideLink,
751
            'label' => $this->translator->trans('User guides'),
752
        ];
753
        $items[] = [
754
            'class' => 'item-forum',
755
            'url' => 'https://github.com/chamilo/chamilo-lms/discussions/',
756
            'label' => $this->translator->trans('Chamilo forum'),
757
        ];
758
        $items[] = [
759
            'class' => 'item-installation-guide',
760
            'url' => '/documentation/installation_guide.html',
761
            'label' => $this->translator->trans('Installation guide'),
762
        ];
763
        $items[] = [
764
            'class' => 'item-changelog',
765
            'url' => '/documentation/changelog.html',
766
            'label' => $this->translator->trans('Changes in last version'),
767
        ];
768
        $items[] = [
769
            'class' => 'item-credits',
770
            'url' => '/documentation/credits.html',
771
            'label' => $this->translator->trans('Contributors list'),
772
        ];
773
        $items[] = [
774
            'class' => 'item-security',
775
            'url' => '/documentation/security.html',
776
            'label' => $this->translator->trans('Security guide'),
777
        ];
778
        $items[] = [
779
            'class' => 'item-optimization',
780
            'url' => '/documentation/optimization.html',
781
            'label' => $this->translator->trans('Optimization guide'),
782
        ];
783
        $items[] = [
784
            'class' => 'item-extensions',
785
            'url' => 'https://chamilo.org/extensions',
786
            'label' => $this->translator->trans('Chamilo extensions'),
787
        ];
788
        $items[] = [
789
            'class' => 'item-providers',
790
            'url' => 'https://chamilo.org/providers',
791
            'label' => $this->translator->trans('Chamilo official services providers'),
792
        ];
793
794
        return $items;
795
    }
796
797
    private function getItemsSessions(): array
798
    {
799
        $items = [];
800
        $items[] = [
801
            'class' => 'item-session-list',
802
            'url' => '/main/session/session_list.php',
803
            'label' => $this->translator->trans('Training sessions list'),
804
        ];
805
        $items[] = [
806
            'class' => 'item-session-add',
807
            'url' => '/main/session/session_add.php',
808
            'label' => $this->translator->trans('Add a training session'),
809
        ];
810
        $items[] = [
811
            'class' => 'item-session-category',
812
            'url' => '/main/session/session_category_list.php',
813
            'label' => $this->translator->trans('Sessions categories list'),
814
        ];
815
        $items[] = [
816
            'class' => 'item-session-import',
817
            'url' => '/main/session/session_import.php',
818
            'label' => $this->translator->trans('Import sessions list'),
819
        ];
820
        $items[] = [
821
            'class' => 'item-session-import-hr',
822
            'url' => '/main/session/session_import_drh.php',
823
            'label' => $this->translator->trans('Import list of HR directors into sessions'),
824
        ];
825
826
        if ($this->isLdapActive) {
827
            $items[] = [
828
                'class' => 'item-session-subscription-ldap-import',
829
                'url' => '/main/admin/ldap_import_students_to_session.php',
830
                'label' => $this->translator->trans('Import LDAP users into a session'),
831
            ];
832
        }
833
834
        $items[] = [
835
            'class' => 'item-session-export',
836
            'url' => '/main/session/session_export.php',
837
            'label' => $this->translator->trans('Export sessions list'),
838
        ];
839
840
        $items[] = [
841
            'class' => 'item-session-course-copy',
842
            'url' => '/main/coursecopy/copy_course_session.php',
843
            'label' => $this->translator->trans('Copy from course in session to another session'),
844
        ];
845
846
        $allowCareer = $this->settingsManager->getSetting('session.allow_session_admin_read_careers');
847
848
        if ($this->isAdmin || ('true' === $allowCareer && $this->isSessionAdmin)) {
849
            // Disabled until it is reemplemented to work with Chamilo 2
850
            /*                $items[] = [
851
                                'class' => 'item-session-user-move-stats',
852
                                'url' => '/main/admin/user_move_stats.php',
853
                                'label' => $this->translator->trans('Move users results from/to a session'),
854
                            ];
855
             */
856
            $items[] = [
857
                'class' => 'item-session-user-move',
858
                'url' => '/main/coursecopy/move_users_from_course_to_session.php',
859
                'label' => $this->translator->trans('Move users results from base course to a session'),
860
            ];
861
862
            $items[] = [
863
                'class' => 'item-career-dashboard',
864
                'url' => '/main/admin/career_dashboard.php',
865
                'label' => $this->translator->trans('Careers and promotions'),
866
            ];
867
            $items[] = [
868
                'class' => 'item-session-field',
869
                'url' => '/main/admin/extra_fields.php?'.http_build_query(['type' => 'session']),
870
                'label' => $this->translator->trans('Manage session fields'),
871
            ];
872
            $items[] = [
873
                'class' => 'item-resource-sequence',
874
                'url' => '/main/admin/resource_sequence.php?'.http_build_query(['type' => SequenceResource::SESSION_TYPE]),
875
                'label' => $this->translator->trans('Resources sequencing'),
876
            ];
877
            $items[] = [
878
                'class' => 'item-export-exercise-results',
879
                'url' => '/main/admin/export_exercise_results.php',
880
                'label' => $this->translator->trans('Export all results from an exercise'),
881
            ];
882
        }
883
884
        return $items;
885
    }
886
887
    private function getItemsPlugins(): array
888
    {
889
        $items = [];
890
891
        $accessUrl = $this->accessUrlHelper->getCurrent();
892
        $appPlugin = new AppPlugin();
893
        $plugins = $this->pluginRepository->getInstalledPlugins();
894
895
        foreach ($plugins as $plugin) {
896
            $pluginInfo = $appPlugin->getPluginInfo($plugin->getTitle());
897
898
            /** @var Plugin $objPlugin */
899
            $objPlugin = $pluginInfo['obj'];
900
            $pluginInUrl = $plugin->getOrCreatePluginConfiguration($accessUrl);
901
            $configuration = $pluginInUrl->getConfiguration();
902
903
            if ($accessUrl->getId() !== $pluginInUrl->getUrl()?->getId()) {
904
                continue;
905
            }
906
907
            if (!\in_array('menu_administrator', $configuration['regions'] ?? [])) {
908
                continue;
909
            }
910
911
            $items[] = [
912
                'class' => 'item-plugin-'.strtolower($plugin->getTitle()),
913
                'url' => $objPlugin->getAdminUrl(),
914
                'label' => $pluginInfo['title'],
915
            ];
916
        }
917
918
        return $items;
919
    }
920
921
    private function getItemsHealthCheck(): array
922
    {
923
        $items = [];
924
925
        // Check if dsn or email is defined :
926
        $mailDsn = $this->settingsManager->getSetting('mail.mailer_dsn', true);
927
        $mailSender = $this->settingsManager->getSetting('mail.mailer_from_email', true);
928
        if ((empty($mailDsn) || 'null://null' == $mailDsn) && empty($mailSender)) {
929
            $items[] = [
930
                'className' => 'item-health-check-mail-settings text-error',
931
                'url' => '/admin/settings/mail',
932
                'label' => $this->translator->trans('E-mail settings need to be configured'),
933
            ];
934
        } else {
935
            $items[] = [
936
                'className' => 'item-health-check-mail-settings text-success',
937
                'url' => '/admin/settings/mail',
938
                'label' => $this->translator->trans('E-mail settings are OK'),
939
            ];
940
        }
941
942
        // Check if the admin user has access to all URLs
943
        if (api_is_admin_in_all_active_urls()) {
944
            $items[] = [
945
                'className' => 'item-health-check-admin-urls text-success',
946
                'url' => '/main/admin/access_urls.php',
947
                'label' => $this->translator->trans('Admin has access to all active URLs'),
948
            ];
949
        } else {
950
            $items[] = [
951
                'className' => 'item-health-check-admin-urls text-error',
952
                'url' => '/main/admin/access_url_edit_users_to_url.php',
953
                'label' => $this->translator->trans('Admin does not have access to all active URLs'),
954
            ];
955
        }
956
957
        return $items;
958
    }
959
}
960