|
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\EventDemand; |
|
12
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand; |
|
13
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Event; |
|
14
|
|
|
use DERHANSEN\SfEventMgt\Service; |
|
15
|
|
|
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter; |
|
16
|
|
|
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* AdministrationController |
|
20
|
|
|
* |
|
21
|
|
|
* @author Torben Hansen <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class AdministrationController extends AbstractController |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* CustomNotificationLogRepository |
|
27
|
|
|
* |
|
28
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $customNotificationLogRepository = null; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* ExportService |
|
34
|
|
|
* |
|
35
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\ExportService |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $exportService = null; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* SettingsService |
|
41
|
|
|
* |
|
42
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\SettingsService |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $settingsService = null; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Backend User Session Service |
|
48
|
|
|
* |
|
49
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\BeUserSessionService |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $beUserSessionService = null; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* The current page uid |
|
55
|
|
|
* |
|
56
|
|
|
* @var int |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $pid = 0; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* DI for $customNotificationLogRepository |
|
62
|
|
|
* |
|
63
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
|
64
|
|
|
*/ |
|
65
|
|
|
public function injectCustomNotificationLogRepository( |
|
66
|
|
|
\DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
|
67
|
|
|
) { |
|
68
|
|
|
$this->customNotificationLogRepository = $customNotificationLogRepository; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* DI for $exportService |
|
73
|
|
|
* |
|
74
|
|
|
* @param Service\ExportService $exportService |
|
75
|
|
|
*/ |
|
76
|
|
|
public function injectExportService(\DERHANSEN\SfEventMgt\Service\ExportService $exportService) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->exportService = $exportService; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* DI for $settingsService |
|
83
|
|
|
* |
|
84
|
|
|
* @param Service\SettingsService $settingsService |
|
85
|
|
|
*/ |
|
86
|
|
|
public function injectSettingsService(\DERHANSEN\SfEventMgt\Service\SettingsService $settingsService) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->settingsService = $settingsService; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
1 |
|
/** |
|
92
|
|
|
* DI for $beUserSessionService |
|
93
|
1 |
|
* |
|
94
|
1 |
|
* @param Service\BeUserSessionService $beUserSessionService |
|
95
|
|
|
*/ |
|
96
|
|
|
public function injectBeUserSessionService(\DERHANSEN\SfEventMgt\Service\BeUserSessionService $beUserSessionService) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->beUserSessionService = $beUserSessionService; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
2 |
|
/** |
|
102
|
|
|
* Initialize action |
|
103
|
2 |
|
* |
|
104
|
1 |
|
* @return void |
|
105
|
1 |
|
*/ |
|
106
|
2 |
|
public function initializeAction() |
|
107
|
2 |
|
{ |
|
108
|
2 |
|
$this->pid = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id'); |
|
109
|
2 |
|
} |
|
110
|
2 |
|
|
|
111
|
2 |
|
/** |
|
112
|
2 |
|
* Set date format for fields startDate and endDate |
|
113
|
2 |
|
* |
|
114
|
2 |
|
* @return void |
|
115
|
2 |
|
*/ |
|
116
|
2 |
|
public function initializeListAction() |
|
117
|
2 |
|
{ |
|
118
|
2 |
|
if ($this->settings === null) { |
|
119
|
2 |
|
$this->redirect('settingsError'); |
|
120
|
2 |
|
} |
|
121
|
|
|
$this->arguments->getArgument('searchDemand') |
|
122
|
|
|
->getPropertyMappingConfiguration()->forProperty('startDate') |
|
123
|
|
|
->setTypeConverterOption( |
|
124
|
|
|
DateTimeConverter::class, |
|
125
|
|
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
|
126
|
|
|
$this->settings['search']['dateFormat'] |
|
127
|
|
|
); |
|
128
|
|
|
$this->arguments->getArgument('searchDemand') |
|
129
|
|
|
->getPropertyMappingConfiguration()->forProperty('endDate') |
|
130
|
4 |
|
->setTypeConverterOption( |
|
131
|
|
|
DateTimeConverter::class, |
|
132
|
|
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
|
133
|
4 |
|
$this->settings['search']['dateFormat'] |
|
134
|
|
|
); |
|
135
|
4 |
|
} |
|
136
|
3 |
|
|
|
137
|
3 |
|
/** |
|
138
|
4 |
|
* List action for backend module |
|
139
|
|
|
* |
|
140
|
4 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand $searchDemand SearchDemand |
|
141
|
2 |
|
* @param int $messageId MessageID |
|
142
|
2 |
|
* |
|
143
|
|
|
* @return void |
|
144
|
4 |
|
*/ |
|
145
|
1 |
|
public function listAction(SearchDemand $searchDemand = null, $messageId = null) |
|
146
|
1 |
|
{ |
|
147
|
1 |
|
/** @var EventDemand $demand */ |
|
148
|
1 |
|
$demand = $this->objectManager->get(EventDemand::class); |
|
149
|
|
|
|
|
150
|
4 |
|
if ($searchDemand !== null) { |
|
151
|
4 |
|
$searchDemand->setFields($this->settings['search']['fields']); |
|
152
|
4 |
|
|
|
153
|
4 |
|
$sessionData = []; |
|
154
|
|
|
$sessionData['searchDemand'] = $searchDemand; |
|
155
|
|
|
$this->beUserSessionService->saveSessionData($sessionData); |
|
156
|
|
|
} else { |
|
157
|
|
|
// Try to restore search demand from Session |
|
158
|
|
|
$searchDemand = $this->beUserSessionService->getSessionDataByKey('searchDemand'); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
$demand->setSearchDemand($searchDemand); |
|
162
|
1 |
|
|
|
163
|
|
|
if ($this->pid > 0) { |
|
164
|
1 |
|
$demand->setStoragePage($this->pid); |
|
165
|
1 |
|
} |
|
166
|
|
|
|
|
167
|
|
|
$variables = []; |
|
168
|
|
|
if ($messageId !== null && is_numeric($messageId)) { |
|
169
|
|
|
$variables['showMessage'] = true; |
|
170
|
|
|
$variables['messageTitleKey'] = 'administration.message-' . $messageId . '.title'; |
|
171
|
|
|
$variables['messageContentKey'] = 'administration.message-' . $messageId . '.content'; |
|
172
|
|
|
} |
|
173
|
1 |
|
|
|
174
|
|
|
$variables['events'] = $this->eventRepository->findDemanded($demand); |
|
175
|
1 |
|
$variables['searchDemand'] = $searchDemand; |
|
176
|
1 |
|
$variables['csvExportPossible'] = $this->getBackendUser()->getDefaultUploadTemporaryFolder() !== null; |
|
177
|
1 |
|
$this->view->assignMultiple($variables); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Export registrations for a given event |
|
182
|
|
|
* |
|
183
|
|
|
* @param int $eventUid Event UID |
|
184
|
|
|
* |
|
185
|
|
|
* @return bool Always FALSE, since no view should be rendered |
|
186
|
1 |
|
*/ |
|
187
|
|
|
public function exportAction($eventUid) |
|
188
|
1 |
|
{ |
|
189
|
1 |
|
$this->exportService->downloadRegistrationsCsv($eventUid, $this->settings['csvExport']); |
|
190
|
1 |
|
|
|
191
|
1 |
|
return false; |
|
192
|
1 |
|
} |
|
193
|
1 |
|
|
|
194
|
1 |
|
/** |
|
195
|
1 |
|
* Calls the handleExpiredRegistrations Service |
|
196
|
|
|
* |
|
197
|
|
|
* @return void |
|
198
|
|
|
*/ |
|
199
|
|
|
public function handleExpiredRegistrationsAction() |
|
200
|
|
|
{ |
|
201
|
|
|
$this->registrationService->handleExpiredRegistrations($this->settings['registration']['deleteExpiredRegistrations']); |
|
202
|
|
|
$this->redirect('list', 'Administration', 'SfEventMgt', ['demand' => null, 'messageId' => 1]); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
1 |
|
/** |
|
206
|
|
|
* The index notify action |
|
207
|
1 |
|
* |
|
208
|
1 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
|
209
|
1 |
|
* |
|
210
|
1 |
|
* @return void |
|
211
|
1 |
|
*/ |
|
212
|
|
|
public function indexNotifyAction(Event $event) |
|
213
|
1 |
|
{ |
|
214
|
1 |
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
|
215
|
1 |
|
$logEntries = $this->customNotificationLogRepository->findByEvent($event); |
|
|
|
|
|
|
216
|
|
|
$this->view->assignMultiple([ |
|
217
|
|
|
'event' => $event, |
|
218
|
|
|
'customNotifications' => $customNotifications, |
|
219
|
|
|
'logEntries' => $logEntries, |
|
220
|
|
|
]); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* Notify action |
|
225
|
|
|
* |
|
226
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
|
227
|
|
|
* @param string $customNotification CustomNotification |
|
228
|
|
|
* |
|
229
|
|
|
* @return void |
|
230
|
|
|
*/ |
|
231
|
|
|
public function notifyAction(Event $event, $customNotification) |
|
232
|
|
|
{ |
|
233
|
|
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
|
234
|
|
|
$result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings); |
|
235
|
|
|
$this->notificationService->createCustomNotificationLogentry( |
|
236
|
|
|
$event, |
|
237
|
|
|
$customNotifications[$customNotification], |
|
238
|
|
|
$result |
|
239
|
|
|
); |
|
240
|
|
|
$this->redirect('list', 'Administration', 'SfEventMgt', ['demand' => null, 'messageId' => 2]); |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* Shows the settings error view |
|
245
|
|
|
* |
|
246
|
|
|
* @return void |
|
247
|
|
|
*/ |
|
248
|
|
|
public function settingsErrorAction() |
|
249
|
|
|
{ |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* Suppress default validation messages |
|
254
|
|
|
* |
|
255
|
|
|
* @return bool |
|
256
|
|
|
*/ |
|
257
|
|
|
protected function getErrorFlashMessage() |
|
258
|
|
|
{ |
|
259
|
|
|
return false; |
|
|
|
|
|
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
264
|
|
|
*/ |
|
265
|
|
|
protected function getBackendUser() |
|
266
|
|
|
{ |
|
267
|
|
|
return $GLOBALS['BE_USER']; |
|
268
|
|
|
} |
|
269
|
|
|
} |
|
270
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: