Completed
Push — development ( f1f447...342f1e )
by Torben
43:38
created

Event::setEnableAutoconfirm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace DERHANSEN\SfEventMgt\Domain\Model;
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
/**
18
 * Event
19
 *
20
 * @author Torben Hansen <[email protected]>
21
 */
22
class Event extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
23
{
24
25
    /**
26
     * Title
27
     *
28
     * @var string
29
     * @validate NotEmpty
30
     */
31
    protected $title = '';
32
33
    /**
34
     * Teaser
35
     *
36
     * @var string
37
     */
38
    protected $teaser = '';
39
40
    /**
41
     * Description
42
     *
43
     * @var string
44
     */
45
    protected $description = '';
46
47
    /**
48
     * Program/Schedule
49
     *
50
     * @var string
51
     */
52
    protected $program = '';
53
54
    /**
55
     * Startdate and time
56
     *
57
     * @var \DateTime
58
     */
59
    protected $startdate = null;
60
61
    /**
62
     * Enddate and time
63
     *
64
     * @var \DateTime
65
     */
66
    protected $enddate = null;
67
68
    /**
69
     * Max participants
70
     *
71
     * @var int
72
     */
73
    protected $maxParticipants = 0;
74
75
    /**
76
     * Max registrations per user
77
     *
78
     * @var int
79
     */
80
    protected $maxRegistrationsPerUser = 1;
81
82
    /**
83
     * Price
84
     *
85
     * @var float
86
     */
87
    protected $price = 0.0;
88
89
    /**
90
     * Currency
91
     *
92
     * @var string
93
     */
94
    protected $currency = '';
95
96
    /**
97
     * Enable payment
98
     *
99
     * @var bool
100
     */
101
    protected $enablePayment = false;
102
103
    /**
104
     * Restrict payment methods
105
     *
106
     * @var bool
107
     */
108
    protected $restrictPaymentMethods = false;
109
110
    /**
111
     * Selected payment methods
112
     *
113
     * @var string
114
     */
115
    protected $selectedPaymentMethods = '';
116
117
    /**
118
     * Category
119
     *
120
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
121
     * @lazy
122
     */
123
    protected $category = null;
124
125
    /**
126
     * Related
127
     *
128
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Event>
129
     * @lazy
130
     */
131
    protected $related;
132
133
    /**
134
     * Registration
135
     *
136
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration>
137
     * @cascade remove
138
     * @lazy
139
     */
140
    protected $registration = null;
141
142
    /**
143
     * Registration waitlist
144
     *
145
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration>
146
     * @lazy
147
     */
148
    protected $registrationWaitlist;
149
150
    /**
151
     * Registration deadline date
152
     *
153
     * @var \DateTime
154
     */
155
    protected $registrationDeadline = null;
156
157
    /**
158
     * The image
159
     *
160
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
161
     * @lazy
162
     */
163
    protected $image = null;
164
165
    /**
166
     * Additional files
167
     *
168
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
169
     * @lazy
170
     */
171
    protected $files = null;
172
173
    /**
174
     * YouTube Embed code
175
     *
176
     * @var string
177
     */
178
    protected $youtube = '';
179
180
    /**
181
     * The Location
182
     *
183
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Location
184
     */
185
    protected $location = null;
186
187
    /**
188
     * Enable registration
189
     *
190
     * @var bool
191
     */
192
    protected $enableRegistration = false;
193
194
    /**
195
     * Enable waitlist
196
     *
197
     * @var bool
198
     */
199
    protected $enableWaitlist = false;
200
201
    /**
202
     * Link
203
     *
204
     * @var string
205
     */
206
    protected $link;
207
208
    /**
209
     * Top event
210
     *
211
     * @var bool
212
     */
213
    protected $topEvent = false;
214
215
    /**
216
     * The additionalImage
217
     *
218
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
219
     * @lazy
220
     */
221
    protected $additionalImage = null;
222
223
    /**
224
     * The organisator
225
     *
226
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Organisator
227
     */
228
    protected $organisator = null;
229
230
    /**
231
     * Notify admin
232
     *
233
     * @var bool
234
     */
235
    protected $notifyAdmin = true;
236
237
    /**
238
     * Notify organisator
239
     *
240
     * @var bool
241
     */
242
    protected $notifyOrganisator = false;
243
244
    /**
245
     * Enable cancel of registration
246
     *
247
     * @var bool
248
     */
249
    protected $enableCancel = false;
250
251
    /**
252
     * Deadline for cancel
253
     *
254
     * @var \DateTime
255
     */
256
    protected $cancelDeadline = null;
257
258
    /**
259
     * Enable auto confirmation
260
     *
261
     * @var bool
262
     */
263
    protected $enableAutoconfirm = false;
264
265
    /**
266
     * Unique e-mail check
267
     *
268
     * @var bool
269
     */
270
    protected $uniqueEmailCheck = false;
271
272
    /**
273
     * Price options
274
     *
275
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\PriceOption>
276
     * @cascade remove
277 181
     * @lazy
278
     */
279 181
    protected $priceOptions = null;
280 181
281 181
    /**
282 181
     * Constructor
283 181
     */
284 181
    public function __construct()
285 181
    {
286 181
        $this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
287 181
        $this->related = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
288
        $this->registration = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
289
        $this->registrationWaitlist = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
290
        $this->image = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
291
        $this->files = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
292
        $this->additionalImage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
293
        $this->priceOptions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
294 9
    }
295
296 9
    /**
297
     * Returns the title
298
     *
299
     * @return string $title
300
     */
301
    public function getTitle()
302
    {
303
        return $this->title;
304
    }
305
306 1
    /**
307
     * Sets the title
308 1
     *
309 1
     * @param string $title Title
310
     *
311
     * @return void
312
     */
313
    public function setTitle($title)
314
    {
315
        $this->title = $title;
316 1
    }
317
318 1
    /**
319
     * Returns the teaser
320
     *
321
     * @return string
322
     */
323
    public function getTeaser()
324
    {
325
        return $this->teaser;
326
    }
327
328 1
    /**
329
     * Sets the teaser
330 1
     *
331 1
     * @param string $teaser Teaser
332
     *
333
     * @return void
334
     */
335
    public function setTeaser($teaser)
336
    {
337
        $this->teaser = $teaser;
338 1
    }
339
340 1
    /**
341
     * Returns the description
342
     *
343
     * @return string $description
344
     */
345
    public function getDescription()
346
    {
347
        return $this->description;
348
    }
349
350 1
    /**
351
     * Sets the description
352 1
     *
353 1
     * @param string $description Description
354
     *
355
     * @return void
356
     */
357
    public function setDescription($description)
358
    {
359
        $this->description = $description;
360 1
    }
361
362 1
    /**
363
     * Returns the program
364
     *
365
     * @return string $program
366
     */
367
    public function getProgram()
368
    {
369
        return $this->program;
370
    }
371
372 1
    /**
373
     * Sets the program
374 1
     *
375 1
     * @param string $program The program
376
     *
377
     * @return void
378
     */
379
    public function setProgram($program)
380
    {
381
        $this->program = $program;
382 11
    }
383
384 11
    /**
385
     * Returns the startdate
386
     *
387
     * @return \DateTime $startdate
388
     */
389
    public function getStartdate()
390
    {
391
        return $this->startdate;
392
    }
393
394 11
    /**
395
     * Sets the startdate
396 11
     *
397 11
     * @param \DateTime $startdate Startdate
398
     *
399
     * @return void
400
     */
401
    public function setStartdate(\DateTime $startdate)
402
    {
403
        $this->startdate = $startdate;
404 1
    }
405
406 1
    /**
407
     * Returns the enddate
408
     *
409
     * @return \DateTime $enddate
410
     */
411
    public function getEnddate()
412
    {
413
        return $this->enddate;
414
    }
415
416 1
    /**
417
     * Sets the enddate
418 1
     *
419 1
     * @param \DateTime $enddate Enddate
420
     *
421
     * @return void
422
     */
423
    public function setEnddate(\DateTime $enddate)
424
    {
425
        $this->enddate = $enddate;
426 14
    }
427
428 14
    /**
429
     * Returns the participants
430
     *
431
     * @return int $participants
432
     */
433
    public function getMaxParticipants()
434
    {
435
        return $this->maxParticipants;
436
    }
437
438 13
    /**
439
     * Sets the participants
440 13
     *
441 13
     * @param int $participants Participants
442
     *
443
     * @return void
444
     */
445
    public function setMaxParticipants($participants)
446
    {
447
        $this->maxParticipants = $participants;
448 1
    }
449
450 1
    /**
451
     * Returns the price
452
     *
453
     * @return float $price
454
     */
455
    public function getPrice()
456
    {
457
        return $this->price;
458
    }
459
460 3
    /**
461
     * Sets the price
462 3
     *
463 3
     * @param float $price Price
464
     *
465
     * @return void
466
     */
467
    public function setPrice($price)
468
    {
469
        $this->price = $price;
470 1
    }
471
472 1
    /**
473
     * Returns the currency
474
     *
475
     * @return string $currency
476
     */
477
    public function getCurrency()
478
    {
479
        return $this->currency;
480
    }
481
482 1
    /**
483
     * Sets the currency
484 1
     *
485 1
     * @param string $currency Currency
486
     *
487
     * @return void
488
     */
489
    public function setCurrency($currency)
490
    {
491
        $this->currency = $currency;
492 4
    }
493
494 4
    /**
495
     * Returns if payment is enabled
496
     *
497
     * @return boolean
498
     */
499
    public function getEnablePayment()
500
    {
501
        return $this->enablePayment;
502
    }
503 3
504
    /**
505 3
     * Sets enablePayment
506 3
     *
507
     * @param boolean $enablePayment
508
     * @return void
509
     */
510
    public function setEnablePayment($enablePayment)
511
    {
512
        $this->enablePayment = $enablePayment;
513 3
    }
514
515 3
    /**
516
     * Returns if payment methods should be restricted
517
     *
518
     * @return boolean
519
     */
520
    public function getRestrictPaymentMethods()
521
    {
522
        return $this->restrictPaymentMethods;
523
    }
524 1
525
    /**
526 1
     * Sets if payment methods should be restricted
527 1
     *
528
     * @param boolean $restrictPaymentMethods
529
     * @return void
530
     */
531
    public function setRestrictPaymentMethods($restrictPaymentMethods)
532
    {
533
        $this->restrictPaymentMethods = $restrictPaymentMethods;
534 2
    }
535
536 2
    /**
537
     * Returns selected payment methods
538
     *
539
     * @return string
540
     */
541
    public function getSelectedPaymentMethods()
542
    {
543
        return $this->selectedPaymentMethods;
544
    }
545 1
546
    /**
547 1
     * Sets selected payment methods
548 1
     *
549
     * @param string $selectedPaymentMethods
550
     * @return void
551
     */
552
    public function setSelectedPaymentMethods($selectedPaymentMethods)
553
    {
554
        $this->selectedPaymentMethods = $selectedPaymentMethods;
555
    }
556
557 1
    /**
558
     * Adds a Category
559 1
     *
560 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\Category $category Category
561
     *
562
     * @return void
563
     */
564
    public function addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
565
    {
566
        $this->category->attach($category);
567
    }
568
569 1
    /**
570
     * Removes a Category
571 1
     *
572 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove The Category to be removed
573
     *
574
     * @return void
575
     */
576
    public function removeCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove)
577
    {
578
        $this->category->detach($categoryToRemove);
579 1
    }
580
581 1
    /**
582
     * Returns the category
583
     *
584
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
585
     */
586
    public function getCategory()
587
    {
588
        return $this->category;
589
    }
590
591 3
    /**
592
     * Sets the category
593 3
     *
594 3
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category Category
595
     *
596
     * @return void
597
     */
598
    public function setCategory(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $category)
599
    {
600
        $this->category = $category;
601 2
    }
602
603 2
    /**
604
     * Returns related events
605
     *
606
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
607
     */
608
    public function getRelated()
609
    {
610
        return $this->related;
611
    }
612 3
613
    /**
614 3
     * Sets related events
615 3
     *
616
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $related
617
     * @return void
618
     */
619
    public function setRelated($related)
620
    {
621
        $this->related = $related;
622
    }
623 1
624
    /**
625 1
     * Adds a related event
626 1
     *
627
     * @param Event $event
628
     * @return void
629
     */
630
    public function addRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event)
631
    {
632
        $this->related->attach($event);
633
    }
634 1
635
    /**
636 1
     * Removes a related event
637 1
     *
638
     * @param Event $event
639
     * @return void
640
     */
641
    public function removeRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event)
642
    {
643
        $this->related->detach($event);
644
    }
645
646 2
    /**
647
     * Adds a Registration
648 2
     *
649 2
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
650
     *
651
     * @return void
652
     */
653
    public function addRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration)
654
    {
655
        $this->registration->attach($registration);
656
    }
657
658 1
    /**
659
     * Removes a Registration
660 1
     *
661 1
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration
662
     *
663
     * @return void
664
     */
665
    public function removeRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove)
666
    {
667
        $this->registration->detach($registrationToRemove);
668 12
    }
669
670 12
    /**
671
     * Returns the Registration
672
     *
673
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration
674
     */
675
    public function getRegistration()
676
    {
677
        return $this->registration;
678
    }
679
680 9
    /**
681
     * Sets the Registration
682 9
     *
683 9
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration
684
     *
685
     * @return void
686
     */
687
    public function setRegistration(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration)
688
    {
689
        $this->registration = $registration;
690
    }
691
692 1
    /**
693
     * Adds an image
694 1
     *
695 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image Image
696
     *
697
     * @return void
698
     */
699
    public function addImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image)
700
    {
701
        $this->image->attach($image);
702
    }
703
704 1
    /**
705
     * Removes an image
706 1
     *
707 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove Image
708
     *
709
     * @return void
710
     */
711
    public function removeImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove)
