|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Entities; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
8
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
|
9
|
|
|
use WMDE\Fundraising\Store\DonationData; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @since 2.0 |
|
13
|
|
|
* |
|
14
|
|
|
* @ORM\Table( |
|
15
|
|
|
* name="spenden", |
|
16
|
|
|
* indexes={ |
|
17
|
|
|
* @ORM\Index(name="d_email", columns={"email"}, flags={"fulltext"}), |
|
18
|
|
|
* @ORM\Index(name="d_name", columns={"name"}, flags={"fulltext"}), |
|
19
|
|
|
* @ORM\Index(name="d_ort", columns={"ort"}, flags={"fulltext"}), |
|
20
|
|
|
* @ORM\Index(name="d_dt_new", columns={"dt_new", "is_public"}), |
|
21
|
|
|
* @ORM\Index(name="d_zahlweise", columns={"zahlweise", "dt_new"}), |
|
22
|
|
|
* @ORM\Index(name="d_dt_gruen", columns={"dt_gruen", "dt_del"}), |
|
23
|
|
|
* @ORM\Index(name="d_ueb_code", columns={"ueb_code"}), |
|
24
|
|
|
* @ORM\Index(name="d_dt_backup", columns={"dt_backup"}), |
|
25
|
|
|
* @ORM\Index(name="d_status", columns={"status", "dt_new"}), |
|
26
|
|
|
* @ORM\Index(name="d_comment_list", columns={"is_public", "dt_del"}) |
|
27
|
|
|
* } |
|
28
|
|
|
* ) |
|
29
|
|
|
* @ORM\Entity |
|
30
|
|
|
*/ |
|
31
|
|
|
class Donation { |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @since 2.0 |
|
35
|
|
|
*/ |
|
36
|
|
|
public const STATUS_NEW = 'N'; // status for direct debit |
|
37
|
|
|
public const STATUS_PROMISE = 'Z'; // status for bank transfer |
|
38
|
|
|
public const STATUS_EXTERNAL_INCOMPLETE = 'X'; // status for external payments |
|
39
|
|
|
public const STATUS_EXTERNAL_BOOKED = 'B'; // status for external payments |
|
40
|
|
|
public const STATUS_MODERATION = 'P'; |
|
41
|
|
|
public const STATUS_CANCELLED = 'D'; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @since 6.1 |
|
45
|
|
|
* @deprecated since 6.1; This status is defined for historical reasons. It should not be used to define a |
|
46
|
|
|
* donation's status anymore. |
|
47
|
|
|
*/ |
|
48
|
|
|
public const STATUS_EXPORTED = 'E'; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var integer |
|
52
|
|
|
* |
|
53
|
|
|
* @ORM\Column(name="id", type="integer") |
|
54
|
|
|
* @ORM\Id |
|
55
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
|
56
|
|
|
*/ |
|
57
|
|
|
private $id; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var string |
|
61
|
|
|
* |
|
62
|
|
|
* @ORM\Column(name="status", type="string", length=1, options={"default":"N", "fixed":true}, nullable=false) |
|
63
|
|
|
*/ |
|
64
|
|
|
private $status = self::STATUS_NEW; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var string |
|
68
|
|
|
* |
|
69
|
|
|
* @ORM\Column(name="name", type="string", length=250, nullable=true) |
|
70
|
|
|
*/ |
|
71
|
|
|
private $donorFullName; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @var string |
|
75
|
|
|
* |
|
76
|
|
|
* @ORM\Column(name="ort", type="string", length=250, nullable=true) |
|
77
|
|
|
*/ |
|
78
|
|
|
private $donorCity; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @var string |
|
82
|
|
|
* |
|
83
|
|
|
* @ORM\Column(name="email", type="string", length=250, nullable=true) |
|
84
|
|
|
*/ |
|
85
|
|
|
private $donorEmail; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @var boolean |
|
89
|
|
|
* |
|
90
|
|
|
* @ORM\Column(name="info", type="boolean", options={"default":0}, nullable=false) |
|
91
|
|
|
*/ |
|
92
|
|
|
private $donorOptsIntoNewsletter = 0; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @var boolean |
|
96
|
|
|
* |
|
97
|
|
|
* @ORM\Column(name="bescheinigung", type="boolean", nullable=true) |
|
98
|
|
|
*/ |
|
99
|
|
|
private $donationReceipt; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @var string |
|
103
|
|
|
* |
|
104
|
|
|
* @ORM\Column(name="eintrag", type="string", length=250, options={"default":""}, nullable=false) |
|
105
|
|
|
*/ |
|
106
|
|
|
private $publicRecord = ''; |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @var string |
|
110
|
|
|
* |
|
111
|
|
|
* @ORM\Column(name="betrag", type="string", length=250, nullable=true) |
|
112
|
|
|
*/ |
|
113
|
|
|
private $amount; |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @var integer |
|
117
|
|
|
* |
|
118
|
|
|
* @ORM\Column(name="periode", type="smallint", options={"default":0}, nullable=false) |
|
119
|
|
|
*/ |
|
120
|
|
|
private $paymentIntervalInMonths = 0; |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @var string |
|
124
|
|
|
* |
|
125
|
|
|
* @ORM\Column(name="zahlweise", type="string", length=3, options={"default":"BEZ", "fixed":true}, nullable=false) |
|
126
|
|
|
*/ |
|
127
|
|
|
private $paymentType = 'BEZ'; |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @var string |
|
131
|
|
|
* |
|
132
|
|
|
* @ORM\Column(name="kommentar", type="text", options={"default":""}, nullable=false) |
|
133
|
|
|
*/ |
|
134
|
|
|
private $comment = ''; |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @var string |
|
138
|
|
|
* |
|
139
|
|
|
* @ORM\Column(name="ueb_code", type="string", length=32, options={"default":""}, nullable=false) |
|
140
|
|
|
*/ |
|
141
|
|
|
private $bankTransferCode = ''; |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @var string |
|
145
|
|
|
* |
|
146
|
|
|
* @ORM\Column(name="data", type="text", nullable=true) |
|
147
|
|
|
*/ |
|
148
|
|
|
private $data; |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @var string |
|
152
|
|
|
* |
|
153
|
|
|
* @ORM\Column(name="source", type="string", length=250, nullable=true) |
|
154
|
|
|
*/ |
|
155
|
|
|
private $source; |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @var string |
|
159
|
|
|
* |
|
160
|
|
|
* @ORM\Column(name="remote_addr", type="string", length=250, options={"default":""}, nullable=false) |
|
161
|
|
|
*/ |
|
162
|
|
|
private $remoteAddr = ''; |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @var string |
|
166
|
|
|
* |
|
167
|
|
|
* @ORM\Column(name="hash", type="string", length=250, nullable=true) |
|
168
|
|
|
*/ |
|
169
|
|
|
private $hash; |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @var boolean |
|
173
|
|
|
* |
|
174
|
|
|
* @ORM\Column(name="is_public", type="boolean", options={"default":0}, nullable=false) |
|
175
|
|
|
*/ |
|
176
|
|
|
private $isPublic = 0; |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @var \DateTime |
|
180
|
|
|
* |
|
181
|
|
|
* @Gedmo\Timestampable(on="create") |
|
182
|
|
|
* @ORM\Column(name="dt_new", type="datetime") |
|
183
|
|
|
*/ |
|
184
|
|
|
private $creationTime; |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @var \DateTime |
|
188
|
|
|
* |
|
189
|
|
|
* @ORM\Column(name="dt_del", type="datetime", nullable=true) |
|
190
|
|
|
*/ |
|
191
|
|
|
private $deletionTime; |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @var \DateTime |
|
195
|
|
|
* |
|
196
|
|
|
* @ORM\Column(name="dt_exp", type="datetime", nullable=true) |
|
197
|
|
|
*/ |
|
198
|
|
|
private $dtExp; |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @var \DateTime |
|
202
|
|
|
* |
|
203
|
|
|
* @ORM\Column(name="dt_gruen", type="datetime", nullable=true) |
|
204
|
|
|
*/ |
|
205
|
|
|
private $dtGruen; |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @var \DateTime |
|
209
|
|
|
* |
|
210
|
|
|
* @ORM\Column(name="dt_backup", type="datetime", nullable=true) |
|
211
|
|
|
*/ |
|
212
|
|
|
private $dtBackup; |
|
213
|
|
|
|
|
214
|
|
|
/** |
|
215
|
|
|
* @ORM\OneToOne(targetEntity="WMDE\Fundraising\Entities\DonationPayment", cascade={"all"}, fetch="EAGER") |
|
216
|
|
|
*/ |
|
217
|
|
|
private $payment; |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @ORM\OneToOne(targetEntity="WMDE\Fundraising\Entities\AddressChange", cascade={"all"}, fetch="EAGER") |
|
221
|
|
|
* @ORM\JoinColumn(name="address_change_id", referencedColumnName="id") |
|
222
|
|
|
*/ |
|
223
|
|
|
private $addressChange; |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* @param string $donorFullName |
|
227
|
|
|
* |
|
228
|
|
|
* @return self |
|
229
|
|
|
*/ |
|
230
|
|
|
public function setDonorFullName( $donorFullName ) { |
|
231
|
|
|
$this->donorFullName = $donorFullName; |
|
232
|
|
|
|
|
233
|
|
|
return $this; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* @return string |
|
238
|
|
|
*/ |
|
239
|
|
|
public function getDonorFullName() { |
|
240
|
|
|
return $this->donorFullName; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* @param string $donorCity |
|
245
|
|
|
* |
|
246
|
|
|
* @return self |
|
247
|
|
|
*/ |
|
248
|
|
|
public function setDonorCity( $donorCity ) { |
|
249
|
|
|
$this->donorCity = $donorCity; |
|
250
|
|
|
|
|
251
|
|
|
return $this; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @return string |
|
256
|
|
|
*/ |
|
257
|
|
|
public function getDonorCity() { |
|
258
|
|
|
return $this->donorCity; |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* @param string $donorEmail |
|
263
|
|
|
* |
|
264
|
|
|
* @return self |
|
265
|
|
|
*/ |
|
266
|
|
|
public function setDonorEmail( $donorEmail ) { |
|
267
|
|
|
$this->donorEmail = $donorEmail; |
|
268
|
|
|
|
|
269
|
|
|
return $this; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* @return string |
|
274
|
|
|
*/ |
|
275
|
|
|
public function getDonorEmail() { |
|
276
|
|
|
return $this->donorEmail; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* @param boolean $donorOptsIntoNewsletter |
|
281
|
|
|
* |
|
282
|
|
|
* @return self |
|
283
|
|
|
*/ |
|
284
|
|
|
public function setDonorOptsIntoNewsletter( $donorOptsIntoNewsletter ) { |
|
285
|
|
|
$this->donorOptsIntoNewsletter = $donorOptsIntoNewsletter; |
|
286
|
|
|
|
|
287
|
|
|
return $this; |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
/** |
|
291
|
|
|
* @return boolean |
|
292
|
|
|
*/ |
|
293
|
|
|
public function getDonorOptsIntoNewsletter() { |
|
294
|
|
|
return $this->donorOptsIntoNewsletter; |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* Set donation receipt state |
|
299
|
|
|
* |
|
300
|
|
|
* @param boolean $donationReceipt |
|
301
|
|
|
* @return self |
|
302
|
|
|
*/ |
|
303
|
|
|
public function setDonationReceipt( $donationReceipt ) { |
|
304
|
|
|
$this->donationReceipt = $donationReceipt; |
|
305
|
|
|
|
|
306
|
|
|
return $this; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* Get donation receipt state |
|
311
|
|
|
* |
|
312
|
|
|
* @return boolean |
|
313
|
|
|
*/ |
|
314
|
|
|
public function getDonationReceipt() { |
|
315
|
|
|
return $this->donationReceipt; |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* Set publicly displayed donation record |
|
320
|
|
|
* |
|
321
|
|
|
* @param string $publicRecord |
|
322
|
|
|
* @return self |
|
323
|
|
|
*/ |
|
324
|
|
|
public function setPublicRecord( $publicRecord ) { |
|
325
|
|
|
$this->publicRecord = $publicRecord; |
|
326
|
|
|
|
|
327
|
|
|
return $this; |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* Get publicly displayed donation record |
|
332
|
|
|
* |
|
333
|
|
|
* @return string |
|
334
|
|
|
*/ |
|
335
|
|
|
public function getPublicRecord() { |
|
336
|
|
|
return $this->publicRecord; |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
/** |
|
340
|
|
|
* @param string $amount |
|
341
|
|
|
* @return self |
|
342
|
|
|
*/ |
|
343
|
|
|
public function setAmount( $amount ) { |
|
344
|
|
|
$this->amount = $amount; |
|
345
|
|
|
|
|
346
|
|
|
return $this; |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
/** |
|
350
|
|
|
* @return string |
|
351
|
|
|
*/ |
|
352
|
|
|
public function getAmount() { |
|
353
|
|
|
return $this->amount; |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
/** |
|
357
|
|
|
* @param integer $paymentIntervalInMonths |
|
358
|
|
|
* |
|
359
|
|
|
* @return self |
|
360
|
|
|
*/ |
|
361
|
|
|
public function setPaymentIntervalInMonths( $paymentIntervalInMonths ) { |
|
362
|
|
|
$this->paymentIntervalInMonths = $paymentIntervalInMonths; |
|
363
|
|
|
|
|
364
|
|
|
return $this; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
/** |
|
368
|
|
|
* @return integer |
|
369
|
|
|
*/ |
|
370
|
|
|
public function getPaymentIntervalInMonths() { |
|
371
|
|
|
return $this->paymentIntervalInMonths; |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
/** |
|
375
|
|
|
* Set payment type short code |
|
376
|
|
|
* |
|
377
|
|
|
* @param string $paymentType |
|
378
|
|
|
* @return self |
|
379
|
|
|
*/ |
|
380
|
|
|
public function setPaymentType( $paymentType ) { |
|
381
|
|
|
$this->paymentType = $paymentType; |
|
382
|
|
|
|
|
383
|
|
|
return $this; |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* Get payment type short code |
|
388
|
|
|
* |
|
389
|
|
|
* @return string |
|
390
|
|
|
*/ |
|
391
|
|
|
public function getPaymentType() { |
|
392
|
|
|
return $this->paymentType; |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* @param string $comment |
|
397
|
|
|
* @return self |
|
398
|
|
|
*/ |
|
399
|
|
|
public function setComment( $comment ) { |
|
400
|
|
|
$this->comment = $comment; |
|
401
|
|
|
|
|
402
|
|
|
return $this; |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
/** |
|
406
|
|
|
* @return string |
|
407
|
|
|
*/ |
|
408
|
|
|
public function getComment() { |
|
409
|
|
|
return $this->comment; |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
/** |
|
413
|
|
|
* Set bank transfer reference code |
|
414
|
|
|
* |
|
415
|
|
|
* @param string $bankTransferCode |
|
416
|
|
|
* |
|
417
|
|
|
* @return self |
|
418
|
|
|
*/ |
|
419
|
|
|
public function setBankTransferCode( $bankTransferCode ) { |
|
420
|
|
|
$this->bankTransferCode = $bankTransferCode; |
|
421
|
|
|
|
|
422
|
|
|
return $this; |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
/** |
|
426
|
|
|
* Get bank transfer reference code |
|
427
|
|
|
* |
|
428
|
|
|
* @return string |
|
429
|
|
|
*/ |
|
430
|
|
|
public function getBankTransferCode() { |
|
431
|
|
|
return $this->bankTransferCode; |
|
432
|
|
|
} |
|
433
|
|
|
|
|
434
|
|
|
/** |
|
435
|
|
|
* @param string $source |
|
436
|
|
|
* @return self |
|
437
|
|
|
*/ |
|
438
|
|
|
public function setSource( $source ) { |
|
439
|
|
|
$this->source = $source; |
|
440
|
|
|
|
|
441
|
|
|
return $this; |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
|
|
/** |
|
445
|
|
|
* @return string |
|
446
|
|
|
*/ |
|
447
|
|
|
public function getSource() { |
|
448
|
|
|
return $this->source; |
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
|
|
/** |
|
452
|
|
|
* @param string $remoteAddr |
|
453
|
|
|
* @return self |
|
454
|
|
|
*/ |
|
455
|
|
|
public function setRemoteAddr( $remoteAddr ) { |
|
456
|
|
|
$this->remoteAddr = $remoteAddr; |
|
457
|
|
|
|
|
458
|
|
|
return $this; |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
/** |
|
462
|
|
|
* @return string |
|
463
|
|
|
*/ |
|
464
|
|
|
public function getRemoteAddr() { |
|
465
|
|
|
return $this->remoteAddr; |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
/** |
|
469
|
|
|
* @param string $hash |
|
470
|
|
|
* @return self |
|
471
|
|
|
*/ |
|
472
|
|
|
public function setHash( $hash ) { |
|
473
|
|
|
$this->hash = $hash; |
|
474
|
|
|
|
|
475
|
|
|
return $this; |
|
476
|
|
|
} |
|
477
|
|
|
|
|
478
|
|
|
/** |
|
479
|
|
|
* @return string |
|
480
|
|
|
*/ |
|
481
|
|
|
public function getHash() { |
|
482
|
|
|
return $this->hash; |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* Sets if the donations comment should be public or private. |
|
487
|
|
|
* @param boolean $isPublic |
|
488
|
|
|
* @return self |
|
489
|
|
|
*/ |
|
490
|
|
|
public function setIsPublic( $isPublic ) { |
|
491
|
|
|
$this->isPublic = $isPublic; |
|
492
|
|
|
|
|
493
|
|
|
return $this; |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
/** |
|
497
|
|
|
* Gets if the donations comment is public or private. |
|
498
|
|
|
* @return boolean |
|
499
|
|
|
*/ |
|
500
|
|
|
public function getIsPublic() { |
|
501
|
|
|
return $this->isPublic; |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
/** |
|
505
|
|
|
* @param \DateTime $creationTime |
|
506
|
|
|
* |
|
507
|
|
|
* @return self |
|
508
|
|
|
*/ |
|
509
|
|
|
public function setCreationTime( $creationTime ) { |
|
510
|
|
|
$this->creationTime = $creationTime; |
|
511
|
|
|
|
|
512
|
|
|
return $this; |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
/** |
|
516
|
|
|
* @return \DateTime |
|
517
|
|
|
*/ |
|
518
|
|
|
public function getCreationTime() { |
|
519
|
|
|
return $this->creationTime; |
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
/** |
|
523
|
|
|
* @param \DateTime|null $deletionTime |
|
524
|
|
|
* |
|
525
|
|
|
* @return self |
|
526
|
|
|
*/ |
|
527
|
|
|
public function setDeletionTime( $deletionTime ) { |
|
528
|
|
|
$this->deletionTime = $deletionTime; |
|
529
|
|
|
|
|
530
|
|
|
return $this; |
|
531
|
|
|
} |
|
532
|
|
|
|
|
533
|
|
|
/** |
|
534
|
|
|
* @return \DateTime|null |
|
535
|
|
|
*/ |
|
536
|
|
|
public function getDeletionTime() { |
|
537
|
|
|
return $this->deletionTime; |
|
538
|
|
|
} |
|
539
|
|
|
|
|
540
|
|
|
/** |
|
541
|
|
|
* @param \DateTime $dtExp |
|
542
|
|
|
* @return self |
|
543
|
|
|
*/ |
|
544
|
|
|
public function setDtExp( $dtExp ) { |
|
545
|
|
|
$this->dtExp = $dtExp; |
|
546
|
|
|
|
|
547
|
|
|
return $this; |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
|
|
/** |
|
551
|
|
|
* @return \DateTime |
|
552
|
|
|
*/ |
|
553
|
|
|
public function getDtExp() { |
|
554
|
|
|
return $this->dtExp; |
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
/** |
|
558
|
|
|
* @param string $status |
|
559
|
|
|
* @return self |
|
560
|
|
|
*/ |
|
561
|
|
|
public function setStatus( $status ) { |
|
562
|
|
|
$this->status = $status; |
|
563
|
|
|
|
|
564
|
|
|
return $this; |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
/** |
|
568
|
|
|
* @return string |
|
569
|
|
|
*/ |
|
570
|
|
|
public function getStatus() { |
|
571
|
|
|
return $this->status; |
|
572
|
|
|
} |
|
573
|
|
|
|
|
574
|
|
|
/** |
|
575
|
|
|
* @param \DateTime $dtGruen |
|
576
|
|
|
* @return self |
|
577
|
|
|
*/ |
|
578
|
|
|
public function setDtGruen( $dtGruen ) { |
|
579
|
|
|
$this->dtGruen = $dtGruen; |
|
580
|
|
|
|
|
581
|
|
|
return $this; |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
/** |
|
585
|
|
|
* @return \DateTime |
|
586
|
|
|
*/ |
|
587
|
|
|
public function getDtGruen() { |
|
588
|
|
|
return $this->dtGruen; |
|
589
|
|
|
} |
|
590
|
|
|
|
|
591
|
|
|
/** |
|
592
|
|
|
* @param \DateTime $dtBackup |
|
593
|
|
|
* @return self |
|
594
|
|
|
*/ |
|
595
|
|
|
public function setDtBackup( $dtBackup ) { |
|
596
|
|
|
$this->dtBackup = $dtBackup; |
|
597
|
|
|
|
|
598
|
|
|
return $this; |
|
599
|
|
|
} |
|
600
|
|
|
|
|
601
|
|
|
/** |
|
602
|
|
|
* @return \DateTime |
|
603
|
|
|
*/ |
|
604
|
|
|
public function getDtBackup() { |
|
605
|
|
|
return $this->dtBackup; |
|
606
|
|
|
} |
|
607
|
|
|
|
|
608
|
|
|
/** |
|
609
|
|
|
* @return integer|null |
|
610
|
|
|
*/ |
|
611
|
3 |
|
public function getId() { |
|
612
|
3 |
|
return $this->id; |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
public function getPayment(): ?DonationPayment { |
|
616
|
|
|
return $this->payment; |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
|
|
public function setPayment( DonationPayment $payment ) { |
|
620
|
|
|
$this->payment = $payment; |
|
621
|
|
|
} |
|
622
|
|
|
|
|
623
|
|
|
|
|
624
|
|
|
/** |
|
625
|
|
|
* @since 2.0 |
|
626
|
|
|
* |
|
627
|
|
|
* @param integer|null $id |
|
628
|
|
|
*/ |
|
629
|
2 |
|
public function setId( $id ) { |
|
630
|
2 |
|
$this->id = $id; |
|
631
|
2 |
|
} |
|
632
|
|
|
|
|
633
|
|
|
public function getUExpiry() { |
|
634
|
|
|
return $this->getDecodedData()['uexpiry']; |
|
635
|
|
|
} |
|
636
|
|
|
|
|
637
|
|
|
public function uTokenIsExpired() { |
|
638
|
|
|
return time() > strtotime( $this->getUExpiry() ); |
|
639
|
|
|
} |
|
640
|
|
|
|
|
641
|
|
|
public function validateToken( $tokenToCheck, $serverSecret ) { |
|
642
|
|
|
$checkToken = preg_replace( '/\$.*$/', '', $tokenToCheck ); |
|
643
|
|
|
|
|
644
|
|
|
$checkToken = $checkToken . '$' . |
|
645
|
|
|
sha1( sha1( "$checkToken+$serverSecret" ) . '|' . |
|
646
|
|
|
sha1( "{$this->id}+$serverSecret" ) . '|' . |
|
647
|
|
|
sha1( "{$this->creationTime->format( 'Y-m-d H:i:s' )}+$serverSecret" ) ); |
|
648
|
|
|
return $checkToken === $tokenToCheck; |
|
649
|
|
|
} |
|
650
|
|
|
|
|
651
|
|
|
public function getEntryType( $mode = null ) { |
|
652
|
|
|
$data = $this->getDecodedData(); |
|
653
|
|
|
|
|
654
|
|
|
if ( $mode === null ) { |
|
655
|
|
|
$mode = $this->publicRecord; |
|
656
|
|
|
if ( !is_int( $mode ) ) { |
|
657
|
|
|
return $this->publicRecord; |
|
658
|
|
|
} |
|
659
|
|
|
} |
|
660
|
|
|
|
|
661
|
|
|
if ( $mode == 1 || $mode == 2 ) { |
|
662
|
|
|
$eintrag = $this->donorFullName; |
|
663
|
|
|
} else { |
|
664
|
|
|
$eintrag = 'anonym'; |
|
665
|
|
|
} |
|
666
|
|
|
|
|
667
|
|
|
if ( ( $mode == 1 || $mode == 3 ) && !empty( $data['ort'] ) ) { |
|
668
|
|
|
$eintrag .= ', ' . $data['ort']; |
|
669
|
|
|
} |
|
670
|
|
|
|
|
671
|
|
|
return $eintrag; |
|
672
|
|
|
} |
|
673
|
|
|
|
|
674
|
|
|
/** |
|
675
|
|
|
* @deprecated since 2.0, use encodeAndSetData or setDataObject instead |
|
676
|
|
|
* |
|
677
|
|
|
* @param string $data Base 64 encoded, serialized PHP array |
|
678
|
|
|
* @return self |
|
679
|
|
|
*/ |
|
680
|
|
|
public function setData( $data ) { |
|
681
|
|
|
$this->data = $data; |
|
682
|
|
|
|
|
683
|
|
|
return $this; |
|
684
|
|
|
} |
|
685
|
|
|
|
|
686
|
|
|
/** |
|
687
|
|
|
* @deprecated since 2.0, use @see getDecodedData or @see getDataObject instead |
|
688
|
|
|
* |
|
689
|
|
|
* @return string Base 64 encoded, serialized PHP array |
|
690
|
|
|
*/ |
|
691
|
|
|
public function getData() { |
|
692
|
|
|
return $this->data; |
|
693
|
|
|
} |
|
694
|
|
|
|
|
695
|
|
|
/** |
|
696
|
|
|
* NOTE: if possible, use @see getDataObject instead, as it provides a nicer API. |
|
697
|
|
|
* |
|
698
|
|
|
* @since 2.0 |
|
699
|
|
|
* @return array |
|
700
|
|
|
*/ |
|
701
|
8 |
|
public function getDecodedData() { |
|
702
|
8 |
|
if ( $this->data === null ) { |
|
703
|
4 |
|
return []; |
|
704
|
|
|
} |
|
705
|
|
|
|
|
706
|
6 |
|
$data = unserialize( base64_decode( $this->data ) ); |
|
707
|
|
|
|
|
708
|
6 |
|
return is_array( $data ) ? $data : []; |
|
709
|
|
|
} |
|
710
|
|
|
|
|
711
|
|
|
/** |
|
712
|
|
|
* NOTE: if possible, use @see modifyDataObject instead, as it provides a nicer API. |
|
713
|
|
|
* |
|
714
|
|
|
* @since 2.0 |
|
715
|
|
|
* @param array $data |
|
716
|
|
|
*/ |
|
717
|
6 |
|
public function encodeAndSetData( array $data ) { |
|
718
|
6 |
|
$this->data = base64_encode( serialize( $data ) ); |
|
719
|
6 |
|
} |
|
720
|
|
|
|
|
721
|
|
|
/** |
|
722
|
|
|
* WARNING: updates made to the return value will not be reflected in the Donation state. |
|
723
|
|
|
* Similarly, updates to the Donation state will not propagate to the returned object. |
|
724
|
|
|
* To update the Donation state, explicitly call @see setDataObject. |
|
725
|
|
|
* |
|
726
|
|
|
* @since 2.0 |
|
727
|
|
|
* @return DonationData |
|
728
|
|
|
*/ |
|
729
|
3 |
|
public function getDataObject() { |
|
730
|
3 |
|
$dataArray = $this->getDecodedData(); |
|
731
|
|
|
|
|
732
|
3 |
|
$data = new DonationData(); |
|
733
|
|
|
|
|
734
|
3 |
|
$data->setAccessToken( array_key_exists( 'token', $dataArray ) ? $dataArray['token'] : null ); |
|
735
|
3 |
|
$data->setUpdateToken( array_key_exists( 'utoken', $dataArray ) ? $dataArray['utoken'] : null ); |
|
736
|
3 |
|
$data->setUpdateTokenExpiry( array_key_exists( 'uexpiry', $dataArray ) ? $dataArray['uexpiry'] : null ); |
|
737
|
|
|
|
|
738
|
3 |
|
return $data; |
|
739
|
|
|
} |
|
740
|
|
|
|
|
741
|
|
|
/** |
|
742
|
|
|
* @since 2.0 |
|
743
|
|
|
* @param DonationData $data |
|
744
|
|
|
*/ |
|
745
|
4 |
|
public function setDataObject( DonationData $data ) { |
|
746
|
4 |
|
$dataArray = array_merge( |
|
747
|
4 |
|
$this->getDecodedData(), |
|
748
|
|
|
[ |
|
749
|
4 |
|
'token' => $data->getAccessToken(), |
|
750
|
4 |
|
'utoken' => $data->getUpdateToken(), |
|
751
|
4 |
|
'uexpiry' => $data->getUpdateTokenExpiry(), |
|
752
|
|
|
] |
|
753
|
|
|
); |
|
754
|
|
|
|
|
755
|
4 |
|
foreach ( [ 'token', 'utoken', 'uexpiry' ] as $keyName ) { |
|
756
|
4 |
|
if ( is_null( $dataArray[$keyName] ) ) { |
|
757
|
4 |
|
unset( $dataArray[$keyName] ); |
|
758
|
|
|
} |
|
759
|
|
|
} |
|
760
|
|
|
|
|
761
|
4 |
|
$this->encodeAndSetData( $dataArray ); |
|
762
|
4 |
|
} |
|
763
|
|
|
|
|
764
|
|
|
/** |
|
765
|
|
|
* @since 2.0 |
|
766
|
|
|
* @param callable $modificationFunction Takes a modifiable DonationData parameter |
|
767
|
|
|
*/ |
|
768
|
1 |
|
public function modifyDataObject( callable $modificationFunction ) { |
|
769
|
1 |
|
$dataObject = $this->getDataObject(); |
|
770
|
1 |
|
$modificationFunction( $dataObject ); |
|
771
|
1 |
|
$this->setDataObject( $dataObject ); |
|
772
|
1 |
|
} |
|
773
|
|
|
|
|
774
|
|
|
/** |
|
775
|
|
|
* Get AddressChange reference |
|
776
|
|
|
* |
|
777
|
|
|
* @since 8.0 |
|
778
|
|
|
* |
|
779
|
|
|
* @return AddressChange |
|
780
|
|
|
*/ |
|
781
|
|
|
public function getAddressChange(): AddressChange { |
|
782
|
|
|
return $this->addressChange; |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
/** |
|
786
|
|
|
* Set AddressChange reference |
|
787
|
|
|
* |
|
788
|
|
|
* @since 8.0 |
|
789
|
|
|
* @param $addressChange AddressChange |
|
790
|
|
|
* |
|
791
|
|
|
* @return AddressChange |
|
792
|
|
|
*/ |
|
793
|
|
|
public function setAddressChange(AddressChange $addressChange) { |
|
794
|
|
|
return $this->addressChange = $addressChange; |
|
795
|
|
|
} |
|
796
|
|
|
} |
|
797
|
|
|
|