|
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
|
|
|
* @inject |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $eventRepository = null; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* CustomNotificationLogRepository |
|
41
|
|
|
* |
|
42
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository |
|
43
|
|
|
* @inject |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $customNotificationLogRepository = null; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* ExportService |
|
49
|
|
|
* |
|
50
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\ExportService |
|
51
|
|
|
* @inject |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $exportService = null; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* RegistrationService |
|
57
|
|
|
* |
|
58
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\RegistrationService |
|
59
|
|
|
* @inject |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $registrationService = null; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* NotificationService |
|
65
|
|
|
* |
|
66
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\NotificationService |
|
67
|
|
|
* @inject |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $notificationService = null; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* SettingsService |
|
73
|
|
|
* |
|
74
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\SettingsService |
|
75
|
|
|
* @inject |
|
76
|
|
|
*/ |
|
77
|
|
|
protected $settingsService = null; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* The current page uid |
|
81
|
|
|
* |
|
82
|
|
|
* @var int |
|
83
|
|
|
*/ |
|
84
|
|
|
protected $pid = 0; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Initialize action |
|
88
|
|
|
* |
|
89
|
|
|
* @return void |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function initializeAction() |
|
92
|
|
|
{ |
|
93
|
1 |
|
$this->pid = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id'); |
|
94
|
1 |
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Set date format for fields startDate and endDate |
|
98
|
|
|
* |
|
99
|
|
|
* @return void |
|
100
|
|
|
*/ |
|
101
|
2 |
|
public function initializeListAction() |
|
102
|
|
|
{ |
|
103
|
2 |
|
if ($this->settings === null) { |
|
104
|
1 |
|
$this->redirect('settingsError'); |
|
105
|
1 |
|
} |
|
106
|
2 |
|
$this->arguments->getArgument('searchDemand') |
|
107
|
2 |
|
->getPropertyMappingConfiguration()->forProperty('startDate') |
|
108
|
2 |
|
->setTypeConverterOption( |
|
109
|
2 |
|
'TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', |
|
110
|
2 |
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
|
111
|
2 |
|
$this->settings['search']['dateFormat'] |
|
112
|
2 |
|
); |
|
113
|
2 |
|
$this->arguments->getArgument('searchDemand') |
|
114
|
2 |
|
->getPropertyMappingConfiguration()->forProperty('endDate') |
|
115
|
2 |
|
->setTypeConverterOption( |
|
116
|
2 |
|
'TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', |
|
117
|
2 |
|
DateTimeConverter::CONFIGURATION_DATE_FORMAT, |
|
118
|
2 |
|
$this->settings['search']['dateFormat'] |
|
119
|
2 |
|
); |
|
120
|
2 |
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* List action for backend module |
|
124
|
|
|
* |
|
125
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand $searchDemand SearchDemand |
|
126
|
|
|
* @param int $messageId MessageID |
|
127
|
|
|
* |
|
128
|
|
|
* @return void |
|
129
|
|
|
*/ |
|
130
|
4 |
|
public function listAction(SearchDemand $searchDemand = null, $messageId = null) |
|
131
|
|
|
{ |
|
132
|
|
|
/** @var EventDemand $demand */ |
|
133
|
4 |
|
$demand = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Dto\\EventDemand'); |
|
134
|
|
|
|
|
135
|
4 |
|
if ($searchDemand !== null) { |
|
136
|
3 |
|
$searchDemand->setFields($this->settings['search']['fields']); |
|
137
|
3 |
|
} |
|
138
|
4 |
|
$demand->setSearchDemand($searchDemand); |
|
139
|
|
|
|
|
140
|
4 |
|
if ($this->pid > 0) { |
|
141
|
2 |
|
$demand->setStoragePage($this->pid); |
|
142
|
2 |
|
} |
|
143
|
|
|
|
|
144
|
4 |
|
if ($messageId !== null && is_numeric($messageId)) { |
|
145
|
1 |
|
$this->view->assign('showMessage', true); |
|
146
|
1 |
|
$this->view->assign('messageTitleKey', 'administration.message-' . $messageId . '.title'); |
|
147
|
1 |
|
$this->view->assign('messageContentKey', 'administration.message-' . $messageId . '.content'); |
|
148
|
1 |
|
} |
|
149
|
|
|
|
|
150
|
4 |
|
$events = $this->eventRepository->findDemanded($demand); |
|
151
|
4 |
|
$this->view->assign('events', $events); |
|
152
|
4 |
|
$this->view->assign('searchDemand', $searchDemand); |
|
153
|
4 |
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Export registrations for a given event |
|
157
|
|
|
* |
|
158
|
|
|
* @param int $eventUid Event UID |
|
159
|
|
|
* |
|
160
|
|
|
* @return bool Always FALSE, since no view should be rendered |
|
161
|
|
|
*/ |
|
162
|
1 |
|
public function exportAction($eventUid) |
|
163
|
|
|
{ |
|
164
|
1 |
|
$this->exportService->downloadRegistrationsCsv($eventUid, $this->settings['csvExport']); |
|
165
|
1 |
|
return false; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Calls the handleExpiredRegistrations Service |
|
170
|
|
|
* |
|
171
|
|
|
* @return void |
|
172
|
|
|
*/ |
|
173
|
1 |
|
public function handleExpiredRegistrationsAction() |
|
174
|
|
|
{ |
|
175
|
1 |
|
$this->registrationService->handleExpiredRegistrations($this->settings['registration']['deleteExpiredRegistrations']); |
|
176
|
1 |
|
$this->redirect('list', 'Administration', 'SfEventMgt', ['demand' => null, 'messageId' => 1]); |
|
177
|
1 |
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* The index notify action |
|
181
|
|
|
* |
|
182
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
|
183
|
|
|
* |
|
184
|
|
|
* @return void |
|
185
|
|
|
*/ |
|
186
|
1 |
|
public function indexNotifyAction(Event $event) |
|
187
|
|
|
{ |
|
188
|
1 |
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
|
189
|
1 |
|
$logEntries = $this->customNotificationLogRepository->findByEvent($event); |
|
190
|
1 |
|
$this->view->assignMultiple([ |
|
191
|
1 |
|
'event' => $event, |
|
192
|
1 |
|
'customNotifications' => $customNotifications, |
|
193
|
1 |
|
'logEntries' => $logEntries, |
|
194
|
1 |
|
]); |
|
195
|
1 |
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Notify action |
|
199
|
|
|
* |
|
200
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
|
201
|
|
|
* @param string $customNotification CustomNotification |
|
202
|
|
|
* |
|
203
|
|
|
* @return void |
|
204
|
|
|
*/ |
|
205
|
1 |
|
public function notifyAction(Event $event, $customNotification) |
|
206
|
|
|
{ |
|
207
|
1 |
|
$customNotifications = $this->settingsService->getCustomNotifications($this->settings); |
|
208
|
1 |
|
$result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings); |
|
209
|
1 |
|
$this->notificationService->createCustomNotificationLogentry( |
|
210
|
1 |
|
$event, |
|
211
|
1 |
|
$customNotifications[$customNotification], |
|
212
|
|
|
$result |
|
213
|
1 |
|
); |
|
214
|
1 |
|
$this->redirect('list', 'Administration', 'SfEventMgt', ['demand' => null, 'messageId' => 2]); |
|
215
|
1 |
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Shows the settings error view |
|
219
|
|
|
* |
|
220
|
|
|
* @return void |
|
221
|
|
|
*/ |
|
222
|
|
|
public function settingsErrorAction() |
|
223
|
|
|
{ |
|
224
|
|
|
} |
|
225
|
|
|
} |
|
226
|
|
|
|