Completed
Push — master ( 17edcb...7372de )
by Torben
06:23
created

Event::setStarttime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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