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