1
|
|
|
<?php |
2
|
|
|
namespace DERHANSEN\SfEventMgt\Controller; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please read the |
8
|
|
|
* LICENSE.txt file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification; |
12
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand; |
13
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand; |
14
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Event; |
15
|
|
|
use DERHANSEN\SfEventMgt\Service; |
16
|
|
|
use DERHANSEN\SfEventMgt\Utility\MiscUtility; |
17
|
|
|
use TYPO3\CMS\Backend\Template\Components\ButtonBar; |
18
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
19
|
|
|
use TYPO3\CMS\Backend\View\BackendTemplateView; |
20
|
|
|
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; |
21
|
|
|
use TYPO3\CMS\Core\FormProtection\FormProtectionFactory; |
22
|
|
|
use TYPO3\CMS\Core\Imaging\Icon; |
23
|
|
|
use TYPO3\CMS\Core\Imaging\IconFactory; |
24
|
|
|
use TYPO3\CMS\Core\Messaging\FlashMessage; |
25
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
26
|
|
|
use TYPO3\CMS\Core\Utility\HttpUtility; |
27
|
|
|
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; |
28
|
|
|
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; |
29
|
|
|
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter; |
30
|
|
|
use TYPO3\CMS\Lang\LanguageService; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* AdministrationController |
34
|
|
|
* |
35
|
|
|
* Several parts are heavily inspired by ext:news from Georg Ringer |
36
|
|
|
* |
37
|
|
|
* @author Torben Hansen <[email protected]> |
38
|
|
|
*/ |
39
|
|
|
class AdministrationController extends AbstractController |
40
|
|
|
{ |
41
|
|
|
const LANG_FILE = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:'; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Backend Template Container |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* CustomNotificationLogRepository |
52
|
|
|
* |
53
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository |
54
|
|
|
*/ |
55
|
|
|
protected $customNotificationLogRepository = null; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* ExportService |
59
|
|
|
* |
60
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\ExportService |
61
|
|
|
*/ |
62
|
|
|
protected $exportService = null; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* SettingsService |
66
|
|
|
* |
67
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\SettingsService |
68
|
|
|
*/ |
69
|
|
|
protected $settingsService = null; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Backend User Session Service |
73
|
|
|
* |
74
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\BeUserSessionService |
75
|
|
|
*/ |
76
|
|
|
protected $beUserSessionService = null; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\MaintenanceService |
80
|
|
|
*/ |
81
|
|
|
protected $maintenanceService = null; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* The current page uid |
85
|
|
|
* |
86
|
|
|
* @var int |
87
|
|
|
*/ |
88
|
|
|
protected $pid = 0; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* BackendTemplateContainer |
92
|
|
|
* |
93
|
|
|
* @var BackendTemplateView |
94
|
|
|
*/ |
95
|
|
|
protected $view; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @var IconFactory |
99
|
|
|
*/ |
100
|
|
|
protected $iconFactory = null; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* DI for $customNotificationLogRepository |
104
|
|
|
* |
105
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
106
|
|
|
*/ |
107
|
|
|
public function injectCustomNotificationLogRepository( |
108
|
|
|
\DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
109
|
|
|
) { |
110
|
|
|
$this->customNotificationLogRepository = $customNotificationLogRepository; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* DI for $exportService |
115
|
|
|
* |
116
|
|
|
* @param Service\ExportService $exportService |
117
|
|
|
*/ |
118
|
|
|
public function injectExportService(\DERHANSEN\SfEventMgt\Service\ExportService $exportService) |
119
|
|
|
{ |
120
|
|
|
$this->exportService = $exportService; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* DI for $settingsService |
125
|
|
|
* |
126
|
|
|
* @param Service\SettingsService $settingsService |
127
|
|
|
*/ |
128
|
|
|
public function injectSettingsService(\DERHANSEN\SfEventMgt\Service\SettingsService $settingsService) |
129
|
|
|
{ |
130
|
|
|
$this->settingsService = $settingsService; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* DI for $beUserSessionService |
135
|
|
|
* |
136
|
|
|
* @param Service\BeUserSessionService $beUserSessionService |
137
|
|
|
*/ |
138
|
|
|
public function injectBeUserSessionService(\DERHANSEN\SfEventMgt\Service\BeUserSessionService $beUserSessionService) |
139
|
|
|
{ |
140
|
|
|
$this->beUserSessionService = $beUserSessionService; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* DI for $iconFactory |
145
|
|
|
* |
146
|
|
|
* @param IconFactory $iconFactory |
147
|
|
|
*/ |
148
|
|
|
public function injectIconFactory(IconFactory $iconFactory) |
149
|
|
|
{ |
150
|
|
|
$this->iconFactory = $iconFactory; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param Service\MaintenanceService $maintenanceService |
155
|
|
|
*/ |
156
|
|
|
public function injectMaintenanceService(\DERHANSEN\SfEventMgt\Service\MaintenanceService $maintenanceService) |
157
|
|
|
{ |
158
|
|
|
$this->maintenanceService = $maintenanceService; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Set up the doc header properly here |
163
|
|
|
* |
164
|
|
|
* @param ViewInterface $view |
165
|
|
|
* |
166
|
|
|
* @return void |
167
|
|
|
*/ |
168
|
|
|
protected function initializeView(ViewInterface $view) |
169
|
|
|
{ |
170
|
|
|
/** @var BackendTemplateView $view */ |
171
|
|
|
parent::initializeView($view); |
172
|
|
|
if ($this->actionMethodName === 'listAction' |
173
|
|
|
|| $this->actionMethodName === 'indexNotifyAction' |
174
|
|
|
|| $this->actionMethodName === 'settingsErrorAction' |
175
|
|
|
) { |
176
|
|
|
$this->registerDocHeaderButtons(); |
177
|
|
|
|
178
|
|
|
$pageRenderer = $this->view->getModuleTemplate()->getPageRenderer(); |
179
|
|
|
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker'); |
180
|
|
|
|
181
|
|
|
$dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? |
182
|
|
|
['MM-DD-YYYY', 'HH:mm MM-DD-YYYY'] : |
183
|
|
|
['DD-MM-YYYY', 'HH:mm DD-MM-YYYY']; |
184
|
|
|
$pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat); |
185
|
|
|
|
186
|
|
|
$this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); |
187
|
|
|
if ($view instanceof BackendTemplateView) { |
188
|
|
|
$view->getModuleTemplate()->getPageRenderer()->addCssFile( |
189
|
|
|
'EXT:sf_event_mgt/Resources/Public/Css/administration.css' |
190
|
|
|
); |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Register docHeaderButtons |
197
|
|
|
* |
198
|
|
|
* @return void |
199
|
|
|
*/ |
200
|
|
|
protected function registerDocHeaderButtons() |
201
|
|
|
{ |
202
|
|
|
$buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); |
203
|
|
|
|
204
|
|
|
$uriBuilder = $this->objectManager->get(UriBuilder::class); |
205
|
|
|
$uriBuilder->setRequest($this->request); |
206
|
|
|
|
207
|
|
|
if ($this->request->getControllerActionName() === 'list') { |
208
|
|
|
$buttons = [ |
209
|
|
|
[ |
210
|
|
|
'label' => 'administration.newEvent', |
211
|
|
|
'action' => 'newEvent', |
212
|
|
|
'icon' => 'ext-sfeventmgt-event', |
213
|
|
|
'group' => 1 |
214
|
|
|
], |
215
|
|
|
[ |
216
|
|
|
'label' => 'administration.newLocation', |
217
|
|
|
'action' => 'newLocation', |
218
|
|
|
'icon' => 'ext-sfeventmgt-location', |
219
|
|
|
'group' => 1 |
220
|
|
|
], |
221
|
|
|
[ |
222
|
|
|
'label' => 'administration.newOrganisator', |
223
|
|
|
'action' => 'newOrganisator', |
224
|
|
|
'icon' => 'ext-sfeventmgt-organisator', |
225
|
|
|
'group' => 1 |
226
|
|
|
], |
227
|
|
|
[ |
228
|
|
|
'label' => 'administration.newSpeaker', |
229
|
|
|
'action' => 'newSpeaker', |
230
|
|
|
'icon' => 'ext-sfeventmgt-speaker', |
231
|
|
|
'group' => 1 |
232
|
|
|
], |
233
|
|
|
[ |
234
|
|
|
'label' => 'administration.handleExpiredRegistrations', |
235
|
|
|
'action' => 'handleExpiredRegistrations', |
236
|
|
|
'icon' => 'ext-sfeventmgt-action-handle-expired', |
237
|
|
|
'group' => 2 |
238
|
|
|
] |
239
|
|
|
]; |
240
|
|
|
foreach ($buttons as $key => $tableConfiguration) { |
241
|
|
|
$title = $this->getLanguageService()->sL(self::LANG_FILE . $tableConfiguration['label']); |
242
|
|
|
$link = $uriBuilder->reset()->setRequest($this->request) |
243
|
|
|
->uriFor($tableConfiguration['action'], [], 'Administration'); |
244
|
|
|
$icon = $this->iconFactory->getIcon($tableConfiguration['icon'], Icon::SIZE_SMALL); |
245
|
|
|
$viewButton = $buttonBar->makeLinkButton() |
246
|
|
|
->setHref($link) |
247
|
|
|
->setDataAttributes([ |
248
|
|
|
'toggle' => 'tooltip', |
249
|
|
|
'placement' => 'bottom', |
250
|
|
|
'title' => $title |
251
|
|
|
]) |
252
|
|
|
->setTitle($title) |
253
|
|
|
->setIcon($icon); |
254
|
|
|
$buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $tableConfiguration['group']); |
255
|
|
|
} |
256
|
|
|
} |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* Redirect to tceform creating a new record |
261
|
|
|
* |
262
|
|
|
* @param string $table table name |
263
|
|
|
* @return void |
264
|
|
|
*/ |
265
|
|
|
private function redirectToCreateNewRecord($table) |
266
|
|
|
{ |
267
|
|
|
$pid = $this->pid; |
268
|
|
|
$tsConfig = BackendUtility::getPagesTSconfig(0); |
269
|
|
|
if ($pid === 0 && isset($tsConfig['defaultPid.']) |
270
|
|
|
&& is_array($tsConfig['defaultPid.']) |
271
|
|
|
&& isset($tsConfig['defaultPid.'][$table]) |
272
|
|
|
) { |
273
|
|
|
$pid = (int)$tsConfig['defaultPid.'][$table]; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
if (MiscUtility::isV9Lts()) { |
277
|
|
|
$returnUrl = 'index.php?route=/web/SfEventMgtTxSfeventmgtM1/'; |
278
|
|
|
} else { |
279
|
|
|
$returnUrl = 'index.php?M=web_SfEventMgtTxSfeventmgtM1'; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
$returnUrl .= '&id=' . $this->pid . $this->getToken(); |
283
|
|
|
$url = BackendUtility::getModuleUrl('record_edit', [ |
|
|
|
|
284
|
|
|
'edit[' . $table . '][' . $pid . ']' => 'new', |
285
|
|
|
'returnUrl' => $returnUrl |
286
|
|
|
]); |
287
|
|
|
|
288
|
|
|
HttpUtility::redirect($url); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Initialize action |
293
|
|
|
* |
294
|
|
|
* @return void |
295
|
|
|
*/ |
296
|
|
|
public function initializeAction() |
297
|
|
|
{ |
298
|
|
|
$this->pid = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id'); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* Set date format for fields startDate and endDate |
303
|
|
|
* |
304
|
|
|
* @return void |
305
|
|
|
*/ |
306
|
|
|
public function initializeListAction() |
307
|
|
|
{ |
308
|
|
|
if ($this->settings === null || empty($this->settings)) { |
309
|
|
|
$this->redirect('settingsError'); |
310
|
|
|
} |
311
|
|
|
$this->arguments->getArgument('searchDemand') |
312
|
|
|
->getPropertyMappingConfiguration()->forProperty('startDate') |
313
|
|
|
->setTypeConverterOption( |
314
|
|
|
DateTimeConverter::class, |
315
|
|
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
316
|
|
|
$this->settings['search']['dateFormat'] |
317
|
|
|
); |
318
|
|
|
$this->arguments->getArgument('searchDemand') |
319
|
|
|
->getPropertyMappingConfiguration()->forProperty('endDate') |
320
|
|
|
->setTypeConverterOption( |
321
|
|
|
DateTimeConverter::class, |
322
|
|
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
323
|
|
|
$this->settings['search']['dateFormat'] |
324
|
|
|
); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* List action for backend module |
329
|
|
|
* |
330
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand $searchDemand SearchDemand |
331
|
|
|
* @param array $overwriteDemand OverwriteDemand |
332
|
|
|
* |
333
|
|
|
* @return void |
334
|
|
|
*/ |
335
|
|
|
public function listAction(SearchDemand $searchDemand = null, array $overwriteDemand = []) |
336
|
|
|
{ |
337
|
|
|
/** @var EventDemand $eventDemand */ |
338
|
|
|
$eventDemand = $this->objectManager->get(EventDemand::class); |
339
|
|
|
$eventDemand = $this->overwriteEventDemandObject($eventDemand, $overwriteDemand); |
340
|
|
|
$eventDemand->setOrderFieldAllowed($this->settings['orderFieldAllowed']); |
341
|
|
|
|
342
|
|
|
if ($searchDemand !== null) { |
343
|
|
|
$searchDemand->setFields($this->settings['search']['fields']); |
344
|
|
|
|
345
|
|
|
$sessionData = []; |
346
|
|
|
$sessionData['searchDemand'] = $searchDemand; |
347
|
|
|
$sessionData['overwriteDemand'] = $overwriteDemand; |
348
|
|
|
$this->beUserSessionService->saveSessionData($sessionData); |
349
|
|
|
} else { |
350
|
|
|
// Try to restore search demand from Session |
351
|
|
|
$searchDemand = $this->beUserSessionService->getSessionDataByKey('searchDemand'); |
352
|
|
|
$overwriteDemand = $this->beUserSessionService->getSessionDataByKey('overwriteDemand'); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
$eventDemand->setSearchDemand($searchDemand); |
356
|
|
|
$eventDemand->setStoragePage($this->pid); |
357
|
|
|
|
358
|
|
|
$events = []; |
359
|
|
|
if ($this->getBackendUser()->isInWebMount($this->pid)) { |
|
|
|
|
360
|
|
|
$events = $this->eventRepository->findDemanded($eventDemand); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
$this->view->assignMultiple([ |
364
|
|
|
'pid' => $this->pid, |
365
|
|
|
'events' => $events, |
366
|
|
|
'searchDemand' => $searchDemand, |
367
|
|
|
'orderByFields' => $this->getOrderByFields(), |
368
|
|
|
'orderDirections' => $this->getOrderDirections(), |
369
|
|
|
'overwriteDemand' => $overwriteDemand, |
370
|
|
|
]); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* Export registrations for a given event |
375
|
|
|
* |
376
|
|
|
* @param int $eventUid Event UID |
377
|
|
|
* |
378
|
|
|
* @return void |
379
|
|
|
*/ |
380
|
|
|
public function exportAction($eventUid) |
381
|
|
|
{ |
382
|
|
|
/** @var Event $event */ |
383
|
|
|
$event = $this->eventRepository->findByUid($eventUid); |
384
|
|
|
if ($event) { |
385
|
|
|
$this->checkEventAccess($event); |
386
|
|
|
$this->exportService->downloadRegistrationsCsv($eventUid, $this->settings['csvExport']); |
387
|
|
|
} |
388
|
|
|
exit(); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* Handles expired registrations |
393
|
|
|
* |
394
|
|
|
* @return void |
395
|
|
|
*/ |
396
|
|
|
public function handleExpiredRegistrationsAction() |
397
|
|
|
{ |
398
|
|
|
$delete = (bool)$this->settings['registration']['deleteExpiredRegistrations']; |
399
|
|
|
$this->maintenanceService->handleExpiredRegistrations($delete); |
400
|
|
|
|
401
|
|
|
$this->addFlashMessage( |
402
|
|
|
$this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.content'), |
403
|
|
|
$this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.title'), |
404
|
|
|
FlashMessage::OK |
405
|
|
|
); |
406
|
|
|
|
407
|
|
|
$this->redirect('list'); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* The index notify action |
412
|
|
|
* |
413
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
414
|
|
|
* |
415
|
|
|
* @return void |
416
|
|
|
*/ |
417
|
|
|
public function indexNotifyAction(Event $event) |
418
|
|
|
{ |
419
|
|
|
$this->checkEventAccess($event); |
420
|
|
|
$customNotification = GeneralUtility::makeInstance(CustomNotification::class); |
421
|
|
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
422
|
|
|
$logEntries = $this->customNotificationLogRepository->findByEvent($event); |
|
|
|
|
423
|
|
|
$this->view->assignMultiple([ |
424
|
|
|
'event' => $event, |
425
|
|
|
'recipients' => $this->getNotificationRecipients(), |
426
|
|
|
'customNotification' => $customNotification, |
427
|
|
|
'customNotifications' => $customNotifications, |
428
|
|
|
'logEntries' => $logEntries, |
429
|
|
|
]); |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* Returns an array of recipient option for the indexNotify action |
434
|
|
|
* |
435
|
|
|
* @return array|array[] |
436
|
|
|
*/ |
437
|
|
|
public function getNotificationRecipients(): array |
438
|
|
|
{ |
439
|
|
|
return [ |
440
|
|
|
[ |
441
|
|
|
'value' => CustomNotification::RECIPIENTS_ALL, |
442
|
|
|
'label' => $this->getLanguageService()->sL( |
443
|
|
|
self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_ALL |
444
|
|
|
) |
445
|
|
|
], |
446
|
|
|
[ |
447
|
|
|
'value' => CustomNotification::RECIPIENTS_CONFIRMED, |
448
|
|
|
'label' => $this->getLanguageService()->sL( |
449
|
|
|
self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_CONFIRMED |
450
|
|
|
) |
451
|
|
|
], |
452
|
|
|
[ |
453
|
|
|
'value' => CustomNotification::RECIPIENTS_UNCONFIRMED, |
454
|
|
|
'label' => $this->getLanguageService()->sL( |
455
|
|
|
self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_UNCONFIRMED |
456
|
|
|
) |
457
|
|
|
], |
458
|
|
|
]; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* Create new event action |
463
|
|
|
*/ |
464
|
|
|
public function newEventAction() |
465
|
|
|
{ |
466
|
|
|
$this->redirectToCreateNewRecord('tx_sfeventmgt_domain_model_event'); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* Create new location action |
471
|
|
|
*/ |
472
|
|
|
public function newLocationAction() |
473
|
|
|
{ |
474
|
|
|
$this->redirectToCreateNewRecord('tx_sfeventmgt_domain_model_location'); |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Create new organisator action |
479
|
|
|
*/ |
480
|
|
|
public function newOrganisatorAction() |
481
|
|
|
{ |
482
|
|
|
$this->redirectToCreateNewRecord('tx_sfeventmgt_domain_model_organisator'); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* Create new speaker action |
487
|
|
|
*/ |
488
|
|
|
public function newSpeakerAction() |
489
|
|
|
{ |
490
|
|
|
$this->redirectToCreateNewRecord('tx_sfeventmgt_domain_model_speaker'); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Notify action |
495
|
|
|
* |
496
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
497
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification $customNotification |
498
|
|
|
* |
499
|
|
|
* @return void |
500
|
|
|
*/ |
501
|
|
|
public function notifyAction(Event $event, CustomNotification $customNotification) |
502
|
|
|
{ |
503
|
|
|
$this->checkEventAccess($event); |
504
|
|
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
505
|
|
|
$result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings); |
506
|
|
|
$this->notificationService->createCustomNotificationLogentry( |
507
|
|
|
$event, |
508
|
|
|
$customNotifications[$customNotification->getTemplate()], |
509
|
|
|
$result |
510
|
|
|
); |
511
|
|
|
$this->addFlashMessage( |
512
|
|
|
$this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.content'), |
513
|
|
|
$this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.title'), |
514
|
|
|
FlashMessage::OK |
515
|
|
|
); |
516
|
|
|
$this->redirect('list'); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
520
|
|
|
* Checks if the current backend user has access to the PID of the event and if not, enqueue an |
521
|
|
|
* access denied flash message and redirect to list view |
522
|
|
|
* |
523
|
|
|
* @param Event $event |
524
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
525
|
|
|
*/ |
526
|
|
|
public function checkEventAccess(Event $event) |
527
|
|
|
{ |
528
|
|
|
if ($this->getBackendUser()->isInWebMount($event->getPid()) === null) { |
529
|
|
|
$this->addFlashMessage( |
530
|
|
|
$this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.content'), |
531
|
|
|
$this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.title'), |
532
|
|
|
FlashMessage::ERROR |
533
|
|
|
); |
534
|
|
|
|
535
|
|
|
$this->redirect('list'); |
536
|
|
|
} |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* Shows the settings error view |
541
|
|
|
* |
542
|
|
|
* @return void |
543
|
|
|
*/ |
544
|
|
|
public function settingsErrorAction() |
545
|
|
|
{ |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Suppress default validation messages |
550
|
|
|
* |
551
|
|
|
* @return bool |
552
|
|
|
*/ |
553
|
|
|
protected function getErrorFlashMessage() |
554
|
|
|
{ |
555
|
|
|
return false; |
|
|
|
|
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Get a CSRF token |
560
|
|
|
* |
561
|
|
|
* @param bool $tokenOnly Set it to TRUE to get only the token, otherwise including the &moduleToken= as prefix |
562
|
|
|
* @return string |
563
|
|
|
*/ |
564
|
|
|
protected function getToken(bool $tokenOnly = false): string |
565
|
|
|
{ |
566
|
|
|
if (MiscUtility::isV9Lts()) { |
567
|
|
|
$tokenParameterName = 'token'; |
568
|
|
|
$token = FormProtectionFactory::get('backend')->generateToken('route', 'web_SfEventMgtTxSfeventmgtM1'); |
569
|
|
|
} else { |
570
|
|
|
$tokenParameterName = 'moduleToken'; |
571
|
|
|
$token = FormProtectionFactory::get()->generateToken('moduleCall', 'web_SfEventMgtTxSfeventmgtM1'); |
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
if ($tokenOnly) { |
575
|
|
|
return $token; |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
return '&' . $tokenParameterName . '=' . $token; |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
/** |
582
|
|
|
* Returns the LanguageService |
583
|
|
|
* |
584
|
|
|
* @return LanguageService |
585
|
|
|
*/ |
586
|
|
|
protected function getLanguageService(): LanguageService |
587
|
|
|
{ |
588
|
|
|
return $GLOBALS['LANG']; |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
/** |
592
|
|
|
* Returns an array with possible order directions |
593
|
|
|
* |
594
|
|
|
* @return array |
595
|
|
|
*/ |
596
|
|
|
public function getOrderDirections() |
597
|
|
|
{ |
598
|
|
|
return [ |
599
|
|
|
'asc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.asc'), |
600
|
|
|
'desc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.desc') |
601
|
|
|
]; |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
/** |
605
|
|
|
* Returns an array with possible orderBy fields |
606
|
|
|
* |
607
|
|
|
* @return array |
608
|
|
|
*/ |
609
|
|
|
public function getOrderByFields() |
610
|
|
|
{ |
611
|
|
|
return [ |
612
|
|
|
'title' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.title'), |
613
|
|
|
'startdate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.startdate'), |
614
|
|
|
'enddate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.enddate') |
615
|
|
|
]; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* Returns the Backend User |
620
|
|
|
* @return BackendUserAuthentication |
621
|
|
|
*/ |
622
|
|
|
protected function getBackendUser(): BackendUserAuthentication |
623
|
|
|
{ |
624
|
|
|
return $GLOBALS['BE_USER']; |
625
|
|
|
} |
626
|
|
|
} |
627
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.