712
    {
713
        $this->image->detach($imageToRemove);
714 1
    }
715
716 1
    /**
717
     * Returns the image
718
     *
719
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image
720
     */
721
    public function getImage()
722
    {
723
        return $this->image;
724
    }
725
726 3
    /**
727
     * Sets the image
728 3
     *
729 3
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image Image
730
     *
731
     * @return void
732
     */
733
    public function setImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $image)
734
    {
735
        $this->image = $image;
736
    }
737
738 2
    /**
739
     * Adds a file
740 2
     *
741 2
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file File
742
     *
743
     * @return void
744
     */
745
    public function addFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $file)
746
    {
747
        $this->files->attach($file);
748
    }
749
750 1
    /**
751
     * Removes a file
752 1
     *
753 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove File
754
     *
755
     * @return void
756
     */
757
    public function removeFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove)
758
    {
759
        $this->files->detach($fileToRemove);
760 1
    }
761
762 1
    /**
763
     * Returns the files
764
     *
765
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files
766
     */
767
    public function getFiles()
768
    {
769
        return $this->files;
770
    }
771
772 3
    /**
773
     * Sets the files
774 3
     *
775 3
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files Files
776
     *
777
     * @return void
778
     */
779
    public function setFiles(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $files)
780
    {
781
        $this->files = $files;
782 2
    }
783
784 2
    /**
785
     * Returns YouTube embed code
786
     *
787
     * @return string
788
     */
789
    public function getYoutube()
