1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\admin\privacy\export; |
4
|
|
|
|
5
|
|
|
use EEM_Attendee; |
6
|
|
|
use EventEspresso\core\services\privacy\export\PersonalDataExporterInterface; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class ExportAttendee |
10
|
|
|
* Returns data on all the attendees using that email address |
11
|
|
|
* |
12
|
|
|
* @package Event Espresso |
13
|
|
|
* @author Mike Nelson |
14
|
|
|
* @since $VID:$ |
15
|
|
|
*/ |
16
|
|
|
class ExportAttendee implements PersonalDataExporterInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var EEM_Attendee |
20
|
|
|
*/ |
21
|
|
|
protected $attendee_model; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* ExportAttendee constructor. |
25
|
|
|
* |
26
|
|
|
* @param EEM_Attendee $attendee_model |
27
|
|
|
*/ |
28
|
|
|
public function __construct(EEM_Attendee $attendee_model) |
29
|
|
|
{ |
30
|
|
|
$this->attendee_model = $attendee_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
|
|
|
$attendees = $this->attendee_model->get_all( |
58
|
|
|
array( |
59
|
|
|
array( |
60
|
|
|
'ATT_email' => $email_address, |
61
|
|
|
), |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
if (empty($attendees)) { |
66
|
|
|
return array( |
67
|
|
|
'data' => array(), |
68
|
|
|
'done' => true, |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$export_items = array(); |
73
|
|
|
foreach ($attendees as $attendee) { |
74
|
|
|
$export_fields = array_intersect_key( |
75
|
|
|
$this->attendee_model->field_settings(), |
76
|
|
|
array_flip( |
77
|
|
|
array( |
78
|
|
|
'ATT_fname', |
79
|
|
|
'ATT_lname', |
80
|
|
|
'ATT_email', |
81
|
|
|
'ATT_address1', |
82
|
|
|
'ATT_address2', |
83
|
|
|
'ATT_city', |
84
|
|
|
'STA_ID', |
85
|
|
|
'CNT_ISO', |
86
|
|
|
'ATT_zip', |
87
|
|
|
'ATT_phone', |
88
|
|
|
) |
89
|
|
|
) |
90
|
|
|
); |
91
|
|
|
$data = array(); |
92
|
|
View Code Duplication |
foreach ($export_fields as $field_name => $field_obj) { |
93
|
|
|
if ($field_name === 'STA_ID') { |
|
|
|
|
94
|
|
|
$value = $attendee->state_name(); |
95
|
|
|
} elseif ($field_name == 'CNT_ISO') { |
96
|
|
|
$value = $attendee->country_name(); |
97
|
|
|
} else { |
98
|
|
|
$value = $attendee->get_pretty($field_name); |
99
|
|
|
} |
100
|
|
|
$data[] = array( |
101
|
|
|
'name' => $field_obj->get_nicename(), |
102
|
|
|
'value' => $value, |
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
$export_items[] = |
106
|
|
|
array( |
107
|
|
|
'group_id' => 'att-' . $attendee->ID(), |
108
|
|
|
'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
109
|
|
|
'item_id' => $attendee->ID(), |
110
|
|
|
'data' => $data, |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
return array( |
114
|
|
|
'data' => $export_items, |
115
|
|
|
'done' => true, |
116
|
|
|
); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Gets the Translated name of this exporter |
121
|
|
|
* |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
public function name() |
125
|
|
|
{ |
126
|
|
|
return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
// End of file ExportAttendee.php |
130
|
|
|
// Location: EventEspresso\core\domain\services\admin\privacy\export/ExportAttendee.php |
131
|
|
|
|