1
|
|
|
<?php |
2
|
|
|
namespace DERHANSEN\SfEventMgt\Controller; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the TYPO3 CMS project. |
6
|
|
|
* |
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
9
|
|
|
* of the License, or any later version. |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please read the |
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
13
|
|
|
* |
14
|
|
|
* The TYPO3 project - inspiring people to share! |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter; |
18
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand; |
19
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand; |
20
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Event; |
21
|
|
|
use DERHANSEN\SfEventMgt\Service; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* AdministrationController |
25
|
|
|
* |
26
|
|
|
* @author Torben Hansen <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
class AdministrationController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* EventRepository |
33
|
|
|
* |
34
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Repository\EventRepository |
35
|
|
|
* */ |
36
|
|
|
protected $eventRepository = null; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* CustomNotificationLogRepository |
40
|
|
|
* |
41
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository |
42
|
|
|
*/ |
43
|
|
|
protected $customNotificationLogRepository = null; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* ExportService |
47
|
|
|
* |
48
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\ExportService |
49
|
|
|
*/ |
50
|
|
|
protected $exportService = null; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* RegistrationService |
54
|
|
|
* |
55
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\RegistrationService |
56
|
|
|
*/ |
57
|
|
|
protected $registrationService = null; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* NotificationService |
61
|
|
|
* |
62
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\NotificationService |
63
|
|
|
*/ |
64
|
|
|
protected $notificationService = null; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* SettingsService |
68
|
|
|
* |
69
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\SettingsService |
70
|
|
|
*/ |
71
|
|
|
protected $settingsService = null; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* The current page uid |
75
|
|
|
* |
76
|
|
|
* @var int |
77
|
|
|
*/ |
78
|
|
|
protected $pid = 0; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* DI for $customNotificationLogRepository |
82
|
|
|
* |
83
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
84
|
|
|
*/ |
85
|
|
|
public function injectCustomNotificationLogRepository( |
86
|
|
|
\DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
87
|
|
|
) { |
88
|
|
|
$this->customNotificationLogRepository = $customNotificationLogRepository; |
89
|
|
|
} |
90
|
|
|
|
91
|
1 |
|
/** |
92
|
|
|
* DI for $eventRepository |
93
|
1 |
|
* |
94
|
1 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Repository\EventRepository $eventRepository |
95
|
|
|
*/ |
96
|
|
|
public function injectEventRepository(\DERHANSEN\SfEventMgt\Domain\Repository\EventRepository $eventRepository) |
97
|
|
|
{ |
98
|
|
|
$this->eventRepository = $eventRepository; |
99
|
|
|
} |
100
|
|
|
|
101
|
2 |
|
/** |
102
|
|
|
* DI for $exportService |
103
|
2 |
|
* |
104
|
1 |
|
* @param Service\ExportService $exportService |
105
|
1 |
|
*/ |
106
|
2 |
|
public function injectExportService(\DERHANSEN\SfEventMgt\Service\ExportService $exportService) |
107
|
2 |
|
{ |
108
|
2 |
|
$this->exportService = $exportService; |
109
|
2 |
|
} |
110
|
2 |
|
|
111
|
2 |
|
/** |
112
|
2 |
|
* DI for $notificationService |
113
|
2 |
|
* |
114
|
2 |
|
* @param Service\NotificationService $notificationService |
115
|
2 |
|
*/ |
116
|
2 |
|
public function injectNotificationService(\DERHANSEN\SfEventMgt\Service\NotificationService $notificationService) |
117
|
2 |
|
{ |
118
|
2 |
|
$this->notificationService = $notificationService; |
119
|
2 |
|
} |
120
|
2 |
|
|
121
|
|
|
/** |
122
|
|
|
* DI for $registrationService |
123
|
|
|
* |
124
|
|
|
* @param Service\RegistrationService $registrationService |
125
|
|
|
*/ |
126
|
|
|
public function injectRegistrationService(\DERHANSEN\SfEventMgt\Service\RegistrationService $registrationService) |
127
|
|
|
{ |
128
|
|
|
$this->registrationService = $registrationService; |
129
|
|
|
} |
130
|
4 |
|
|
131
|
|
|
/** |
132
|
|
|
* DI for $settingsService |
133
|
4 |
|
* |
134
|
|
|
* @param Service\SettingsService $settingsService |
135
|
4 |
|
*/ |
136
|
3 |
|
public function injectSettingsService(\DERHANSEN\SfEventMgt\Service\SettingsService $settingsService) |
137
|
3 |
|
{ |
138
|
4 |
|
$this->settingsService = $settingsService; |
139
|
|
|
} |
140
|
4 |
|
|
141
|
2 |
|
/** |
142
|
2 |
|
* Initialize action |
143
|
|
|
* |
144
|
4 |
|
* @return void |
145
|
1 |
|
*/ |
146
|
1 |
|
public function initializeAction() |
147
|
1 |
|
{ |
148
|
1 |
|
$this->pid = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id'); |
149
|
|
|
} |
150
|
4 |
|
|
151
|
4 |
|
/** |
152
|
4 |
|
* Set date format for fields startDate and endDate |
153
|
4 |
|
* |
154
|
|
|
* @return void |
155
|
|
|
*/ |
156
|
|
|
public function initializeListAction() |
157
|
|
|
{ |
158
|
|
|
if ($this->settings === null) { |
159
|
|
|
$this->redirect('settingsError'); |
160
|
|
|
} |
161
|
|
|
$this->arguments->getArgument('searchDemand') |
162
|
1 |
|
->getPropertyMappingConfiguration()->forProperty('startDate') |
163
|
|
|
->setTypeConverterOption( |
164
|
1 |
|
'TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', |
165
|
1 |
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
166
|
|
|
$this->settings['search']['dateFormat'] |
167
|
|
|
); |
168
|
|
|
$this->arguments->getArgument('searchDemand') |
169
|
|
|
->getPropertyMappingConfiguration()->forProperty('endDate') |
170
|
|
|
->setTypeConverterOption( |
171
|
|
|
'TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', |
172
|
|
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
173
|
1 |
|
$this->settings['search']['dateFormat'] |
174
|
|
|
); |
175
|
1 |
|
} |
176
|
1 |
|
|
177
|
1 |
|
/** |
178
|
|
|
* List action for backend module |
179
|
|
|
* |
180
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand $searchDemand SearchDemand |
181
|
|
|
* @param int $messageId MessageID |
182
|
|
|
* |
183
|
|
|
* @return void |
184
|
|
|
*/ |
185
|
|
|
public function listAction(SearchDemand $searchDemand = null, $messageId = null) |
186
|
1 |
|
{ |
187
|
|
|
/** @var EventDemand $demand */ |
188
|
1 |
|
$demand = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Dto\\EventDemand'); |
189
|
1 |
|
|
190
|
1 |
|
if ($searchDemand !== null) { |
191
|
1 |
|
$searchDemand->setFields($this->settings['search']['fields']); |
192
|
1 |
|
} |
193
|
1 |
|
$demand->setSearchDemand($searchDemand); |
|
|
|
|
194
|
1 |
|
|
195
|
1 |
|
if ($this->pid > 0) { |
196
|
|
|
$demand->setStoragePage($this->pid); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
$variables = []; |
200
|
|
|
if ($messageId !== null && is_numeric($messageId)) { |
201
|
|
|
$variables['showMessage'] = true; |
202
|
|
|
$variables['messageTitleKey'] = 'administration.message-' . $messageId . '.title'; |
203
|
|
|
$variables['messageContentKey'] = 'administration.message-' . $messageId . '.content'; |
204
|
|
|
} |
205
|
1 |
|
|
206
|
|
|
$variables['events'] = $this->eventRepository->findDemanded($demand); |
207
|
1 |
|
$variables['searchDemand'] = $searchDemand; |
208
|
1 |
|
$this->view->assignMultiple($variables); |
209
|
1 |
|
} |
210
|
1 |
|
|
211
|
1 |
|
/** |
212
|
|
|
* Export registrations for a given event |
213
|
1 |
|
* |
214
|
1 |
|
* @param int $eventUid Event UID |
215
|
1 |
|
* |
216
|
|
|
* @return bool Always FALSE, since no view should be rendered |
217
|
|
|
*/ |
218
|
|
|
public function exportAction($eventUid) |
219
|
|
|
{ |
220
|
|
|
$this->exportService->downloadRegistrationsCsv($eventUid, $this->settings['csvExport']); |
221
|
|
|
return false; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Calls the handleExpiredRegistrations Service |
226
|
|
|
* |
227
|
|
|
* @return void |
228
|
|
|
*/ |
229
|
|
|
public function handleExpiredRegistrationsAction() |
230
|
|
|
{ |
231
|
|
|
$this->registrationService->handleExpiredRegistrations($this->settings['registration']['deleteExpiredRegistrations']); |
232
|
|
|
$this->redirect('list', 'Administration', 'SfEventMgt', ['demand' => null, 'messageId' => 1]); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* The index notify action |
237
|
|
|
* |
238
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
239
|
|
|
* |
240
|
|
|
* @return void |
241
|
|
|
*/ |
242
|
|
|
public function indexNotifyAction(Event $event) |
243
|
|
|
{ |
244
|
|
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
245
|
|
|
$logEntries = $this->customNotificationLogRepository->findByEvent($event); |
|
|
|
|
246
|
|
|
$this->view->assignMultiple([ |
247
|
|
|
'event' => $event, |
248
|
|
|
'customNotifications' => $customNotifications, |
249
|
|
|
'logEntries' => $logEntries, |
250
|
|
|
]); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Notify action |
255
|
|
|
* |
256
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
257
|
|
|
* @param string $customNotification CustomNotification |
258
|
|
|
* |
259
|
|
|
* @return void |
260
|
|
|
*/ |
261
|
|
|
public function notifyAction(Event $event, $customNotification) |
262
|
|
|
{ |
263
|
|
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
264
|
|
|
$result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings); |
265
|
|
|
$this->notificationService->createCustomNotificationLogentry( |
266
|
|
|
$event, |
267
|
|
|
$customNotifications[$customNotification], |
268
|
|
|
$result |
269
|
|
|
); |
270
|
|
|
$this->redirect('list', 'Administration', 'SfEventMgt', ['demand' => null, 'messageId' => 2]); |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* Shows the settings error view |
275
|
|
|
* |
276
|
|
|
* @return void |
277
|
|
|
*/ |
278
|
|
|
public function settingsErrorAction() |
279
|
|
|
{ |
280
|
|
|
} |
281
|
|
|
} |
282
|
|
|
|
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):