790
    {
791
        return $this->youtube;
792
    }
793
794 1
    /**
795
     * Sets YouTube embed code
796 1
     *
797 1
     * @param string $youtube Youtube
798
     *
799
     * @return void
800
     */
801
    public function setYoutube($youtube)
802
    {
803
        $this->youtube = $youtube;
804 10
    }
805
806 10
    /**
807 10
     * Returns if the registration for this event is logically possible
808 3
     *
809 3
     * @return bool
810 10
     */
811 10
    public function getRegistrationPossible()
812 1
    {
813 1
        $maxParticipantsNotReached = true;
814 10
        if ($this->getMaxParticipants() > 0 && $this->getRegistration()->count() >= $this->maxParticipants) {
815 10
            $maxParticipantsNotReached = false;
816 10
        }
817
        $deadlineNotReached = true;
818
        if ($this->getRegistrationDeadline() != null && $this->getRegistrationDeadline() <= new \DateTime()) {
819
            $deadlineNotReached = false;
820
        }
821
        return ($this->getStartdate() > new \DateTime()) &&
822
        ($maxParticipantsNotReached || !$maxParticipantsNotReached && $this->enableWaitlist) &&
823
        $this->getEnableRegistration() && $deadlineNotReached;
824 5
    }
825
826 5
    /**
827
     * Returns the amount of free places
828
     *
829
     * @return int
830
     */
831
    public function getFreePlaces()
832
    {
833
        return $this->maxParticipants - $this->getRegistration()->count();
834
    }
835
836 1
    /**
837
     * Sets the location
838 1
     *
839 1
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location
840
     *
841
     * @return void
842
     */
843
    public function setLocation($location)
844
    {
845
        $this->location = $location;
846 1
    }
847
848 1
    /**
849
     * Returns the location
850
     *
851
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Location
852
     */
853
    public function getLocation()
854
    {
855
        return $this->location;
856
    }
857
858 10
    /**
859
     * Sets enableRegistration
860 10
     *
861 10
     * @param bool $enableRegistration EnableRegistration
862
     *
863
     * @return void
864
     */
865
    public function setEnableRegistration($enableRegistration)
866
    {
867
        $this->enableRegistration = $enableRegistration;
868 8
    }
869
870 8
    /**
871
     * Returns if registration is enabled
872
     *
873
     * @return bool
874
     */
875
    public function getEnableRegistration()
876
    {
877
        return $this->enableRegistration;
878 4
    }
879
880 4
    /**
881
     * Returns enableWaitlist
882
     *
883
     * @return boolean
884
     */
885
    public function getEnableWaitlist()
886
    {
887
        return $this->enableWaitlist;
888
    }
889 5
890
    /**
891 5
     * Sets enableWaitlist
892 5
     *
893
     * @param boolean $enableWaitlist
894
     * @return void
895
     */
896
    public function setEnableWaitlist($enableWaitlist)
897
    {
898
        $this->enableWaitlist = $enableWaitlist;
899
    }
900
901 3
    /**
902
     * Sets the registration deadline
903 3
     *
904 3
     * @param \DateTime $registrationDeadline RegistrationDeadline
905
     *
906
     * @return void
907
     */
908
    public function setRegistrationDeadline(\DateTime $registrationDeadline)
909
    {
910
        $this->registrationDeadline = $registrationDeadline;
911 11
    }
912
913 11
    /**
914
     * Returns the registration deadline
915
     *
916
     * @return \DateTime
917
     */
918
    public function getRegistrationDeadline()
919
    {
920
        return $this->registrationDeadline;
921
    }
922
923 12
    /**
924
     * Sets the link
925 12
     *
926 12
     * @param string $link Link
927
     *
928
     * @return void
929
     */
930
    public function setLink($link)
931
    {
932
        $this->link = $link;
933 1
    }
934
935 1
    /**
936
     * Returns the link
937
     *
938
     * @return string
939
     */
940
    public function getLink()
941
    {
942
        return $this->link;
943 1
    }
944
945 1
    /**
946
     * Returns the uri of the link
947
     *
948
     * @return string
949
     */
950
    public function getLinkUrl()
951
    {
952
        return $this->getLinkPart(0);
953 1
    }
954
955 1
    /**
956
     * Returns the target of the link
957
     *
958
     * @return string
959
     */
960
    public function getLinkTarget()
961
    {
962
        return $this->getLinkPart(1);
963 1
    }
964
965 1
    /**
966
     * Returns the title of the link
967
     *
968
     * @return string
969
     */
970
    public function getLinkTitle()
971
    {
972
        return $this->getLinkPart(3);
973
    }
974
975
    /**
976
     * Splits link to an array respection that a title with more than one word is
977 11
     * surrounded by quotation marks. Returns part of the link for usage in fluid
978
     * viewhelpers.
979 11
     *
980 11
     * @param int $part The part
981 11
     *
982 11
     * @return string
983 11
     */
984 11
    public function getLinkPart($part)
985 1
    {
986 1
        $linkArray = str_getcsv($this->link, ' ', '"');
987 11
        $ret = '';
988
        if (count($linkArray) >= $part) {
989
            $ret = $linkArray[$part];
990
        }
991
        if ($ret === '-') {
992
            $ret = '';
993
        }
994
        return $ret;
995
    }
996
997 1
    /**
998
     * Sets topEvent
999 1
     *
1000 1
     * @param bool $topEvent TopEvent
1001
     *
1002
     * @return void
1003
     */
1004
    public function setTopEvent($topEvent)
1005
    {
1006
        $this->topEvent = $topEvent;
1007 1
    }
1008
1009 1
    /**
1010
     * Returns if topEvent is checked
1011
     *
1012
     * @return bool
1013
     */
1014
    public function getTopEvent()
1015
    {
1016
        return $this->topEvent;
1017 2
    }
1018
1019 2
    /**
1020
     * Returns max regisrations per user
1021
     *
1022
     * @return int
1023
     */
1024
    public function getMaxRegistrationsPerUser()
1025
    {
1026
        return $this->maxRegistrationsPerUser;
1027
    }
1028
1029 1
    /**
1030
     * Sets max registrations per user
1031 1
     *
1032 1
     * @param int $maxRegistrationsPerUser MaxRegistrationsPerUser
1033
     *
1034
     * @return void
1035
     */
1036
    public function setMaxRegistrationsPerUser($maxRegistrationsPerUser)
1037
    {
1038
        $this->maxRegistrationsPerUser = $maxRegistrationsPerUser;
1039
    }
1040
1041
1042 1
    /**
1043
     * Adds an additionalImage
1044 1
     *
1045 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage The Image
1046
     *
1047
     * @return void
1048
     */
1049
    public function addAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage)
1050
    {
1051
        $this->additionalImage->attach($additionalImage);
1052
    }
1053
1054 1
    /**
1055
     * Removes an additionalImage
1056 1
     *
1057 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove The Image
1058
     *
1059
     * @return void
1060
     */
1061
    public function removeAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove)
1062
    {
1063
        $this->additionalImage->detach($additionalImageToRemove);
1064 1
    }
1065
1066 1
    /**
1067
     * Returns the additionalImage
1068
     *
1069
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage
1070
     */
1071
    public function getAdditionalImage()
1072
    {
1073
        return $this->additionalImage;
1074
    }
1075
1076 3
    /**
1077
     * Sets the additionalImage
1078 3
     *
1079 3
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage The Image
1080
     *
1081
     * @return void
1082
     */
1083
    public function setAdditionalImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage)
1084
    {
1085
        $this->additionalImage = $additionalImage;
1086 6
    }
1087
1088 6
    /**
1089
     * Returns the organisator
1090
     *
1091
     * @return Organisator
1092
     */
1093
    public function getOrganisator()
