1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\admin\privacy\export; |
4
|
|
|
|
5
|
|
|
use EE_Registration; |
6
|
|
|
use EE_Ticket; |
7
|
|
|
use EEM_Answer; |
8
|
|
|
use EEM_Registration; |
9
|
|
|
use EventEspresso\core\services\privacy\export\PersonalDataExporterInterface; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class ExportRegistration |
13
|
|
|
* Returns information about what this user registered for |
14
|
|
|
* |
15
|
|
|
* @package Event Espresso |
16
|
|
|
* @author Mike Nelson |
17
|
|
|
* @since $VID:$ |
18
|
|
|
*/ |
19
|
|
|
class ExportRegistration implements PersonalDataExporterInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var EEM_Registration |
23
|
|
|
*/ |
24
|
|
|
protected $registration_model; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* ExportRegistration constructor. |
28
|
|
|
* |
29
|
|
|
* @param EEM_Registration $registration_model |
30
|
|
|
*/ |
31
|
|
|
public function __construct(EEM_Registration $registration_model) |
32
|
|
|
{ |
33
|
|
|
$this->registration_model = $registration_model; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns data for export. |
39
|
|
|
* |
40
|
|
|
* @param string $email_address , |
41
|
|
|
* @param int $page starts at 1, not 0 |
42
|
|
|
* @return array { |
43
|
|
|
* @type array $data { |
44
|
|
|
* @type array { |
45
|
|
|
* @type string $group_id (not translated, same for all exports) |
46
|
|
|
* @type string $group_label (translated string) |
47
|
|
|
* @type string|int $item_id |
48
|
|
|
* @type array $data { |
49
|
|
|
* @type array { |
50
|
|
|
* @type string $name what's shown in the left-column of the export row |
51
|
|
|
* @type string $value what's showin the right-column of the export row |
52
|
|
|
* } |
53
|
|
|
* } |
54
|
|
|
* } |
55
|
|
|
* } |
56
|
|
|
* } |
57
|
|
|
*/ |
58
|
|
|
public function export($email_address, $page = 1) |
59
|
|
|
{ |
60
|
|
|
$page_size = 10; |
61
|
|
|
$registrations = $this->registration_model->get_all( |
62
|
|
|
array( |
63
|
|
|
array( |
64
|
|
|
'Attendee.ATT_email' => $email_address, |
65
|
|
|
), |
66
|
|
|
'limit' => array( |
67
|
|
|
($page - 1) * $page_size, |
68
|
|
|
$page_size, |
69
|
|
|
), |
70
|
|
|
) |
71
|
|
|
); |
72
|
|
|
$export_fields = array_intersect_key( |
73
|
|
|
$this->registration_model->field_settings(), |
74
|
|
|
array_flip( |
75
|
|
|
array( |
76
|
|
|
'REG_code', |
77
|
|
|
'REG_date', |
78
|
|
|
'REG_final_price', |
79
|
|
|
'REG_paid', |
80
|
|
|
'REG_url_link', |
81
|
|
|
'REG_count', |
82
|
|
|
'REG_group_size', |
83
|
|
|
'REG_att_is_going', |
84
|
|
|
) |
85
|
|
|
) |
86
|
|
|
); |
87
|
|
|
$export_items = array(); |
88
|
|
|
$found_something = false; |
89
|
|
|
foreach ($registrations as $registration) { |
90
|
|
|
/** |
91
|
|
|
* @var $registration EE_Registration |
92
|
|
|
*/ |
93
|
|
|
$found_something = true; |
94
|
|
|
$data = array(); |
95
|
|
|
foreach ($export_fields as $field_name => $field_obj) { |
96
|
|
|
$data[] = array( |
97
|
|
|
'name' => $field_obj->get_nicename(), |
98
|
|
|
'value' => $registration->get_pretty($field_name), |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
$answers = $registration->answers( |
102
|
|
|
array( |
103
|
|
|
'force_join' => array( |
104
|
|
|
'Question', |
105
|
|
|
), |
106
|
|
|
) |
107
|
|
|
); |
108
|
|
|
foreach ($answers as $answer) { |
109
|
|
|
$data[] = array( |
110
|
|
|
'name' => $answer->question()->display_text(), |
111
|
|
|
'value' => $answer->pretty_value(), |
112
|
|
|
); |
113
|
|
|
} |
114
|
|
|
$ticket = $registration->ticket(); |
115
|
|
|
if ($ticket instanceof EE_Ticket) { |
116
|
|
|
$data[] = array( |
117
|
|
|
'name' => esc_html__('Ticket', 'event_espresso'), |
118
|
|
|
'value' => $ticket->name_and_info(), |
119
|
|
|
); |
120
|
|
|
$data[] = array( |
121
|
|
|
'name' => esc_html__('Event', 'event_espresso'), |
122
|
|
|
'value' => $ticket->get_event_name(), |
123
|
|
|
); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
$export_items[] = array( |
127
|
|
|
'group_id' => 'registration', |
128
|
|
|
'group_label' => esc_html__('Event Registrations', 'event_espresso'), |
129
|
|
|
'item_id' => $registration->ID(), |
130
|
|
|
'data' => $data, |
131
|
|
|
); |
132
|
|
|
} |
133
|
|
|
return array( |
134
|
|
|
'data' => $export_items, |
135
|
|
|
'done' => ! $found_something, |
136
|
|
|
); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Gets the Translated name of this exporter |
141
|
|
|
* |
142
|
|
|
* @return string |
143
|
|
|
*/ |
144
|
|
|
public function name() |
145
|
|
|
{ |
146
|
|
|
return esc_html__('Event Espresso Registration Data Exporter', 'event_espresso'); |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
// End of file ExportRegistration.php |
150
|
|
|
// Location: EventEspresso\core\domain\services\admin\privacy\export/ExportRegistration.php |
151
|
|
|
|