|
1
|
|
|
<?php |
|
2
|
|
|
namespace DERHANSEN\SfEventMgt\Domain\Repository; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The repository for registrations |
|
19
|
|
|
* |
|
20
|
|
|
* @author Torben Hansen <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class RegistrationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository |
|
23
|
|
|
{ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Disable the use of storage records, because the StoragePage can be set |
|
27
|
|
|
* in the plugin |
|
28
|
|
|
* |
|
29
|
|
|
* @return void |
|
30
|
|
|
*/ |
|
31
|
|
|
public function initializeObject() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings'); |
|
34
|
|
|
$this->defaultQuerySettings->setRespectStoragePage(false); |
|
35
|
|
|
$this->defaultQuerySettings->setRespectSysLanguage(false); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Returns all registrations, where the confirmation date is less than the |
|
40
|
|
|
* given date |
|
41
|
|
|
* |
|
42
|
|
|
* @param \Datetime $dateNow Date |
|
43
|
|
|
* |
|
44
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array |
|
45
|
|
|
*/ |
|
46
|
|
|
public function findExpiredRegistrations($dateNow) |
|
47
|
|
|
{ |
|
48
|
|
|
$constraints = []; |
|
49
|
|
|
$query = $this->createQuery(); |
|
50
|
|
|
$constraints[] = $query->lessThanOrEqual('confirmationUntil', $dateNow); |
|
51
|
|
|
$constraints[] = $query->equals('confirmed', false); |
|
52
|
|
|
return $query->matching($query->logicalAnd($constraints))->execute(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Returns all registrations for the given event with the given constraints |
|
57
|
|
|
* Constraints are combined with a logical AND |
|
58
|
|
|
* |
|
59
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
|
60
|
|
|
* @param array $findConstraints FindConstraints |
|
61
|
|
|
* |
|
62
|
|
|
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface |
|
63
|
|
|
*/ |
|
64
|
|
|
public function findNotificationRegistrations($event, $findConstraints) |
|
65
|
|
|
{ |
|
66
|
|
|
$constraints = []; |
|
67
|
|
|
$query = $this->createQuery(); |
|
68
|
|
|
$constraints[] = $query->equals('event', $event); |
|
69
|
|
|
$constraints[] = $query->equals('ignoreNotifications', false); |
|
70
|
|
|
|
|
71
|
|
|
if (!is_array($findConstraints) || count($findConstraints) == 0) { |
|
72
|
|
|
return $query->matching($query->logicalAnd($constraints))->execute(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
foreach ($findConstraints as $findConstraint => $value) { |
|
76
|
|
|
$condition = key($value); |
|
77
|
|
|
switch ($condition) { |
|
78
|
|
|
case 'equals': |
|
79
|
|
|
$constraints[] = $query->equals($findConstraint, $value[$condition]); |
|
80
|
|
|
break; |
|
81
|
|
|
case 'lessThan': |
|
82
|
|
|
$constraints[] = $query->lessThan($findConstraint, $value[$condition]); |
|
83
|
|
|
break; |
|
84
|
|
|
case 'lessThanOrEqual': |
|
85
|
|
|
$constraints[] = $query->lessThanOrEqual($findConstraint, $value[$condition]); |
|
86
|
|
|
break; |
|
87
|
|
|
case 'greaterThan': |
|
88
|
|
|
$constraints[] = $query->greaterThan($findConstraint, $value[$condition]); |
|
89
|
|
|
break; |
|
90
|
|
|
case 'greaterThanOrEqual': |
|
91
|
|
|
$constraints[] = $query->greaterThanOrEqual($findConstraint, $value[$condition]); |
|
92
|
|
|
break; |
|
93
|
|
|
default: |
|
94
|
|
|
throw new \InvalidArgumentException('An error occured - Unknown condition: ' . $condition); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
return $query->matching($query->logicalAnd($constraints))->execute(); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Returns all registrations for the given event matching the given e-mail address |
|
103
|
|
|
* |
|
104
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
|
105
|
|
|
* @param string $email E-Mail |
|
106
|
|
|
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface |
|
107
|
|
|
*/ |
|
108
|
|
|
public function findEventRegistrationsByEmail($event, $email) |
|
109
|
|
|
{ |
|
110
|
|
|
$constraints = []; |
|
111
|
|
|
$query = $this->createQuery(); |
|
112
|
|
|
$constraints[] = $query->equals('event', $event); |
|
113
|
|
|
$constraints[] = $query->equals('email', $email); |
|
114
|
|
|
return $query->matching($query->logicalAnd($constraints))->execute(); |
|
115
|
|
|
} |
|
116
|
|
|
} |