1094
    {
1095
        return $this->organisator;
1096
    }
1097
1098 6
    /**
1099
     * Sets the organisator
1100 6
     *
1101 6
     * @param Organisator $organisator The organisator
1102
     *
1103
     * @return void
1104
     */
1105
    public function setOrganisator($organisator)
1106
    {
1107
        $this->organisator = $organisator;
1108 27
    }
1109
1110 27
    /**
1111
     * Returns notifyAdmin
1112
     *
1113
     * @return bool
1114
     */
1115
    public function getNotifyAdmin()
1116
    {
1117
        return $this->notifyAdmin;
1118
    }
1119
1120 11
    /**
1121
     * Sets notifyAdmin
1122 11
     *
1123 11
     * @param bool $notifyAdmin NotifyAdmin
1124
     *
1125
     * @return void
1126
     */
1127
    public function setNotifyAdmin($notifyAdmin)
1128
    {
1129
        $this->notifyAdmin = $notifyAdmin;
1130 27
    }
1131
1132 27
    /**
1133
     * Returns if notifyAdmin is set
1134
     *
1135
     * @return bool
1136
     */
1137
    public function getNotifyOrganisator()
1138
    {
1139
        return $this->notifyOrganisator;
1140
    }
1141
1142 11
    /**
1143
     * Sets notifyOrganisator
1144 11
     *
1145 11
     * @param bool $notifyOrganisator NotifyOrganisator
1146
     *
1147
     * @return void
1148
     */
1149
    public function setNotifyOrganisator($notifyOrganisator)
1150
    {
1151
        $this->notifyOrganisator = $notifyOrganisator;
1152
    }
1153
1154 4
    /**
1155
     * Sets enableCancel
1156 4
     *
1157 4
     * @param bool $enableCancel EnableCancel
1158
     *
1159
     * @return void
1160
     */
1161
    public function setEnableCancel($enableCancel)
1162
    {
1163
        $this->enableCancel = $enableCancel;
1164 5
    }
1165
1166 5
    /**
1167
     * Returns if registration can be canceled
1168
     *
1169
     * @return bool
1170
     */
1171
    public function getEnableCancel()
1172
    {
1173
        return $this->enableCancel;
1174
    }
1175
1176 4
    /**
1177
     * Sets the cancel deadline
1178 4
     *
1179 4
     * @param \DateTime $cancelDeadline CancelDeadline
1180
     *
1181
     * @return void
1182
     */
1183
    public function setCancelDeadline(\DateTime $cancelDeadline)
1184
    {
1185
        $this->cancelDeadline = $cancelDeadline;
1186 4
    }
1187
1188 4
    /**
1189
     * Returns the cancel deadline
1190
     *
1191
     * @return \DateTime
1192
     */
1193
    public function getCancelDeadline()
1194
    {
1195
        return $this->cancelDeadline;
1196 2
    }
1197
1198 2
    /**
1199
     * Returns if autoconfirmation is enabled
1200
     *
1201
     * @return bool
1202
     */
1203
    public function getEnableAutoconfirm()
1204
    {
1205
        return $this->enableAutoconfirm;
1206
    }
1207 1
1208
    /**
1209 1
     * Sets enable autoconfirm
1210 1
     *
1211
     * @param bool $enableAutoconfirm
1212
     * @return void
1213
     */
1214
    public function setEnableAutoconfirm($enableAutoconfirm)
1215
    {
1216
        $this->enableAutoconfirm = $enableAutoconfirm;
1217 5
    }
1218
1219 5
    /**
1220
     * Returns uniqueEmailCheck
1221
     *
1222
     * @return boolean
1223
     */
1224
    public function getUniqueEmailCheck()
1225
    {
1226
        return $this->uniqueEmailCheck;
1227
    }
1228 3
1229
    /**
1230 3
     * Sets UniqueEmailCheck
1231 3
     *
1232
     * @param boolean $uniqueEmailCheck
1233
     * @return void
1234
     */
