Passed
Push — 7.x ( 2fd8d1...271590 )
by Torben
03:05
created

AdministrationController::getRecursiveLevels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Controller;
13
14
use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification;
15
use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand;
16
use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand;
17
use DERHANSEN\SfEventMgt\Domain\Model\Event;
18
use DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository;
19
use DERHANSEN\SfEventMgt\Event\InitAdministrationModuleTemplateEvent;
20
use DERHANSEN\SfEventMgt\Event\ModifyAdministrationIndexNotifyViewVariablesEvent;
21
use DERHANSEN\SfEventMgt\Event\ModifyAdministrationListViewVariablesEvent;
22
use DERHANSEN\SfEventMgt\Service\BeUserSessionService;
23
use DERHANSEN\SfEventMgt\Service\ExportService;
24
use DERHANSEN\SfEventMgt\Service\MaintenanceService;
25
use DERHANSEN\SfEventMgt\Service\SettingsService;
26
use DERHANSEN\SfEventMgt\Utility\PageUtility;
27
use Psr\Http\Message\ResponseInterface;
28
use TYPO3\CMS\Backend\Routing\UriBuilder;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Routing\UriBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Template\Components\ButtonBar was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
use TYPO3\CMS\Backend\Template\ModuleTemplate;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Template\ModuleTemplate was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Template\ModuleTemplateFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
use TYPO3\CMS\Backend\Utility\BackendUtility;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Utility\BackendUtility was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
34
use TYPO3\CMS\Core\Imaging\Icon;
35
use TYPO3\CMS\Core\Imaging\IconFactory;
36
use TYPO3\CMS\Core\Localization\LanguageService;
37
use TYPO3\CMS\Core\Page\PageRenderer;
38
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
39
use TYPO3\CMS\Core\Utility\GeneralUtility;
40
41
class AdministrationController extends AbstractController
42
{
43
    private const LANG_FILE = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:';
44
45
    protected ModuleTemplateFactory $moduleTemplateFactory;
46
    protected CustomNotificationLogRepository $customNotificationLogRepository;
47
    protected ExportService $exportService;
48
    protected SettingsService $settingsService;
49
    protected BeUserSessionService $beUserSessionService;
50
    protected MaintenanceService $maintenanceService;
51
    protected IconFactory $iconFactory;
52
    protected PageRenderer $pageRenderer;
53
    protected int $pid = 0;
54
55
    public function injectCustomNotificationLogRepository(
56
        CustomNotificationLogRepository $customNotificationLogRepository
57
    ): void {
58
        $this->customNotificationLogRepository = $customNotificationLogRepository;
59
    }
60
61
    public function injectExportService(ExportService $exportService): void
62
    {
63
        $this->exportService = $exportService;
64
    }
65
66
    public function injectSettingsService(SettingsService $settingsService): void
67
    {
68
        $this->settingsService = $settingsService;
69
    }
70
71
    public function injectBeUserSessionService(BeUserSessionService $beUserSessionService): void
72
    {
73
        $this->beUserSessionService = $beUserSessionService;
74
    }
75
76
    public function injectIconFactory(IconFactory $iconFactory): void
77
    {
78
        $this->iconFactory = $iconFactory;
79
    }
80
81
    public function injectMaintenanceService(MaintenanceService $maintenanceService): void
82
    {
83
        $this->maintenanceService = $maintenanceService;
84
    }
85
86
    public function injectModuleTemplateFactory(ModuleTemplateFactory $moduleTemplateFactory): void
87
    {
88
        $this->moduleTemplateFactory = $moduleTemplateFactory;
89
    }
90
91
    public function injectPageRenderer(PageRenderer $pageRenderer): void
92
    {
93
        $this->pageRenderer = $pageRenderer;
94
    }
95
96
    /**
97
     * Register docHeaderButtons
98
     */
99
    protected function registerDocHeaderButtons(ModuleTemplate $moduleTemplate): void
100
    {
101
        $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
102
103
        if ($this->request->getControllerActionName() === 'list') {
104
            $buttons = [
105
                [
106
                    'label' => 'administration.newEvent',
107
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_event'),
108
                    'icon' => 'ext-sfeventmgt-event',
109
                    'group' => 1,
110
                ],
111
                [
112
                    'label' => 'administration.newLocation',
113
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_location'),
114
                    'icon' => 'ext-sfeventmgt-location',
115
                    'group' => 1,
116
                ],
117
                [
118
                    'label' => 'administration.newOrganisator',
119
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_organisator'),
120
                    'icon' => 'ext-sfeventmgt-organisator',
121
                    'group' => 1,
122
                ],
123
                [
124
                    'label' => 'administration.newSpeaker',
125
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_speaker'),
126
                    'icon' => 'ext-sfeventmgt-speaker',
127
                    'group' => 1,
128
                ],
129
                [
130
                    'label' => 'administration.handleExpiredRegistrations',
131
                    'link' => $this->uriBuilder->reset()->setRequest($this->request)
132
                        ->uriFor('handleExpiredRegistrations', [], 'Administration'),
133
                    'icon' => 'ext-sfeventmgt-action-handle-expired',
134
                    'group' => 2,
135
                ],
136
            ];
137
            foreach ($buttons as $tableConfiguration) {
138
                $title = $this->getLanguageService()->sL(self::LANG_FILE . $tableConfiguration['label']);
139
                $icon = $this->iconFactory->getIcon($tableConfiguration['icon'], Icon::SIZE_SMALL);
140
                $viewButton = $buttonBar->makeLinkButton()
141
                    ->setHref($tableConfiguration['link'])
142
                    ->setDataAttributes([
143
                        'toggle' => 'tooltip',
144
                        'placement' => 'bottom',
145
                        'title' => $title,
146
                    ])
147
                    ->setTitle($title)
148
                    ->setIcon($icon);
149
                $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $tableConfiguration['group']);
150
            }
151
        }
152
    }
153
154
    /**
155
     * Returns the create new record URL for the given table
156
     */
157
    private function getCreateNewRecordUri(string $table): string
158
    {
159
        $pid = $this->pid;
160
        $tsConfig = BackendUtility::getPagesTSconfig(0);
161
        if ($pid === 0 && isset($tsConfig['defaultPid.'])
162
            && is_array($tsConfig['defaultPid.'])
163
            && isset($tsConfig['defaultPid.'][$table])
164
        ) {
165
            $pid = (int)$tsConfig['defaultPid.'][$table];
166
        }
167
168
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
169
170
        return (string)$uriBuilder->buildUriFromRoute('record_edit', [
171
            'edit[' . $table . '][' . $pid . ']' => 'new',
172
            'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
173
        ]);
174
    }
175
176
    /**
177
     * Initializes module template and returns a response which must be used as response for any extbase action
178
     * that should render a view.
179
     */
180
    protected function initModuleTemplateAndReturnResponse(string $templateFileName, array $variables = []): ResponseInterface
181
    {
182
        $moduleTemplate = $this->moduleTemplateFactory->create($this->request);
183
        $this->pageRenderer->addCssFile('EXT:sf_event_mgt/Resources/Public/Css/administration.css');
184
185
        $this->pageRenderer->loadJavaScriptModule('@derhansen/sf_event_mgt/administration-module.js');
186
187
        $this->registerDocHeaderButtons($moduleTemplate);
188
189
        $moduleTemplate->setFlashMessageQueue($this->getFlashMessageQueue());
190
191
        $initAdministrationModuleTemplateEvent = new InitAdministrationModuleTemplateEvent(
192
            $moduleTemplate,
193
            $this->uriBuilder,
194
            $this
195
        );
196
        $this->eventDispatcher->dispatch($initAdministrationModuleTemplateEvent);
197
198
        $variables['settings'] = $this->settings;
199
        $moduleTemplate->assignMultiple($variables);
200
201
        return $moduleTemplate->renderResponse($templateFileName);
202
    }
203
204
    public function initializeAction(): void
205
    {
206
        $this->pid = (int)($this->request->getQueryParams()['id'] ?? 0);
207
    }
208
209
    /**
210
     * Set date format for fields startDate and endDate
211
     */
212
    public function initializeListAction(): void
213
    {
214
        // Static format needed for date picker (flatpickr), see BackendController::generateJavascript() and #91606
215
        if (!empty($this->settings)) {
216
            $this->settings['search']['dateFormat'] = 'H:i d-m-Y';
0 ignored issues
show
Bug Best Practice introduced by
The property settings does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
217
        }
218
    }
219
220
    /**
221
     * List action for backend module
222
     */
223
    public function listAction(?SearchDemand $searchDemand = null, array $overwriteDemand = []): ResponseInterface
224
    {
225
        if (empty($this->settings)) {
226
            return $this->redirect('settingsError');
227
        }
228
229
        if ($searchDemand !== null) {
230
            $searchDemand->setFields($this->settings['search']['fields'] ?? 'title');
231
232
            $sessionData = [];
233
            $sessionData['searchDemand'] = $searchDemand->toArray();
234
            $sessionData['overwriteDemand'] = $overwriteDemand;
235
            $this->beUserSessionService->saveSessionData($sessionData);
236
        } else {
237
            // Try to restore search demand from Session
238
            $sessionSearchDemand = $this->beUserSessionService->getSessionDataByKey('searchDemand') ?? [];
239
            $searchDemand = SearchDemand::fromArray($sessionSearchDemand);
240
            $overwriteDemand = $this->beUserSessionService->getSessionDataByKey('overwriteDemand');
241
        }
242
243
        if ($this->isResetFilter()) {
244
            $searchDemand = GeneralUtility::makeInstance(SearchDemand::class);
245
            $overwriteDemand = [];
246
247
            $sessionData = [];
248
            $sessionData['searchDemand'] = $searchDemand->toArray();
249
            $sessionData['overwriteDemand'] = $overwriteDemand;
250
            $this->beUserSessionService->saveSessionData($sessionData);
251
        }
252
253
        // Initialize default ordering when no overwriteDemand is available
254
        if (empty($overwriteDemand)) {
255
            $overwriteDemand = [
256
                'orderField' => $this->settings['defaultSorting']['orderField'] ?? 'title',
257
                'orderDirection' => $this->settings['defaultSorting']['orderDirection'] ?? 'asc',
258
            ];
259
        }
260
261
        $events = [];
262
        $pagination = null;
263
        $pageUids = $this->resolveSearchPageUids((int)($overwriteDemand['recursive'] ?? 0));
264
        if ($pageUids !== '' &&
265
            $this->getBackendUser()->check('tables_select', 'tx_sfeventmgt_domain_model_event')
266
        ) {
267
            $eventDemand = GeneralUtility::makeInstance(EventDemand::class);
268
            $eventDemand = $this->overwriteEventDemandObject($eventDemand, $overwriteDemand);
0 ignored issues
show
Bug introduced by
It seems like $overwriteDemand can also be of type null; however, parameter $overwriteDemand of DERHANSEN\SfEventMgt\Con...riteEventDemandObject() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

268
            $eventDemand = $this->overwriteEventDemandObject($eventDemand, /** @scrutinizer ignore-type */ $overwriteDemand);
Loading history...
269
            $eventDemand->setOrderFieldAllowed($this->settings['orderFieldAllowed'] ?? '');
270
            $eventDemand->setSearchDemand($searchDemand);
271
            $eventDemand->setIgnoreEnableFields(true);
272
            $eventDemand->setStoragePage($pageUids);
273
274
            $events = $this->eventRepository->findDemanded($eventDemand);
275
            $pagination = $this->getPagination($events, $this->settings['pagination'] ?? []);
276
        }
277
278
        $modifyAdministrationListViewVariablesEvent = new ModifyAdministrationListViewVariablesEvent(
279
            [
280
                'pid' => $this->pid,
281
                'events' => $events,
282
                'searchDemand' => $searchDemand,
283
                'orderByFields' => $this->getOrderByFields(),
284
                'orderDirections' => $this->getOrderDirections(),
285
                'recursiveLevels' => $this->getRecursiveLevels(),
286
                'overwriteDemand' => $overwriteDemand,
287
                'pagination' => $pagination,
288
            ],
289
            $this
290
        );
291
        $this->eventDispatcher->dispatch($modifyAdministrationListViewVariablesEvent);
292
        $variables = $modifyAdministrationListViewVariablesEvent->getVariables();
293
294
        return $this->initModuleTemplateAndReturnResponse('Administration/List', $variables);
295
    }
296
297
    /**
298
     * Resolves the page UIDs to search in respecting the given recursive option and additionally checking, if
299
     * the current backend user is allowed to affected pages
300
     */
301
    private function resolveSearchPageUids(int $recursive): string
302
    {
303
        $extendedPageUids = PageUtility::extendPidListByChildren(
304
            (string)$this->pid,
305
            $recursive
306
        );
307
        $extendedPageUids = GeneralUtility::intExplode(',', $extendedPageUids, true);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Core\Utility\G...alUtility::intExplode() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

307
        $extendedPageUids = /** @scrutinizer ignore-deprecated */ GeneralUtility::intExplode(',', $extendedPageUids, true);
Loading history...
308
309
        $pageUids = [];
310
        foreach ($extendedPageUids as $extendedPageUid) {
311
            if (!in_array($extendedPageUid, $pageUids, true) &&
312
                $this->getBackendUser()->isInWebMount($extendedPageUid)
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->getBackendUser()-...Mount($extendedPageUid) of type integer|null is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
313
            ) {
314
                $pageUids[] = $extendedPageUid;
315
            }
316
        }
317
318
        return implode(',', $pageUids);
319
    }
320
321
    /**
322
     * Returns, if reset filter operation has been used
323
     */
324
    private function isResetFilter(): bool
325
    {
326
        $resetFilter = false;
327
        if ($this->request->hasArgument('operation')) {
328
            $resetFilter = $this->request->getArgument('operation') === 'reset-filters';
329
        }
330
331
        return $resetFilter;
332
    }
333
334
    /**
335
     * Export registrations for a given event
336
     */
337
    public function exportAction(int $eventUid): void
338
    {
339
        /** @var Event $event */
340
        $event = $this->eventRepository->findByUidIncludeHidden($eventUid);
341
        if ($event !== null && $this->checkEventAccess($event)) {
342
            $this->exportService->downloadRegistrationsCsv($eventUid, $this->settings['csvExport'] ?? []);
343
        }
344
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
345
    }
346
347
    /**
348
     * Handles expired registrations
349
     */
350
    public function handleExpiredRegistrationsAction(): ResponseInterface
351
    {
352
        $delete = (bool)($this->settings['registration']['deleteExpiredRegistrations'] ?? false);
353
        $this->maintenanceService->handleExpiredRegistrations($delete);
354
355
        $this->addFlashMessage(
356
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.content'),
357
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.title')
358
        );
359
360
        return $this->redirect('list');
361
    }
362
363
    /**
364
     * The index notify action
365
     */
366
    public function indexNotifyAction(Event $event): ResponseInterface
367
    {
368
        if (!$this->checkEventAccess($event)) {
369
            return $this->redirect('list');
370
        }
371
372
        $customNotification = GeneralUtility::makeInstance(CustomNotification::class);
373
        $customNotifications = $this->settingsService->getCustomNotifications($this->settings);
374
        $logEntries = $this->customNotificationLogRepository->findBy(['event' => $event]);
375
376
        $modifyAdministrationIndexNotifyViewVariablesEvent = new ModifyAdministrationIndexNotifyViewVariablesEvent(
377
            [
378
                'event' => $event,
379
                'recipients' => $this->getNotificationRecipients(),
380
                'customNotification' => $customNotification,
381
                'customNotifications' => $customNotifications,
382
                'logEntries' => $logEntries,
383
            ],
384
            $this
385
        );
386
        $this->eventDispatcher->dispatch($modifyAdministrationIndexNotifyViewVariablesEvent);
387
        $variables = $modifyAdministrationIndexNotifyViewVariablesEvent->getVariables();
388
389
        return $this->initModuleTemplateAndReturnResponse('Administration/IndexNotify', $variables);
390
    }
