@@ -20,586 +20,586 @@ |
||
20 | 20 | class EE_Messages_Preview_incoming_data extends EE_Messages_incoming_data |
21 | 21 | { |
22 | 22 | |
23 | - // some specific properties we need for this class |
|
24 | - private $_events = array(); |
|
25 | - private $_attendees = array(); |
|
26 | - private $_registrations = array(); |
|
23 | + // some specific properties we need for this class |
|
24 | + private $_events = array(); |
|
25 | + private $_attendees = array(); |
|
26 | + private $_registrations = array(); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
31 | - * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
32 | - * we'll get the first three published events from the users database and use that as a source. |
|
33 | - * |
|
34 | - * @param array $data |
|
35 | - */ |
|
36 | - public function __construct($data = array()) |
|
37 | - { |
|
38 | - $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
39 | - $this->_setup_attendees_events(); |
|
40 | - parent::__construct($data); |
|
41 | - } |
|
29 | + /** |
|
30 | + * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
31 | + * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
32 | + * we'll get the first three published events from the users database and use that as a source. |
|
33 | + * |
|
34 | + * @param array $data |
|
35 | + */ |
|
36 | + public function __construct($data = array()) |
|
37 | + { |
|
38 | + $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
39 | + $this->_setup_attendees_events(); |
|
40 | + parent::__construct($data); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
46 | - * |
|
47 | - * @param array $data The incoming data to be prepped. |
|
48 | - * |
|
49 | - * @return array The prepped data for db |
|
50 | - */ |
|
51 | - public static function convert_data_for_persistent_storage($data) |
|
52 | - { |
|
53 | - return $data; |
|
54 | - } |
|
44 | + /** |
|
45 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
46 | + * |
|
47 | + * @param array $data The incoming data to be prepped. |
|
48 | + * |
|
49 | + * @return array The prepped data for db |
|
50 | + */ |
|
51 | + public static function convert_data_for_persistent_storage($data) |
|
52 | + { |
|
53 | + return $data; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
59 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
60 | - * |
|
61 | - * @param array $data |
|
62 | - * |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - public static function convert_data_from_persistent_storage($data) |
|
66 | - { |
|
67 | - return $data; |
|
68 | - } |
|
57 | + /** |
|
58 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
59 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
60 | + * |
|
61 | + * @param array $data |
|
62 | + * |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + public static function convert_data_from_persistent_storage($data) |
|
66 | + { |
|
67 | + return $data; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * This will just setup the _events property in the expected format. |
|
73 | - * |
|
74 | - * @throws \EE_Error |
|
75 | - */ |
|
76 | - private function _setup_attendees_events() |
|
77 | - { |
|
78 | - |
|
79 | - // setup some attendee objects |
|
80 | - $attendees = $this->_get_some_attendees(); |
|
81 | - |
|
82 | - // if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids. |
|
83 | - $events = $this->_get_some_events($this->_data); |
|
84 | - |
|
85 | - $answers_n_questions = $this->_get_some_q_and_as(); |
|
86 | - |
|
87 | - if (count($events) < 1) { |
|
88 | - throw new EE_Error(__( |
|
89 | - 'We can\'t generate a preview for you because there are no active events in your database', |
|
90 | - 'event_espresso' |
|
91 | - )); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
96 | - |
|
97 | - |
|
98 | - // we'll actually use the generated line_item identifiers for our loop |
|
99 | - $dtts = $tkts = array(); |
|
100 | - foreach ($events as $id => $event) { |
|
101 | - if (! $event instanceof EE_Event) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - $this->_events[ $id ]['ID'] = $id; |
|
105 | - $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
106 | - $datetime = $event->get_first_related('Datetime'); |
|
107 | - $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
108 | - 'Ticket', |
|
109 | - array('default_where_conditions' => 'none') |
|
110 | - ) : array(); |
|
111 | - $this->_events[ $id ]['event'] = $event; |
|
112 | - $this->_events[ $id ]['reg_objs'] = array(); |
|
113 | - $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
114 | - $this->_events[ $id ]['dtt_objs'] = array(); |
|
71 | + /** |
|
72 | + * This will just setup the _events property in the expected format. |
|
73 | + * |
|
74 | + * @throws \EE_Error |
|
75 | + */ |
|
76 | + private function _setup_attendees_events() |
|
77 | + { |
|
78 | + |
|
79 | + // setup some attendee objects |
|
80 | + $attendees = $this->_get_some_attendees(); |
|
81 | + |
|
82 | + // if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids. |
|
83 | + $events = $this->_get_some_events($this->_data); |
|
84 | + |
|
85 | + $answers_n_questions = $this->_get_some_q_and_as(); |
|
86 | + |
|
87 | + if (count($events) < 1) { |
|
88 | + throw new EE_Error(__( |
|
89 | + 'We can\'t generate a preview for you because there are no active events in your database', |
|
90 | + 'event_espresso' |
|
91 | + )); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
96 | + |
|
97 | + |
|
98 | + // we'll actually use the generated line_item identifiers for our loop |
|
99 | + $dtts = $tkts = array(); |
|
100 | + foreach ($events as $id => $event) { |
|
101 | + if (! $event instanceof EE_Event) { |
|
102 | + continue; |
|
103 | + } |
|
104 | + $this->_events[ $id ]['ID'] = $id; |
|
105 | + $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
106 | + $datetime = $event->get_first_related('Datetime'); |
|
107 | + $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
108 | + 'Ticket', |
|
109 | + array('default_where_conditions' => 'none') |
|
110 | + ) : array(); |
|
111 | + $this->_events[ $id ]['event'] = $event; |
|
112 | + $this->_events[ $id ]['reg_objs'] = array(); |
|
113 | + $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
114 | + $this->_events[ $id ]['dtt_objs'] = array(); |
|
115 | 115 | |
116 | - $dttcache = array(); |
|
117 | - $tkts = array(); |
|
118 | - foreach ($tickets as $ticket) { |
|
119 | - if (! $ticket instanceof EE_Ticket) { |
|
120 | - continue; |
|
121 | - } |
|
122 | - $reldatetime = $ticket->datetimes(); |
|
123 | - $tkts[ $ticket->ID() ] = array(); |
|
124 | - $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
125 | - $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
126 | - $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
127 | - $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
128 | - $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
129 | - foreach ($reldatetime as $datetime) { |
|
130 | - if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
131 | - $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
132 | - $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
133 | - $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
134 | - $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
135 | - $dttcache[ $datetime->ID() ] = $datetime; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
116 | + $dttcache = array(); |
|
117 | + $tkts = array(); |
|
118 | + foreach ($tickets as $ticket) { |
|
119 | + if (! $ticket instanceof EE_Ticket) { |
|
120 | + continue; |
|
121 | + } |
|
122 | + $reldatetime = $ticket->datetimes(); |
|
123 | + $tkts[ $ticket->ID() ] = array(); |
|
124 | + $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
125 | + $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
126 | + $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
127 | + $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
128 | + $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
129 | + foreach ($reldatetime as $datetime) { |
|
130 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
131 | + $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
132 | + $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
133 | + $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
134 | + $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
135 | + $dttcache[ $datetime->ID() ] = $datetime; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
141 | - $this->_events[ $id ]['att_objs'] = $attendees; |
|
140 | + $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
141 | + $this->_events[ $id ]['att_objs'] = $attendees; |
|
142 | 142 | |
143 | - // let's also setup the dummy attendees property! |
|
144 | - foreach ($attendees as $att_key => $attendee) { |
|
145 | - if (! $attendee instanceof EE_Attendee) { |
|
146 | - continue; |
|
147 | - } |
|
148 | - $this->_attendees[ $att_key ]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
149 | - $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
150 | - $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
151 | - // $this->_attendees[$att_key]['registration_id'] = 0; |
|
152 | - $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
153 | - $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
154 | - if ($att_key == 999999991) { |
|
155 | - $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | - $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | - $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
158 | - } elseif ($att_key == 999999992) { |
|
159 | - $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | - $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | - $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
162 | - } elseif ($att_key == 999999993) { |
|
163 | - $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | - $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | - $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - $this->tickets = $tkts; |
|
171 | - $this->datetimes = $dtts; |
|
172 | - $this->answers = $answers_n_questions['answers']; |
|
173 | - $this->questions = $answers_n_questions['questions']; |
|
174 | - $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
175 | - } |
|
143 | + // let's also setup the dummy attendees property! |
|
144 | + foreach ($attendees as $att_key => $attendee) { |
|
145 | + if (! $attendee instanceof EE_Attendee) { |
|
146 | + continue; |
|
147 | + } |
|
148 | + $this->_attendees[ $att_key ]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
149 | + $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
150 | + $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
151 | + // $this->_attendees[$att_key]['registration_id'] = 0; |
|
152 | + $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
153 | + $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
154 | + if ($att_key == 999999991) { |
|
155 | + $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | + $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | + $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
158 | + } elseif ($att_key == 999999992) { |
|
159 | + $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | + $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | + $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
162 | + } elseif ($att_key == 999999993) { |
|
163 | + $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | + $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | + $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + $this->tickets = $tkts; |
|
171 | + $this->datetimes = $dtts; |
|
172 | + $this->answers = $answers_n_questions['answers']; |
|
173 | + $this->questions = $answers_n_questions['questions']; |
|
174 | + $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | |
178 | - /** |
|
179 | - * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
180 | - * |
|
181 | - * @access private |
|
182 | - * @return array an array of attendee objects |
|
183 | - */ |
|
184 | - private function _get_some_attendees() |
|
185 | - { |
|
186 | - // let's just setup a dummy array of various attendee details |
|
187 | - $dummy_attendees = array( |
|
188 | - 0 => array( |
|
189 | - 'Luke', |
|
190 | - 'Skywalker', |
|
191 | - '[email protected]', |
|
192 | - '804 Bantha Dr.', |
|
193 | - 'Complex 8', |
|
194 | - 'Mos Eisley', |
|
195 | - 32, |
|
196 | - 'US', |
|
197 | - 'f0r3e', |
|
198 | - '222-333-4763', |
|
199 | - false, |
|
200 | - '999999991' |
|
201 | - ), |
|
202 | - 1 => array( |
|
203 | - 'Princess', |
|
204 | - 'Leia', |
|
205 | - '[email protected]', |
|
206 | - '1456 Valley Way Boulevard', |
|
207 | - 'Suite 9', |
|
208 | - 'Alderaan', |
|
209 | - 15, |
|
210 | - 'US', |
|
211 | - 'c1h2c', |
|
212 | - '78-123-111-1111', |
|
213 | - false, |
|
214 | - '999999992' |
|
215 | - ), |
|
216 | - 2 => array( |
|
217 | - 'Yoda', |
|
218 | - 'I Am', |
|
219 | - '[email protected]', |
|
220 | - '4th Tree', |
|
221 | - '5th Knot', |
|
222 | - 'Marsh', |
|
223 | - 22, |
|
224 | - 'US', |
|
225 | - 'l18n', |
|
226 | - '999-999-9999', |
|
227 | - false, |
|
228 | - '999999993' |
|
229 | - ), |
|
230 | - ); |
|
231 | - |
|
232 | - // let's generate the attendee objects |
|
233 | - $attendees = array(); |
|
234 | - $var_array = array( |
|
235 | - 'fname', |
|
236 | - 'lname', |
|
237 | - 'email', |
|
238 | - 'address', |
|
239 | - 'address2', |
|
240 | - 'city', |
|
241 | - 'staid', |
|
242 | - 'cntry', |
|
243 | - 'zip', |
|
244 | - 'phone', |
|
245 | - 'deleted', |
|
246 | - 'attid' |
|
247 | - ); |
|
248 | - |
|
249 | - // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
250 | - foreach ($dummy_attendees as $dummy) { |
|
251 | - $att = array_combine($var_array, $dummy); |
|
252 | - extract($att); |
|
253 | - /** @var $fname string */ |
|
254 | - /** @var $lname string */ |
|
255 | - /** @var $address string */ |
|
256 | - /** @var $address2 string */ |
|
257 | - /** @var $city string */ |
|
258 | - /** @var $staid string */ |
|
259 | - /** @var $cntry string */ |
|
260 | - /** @var $zip string */ |
|
261 | - /** @var $email string */ |
|
262 | - /** @var $phone string */ |
|
263 | - /** @var $attid string */ |
|
264 | - $attendees[ $attid ] = EE_Attendee::new_instance( |
|
265 | - array( |
|
266 | - 'ATT_fname' => $fname, |
|
267 | - 'ATT_lname' => $lname, |
|
268 | - 'ATT_address' => $address, |
|
269 | - 'ATT_address2' => $address2, |
|
270 | - 'ATT_city' => $city, |
|
271 | - 'STA_ID' => $staid, |
|
272 | - 'CNT_ISO' => $cntry, |
|
273 | - 'ATT_zip' => $zip, |
|
274 | - 'ATT_email' => $email, |
|
275 | - 'ATT_phone' => $phone, |
|
276 | - 'ATT_ID' => $attid |
|
277 | - ) |
|
278 | - ); |
|
279 | - } |
|
280 | - |
|
281 | - return $attendees; |
|
282 | - } |
|
178 | + /** |
|
179 | + * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
180 | + * |
|
181 | + * @access private |
|
182 | + * @return array an array of attendee objects |
|
183 | + */ |
|
184 | + private function _get_some_attendees() |
|
185 | + { |
|
186 | + // let's just setup a dummy array of various attendee details |
|
187 | + $dummy_attendees = array( |
|
188 | + 0 => array( |
|
189 | + 'Luke', |
|
190 | + 'Skywalker', |
|
191 | + '[email protected]', |
|
192 | + '804 Bantha Dr.', |
|
193 | + 'Complex 8', |
|
194 | + 'Mos Eisley', |
|
195 | + 32, |
|
196 | + 'US', |
|
197 | + 'f0r3e', |
|
198 | + '222-333-4763', |
|
199 | + false, |
|
200 | + '999999991' |
|
201 | + ), |
|
202 | + 1 => array( |
|
203 | + 'Princess', |
|
204 | + 'Leia', |
|
205 | + '[email protected]', |
|
206 | + '1456 Valley Way Boulevard', |
|
207 | + 'Suite 9', |
|
208 | + 'Alderaan', |
|
209 | + 15, |
|
210 | + 'US', |
|
211 | + 'c1h2c', |
|
212 | + '78-123-111-1111', |
|
213 | + false, |
|
214 | + '999999992' |
|
215 | + ), |
|
216 | + 2 => array( |
|
217 | + 'Yoda', |
|
218 | + 'I Am', |
|
219 | + '[email protected]', |
|
220 | + '4th Tree', |
|
221 | + '5th Knot', |
|
222 | + 'Marsh', |
|
223 | + 22, |
|
224 | + 'US', |
|
225 | + 'l18n', |
|
226 | + '999-999-9999', |
|
227 | + false, |
|
228 | + '999999993' |
|
229 | + ), |
|
230 | + ); |
|
231 | + |
|
232 | + // let's generate the attendee objects |
|
233 | + $attendees = array(); |
|
234 | + $var_array = array( |
|
235 | + 'fname', |
|
236 | + 'lname', |
|
237 | + 'email', |
|
238 | + 'address', |
|
239 | + 'address2', |
|
240 | + 'city', |
|
241 | + 'staid', |
|
242 | + 'cntry', |
|
243 | + 'zip', |
|
244 | + 'phone', |
|
245 | + 'deleted', |
|
246 | + 'attid' |
|
247 | + ); |
|
248 | + |
|
249 | + // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
250 | + foreach ($dummy_attendees as $dummy) { |
|
251 | + $att = array_combine($var_array, $dummy); |
|
252 | + extract($att); |
|
253 | + /** @var $fname string */ |
|
254 | + /** @var $lname string */ |
|
255 | + /** @var $address string */ |
|
256 | + /** @var $address2 string */ |
|
257 | + /** @var $city string */ |
|
258 | + /** @var $staid string */ |
|
259 | + /** @var $cntry string */ |
|
260 | + /** @var $zip string */ |
|
261 | + /** @var $email string */ |
|
262 | + /** @var $phone string */ |
|
263 | + /** @var $attid string */ |
|
264 | + $attendees[ $attid ] = EE_Attendee::new_instance( |
|
265 | + array( |
|
266 | + 'ATT_fname' => $fname, |
|
267 | + 'ATT_lname' => $lname, |
|
268 | + 'ATT_address' => $address, |
|
269 | + 'ATT_address2' => $address2, |
|
270 | + 'ATT_city' => $city, |
|
271 | + 'STA_ID' => $staid, |
|
272 | + 'CNT_ISO' => $cntry, |
|
273 | + 'ATT_zip' => $zip, |
|
274 | + 'ATT_email' => $email, |
|
275 | + 'ATT_phone' => $phone, |
|
276 | + 'ATT_ID' => $attid |
|
277 | + ) |
|
278 | + ); |
|
279 | + } |
|
280 | + |
|
281 | + return $attendees; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | - /** |
|
286 | - * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
287 | - * This will be used in our dummy data setup |
|
288 | - * @return array |
|
289 | - */ |
|
290 | - private function _get_some_q_and_as() |
|
291 | - { |
|
292 | - |
|
293 | - |
|
294 | - $quests_array = array( |
|
295 | - 0 => array( |
|
296 | - 555, |
|
297 | - __('What is your favorite planet?', 'event_espresso'), |
|
298 | - 0 |
|
299 | - ), |
|
300 | - 1 => array( |
|
301 | - 556, |
|
302 | - __('What is your favorite food?', 'event_espresso'), |
|
303 | - 0 |
|
304 | - ), |
|
305 | - 2 => array( |
|
306 | - 557, |
|
307 | - __('How many lightyears have you travelled', 'event_espresso'), |
|
308 | - 0 |
|
309 | - ) |
|
310 | - ); |
|
311 | - |
|
312 | - |
|
313 | - $ans_array = array( |
|
314 | - 0 => array( |
|
315 | - 999, |
|
316 | - 555, |
|
317 | - 'Tattoine' |
|
318 | - ), |
|
319 | - 1 => array( |
|
320 | - 1000, |
|
321 | - 555, |
|
322 | - 'Alderaan' |
|
323 | - ), |
|
324 | - 2 => array( |
|
325 | - 1001, |
|
326 | - 555, |
|
327 | - 'Dantooine' |
|
328 | - ), |
|
329 | - 3 => array( |
|
330 | - 1002, |
|
331 | - 556, |
|
332 | - 'Fish Fingers' |
|
333 | - ), |
|
334 | - 4 => array( |
|
335 | - 1003, |
|
336 | - 556, |
|
337 | - 'Sushi' |
|
338 | - ), |
|
339 | - 5 => array( |
|
340 | - 1004, |
|
341 | - 556, |
|
342 | - 'Water' |
|
343 | - ), |
|
344 | - 6 => array( |
|
345 | - 1005, |
|
346 | - 557, |
|
347 | - 'A lot', |
|
348 | - ), |
|
349 | - 7 => array( |
|
350 | - 1006, |
|
351 | - 557, |
|
352 | - "That's none of your business." |
|
353 | - ), |
|
354 | - 8 => array( |
|
355 | - 1007, |
|
356 | - 557, |
|
357 | - "People less travel me then." |
|
358 | - ) |
|
359 | - ); |
|
360 | - |
|
361 | - $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
362 | - $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
363 | - |
|
364 | - // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
365 | - // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
366 | - |
|
367 | - $qsts = array(); |
|
368 | - // first the questions |
|
369 | - foreach ($quests_array as $qst) { |
|
370 | - $qstobj = array_combine($qst_columns, $qst); |
|
371 | - $qsts[ $qstobj['QST_ID'] ] = EE_Question::new_instance($qstobj); |
|
372 | - } |
|
373 | - |
|
374 | - // now the answers (and we'll setup our arrays) |
|
375 | - $q_n_as = array(); |
|
376 | - foreach ($ans_array as $ans) { |
|
377 | - $ansobj = array_combine($ans_columns, $ans); |
|
378 | - $ansobj = EE_Answer::new_instance($ansobj); |
|
379 | - $q_n_as['answers'][ $ansobj->ID() ] = $ansobj; |
|
380 | - $q_n_as['questions'][ $ansobj->ID() ] = $qsts[ $ansobj->get('QST_ID') ]; |
|
381 | - } |
|
382 | - |
|
383 | - return $q_n_as; |
|
384 | - } |
|
285 | + /** |
|
286 | + * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
287 | + * This will be used in our dummy data setup |
|
288 | + * @return array |
|
289 | + */ |
|
290 | + private function _get_some_q_and_as() |
|
291 | + { |
|
292 | + |
|
293 | + |
|
294 | + $quests_array = array( |
|
295 | + 0 => array( |
|
296 | + 555, |
|
297 | + __('What is your favorite planet?', 'event_espresso'), |
|
298 | + 0 |
|
299 | + ), |
|
300 | + 1 => array( |
|
301 | + 556, |
|
302 | + __('What is your favorite food?', 'event_espresso'), |
|
303 | + 0 |
|
304 | + ), |
|
305 | + 2 => array( |
|
306 | + 557, |
|
307 | + __('How many lightyears have you travelled', 'event_espresso'), |
|
308 | + 0 |
|
309 | + ) |
|
310 | + ); |
|
311 | + |
|
312 | + |
|
313 | + $ans_array = array( |
|
314 | + 0 => array( |
|
315 | + 999, |
|
316 | + 555, |
|
317 | + 'Tattoine' |
|
318 | + ), |
|
319 | + 1 => array( |
|
320 | + 1000, |
|
321 | + 555, |
|
322 | + 'Alderaan' |
|
323 | + ), |
|
324 | + 2 => array( |
|
325 | + 1001, |
|
326 | + 555, |
|
327 | + 'Dantooine' |
|
328 | + ), |
|
329 | + 3 => array( |
|
330 | + 1002, |
|
331 | + 556, |
|
332 | + 'Fish Fingers' |
|
333 | + ), |
|
334 | + 4 => array( |
|
335 | + 1003, |
|
336 | + 556, |
|
337 | + 'Sushi' |
|
338 | + ), |
|
339 | + 5 => array( |
|
340 | + 1004, |
|
341 | + 556, |
|
342 | + 'Water' |
|
343 | + ), |
|
344 | + 6 => array( |
|
345 | + 1005, |
|
346 | + 557, |
|
347 | + 'A lot', |
|
348 | + ), |
|
349 | + 7 => array( |
|
350 | + 1006, |
|
351 | + 557, |
|
352 | + "That's none of your business." |
|
353 | + ), |
|
354 | + 8 => array( |
|
355 | + 1007, |
|
356 | + 557, |
|
357 | + "People less travel me then." |
|
358 | + ) |
|
359 | + ); |
|
360 | + |
|
361 | + $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
362 | + $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
363 | + |
|
364 | + // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
365 | + // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
366 | + |
|
367 | + $qsts = array(); |
|
368 | + // first the questions |
|
369 | + foreach ($quests_array as $qst) { |
|
370 | + $qstobj = array_combine($qst_columns, $qst); |
|
371 | + $qsts[ $qstobj['QST_ID'] ] = EE_Question::new_instance($qstobj); |
|
372 | + } |
|
373 | + |
|
374 | + // now the answers (and we'll setup our arrays) |
|
375 | + $q_n_as = array(); |
|
376 | + foreach ($ans_array as $ans) { |
|
377 | + $ansobj = array_combine($ans_columns, $ans); |
|
378 | + $ansobj = EE_Answer::new_instance($ansobj); |
|
379 | + $q_n_as['answers'][ $ansobj->ID() ] = $ansobj; |
|
380 | + $q_n_as['questions'][ $ansobj->ID() ] = $qsts[ $ansobj->get('QST_ID') ]; |
|
381 | + } |
|
382 | + |
|
383 | + return $q_n_as; |
|
384 | + } |
|
385 | 385 | |
386 | 386 | |
387 | - /** |
|
388 | - * Return an array of event objects from the database |
|
389 | - * |
|
390 | - * If event ids are not included then we'll just retrieve the first published event from the database. |
|
391 | - * |
|
392 | - * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
393 | - * |
|
394 | - * @return array An array of event objects from the db. |
|
395 | - */ |
|
396 | - private function _get_some_events($event_ids = array()) |
|
397 | - { |
|
398 | - |
|
399 | - // HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed); |
|
400 | - $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
401 | - ? array($_REQUEST['evt_id']) |
|
402 | - : $event_ids; |
|
403 | - |
|
404 | - $limit = ! empty($event_ids) |
|
405 | - ? null |
|
406 | - : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
407 | - |
|
408 | - $where = ! empty($event_ids) |
|
409 | - ? array( |
|
410 | - 'EVT_ID' => array('IN', $event_ids), |
|
411 | - 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
412 | - ) |
|
413 | - : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
414 | - |
|
415 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
416 | - |
|
417 | - return $events; |
|
418 | - } |
|
387 | + /** |
|
388 | + * Return an array of event objects from the database |
|
389 | + * |
|
390 | + * If event ids are not included then we'll just retrieve the first published event from the database. |
|
391 | + * |
|
392 | + * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
393 | + * |
|
394 | + * @return array An array of event objects from the db. |
|
395 | + */ |
|
396 | + private function _get_some_events($event_ids = array()) |
|
397 | + { |
|
398 | + |
|
399 | + // HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed); |
|
400 | + $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
401 | + ? array($_REQUEST['evt_id']) |
|
402 | + : $event_ids; |
|
403 | + |
|
404 | + $limit = ! empty($event_ids) |
|
405 | + ? null |
|
406 | + : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
407 | + |
|
408 | + $where = ! empty($event_ids) |
|
409 | + ? array( |
|
410 | + 'EVT_ID' => array('IN', $event_ids), |
|
411 | + 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
412 | + ) |
|
413 | + : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
414 | + |
|
415 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
416 | + |
|
417 | + return $events; |
|
418 | + } |
|
419 | 419 | |
420 | 420 | |
421 | - protected function _setup_data() |
|
422 | - { |
|
423 | - |
|
424 | - // need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
425 | - if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
426 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
427 | - $session = EE_Registry::instance()->SSN; |
|
428 | - } else { |
|
429 | - $session = EE_Registry::instance()->load_core('Session'); |
|
430 | - } |
|
431 | - $cart = EE_Cart::instance(null, $session); |
|
432 | - |
|
433 | - |
|
434 | - // add tickets to cart |
|
435 | - foreach ($this->tickets as $ticket) { |
|
436 | - $cart->add_ticket_to_cart($ticket['ticket']); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - // setup txn property |
|
441 | - $this->txn = EE_Transaction::new_instance( |
|
442 | - array( |
|
443 | - 'TXN_timestamp' => time(), // unix timestamp |
|
444 | - 'TXN_total' => 0, // txn_total |
|
445 | - 'TXN_paid' => 0, // txn_paid |
|
446 | - 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
447 | - 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
448 | - 'TXN_hash_salt' => null, // hash salt blank as well |
|
449 | - 'TXN_ID' => 999999 |
|
450 | - ) |
|
451 | - ); |
|
452 | - |
|
453 | - |
|
454 | - // setup reg_objects |
|
455 | - // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
456 | - $this->reg_objs = array(); |
|
457 | - $regid = 9999990; |
|
458 | - foreach ($this->_attendees as $key => $attendee) { |
|
459 | - // note we need to setup reg_objects for each event this attendee belongs to |
|
460 | - $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
461 | - $regtxn = $this->txn->ID(); |
|
462 | - $regcnt = 1; |
|
463 | - foreach ($attendee['line_ref'] as $evtid) { |
|
464 | - foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
465 | - if (! $ticket instanceof EE_Ticket) { |
|
466 | - continue; |
|
467 | - } |
|
468 | - $reg_array = array( |
|
469 | - 'EVT_ID' => $evtid, |
|
470 | - 'ATT_ID' => $regatt, |
|
471 | - 'TXN_ID' => $regtxn, |
|
472 | - 'TKT_ID' => $ticket->ID(), |
|
473 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
474 | - 'REG_date' => time(), |
|
475 | - 'REG_final_price' => $ticket->get('TKT_price'), |
|
476 | - 'REG_session' => 'dummy_session_id', |
|
477 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
478 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
479 | - 'REG_count' => $regcnt, |
|
480 | - 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
481 | - 'REG_att_is_going' => true, |
|
482 | - 'REG_ID' => $regid |
|
483 | - ); |
|
484 | - $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
485 | - $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
486 | - $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
487 | - $this->reg_objs[] = $REG_OBJ; |
|
488 | - $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
421 | + protected function _setup_data() |
|
422 | + { |
|
423 | + |
|
424 | + // need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
425 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
426 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
427 | + $session = EE_Registry::instance()->SSN; |
|
428 | + } else { |
|
429 | + $session = EE_Registry::instance()->load_core('Session'); |
|
430 | + } |
|
431 | + $cart = EE_Cart::instance(null, $session); |
|
432 | + |
|
433 | + |
|
434 | + // add tickets to cart |
|
435 | + foreach ($this->tickets as $ticket) { |
|
436 | + $cart->add_ticket_to_cart($ticket['ticket']); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + // setup txn property |
|
441 | + $this->txn = EE_Transaction::new_instance( |
|
442 | + array( |
|
443 | + 'TXN_timestamp' => time(), // unix timestamp |
|
444 | + 'TXN_total' => 0, // txn_total |
|
445 | + 'TXN_paid' => 0, // txn_paid |
|
446 | + 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
447 | + 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
448 | + 'TXN_hash_salt' => null, // hash salt blank as well |
|
449 | + 'TXN_ID' => 999999 |
|
450 | + ) |
|
451 | + ); |
|
452 | + |
|
453 | + |
|
454 | + // setup reg_objects |
|
455 | + // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
456 | + $this->reg_objs = array(); |
|
457 | + $regid = 9999990; |
|
458 | + foreach ($this->_attendees as $key => $attendee) { |
|
459 | + // note we need to setup reg_objects for each event this attendee belongs to |
|
460 | + $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
461 | + $regtxn = $this->txn->ID(); |
|
462 | + $regcnt = 1; |
|
463 | + foreach ($attendee['line_ref'] as $evtid) { |
|
464 | + foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
465 | + if (! $ticket instanceof EE_Ticket) { |
|
466 | + continue; |
|
467 | + } |
|
468 | + $reg_array = array( |
|
469 | + 'EVT_ID' => $evtid, |
|
470 | + 'ATT_ID' => $regatt, |
|
471 | + 'TXN_ID' => $regtxn, |
|
472 | + 'TKT_ID' => $ticket->ID(), |
|
473 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
474 | + 'REG_date' => time(), |
|
475 | + 'REG_final_price' => $ticket->get('TKT_price'), |
|
476 | + 'REG_session' => 'dummy_session_id', |
|
477 | + 'REG_code' => $regid . '-dummy-generated-code', |
|
478 | + 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
479 | + 'REG_count' => $regcnt, |
|
480 | + 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
481 | + 'REG_att_is_going' => true, |
|
482 | + 'REG_ID' => $regid |
|
483 | + ); |
|
484 | + $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
485 | + $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
486 | + $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
487 | + $this->reg_objs[] = $REG_OBJ; |
|
488 | + $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
489 | 489 | |
490 | - $regcnt++; |
|
491 | - $regid++; |
|
492 | - } |
|
493 | - } |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - // setup line items! |
|
498 | - $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
499 | - |
|
500 | - // add tickets |
|
501 | - foreach ($this->tickets as $tktid => $item) { |
|
502 | - $qty = $item['count']; |
|
503 | - $ticket = $item['ticket']; |
|
504 | - EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
505 | - } |
|
506 | - |
|
507 | - $shipping_line_item = EE_Line_Item::new_instance(array( |
|
508 | - 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
509 | - 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
510 | - 'LIN_unit_price' => 20, |
|
511 | - 'LIN_quantity' => 1, |
|
512 | - 'LIN_is_taxable' => true, |
|
513 | - 'LIN_total' => 20, |
|
514 | - 'LIN_type' => EEM_Line_Item::type_line_item |
|
515 | - )); |
|
516 | - EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
517 | - $this->additional_line_items = array($shipping_line_item); |
|
518 | - |
|
519 | - // now let's add taxes |
|
520 | - EEH_Line_Item::apply_taxes($line_item_total); |
|
521 | - |
|
522 | - // now we should be able to get the items we need from this object |
|
523 | - $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
524 | - $line_items = array(); |
|
525 | - foreach ($event_line_items as $line_id => $line_item) { |
|
526 | - if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
527 | - continue; |
|
528 | - } |
|
529 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
530 | - foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
531 | - if (! $ticket_line_item instanceof EE_Line_Item) { |
|
532 | - continue; |
|
533 | - } |
|
534 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
535 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
536 | - $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
537 | - $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
538 | - } |
|
539 | - } |
|
540 | - |
|
541 | - $this->line_items_with_children = $line_items; |
|
542 | - $this->tax_line_items = $line_item_total->tax_descendants(); |
|
543 | - |
|
544 | - // add proper total to transaction object. |
|
545 | - $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
546 | - $this->grand_total_line_item = $line_item_total; |
|
547 | - $this->txn->set_total($grand_total); |
|
548 | - |
|
549 | - |
|
550 | - // add additional details for each registration |
|
551 | - foreach ($this->reg_objs as $reg) { |
|
552 | - if (! $reg instanceof EE_Registration) { |
|
553 | - continue; |
|
554 | - } |
|
555 | - $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
556 | - $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
557 | - $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
558 | - $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
559 | - $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
560 | - $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
561 | - } |
|
562 | - |
|
563 | - |
|
564 | - // events and attendees |
|
565 | - $this->events = $this->_events; |
|
566 | - $this->attendees = $this->_attendees; |
|
567 | - $this->registrations = $this->_registrations; |
|
568 | - |
|
569 | - $attendees_to_shift = $this->_attendees; |
|
570 | - |
|
571 | - // setup primary attendee property |
|
572 | - $this->primary_attendee_data = array( |
|
573 | - 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
574 | - ? $this->_attendees[999999991]['att_obj']->fname() |
|
575 | - : '', |
|
490 | + $regcnt++; |
|
491 | + $regid++; |
|
492 | + } |
|
493 | + } |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + // setup line items! |
|
498 | + $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
499 | + |
|
500 | + // add tickets |
|
501 | + foreach ($this->tickets as $tktid => $item) { |
|
502 | + $qty = $item['count']; |
|
503 | + $ticket = $item['ticket']; |
|
504 | + EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
505 | + } |
|
506 | + |
|
507 | + $shipping_line_item = EE_Line_Item::new_instance(array( |
|
508 | + 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
509 | + 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
510 | + 'LIN_unit_price' => 20, |
|
511 | + 'LIN_quantity' => 1, |
|
512 | + 'LIN_is_taxable' => true, |
|
513 | + 'LIN_total' => 20, |
|
514 | + 'LIN_type' => EEM_Line_Item::type_line_item |
|
515 | + )); |
|
516 | + EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
517 | + $this->additional_line_items = array($shipping_line_item); |
|
518 | + |
|
519 | + // now let's add taxes |
|
520 | + EEH_Line_Item::apply_taxes($line_item_total); |
|
521 | + |
|
522 | + // now we should be able to get the items we need from this object |
|
523 | + $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
524 | + $line_items = array(); |
|
525 | + foreach ($event_line_items as $line_id => $line_item) { |
|
526 | + if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
527 | + continue; |
|
528 | + } |
|
529 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
530 | + foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
531 | + if (! $ticket_line_item instanceof EE_Line_Item) { |
|
532 | + continue; |
|
533 | + } |
|
534 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
535 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
536 | + $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
537 | + $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
538 | + } |
|
539 | + } |
|
540 | + |
|
541 | + $this->line_items_with_children = $line_items; |
|
542 | + $this->tax_line_items = $line_item_total->tax_descendants(); |
|
543 | + |
|
544 | + // add proper total to transaction object. |
|
545 | + $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
546 | + $this->grand_total_line_item = $line_item_total; |
|
547 | + $this->txn->set_total($grand_total); |
|
548 | + |
|
549 | + |
|
550 | + // add additional details for each registration |
|
551 | + foreach ($this->reg_objs as $reg) { |
|
552 | + if (! $reg instanceof EE_Registration) { |
|
553 | + continue; |
|
554 | + } |
|
555 | + $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
556 | + $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
557 | + $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
558 | + $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
559 | + $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
560 | + $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
561 | + } |
|
562 | + |
|
563 | + |
|
564 | + // events and attendees |
|
565 | + $this->events = $this->_events; |
|
566 | + $this->attendees = $this->_attendees; |
|
567 | + $this->registrations = $this->_registrations; |
|
568 | + |
|
569 | + $attendees_to_shift = $this->_attendees; |
|
570 | + |
|
571 | + // setup primary attendee property |
|
572 | + $this->primary_attendee_data = array( |
|
573 | + 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
574 | + ? $this->_attendees[999999991]['att_obj']->fname() |
|
575 | + : '', |
|
576 | 576 | |
577 | - 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
578 | - ? $this->_attendees[999999991]['att_obj']->lname() |
|
579 | - : '', |
|
577 | + 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
578 | + ? $this->_attendees[999999991]['att_obj']->lname() |
|
579 | + : '', |
|
580 | 580 | |
581 | - 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
582 | - ? $this->_attendees[999999991]['att_obj']->email() |
|
583 | - : '', |
|
581 | + 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
582 | + ? $this->_attendees[999999991]['att_obj']->email() |
|
583 | + : '', |
|
584 | 584 | |
585 | - 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
585 | + 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
586 | 586 | |
587 | - 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
588 | - ); |
|
587 | + 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
588 | + ); |
|
589 | 589 | |
590 | - // reg_info property |
|
591 | - // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
592 | - $this->reg_info = array(); |
|
590 | + // reg_info property |
|
591 | + // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
592 | + $this->reg_info = array(); |
|
593 | 593 | |
594 | - // let's set a reg_obj for messengers expecting one. |
|
595 | - $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']); |
|
594 | + // let's set a reg_obj for messengers expecting one. |
|
595 | + $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']); |
|
596 | 596 | |
597 | 597 | |
598 | - // the below are just dummy items. |
|
599 | - $this->user_id = 1; |
|
600 | - $this->ip_address = '192.0.2.1'; |
|
601 | - $this->user_agent = ''; |
|
602 | - $this->init_access = time(); |
|
603 | - $this->last_access = time(); |
|
604 | - } |
|
598 | + // the below are just dummy items. |
|
599 | + $this->user_id = 1; |
|
600 | + $this->ip_address = '192.0.2.1'; |
|
601 | + $this->user_agent = ''; |
|
602 | + $this->init_access = time(); |
|
603 | + $this->last_access = time(); |
|
604 | + } |
|
605 | 605 | } |
@@ -98,71 +98,71 @@ discard block |
||
98 | 98 | // we'll actually use the generated line_item identifiers for our loop |
99 | 99 | $dtts = $tkts = array(); |
100 | 100 | foreach ($events as $id => $event) { |
101 | - if (! $event instanceof EE_Event) { |
|
101 | + if ( ! $event instanceof EE_Event) { |
|
102 | 102 | continue; |
103 | 103 | } |
104 | - $this->_events[ $id ]['ID'] = $id; |
|
105 | - $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
104 | + $this->_events[$id]['ID'] = $id; |
|
105 | + $this->_events[$id]['name'] = $event->get('EVT_name'); |
|
106 | 106 | $datetime = $event->get_first_related('Datetime'); |
107 | 107 | $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
108 | 108 | 'Ticket', |
109 | 109 | array('default_where_conditions' => 'none') |
110 | 110 | ) : array(); |
111 | - $this->_events[ $id ]['event'] = $event; |
|
112 | - $this->_events[ $id ]['reg_objs'] = array(); |
|
113 | - $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
114 | - $this->_events[ $id ]['dtt_objs'] = array(); |
|
111 | + $this->_events[$id]['event'] = $event; |
|
112 | + $this->_events[$id]['reg_objs'] = array(); |
|
113 | + $this->_events[$id]['tkt_objs'] = $tickets; |
|
114 | + $this->_events[$id]['dtt_objs'] = array(); |
|
115 | 115 | |
116 | 116 | $dttcache = array(); |
117 | 117 | $tkts = array(); |
118 | 118 | foreach ($tickets as $ticket) { |
119 | - if (! $ticket instanceof EE_Ticket) { |
|
119 | + if ( ! $ticket instanceof EE_Ticket) { |
|
120 | 120 | continue; |
121 | 121 | } |
122 | - $reldatetime = $ticket->datetimes(); |
|
123 | - $tkts[ $ticket->ID() ] = array(); |
|
124 | - $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
125 | - $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
126 | - $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
127 | - $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
128 | - $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
122 | + $reldatetime = $ticket->datetimes(); |
|
123 | + $tkts[$ticket->ID()] = array(); |
|
124 | + $tkts[$ticket->ID()]['ticket'] = $ticket; |
|
125 | + $tkts[$ticket->ID()]['dtt_objs'] = $reldatetime; |
|
126 | + $tkts[$ticket->ID()]['att_objs'] = $attendees; |
|
127 | + $tkts[$ticket->ID()]['count'] = count($attendees); |
|
128 | + $tkts[$ticket->ID()]['EE_Event'] = $event; |
|
129 | 129 | foreach ($reldatetime as $datetime) { |
130 | - if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
131 | - $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
132 | - $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
133 | - $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
134 | - $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
135 | - $dttcache[ $datetime->ID() ] = $datetime; |
|
130 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) { |
|
131 | + $this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime; |
|
132 | + $dtts[$datetime->ID()]['datetime'] = $datetime; |
|
133 | + $dtts[$datetime->ID()]['tkt_objs'][] = $ticket; |
|
134 | + $dtts[$datetime->ID()]['evt_objs'][] = $event; |
|
135 | + $dttcache[$datetime->ID()] = $datetime; |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
141 | - $this->_events[ $id ]['att_objs'] = $attendees; |
|
140 | + $this->_events[$id]['total_attendees'] = count($attendees); |
|
141 | + $this->_events[$id]['att_objs'] = $attendees; |
|
142 | 142 | |
143 | 143 | // let's also setup the dummy attendees property! |
144 | 144 | foreach ($attendees as $att_key => $attendee) { |
145 | - if (! $attendee instanceof EE_Attendee) { |
|
145 | + if ( ! $attendee instanceof EE_Attendee) { |
|
146 | 146 | continue; |
147 | 147 | } |
148 | - $this->_attendees[ $att_key ]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
149 | - $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
150 | - $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
148 | + $this->_attendees[$att_key]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
149 | + $this->_attendees[$att_key]['evt_objs'][] = $event; |
|
150 | + $this->_attendees[$att_key]['att_obj'] = $attendee; |
|
151 | 151 | // $this->_attendees[$att_key]['registration_id'] = 0; |
152 | - $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
153 | - $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
152 | + $this->_attendees[$att_key]['attendee_email'] = $attendee->email(); |
|
153 | + $this->_attendees[$att_key]['tkt_objs'] = $tickets; |
|
154 | 154 | if ($att_key == 999999991) { |
155 | - $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | - $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | - $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
155 | + $this->_attendees[$att_key]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | + $this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | + $this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
158 | 158 | } elseif ($att_key == 999999992) { |
159 | - $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | - $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | - $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
159 | + $this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | + $this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | + $this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
162 | 162 | } elseif ($att_key == 999999993) { |
163 | - $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | - $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | - $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
163 | + $this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | + $this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | + $this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | /** @var $email string */ |
262 | 262 | /** @var $phone string */ |
263 | 263 | /** @var $attid string */ |
264 | - $attendees[ $attid ] = EE_Attendee::new_instance( |
|
264 | + $attendees[$attid] = EE_Attendee::new_instance( |
|
265 | 265 | array( |
266 | 266 | 'ATT_fname' => $fname, |
267 | 267 | 'ATT_lname' => $lname, |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | $qsts = array(); |
368 | 368 | // first the questions |
369 | 369 | foreach ($quests_array as $qst) { |
370 | - $qstobj = array_combine($qst_columns, $qst); |
|
371 | - $qsts[ $qstobj['QST_ID'] ] = EE_Question::new_instance($qstobj); |
|
370 | + $qstobj = array_combine($qst_columns, $qst); |
|
371 | + $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | // now the answers (and we'll setup our arrays) |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | foreach ($ans_array as $ans) { |
377 | 377 | $ansobj = array_combine($ans_columns, $ans); |
378 | 378 | $ansobj = EE_Answer::new_instance($ansobj); |
379 | - $q_n_as['answers'][ $ansobj->ID() ] = $ansobj; |
|
380 | - $q_n_as['questions'][ $ansobj->ID() ] = $qsts[ $ansobj->get('QST_ID') ]; |
|
379 | + $q_n_as['answers'][$ansobj->ID()] = $ansobj; |
|
380 | + $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')]; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $q_n_as; |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | $regtxn = $this->txn->ID(); |
462 | 462 | $regcnt = 1; |
463 | 463 | foreach ($attendee['line_ref'] as $evtid) { |
464 | - foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
465 | - if (! $ticket instanceof EE_Ticket) { |
|
464 | + foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) { |
|
465 | + if ( ! $ticket instanceof EE_Ticket) { |
|
466 | 466 | continue; |
467 | 467 | } |
468 | - $reg_array = array( |
|
468 | + $reg_array = array( |
|
469 | 469 | 'EVT_ID' => $evtid, |
470 | 470 | 'ATT_ID' => $regatt, |
471 | 471 | 'TXN_ID' => $regtxn, |
@@ -474,18 +474,18 @@ discard block |
||
474 | 474 | 'REG_date' => time(), |
475 | 475 | 'REG_final_price' => $ticket->get('TKT_price'), |
476 | 476 | 'REG_session' => 'dummy_session_id', |
477 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
478 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
477 | + 'REG_code' => $regid.'-dummy-generated-code', |
|
478 | + 'REG_url_link' => $regcnt.'-daafpapasdlfakasdfpqasdfasdf', |
|
479 | 479 | 'REG_count' => $regcnt, |
480 | - 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
480 | + 'REG_group_size' => $this->_events[$evtid]['total_attendees'], |
|
481 | 481 | 'REG_att_is_going' => true, |
482 | 482 | 'REG_ID' => $regid |
483 | 483 | ); |
484 | 484 | $REG_OBJ = EE_Registration::new_instance($reg_array); |
485 | - $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
486 | - $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
485 | + $this->_attendees[$key]['reg_objs'][$regid] = $REG_OBJ; |
|
486 | + $this->_events[$evtid]['reg_objs'][] = $REG_OBJ; |
|
487 | 487 | $this->reg_objs[] = $REG_OBJ; |
488 | - $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
488 | + $this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ; |
|
489 | 489 | |
490 | 490 | $regcnt++; |
491 | 491 | $regid++; |
@@ -523,18 +523,18 @@ discard block |
||
523 | 523 | $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
524 | 524 | $line_items = array(); |
525 | 525 | foreach ($event_line_items as $line_id => $line_item) { |
526 | - if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
526 | + if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
527 | 527 | continue; |
528 | 528 | } |
529 | 529 | $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
530 | 530 | foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
531 | - if (! $ticket_line_item instanceof EE_Line_Item) { |
|
531 | + if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
532 | 532 | continue; |
533 | 533 | } |
534 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
535 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
536 | - $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
537 | - $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
534 | + $this->tickets[$ticket_line_item->OBJ_ID()]['line_item'] = $ticket_line_item; |
|
535 | + $this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children(); |
|
536 | + $line_items[$ticket_line_item->ID()]['children'] = $ticket_line_item->children(); |
|
537 | + $line_items[$ticket_line_item->ID()]['EE_Ticket'] = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket']; |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | |
@@ -549,15 +549,15 @@ discard block |
||
549 | 549 | |
550 | 550 | // add additional details for each registration |
551 | 551 | foreach ($this->reg_objs as $reg) { |
552 | - if (! $reg instanceof EE_Registration) { |
|
552 | + if ( ! $reg instanceof EE_Registration) { |
|
553 | 553 | continue; |
554 | 554 | } |
555 | - $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
556 | - $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
557 | - $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
558 | - $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
559 | - $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
560 | - $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
555 | + $this->_registrations[$reg->ID()]['tkt_obj'] = $this->tickets[$reg->get('TKT_ID')]['ticket']; |
|
556 | + $this->_registrations[$reg->ID()]['evt_obj'] = $this->_events[$reg->get('EVT_ID')]['event']; |
|
557 | + $this->_registrations[$reg->ID()]['reg_obj'] = $reg; |
|
558 | + $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs']; |
|
559 | + $this->_registrations[$reg->ID()]['att_obj'] = $this->_attendees[$reg->get('ATT_ID')]['att_obj']; |
|
560 | + $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs']; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 |
@@ -18,518 +18,518 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * user id for logged in user when data collected |
|
23 | - * |
|
24 | - * @var string $user_id |
|
25 | - */ |
|
26 | - public $user_id; |
|
27 | - |
|
28 | - /** |
|
29 | - * IP Address of browser used |
|
30 | - * |
|
31 | - * @var string $ip_address |
|
32 | - */ |
|
33 | - public $ip_address; |
|
34 | - |
|
35 | - /** |
|
36 | - * browser |
|
37 | - * |
|
38 | - * @var string $user_agent |
|
39 | - */ |
|
40 | - public $user_agent; |
|
41 | - |
|
42 | - /** |
|
43 | - * Unix timestamp |
|
44 | - * |
|
45 | - * @var string $init_access |
|
46 | - */ |
|
47 | - public $init_access; |
|
48 | - |
|
49 | - /** |
|
50 | - * Unix timestamp |
|
51 | - * |
|
52 | - * @var string $last_access |
|
53 | - */ |
|
54 | - public $last_access; |
|
55 | - |
|
56 | - /** |
|
57 | - * The registrations details from the cart |
|
58 | - * |
|
59 | - * @var array $reg_info |
|
60 | - */ |
|
61 | - public $reg_info; |
|
62 | - |
|
63 | - /** |
|
64 | - * Some data handlers can set what reg status all the registrations are filtered by. |
|
65 | - * The status should match a EEM_Registration status constant. |
|
66 | - * |
|
67 | - * @var string $filtered_reg_status |
|
68 | - */ |
|
69 | - public $filtered_reg_status; |
|
70 | - |
|
71 | - /** |
|
72 | - * will hold an array of events assembled from $reg_info |
|
73 | - * |
|
74 | - * @var EE_Event[] $events |
|
75 | - */ |
|
76 | - public $events; |
|
77 | - |
|
78 | - /** |
|
79 | - * holds an array of datetimes assembled from the incoming data. |
|
80 | - * |
|
81 | - * @var EE_Datetime[] $datetimes |
|
82 | - */ |
|
83 | - public $datetimes; |
|
84 | - |
|
85 | - /** |
|
86 | - * holds an array of tickets assembled from the incoming data. |
|
87 | - * |
|
88 | - * @var EE_Ticket[] $tickets |
|
89 | - */ |
|
90 | - public $tickets; |
|
91 | - |
|
92 | - /** |
|
93 | - * holds an array with a key of parent line item and values are an array of children of that line item. |
|
94 | - * |
|
95 | - * @since 4.5.0 |
|
96 | - * @var EE_Line_Item[] $line_items_with_children |
|
97 | - */ |
|
98 | - public $line_items_with_children; |
|
99 | - |
|
100 | - /** |
|
101 | - * will hold an array of attendees assembled from the $reg_info |
|
102 | - * |
|
103 | - * @var EE_Attendee[] $attendees |
|
104 | - */ |
|
105 | - public $attendees; |
|
106 | - |
|
107 | - /** |
|
108 | - * will hold an array of cached registration objects and info assembled from reg_info |
|
109 | - * |
|
110 | - * @var array $registrations |
|
111 | - */ |
|
112 | - public $registrations; |
|
113 | - |
|
114 | - /** |
|
115 | - * will hold an array of answers assembled from the $reg_info |
|
116 | - * |
|
117 | - * @var EE_Answer[] $answers |
|
118 | - */ |
|
119 | - public $answers; |
|
120 | - |
|
121 | - /** |
|
122 | - * will hold an array of questions assembled from the $reg_info (indexed by Answer ID); |
|
123 | - * |
|
124 | - * @var EE_Question[] $questions |
|
125 | - */ |
|
126 | - public $questions; |
|
127 | - |
|
128 | - /** |
|
129 | - * Will hold billing data assembled from $billing_info (if present) |
|
130 | - * |
|
131 | - * @var mixed (array|null) $billing |
|
132 | - */ |
|
133 | - public $billing; |
|
134 | - |
|
135 | - /** |
|
136 | - * The total amount of tax for the transaction |
|
137 | - * |
|
138 | - * @var float $taxes |
|
139 | - */ |
|
140 | - public $taxes; |
|
141 | - |
|
142 | - /** |
|
143 | - * Holds the line items related to taxes |
|
144 | - * |
|
145 | - * @since 4.5.0 |
|
146 | - * @var EE_Line_Item[] $tax_line_items |
|
147 | - */ |
|
148 | - public $tax_line_items; |
|
149 | - |
|
150 | - /** |
|
151 | - * Hold the line items which aren't taxes and don't relate |
|
152 | - * to tickets. So: promotions and miscellaneous charges |
|
153 | - * |
|
154 | - * @since 4.5 |
|
155 | - * @var EE_Line_Item[] $additional_line_items |
|
156 | - */ |
|
157 | - public $additional_line_items; |
|
158 | - |
|
159 | - /** |
|
160 | - * Holds the grand total EE_Line_Item |
|
161 | - * |
|
162 | - * @var EE_Line_Item $grand_total_line_item |
|
163 | - */ |
|
164 | - public $grand_total_line_item; |
|
165 | - |
|
166 | - /** |
|
167 | - * holds the grand total price object |
|
168 | - * currently not used. |
|
169 | - * |
|
170 | - * @var null $grand_total_price_object |
|
171 | - */ |
|
172 | - public $grand_total_price_object; |
|
173 | - |
|
174 | - /** |
|
175 | - * total number of tickets |
|
176 | - * |
|
177 | - * @var int $total_ticket_count |
|
178 | - */ |
|
179 | - public $total_ticket_count; |
|
180 | - |
|
181 | - /** |
|
182 | - * Will hold the final transaction object (EE_Transaction) |
|
183 | - * |
|
184 | - * @var EE_Transaction $txn |
|
185 | - */ |
|
186 | - public $txn; |
|
187 | - |
|
188 | - /** |
|
189 | - * Holds the payments related to a transaction |
|
190 | - * |
|
191 | - * @since 4.5.0 |
|
192 | - * @var EE_Payment[] $payments |
|
193 | - */ |
|
194 | - public $payments; |
|
195 | - |
|
196 | - /** |
|
197 | - * Holds the first related payment related for a transaction |
|
198 | - * |
|
199 | - * @since 4.5.0 |
|
200 | - * @var EE_Payment $payment |
|
201 | - */ |
|
202 | - public $payment; |
|
203 | - |
|
204 | - /** |
|
205 | - * Will hold the label for the txn status |
|
206 | - * |
|
207 | - * @var string $txn_status |
|
208 | - */ |
|
209 | - public $txn_status; |
|
210 | - |
|
211 | - /** |
|
212 | - * Will hold the final registration object (EE_Registration) |
|
213 | - * |
|
214 | - * @var EE_Registration[] $reg_objs |
|
215 | - */ |
|
216 | - public $reg_objs; |
|
217 | - |
|
218 | - /** |
|
219 | - * Will hold an array of primary attendee data (if present) |
|
220 | - * |
|
221 | - * @var array $primary_attendee_data |
|
222 | - */ |
|
223 | - public $primary_attendee_data; |
|
224 | - |
|
225 | - /** |
|
226 | - * This is just an internal object used for passing around the incoming data. |
|
227 | - * |
|
228 | - * @var mixed $_data |
|
229 | - */ |
|
230 | - protected $_data; |
|
231 | - |
|
232 | - /** |
|
233 | - * This is just an internal object used for passing around the incoming data. |
|
234 | - * |
|
235 | - * @var mixed $incoming_data |
|
236 | - */ |
|
237 | - public $incoming_data; |
|
238 | - |
|
239 | - /** |
|
240 | - * hold objects that might be created |
|
241 | - * |
|
242 | - * @type EE_Registration $reg_obj |
|
243 | - */ |
|
244 | - public $reg_obj; |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * constructor |
|
249 | - * |
|
250 | - * @param mixed $data incoming data object|array. Suggested that child classes use type hinting for expected |
|
251 | - * data object. But here parent will be generic because we don't know what's coming in. |
|
252 | - */ |
|
253 | - public function __construct($data) |
|
254 | - { |
|
255 | - $this->_data = $data; |
|
256 | - $this->_setup_data(); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * Every child class has to setup the data object ! |
|
262 | - * |
|
263 | - * @return void |
|
264 | - */ |
|
265 | - abstract protected function _setup_data(); |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
270 | - * |
|
271 | - * @param mixed $data The incoming data to be prepped. |
|
272 | - * @return mixed The prepped data for db |
|
273 | - */ |
|
274 | - public static function convert_data_for_persistent_storage($data) |
|
275 | - { |
|
276 | - return $data; |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - /** |
|
281 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
282 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
283 | - * |
|
284 | - * @param $data |
|
285 | - * @return mixed |
|
286 | - */ |
|
287 | - public static function convert_data_from_persistent_storage($data) |
|
288 | - { |
|
289 | - return $data; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * only purpose is to return the data |
|
295 | - * |
|
296 | - * @access public |
|
297 | - * @return mixed the formatted data object! |
|
298 | - */ |
|
299 | - public function data() |
|
300 | - { |
|
301 | - return $this->_data; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * This helper method can be used by any incoming data handlers to setup the data correctly. All that is required |
|
307 | - * is that $this->reg_objs be set. |
|
308 | - * |
|
309 | - * @throws EE_Error |
|
310 | - * @throws InvalidDataTypeException |
|
311 | - * @throws InvalidInterfaceException |
|
312 | - * @throws InvalidArgumentException |
|
313 | - * @throws EntityNotFoundException |
|
314 | - */ |
|
315 | - protected function _assemble_data() |
|
316 | - { |
|
317 | - // verify that reg_objs is set |
|
318 | - if (! is_array($this->reg_objs) |
|
319 | - && ! reset($this->reg_objs) instanceof EE_Registration |
|
320 | - ) { |
|
321 | - throw new EE_Error( |
|
322 | - esc_html__( |
|
323 | - 'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects', |
|
324 | - 'event_espresso' |
|
325 | - ) |
|
326 | - ); |
|
327 | - } |
|
328 | - |
|
329 | - // get all attendee and events associated with the registrations in this transaction |
|
330 | - $events = $event_setup = $evtcache = $tickets = $datetimes = array(); |
|
331 | - $answers = $questions = $attendees = $line_items = $registrations = array(); |
|
332 | - $total_ticket_count = 0; |
|
333 | - |
|
334 | - if (! empty($this->reg_objs)) { |
|
335 | - $event_attendee_count = array(); |
|
336 | - /** @var EE_Registration $reg */ |
|
337 | - foreach ($this->reg_objs as $reg) { |
|
338 | - if ($this->_skip_registration_for_processing($reg) |
|
339 | - ) { |
|
340 | - continue; |
|
341 | - } |
|
342 | - |
|
343 | - $evt_id = $reg->event_ID(); |
|
344 | - /** @type EE_Ticket $ticket */ |
|
345 | - $ticket = $reg->get_first_related('Ticket'); |
|
346 | - $attendee = $reg->attendee(); |
|
347 | - $event = $reg->event(); |
|
348 | - // if none of the following entities are available, then we can't setup other data reliably, |
|
349 | - // so let's just skip. |
|
350 | - if (! $ticket instanceof EE_Ticket |
|
351 | - || ! $attendee instanceof EE_Attendee |
|
352 | - || ! $event instanceof EE_Event |
|
353 | - ) { |
|
354 | - continue; |
|
355 | - } |
|
356 | - $relateddatetime = $ticket->datetimes(); |
|
357 | - $total_ticket_count++; |
|
358 | - $tickets[ $ticket->ID() ]['ticket'] = $ticket; |
|
359 | - $tickets[ $ticket->ID() ]['count'] = is_array($tickets[ $ticket->ID() ]) |
|
360 | - && isset($tickets[ $ticket->ID() ]['count']) |
|
361 | - ? $tickets[ $ticket->ID() ]['count'] + 1 |
|
362 | - : 1; |
|
363 | - $tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee; |
|
364 | - $tickets[ $ticket->ID() ]['dtt_objs'] = $relateddatetime; |
|
365 | - $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
366 | - $tickets[ $ticket->ID() ]['EE_Event'] = $event; |
|
367 | - $evtcache[ $evt_id ] = $event; |
|
368 | - $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
369 | - $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
370 | - $eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ] = $attendee; |
|
371 | - $event_attendee_count[ $evt_id ] = isset($event_attendee_count[ $evt_id ]) |
|
372 | - ? $event_attendee_count[ $evt_id ] + 1 |
|
373 | - : 0; |
|
374 | - $attendees[ $reg->attendee_ID() ]['line_ref'][] = $evt_id; |
|
375 | - $attendees[ $reg->attendee_ID() ]['att_obj'] = $attendee; |
|
376 | - $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
377 | - // $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID(); |
|
378 | - $attendees[ $reg->attendee_ID() ]['attendee_email'] = $attendee->email(); |
|
379 | - $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
380 | - $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ] = $event; |
|
381 | - |
|
382 | - // registrations |
|
383 | - $registrations[ $reg->ID() ]['tkt_obj'] = $ticket; |
|
384 | - $registrations[ $reg->ID() ]['evt_obj'] = $event; |
|
385 | - $registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
386 | - $registrations[ $reg->ID() ]['att_obj'] = $attendee; |
|
387 | - |
|
388 | - // set up answer objects |
|
389 | - $rel_ans = $reg->get_many_related('Answer'); |
|
390 | - foreach ($rel_ans as $ansid => $answer) { |
|
391 | - if (! isset($questions[ $ansid ])) { |
|
392 | - $questions[ $ansid ] = $answer->get_first_related('Question'); |
|
393 | - } |
|
394 | - $answers[ $ansid ] = $answer; |
|
395 | - $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer; |
|
396 | - } |
|
397 | - /** |
|
398 | - * @var int $dtt_id |
|
399 | - * @var EE_Datetime $datetime |
|
400 | - */ |
|
401 | - foreach ($relateddatetime as $dtt_id => $datetime) { |
|
402 | - $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
403 | - $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
404 | - |
|
405 | - if (isset($datetimes[ $dtt_id ])) { |
|
406 | - continue; // already have this info in the datetimes array. |
|
407 | - } |
|
408 | - |
|
409 | - $datetimes[ $dtt_id ]['tkt_objs'][] = $ticket; |
|
410 | - $datetimes[ $dtt_id ]['datetime'] = $datetime; |
|
411 | - $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ] = $event; |
|
412 | - $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - // let's loop through the unique event=>reg items and setup data on them |
|
417 | - |
|
418 | - if (! empty($eventsetup)) { |
|
419 | - foreach ($eventsetup as $evt_id => $items) { |
|
420 | - $ticket_line_items_for_event = array(); |
|
421 | - if ($this->txn instanceof EE_Transaction) { |
|
422 | - $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all( |
|
423 | - array( |
|
424 | - array( |
|
425 | - 'Ticket.Datetime.EVT_ID' => $evt_id, |
|
426 | - 'TXN_ID' => $this->txn->ID(), |
|
427 | - ), |
|
428 | - 'default_where_conditions' => 'none', |
|
429 | - ) |
|
430 | - ); |
|
431 | - } |
|
432 | - $events[ $evt_id ] = array( |
|
433 | - 'ID' => $evt_id, |
|
434 | - 'event' => $evtcache[ $evt_id ], |
|
435 | - 'name' => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '', |
|
436 | - 'total_attendees' => $event_attendee_count[ $evt_id ], |
|
437 | - 'reg_objs' => $items['reg_objs'], |
|
438 | - 'tkt_objs' => $items['tkt_objs'], |
|
439 | - 'att_objs' => $items['att_objs'], |
|
440 | - 'dtt_objs' => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(), |
|
441 | - 'line_items' => $ticket_line_items_for_event, |
|
442 | - ); |
|
443 | - |
|
444 | - // make sure the tickets have the line items setup for them. |
|
445 | - foreach ($ticket_line_items_for_event as $line_id => $line_item) { |
|
446 | - if ($line_item instanceof EE_Line_Item) { |
|
447 | - $tickets[ $line_item->ticket()->ID() ]['line_item'] = $line_item; |
|
448 | - $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children(); |
|
449 | - $line_items[ $line_item->ID() ]['children'] = $line_item->children(); |
|
450 | - $line_items[ $line_item->ID() ]['EE_Ticket'] = $line_item->ticket(); |
|
451 | - } |
|
452 | - } |
|
453 | - } |
|
454 | - } |
|
455 | - |
|
456 | - $this->grand_total_line_item = $this->txn instanceof EE_Transaction |
|
457 | - ? $this->txn->total_line_item() |
|
458 | - : null; |
|
459 | - } |
|
460 | - |
|
461 | - // lets set the attendees and events properties |
|
462 | - $this->attendees = $attendees; |
|
463 | - $this->events = $events; |
|
464 | - $this->tickets = $tickets; |
|
465 | - $this->line_items_with_children = $line_items; |
|
466 | - $this->datetimes = $datetimes; |
|
467 | - $this->questions = $questions; |
|
468 | - $this->answers = $answers; |
|
469 | - $this->total_ticket_count = $total_ticket_count; |
|
470 | - $this->registrations = $registrations; |
|
471 | - |
|
472 | - if ($this->txn instanceof EE_Transaction) { |
|
473 | - $this->tax_line_items = $this->txn->tax_items(); |
|
474 | - $this->additional_line_items = $this->txn->non_ticket_line_items(); |
|
475 | - $this->payments = $this->txn->payments(); |
|
476 | - |
|
477 | - // setup primary registration if we have a single transaction object to work with |
|
478 | - |
|
479 | - // let's get just the primary_attendee_data! First we get the primary registration object. |
|
480 | - $primary_reg = $this->txn->primary_registration(); |
|
481 | - // verify |
|
482 | - if ($primary_reg instanceof EE_Registration) { |
|
483 | - // get attendee object |
|
484 | - if ($primary_reg->attendee() instanceof EE_Attendee) { |
|
485 | - // now we can setup the primary_attendee_data array |
|
486 | - $this->primary_attendee_data = array( |
|
487 | - 'registration_id' => $primary_reg->ID(), |
|
488 | - 'att_obj' => $primary_reg->attendee(), |
|
489 | - 'reg_obj' => $primary_reg, |
|
490 | - 'primary_att_obj' => $primary_reg->attendee(), |
|
491 | - 'primary_reg_obj' => $primary_reg, |
|
492 | - ); |
|
493 | - } else { |
|
494 | - EE_Error::add_error( |
|
495 | - esc_html__( |
|
496 | - 'Incoming data does not have a valid Attendee object for the primary registrant.', |
|
497 | - 'event_espresso' |
|
498 | - ), |
|
499 | - __FILE__, |
|
500 | - __FUNCTION__, |
|
501 | - __LINE__ |
|
502 | - ); |
|
503 | - } |
|
504 | - } else { |
|
505 | - EE_Error::add_error( |
|
506 | - esc_html__( |
|
507 | - 'Incoming data does not have a valid Registration object for the primary registrant.', |
|
508 | - 'event_espresso' |
|
509 | - ), |
|
510 | - __FILE__, |
|
511 | - __FUNCTION__, |
|
512 | - __LINE__ |
|
513 | - ); |
|
514 | - } |
|
515 | - } |
|
516 | - } |
|
517 | - |
|
518 | - /** |
|
519 | - * This simply considers whether the given registration should be processed or not based on comparison with the |
|
520 | - * filtered_reg_status property. |
|
521 | - * |
|
522 | - * @param EE_Registration $registration |
|
523 | - * @return bool returning true means we DO want to skip processing. returning false means we DON'T want to skip |
|
524 | - * processing |
|
525 | - */ |
|
526 | - protected function _skip_registration_for_processing(EE_Registration $registration) |
|
527 | - { |
|
528 | - if (empty($this->filtered_reg_status)) { |
|
529 | - return false; |
|
530 | - } |
|
531 | - |
|
532 | - // if we made it here then we just compare the filtered_reg_status with the registration status and return that |
|
533 | - return $this->filtered_reg_status !== $registration->status_ID(); |
|
534 | - } |
|
21 | + /** |
|
22 | + * user id for logged in user when data collected |
|
23 | + * |
|
24 | + * @var string $user_id |
|
25 | + */ |
|
26 | + public $user_id; |
|
27 | + |
|
28 | + /** |
|
29 | + * IP Address of browser used |
|
30 | + * |
|
31 | + * @var string $ip_address |
|
32 | + */ |
|
33 | + public $ip_address; |
|
34 | + |
|
35 | + /** |
|
36 | + * browser |
|
37 | + * |
|
38 | + * @var string $user_agent |
|
39 | + */ |
|
40 | + public $user_agent; |
|
41 | + |
|
42 | + /** |
|
43 | + * Unix timestamp |
|
44 | + * |
|
45 | + * @var string $init_access |
|
46 | + */ |
|
47 | + public $init_access; |
|
48 | + |
|
49 | + /** |
|
50 | + * Unix timestamp |
|
51 | + * |
|
52 | + * @var string $last_access |
|
53 | + */ |
|
54 | + public $last_access; |
|
55 | + |
|
56 | + /** |
|
57 | + * The registrations details from the cart |
|
58 | + * |
|
59 | + * @var array $reg_info |
|
60 | + */ |
|
61 | + public $reg_info; |
|
62 | + |
|
63 | + /** |
|
64 | + * Some data handlers can set what reg status all the registrations are filtered by. |
|
65 | + * The status should match a EEM_Registration status constant. |
|
66 | + * |
|
67 | + * @var string $filtered_reg_status |
|
68 | + */ |
|
69 | + public $filtered_reg_status; |
|
70 | + |
|
71 | + /** |
|
72 | + * will hold an array of events assembled from $reg_info |
|
73 | + * |
|
74 | + * @var EE_Event[] $events |
|
75 | + */ |
|
76 | + public $events; |
|
77 | + |
|
78 | + /** |
|
79 | + * holds an array of datetimes assembled from the incoming data. |
|
80 | + * |
|
81 | + * @var EE_Datetime[] $datetimes |
|
82 | + */ |
|
83 | + public $datetimes; |
|
84 | + |
|
85 | + /** |
|
86 | + * holds an array of tickets assembled from the incoming data. |
|
87 | + * |
|
88 | + * @var EE_Ticket[] $tickets |
|
89 | + */ |
|
90 | + public $tickets; |
|
91 | + |
|
92 | + /** |
|
93 | + * holds an array with a key of parent line item and values are an array of children of that line item. |
|
94 | + * |
|
95 | + * @since 4.5.0 |
|
96 | + * @var EE_Line_Item[] $line_items_with_children |
|
97 | + */ |
|
98 | + public $line_items_with_children; |
|
99 | + |
|
100 | + /** |
|
101 | + * will hold an array of attendees assembled from the $reg_info |
|
102 | + * |
|
103 | + * @var EE_Attendee[] $attendees |
|
104 | + */ |
|
105 | + public $attendees; |
|
106 | + |
|
107 | + /** |
|
108 | + * will hold an array of cached registration objects and info assembled from reg_info |
|
109 | + * |
|
110 | + * @var array $registrations |
|
111 | + */ |
|
112 | + public $registrations; |
|
113 | + |
|
114 | + /** |
|
115 | + * will hold an array of answers assembled from the $reg_info |
|
116 | + * |
|
117 | + * @var EE_Answer[] $answers |
|
118 | + */ |
|
119 | + public $answers; |
|
120 | + |
|
121 | + /** |
|
122 | + * will hold an array of questions assembled from the $reg_info (indexed by Answer ID); |
|
123 | + * |
|
124 | + * @var EE_Question[] $questions |
|
125 | + */ |
|
126 | + public $questions; |
|
127 | + |
|
128 | + /** |
|
129 | + * Will hold billing data assembled from $billing_info (if present) |
|
130 | + * |
|
131 | + * @var mixed (array|null) $billing |
|
132 | + */ |
|
133 | + public $billing; |
|
134 | + |
|
135 | + /** |
|
136 | + * The total amount of tax for the transaction |
|
137 | + * |
|
138 | + * @var float $taxes |
|
139 | + */ |
|
140 | + public $taxes; |
|
141 | + |
|
142 | + /** |
|
143 | + * Holds the line items related to taxes |
|
144 | + * |
|
145 | + * @since 4.5.0 |
|
146 | + * @var EE_Line_Item[] $tax_line_items |
|
147 | + */ |
|
148 | + public $tax_line_items; |
|
149 | + |
|
150 | + /** |
|
151 | + * Hold the line items which aren't taxes and don't relate |
|
152 | + * to tickets. So: promotions and miscellaneous charges |
|
153 | + * |
|
154 | + * @since 4.5 |
|
155 | + * @var EE_Line_Item[] $additional_line_items |
|
156 | + */ |
|
157 | + public $additional_line_items; |
|
158 | + |
|
159 | + /** |
|
160 | + * Holds the grand total EE_Line_Item |
|
161 | + * |
|
162 | + * @var EE_Line_Item $grand_total_line_item |
|
163 | + */ |
|
164 | + public $grand_total_line_item; |
|
165 | + |
|
166 | + /** |
|
167 | + * holds the grand total price object |
|
168 | + * currently not used. |
|
169 | + * |
|
170 | + * @var null $grand_total_price_object |
|
171 | + */ |
|
172 | + public $grand_total_price_object; |
|
173 | + |
|
174 | + /** |
|
175 | + * total number of tickets |
|
176 | + * |
|
177 | + * @var int $total_ticket_count |
|
178 | + */ |
|
179 | + public $total_ticket_count; |
|
180 | + |
|
181 | + /** |
|
182 | + * Will hold the final transaction object (EE_Transaction) |
|
183 | + * |
|
184 | + * @var EE_Transaction $txn |
|
185 | + */ |
|
186 | + public $txn; |
|
187 | + |
|
188 | + /** |
|
189 | + * Holds the payments related to a transaction |
|
190 | + * |
|
191 | + * @since 4.5.0 |
|
192 | + * @var EE_Payment[] $payments |
|
193 | + */ |
|
194 | + public $payments; |
|
195 | + |
|
196 | + /** |
|
197 | + * Holds the first related payment related for a transaction |
|
198 | + * |
|
199 | + * @since 4.5.0 |
|
200 | + * @var EE_Payment $payment |
|
201 | + */ |
|
202 | + public $payment; |
|
203 | + |
|
204 | + /** |
|
205 | + * Will hold the label for the txn status |
|
206 | + * |
|
207 | + * @var string $txn_status |
|
208 | + */ |
|
209 | + public $txn_status; |
|
210 | + |
|
211 | + /** |
|
212 | + * Will hold the final registration object (EE_Registration) |
|
213 | + * |
|
214 | + * @var EE_Registration[] $reg_objs |
|
215 | + */ |
|
216 | + public $reg_objs; |
|
217 | + |
|
218 | + /** |
|
219 | + * Will hold an array of primary attendee data (if present) |
|
220 | + * |
|
221 | + * @var array $primary_attendee_data |
|
222 | + */ |
|
223 | + public $primary_attendee_data; |
|
224 | + |
|
225 | + /** |
|
226 | + * This is just an internal object used for passing around the incoming data. |
|
227 | + * |
|
228 | + * @var mixed $_data |
|
229 | + */ |
|
230 | + protected $_data; |
|
231 | + |
|
232 | + /** |
|
233 | + * This is just an internal object used for passing around the incoming data. |
|
234 | + * |
|
235 | + * @var mixed $incoming_data |
|
236 | + */ |
|
237 | + public $incoming_data; |
|
238 | + |
|
239 | + /** |
|
240 | + * hold objects that might be created |
|
241 | + * |
|
242 | + * @type EE_Registration $reg_obj |
|
243 | + */ |
|
244 | + public $reg_obj; |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * constructor |
|
249 | + * |
|
250 | + * @param mixed $data incoming data object|array. Suggested that child classes use type hinting for expected |
|
251 | + * data object. But here parent will be generic because we don't know what's coming in. |
|
252 | + */ |
|
253 | + public function __construct($data) |
|
254 | + { |
|
255 | + $this->_data = $data; |
|
256 | + $this->_setup_data(); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * Every child class has to setup the data object ! |
|
262 | + * |
|
263 | + * @return void |
|
264 | + */ |
|
265 | + abstract protected function _setup_data(); |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
270 | + * |
|
271 | + * @param mixed $data The incoming data to be prepped. |
|
272 | + * @return mixed The prepped data for db |
|
273 | + */ |
|
274 | + public static function convert_data_for_persistent_storage($data) |
|
275 | + { |
|
276 | + return $data; |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + /** |
|
281 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
282 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
283 | + * |
|
284 | + * @param $data |
|
285 | + * @return mixed |
|
286 | + */ |
|
287 | + public static function convert_data_from_persistent_storage($data) |
|
288 | + { |
|
289 | + return $data; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * only purpose is to return the data |
|
295 | + * |
|
296 | + * @access public |
|
297 | + * @return mixed the formatted data object! |
|
298 | + */ |
|
299 | + public function data() |
|
300 | + { |
|
301 | + return $this->_data; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * This helper method can be used by any incoming data handlers to setup the data correctly. All that is required |
|
307 | + * is that $this->reg_objs be set. |
|
308 | + * |
|
309 | + * @throws EE_Error |
|
310 | + * @throws InvalidDataTypeException |
|
311 | + * @throws InvalidInterfaceException |
|
312 | + * @throws InvalidArgumentException |
|
313 | + * @throws EntityNotFoundException |
|
314 | + */ |
|
315 | + protected function _assemble_data() |
|
316 | + { |
|
317 | + // verify that reg_objs is set |
|
318 | + if (! is_array($this->reg_objs) |
|
319 | + && ! reset($this->reg_objs) instanceof EE_Registration |
|
320 | + ) { |
|
321 | + throw new EE_Error( |
|
322 | + esc_html__( |
|
323 | + 'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects', |
|
324 | + 'event_espresso' |
|
325 | + ) |
|
326 | + ); |
|
327 | + } |
|
328 | + |
|
329 | + // get all attendee and events associated with the registrations in this transaction |
|
330 | + $events = $event_setup = $evtcache = $tickets = $datetimes = array(); |
|
331 | + $answers = $questions = $attendees = $line_items = $registrations = array(); |
|
332 | + $total_ticket_count = 0; |
|
333 | + |
|
334 | + if (! empty($this->reg_objs)) { |
|
335 | + $event_attendee_count = array(); |
|
336 | + /** @var EE_Registration $reg */ |
|
337 | + foreach ($this->reg_objs as $reg) { |
|
338 | + if ($this->_skip_registration_for_processing($reg) |
|
339 | + ) { |
|
340 | + continue; |
|
341 | + } |
|
342 | + |
|
343 | + $evt_id = $reg->event_ID(); |
|
344 | + /** @type EE_Ticket $ticket */ |
|
345 | + $ticket = $reg->get_first_related('Ticket'); |
|
346 | + $attendee = $reg->attendee(); |
|
347 | + $event = $reg->event(); |
|
348 | + // if none of the following entities are available, then we can't setup other data reliably, |
|
349 | + // so let's just skip. |
|
350 | + if (! $ticket instanceof EE_Ticket |
|
351 | + || ! $attendee instanceof EE_Attendee |
|
352 | + || ! $event instanceof EE_Event |
|
353 | + ) { |
|
354 | + continue; |
|
355 | + } |
|
356 | + $relateddatetime = $ticket->datetimes(); |
|
357 | + $total_ticket_count++; |
|
358 | + $tickets[ $ticket->ID() ]['ticket'] = $ticket; |
|
359 | + $tickets[ $ticket->ID() ]['count'] = is_array($tickets[ $ticket->ID() ]) |
|
360 | + && isset($tickets[ $ticket->ID() ]['count']) |
|
361 | + ? $tickets[ $ticket->ID() ]['count'] + 1 |
|
362 | + : 1; |
|
363 | + $tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee; |
|
364 | + $tickets[ $ticket->ID() ]['dtt_objs'] = $relateddatetime; |
|
365 | + $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
366 | + $tickets[ $ticket->ID() ]['EE_Event'] = $event; |
|
367 | + $evtcache[ $evt_id ] = $event; |
|
368 | + $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
369 | + $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
370 | + $eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ] = $attendee; |
|
371 | + $event_attendee_count[ $evt_id ] = isset($event_attendee_count[ $evt_id ]) |
|
372 | + ? $event_attendee_count[ $evt_id ] + 1 |
|
373 | + : 0; |
|
374 | + $attendees[ $reg->attendee_ID() ]['line_ref'][] = $evt_id; |
|
375 | + $attendees[ $reg->attendee_ID() ]['att_obj'] = $attendee; |
|
376 | + $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
377 | + // $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID(); |
|
378 | + $attendees[ $reg->attendee_ID() ]['attendee_email'] = $attendee->email(); |
|
379 | + $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
380 | + $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ] = $event; |
|
381 | + |
|
382 | + // registrations |
|
383 | + $registrations[ $reg->ID() ]['tkt_obj'] = $ticket; |
|
384 | + $registrations[ $reg->ID() ]['evt_obj'] = $event; |
|
385 | + $registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
386 | + $registrations[ $reg->ID() ]['att_obj'] = $attendee; |
|
387 | + |
|
388 | + // set up answer objects |
|
389 | + $rel_ans = $reg->get_many_related('Answer'); |
|
390 | + foreach ($rel_ans as $ansid => $answer) { |
|
391 | + if (! isset($questions[ $ansid ])) { |
|
392 | + $questions[ $ansid ] = $answer->get_first_related('Question'); |
|
393 | + } |
|
394 | + $answers[ $ansid ] = $answer; |
|
395 | + $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer; |
|
396 | + } |
|
397 | + /** |
|
398 | + * @var int $dtt_id |
|
399 | + * @var EE_Datetime $datetime |
|
400 | + */ |
|
401 | + foreach ($relateddatetime as $dtt_id => $datetime) { |
|
402 | + $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
403 | + $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
404 | + |
|
405 | + if (isset($datetimes[ $dtt_id ])) { |
|
406 | + continue; // already have this info in the datetimes array. |
|
407 | + } |
|
408 | + |
|
409 | + $datetimes[ $dtt_id ]['tkt_objs'][] = $ticket; |
|
410 | + $datetimes[ $dtt_id ]['datetime'] = $datetime; |
|
411 | + $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ] = $event; |
|
412 | + $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + // let's loop through the unique event=>reg items and setup data on them |
|
417 | + |
|
418 | + if (! empty($eventsetup)) { |
|
419 | + foreach ($eventsetup as $evt_id => $items) { |
|
420 | + $ticket_line_items_for_event = array(); |
|
421 | + if ($this->txn instanceof EE_Transaction) { |
|
422 | + $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all( |
|
423 | + array( |
|
424 | + array( |
|
425 | + 'Ticket.Datetime.EVT_ID' => $evt_id, |
|
426 | + 'TXN_ID' => $this->txn->ID(), |
|
427 | + ), |
|
428 | + 'default_where_conditions' => 'none', |
|
429 | + ) |
|
430 | + ); |
|
431 | + } |
|
432 | + $events[ $evt_id ] = array( |
|
433 | + 'ID' => $evt_id, |
|
434 | + 'event' => $evtcache[ $evt_id ], |
|
435 | + 'name' => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '', |
|
436 | + 'total_attendees' => $event_attendee_count[ $evt_id ], |
|
437 | + 'reg_objs' => $items['reg_objs'], |
|
438 | + 'tkt_objs' => $items['tkt_objs'], |
|
439 | + 'att_objs' => $items['att_objs'], |
|
440 | + 'dtt_objs' => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(), |
|
441 | + 'line_items' => $ticket_line_items_for_event, |
|
442 | + ); |
|
443 | + |
|
444 | + // make sure the tickets have the line items setup for them. |
|
445 | + foreach ($ticket_line_items_for_event as $line_id => $line_item) { |
|
446 | + if ($line_item instanceof EE_Line_Item) { |
|
447 | + $tickets[ $line_item->ticket()->ID() ]['line_item'] = $line_item; |
|
448 | + $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children(); |
|
449 | + $line_items[ $line_item->ID() ]['children'] = $line_item->children(); |
|
450 | + $line_items[ $line_item->ID() ]['EE_Ticket'] = $line_item->ticket(); |
|
451 | + } |
|
452 | + } |
|
453 | + } |
|
454 | + } |
|
455 | + |
|
456 | + $this->grand_total_line_item = $this->txn instanceof EE_Transaction |
|
457 | + ? $this->txn->total_line_item() |
|
458 | + : null; |
|
459 | + } |
|
460 | + |
|
461 | + // lets set the attendees and events properties |
|
462 | + $this->attendees = $attendees; |
|
463 | + $this->events = $events; |
|
464 | + $this->tickets = $tickets; |
|
465 | + $this->line_items_with_children = $line_items; |
|
466 | + $this->datetimes = $datetimes; |
|
467 | + $this->questions = $questions; |
|
468 | + $this->answers = $answers; |
|
469 | + $this->total_ticket_count = $total_ticket_count; |
|
470 | + $this->registrations = $registrations; |
|
471 | + |
|
472 | + if ($this->txn instanceof EE_Transaction) { |
|
473 | + $this->tax_line_items = $this->txn->tax_items(); |
|
474 | + $this->additional_line_items = $this->txn->non_ticket_line_items(); |
|
475 | + $this->payments = $this->txn->payments(); |
|
476 | + |
|
477 | + // setup primary registration if we have a single transaction object to work with |
|
478 | + |
|
479 | + // let's get just the primary_attendee_data! First we get the primary registration object. |
|
480 | + $primary_reg = $this->txn->primary_registration(); |
|
481 | + // verify |
|
482 | + if ($primary_reg instanceof EE_Registration) { |
|
483 | + // get attendee object |
|
484 | + if ($primary_reg->attendee() instanceof EE_Attendee) { |
|
485 | + // now we can setup the primary_attendee_data array |
|
486 | + $this->primary_attendee_data = array( |
|
487 | + 'registration_id' => $primary_reg->ID(), |
|
488 | + 'att_obj' => $primary_reg->attendee(), |
|
489 | + 'reg_obj' => $primary_reg, |
|
490 | + 'primary_att_obj' => $primary_reg->attendee(), |
|
491 | + 'primary_reg_obj' => $primary_reg, |
|
492 | + ); |
|
493 | + } else { |
|
494 | + EE_Error::add_error( |
|
495 | + esc_html__( |
|
496 | + 'Incoming data does not have a valid Attendee object for the primary registrant.', |
|
497 | + 'event_espresso' |
|
498 | + ), |
|
499 | + __FILE__, |
|
500 | + __FUNCTION__, |
|
501 | + __LINE__ |
|
502 | + ); |
|
503 | + } |
|
504 | + } else { |
|
505 | + EE_Error::add_error( |
|
506 | + esc_html__( |
|
507 | + 'Incoming data does not have a valid Registration object for the primary registrant.', |
|
508 | + 'event_espresso' |
|
509 | + ), |
|
510 | + __FILE__, |
|
511 | + __FUNCTION__, |
|
512 | + __LINE__ |
|
513 | + ); |
|
514 | + } |
|
515 | + } |
|
516 | + } |
|
517 | + |
|
518 | + /** |
|
519 | + * This simply considers whether the given registration should be processed or not based on comparison with the |
|
520 | + * filtered_reg_status property. |
|
521 | + * |
|
522 | + * @param EE_Registration $registration |
|
523 | + * @return bool returning true means we DO want to skip processing. returning false means we DON'T want to skip |
|
524 | + * processing |
|
525 | + */ |
|
526 | + protected function _skip_registration_for_processing(EE_Registration $registration) |
|
527 | + { |
|
528 | + if (empty($this->filtered_reg_status)) { |
|
529 | + return false; |
|
530 | + } |
|
531 | + |
|
532 | + // if we made it here then we just compare the filtered_reg_status with the registration status and return that |
|
533 | + return $this->filtered_reg_status !== $registration->status_ID(); |
|
534 | + } |
|
535 | 535 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | protected function _assemble_data() |
316 | 316 | { |
317 | 317 | // verify that reg_objs is set |
318 | - if (! is_array($this->reg_objs) |
|
318 | + if ( ! is_array($this->reg_objs) |
|
319 | 319 | && ! reset($this->reg_objs) instanceof EE_Registration |
320 | 320 | ) { |
321 | 321 | throw new EE_Error( |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $answers = $questions = $attendees = $line_items = $registrations = array(); |
332 | 332 | $total_ticket_count = 0; |
333 | 333 | |
334 | - if (! empty($this->reg_objs)) { |
|
334 | + if ( ! empty($this->reg_objs)) { |
|
335 | 335 | $event_attendee_count = array(); |
336 | 336 | /** @var EE_Registration $reg */ |
337 | 337 | foreach ($this->reg_objs as $reg) { |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | |
343 | 343 | $evt_id = $reg->event_ID(); |
344 | 344 | /** @type EE_Ticket $ticket */ |
345 | - $ticket = $reg->get_first_related('Ticket'); |
|
345 | + $ticket = $reg->get_first_related('Ticket'); |
|
346 | 346 | $attendee = $reg->attendee(); |
347 | 347 | $event = $reg->event(); |
348 | 348 | // if none of the following entities are available, then we can't setup other data reliably, |
349 | 349 | // so let's just skip. |
350 | - if (! $ticket instanceof EE_Ticket |
|
350 | + if ( ! $ticket instanceof EE_Ticket |
|
351 | 351 | || ! $attendee instanceof EE_Attendee |
352 | 352 | || ! $event instanceof EE_Event |
353 | 353 | ) { |
@@ -355,67 +355,67 @@ discard block |
||
355 | 355 | } |
356 | 356 | $relateddatetime = $ticket->datetimes(); |
357 | 357 | $total_ticket_count++; |
358 | - $tickets[ $ticket->ID() ]['ticket'] = $ticket; |
|
359 | - $tickets[ $ticket->ID() ]['count'] = is_array($tickets[ $ticket->ID() ]) |
|
360 | - && isset($tickets[ $ticket->ID() ]['count']) |
|
361 | - ? $tickets[ $ticket->ID() ]['count'] + 1 |
|
358 | + $tickets[$ticket->ID()]['ticket'] = $ticket; |
|
359 | + $tickets[$ticket->ID()]['count'] = is_array($tickets[$ticket->ID()]) |
|
360 | + && isset($tickets[$ticket->ID()]['count']) |
|
361 | + ? $tickets[$ticket->ID()]['count'] + 1 |
|
362 | 362 | : 1; |
363 | - $tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee; |
|
364 | - $tickets[ $ticket->ID() ]['dtt_objs'] = $relateddatetime; |
|
365 | - $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
366 | - $tickets[ $ticket->ID() ]['EE_Event'] = $event; |
|
367 | - $evtcache[ $evt_id ] = $event; |
|
368 | - $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
369 | - $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
370 | - $eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ] = $attendee; |
|
371 | - $event_attendee_count[ $evt_id ] = isset($event_attendee_count[ $evt_id ]) |
|
372 | - ? $event_attendee_count[ $evt_id ] + 1 |
|
363 | + $tickets[$ticket->ID()]['att_objs'][$attendee->ID()] = $attendee; |
|
364 | + $tickets[$ticket->ID()]['dtt_objs'] = $relateddatetime; |
|
365 | + $tickets[$ticket->ID()]['reg_objs'][$reg->ID()] = $reg; |
|
366 | + $tickets[$ticket->ID()]['EE_Event'] = $event; |
|
367 | + $evtcache[$evt_id] = $event; |
|
368 | + $eventsetup[$evt_id]['reg_objs'][$reg->ID()] = $reg; |
|
369 | + $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()] = $ticket; |
|
370 | + $eventsetup[$evt_id]['att_objs'][$attendee->ID()] = $attendee; |
|
371 | + $event_attendee_count[$evt_id] = isset($event_attendee_count[$evt_id]) |
|
372 | + ? $event_attendee_count[$evt_id] + 1 |
|
373 | 373 | : 0; |
374 | - $attendees[ $reg->attendee_ID() ]['line_ref'][] = $evt_id; |
|
375 | - $attendees[ $reg->attendee_ID() ]['att_obj'] = $attendee; |
|
376 | - $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
374 | + $attendees[$reg->attendee_ID()]['line_ref'][] = $evt_id; |
|
375 | + $attendees[$reg->attendee_ID()]['att_obj'] = $attendee; |
|
376 | + $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()] = $reg; |
|
377 | 377 | // $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID(); |
378 | - $attendees[ $reg->attendee_ID() ]['attendee_email'] = $attendee->email(); |
|
379 | - $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
380 | - $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ] = $event; |
|
378 | + $attendees[$reg->attendee_ID()]['attendee_email'] = $attendee->email(); |
|
379 | + $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket; |
|
380 | + $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id] = $event; |
|
381 | 381 | |
382 | 382 | // registrations |
383 | - $registrations[ $reg->ID() ]['tkt_obj'] = $ticket; |
|
384 | - $registrations[ $reg->ID() ]['evt_obj'] = $event; |
|
385 | - $registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
386 | - $registrations[ $reg->ID() ]['att_obj'] = $attendee; |
|
383 | + $registrations[$reg->ID()]['tkt_obj'] = $ticket; |
|
384 | + $registrations[$reg->ID()]['evt_obj'] = $event; |
|
385 | + $registrations[$reg->ID()]['reg_obj'] = $reg; |
|
386 | + $registrations[$reg->ID()]['att_obj'] = $attendee; |
|
387 | 387 | |
388 | 388 | // set up answer objects |
389 | 389 | $rel_ans = $reg->get_many_related('Answer'); |
390 | 390 | foreach ($rel_ans as $ansid => $answer) { |
391 | - if (! isset($questions[ $ansid ])) { |
|
392 | - $questions[ $ansid ] = $answer->get_first_related('Question'); |
|
391 | + if ( ! isset($questions[$ansid])) { |
|
392 | + $questions[$ansid] = $answer->get_first_related('Question'); |
|
393 | 393 | } |
394 | - $answers[ $ansid ] = $answer; |
|
395 | - $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer; |
|
394 | + $answers[$ansid] = $answer; |
|
395 | + $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer; |
|
396 | 396 | } |
397 | 397 | /** |
398 | 398 | * @var int $dtt_id |
399 | 399 | * @var EE_Datetime $datetime |
400 | 400 | */ |
401 | 401 | foreach ($relateddatetime as $dtt_id => $datetime) { |
402 | - $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
403 | - $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
402 | + $eventsetup[$evt_id]['dtt_objs'][$dtt_id] = $datetime; |
|
403 | + $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime; |
|
404 | 404 | |
405 | - if (isset($datetimes[ $dtt_id ])) { |
|
405 | + if (isset($datetimes[$dtt_id])) { |
|
406 | 406 | continue; // already have this info in the datetimes array. |
407 | 407 | } |
408 | 408 | |
409 | - $datetimes[ $dtt_id ]['tkt_objs'][] = $ticket; |
|
410 | - $datetimes[ $dtt_id ]['datetime'] = $datetime; |
|
411 | - $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ] = $event; |
|
412 | - $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
409 | + $datetimes[$dtt_id]['tkt_objs'][] = $ticket; |
|
410 | + $datetimes[$dtt_id]['datetime'] = $datetime; |
|
411 | + $datetimes[$dtt_id]['evt_objs'][$evt_id] = $event; |
|
412 | + $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg; |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | 416 | // let's loop through the unique event=>reg items and setup data on them |
417 | 417 | |
418 | - if (! empty($eventsetup)) { |
|
418 | + if ( ! empty($eventsetup)) { |
|
419 | 419 | foreach ($eventsetup as $evt_id => $items) { |
420 | 420 | $ticket_line_items_for_event = array(); |
421 | 421 | if ($this->txn instanceof EE_Transaction) { |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | ) |
430 | 430 | ); |
431 | 431 | } |
432 | - $events[ $evt_id ] = array( |
|
432 | + $events[$evt_id] = array( |
|
433 | 433 | 'ID' => $evt_id, |
434 | - 'event' => $evtcache[ $evt_id ], |
|
435 | - 'name' => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '', |
|
436 | - 'total_attendees' => $event_attendee_count[ $evt_id ], |
|
434 | + 'event' => $evtcache[$evt_id], |
|
435 | + 'name' => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '', |
|
436 | + 'total_attendees' => $event_attendee_count[$evt_id], |
|
437 | 437 | 'reg_objs' => $items['reg_objs'], |
438 | 438 | 'tkt_objs' => $items['tkt_objs'], |
439 | 439 | 'att_objs' => $items['att_objs'], |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | // make sure the tickets have the line items setup for them. |
445 | 445 | foreach ($ticket_line_items_for_event as $line_id => $line_item) { |
446 | 446 | if ($line_item instanceof EE_Line_Item) { |
447 | - $tickets[ $line_item->ticket()->ID() ]['line_item'] = $line_item; |
|
448 | - $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children(); |
|
449 | - $line_items[ $line_item->ID() ]['children'] = $line_item->children(); |
|
450 | - $line_items[ $line_item->ID() ]['EE_Ticket'] = $line_item->ticket(); |
|
447 | + $tickets[$line_item->ticket()->ID()]['line_item'] = $line_item; |
|
448 | + $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children(); |
|
449 | + $line_items[$line_item->ID()]['children'] = $line_item->children(); |
|
450 | + $line_items[$line_item->ID()]['EE_Ticket'] = $line_item->ticket(); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | } |
@@ -14,141 +14,141 @@ |
||
14 | 14 | class EE_Messages_Gateways_incoming_data extends EE_Messages_incoming_data |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * This holds the incoming payment object |
|
19 | - * @var EE_Payment |
|
20 | - */ |
|
21 | - public $payment; |
|
22 | - |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * incoming data is expected to be a EE_Transaction object and (possibly) EE_Payment object in an array. |
|
27 | - * |
|
28 | - * @param array $data |
|
29 | - * @throws EE_Error |
|
30 | - */ |
|
31 | - public function __construct($data) |
|
32 | - { |
|
33 | - |
|
34 | - // test for valid params |
|
35 | - if (! ( $data[0] instanceof EE_Transaction )) { |
|
36 | - throw new EE_Error(__('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso')); |
|
37 | - } |
|
38 | - |
|
39 | - if (empty($data[1]) || ! $data[1] instanceof EE_Payment) { |
|
40 | - $pmt_obj = $this->_get_empty_payment_obj($data[0]); |
|
41 | - } |
|
42 | - |
|
43 | - if (! empty($data[2])) { |
|
44 | - $filtered_reg_status = $data[2]; |
|
45 | - } |
|
17 | + /** |
|
18 | + * This holds the incoming payment object |
|
19 | + * @var EE_Payment |
|
20 | + */ |
|
21 | + public $payment; |
|
22 | + |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * incoming data is expected to be a EE_Transaction object and (possibly) EE_Payment object in an array. |
|
27 | + * |
|
28 | + * @param array $data |
|
29 | + * @throws EE_Error |
|
30 | + */ |
|
31 | + public function __construct($data) |
|
32 | + { |
|
33 | + |
|
34 | + // test for valid params |
|
35 | + if (! ( $data[0] instanceof EE_Transaction )) { |
|
36 | + throw new EE_Error(__('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso')); |
|
37 | + } |
|
38 | + |
|
39 | + if (empty($data[1]) || ! $data[1] instanceof EE_Payment) { |
|
40 | + $pmt_obj = $this->_get_empty_payment_obj($data[0]); |
|
41 | + } |
|
42 | + |
|
43 | + if (! empty($data[2])) { |
|
44 | + $filtered_reg_status = $data[2]; |
|
45 | + } |
|
46 | 46 | |
47 | - $data = array( |
|
48 | - 'txn_obj' => $data[0], |
|
49 | - 'pmt_obj' => isset($pmt_obj) ? $pmt_obj : $data[1], |
|
50 | - 'filtered_reg_status' => isset($filtered_reg_status) ? $filtered_reg_status : null |
|
51 | - ); |
|
52 | - parent::__construct($data); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
61 | - * |
|
62 | - * @param array $data The incoming data to be prepped. |
|
63 | - * |
|
64 | - * @return array The prepped data for db |
|
65 | - */ |
|
66 | - public static function convert_data_for_persistent_storage($data) |
|
67 | - { |
|
68 | - $prepped_data = array(); |
|
69 | - |
|
70 | - if ($data[0] instanceof EE_Transaction) { |
|
71 | - $prepped_data['Transaction'] = $data[0]->ID(); |
|
72 | - } |
|
73 | - |
|
74 | - if (isset($data[1]) && $data[1] instanceof EE_Payment) { |
|
75 | - $prepped_data['Payment'] = $data[1]->ID(); |
|
76 | - } |
|
77 | - |
|
78 | - if (! empty($data[2])) { |
|
79 | - $prepped_data['filter'] = $data[2]; |
|
80 | - } |
|
81 | - |
|
82 | - return $prepped_data; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
92 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
93 | - * |
|
94 | - * @param array $data |
|
95 | - * |
|
96 | - * @return array |
|
97 | - */ |
|
98 | - public static function convert_data_from_persistent_storage($data) |
|
99 | - { |
|
100 | - $prepped_data = array( |
|
101 | - 0 => isset($data['Transaction']) ? EEM_Transaction::instance()->get_one_by_ID($data['Transaction']) : null, |
|
102 | - 1 => isset($data['Payment']) ? EEM_Payment::instance()->get_one_by_ID($data['Payment']) : null, |
|
103 | - 2 => isset($data['filter']) ? $data['filter'] : null |
|
104 | - ); |
|
105 | - return $prepped_data; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * This sets up an empty EE_Payment object for the purpose of shortcode parsing. Note that this doesn't actually get saved to the db. |
|
111 | - * @param \EE_Transaction $txn |
|
112 | - * @return \EE_Payment |
|
113 | - */ |
|
114 | - private function _get_empty_payment_obj(EE_Transaction $txn) |
|
115 | - { |
|
116 | - $PMT = EE_Payment::new_instance(array( |
|
117 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
118 | - 'PAY_timestamp' => time(), |
|
119 | - 'PMD_ID' => $txn->payment_method_ID(), |
|
120 | - 'PAY_gateway_response' => $txn->gateway_response_on_transaction(), |
|
121 | - )); |
|
122 | - return $PMT; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * _setup_data |
|
129 | - * |
|
130 | - * @throws EE_Error |
|
131 | - */ |
|
132 | - protected function _setup_data() |
|
133 | - { |
|
134 | - |
|
135 | - $this->reg_info = array(); |
|
136 | - |
|
137 | - $this->txn = $this->_data['txn_obj']; |
|
138 | - $this->payment = $this->_data['pmt_obj']; |
|
139 | - $this->filtered_reg_status = $this->_data['filtered_reg_status']; |
|
140 | - $this->incoming_data = $this->_data; |
|
141 | - |
|
142 | - $session_data = $this->txn->session_data(); |
|
143 | - |
|
144 | - |
|
145 | - // other data from the session (if possible) |
|
146 | - $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : ''; |
|
147 | - $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : ''; |
|
148 | - $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : ''; |
|
149 | - $this->init_access = $this->last_access = ''; |
|
150 | - // get all non-trashed registrations |
|
151 | - $this->reg_objs = $this->txn->registrations(array(array('REG_deleted' => false))); |
|
152 | - $this->_assemble_data(); |
|
153 | - } |
|
47 | + $data = array( |
|
48 | + 'txn_obj' => $data[0], |
|
49 | + 'pmt_obj' => isset($pmt_obj) ? $pmt_obj : $data[1], |
|
50 | + 'filtered_reg_status' => isset($filtered_reg_status) ? $filtered_reg_status : null |
|
51 | + ); |
|
52 | + parent::__construct($data); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
61 | + * |
|
62 | + * @param array $data The incoming data to be prepped. |
|
63 | + * |
|
64 | + * @return array The prepped data for db |
|
65 | + */ |
|
66 | + public static function convert_data_for_persistent_storage($data) |
|
67 | + { |
|
68 | + $prepped_data = array(); |
|
69 | + |
|
70 | + if ($data[0] instanceof EE_Transaction) { |
|
71 | + $prepped_data['Transaction'] = $data[0]->ID(); |
|
72 | + } |
|
73 | + |
|
74 | + if (isset($data[1]) && $data[1] instanceof EE_Payment) { |
|
75 | + $prepped_data['Payment'] = $data[1]->ID(); |
|
76 | + } |
|
77 | + |
|
78 | + if (! empty($data[2])) { |
|
79 | + $prepped_data['filter'] = $data[2]; |
|
80 | + } |
|
81 | + |
|
82 | + return $prepped_data; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
92 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
93 | + * |
|
94 | + * @param array $data |
|
95 | + * |
|
96 | + * @return array |
|
97 | + */ |
|
98 | + public static function convert_data_from_persistent_storage($data) |
|
99 | + { |
|
100 | + $prepped_data = array( |
|
101 | + 0 => isset($data['Transaction']) ? EEM_Transaction::instance()->get_one_by_ID($data['Transaction']) : null, |
|
102 | + 1 => isset($data['Payment']) ? EEM_Payment::instance()->get_one_by_ID($data['Payment']) : null, |
|
103 | + 2 => isset($data['filter']) ? $data['filter'] : null |
|
104 | + ); |
|
105 | + return $prepped_data; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * This sets up an empty EE_Payment object for the purpose of shortcode parsing. Note that this doesn't actually get saved to the db. |
|
111 | + * @param \EE_Transaction $txn |
|
112 | + * @return \EE_Payment |
|
113 | + */ |
|
114 | + private function _get_empty_payment_obj(EE_Transaction $txn) |
|
115 | + { |
|
116 | + $PMT = EE_Payment::new_instance(array( |
|
117 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
118 | + 'PAY_timestamp' => time(), |
|
119 | + 'PMD_ID' => $txn->payment_method_ID(), |
|
120 | + 'PAY_gateway_response' => $txn->gateway_response_on_transaction(), |
|
121 | + )); |
|
122 | + return $PMT; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * _setup_data |
|
129 | + * |
|
130 | + * @throws EE_Error |
|
131 | + */ |
|
132 | + protected function _setup_data() |
|
133 | + { |
|
134 | + |
|
135 | + $this->reg_info = array(); |
|
136 | + |
|
137 | + $this->txn = $this->_data['txn_obj']; |
|
138 | + $this->payment = $this->_data['pmt_obj']; |
|
139 | + $this->filtered_reg_status = $this->_data['filtered_reg_status']; |
|
140 | + $this->incoming_data = $this->_data; |
|
141 | + |
|
142 | + $session_data = $this->txn->session_data(); |
|
143 | + |
|
144 | + |
|
145 | + // other data from the session (if possible) |
|
146 | + $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : ''; |
|
147 | + $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : ''; |
|
148 | + $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : ''; |
|
149 | + $this->init_access = $this->last_access = ''; |
|
150 | + // get all non-trashed registrations |
|
151 | + $this->reg_objs = $this->txn->registrations(array(array('REG_deleted' => false))); |
|
152 | + $this->_assemble_data(); |
|
153 | + } |
|
154 | 154 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | |
34 | 34 | // test for valid params |
35 | - if (! ( $data[0] instanceof EE_Transaction )) { |
|
35 | + if ( ! ($data[0] instanceof EE_Transaction)) { |
|
36 | 36 | throw new EE_Error(__('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso')); |
37 | 37 | } |
38 | 38 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $pmt_obj = $this->_get_empty_payment_obj($data[0]); |
41 | 41 | } |
42 | 42 | |
43 | - if (! empty($data[2])) { |
|
43 | + if ( ! empty($data[2])) { |
|
44 | 44 | $filtered_reg_status = $data[2]; |
45 | 45 | } |
46 | 46 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $prepped_data['Payment'] = $data[1]->ID(); |
76 | 76 | } |
77 | 77 | |
78 | - if (! empty($data[2])) { |
|
78 | + if ( ! empty($data[2])) { |
|
79 | 79 | $prepped_data['filter'] = $data[2]; |
80 | 80 | } |
81 | 81 |
@@ -17,172 +17,172 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * Constructor. |
|
22 | - * |
|
23 | - * @param EE_Registration[] $data expecting an array of EE_Registration objects. |
|
24 | - * @throws EE_Error |
|
25 | - * @access protected |
|
26 | - */ |
|
27 | - public function __construct($data = array()) |
|
28 | - { |
|
29 | - |
|
30 | - // validate that the first element in the array is an EE_Registration object. |
|
31 | - if (! reset($data) instanceof EE_Registration) { |
|
32 | - throw new EE_Error( |
|
33 | - esc_html__( |
|
34 | - 'The EE_Message_Registrations_incoming_data class expects an array of EE_Registration objects.', |
|
35 | - 'event_espresso' |
|
36 | - ) |
|
37 | - ); |
|
38 | - } |
|
39 | - parent::__construct($data); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * setup the data. |
|
45 | - * Sets up the expected data object for the messages prep using incoming registration objects. |
|
46 | - * |
|
47 | - * @return void |
|
48 | - * @throws EE_Error |
|
49 | - * @throws EntityNotFoundException |
|
50 | - * @access protected |
|
51 | - */ |
|
52 | - protected function _setup_data() |
|
53 | - { |
|
54 | - // we'll loop through each contact and setup the data needed. Note that many properties will just be set as |
|
55 | - // empty because this data handler is for a very specific set of data (i.e. just what's related to the |
|
56 | - // registration). |
|
57 | - |
|
58 | - $this->reg_objs = $this->data(); |
|
59 | - $this->txn = $this->_maybe_get_transaction(); |
|
60 | - $this->_assemble_data(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * If the incoming registrations all share the same transaction then this will return the transaction object shared |
|
66 | - * among the registrations. Otherwise the transaction object is set to null because its intended to only represent |
|
67 | - * one transaction. |
|
68 | - * |
|
69 | - * @return EE_Transaction|null |
|
70 | - * @throws EE_Error |
|
71 | - * @throws EntityNotFoundException |
|
72 | - */ |
|
73 | - protected function _maybe_get_transaction() |
|
74 | - { |
|
75 | - $transactions = array(); |
|
76 | - foreach ($this->reg_objs as $registration) { |
|
77 | - if ($registration instanceof EE_Registration) { |
|
78 | - $transaction = $registration->transaction(); |
|
79 | - if ($transaction instanceof EE_Transaction) { |
|
80 | - $transactions[ $transaction->ID() ] = $transaction; |
|
81 | - } |
|
82 | - } |
|
83 | - } |
|
84 | - return count($transactions) === 1 ? reset($transactions) : null; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
90 | - * |
|
91 | - * @param array $registrations The incoming data to be prepped. |
|
92 | - * @return EE_Registration[] The data being prepared for the db |
|
93 | - * @throws EE_Error |
|
94 | - * @throws InvalidArgumentException |
|
95 | - * @throws InvalidDataTypeException |
|
96 | - * @throws InvalidInterfaceException |
|
97 | - */ |
|
98 | - public static function convert_data_for_persistent_storage($registrations) |
|
99 | - { |
|
100 | - if (! self::validateRegistrationsForConversion($registrations)) { |
|
101 | - return array(); |
|
102 | - } |
|
103 | - |
|
104 | - // is this an array of ints? |
|
105 | - $first_item = reset($registrations); |
|
106 | - if (is_int($first_item)) { |
|
107 | - return $registrations; |
|
108 | - } |
|
109 | - |
|
110 | - // k nope so let's pull from the registrations |
|
111 | - $registration_ids = array_filter( |
|
112 | - array_map( |
|
113 | - function ($registration) { |
|
114 | - if ($registration instanceof EE_Registration) { |
|
115 | - return $registration->ID(); |
|
116 | - } |
|
117 | - return false; |
|
118 | - }, |
|
119 | - $registrations |
|
120 | - ) |
|
121 | - ); |
|
122 | - |
|
123 | - return $registration_ids; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * This validates incoming registrations (considers whether they are ids or EE_Registration objects. |
|
129 | - * |
|
130 | - * @param array $registrations Could be EE_Registration[] or int[] |
|
131 | - * @return bool |
|
132 | - * @throws EE_Error |
|
133 | - * @throws InvalidArgumentException |
|
134 | - * @throws InvalidDataTypeException |
|
135 | - * @throws InvalidInterfaceException |
|
136 | - */ |
|
137 | - protected static function validateRegistrationsForConversion($registrations) |
|
138 | - { |
|
139 | - if (is_array($registrations)) { |
|
140 | - $first_item = reset($registrations); |
|
141 | - if ($first_item instanceof EE_Registration) { |
|
142 | - return true; |
|
143 | - } |
|
144 | - if (is_int($first_item)) { |
|
145 | - // k let's some basic validation here. This isn't foolproof but better than nothing. |
|
146 | - // the purpose of this validation is to verify that the ids sent in match valid registrations existing |
|
147 | - // in the db. If the count is different, then we know they aren't valid. |
|
148 | - $count_for_ids = EEM_Registration::instance()->count( |
|
149 | - array( |
|
150 | - array( |
|
151 | - 'REG_ID' => array('IN', $registrations) |
|
152 | - ) |
|
153 | - ) |
|
154 | - ); |
|
155 | - return $count_for_ids === count($registrations); |
|
156 | - } |
|
157 | - } |
|
158 | - return false; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
164 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
165 | - * |
|
166 | - * @param array $data |
|
167 | - * @return EE_Registration[] |
|
168 | - * @throws EE_Error |
|
169 | - * @throws InvalidArgumentException |
|
170 | - * @throws InvalidDataTypeException |
|
171 | - * @throws InvalidInterfaceException |
|
172 | - */ |
|
173 | - public static function convert_data_from_persistent_storage($data) |
|
174 | - { |
|
175 | - // since this was added later, we need to account of possible back compat issues where data already queued for |
|
176 | - // generation is in the old format, which is an array of EE_Registration objects. So if that's the case, then |
|
177 | - // let's just return them |
|
178 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10127 |
|
179 | - if (is_array($data) && reset($data) instanceof EE_Registration) { |
|
180 | - return $data; |
|
181 | - } |
|
182 | - |
|
183 | - $registrations = is_array($data) |
|
184 | - ? EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $data)))) |
|
185 | - : array(); |
|
186 | - return $registrations; |
|
187 | - } |
|
20 | + /** |
|
21 | + * Constructor. |
|
22 | + * |
|
23 | + * @param EE_Registration[] $data expecting an array of EE_Registration objects. |
|
24 | + * @throws EE_Error |
|
25 | + * @access protected |
|
26 | + */ |
|
27 | + public function __construct($data = array()) |
|
28 | + { |
|
29 | + |
|
30 | + // validate that the first element in the array is an EE_Registration object. |
|
31 | + if (! reset($data) instanceof EE_Registration) { |
|
32 | + throw new EE_Error( |
|
33 | + esc_html__( |
|
34 | + 'The EE_Message_Registrations_incoming_data class expects an array of EE_Registration objects.', |
|
35 | + 'event_espresso' |
|
36 | + ) |
|
37 | + ); |
|
38 | + } |
|
39 | + parent::__construct($data); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * setup the data. |
|
45 | + * Sets up the expected data object for the messages prep using incoming registration objects. |
|
46 | + * |
|
47 | + * @return void |
|
48 | + * @throws EE_Error |
|
49 | + * @throws EntityNotFoundException |
|
50 | + * @access protected |
|
51 | + */ |
|
52 | + protected function _setup_data() |
|
53 | + { |
|
54 | + // we'll loop through each contact and setup the data needed. Note that many properties will just be set as |
|
55 | + // empty because this data handler is for a very specific set of data (i.e. just what's related to the |
|
56 | + // registration). |
|
57 | + |
|
58 | + $this->reg_objs = $this->data(); |
|
59 | + $this->txn = $this->_maybe_get_transaction(); |
|
60 | + $this->_assemble_data(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * If the incoming registrations all share the same transaction then this will return the transaction object shared |
|
66 | + * among the registrations. Otherwise the transaction object is set to null because its intended to only represent |
|
67 | + * one transaction. |
|
68 | + * |
|
69 | + * @return EE_Transaction|null |
|
70 | + * @throws EE_Error |
|
71 | + * @throws EntityNotFoundException |
|
72 | + */ |
|
73 | + protected function _maybe_get_transaction() |
|
74 | + { |
|
75 | + $transactions = array(); |
|
76 | + foreach ($this->reg_objs as $registration) { |
|
77 | + if ($registration instanceof EE_Registration) { |
|
78 | + $transaction = $registration->transaction(); |
|
79 | + if ($transaction instanceof EE_Transaction) { |
|
80 | + $transactions[ $transaction->ID() ] = $transaction; |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + return count($transactions) === 1 ? reset($transactions) : null; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
90 | + * |
|
91 | + * @param array $registrations The incoming data to be prepped. |
|
92 | + * @return EE_Registration[] The data being prepared for the db |
|
93 | + * @throws EE_Error |
|
94 | + * @throws InvalidArgumentException |
|
95 | + * @throws InvalidDataTypeException |
|
96 | + * @throws InvalidInterfaceException |
|
97 | + */ |
|
98 | + public static function convert_data_for_persistent_storage($registrations) |
|
99 | + { |
|
100 | + if (! self::validateRegistrationsForConversion($registrations)) { |
|
101 | + return array(); |
|
102 | + } |
|
103 | + |
|
104 | + // is this an array of ints? |
|
105 | + $first_item = reset($registrations); |
|
106 | + if (is_int($first_item)) { |
|
107 | + return $registrations; |
|
108 | + } |
|
109 | + |
|
110 | + // k nope so let's pull from the registrations |
|
111 | + $registration_ids = array_filter( |
|
112 | + array_map( |
|
113 | + function ($registration) { |
|
114 | + if ($registration instanceof EE_Registration) { |
|
115 | + return $registration->ID(); |
|
116 | + } |
|
117 | + return false; |
|
118 | + }, |
|
119 | + $registrations |
|
120 | + ) |
|
121 | + ); |
|
122 | + |
|
123 | + return $registration_ids; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * This validates incoming registrations (considers whether they are ids or EE_Registration objects. |
|
129 | + * |
|
130 | + * @param array $registrations Could be EE_Registration[] or int[] |
|
131 | + * @return bool |
|
132 | + * @throws EE_Error |
|
133 | + * @throws InvalidArgumentException |
|
134 | + * @throws InvalidDataTypeException |
|
135 | + * @throws InvalidInterfaceException |
|
136 | + */ |
|
137 | + protected static function validateRegistrationsForConversion($registrations) |
|
138 | + { |
|
139 | + if (is_array($registrations)) { |
|
140 | + $first_item = reset($registrations); |
|
141 | + if ($first_item instanceof EE_Registration) { |
|
142 | + return true; |
|
143 | + } |
|
144 | + if (is_int($first_item)) { |
|
145 | + // k let's some basic validation here. This isn't foolproof but better than nothing. |
|
146 | + // the purpose of this validation is to verify that the ids sent in match valid registrations existing |
|
147 | + // in the db. If the count is different, then we know they aren't valid. |
|
148 | + $count_for_ids = EEM_Registration::instance()->count( |
|
149 | + array( |
|
150 | + array( |
|
151 | + 'REG_ID' => array('IN', $registrations) |
|
152 | + ) |
|
153 | + ) |
|
154 | + ); |
|
155 | + return $count_for_ids === count($registrations); |
|
156 | + } |
|
157 | + } |
|
158 | + return false; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
164 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
165 | + * |
|
166 | + * @param array $data |
|
167 | + * @return EE_Registration[] |
|
168 | + * @throws EE_Error |
|
169 | + * @throws InvalidArgumentException |
|
170 | + * @throws InvalidDataTypeException |
|
171 | + * @throws InvalidInterfaceException |
|
172 | + */ |
|
173 | + public static function convert_data_from_persistent_storage($data) |
|
174 | + { |
|
175 | + // since this was added later, we need to account of possible back compat issues where data already queued for |
|
176 | + // generation is in the old format, which is an array of EE_Registration objects. So if that's the case, then |
|
177 | + // let's just return them |
|
178 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10127 |
|
179 | + if (is_array($data) && reset($data) instanceof EE_Registration) { |
|
180 | + return $data; |
|
181 | + } |
|
182 | + |
|
183 | + $registrations = is_array($data) |
|
184 | + ? EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $data)))) |
|
185 | + : array(); |
|
186 | + return $registrations; |
|
187 | + } |
|
188 | 188 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | |
30 | 30 | // validate that the first element in the array is an EE_Registration object. |
31 | - if (! reset($data) instanceof EE_Registration) { |
|
31 | + if ( ! reset($data) instanceof EE_Registration) { |
|
32 | 32 | throw new EE_Error( |
33 | 33 | esc_html__( |
34 | 34 | 'The EE_Message_Registrations_incoming_data class expects an array of EE_Registration objects.', |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if ($registration instanceof EE_Registration) { |
78 | 78 | $transaction = $registration->transaction(); |
79 | 79 | if ($transaction instanceof EE_Transaction) { |
80 | - $transactions[ $transaction->ID() ] = $transaction; |
|
80 | + $transactions[$transaction->ID()] = $transaction; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public static function convert_data_for_persistent_storage($registrations) |
99 | 99 | { |
100 | - if (! self::validateRegistrationsForConversion($registrations)) { |
|
100 | + if ( ! self::validateRegistrationsForConversion($registrations)) { |
|
101 | 101 | return array(); |
102 | 102 | } |
103 | 103 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | // k nope so let's pull from the registrations |
111 | 111 | $registration_ids = array_filter( |
112 | 112 | array_map( |
113 | - function ($registration) { |
|
113 | + function($registration) { |
|
114 | 114 | if ($registration instanceof EE_Registration) { |
115 | 115 | return $registration->ID(); |
116 | 116 | } |
@@ -15,37 +15,37 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - public function __construct($fields, $context) |
|
19 | - { |
|
20 | - $this->_m_name = 'email'; |
|
21 | - $this->_mt_name = 'payment_refund'; |
|
22 | - |
|
23 | - parent::__construct($fields, $context); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * at this point no custom validation needed for this messenger/message_type combo. |
|
28 | - */ |
|
29 | - protected function _modify_validator() |
|
30 | - { |
|
31 | - $new_config = $this->_messenger->get_validator_config(); |
|
32 | - |
|
33 | - // modify just event_list |
|
34 | - $new_config['event_list'] = array( |
|
35 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
36 | - ); |
|
37 | - $new_config['ticket_list'] = array( |
|
38 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction') |
|
39 | - ); |
|
40 | - $new_config['content'] = array( |
|
41 | - 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
42 | - ); |
|
43 | - $this->_messenger->set_validator_config($new_config); |
|
44 | - |
|
45 | - if ($this->_context != 'admin') { |
|
46 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
47 | - } |
|
48 | - |
|
49 | - $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
50 | - } |
|
18 | + public function __construct($fields, $context) |
|
19 | + { |
|
20 | + $this->_m_name = 'email'; |
|
21 | + $this->_mt_name = 'payment_refund'; |
|
22 | + |
|
23 | + parent::__construct($fields, $context); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * at this point no custom validation needed for this messenger/message_type combo. |
|
28 | + */ |
|
29 | + protected function _modify_validator() |
|
30 | + { |
|
31 | + $new_config = $this->_messenger->get_validator_config(); |
|
32 | + |
|
33 | + // modify just event_list |
|
34 | + $new_config['event_list'] = array( |
|
35 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
36 | + ); |
|
37 | + $new_config['ticket_list'] = array( |
|
38 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction') |
|
39 | + ); |
|
40 | + $new_config['content'] = array( |
|
41 | + 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
42 | + ); |
|
43 | + $this->_messenger->set_validator_config($new_config); |
|
44 | + |
|
45 | + if ($this->_context != 'admin') { |
|
46 | + $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
47 | + } |
|
48 | + |
|
49 | + $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
50 | + } |
|
51 | 51 | } |
@@ -32,18 +32,18 @@ |
||
32 | 32 | |
33 | 33 | // modify just event_list |
34 | 34 | $new_config['event_list'] = array( |
35 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
35 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
36 | 36 | ); |
37 | 37 | $new_config['ticket_list'] = array( |
38 | 38 | 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction') |
39 | 39 | ); |
40 | 40 | $new_config['content'] = array( |
41 | - 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
41 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
42 | 42 | ); |
43 | 43 | $this->_messenger->set_validator_config($new_config); |
44 | 44 | |
45 | 45 | if ($this->_context != 'admin') { |
46 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
46 | + $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -16,31 +16,31 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - public function __construct($fields, $context) |
|
20 | - { |
|
21 | - $this->_m_name = 'email'; |
|
22 | - $this->_mt_name = 'registration_summary'; |
|
19 | + public function __construct($fields, $context) |
|
20 | + { |
|
21 | + $this->_m_name = 'email'; |
|
22 | + $this->_mt_name = 'registration_summary'; |
|
23 | 23 | |
24 | - parent::__construct($fields, $context); |
|
25 | - } |
|
24 | + parent::__construct($fields, $context); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * custom validator (restricting what was originally set by the messenger) |
|
29 | - */ |
|
30 | - protected function _modify_validator() |
|
31 | - { |
|
32 | - $new_config = $this->_messenger->get_validator_config(); |
|
33 | - // modify just event_list |
|
34 | - $new_config['event_list'] = array( |
|
35 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
36 | - 'required' => array('[EVENT_LIST]') |
|
37 | - ); |
|
38 | - $this->_messenger->set_validator_config($new_config); |
|
27 | + /** |
|
28 | + * custom validator (restricting what was originally set by the messenger) |
|
29 | + */ |
|
30 | + protected function _modify_validator() |
|
31 | + { |
|
32 | + $new_config = $this->_messenger->get_validator_config(); |
|
33 | + // modify just event_list |
|
34 | + $new_config['event_list'] = array( |
|
35 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
36 | + 'required' => array('[EVENT_LIST]') |
|
37 | + ); |
|
38 | + $this->_messenger->set_validator_config($new_config); |
|
39 | 39 | |
40 | - if ($this->_context != 'admin') { |
|
41 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
42 | - } |
|
40 | + if ($this->_context != 'admin') { |
|
41 | + $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
42 | + } |
|
43 | 43 | |
44 | - $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
45 | - } |
|
44 | + $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
45 | + } |
|
46 | 46 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $this->_messenger->set_validator_config($new_config); |
39 | 39 | |
40 | 40 | if ($this->_context != 'admin') { |
41 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | + $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -15,31 +15,31 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - public function __construct($fields, $context) |
|
19 | - { |
|
20 | - $this->_m_name = 'email'; |
|
21 | - $this->_mt_name = 'registration'; |
|
18 | + public function __construct($fields, $context) |
|
19 | + { |
|
20 | + $this->_m_name = 'email'; |
|
21 | + $this->_mt_name = 'registration'; |
|
22 | 22 | |
23 | - parent::__construct($fields, $context); |
|
24 | - } |
|
23 | + parent::__construct($fields, $context); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * custom validator (restricting what was originally set by the messenger) |
|
28 | - */ |
|
29 | - protected function _modify_validator() |
|
30 | - { |
|
31 | - $new_config = $this->_messenger->get_validator_config(); |
|
32 | - // modify just event_list |
|
33 | - $new_config['event_list'] = array( |
|
34 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
35 | - 'required' => array('[EVENT_LIST]') |
|
36 | - ); |
|
37 | - $this->_messenger->set_validator_config($new_config); |
|
26 | + /** |
|
27 | + * custom validator (restricting what was originally set by the messenger) |
|
28 | + */ |
|
29 | + protected function _modify_validator() |
|
30 | + { |
|
31 | + $new_config = $this->_messenger->get_validator_config(); |
|
32 | + // modify just event_list |
|
33 | + $new_config['event_list'] = array( |
|
34 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
35 | + 'required' => array('[EVENT_LIST]') |
|
36 | + ); |
|
37 | + $this->_messenger->set_validator_config($new_config); |
|
38 | 38 | |
39 | - if ($this->_context != 'admin') { |
|
40 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | - } |
|
39 | + if ($this->_context != 'admin') { |
|
40 | + $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | + } |
|
42 | 42 | |
43 | - $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
44 | - } |
|
43 | + $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
44 | + } |
|
45 | 45 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $this->_messenger->set_validator_config($new_config); |
39 | 39 | |
40 | 40 | if ($this->_context != 'admin') { |
41 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | + $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -15,30 +15,30 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - public function __construct($fields, $context) |
|
19 | - { |
|
20 | - $this->_m_name = 'email'; |
|
21 | - $this->_mt_name = 'not_approved_registration'; |
|
18 | + public function __construct($fields, $context) |
|
19 | + { |
|
20 | + $this->_m_name = 'email'; |
|
21 | + $this->_mt_name = 'not_approved_registration'; |
|
22 | 22 | |
23 | - parent::__construct($fields, $context); |
|
24 | - } |
|
23 | + parent::__construct($fields, $context); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * custom validator (restricting what was originally set by the messenger) |
|
28 | - */ |
|
29 | - protected function _modify_validator() |
|
30 | - { |
|
31 | - $new_config = $this->_messenger->get_validator_config(); |
|
32 | - $new_config['event_list'] = array( |
|
33 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
34 | - 'required' => array('[EVENT_LIST]') |
|
35 | - ); |
|
36 | - $this->_messenger->set_validator_config($new_config); |
|
26 | + /** |
|
27 | + * custom validator (restricting what was originally set by the messenger) |
|
28 | + */ |
|
29 | + protected function _modify_validator() |
|
30 | + { |
|
31 | + $new_config = $this->_messenger->get_validator_config(); |
|
32 | + $new_config['event_list'] = array( |
|
33 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
34 | + 'required' => array('[EVENT_LIST]') |
|
35 | + ); |
|
36 | + $this->_messenger->set_validator_config($new_config); |
|
37 | 37 | |
38 | - if ($this->_context != 'admin') { |
|
39 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
40 | - } |
|
38 | + if ($this->_context != 'admin') { |
|
39 | + $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
40 | + } |
|
41 | 41 | |
42 | - $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
43 | - } |
|
42 | + $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
43 | + } |
|
44 | 44 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $this->_messenger->set_validator_config($new_config); |
39 | 39 | |
40 | 40 | if ($this->_context != 'admin') { |
41 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | + $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -15,31 +15,31 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - public function __construct($fields, $context) |
|
19 | - { |
|
20 | - $this->_m_name = 'email'; |
|
21 | - $this->_mt_name = 'pending_approval'; |
|
18 | + public function __construct($fields, $context) |
|
19 | + { |
|
20 | + $this->_m_name = 'email'; |
|
21 | + $this->_mt_name = 'pending_approval'; |
|
22 | 22 | |
23 | - parent::__construct($fields, $context); |
|
24 | - } |
|
23 | + parent::__construct($fields, $context); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * custom validator (restricting what was originally set by the messenger) |
|
28 | - */ |
|
29 | - protected function _modify_validator() |
|
30 | - { |
|
31 | - $new_config = $this->_messenger->get_validator_config(); |
|
32 | - // modify just event_list |
|
33 | - $new_config['event_list'] = array( |
|
34 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
35 | - 'required' => array('[EVENT_LIST]') |
|
36 | - ); |
|
37 | - $this->_messenger->set_validator_config($new_config); |
|
26 | + /** |
|
27 | + * custom validator (restricting what was originally set by the messenger) |
|
28 | + */ |
|
29 | + protected function _modify_validator() |
|
30 | + { |
|
31 | + $new_config = $this->_messenger->get_validator_config(); |
|
32 | + // modify just event_list |
|
33 | + $new_config['event_list'] = array( |
|
34 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
|
35 | + 'required' => array('[EVENT_LIST]') |
|
36 | + ); |
|
37 | + $this->_messenger->set_validator_config($new_config); |
|
38 | 38 | |
39 | - if ($this->_context != 'admin') { |
|
40 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | - } |
|
39 | + if ($this->_context != 'admin') { |
|
40 | + $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | + } |
|
42 | 42 | |
43 | - $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
44 | - } |
|
43 | + $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
|
44 | + } |
|
45 | 45 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $this->_messenger->set_validator_config($new_config); |
39 | 39 | |
40 | 40 | if ($this->_context != 'admin') { |
41 | - $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
41 | + $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |