@@ -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,584 +18,584 @@ |
||
18 | 18 | class EE_Messages_Preview_incoming_data extends EE_Messages_incoming_data |
19 | 19 | { |
20 | 20 | |
21 | - // some specific properties we need for this class |
|
22 | - private $_events = array(); |
|
23 | - private $_attendees = array(); |
|
24 | - private $_registrations = array(); |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
29 | - * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
30 | - * we'll get the first three published events from the users database and use that as a source. |
|
31 | - * |
|
32 | - * @param array $data |
|
33 | - */ |
|
34 | - public function __construct($data = array()) |
|
35 | - { |
|
36 | - $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
37 | - $this->_setup_attendees_events(); |
|
38 | - parent::__construct($data); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
44 | - * |
|
45 | - * @param array $data The incoming data to be prepped. |
|
46 | - * |
|
47 | - * @return array The prepped data for db |
|
48 | - */ |
|
49 | - public static function convert_data_for_persistent_storage($data) |
|
50 | - { |
|
51 | - return $data; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
57 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
58 | - * |
|
59 | - * @param array $data |
|
60 | - * |
|
61 | - * @return array |
|
62 | - */ |
|
63 | - public static function convert_data_from_persistent_storage($data) |
|
64 | - { |
|
65 | - return $data; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * This will just setup the _events property in the expected format. |
|
71 | - * |
|
72 | - * @throws \EE_Error |
|
73 | - */ |
|
74 | - private function _setup_attendees_events() |
|
75 | - { |
|
76 | - |
|
77 | - // setup some attendee objects |
|
78 | - $attendees = $this->_get_some_attendees(); |
|
79 | - |
|
80 | - // 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. |
|
81 | - $events = $this->_get_some_events($this->_data); |
|
82 | - |
|
83 | - $answers_n_questions = $this->_get_some_q_and_as(); |
|
84 | - |
|
85 | - if (count($events) < 1) { |
|
86 | - throw new EE_Error(__( |
|
87 | - 'We can\'t generate a preview for you because there are no active events in your database', |
|
88 | - 'event_espresso' |
|
89 | - )); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
94 | - |
|
95 | - |
|
96 | - // we'll actually use the generated line_item identifiers for our loop |
|
97 | - $dtts = $tkts = array(); |
|
98 | - foreach ($events as $id => $event) { |
|
99 | - if (! $event instanceof EE_Event) { |
|
100 | - continue; |
|
101 | - } |
|
102 | - $this->_events[ $id ]['ID'] = $id; |
|
103 | - $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
104 | - $datetime = $event->get_first_related('Datetime'); |
|
105 | - $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
106 | - 'Ticket', |
|
107 | - array('default_where_conditions' => 'none') |
|
108 | - ) : array(); |
|
109 | - $this->_events[ $id ]['event'] = $event; |
|
110 | - $this->_events[ $id ]['reg_objs'] = array(); |
|
111 | - $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
112 | - $this->_events[ $id ]['dtt_objs'] = array(); |
|
113 | - |
|
114 | - $dttcache = array(); |
|
115 | - $tkts = array(); |
|
116 | - foreach ($tickets as $ticket) { |
|
117 | - if (! $ticket instanceof EE_Ticket) { |
|
118 | - continue; |
|
119 | - } |
|
120 | - $reldatetime = $ticket->datetimes(); |
|
121 | - $tkts[ $ticket->ID() ] = array(); |
|
122 | - $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
123 | - $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
124 | - $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
125 | - $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
126 | - $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
127 | - foreach ($reldatetime as $datetime) { |
|
128 | - if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
129 | - $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
130 | - $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
131 | - $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
132 | - $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
133 | - $dttcache[ $datetime->ID() ] = $datetime; |
|
134 | - } |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
139 | - $this->_events[ $id ]['att_objs'] = $attendees; |
|
140 | - |
|
141 | - // let's also setup the dummy attendees property! |
|
142 | - foreach ($attendees as $att_key => $attendee) { |
|
143 | - if (! $attendee instanceof EE_Attendee) { |
|
144 | - continue; |
|
145 | - } |
|
146 | - $this->_attendees[ $att_key ]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
147 | - $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
148 | - $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
149 | - // $this->_attendees[$att_key]['registration_id'] = 0; |
|
150 | - $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
151 | - $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
152 | - if ($att_key == 999999991) { |
|
153 | - $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
154 | - $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
155 | - $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
156 | - } elseif ($att_key == 999999992) { |
|
157 | - $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
158 | - $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
159 | - $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
160 | - } elseif ($att_key == 999999993) { |
|
161 | - $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
162 | - $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
163 | - $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
164 | - } |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - $this->tickets = $tkts; |
|
169 | - $this->datetimes = $dtts; |
|
170 | - $this->answers = $answers_n_questions['answers']; |
|
171 | - $this->questions = $answers_n_questions['questions']; |
|
172 | - $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
178 | - * |
|
179 | - * @access private |
|
180 | - * @return array an array of attendee objects |
|
181 | - */ |
|
182 | - private function _get_some_attendees() |
|
183 | - { |
|
184 | - // let's just setup a dummy array of various attendee details |
|
185 | - $dummy_attendees = array( |
|
186 | - 0 => array( |
|
187 | - 'Luke', |
|
188 | - 'Skywalker', |
|
189 | - '[email protected]', |
|
190 | - '804 Bantha Dr.', |
|
191 | - 'Complex 8', |
|
192 | - 'Mos Eisley', |
|
193 | - 32, |
|
194 | - 'US', |
|
195 | - 'f0r3e', |
|
196 | - '222-333-4763', |
|
197 | - false, |
|
198 | - '999999991' |
|
199 | - ), |
|
200 | - 1 => array( |
|
201 | - 'Princess', |
|
202 | - 'Leia', |
|
203 | - '[email protected]', |
|
204 | - '1456 Valley Way Boulevard', |
|
205 | - 'Suite 9', |
|
206 | - 'Alderaan', |
|
207 | - 15, |
|
208 | - 'US', |
|
209 | - 'c1h2c', |
|
210 | - '78-123-111-1111', |
|
211 | - false, |
|
212 | - '999999992' |
|
213 | - ), |
|
214 | - 2 => array( |
|
215 | - 'Yoda', |
|
216 | - 'I Am', |
|
217 | - '[email protected]', |
|
218 | - '4th Tree', |
|
219 | - '5th Knot', |
|
220 | - 'Marsh', |
|
221 | - 22, |
|
222 | - 'US', |
|
223 | - 'l18n', |
|
224 | - '999-999-9999', |
|
225 | - false, |
|
226 | - '999999993' |
|
227 | - ), |
|
228 | - ); |
|
229 | - |
|
230 | - // let's generate the attendee objects |
|
231 | - $attendees = array(); |
|
232 | - $var_array = array( |
|
233 | - 'fname', |
|
234 | - 'lname', |
|
235 | - 'email', |
|
236 | - 'address', |
|
237 | - 'address2', |
|
238 | - 'city', |
|
239 | - 'staid', |
|
240 | - 'cntry', |
|
241 | - 'zip', |
|
242 | - 'phone', |
|
243 | - 'deleted', |
|
244 | - 'attid' |
|
245 | - ); |
|
246 | - |
|
247 | - // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
248 | - foreach ($dummy_attendees as $dummy) { |
|
249 | - $att = array_combine($var_array, $dummy); |
|
250 | - extract($att); |
|
251 | - /** @var $fname string */ |
|
252 | - /** @var $lname string */ |
|
253 | - /** @var $address string */ |
|
254 | - /** @var $address2 string */ |
|
255 | - /** @var $city string */ |
|
256 | - /** @var $staid string */ |
|
257 | - /** @var $cntry string */ |
|
258 | - /** @var $zip string */ |
|
259 | - /** @var $email string */ |
|
260 | - /** @var $phone string */ |
|
261 | - /** @var $attid string */ |
|
262 | - $attendees[ $attid ] = EE_Attendee::new_instance( |
|
263 | - array( |
|
264 | - 'ATT_fname' => $fname, |
|
265 | - 'ATT_lname' => $lname, |
|
266 | - 'ATT_address' => $address, |
|
267 | - 'ATT_address2' => $address2, |
|
268 | - 'ATT_city' => $city, |
|
269 | - 'STA_ID' => $staid, |
|
270 | - 'CNT_ISO' => $cntry, |
|
271 | - 'ATT_zip' => $zip, |
|
272 | - 'ATT_email' => $email, |
|
273 | - 'ATT_phone' => $phone, |
|
274 | - 'ATT_ID' => $attid |
|
275 | - ) |
|
276 | - ); |
|
277 | - } |
|
278 | - |
|
279 | - return $attendees; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
285 | - * This will be used in our dummy data setup |
|
286 | - * @return array |
|
287 | - */ |
|
288 | - private function _get_some_q_and_as() |
|
289 | - { |
|
290 | - |
|
291 | - |
|
292 | - $quests_array = array( |
|
293 | - 0 => array( |
|
294 | - 555, |
|
295 | - __('What is your favorite planet?', 'event_espresso'), |
|
296 | - 0 |
|
297 | - ), |
|
298 | - 1 => array( |
|
299 | - 556, |
|
300 | - __('What is your favorite food?', 'event_espresso'), |
|
301 | - 0 |
|
302 | - ), |
|
303 | - 2 => array( |
|
304 | - 557, |
|
305 | - __('How many lightyears have you travelled', 'event_espresso'), |
|
306 | - 0 |
|
307 | - ) |
|
308 | - ); |
|
309 | - |
|
310 | - |
|
311 | - $ans_array = array( |
|
312 | - 0 => array( |
|
313 | - 999, |
|
314 | - 555, |
|
315 | - 'Tattoine' |
|
316 | - ), |
|
317 | - 1 => array( |
|
318 | - 1000, |
|
319 | - 555, |
|
320 | - 'Alderaan' |
|
321 | - ), |
|
322 | - 2 => array( |
|
323 | - 1001, |
|
324 | - 555, |
|
325 | - 'Dantooine' |
|
326 | - ), |
|
327 | - 3 => array( |
|
328 | - 1002, |
|
329 | - 556, |
|
330 | - 'Fish Fingers' |
|
331 | - ), |
|
332 | - 4 => array( |
|
333 | - 1003, |
|
334 | - 556, |
|
335 | - 'Sushi' |
|
336 | - ), |
|
337 | - 5 => array( |
|
338 | - 1004, |
|
339 | - 556, |
|
340 | - 'Water' |
|
341 | - ), |
|
342 | - 6 => array( |
|
343 | - 1005, |
|
344 | - 557, |
|
345 | - 'A lot', |
|
346 | - ), |
|
347 | - 7 => array( |
|
348 | - 1006, |
|
349 | - 557, |
|
350 | - "That's none of your business." |
|
351 | - ), |
|
352 | - 8 => array( |
|
353 | - 1007, |
|
354 | - 557, |
|
355 | - "People less travel me then." |
|
356 | - ) |
|
357 | - ); |
|
358 | - |
|
359 | - $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
360 | - $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
361 | - |
|
362 | - // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
363 | - // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
364 | - |
|
365 | - $qsts = array(); |
|
366 | - // first the questions |
|
367 | - foreach ($quests_array as $qst) { |
|
368 | - $qstobj = array_combine($qst_columns, $qst); |
|
369 | - $qsts[ $qstobj['QST_ID'] ] = EE_Question::new_instance($qstobj); |
|
370 | - } |
|
371 | - |
|
372 | - // now the answers (and we'll setup our arrays) |
|
373 | - $q_n_as = array(); |
|
374 | - foreach ($ans_array as $ans) { |
|
375 | - $ansobj = array_combine($ans_columns, $ans); |
|
376 | - $ansobj = EE_Answer::new_instance($ansobj); |
|
377 | - $q_n_as['answers'][ $ansobj->ID() ] = $ansobj; |
|
378 | - $q_n_as['questions'][ $ansobj->ID() ] = $qsts[ $ansobj->get('QST_ID') ]; |
|
379 | - } |
|
380 | - |
|
381 | - return $q_n_as; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * Return an array of event objects from the database |
|
387 | - * |
|
388 | - * If event ids are not included then we'll just retrieve the first published event from the database. |
|
389 | - * |
|
390 | - * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
391 | - * |
|
392 | - * @return array An array of event objects from the db. |
|
393 | - */ |
|
394 | - private function _get_some_events($event_ids = array()) |
|
395 | - { |
|
396 | - |
|
397 | - // 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); |
|
398 | - $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
399 | - ? array($_REQUEST['evt_id']) |
|
400 | - : $event_ids; |
|
401 | - |
|
402 | - $limit = ! empty($event_ids) |
|
403 | - ? null |
|
404 | - : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
405 | - |
|
406 | - $where = ! empty($event_ids) |
|
407 | - ? array( |
|
408 | - 'EVT_ID' => array('IN', $event_ids), |
|
409 | - 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
410 | - ) |
|
411 | - : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
412 | - |
|
413 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
414 | - |
|
415 | - return $events; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - protected function _setup_data() |
|
420 | - { |
|
421 | - |
|
422 | - // 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! |
|
423 | - if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
424 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
425 | - $session = EE_Registry::instance()->SSN; |
|
426 | - } else { |
|
427 | - $session = EE_Registry::instance()->load_core('Session'); |
|
428 | - } |
|
429 | - $cart = EE_Cart::instance(null, $session); |
|
430 | - |
|
431 | - |
|
432 | - // add tickets to cart |
|
433 | - foreach ($this->tickets as $ticket) { |
|
434 | - $cart->add_ticket_to_cart($ticket['ticket']); |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - // setup txn property |
|
439 | - $this->txn = EE_Transaction::new_instance( |
|
440 | - array( |
|
441 | - 'TXN_timestamp' => time(), // unix timestamp |
|
442 | - 'TXN_total' => 0, // txn_total |
|
443 | - 'TXN_paid' => 0, // txn_paid |
|
444 | - 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
445 | - 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
446 | - 'TXN_hash_salt' => null, // hash salt blank as well |
|
447 | - 'TXN_ID' => 999999 |
|
448 | - ) |
|
449 | - ); |
|
450 | - |
|
451 | - |
|
452 | - // setup reg_objects |
|
453 | - // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
454 | - $this->reg_objs = array(); |
|
455 | - $regid = 9999990; |
|
456 | - foreach ($this->_attendees as $key => $attendee) { |
|
457 | - // note we need to setup reg_objects for each event this attendee belongs to |
|
458 | - $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
459 | - $regtxn = $this->txn->ID(); |
|
460 | - $regcnt = 1; |
|
461 | - foreach ($attendee['line_ref'] as $evtid) { |
|
462 | - foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
463 | - if (! $ticket instanceof EE_Ticket) { |
|
464 | - continue; |
|
465 | - } |
|
466 | - $reg_array = array( |
|
467 | - 'EVT_ID' => $evtid, |
|
468 | - 'ATT_ID' => $regatt, |
|
469 | - 'TXN_ID' => $regtxn, |
|
470 | - 'TKT_ID' => $ticket->ID(), |
|
471 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
472 | - 'REG_date' => time(), |
|
473 | - 'REG_final_price' => $ticket->get('TKT_price'), |
|
474 | - 'REG_session' => 'dummy_session_id', |
|
475 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
476 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
477 | - 'REG_count' => $regcnt, |
|
478 | - 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
479 | - 'REG_att_is_going' => true, |
|
480 | - 'REG_ID' => $regid |
|
481 | - ); |
|
482 | - $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
483 | - $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
484 | - $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
485 | - $this->reg_objs[] = $REG_OBJ; |
|
486 | - $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
487 | - |
|
488 | - $regcnt++; |
|
489 | - $regid++; |
|
490 | - } |
|
491 | - } |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - // setup line items! |
|
496 | - $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
497 | - |
|
498 | - // add tickets |
|
499 | - foreach ($this->tickets as $tktid => $item) { |
|
500 | - $qty = $item['count']; |
|
501 | - $ticket = $item['ticket']; |
|
502 | - EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
503 | - } |
|
504 | - |
|
505 | - $shipping_line_item = EE_Line_Item::new_instance(array( |
|
506 | - 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
507 | - 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
508 | - 'LIN_unit_price' => 20, |
|
509 | - 'LIN_quantity' => 1, |
|
510 | - 'LIN_is_taxable' => true, |
|
511 | - 'LIN_total' => 20, |
|
512 | - 'LIN_type' => EEM_Line_Item::type_line_item |
|
513 | - )); |
|
514 | - EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
515 | - $this->additional_line_items = array($shipping_line_item); |
|
516 | - |
|
517 | - // now let's add taxes |
|
518 | - EEH_Line_Item::apply_taxes($line_item_total); |
|
519 | - |
|
520 | - // now we should be able to get the items we need from this object |
|
521 | - $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
522 | - $line_items = array(); |
|
523 | - foreach ($event_line_items as $line_id => $line_item) { |
|
524 | - if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
525 | - continue; |
|
526 | - } |
|
527 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
528 | - foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
529 | - if (! $ticket_line_item instanceof EE_Line_Item) { |
|
530 | - continue; |
|
531 | - } |
|
532 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
533 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
534 | - $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
535 | - $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
536 | - } |
|
537 | - } |
|
538 | - |
|
539 | - $this->line_items_with_children = $line_items; |
|
540 | - $this->tax_line_items = $line_item_total->tax_descendants(); |
|
541 | - |
|
542 | - // add proper total to transaction object. |
|
543 | - $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
544 | - $this->grand_total_line_item = $line_item_total; |
|
545 | - $this->txn->set_total($grand_total); |
|
546 | - |
|
547 | - |
|
548 | - // add additional details for each registration |
|
549 | - foreach ($this->reg_objs as $reg) { |
|
550 | - if (! $reg instanceof EE_Registration) { |
|
551 | - continue; |
|
552 | - } |
|
553 | - $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
554 | - $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
555 | - $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
556 | - $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
557 | - $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
558 | - $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - // events and attendees |
|
563 | - $this->events = $this->_events; |
|
564 | - $this->attendees = $this->_attendees; |
|
565 | - $this->registrations = $this->_registrations; |
|
566 | - |
|
567 | - $attendees_to_shift = $this->_attendees; |
|
568 | - |
|
569 | - // setup primary attendee property |
|
570 | - $this->primary_attendee_data = array( |
|
571 | - 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
572 | - ? $this->_attendees[999999991]['att_obj']->fname() |
|
573 | - : '', |
|
574 | - |
|
575 | - 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
576 | - ? $this->_attendees[999999991]['att_obj']->lname() |
|
577 | - : '', |
|
578 | - |
|
579 | - 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
580 | - ? $this->_attendees[999999991]['att_obj']->email() |
|
581 | - : '', |
|
582 | - |
|
583 | - 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
584 | - |
|
585 | - 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
586 | - ); |
|
587 | - |
|
588 | - // reg_info property |
|
589 | - // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
590 | - $this->reg_info = array(); |
|
591 | - |
|
592 | - // let's set a reg_obj for messengers expecting one. |
|
593 | - $this->reg_obj = array_shift($this->_attendees[999999991]['reg_objs']); |
|
594 | - // the below are just dummy items. |
|
595 | - $this->user_id = 1; |
|
596 | - $this->ip_address = '192.0.2.1'; |
|
597 | - $this->user_agent = ''; |
|
598 | - $this->init_access = time(); |
|
599 | - $this->last_access = time(); |
|
600 | - } |
|
21 | + // some specific properties we need for this class |
|
22 | + private $_events = array(); |
|
23 | + private $_attendees = array(); |
|
24 | + private $_registrations = array(); |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
29 | + * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
30 | + * we'll get the first three published events from the users database and use that as a source. |
|
31 | + * |
|
32 | + * @param array $data |
|
33 | + */ |
|
34 | + public function __construct($data = array()) |
|
35 | + { |
|
36 | + $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
37 | + $this->_setup_attendees_events(); |
|
38 | + parent::__construct($data); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
44 | + * |
|
45 | + * @param array $data The incoming data to be prepped. |
|
46 | + * |
|
47 | + * @return array The prepped data for db |
|
48 | + */ |
|
49 | + public static function convert_data_for_persistent_storage($data) |
|
50 | + { |
|
51 | + return $data; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
57 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
58 | + * |
|
59 | + * @param array $data |
|
60 | + * |
|
61 | + * @return array |
|
62 | + */ |
|
63 | + public static function convert_data_from_persistent_storage($data) |
|
64 | + { |
|
65 | + return $data; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * This will just setup the _events property in the expected format. |
|
71 | + * |
|
72 | + * @throws \EE_Error |
|
73 | + */ |
|
74 | + private function _setup_attendees_events() |
|
75 | + { |
|
76 | + |
|
77 | + // setup some attendee objects |
|
78 | + $attendees = $this->_get_some_attendees(); |
|
79 | + |
|
80 | + // 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. |
|
81 | + $events = $this->_get_some_events($this->_data); |
|
82 | + |
|
83 | + $answers_n_questions = $this->_get_some_q_and_as(); |
|
84 | + |
|
85 | + if (count($events) < 1) { |
|
86 | + throw new EE_Error(__( |
|
87 | + 'We can\'t generate a preview for you because there are no active events in your database', |
|
88 | + 'event_espresso' |
|
89 | + )); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
94 | + |
|
95 | + |
|
96 | + // we'll actually use the generated line_item identifiers for our loop |
|
97 | + $dtts = $tkts = array(); |
|
98 | + foreach ($events as $id => $event) { |
|
99 | + if (! $event instanceof EE_Event) { |
|
100 | + continue; |
|
101 | + } |
|
102 | + $this->_events[ $id ]['ID'] = $id; |
|
103 | + $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
104 | + $datetime = $event->get_first_related('Datetime'); |
|
105 | + $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
106 | + 'Ticket', |
|
107 | + array('default_where_conditions' => 'none') |
|
108 | + ) : array(); |
|
109 | + $this->_events[ $id ]['event'] = $event; |
|
110 | + $this->_events[ $id ]['reg_objs'] = array(); |
|
111 | + $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
112 | + $this->_events[ $id ]['dtt_objs'] = array(); |
|
113 | + |
|
114 | + $dttcache = array(); |
|
115 | + $tkts = array(); |
|
116 | + foreach ($tickets as $ticket) { |
|
117 | + if (! $ticket instanceof EE_Ticket) { |
|
118 | + continue; |
|
119 | + } |
|
120 | + $reldatetime = $ticket->datetimes(); |
|
121 | + $tkts[ $ticket->ID() ] = array(); |
|
122 | + $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
123 | + $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
124 | + $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
125 | + $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
126 | + $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
127 | + foreach ($reldatetime as $datetime) { |
|
128 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
129 | + $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
130 | + $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
131 | + $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
132 | + $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
133 | + $dttcache[ $datetime->ID() ] = $datetime; |
|
134 | + } |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
139 | + $this->_events[ $id ]['att_objs'] = $attendees; |
|
140 | + |
|
141 | + // let's also setup the dummy attendees property! |
|
142 | + foreach ($attendees as $att_key => $attendee) { |
|
143 | + if (! $attendee instanceof EE_Attendee) { |
|
144 | + continue; |
|
145 | + } |
|
146 | + $this->_attendees[ $att_key ]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
147 | + $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
148 | + $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
149 | + // $this->_attendees[$att_key]['registration_id'] = 0; |
|
150 | + $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
151 | + $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
152 | + if ($att_key == 999999991) { |
|
153 | + $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
154 | + $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
155 | + $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
156 | + } elseif ($att_key == 999999992) { |
|
157 | + $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
158 | + $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
159 | + $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
160 | + } elseif ($att_key == 999999993) { |
|
161 | + $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
162 | + $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
163 | + $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
164 | + } |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + $this->tickets = $tkts; |
|
169 | + $this->datetimes = $dtts; |
|
170 | + $this->answers = $answers_n_questions['answers']; |
|
171 | + $this->questions = $answers_n_questions['questions']; |
|
172 | + $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
178 | + * |
|
179 | + * @access private |
|
180 | + * @return array an array of attendee objects |
|
181 | + */ |
|
182 | + private function _get_some_attendees() |
|
183 | + { |
|
184 | + // let's just setup a dummy array of various attendee details |
|
185 | + $dummy_attendees = array( |
|
186 | + 0 => array( |
|
187 | + 'Luke', |
|
188 | + 'Skywalker', |
|
189 | + '[email protected]', |
|
190 | + '804 Bantha Dr.', |
|
191 | + 'Complex 8', |
|
192 | + 'Mos Eisley', |
|
193 | + 32, |
|
194 | + 'US', |
|
195 | + 'f0r3e', |
|
196 | + '222-333-4763', |
|
197 | + false, |
|
198 | + '999999991' |
|
199 | + ), |
|
200 | + 1 => array( |
|
201 | + 'Princess', |
|
202 | + 'Leia', |
|
203 | + '[email protected]', |
|
204 | + '1456 Valley Way Boulevard', |
|
205 | + 'Suite 9', |
|
206 | + 'Alderaan', |
|
207 | + 15, |
|
208 | + 'US', |
|
209 | + 'c1h2c', |
|
210 | + '78-123-111-1111', |
|
211 | + false, |
|
212 | + '999999992' |
|
213 | + ), |
|
214 | + 2 => array( |
|
215 | + 'Yoda', |
|
216 | + 'I Am', |
|
217 | + '[email protected]', |
|
218 | + '4th Tree', |
|
219 | + '5th Knot', |
|
220 | + 'Marsh', |
|
221 | + 22, |
|
222 | + 'US', |
|
223 | + 'l18n', |
|
224 | + '999-999-9999', |
|
225 | + false, |
|
226 | + '999999993' |
|
227 | + ), |
|
228 | + ); |
|
229 | + |
|
230 | + // let's generate the attendee objects |
|
231 | + $attendees = array(); |
|
232 | + $var_array = array( |
|
233 | + 'fname', |
|
234 | + 'lname', |
|
235 | + 'email', |
|
236 | + 'address', |
|
237 | + 'address2', |
|
238 | + 'city', |
|
239 | + 'staid', |
|
240 | + 'cntry', |
|
241 | + 'zip', |
|
242 | + 'phone', |
|
243 | + 'deleted', |
|
244 | + 'attid' |
|
245 | + ); |
|
246 | + |
|
247 | + // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
248 | + foreach ($dummy_attendees as $dummy) { |
|
249 | + $att = array_combine($var_array, $dummy); |
|
250 | + extract($att); |
|
251 | + /** @var $fname string */ |
|
252 | + /** @var $lname string */ |
|
253 | + /** @var $address string */ |
|
254 | + /** @var $address2 string */ |
|
255 | + /** @var $city string */ |
|
256 | + /** @var $staid string */ |
|
257 | + /** @var $cntry string */ |
|
258 | + /** @var $zip string */ |
|
259 | + /** @var $email string */ |
|
260 | + /** @var $phone string */ |
|
261 | + /** @var $attid string */ |
|
262 | + $attendees[ $attid ] = EE_Attendee::new_instance( |
|
263 | + array( |
|
264 | + 'ATT_fname' => $fname, |
|
265 | + 'ATT_lname' => $lname, |
|
266 | + 'ATT_address' => $address, |
|
267 | + 'ATT_address2' => $address2, |
|
268 | + 'ATT_city' => $city, |
|
269 | + 'STA_ID' => $staid, |
|
270 | + 'CNT_ISO' => $cntry, |
|
271 | + 'ATT_zip' => $zip, |
|
272 | + 'ATT_email' => $email, |
|
273 | + 'ATT_phone' => $phone, |
|
274 | + 'ATT_ID' => $attid |
|
275 | + ) |
|
276 | + ); |
|
277 | + } |
|
278 | + |
|
279 | + return $attendees; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
285 | + * This will be used in our dummy data setup |
|
286 | + * @return array |
|
287 | + */ |
|
288 | + private function _get_some_q_and_as() |
|
289 | + { |
|
290 | + |
|
291 | + |
|
292 | + $quests_array = array( |
|
293 | + 0 => array( |
|
294 | + 555, |
|
295 | + __('What is your favorite planet?', 'event_espresso'), |
|
296 | + 0 |
|
297 | + ), |
|
298 | + 1 => array( |
|
299 | + 556, |
|
300 | + __('What is your favorite food?', 'event_espresso'), |
|
301 | + 0 |
|
302 | + ), |
|
303 | + 2 => array( |
|
304 | + 557, |
|
305 | + __('How many lightyears have you travelled', 'event_espresso'), |
|
306 | + 0 |
|
307 | + ) |
|
308 | + ); |
|
309 | + |
|
310 | + |
|
311 | + $ans_array = array( |
|
312 | + 0 => array( |
|
313 | + 999, |
|
314 | + 555, |
|
315 | + 'Tattoine' |
|
316 | + ), |
|
317 | + 1 => array( |
|
318 | + 1000, |
|
319 | + 555, |
|
320 | + 'Alderaan' |
|
321 | + ), |
|
322 | + 2 => array( |
|
323 | + 1001, |
|
324 | + 555, |
|
325 | + 'Dantooine' |
|
326 | + ), |
|
327 | + 3 => array( |
|
328 | + 1002, |
|
329 | + 556, |
|
330 | + 'Fish Fingers' |
|
331 | + ), |
|
332 | + 4 => array( |
|
333 | + 1003, |
|
334 | + 556, |
|
335 | + 'Sushi' |
|
336 | + ), |
|
337 | + 5 => array( |
|
338 | + 1004, |
|
339 | + 556, |
|
340 | + 'Water' |
|
341 | + ), |
|
342 | + 6 => array( |
|
343 | + 1005, |
|
344 | + 557, |
|
345 | + 'A lot', |
|
346 | + ), |
|
347 | + 7 => array( |
|
348 | + 1006, |
|
349 | + 557, |
|
350 | + "That's none of your business." |
|
351 | + ), |
|
352 | + 8 => array( |
|
353 | + 1007, |
|
354 | + 557, |
|
355 | + "People less travel me then." |
|
356 | + ) |
|
357 | + ); |
|
358 | + |
|
359 | + $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
360 | + $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
361 | + |
|
362 | + // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
363 | + // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
364 | + |
|
365 | + $qsts = array(); |
|
366 | + // first the questions |
|
367 | + foreach ($quests_array as $qst) { |
|
368 | + $qstobj = array_combine($qst_columns, $qst); |
|
369 | + $qsts[ $qstobj['QST_ID'] ] = EE_Question::new_instance($qstobj); |
|
370 | + } |
|
371 | + |
|
372 | + // now the answers (and we'll setup our arrays) |
|
373 | + $q_n_as = array(); |
|
374 | + foreach ($ans_array as $ans) { |
|
375 | + $ansobj = array_combine($ans_columns, $ans); |
|
376 | + $ansobj = EE_Answer::new_instance($ansobj); |
|
377 | + $q_n_as['answers'][ $ansobj->ID() ] = $ansobj; |
|
378 | + $q_n_as['questions'][ $ansobj->ID() ] = $qsts[ $ansobj->get('QST_ID') ]; |
|
379 | + } |
|
380 | + |
|
381 | + return $q_n_as; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * Return an array of event objects from the database |
|
387 | + * |
|
388 | + * If event ids are not included then we'll just retrieve the first published event from the database. |
|
389 | + * |
|
390 | + * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
391 | + * |
|
392 | + * @return array An array of event objects from the db. |
|
393 | + */ |
|
394 | + private function _get_some_events($event_ids = array()) |
|
395 | + { |
|
396 | + |
|
397 | + // 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); |
|
398 | + $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
399 | + ? array($_REQUEST['evt_id']) |
|
400 | + : $event_ids; |
|
401 | + |
|
402 | + $limit = ! empty($event_ids) |
|
403 | + ? null |
|
404 | + : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
405 | + |
|
406 | + $where = ! empty($event_ids) |
|
407 | + ? array( |
|
408 | + 'EVT_ID' => array('IN', $event_ids), |
|
409 | + 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
410 | + ) |
|
411 | + : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
412 | + |
|
413 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
414 | + |
|
415 | + return $events; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + protected function _setup_data() |
|
420 | + { |
|
421 | + |
|
422 | + // 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! |
|
423 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
424 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
425 | + $session = EE_Registry::instance()->SSN; |
|
426 | + } else { |
|
427 | + $session = EE_Registry::instance()->load_core('Session'); |
|
428 | + } |
|
429 | + $cart = EE_Cart::instance(null, $session); |
|
430 | + |
|
431 | + |
|
432 | + // add tickets to cart |
|
433 | + foreach ($this->tickets as $ticket) { |
|
434 | + $cart->add_ticket_to_cart($ticket['ticket']); |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + // setup txn property |
|
439 | + $this->txn = EE_Transaction::new_instance( |
|
440 | + array( |
|
441 | + 'TXN_timestamp' => time(), // unix timestamp |
|
442 | + 'TXN_total' => 0, // txn_total |
|
443 | + 'TXN_paid' => 0, // txn_paid |
|
444 | + 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
445 | + 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
446 | + 'TXN_hash_salt' => null, // hash salt blank as well |
|
447 | + 'TXN_ID' => 999999 |
|
448 | + ) |
|
449 | + ); |
|
450 | + |
|
451 | + |
|
452 | + // setup reg_objects |
|
453 | + // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
454 | + $this->reg_objs = array(); |
|
455 | + $regid = 9999990; |
|
456 | + foreach ($this->_attendees as $key => $attendee) { |
|
457 | + // note we need to setup reg_objects for each event this attendee belongs to |
|
458 | + $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
459 | + $regtxn = $this->txn->ID(); |
|
460 | + $regcnt = 1; |
|
461 | + foreach ($attendee['line_ref'] as $evtid) { |
|
462 | + foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
463 | + if (! $ticket instanceof EE_Ticket) { |
|
464 | + continue; |
|
465 | + } |
|
466 | + $reg_array = array( |
|
467 | + 'EVT_ID' => $evtid, |
|
468 | + 'ATT_ID' => $regatt, |
|
469 | + 'TXN_ID' => $regtxn, |
|
470 | + 'TKT_ID' => $ticket->ID(), |
|
471 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
472 | + 'REG_date' => time(), |
|
473 | + 'REG_final_price' => $ticket->get('TKT_price'), |
|
474 | + 'REG_session' => 'dummy_session_id', |
|
475 | + 'REG_code' => $regid . '-dummy-generated-code', |
|
476 | + 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
477 | + 'REG_count' => $regcnt, |
|
478 | + 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
479 | + 'REG_att_is_going' => true, |
|
480 | + 'REG_ID' => $regid |
|
481 | + ); |
|
482 | + $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
483 | + $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
484 | + $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
485 | + $this->reg_objs[] = $REG_OBJ; |
|
486 | + $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
487 | + |
|
488 | + $regcnt++; |
|
489 | + $regid++; |
|
490 | + } |
|
491 | + } |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + // setup line items! |
|
496 | + $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
497 | + |
|
498 | + // add tickets |
|
499 | + foreach ($this->tickets as $tktid => $item) { |
|
500 | + $qty = $item['count']; |
|
501 | + $ticket = $item['ticket']; |
|
502 | + EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
503 | + } |
|
504 | + |
|
505 | + $shipping_line_item = EE_Line_Item::new_instance(array( |
|
506 | + 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
507 | + 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
508 | + 'LIN_unit_price' => 20, |
|
509 | + 'LIN_quantity' => 1, |
|
510 | + 'LIN_is_taxable' => true, |
|
511 | + 'LIN_total' => 20, |
|
512 | + 'LIN_type' => EEM_Line_Item::type_line_item |
|
513 | + )); |
|
514 | + EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
515 | + $this->additional_line_items = array($shipping_line_item); |
|
516 | + |
|
517 | + // now let's add taxes |
|
518 | + EEH_Line_Item::apply_taxes($line_item_total); |
|
519 | + |
|
520 | + // now we should be able to get the items we need from this object |
|
521 | + $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
522 | + $line_items = array(); |
|
523 | + foreach ($event_line_items as $line_id => $line_item) { |
|
524 | + if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
525 | + continue; |
|
526 | + } |
|
527 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
528 | + foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
529 | + if (! $ticket_line_item instanceof EE_Line_Item) { |
|
530 | + continue; |
|
531 | + } |
|
532 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
533 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
534 | + $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
535 | + $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
536 | + } |
|
537 | + } |
|
538 | + |
|
539 | + $this->line_items_with_children = $line_items; |
|
540 | + $this->tax_line_items = $line_item_total->tax_descendants(); |
|
541 | + |
|
542 | + // add proper total to transaction object. |
|
543 | + $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
544 | + $this->grand_total_line_item = $line_item_total; |
|
545 | + $this->txn->set_total($grand_total); |
|
546 | + |
|
547 | + |
|
548 | + // add additional details for each registration |
|
549 | + foreach ($this->reg_objs as $reg) { |
|
550 | + if (! $reg instanceof EE_Registration) { |
|
551 | + continue; |
|
552 | + } |
|
553 | + $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
554 | + $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
555 | + $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
556 | + $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
557 | + $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
558 | + $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + // events and attendees |
|
563 | + $this->events = $this->_events; |
|
564 | + $this->attendees = $this->_attendees; |
|
565 | + $this->registrations = $this->_registrations; |
|
566 | + |
|
567 | + $attendees_to_shift = $this->_attendees; |
|
568 | + |
|
569 | + // setup primary attendee property |
|
570 | + $this->primary_attendee_data = array( |
|
571 | + 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
572 | + ? $this->_attendees[999999991]['att_obj']->fname() |
|
573 | + : '', |
|
574 | + |
|
575 | + 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
576 | + ? $this->_attendees[999999991]['att_obj']->lname() |
|
577 | + : '', |
|
578 | + |
|
579 | + 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
580 | + ? $this->_attendees[999999991]['att_obj']->email() |
|
581 | + : '', |
|
582 | + |
|
583 | + 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
584 | + |
|
585 | + 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
586 | + ); |
|
587 | + |
|
588 | + // reg_info property |
|
589 | + // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
590 | + $this->reg_info = array(); |
|
591 | + |
|
592 | + // let's set a reg_obj for messengers expecting one. |
|
593 | + $this->reg_obj = array_shift($this->_attendees[999999991]['reg_objs']); |
|
594 | + // the below are just dummy items. |
|
595 | + $this->user_id = 1; |
|
596 | + $this->ip_address = '192.0.2.1'; |
|
597 | + $this->user_agent = ''; |
|
598 | + $this->init_access = time(); |
|
599 | + $this->last_access = time(); |
|
600 | + } |
|
601 | 601 | } |
@@ -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]'); |
@@ -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'; |
|
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'; |
|
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]'); |