Completed
Push — master ( 12b212...412c33 )
by Torben
03:45
created

Event::setTstamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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