1235
    public function setUniqueEmailCheck($uniqueEmailCheck)
1236
    {
1237
        $this->uniqueEmailCheck = $uniqueEmailCheck;
1238
    }
1239
1240 3
    /**
1241
     * Returns price options
1242 3
     *
1243 3
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1244
     */
1245
    public function getPriceOptions()
1246
    {
1247
        return $this->priceOptions;
1248
    }
1249
1250
    /**
1251
     * Sets price options
1252 1
     *
1253
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $priceOptions
1254 1
     * @return void
1255 1
     */
1256
    public function setPriceOptions($priceOptions)
1257
    {
1258
        $this->priceOptions = $priceOptions;
1259
    }
1260
1261
    /**
1262 3
     * Adds a price option
1263
     *
1264 3
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1265 3
     *
1266 3
     * @return void
1267 3
     */
1268 2
    public function addPriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1269 2
    {
1270 2
        $this->priceOptions->attach($priceOption);
1271 3
    }
1272 3
1273 3
    /**
1274 3
     * Removes a Registration
1275
     *
1276
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1277
     *
1278
     * @return void
1279
     */
1280
    public function removePriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1281
    {
1282 2
        $this->priceOptions->detach($priceOption);
1283
    }
1284 2
1285 2
    /**
1286
     * Returns all active price options sorted by date ASC
1287 1
     *
1288
     * @return array
1289
     */
1290 1
    public function getActivePriceOptions()
1291
    {
1292
        $activePriceOptions = [];
1293
        if ($this->getPriceOptions()) {
1294
            $compareDate = new \DateTime('today midnight');
1295
            foreach ($this->getPriceOptions() as $priceOption) {
1296
                if ($priceOption->getValidUntil() >= $compareDate) {
1297
                    $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption;
1298
                }
1299 1
            }
1300
        }
1301 1
        ksort($activePriceOptions);
1302
        return $activePriceOptions;
1303
    }
1304
1305
    /**
1306
     * Returns the current price of the event respecting possible price options
1307
     *
1308
     * @return float
1309
     */
1310
    public function getCurrentPrice()
1311 3
    {
1312
        $activePriceOptions = $this->getActivePriceOptions();
1313 3
        if (count($activePriceOptions) >= 1) {
1314 3
            // Sort active price options and return first element
1315
            return reset($activePriceOptions)->getPrice();
1316
        } else {
1317
            // Just return the price field
1318
            return $this->price;
1319
        }
1320
    }
1321
1322
    /**
1323 1
     * Returns registrationWaitlist
1324
     *
1325 1
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1326 1
     */
1327
    public function getRegistrationWaitlist()
1328
    {
1329
        return $this->registrationWaitlist;
1330
    }
1331
1332
    /**
1333
     * Sets registrationWaitlist
1334
     *
1335 1
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration
1336
     *
1337 1
     * @return void
1338 1
     */
1339
    public function setRegistrationWaitlist(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration)
1340
    {
1341
        $this->registrationWaitlist = $registration;
1342
    }
1343
1344
    /**
1345 3
     * Adds a Registration to the waitlist
1346
     *
1347 3
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
1348
     *
1349
     * @return void
1350
     */
1351
    public function addRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration)
1352
    {
1353
        $this->registrationWaitlist->attach($registration);
1354
    }
1355
1356
    /**
1357
     * Removes a Registration from the waitlist
1358
     *
1359
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration
1360
     *
1361
     * @return void
1362
     */
1363
    public function removeRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove)
1364
    {
1365
        $this->registrationWaitlist->detach($registrationToRemove);
1366
    }
1367
1368
    /**
1369
     * Returns, if cancellation for registrations of the event is possible
1370
     *
1371
     * @return bool
1372
     */
1373
    public function getCancellationPossible()
1374
    {
1375
        return $this->getEnableCancel() && $this->getCancelDeadline() > new \DateTime();
1376
    }
1377
}
1378