391
392
    /**
393
     * Returns an array of recipient option for the indexNotify action
394
     */
395
    public function getNotificationRecipients(): array
396
    {
397
        return [
398
            [
399
                'value' => CustomNotification::RECIPIENTS_ALL,
400
                'label' => $this->getLanguageService()->sL(
401
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_ALL
402
                ),
403
            ],
404
            [
405
                'value' => CustomNotification::RECIPIENTS_CONFIRMED,
406
                'label' => $this->getLanguageService()->sL(
407
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_CONFIRMED
408
                ),
409
            ],
410
            [
411
                'value' => CustomNotification::RECIPIENTS_UNCONFIRMED,
412
                'label' => $this->getLanguageService()->sL(
413
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_UNCONFIRMED
414
                ),
415
            ],
416
            [
417
                'value' => CustomNotification::RECIPIENTS_WAITLIST_CONFIRMED,
418
                'label' => $this->getLanguageService()->sL(
419
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_WAITLIST_CONFIRMED
420
                ),
421
            ],
422
            [
423
                'value' => CustomNotification::RECIPIENTS_WAITLIST_UNCONFIRMED,
424
                'label' => $this->getLanguageService()->sL(
425
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_WAITLIST_UNCONFIRMED
426
                ),
427
            ],
428
        ];
429
    }
430
431
    /**
432
     * Notify action
433
     */
434
    public function notifyAction(Event $event, CustomNotification $customNotification): ResponseInterface
435
    {
436
        if (!$this->checkEventAccess($event)) {
437
            return $this->redirect('list');
438
        }
439
440
        $customNotifications = $this->settingsService->getCustomNotifications($this->settings);
441
        $result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings);
442
        $this->notificationService->createCustomNotificationLogentry(
443
            $event,
444
            $customNotifications[$customNotification->getTemplate()],
445
            $result,
446
            $customNotification
447
        );
448
        $this->addFlashMessage(
449
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.content'),
450
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.title')
451
        );
452
        return $this->redirect('list');
453
    }
454
455
    /**
456
     * Checks if the current backend user has access to the PID of the event and if not, enqueue an
457
     * access denied flash message
458
     */
459
    public function checkEventAccess(Event $event): bool
460
    {
461
        if ($this->getBackendUser()->isInWebMount($event->getPid()) === null) {
462
            $this->addFlashMessage(
463
                $this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.content'),
464
                $this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.title'),
465
                ContextualFeedbackSeverity::ERROR
466
            );
467
            return false;
468
        }
469
470
        return true;
471
    }
472
473
    /**
474
     * Shows the settings error view
475
     */
476
    public function settingsErrorAction(): ResponseInterface
477
    {
478
        return $this->initModuleTemplateAndReturnResponse('Administration/SettingsError');
479
    }
480
481
    /**
482
     * Suppress default validation messages
483
     */
484
    protected function getErrorFlashMessage(): bool
485
    {
486
        return false;
487
    }
488
489
    /**
490
     * Returns an array with possible order directions
491
     */
492
    public function getOrderDirections(): array
493
    {
494
        return [
495
            'asc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.asc'),
496
            'desc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.desc'),
497
        ];
498
    }
499
500
    /**
501
     * Returns an array with possible recursive levels
502
     */
503
    public function getRecursiveLevels(): array
504
    {
505
        return [
506
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.current'),
507
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level1'),
508
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level2'),
509
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level3'),
510
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level4'),
511
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level5'),
512
        ];
513
    }
514
515
    /**
516
     * Returns an array with possible orderBy fields
517
     */
518
    public function getOrderByFields(): array
519
    {
520
        return [
521
            'title' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.title'),
522
            'startdate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.startdate'),
523
            'enddate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.enddate'),
524
        ];
525
    }
526
527
    protected function getLanguageService(): LanguageService
528
    {
529
        return $GLOBALS['LANG'];
530
    }
531
532
    protected function getBackendUser(): BackendUserAuthentication
533
    {
534
        return $GLOBALS['BE_USER'];
535
    }
536
}
537