1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WMDE\Fundraising\Entities; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @since 2.0 |
10
|
|
|
* |
11
|
|
|
* @ORM\Table( name="subscription" ) |
12
|
|
|
* @ORM\Entity |
13
|
|
|
*/ |
14
|
|
|
class Subscription { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
* |
19
|
|
|
* @ORM\Column(name="full_name", type="string", length=250, options={"default":""}, nullable=false) |
20
|
|
|
*/ |
21
|
|
|
private $fullName = ''; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
* |
26
|
|
|
* @ORM\Column(name="email", type="string", length=250, options={"default":""}, nullable=false) |
27
|
|
|
*/ |
28
|
|
|
private $email = ''; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \DateTime |
32
|
|
|
* |
33
|
|
|
* @ORM\Column(name="export", type="datetime", nullable=true) |
34
|
|
|
*/ |
35
|
|
|
private $export; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var \DateTime |
39
|
|
|
* |
40
|
|
|
* @ORM\Column(name="backup", type="datetime", nullable=true) |
41
|
|
|
*/ |
42
|
|
|
private $backup; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var integer |
46
|
|
|
* |
47
|
|
|
* @ORM\Column(name="status", type="smallint", options={"default":0}, nullable=true) |
48
|
|
|
*/ |
49
|
|
|
private $status = 0; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string |
53
|
|
|
* |
54
|
|
|
* @ORM\Column(name="confirmationCode", type="blob", length=16, nullable=true) |
55
|
|
|
*/ |
56
|
|
|
private $confirmationCode; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var integer |
60
|
|
|
* |
61
|
|
|
* @ORM\Column(name="id", type="integer") |
62
|
|
|
* @ORM\Id |
63
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
64
|
|
|
*/ |
65
|
|
|
private $id; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @ORM\ManyToOne(targetEntity="Address") |
69
|
|
|
* @ORM\JoinColumn(name="address_id", referencedColumnName="id") |
70
|
|
|
*/ |
71
|
|
|
private $address; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var \DateTime |
75
|
|
|
* @Gedmo\Timestampable(on="create") |
76
|
|
|
* @ORM\Column(type="datetime") |
77
|
|
|
*/ |
78
|
|
|
private $createdAt; |
79
|
|
|
|
80
|
|
|
const STATUS_CONFIRMED = 1; |
81
|
|
|
const STATUS_NEUTRAL = 0; |
82
|
|
|
const STATUS_DELETED = -1; |
83
|
|
|
const STATUS_MODERATION = -2; |
84
|
|
|
const STATUS_ABORTED = -4; |
85
|
|
|
const STATUS_CANCELED = -8; |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Set name |
90
|
|
|
* |
91
|
|
|
* @param string $fullName |
92
|
|
|
* @return Subscription |
93
|
|
|
*/ |
94
|
|
|
public function setFullName( $fullName ) { |
95
|
|
|
$this->fullName = $fullName; |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Get name |
102
|
|
|
* |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getFullName() { |
106
|
|
|
return $this->fullName; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Set email |
111
|
|
|
* |
112
|
|
|
* @param string $email |
113
|
|
|
* @return Subscription |
114
|
|
|
*/ |
115
|
|
|
public function setEmail( $email ) { |
116
|
|
|
$this->email = $email; |
117
|
|
|
|
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get email |
123
|
|
|
* |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getEmail() { |
127
|
|
|
return $this->email; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Set export |
132
|
|
|
* |
133
|
|
|
* @param \DateTime $export |
134
|
|
|
* @return Subscription |
135
|
|
|
*/ |
136
|
|
|
public function setExport( $export ) { |
137
|
|
|
$this->export = $export; |
138
|
|
|
|
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Get export |
144
|
|
|
* |
145
|
|
|
* @return \DateTime |
146
|
|
|
*/ |
147
|
|
|
public function getExport() { |
148
|
|
|
return $this->export; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Set backup |
153
|
|
|
* |
154
|
|
|
* @param \DateTime $backup |
155
|
|
|
* @return Subscription |
156
|
|
|
*/ |
157
|
|
|
public function setBackup( $backup ) { |
158
|
|
|
$this->backup = $backup; |
159
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Get backup |
165
|
|
|
* |
166
|
|
|
* @return \DateTime |
167
|
|
|
*/ |
168
|
|
|
public function getBackup() { |
169
|
|
|
return $this->backup; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Set status |
174
|
|
|
* |
175
|
|
|
* @param integer $status |
176
|
|
|
* @return Subscription |
177
|
|
|
*/ |
178
|
|
|
public function setStatus( $status ) { |
179
|
|
|
$this->status = $status; |
180
|
|
|
|
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Get status |
186
|
|
|
* |
187
|
|
|
* @return integer |
188
|
|
|
*/ |
189
|
|
|
public function getStatus() { |
190
|
|
|
return $this->status; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Set guid |
195
|
|
|
* |
196
|
|
|
* @param string $confirmationCode |
197
|
|
|
* @return Subscription |
198
|
|
|
*/ |
199
|
|
|
public function setConfirmationCode( $confirmationCode ) { |
200
|
|
|
$this->confirmationCode = $confirmationCode; |
201
|
|
|
|
202
|
|
|
return $this; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Get guid |
207
|
|
|
* |
208
|
|
|
* @return string |
209
|
|
|
*/ |
210
|
|
|
public function getConfirmationCode() { |
211
|
|
|
return $this->confirmationCode; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Get id |
216
|
|
|
* |
217
|
|
|
* @return integer |
218
|
|
|
*/ |
219
|
|
|
public function getId() { |
220
|
|
|
return $this->id; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @return Address |
225
|
|
|
*/ |
226
|
|
|
public function getAddress() { |
227
|
|
|
return $this->address; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return \DateTime |
232
|
|
|
*/ |
233
|
|
|
public function getCreatedAt() { |
234
|
|
|
return $this->createdAt; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @param \DateTime $createdAt |
239
|
|
|
* @return Membership |
240
|
|
|
*/ |
241
|
|
|
public function setCreatedAt( $createdAt ) { |
242
|
|
|
$this->createdAt = $createdAt; |
243
|
|
|
return $this; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @param Address $address |
248
|
|
|
*/ |
249
|
|
|
public function setAddress( $address ) { |
250
|
|
|
$this->address = $address; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
public function isUnconfirmed() { |
254
|
|
|
return $this->getStatus() === self::STATUS_NEUTRAL; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
public function getHexConfirmationCode() { |
258
|
|
|
return bin2hex( $this->confirmationCode ); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
public function setHexConfirmationCode( $confirmationCode ) { |
262
|
|
|
$this->confirmationCode = hex2bin( $confirmationCode ); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
} |
266
|
|
|
|