Skip to content

Commit df92b3f

Browse files
author
Torben Hansen
committed
Merge branch 'development'
2 parents 8c27e8f + 8598b1d commit df92b3f

File tree

59 files changed

+2286
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2286
-71
lines changed

Classes/Controller/EventController.php

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ class EventController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
8383
*/
8484
protected $notificationService = NULL;
8585

86+
/**
87+
* ICalendar Service
88+
*
89+
* @var \DERHANSEN\SfEventMgt\Service\ICalendarService
90+
* @inject
91+
*/
92+
protected $icalendarService = NULL;
93+
8694
/**
8795
* Settings Service
8896
*
@@ -99,6 +107,14 @@ class EventController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
99107
*/
100108
protected $hashService;
101109

110+
/**
111+
* registrationService
112+
*
113+
* @var \DERHANSEN\SfEventMgt\Service\RegistrationService
114+
* @inject
115+
*/
116+
protected $registrationService = NULL;
117+
102118
/**
103119
* Create a demand object with the given settings
104120
*
@@ -147,6 +163,18 @@ public function detailAction(Event $event) {
147163
$this->view->assign('event', $event);
148164
}
149165

166+
/**
167+
* Initiates the iCalendar download for the given event
168+
*
169+
* @param Event $event The event
170+
*
171+
* @return bool
172+
*/
173+
public function icalDownloadAction(Event $event) {
174+
$this->icalendarService->downloadiCalendarFile($event);
175+
return FALSE;
176+
}
177+
150178
/**
151179
* Registration view for an event
152180
*
@@ -182,22 +210,8 @@ public function initializeSaveRegistrationAction() {
182210
*/
183211
public function saveRegistrationAction(Registration $registration, Event $event) {
184212
$autoConfirmation = (bool)$this->settings['registration']['autoConfirmation'];
185-
$success = TRUE;
186213
$result = RegistrationResult::REGISTRATION_SUCCESSFUL;
187-
if ($event->getEnableRegistration() === FALSE) {
188-
$success = FALSE;
189-
$result = RegistrationResult::REGISTRATION_NOT_ENABLED;
190-
} elseif ($event->getRegistrationDeadline() != NULL && $event->getRegistrationDeadline() < new \DateTime()) {
191-
$success = FALSE;
192-
$result = RegistrationResult::REGISTRATION_FAILED_DEADLINE_EXPIRED;
193-
} elseif ($event->getStartdate() < new \DateTime()) {
194-
$success = FALSE;
195-
$result = RegistrationResult::REGISTRATION_FAILED_EVENT_EXPIRED;
196-
} elseif ($event->getRegistration()->count() >= $event->getMaxParticipants()
197-
&& $event->getMaxParticipants() > 0) {
198-
$success = FALSE;
199-
$result = RegistrationResult::REGISTRATION_FAILED_MAX_PARTICIPANTS;
200-
}
214+
$success = $this->checkRegistrationSuccess($event, $registration, $result);
201215

202216
// Save registration if no errors
203217
if ($success) {
@@ -225,6 +239,11 @@ public function saveRegistrationAction(Registration $registration, Event $event)
225239
MessageType::REGISTRATION_NEW);
226240
}
227241

242+
// Create given amount of registrations if necessary
243+
if ($registration->getAmountOfRegistrations() > 1) {
244+
$this->registrationService->createDependingRegistrations($registration);
245+
}
246+
228247
// Clear cache for configured pages
229248
$pidList = $this->settingsService->getClearCacheUids($this->settings);
230249
if (count($pidList) > 0) {
@@ -242,6 +261,41 @@ public function saveRegistrationAction(Registration $registration, Event $event)
242261
}
243262
}
244263

264+
/**
265+
* Checks, if the registration can successfully be created. Note, that
266+
* $result is passed by reference!
267+
*
268+
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event
269+
* @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration
270+
* @param RegistrationResult $result
271+
*
272+
* @return bool
273+
*/
274+
protected function checkRegistrationSuccess($event, $registration, &$result) {
275+
$success = TRUE;
276+
if ($event->getEnableRegistration() === FALSE) {
277+
$success = FALSE;
278+
$result = RegistrationResult::REGISTRATION_NOT_ENABLED;
279+
} elseif ($event->getRegistrationDeadline() != NULL && $event->getRegistrationDeadline() < new \DateTime()) {
280+
$success = FALSE;
281+
$result = RegistrationResult::REGISTRATION_FAILED_DEADLINE_EXPIRED;
282+
} elseif ($event->getStartdate() < new \DateTime()) {
283+
$success = FALSE;
284+
$result = RegistrationResult::REGISTRATION_FAILED_EVENT_EXPIRED;
285+
} elseif ($event->getRegistration()->count() >= $event->getMaxParticipants()
286+
&& $event->getMaxParticipants() > 0) {
287+
$success = FALSE;
288+
$result = RegistrationResult::REGISTRATION_FAILED_MAX_PARTICIPANTS;
289+
} elseif ($event->getFreePlaces() < $registration->getAmountOfRegistrations()) {
290+
$success = FALSE;
291+
$result = RegistrationResult::REGISTRATION_FAILED_NOT_ENOUGH_FREE_PLACES;
292+
} elseif ($event->getMaxRegistrationsPerUser() < $registration->getAmountOfRegistrations()) {
293+
$success = FALSE;
294+
$result = RegistrationResult::REGISTRATION_FAILED_MAX_AMOUNT_REGISTRATIONS_EXCEEDED;
295+
}
296+
return $success;
297+
}
298+
245299
/**
246300
* Shows the result of the saveRegistrationAction
247301
*
@@ -270,6 +324,14 @@ public function saveRegistrationResultAction($result) {
270324
$messageKey = 'event.message.registrationfaileddeadlineexpired';
271325
$titleKey = 'registrationResult.title.failed';
272326
break;
327+
case RegistrationResult::REGISTRATION_FAILED_NOT_ENOUGH_FREE_PLACES:
328+
$messageKey = 'event.message.registrationfailednotenoughfreeplaces';
329+
$titleKey = 'registrationResult.title.failed';
330+
break;
331+
case RegistrationResult::REGISTRATION_FAILED_MAX_AMOUNT_REGISTRATIONS_EXCEEDED:
332+
$messageKey = 'event.message.registrationfailedmaxamountregistrationsexceeded';
333+
$titleKey = 'registrationResult.title.failed';
334+
break;
273335
default:
274336
$messageKey = '';
275337
$titleKey = '';
@@ -329,6 +391,11 @@ public function confirmRegistrationAction($reguid, $hmac) {
329391
MessageType::REGISTRATION_CONFIRMED);
330392
$this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings,
331393
MessageType::REGISTRATION_CONFIRMED);
394+
395+
// Confirm registrations depending on main registration if necessary
396+
if ($registration->getAmountOfRegistrations() > 1) {
397+
$this->registrationService->confirmDependingRegistrations($registration);
398+
}
332399
}
333400
$this->view->assign('messageKey', $messageKey);
334401
$this->view->assign('titleKey', $titleKey);

Classes/Domain/Model/Event.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ class Event extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
7575
*/
7676
protected $maxParticipants = 0;
7777

78+
/**
79+
* Max registrations per user
80+
*
81+
* @var integer
82+
*/
83+
protected $maxRegistrationsPerUser = 1;
84+
7885
/**
7986
* Price
8087
*
@@ -631,4 +638,24 @@ public function setTopEvent($topEvent) {
631638
public function getTopEvent() {
632639
return $this->topEvent;
633640
}
641+
642+
/**
643+
* Returns max regisrations per user
644+
*
645+
* @return int
646+
*/
647+
public function getMaxRegistrationsPerUser() {
648+
return $this->maxRegistrationsPerUser;
649+
}
650+
651+
/**
652+
* Sets max registrations per user
653+
*
654+
* @param int $maxRegistrationsPerUser
655+
* @return void
656+
*/
657+
public function setMaxRegistrationsPerUser($maxRegistrationsPerUser) {
658+
$this->maxRegistrationsPerUser = $maxRegistrationsPerUser;
659+
}
660+
634661
}

Classes/Domain/Model/Location.php

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,27 @@ class Location extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
3838
*/
3939
protected $title = '';
4040

41+
/**
42+
* Description
43+
*
44+
* @var string
45+
*/
46+
protected $description = '';
47+
48+
/**
49+
* Longitude
50+
*
51+
* @var float
52+
*/
53+
protected $longitude = 0.0;
54+
55+
/**
56+
* Latitude
57+
*
58+
* @var float
59+
*/
60+
protected $latitide = 0.0;
61+
4162
/**
4263
* Returns the title
4364
*
@@ -50,11 +71,71 @@ public function getTitle() {
5071
/**
5172
* Sets the title
5273
*
53-
* @param string $title
74+
* @param string $title The title
75+
*
5476
* @return void
5577
*/
5678
public function setTitle($title) {
5779
$this->title = $title;
5880
}
5981

82+
/**
83+
* Returns the description
84+
*
85+
* @return string $description
86+
*/
87+
public function getDescription() {
88+
return $this->description;
89+
}
90+
91+
/**
92+
* Sets the description
93+
*
94+
* @param string $description The description
95+
*
96+
* @return void
97+
*/
98+
public function setDescription($description) {
99+
$this->description = $description;
100+
}
101+
102+
/**
103+
* Returns the longitude
104+
*
105+
* @return float
106+
*/
107+
public function getLongitude() {
108+
return $this->longitude;
109+
}
110+
111+
/**
112+
* Sets the the longitude
113+
*
114+
* @param float $longitude The longitude
115+
*
116+
* @return void
117+
*/
118+
public function setLongitude($longitude) {
119+
$this->longitude = $longitude;
120+
}
121+
122+
/**
123+
* Returns the latitude
124+
*
125+
* @return float
126+
*/
127+
public function getLatitide() {
128+
return $this->latitide;
129+
}
130+
131+
/**
132+
* Sets the latitude
133+
*
134+
* @param float $latitide The latitude
135+
*
136+
* @return void
137+
*/
138+
public function setLatitide($latitide) {
139+
$this->latitide = $latitide;
140+
}
60141
}

0 commit comments

Comments
 (0)