Completed
Push — registration_fields ( ba51da )
by Torben
10:23
created

Event::getRegistrationFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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