|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\admin\privacy\export; |
|
4
|
|
|
|
|
5
|
|
|
use EEM_Transaction; |
|
6
|
|
|
use EventEspresso\core\services\privacy\export\PersonalDataExporterInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class ExportTransaction |
|
10
|
|
|
* Description |
|
11
|
|
|
* |
|
12
|
|
|
* @package Event Espresso |
|
13
|
|
|
* @author Mike Nelson |
|
14
|
|
|
* @since $VID:$ |
|
15
|
|
|
*/ |
|
16
|
|
|
class ExportTransaction implements PersonalDataExporterInterface |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var EEM_Transaction $transaction_model |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $transaction_model; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* ExportTransaction constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* @param $transaction_model |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(EEM_Transaction $transaction_model) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->transaction_model = $transaction_model; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Returns data for export. |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $email_address , |
|
38
|
|
|
* @param int $page starts at 1, not 0 |
|
39
|
|
|
* @return array { |
|
40
|
|
|
* @type array $data { |
|
41
|
|
|
* @type array { |
|
42
|
|
|
* @type string $group_id (not translated, same for all exports) |
|
43
|
|
|
* @type string $group_label (translated string) |
|
44
|
|
|
* @type string|int $item_id |
|
45
|
|
|
* @type array $data { |
|
46
|
|
|
* @type array { |
|
47
|
|
|
* @type string $name what's shown in the left-column of the export row |
|
48
|
|
|
* @type string $value what's showin the right-column of the export row |
|
49
|
|
|
* } |
|
50
|
|
|
* } |
|
51
|
|
|
* } |
|
52
|
|
|
* } |
|
53
|
|
|
* } |
|
54
|
|
|
*/ |
|
55
|
|
|
public function export($email_address, $page = 1) |
|
56
|
|
|
{ |
|
57
|
|
|
$page_size = 10; |
|
58
|
|
|
$transactions = $this->transaction_model->get_all( |
|
59
|
|
|
array( |
|
60
|
|
|
array( |
|
61
|
|
|
'Registration.Attendee.ATT_email' => $email_address, |
|
62
|
|
|
), |
|
63
|
|
|
'limit' => array( |
|
64
|
|
|
($page - 1) * $page_size, |
|
65
|
|
|
$page_size, |
|
66
|
|
|
), |
|
67
|
|
|
) |
|
68
|
|
|
); |
|
69
|
|
|
$export_fields = array_intersect_key( |
|
70
|
|
|
EEM_Transaction::instance()->field_settings(), |
|
71
|
|
|
array_flip( |
|
72
|
|
|
array( |
|
73
|
|
|
'TXN_timestamp', |
|
74
|
|
|
'TXN_total', |
|
75
|
|
|
'TXN_paid', |
|
76
|
|
|
'TXN_session_data', |
|
77
|
|
|
) |
|
78
|
|
|
) |
|
79
|
|
|
); |
|
80
|
|
|
$export_items = array(); |
|
81
|
|
|
$found_something = false; |
|
82
|
|
|
foreach ($transactions as $transaction) { |
|
83
|
|
|
$found_something = true; |
|
84
|
|
|
$data = array(); |
|
85
|
|
View Code Duplication |
foreach ($export_fields as $field_name => $field_obj) { |
|
86
|
|
|
if ($field_name === 'TXN_session_data') { |
|
|
|
|
|
|
87
|
|
|
$value = $transaction->get_pretty($field_name, 'print_r'); |
|
88
|
|
|
} else { |
|
89
|
|
|
$value = $transaction->get_pretty($field_name); |
|
90
|
|
|
} |
|
91
|
|
|
$data[] = array( |
|
92
|
|
|
'name' => $field_obj->get_nicename(), |
|
93
|
|
|
'value' => $value, |
|
94
|
|
|
); |
|
95
|
|
|
} |
|
96
|
|
|
$export_items[] = array( |
|
97
|
|
|
'group_id' => 'transactions', |
|
98
|
|
|
'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99
|
|
|
'item_id' => $transaction->ID(), |
|
100
|
|
|
'data' => $data, |
|
101
|
|
|
); |
|
102
|
|
|
} |
|
103
|
|
|
return array( |
|
104
|
|
|
'data' => $export_items, |
|
105
|
|
|
'done' => ! $found_something, |
|
106
|
|
|
); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Gets the Translated name of this exporter |
|
111
|
|
|
* |
|
112
|
|
|
* @return string |
|
113
|
|
|
*/ |
|
114
|
|
|
public function name() |
|
115
|
|
|
{ |
|
116
|
|
|
return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
// End of file ExportTransaction.php |
|
120
|
|
|
// Location: EventEspresso\core\domain\services\admin\privacy\export/ExportTransaction.php |
|
121
|
|
|
|