@@ -18,1453 +18,1453 @@ |
||
18 | 18 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @type bool $_print_copy_info |
|
23 | - */ |
|
24 | - private $_print_copy_info = false; |
|
25 | - |
|
26 | - /** |
|
27 | - * @type array $_attendee_data |
|
28 | - */ |
|
29 | - private $_attendee_data = array(); |
|
30 | - |
|
31 | - /** |
|
32 | - * @type array $_required_questions |
|
33 | - */ |
|
34 | - private $_required_questions = array(); |
|
35 | - |
|
36 | - /** |
|
37 | - * @type array $_registration_answers |
|
38 | - */ |
|
39 | - private $_registration_answers = array(); |
|
21 | + /** |
|
22 | + * @type bool $_print_copy_info |
|
23 | + */ |
|
24 | + private $_print_copy_info = false; |
|
25 | + |
|
26 | + /** |
|
27 | + * @type array $_attendee_data |
|
28 | + */ |
|
29 | + private $_attendee_data = array(); |
|
30 | + |
|
31 | + /** |
|
32 | + * @type array $_required_questions |
|
33 | + */ |
|
34 | + private $_required_questions = array(); |
|
35 | + |
|
36 | + /** |
|
37 | + * @type array $_registration_answers |
|
38 | + */ |
|
39 | + private $_registration_answers = array(); |
|
40 | 40 | |
41 | - /** |
|
42 | - * @type int $reg_form_count |
|
43 | - */ |
|
44 | - protected $reg_form_count = 0; |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * class constructor |
|
49 | - * |
|
50 | - * @access public |
|
51 | - * @param EE_Checkout $checkout |
|
52 | - */ |
|
53 | - public function __construct(EE_Checkout $checkout) |
|
54 | - { |
|
55 | - $this->_slug = 'attendee_information'; |
|
56 | - $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
57 | - $this->checkout = $checkout; |
|
58 | - $this->_reset_success_message(); |
|
59 | - $this->set_instructions( |
|
60 | - esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
61 | - ); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - public function translate_js_strings() |
|
66 | - { |
|
67 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
68 | - ' is a required question.', |
|
69 | - 'event_espresso' |
|
70 | - ); |
|
71 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
72 | - ' is a required question. Please enter a value for at least one of the options.', |
|
73 | - 'event_espresso' |
|
74 | - ); |
|
75 | - EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
76 | - 'Please answer all required questions correctly before proceeding.', |
|
77 | - 'event_espresso' |
|
78 | - ); |
|
79 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
80 | - esc_html_x( |
|
81 | - 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
82 | - 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
83 | - 'event_espresso' |
|
84 | - ), |
|
85 | - '<br/>' |
|
86 | - ); |
|
87 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
88 | - 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
89 | - 'event_espresso' |
|
90 | - ); |
|
91 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
92 | - 'You must enter a valid email address.', |
|
93 | - 'event_espresso' |
|
94 | - ); |
|
95 | - EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
96 | - 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
97 | - 'event_espresso' |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - public function enqueue_styles_and_scripts() |
|
103 | - { |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return boolean |
|
109 | - */ |
|
110 | - public function initialize_reg_step() |
|
111 | - { |
|
112 | - return true; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return EE_Form_Section_Proper |
|
118 | - * @throws DomainException |
|
119 | - * @throws EE_Error |
|
120 | - * @throws InvalidArgumentException |
|
121 | - * @throws ReflectionException |
|
122 | - * @throws EntityNotFoundException |
|
123 | - * @throws InvalidDataTypeException |
|
124 | - * @throws InvalidInterfaceException |
|
125 | - */ |
|
126 | - public function generate_reg_form() |
|
127 | - { |
|
128 | - /** |
|
129 | - * @var $reg_config EE_Registration_Config |
|
130 | - */ |
|
131 | - $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
41 | + /** |
|
42 | + * @type int $reg_form_count |
|
43 | + */ |
|
44 | + protected $reg_form_count = 0; |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * class constructor |
|
49 | + * |
|
50 | + * @access public |
|
51 | + * @param EE_Checkout $checkout |
|
52 | + */ |
|
53 | + public function __construct(EE_Checkout $checkout) |
|
54 | + { |
|
55 | + $this->_slug = 'attendee_information'; |
|
56 | + $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
57 | + $this->checkout = $checkout; |
|
58 | + $this->_reset_success_message(); |
|
59 | + $this->set_instructions( |
|
60 | + esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
61 | + ); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + public function translate_js_strings() |
|
66 | + { |
|
67 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
68 | + ' is a required question.', |
|
69 | + 'event_espresso' |
|
70 | + ); |
|
71 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
72 | + ' is a required question. Please enter a value for at least one of the options.', |
|
73 | + 'event_espresso' |
|
74 | + ); |
|
75 | + EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
76 | + 'Please answer all required questions correctly before proceeding.', |
|
77 | + 'event_espresso' |
|
78 | + ); |
|
79 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
80 | + esc_html_x( |
|
81 | + 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
82 | + 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
83 | + 'event_espresso' |
|
84 | + ), |
|
85 | + '<br/>' |
|
86 | + ); |
|
87 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
88 | + 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
89 | + 'event_espresso' |
|
90 | + ); |
|
91 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
92 | + 'You must enter a valid email address.', |
|
93 | + 'event_espresso' |
|
94 | + ); |
|
95 | + EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
96 | + 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
97 | + 'event_espresso' |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + public function enqueue_styles_and_scripts() |
|
103 | + { |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return boolean |
|
109 | + */ |
|
110 | + public function initialize_reg_step() |
|
111 | + { |
|
112 | + return true; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return EE_Form_Section_Proper |
|
118 | + * @throws DomainException |
|
119 | + * @throws EE_Error |
|
120 | + * @throws InvalidArgumentException |
|
121 | + * @throws ReflectionException |
|
122 | + * @throws EntityNotFoundException |
|
123 | + * @throws InvalidDataTypeException |
|
124 | + * @throws InvalidInterfaceException |
|
125 | + */ |
|
126 | + public function generate_reg_form() |
|
127 | + { |
|
128 | + /** |
|
129 | + * @var $reg_config EE_Registration_Config |
|
130 | + */ |
|
131 | + $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
132 | 132 | |
133 | - $this->_print_copy_info = $reg_config->copyAttendeeInfo(); |
|
134 | - |
|
135 | - // Init reg forms count. |
|
136 | - $this->reg_form_count = 0; |
|
137 | - |
|
138 | - $primary_registrant = null; |
|
139 | - // autoload Line_Item_Display classes |
|
140 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
141 | - $Line_Item_Display = new EE_Line_Item_Display(); |
|
142 | - // calculate taxes |
|
143 | - $Line_Item_Display->display_line_item( |
|
144 | - $this->checkout->cart->get_grand_total(), |
|
145 | - array('set_tax_rate' => true) |
|
146 | - ); |
|
147 | - /** @var $subsections EE_Form_Section_Proper[] */ |
|
148 | - $extra_inputs_section = $this->reg_step_hidden_inputs(); |
|
149 | - $subsections = array( |
|
150 | - 'default_hidden_inputs' => $extra_inputs_section, |
|
151 | - ); |
|
152 | - |
|
153 | - // if this isn't a revisit, and they have the privacy consent box enalbed, add it |
|
154 | - if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
155 | - $extra_inputs_section->add_subsections( |
|
156 | - array( |
|
157 | - 'consent_box' => new EE_Form_Section_Proper( |
|
158 | - array( |
|
159 | - 'layout_strategy' => |
|
160 | - new EE_Template_Layout( |
|
161 | - array( |
|
162 | - 'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php', |
|
163 | - ) |
|
164 | - ), |
|
165 | - 'subsections' => array( |
|
166 | - 'consent' => new EE_Checkbox_Multi_Input( |
|
167 | - array( |
|
168 | - 'consent' => $reg_config->getConsentCheckboxLabelText(), |
|
169 | - ), |
|
170 | - array( |
|
171 | - 'required' => true, |
|
172 | - 'required_validation_error_message' => esc_html__( |
|
173 | - 'You must consent to these terms in order to register.', |
|
174 | - 'event_espresso' |
|
175 | - ), |
|
176 | - 'html_label_text' => '', |
|
177 | - ) |
|
178 | - ), |
|
179 | - ), |
|
180 | - ) |
|
181 | - ), |
|
182 | - ), |
|
183 | - null, |
|
184 | - false |
|
185 | - ); |
|
186 | - } |
|
187 | - $template_args = array( |
|
188 | - 'revisit' => $this->checkout->revisit, |
|
189 | - 'registrations' => array(), |
|
190 | - 'ticket_count' => array(), |
|
191 | - ); |
|
192 | - // grab the saved registrations from the transaction |
|
193 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
194 | - if ($registrations) { |
|
195 | - foreach ($registrations as $registration) { |
|
196 | - // can this registration be processed during this visit ? |
|
197 | - if ($registration instanceof EE_Registration |
|
198 | - && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
199 | - ) { |
|
200 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
201 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
202 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
203 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
204 | - ) |
|
205 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
206 | - : 1; |
|
207 | - $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
208 | - $this->checkout->cart->get_grand_total(), |
|
209 | - 'Ticket', |
|
210 | - array($registration->ticket()->ID()) |
|
211 | - ); |
|
212 | - $ticket_line_item = is_array($ticket_line_item) |
|
213 | - ? reset($ticket_line_item) |
|
214 | - : $ticket_line_item; |
|
215 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
216 | - $Line_Item_Display->display_line_item($ticket_line_item); |
|
217 | - if ($registration->is_primary_registrant()) { |
|
218 | - $primary_registrant = $registration->reg_url_link(); |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - if ($primary_registrant && count($registrations) > 1) { |
|
224 | - $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
|
225 | - ? $this->_copy_attendee_info_form() |
|
226 | - : $this->_auto_copy_attendee_info(); |
|
227 | - // generate hidden input |
|
228 | - if (isset($subsections[ $primary_registrant ]) |
|
229 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
230 | - ) { |
|
231 | - $subsections[ $primary_registrant ]->add_subsections( |
|
232 | - $copy_options, |
|
233 | - 'primary_registrant', |
|
234 | - false |
|
235 | - ); |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - // Set the registration form template (default: one form per ticket details table). |
|
241 | - // We decide the template to used based on the number of forms. |
|
242 | - $this->_template = $this->reg_form_count > 1 |
|
243 | - ? SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php' |
|
244 | - : SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_single.template.php'; |
|
245 | - |
|
246 | - return new EE_Form_Section_Proper( |
|
247 | - array( |
|
248 | - 'name' => $this->reg_form_name(), |
|
249 | - 'html_id' => $this->reg_form_name(), |
|
250 | - 'subsections' => $subsections, |
|
251 | - 'layout_strategy' => new EE_Template_Layout( |
|
252 | - array( |
|
253 | - 'layout_template_file' => $this->_template, // layout_template |
|
254 | - 'template_args' => $template_args, |
|
255 | - ) |
|
256 | - ), |
|
257 | - ) |
|
258 | - ); |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * @param EE_Registration $registration |
|
264 | - * @return EE_Form_Section_Base |
|
265 | - * @throws EE_Error |
|
266 | - * @throws InvalidArgumentException |
|
267 | - * @throws EntityNotFoundException |
|
268 | - * @throws InvalidDataTypeException |
|
269 | - * @throws InvalidInterfaceException |
|
270 | - * @throws ReflectionException |
|
271 | - */ |
|
272 | - private function _registrations_reg_form(EE_Registration $registration) |
|
273 | - { |
|
274 | - static $attendee_nmbr = 1; |
|
275 | - $form_args = array(); |
|
276 | - // verify that registration has valid event |
|
277 | - if ($registration->event() instanceof EE_Event) { |
|
278 | - $field_name = 'Event_Question_Group.' |
|
279 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
280 | - $registration->is_primary_registrant() |
|
281 | - ); |
|
282 | - $question_groups = $registration->event()->question_groups( |
|
283 | - apply_filters( |
|
284 | - // @codingStandardsIgnoreStart |
|
285 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
286 | - // @codingStandardsIgnoreEnd |
|
287 | - [ |
|
288 | - [ |
|
289 | - 'Event.EVT_ID' => $registration->event()->ID(), |
|
290 | - $field_name => true, |
|
291 | - ], |
|
292 | - 'order_by' => ['QSG_order' => 'ASC'], |
|
293 | - ], |
|
294 | - $registration, |
|
295 | - $this |
|
296 | - ) |
|
297 | - ); |
|
298 | - if ($question_groups) { |
|
299 | - // array of params to pass to parent constructor |
|
300 | - $form_args = array( |
|
301 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
302 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
303 | - 'html_style' => $this->checkout->admin_request |
|
304 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
305 | - : '', |
|
306 | - 'subsections' => array(), |
|
307 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
308 | - array( |
|
309 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
310 | - 'legend_text' => sprintf( |
|
311 | - esc_html_x( |
|
312 | - 'Attendee %d', |
|
313 | - 'Attendee 123', |
|
314 | - 'event_espresso' |
|
315 | - ), |
|
316 | - $attendee_nmbr |
|
317 | - ), |
|
318 | - ) |
|
319 | - ), |
|
320 | - ); |
|
321 | - foreach ($question_groups as $question_group) { |
|
322 | - if ($question_group instanceof EE_Question_Group) { |
|
323 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
324 | - $registration, |
|
325 | - $question_group |
|
326 | - ); |
|
327 | - } |
|
328 | - } |
|
329 | - // add hidden input |
|
330 | - $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
331 | - $registration |
|
332 | - ); |
|
333 | - |
|
334 | - /** |
|
335 | - * @var $reg_config EE_Registration_Config |
|
336 | - */ |
|
337 | - $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
338 | - |
|
339 | - // If we have question groups for additional attendees, then display the copy options |
|
340 | - $this->_print_copy_info = apply_filters( |
|
341 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
342 | - $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false, |
|
343 | - $attendee_nmbr |
|
344 | - ); |
|
345 | - |
|
346 | - if ($registration->is_primary_registrant()) { |
|
347 | - // generate hidden input |
|
348 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( |
|
349 | - $registration |
|
350 | - ); |
|
351 | - } |
|
352 | - } |
|
353 | - } |
|
354 | - $attendee_nmbr++; |
|
133 | + $this->_print_copy_info = $reg_config->copyAttendeeInfo(); |
|
134 | + |
|
135 | + // Init reg forms count. |
|
136 | + $this->reg_form_count = 0; |
|
137 | + |
|
138 | + $primary_registrant = null; |
|
139 | + // autoload Line_Item_Display classes |
|
140 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
141 | + $Line_Item_Display = new EE_Line_Item_Display(); |
|
142 | + // calculate taxes |
|
143 | + $Line_Item_Display->display_line_item( |
|
144 | + $this->checkout->cart->get_grand_total(), |
|
145 | + array('set_tax_rate' => true) |
|
146 | + ); |
|
147 | + /** @var $subsections EE_Form_Section_Proper[] */ |
|
148 | + $extra_inputs_section = $this->reg_step_hidden_inputs(); |
|
149 | + $subsections = array( |
|
150 | + 'default_hidden_inputs' => $extra_inputs_section, |
|
151 | + ); |
|
152 | + |
|
153 | + // if this isn't a revisit, and they have the privacy consent box enalbed, add it |
|
154 | + if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
155 | + $extra_inputs_section->add_subsections( |
|
156 | + array( |
|
157 | + 'consent_box' => new EE_Form_Section_Proper( |
|
158 | + array( |
|
159 | + 'layout_strategy' => |
|
160 | + new EE_Template_Layout( |
|
161 | + array( |
|
162 | + 'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php', |
|
163 | + ) |
|
164 | + ), |
|
165 | + 'subsections' => array( |
|
166 | + 'consent' => new EE_Checkbox_Multi_Input( |
|
167 | + array( |
|
168 | + 'consent' => $reg_config->getConsentCheckboxLabelText(), |
|
169 | + ), |
|
170 | + array( |
|
171 | + 'required' => true, |
|
172 | + 'required_validation_error_message' => esc_html__( |
|
173 | + 'You must consent to these terms in order to register.', |
|
174 | + 'event_espresso' |
|
175 | + ), |
|
176 | + 'html_label_text' => '', |
|
177 | + ) |
|
178 | + ), |
|
179 | + ), |
|
180 | + ) |
|
181 | + ), |
|
182 | + ), |
|
183 | + null, |
|
184 | + false |
|
185 | + ); |
|
186 | + } |
|
187 | + $template_args = array( |
|
188 | + 'revisit' => $this->checkout->revisit, |
|
189 | + 'registrations' => array(), |
|
190 | + 'ticket_count' => array(), |
|
191 | + ); |
|
192 | + // grab the saved registrations from the transaction |
|
193 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
194 | + if ($registrations) { |
|
195 | + foreach ($registrations as $registration) { |
|
196 | + // can this registration be processed during this visit ? |
|
197 | + if ($registration instanceof EE_Registration |
|
198 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
199 | + ) { |
|
200 | + $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
201 | + $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
202 | + $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
203 | + $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
204 | + ) |
|
205 | + ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
206 | + : 1; |
|
207 | + $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
208 | + $this->checkout->cart->get_grand_total(), |
|
209 | + 'Ticket', |
|
210 | + array($registration->ticket()->ID()) |
|
211 | + ); |
|
212 | + $ticket_line_item = is_array($ticket_line_item) |
|
213 | + ? reset($ticket_line_item) |
|
214 | + : $ticket_line_item; |
|
215 | + $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
216 | + $Line_Item_Display->display_line_item($ticket_line_item); |
|
217 | + if ($registration->is_primary_registrant()) { |
|
218 | + $primary_registrant = $registration->reg_url_link(); |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + if ($primary_registrant && count($registrations) > 1) { |
|
224 | + $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
|
225 | + ? $this->_copy_attendee_info_form() |
|
226 | + : $this->_auto_copy_attendee_info(); |
|
227 | + // generate hidden input |
|
228 | + if (isset($subsections[ $primary_registrant ]) |
|
229 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
230 | + ) { |
|
231 | + $subsections[ $primary_registrant ]->add_subsections( |
|
232 | + $copy_options, |
|
233 | + 'primary_registrant', |
|
234 | + false |
|
235 | + ); |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + // Set the registration form template (default: one form per ticket details table). |
|
241 | + // We decide the template to used based on the number of forms. |
|
242 | + $this->_template = $this->reg_form_count > 1 |
|
243 | + ? SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php' |
|
244 | + : SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_single.template.php'; |
|
245 | + |
|
246 | + return new EE_Form_Section_Proper( |
|
247 | + array( |
|
248 | + 'name' => $this->reg_form_name(), |
|
249 | + 'html_id' => $this->reg_form_name(), |
|
250 | + 'subsections' => $subsections, |
|
251 | + 'layout_strategy' => new EE_Template_Layout( |
|
252 | + array( |
|
253 | + 'layout_template_file' => $this->_template, // layout_template |
|
254 | + 'template_args' => $template_args, |
|
255 | + ) |
|
256 | + ), |
|
257 | + ) |
|
258 | + ); |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * @param EE_Registration $registration |
|
264 | + * @return EE_Form_Section_Base |
|
265 | + * @throws EE_Error |
|
266 | + * @throws InvalidArgumentException |
|
267 | + * @throws EntityNotFoundException |
|
268 | + * @throws InvalidDataTypeException |
|
269 | + * @throws InvalidInterfaceException |
|
270 | + * @throws ReflectionException |
|
271 | + */ |
|
272 | + private function _registrations_reg_form(EE_Registration $registration) |
|
273 | + { |
|
274 | + static $attendee_nmbr = 1; |
|
275 | + $form_args = array(); |
|
276 | + // verify that registration has valid event |
|
277 | + if ($registration->event() instanceof EE_Event) { |
|
278 | + $field_name = 'Event_Question_Group.' |
|
279 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
280 | + $registration->is_primary_registrant() |
|
281 | + ); |
|
282 | + $question_groups = $registration->event()->question_groups( |
|
283 | + apply_filters( |
|
284 | + // @codingStandardsIgnoreStart |
|
285 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
286 | + // @codingStandardsIgnoreEnd |
|
287 | + [ |
|
288 | + [ |
|
289 | + 'Event.EVT_ID' => $registration->event()->ID(), |
|
290 | + $field_name => true, |
|
291 | + ], |
|
292 | + 'order_by' => ['QSG_order' => 'ASC'], |
|
293 | + ], |
|
294 | + $registration, |
|
295 | + $this |
|
296 | + ) |
|
297 | + ); |
|
298 | + if ($question_groups) { |
|
299 | + // array of params to pass to parent constructor |
|
300 | + $form_args = array( |
|
301 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
302 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
303 | + 'html_style' => $this->checkout->admin_request |
|
304 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
305 | + : '', |
|
306 | + 'subsections' => array(), |
|
307 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
308 | + array( |
|
309 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
310 | + 'legend_text' => sprintf( |
|
311 | + esc_html_x( |
|
312 | + 'Attendee %d', |
|
313 | + 'Attendee 123', |
|
314 | + 'event_espresso' |
|
315 | + ), |
|
316 | + $attendee_nmbr |
|
317 | + ), |
|
318 | + ) |
|
319 | + ), |
|
320 | + ); |
|
321 | + foreach ($question_groups as $question_group) { |
|
322 | + if ($question_group instanceof EE_Question_Group) { |
|
323 | + $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
324 | + $registration, |
|
325 | + $question_group |
|
326 | + ); |
|
327 | + } |
|
328 | + } |
|
329 | + // add hidden input |
|
330 | + $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
331 | + $registration |
|
332 | + ); |
|
333 | + |
|
334 | + /** |
|
335 | + * @var $reg_config EE_Registration_Config |
|
336 | + */ |
|
337 | + $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
338 | + |
|
339 | + // If we have question groups for additional attendees, then display the copy options |
|
340 | + $this->_print_copy_info = apply_filters( |
|
341 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
342 | + $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false, |
|
343 | + $attendee_nmbr |
|
344 | + ); |
|
345 | + |
|
346 | + if ($registration->is_primary_registrant()) { |
|
347 | + // generate hidden input |
|
348 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( |
|
349 | + $registration |
|
350 | + ); |
|
351 | + } |
|
352 | + } |
|
353 | + } |
|
354 | + $attendee_nmbr++; |
|
355 | 355 | |
356 | - // Increment the reg forms number if form is valid. |
|
357 | - if (!empty($form_args)) { |
|
358 | - $this->reg_form_count++; |
|
359 | - } |
|
360 | - |
|
361 | - return ! empty($form_args) |
|
362 | - ? new EE_Form_Section_Proper($form_args) |
|
363 | - : new EE_Form_Section_HTML(); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * @param EE_Registration $registration |
|
369 | - * @param bool $additional_attendee_reg_info |
|
370 | - * @return EE_Form_Input_Base |
|
371 | - * @throws EE_Error |
|
372 | - */ |
|
373 | - private function _additional_attendee_reg_info_input( |
|
374 | - EE_Registration $registration, |
|
375 | - $additional_attendee_reg_info = true |
|
376 | - ) { |
|
377 | - // generate hidden input |
|
378 | - return new EE_Hidden_Input( |
|
379 | - array( |
|
380 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
381 | - 'default' => $additional_attendee_reg_info, |
|
382 | - ) |
|
383 | - ); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * @param EE_Registration $registration |
|
389 | - * @param EE_Question_Group $question_group |
|
390 | - * @return EE_Form_Section_Proper |
|
391 | - * @throws EE_Error |
|
392 | - * @throws InvalidArgumentException |
|
393 | - * @throws InvalidDataTypeException |
|
394 | - * @throws InvalidInterfaceException |
|
395 | - * @throws ReflectionException |
|
396 | - */ |
|
397 | - private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) |
|
398 | - { |
|
399 | - // array of params to pass to parent constructor |
|
400 | - $form_args = array( |
|
401 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
402 | - 'html_class' => $this->checkout->admin_request |
|
403 | - ? 'form-table ee-reg-form-qstn-grp-dv' |
|
404 | - : 'ee-reg-form-qstn-grp-dv', |
|
405 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
406 | - . $registration->ID() . '-lbl', |
|
407 | - 'subsections' => array( |
|
408 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
|
409 | - ), |
|
410 | - 'layout_strategy' => $this->checkout->admin_request |
|
411 | - ? new EE_Admin_Two_Column_Layout() |
|
412 | - : new EE_Div_Per_Section_Layout(), |
|
413 | - ); |
|
414 | - // where params |
|
415 | - $query_params = array('QST_deleted' => 0); |
|
416 | - // don't load admin only questions on the frontend |
|
417 | - if (! $this->checkout->admin_request) { |
|
418 | - $query_params['QST_admin_only'] = array('!=', true); |
|
419 | - } |
|
420 | - $questions = $question_group->get_many_related( |
|
421 | - 'Question', |
|
422 | - apply_filters( |
|
423 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
424 | - array( |
|
425 | - $query_params, |
|
426 | - 'order_by' => array( |
|
427 | - 'Question_Group_Question.QGQ_order' => 'ASC', |
|
428 | - ), |
|
429 | - ), |
|
430 | - $question_group, |
|
431 | - $registration, |
|
432 | - $this |
|
433 | - ) |
|
434 | - ); |
|
435 | - // filter for additional content before questions |
|
436 | - $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
437 | - apply_filters( |
|
438 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
439 | - '', |
|
440 | - $registration, |
|
441 | - $question_group, |
|
442 | - $this |
|
443 | - ) |
|
444 | - ); |
|
445 | - // loop thru questions |
|
446 | - foreach ($questions as $question) { |
|
447 | - if ($question instanceof EE_Question) { |
|
448 | - $identifier = $question->is_system_question() |
|
449 | - ? $question->system_ID() |
|
450 | - : $question->ID(); |
|
451 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
452 | - } |
|
453 | - } |
|
454 | - $form_args['subsections'] = apply_filters( |
|
455 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
456 | - $form_args['subsections'], |
|
457 | - $registration, |
|
458 | - $question_group, |
|
459 | - $this |
|
460 | - ); |
|
461 | - // filter for additional content after questions |
|
462 | - $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
463 | - apply_filters( |
|
464 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
465 | - '', |
|
466 | - $registration, |
|
467 | - $question_group, |
|
468 | - $this |
|
469 | - ) |
|
470 | - ); |
|
471 | - // d($form_args); |
|
472 | - $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
473 | - return apply_filters( |
|
474 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
475 | - $question_group_reg_form, |
|
476 | - $registration, |
|
477 | - $question_group, |
|
478 | - $this |
|
479 | - ); |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - /** |
|
484 | - * @param EE_Question_Group $question_group |
|
485 | - * @return EE_Form_Section_HTML |
|
486 | - */ |
|
487 | - private function _question_group_header(EE_Question_Group $question_group) |
|
488 | - { |
|
489 | - $html = ''; |
|
490 | - // group_name |
|
491 | - if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
492 | - if ($this->checkout->admin_request) { |
|
493 | - $html .= EEH_HTML::br(); |
|
494 | - $html .= EEH_HTML::h3( |
|
495 | - $question_group->name(), |
|
496 | - '', |
|
497 | - 'ee-reg-form-qstn-grp-title title', |
|
498 | - 'font-size: 1.3em; padding-left:0;' |
|
499 | - ); |
|
500 | - } else { |
|
501 | - $html .= EEH_HTML::h4( |
|
502 | - $question_group->name(), |
|
503 | - '', |
|
504 | - 'ee-reg-form-qstn-grp-title section-title' |
|
505 | - ); |
|
506 | - } |
|
507 | - } |
|
508 | - // group_desc |
|
509 | - if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
510 | - $html .= EEH_HTML::p( |
|
511 | - $question_group->desc(), |
|
512 | - '', |
|
513 | - $this->checkout->admin_request |
|
514 | - ? 'ee-reg-form-qstn-grp-desc-pg' |
|
515 | - : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
516 | - ); |
|
517 | - } |
|
518 | - return new EE_Form_Section_HTML($html); |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - /** |
|
523 | - * @return EE_Form_Section_Proper |
|
524 | - * @throws EE_Error |
|
525 | - * @throws InvalidArgumentException |
|
526 | - * @throws ReflectionException |
|
527 | - * @throws InvalidDataTypeException |
|
528 | - * @throws InvalidInterfaceException |
|
529 | - */ |
|
530 | - private function _copy_attendee_info_form() |
|
531 | - { |
|
532 | - // array of params to pass to parent constructor |
|
533 | - return new EE_Form_Section_Proper( |
|
534 | - array( |
|
535 | - 'subsections' => $this->_copy_attendee_info_inputs(), |
|
536 | - 'layout_strategy' => new EE_Template_Layout( |
|
537 | - array( |
|
538 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
539 | - . $this->_slug |
|
540 | - . '/copy_attendee_info.template.php', |
|
541 | - 'begin_template_file' => null, |
|
542 | - 'input_template_file' => null, |
|
543 | - 'subsection_template_file' => null, |
|
544 | - 'end_template_file' => null, |
|
545 | - ) |
|
546 | - ), |
|
547 | - ) |
|
548 | - ); |
|
549 | - } |
|
550 | - |
|
551 | - |
|
552 | - /** |
|
553 | - * @return EE_Form_Section_HTML |
|
554 | - * @throws DomainException |
|
555 | - * @throws InvalidArgumentException |
|
556 | - * @throws InvalidDataTypeException |
|
557 | - * @throws InvalidInterfaceException |
|
558 | - */ |
|
559 | - private function _auto_copy_attendee_info() |
|
560 | - { |
|
561 | - return new EE_Form_Section_HTML( |
|
562 | - EEH_Template::locate_template( |
|
563 | - SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php', |
|
564 | - apply_filters( |
|
565 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
566 | - array() |
|
567 | - ), |
|
568 | - true, |
|
569 | - true |
|
570 | - ) |
|
571 | - ); |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - /** |
|
576 | - * @return array |
|
577 | - * @throws EE_Error |
|
578 | - * @throws InvalidArgumentException |
|
579 | - * @throws ReflectionException |
|
580 | - * @throws InvalidDataTypeException |
|
581 | - * @throws InvalidInterfaceException |
|
582 | - */ |
|
583 | - private function _copy_attendee_info_inputs() |
|
584 | - { |
|
585 | - $copy_attendee_info_inputs = array(); |
|
586 | - $prev_ticket = null; |
|
587 | - // grab the saved registrations from the transaction |
|
588 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
589 | - foreach ($registrations as $registration) { |
|
590 | - // for all attendees other than the primary attendee |
|
591 | - if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
592 | - // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
593 | - if ($registration->ticket()->ID() !== $prev_ticket) { |
|
594 | - $item_name = $registration->ticket()->name(); |
|
595 | - $item_name .= $registration->ticket()->description() !== '' |
|
596 | - ? ' - ' . $registration->ticket()->description() |
|
597 | - : ''; |
|
598 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID( |
|
599 | - ) . ']' ] = |
|
600 | - new EE_Form_Section_HTML( |
|
601 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
602 | - ); |
|
603 | - $prev_ticket = $registration->ticket()->ID(); |
|
604 | - } |
|
605 | - |
|
606 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
607 | - new EE_Checkbox_Multi_Input( |
|
608 | - array( |
|
609 | - $registration->ID() => sprintf( |
|
610 | - esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
611 | - $registration->count() |
|
612 | - ), |
|
613 | - ), |
|
614 | - array( |
|
615 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
616 | - 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
617 | - 'display_html_label_text' => false, |
|
618 | - ) |
|
619 | - ); |
|
620 | - } |
|
621 | - } |
|
622 | - return $copy_attendee_info_inputs; |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - /** |
|
627 | - * @param EE_Registration $registration |
|
628 | - * @return EE_Form_Input_Base |
|
629 | - * @throws EE_Error |
|
630 | - */ |
|
631 | - private function _additional_primary_registrant_inputs(EE_Registration $registration) |
|
632 | - { |
|
633 | - // generate hidden input |
|
634 | - return new EE_Hidden_Input( |
|
635 | - array( |
|
636 | - 'html_id' => 'primary_registrant', |
|
637 | - 'default' => $registration->reg_url_link(), |
|
638 | - ) |
|
639 | - ); |
|
640 | - } |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * @param EE_Registration $registration |
|
645 | - * @param EE_Question $question |
|
646 | - * @return EE_Form_Input_Base |
|
647 | - * @throws EE_Error |
|
648 | - * @throws InvalidArgumentException |
|
649 | - * @throws InvalidDataTypeException |
|
650 | - * @throws InvalidInterfaceException |
|
651 | - * @throws ReflectionException |
|
652 | - */ |
|
653 | - public function reg_form_question(EE_Registration $registration, EE_Question $question) |
|
654 | - { |
|
655 | - |
|
656 | - // if this question was for an attendee detail, then check for that answer |
|
657 | - $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
658 | - $registration, |
|
659 | - $question->system_ID() |
|
660 | - ); |
|
661 | - $answer = $answer_value === null |
|
662 | - ? EEM_Answer::instance()->get_one( |
|
663 | - array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
664 | - ) |
|
665 | - : null; |
|
666 | - // if NOT returning to edit an existing registration |
|
667 | - // OR if this question is for an attendee property |
|
668 | - // OR we still don't have an EE_Answer object |
|
669 | - if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
670 | - // create an EE_Answer object for storing everything in |
|
671 | - $answer = EE_Answer::new_instance( |
|
672 | - array( |
|
673 | - 'QST_ID' => $question->ID(), |
|
674 | - 'REG_ID' => $registration->ID(), |
|
675 | - ) |
|
676 | - ); |
|
677 | - } |
|
678 | - // verify instance |
|
679 | - if ($answer instanceof EE_Answer) { |
|
680 | - if (! empty($answer_value)) { |
|
681 | - $answer->set('ANS_value', $answer_value); |
|
682 | - } |
|
683 | - $answer->cache('Question', $question); |
|
684 | - // remember system ID had a bug where sometimes it could be null |
|
685 | - $answer_cache_id = $question->is_system_question() |
|
686 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
687 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
688 | - $registration->cache('Answer', $answer, $answer_cache_id); |
|
689 | - } |
|
690 | - return $this->_generate_question_input($registration, $question, $answer); |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * @param EE_Registration $registration |
|
696 | - * @param EE_Question $question |
|
697 | - * @param $answer |
|
698 | - * @return EE_Form_Input_Base |
|
699 | - * @throws EE_Error |
|
700 | - * @throws InvalidArgumentException |
|
701 | - * @throws ReflectionException |
|
702 | - * @throws InvalidDataTypeException |
|
703 | - * @throws InvalidInterfaceException |
|
704 | - */ |
|
705 | - private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) |
|
706 | - { |
|
707 | - $identifier = $question->is_system_question() |
|
708 | - ? $question->system_ID() |
|
709 | - : $question->ID(); |
|
710 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
711 | - add_filter( |
|
712 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
713 | - array($this, 'use_cached_countries_for_form_input'), |
|
714 | - 10, |
|
715 | - 4 |
|
716 | - ); |
|
717 | - add_filter( |
|
718 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
719 | - array($this, 'use_cached_states_for_form_input'), |
|
720 | - 10, |
|
721 | - 4 |
|
722 | - ); |
|
723 | - $input_constructor_args = array( |
|
724 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
725 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
726 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
727 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
728 | - 'html_label_class' => 'ee-reg-qstn', |
|
729 | - ); |
|
730 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
731 | - if ($answer instanceof EE_Answer && $answer->ID()) { |
|
732 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
733 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
734 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
735 | - } |
|
736 | - $form_input = $question->generate_form_input( |
|
737 | - $registration, |
|
738 | - $answer, |
|
739 | - $input_constructor_args |
|
740 | - ); |
|
741 | - remove_filter( |
|
742 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
743 | - array($this, 'use_cached_countries_for_form_input') |
|
744 | - ); |
|
745 | - remove_filter( |
|
746 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
747 | - array($this, 'use_cached_states_for_form_input') |
|
748 | - ); |
|
749 | - return $form_input; |
|
750 | - } |
|
751 | - |
|
752 | - |
|
753 | - /** |
|
754 | - * Gets the list of countries for the form input |
|
755 | - * |
|
756 | - * @param array|null $countries_list |
|
757 | - * @param EE_Question $question |
|
758 | - * @param EE_Registration $registration |
|
759 | - * @param EE_Answer $answer |
|
760 | - * @return array 2d keys are country IDs, values are their names |
|
761 | - * @throws EE_Error |
|
762 | - * @throws InvalidArgumentException |
|
763 | - * @throws InvalidDataTypeException |
|
764 | - * @throws InvalidInterfaceException |
|
765 | - * @throws ReflectionException |
|
766 | - */ |
|
767 | - public function use_cached_countries_for_form_input( |
|
768 | - $countries_list, |
|
769 | - EE_Question $question = null, |
|
770 | - EE_Registration $registration = null, |
|
771 | - EE_Answer $answer = null |
|
772 | - ) { |
|
773 | - $country_options = array('' => ''); |
|
774 | - // get possibly cached list of countries |
|
775 | - $countries = $this->checkout->action === 'process_reg_step' |
|
776 | - ? EEM_Country::instance()->get_all_countries() |
|
777 | - : EEM_Country::instance()->get_all_active_countries(); |
|
778 | - if (! empty($countries)) { |
|
779 | - foreach ($countries as $country) { |
|
780 | - if ($country instanceof EE_Country) { |
|
781 | - $country_options[ $country->ID() ] = $country->name(); |
|
782 | - } |
|
783 | - } |
|
784 | - } |
|
785 | - if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
786 | - $answer = EEM_Answer::instance()->get_one( |
|
787 | - array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
788 | - ); |
|
789 | - } else { |
|
790 | - $answer = EE_Answer::new_instance(); |
|
791 | - } |
|
792 | - $country_options = apply_filters( |
|
793 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
794 | - $country_options, |
|
795 | - $this, |
|
796 | - $registration, |
|
797 | - $question, |
|
798 | - $answer |
|
799 | - ); |
|
800 | - return $country_options; |
|
801 | - } |
|
802 | - |
|
803 | - |
|
804 | - /** |
|
805 | - * Gets the list of states for the form input |
|
806 | - * |
|
807 | - * @param array|null $states_list |
|
808 | - * @param EE_Question $question |
|
809 | - * @param EE_Registration $registration |
|
810 | - * @param EE_Answer $answer |
|
811 | - * @return array 2d keys are state IDs, values are their names |
|
812 | - * @throws EE_Error |
|
813 | - * @throws InvalidArgumentException |
|
814 | - * @throws InvalidDataTypeException |
|
815 | - * @throws InvalidInterfaceException |
|
816 | - * @throws ReflectionException |
|
817 | - */ |
|
818 | - public function use_cached_states_for_form_input( |
|
819 | - $states_list, |
|
820 | - EE_Question $question = null, |
|
821 | - EE_Registration $registration = null, |
|
822 | - EE_Answer $answer = null |
|
823 | - ) { |
|
824 | - $state_options = array('' => array('' => '')); |
|
825 | - $states = $this->checkout->action === 'process_reg_step' |
|
826 | - ? EEM_State::instance()->get_all_states() |
|
827 | - : EEM_State::instance()->get_all_active_states(); |
|
828 | - if (! empty($states)) { |
|
829 | - foreach ($states as $state) { |
|
830 | - if ($state instanceof EE_State) { |
|
831 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
832 | - } |
|
833 | - } |
|
834 | - } |
|
835 | - $state_options = apply_filters( |
|
836 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
837 | - $state_options, |
|
838 | - $this, |
|
839 | - $registration, |
|
840 | - $question, |
|
841 | - $answer |
|
842 | - ); |
|
843 | - return $state_options; |
|
844 | - } |
|
845 | - |
|
846 | - |
|
847 | - /********************************************************************************************************/ |
|
848 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
849 | - /********************************************************************************************************/ |
|
850 | - |
|
851 | - |
|
852 | - /** |
|
853 | - * @return bool |
|
854 | - * @throws EE_Error |
|
855 | - * @throws InvalidArgumentException |
|
856 | - * @throws ReflectionException |
|
857 | - * @throws RuntimeException |
|
858 | - * @throws InvalidDataTypeException |
|
859 | - * @throws InvalidInterfaceException |
|
860 | - */ |
|
861 | - public function process_reg_step() |
|
862 | - { |
|
863 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
864 | - // grab validated data from form |
|
865 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
866 | - // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
867 | - // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
868 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
869 | - if (empty($valid_data)) { |
|
870 | - EE_Error::add_error( |
|
871 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
872 | - __FILE__, |
|
873 | - __FUNCTION__, |
|
874 | - __LINE__ |
|
875 | - ); |
|
876 | - return false; |
|
877 | - } |
|
878 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
879 | - EE_Error::add_error( |
|
880 | - esc_html__( |
|
881 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
882 | - 'event_espresso' |
|
883 | - ), |
|
884 | - __FILE__, |
|
885 | - __FUNCTION__, |
|
886 | - __LINE__ |
|
887 | - ); |
|
888 | - return false; |
|
889 | - } |
|
890 | - // get cached registrations |
|
891 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
892 | - // verify we got the goods |
|
893 | - if (empty($registrations)) { |
|
894 | - // combine the old translated string with a new one, in order to not break translations |
|
895 | - $error_message = esc_html__( |
|
896 | - 'Your form data could not be applied to any valid registrations.', |
|
897 | - 'event_espresso' |
|
898 | - ) |
|
899 | - . sprintf( |
|
900 | - esc_html_x( |
|
901 | - '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
902 | - '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
903 | - 'event_espresso' |
|
904 | - ), |
|
905 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
906 | - '</a>', |
|
907 | - '<br />' |
|
908 | - ); |
|
909 | - EE_Error::add_error( |
|
910 | - $error_message, |
|
911 | - __FILE__, |
|
912 | - __FUNCTION__, |
|
913 | - __LINE__ |
|
914 | - ); |
|
915 | - return false; |
|
916 | - } |
|
917 | - // extract attendee info from form data and save to model objects |
|
918 | - $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
919 | - // if first pass thru SPCO, |
|
920 | - // then let's check processed registrations against the total number of tickets in the cart |
|
921 | - if ($registrations_processed === false) { |
|
922 | - // but return immediately if the previous step exited early due to errors |
|
923 | - return false; |
|
924 | - } |
|
925 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
926 | - // generate a correctly translated string for all possible singular/plural combinations |
|
927 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
928 | - $error_msg = sprintf( |
|
929 | - esc_html_x( |
|
930 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
931 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
932 | - 'event_espresso' |
|
933 | - ), |
|
934 | - $this->checkout->total_ticket_count, |
|
935 | - $registrations_processed |
|
936 | - ); |
|
937 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
938 | - $error_msg = sprintf( |
|
939 | - esc_html_x( |
|
940 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
941 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
942 | - 'event_espresso' |
|
943 | - ), |
|
944 | - $this->checkout->total_ticket_count, |
|
945 | - $registrations_processed |
|
946 | - ); |
|
947 | - } else { |
|
948 | - $error_msg = sprintf( |
|
949 | - esc_html__( |
|
950 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
951 | - 'event_espresso' |
|
952 | - ), |
|
953 | - $this->checkout->total_ticket_count, |
|
954 | - $registrations_processed |
|
955 | - ); |
|
956 | - } |
|
957 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
958 | - return false; |
|
959 | - } |
|
960 | - // mark this reg step as completed |
|
961 | - $this->set_completed(); |
|
962 | - $this->_set_success_message( |
|
963 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
964 | - ); |
|
965 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
966 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
967 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
968 | - return true; |
|
969 | - } |
|
970 | - |
|
971 | - |
|
972 | - /** |
|
973 | - * _process_registrations |
|
974 | - * |
|
975 | - * @param EE_Registration[] $registrations |
|
976 | - * @param array[][] $valid_data |
|
977 | - * @return bool|int |
|
978 | - * @throws EntityNotFoundException |
|
979 | - * @throws EE_Error |
|
980 | - * @throws InvalidArgumentException |
|
981 | - * @throws ReflectionException |
|
982 | - * @throws RuntimeException |
|
983 | - * @throws InvalidDataTypeException |
|
984 | - * @throws InvalidInterfaceException |
|
985 | - */ |
|
986 | - private function _process_registrations($registrations = array(), $valid_data = array()) |
|
987 | - { |
|
988 | - // load resources and set some defaults |
|
989 | - EE_Registry::instance()->load_model('Attendee'); |
|
990 | - // holder for primary registrant attendee object |
|
991 | - $this->checkout->primary_attendee_obj = null; |
|
992 | - // array for tracking reg form data for the primary registrant |
|
993 | - $primary_registrant = array( |
|
994 | - 'line_item_id' => null, |
|
995 | - ); |
|
996 | - $copy_primary = false; |
|
997 | - // reg form sections that do not contain inputs |
|
998 | - $non_input_form_sections = array( |
|
999 | - 'primary_registrant', |
|
1000 | - 'additional_attendee_reg_info', |
|
1001 | - 'spco_copy_attendee_chk', |
|
1002 | - ); |
|
1003 | - // attendee counter |
|
1004 | - $att_nmbr = 0; |
|
1005 | - // grab the saved registrations from the transaction |
|
1006 | - foreach ($registrations as $registration) { |
|
1007 | - // verify EE_Registration object |
|
1008 | - if (! $registration instanceof EE_Registration) { |
|
1009 | - EE_Error::add_error( |
|
1010 | - esc_html__( |
|
1011 | - 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
1012 | - 'event_espresso' |
|
1013 | - ), |
|
1014 | - __FILE__, |
|
1015 | - __FUNCTION__, |
|
1016 | - __LINE__ |
|
1017 | - ); |
|
1018 | - return false; |
|
1019 | - } |
|
1020 | - /** @var string $reg_url_link */ |
|
1021 | - $reg_url_link = $registration->reg_url_link(); |
|
1022 | - // reg_url_link exists ? |
|
1023 | - if (! empty($reg_url_link)) { |
|
1024 | - // should this registration be processed during this visit ? |
|
1025 | - if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
1026 | - // if NOT revisiting, then let's save the registration now, |
|
1027 | - // so that we have a REG_ID to use when generating other objects |
|
1028 | - if (! $this->checkout->revisit) { |
|
1029 | - $registration->save(); |
|
1030 | - } |
|
1031 | - /** |
|
1032 | - * This allows plugins to trigger a fail on processing of a |
|
1033 | - * registration for any conditions they may have for it to pass. |
|
1034 | - * |
|
1035 | - * @var bool if true is returned by the plugin then the |
|
1036 | - * registration processing is halted. |
|
1037 | - */ |
|
1038 | - if (apply_filters( |
|
1039 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
1040 | - false, |
|
1041 | - $att_nmbr, |
|
1042 | - $registration, |
|
1043 | - $registrations, |
|
1044 | - $valid_data, |
|
1045 | - $this |
|
1046 | - )) { |
|
1047 | - return false; |
|
1048 | - } |
|
1049 | - |
|
1050 | - // Houston, we have a registration! |
|
1051 | - $att_nmbr++; |
|
1052 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
1053 | - // grab any existing related answer objects |
|
1054 | - $this->_registration_answers = $registration->answers(); |
|
1055 | - // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
1056 | - if (isset($valid_data[ $reg_url_link ])) { |
|
1057 | - // do we need to copy basic info from primary attendee ? |
|
1058 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
1059 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
1060 | - // filter form input data for this registration |
|
1061 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
1062 | - 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
1063 | - $valid_data[ $reg_url_link ] |
|
1064 | - ); |
|
1065 | - if (isset($valid_data['primary_attendee'])) { |
|
1066 | - $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
1067 | - ? $valid_data['primary_attendee'] |
|
1068 | - : false; |
|
1069 | - unset($valid_data['primary_attendee']); |
|
1070 | - } |
|
1071 | - // now loop through our array of valid post data && process attendee reg forms |
|
1072 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
1073 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
1074 | - foreach ($form_inputs as $form_input => $input_value) { |
|
1075 | - // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
1076 | - // check for critical inputs |
|
1077 | - if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1078 | - $form_input, |
|
1079 | - $input_value |
|
1080 | - ) |
|
1081 | - ) { |
|
1082 | - return false; |
|
1083 | - } |
|
1084 | - // store a bit of data about the primary attendee |
|
1085 | - if ($att_nmbr === 1 |
|
1086 | - && ! empty($input_value) |
|
1087 | - && $reg_url_link === $primary_registrant['line_item_id'] |
|
1088 | - ) { |
|
1089 | - $primary_registrant[ $form_input ] = $input_value; |
|
1090 | - } elseif ($copy_primary |
|
1091 | - && $input_value === null |
|
1092 | - && isset($primary_registrant[ $form_input ]) |
|
1093 | - ) { |
|
1094 | - $input_value = $primary_registrant[ $form_input ]; |
|
1095 | - } |
|
1096 | - // now attempt to save the input data |
|
1097 | - if (! $this->_save_registration_form_input( |
|
1098 | - $registration, |
|
1099 | - $form_input, |
|
1100 | - $input_value |
|
1101 | - ) |
|
1102 | - ) { |
|
1103 | - EE_Error::add_error( |
|
1104 | - sprintf( |
|
1105 | - esc_html_x( |
|
1106 | - 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
1107 | - 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
1108 | - 'event_espresso' |
|
1109 | - ), |
|
1110 | - $form_input, |
|
1111 | - $input_value |
|
1112 | - ), |
|
1113 | - __FILE__, |
|
1114 | - __FUNCTION__, |
|
1115 | - __LINE__ |
|
1116 | - ); |
|
1117 | - return false; |
|
1118 | - } |
|
1119 | - } |
|
1120 | - } |
|
1121 | - } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
1122 | - } |
|
1123 | - // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
1124 | - // this registration does not require additional attendee information ? |
|
1125 | - if ($copy_primary |
|
1126 | - && $att_nmbr > 1 |
|
1127 | - && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
1128 | - ) { |
|
1129 | - // just copy the primary registrant |
|
1130 | - $attendee = $this->checkout->primary_attendee_obj; |
|
1131 | - } else { |
|
1132 | - // ensure critical details are set for additional attendees |
|
1133 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
1134 | - ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
1135 | - $this->_attendee_data[ $reg_url_link ] |
|
1136 | - ) |
|
1137 | - : $this->_attendee_data[ $reg_url_link ]; |
|
1138 | - // execute create attendee command (which may return an existing attendee) |
|
1139 | - $attendee = EE_Registry::instance()->BUS->execute( |
|
1140 | - new CreateAttendeeCommand( |
|
1141 | - $this->_attendee_data[ $reg_url_link ], |
|
1142 | - $registration |
|
1143 | - ) |
|
1144 | - ); |
|
1145 | - // who's #1 ? |
|
1146 | - if ($att_nmbr === 1) { |
|
1147 | - $this->checkout->primary_attendee_obj = $attendee; |
|
1148 | - } |
|
1149 | - } |
|
1150 | - // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
1151 | - // add relation to registration, set attendee ID, and cache attendee |
|
1152 | - $this->_associate_attendee_with_registration($registration, $attendee); |
|
1153 | - // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
1154 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
1155 | - EE_Error::add_error( |
|
1156 | - sprintf( |
|
1157 | - esc_html_x( |
|
1158 | - 'Registration %s has an invalid or missing Attendee object.', |
|
1159 | - 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
1160 | - 'event_espresso' |
|
1161 | - ), |
|
1162 | - $reg_url_link |
|
1163 | - ), |
|
1164 | - __FILE__, |
|
1165 | - __FUNCTION__, |
|
1166 | - __LINE__ |
|
1167 | - ); |
|
1168 | - return false; |
|
1169 | - } |
|
1170 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1171 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1172 | - // at this point, we should have enough details about the registrant to consider the registration |
|
1173 | - // NOT incomplete |
|
1174 | - $registration_processor->toggle_incomplete_registration_status_to_default( |
|
1175 | - $registration, |
|
1176 | - false, |
|
1177 | - new Context( |
|
1178 | - 'spco_reg_step_attendee_information_process_registrations', |
|
1179 | - esc_html__( |
|
1180 | - 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
1181 | - 'event_espresso' |
|
1182 | - ) |
|
1183 | - ) |
|
1184 | - ); |
|
1185 | - // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
1186 | - // abandoned |
|
1187 | - $this->checkout->transaction->toggle_failed_transaction_status(); |
|
1188 | - // if we've gotten this far, then let's save what we have |
|
1189 | - $registration->save(); |
|
1190 | - // add relation between TXN and registration |
|
1191 | - $this->_associate_registration_with_transaction($registration); |
|
1192 | - } |
|
1193 | - } else { |
|
1194 | - EE_Error::add_error( |
|
1195 | - esc_html__( |
|
1196 | - 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
1197 | - 'event_espresso' |
|
1198 | - ), |
|
1199 | - __FILE__, |
|
1200 | - __FUNCTION__, |
|
1201 | - __LINE__ |
|
1202 | - ); |
|
1203 | - // remove malformed data |
|
1204 | - unset($valid_data[ $reg_url_link ]); |
|
1205 | - return false; |
|
1206 | - } |
|
1207 | - } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
1208 | - return $att_nmbr; |
|
1209 | - } |
|
1210 | - |
|
1211 | - |
|
1212 | - /** |
|
1213 | - * _save_registration_form_input |
|
1214 | - * |
|
1215 | - * @param EE_Registration $registration |
|
1216 | - * @param string $form_input |
|
1217 | - * @param string $input_value |
|
1218 | - * @return bool |
|
1219 | - * @throws EE_Error |
|
1220 | - * @throws InvalidArgumentException |
|
1221 | - * @throws InvalidDataTypeException |
|
1222 | - * @throws InvalidInterfaceException |
|
1223 | - * @throws ReflectionException |
|
1224 | - */ |
|
1225 | - private function _save_registration_form_input( |
|
1226 | - EE_Registration $registration, |
|
1227 | - $form_input = '', |
|
1228 | - $input_value = '' |
|
1229 | - ) { |
|
1230 | - // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
1231 | - // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
1232 | - // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
1233 | - // allow for plugins to hook in and do their own processing of the form input. |
|
1234 | - // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
1235 | - if (apply_filters( |
|
1236 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
1237 | - false, |
|
1238 | - $registration, |
|
1239 | - $form_input, |
|
1240 | - $input_value, |
|
1241 | - $this |
|
1242 | - )) { |
|
1243 | - return true; |
|
1244 | - } |
|
1245 | - /* |
|
356 | + // Increment the reg forms number if form is valid. |
|
357 | + if (!empty($form_args)) { |
|
358 | + $this->reg_form_count++; |
|
359 | + } |
|
360 | + |
|
361 | + return ! empty($form_args) |
|
362 | + ? new EE_Form_Section_Proper($form_args) |
|
363 | + : new EE_Form_Section_HTML(); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * @param EE_Registration $registration |
|
369 | + * @param bool $additional_attendee_reg_info |
|
370 | + * @return EE_Form_Input_Base |
|
371 | + * @throws EE_Error |
|
372 | + */ |
|
373 | + private function _additional_attendee_reg_info_input( |
|
374 | + EE_Registration $registration, |
|
375 | + $additional_attendee_reg_info = true |
|
376 | + ) { |
|
377 | + // generate hidden input |
|
378 | + return new EE_Hidden_Input( |
|
379 | + array( |
|
380 | + 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
381 | + 'default' => $additional_attendee_reg_info, |
|
382 | + ) |
|
383 | + ); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * @param EE_Registration $registration |
|
389 | + * @param EE_Question_Group $question_group |
|
390 | + * @return EE_Form_Section_Proper |
|
391 | + * @throws EE_Error |
|
392 | + * @throws InvalidArgumentException |
|
393 | + * @throws InvalidDataTypeException |
|
394 | + * @throws InvalidInterfaceException |
|
395 | + * @throws ReflectionException |
|
396 | + */ |
|
397 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) |
|
398 | + { |
|
399 | + // array of params to pass to parent constructor |
|
400 | + $form_args = array( |
|
401 | + 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
402 | + 'html_class' => $this->checkout->admin_request |
|
403 | + ? 'form-table ee-reg-form-qstn-grp-dv' |
|
404 | + : 'ee-reg-form-qstn-grp-dv', |
|
405 | + 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
406 | + . $registration->ID() . '-lbl', |
|
407 | + 'subsections' => array( |
|
408 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
|
409 | + ), |
|
410 | + 'layout_strategy' => $this->checkout->admin_request |
|
411 | + ? new EE_Admin_Two_Column_Layout() |
|
412 | + : new EE_Div_Per_Section_Layout(), |
|
413 | + ); |
|
414 | + // where params |
|
415 | + $query_params = array('QST_deleted' => 0); |
|
416 | + // don't load admin only questions on the frontend |
|
417 | + if (! $this->checkout->admin_request) { |
|
418 | + $query_params['QST_admin_only'] = array('!=', true); |
|
419 | + } |
|
420 | + $questions = $question_group->get_many_related( |
|
421 | + 'Question', |
|
422 | + apply_filters( |
|
423 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
424 | + array( |
|
425 | + $query_params, |
|
426 | + 'order_by' => array( |
|
427 | + 'Question_Group_Question.QGQ_order' => 'ASC', |
|
428 | + ), |
|
429 | + ), |
|
430 | + $question_group, |
|
431 | + $registration, |
|
432 | + $this |
|
433 | + ) |
|
434 | + ); |
|
435 | + // filter for additional content before questions |
|
436 | + $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
437 | + apply_filters( |
|
438 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
439 | + '', |
|
440 | + $registration, |
|
441 | + $question_group, |
|
442 | + $this |
|
443 | + ) |
|
444 | + ); |
|
445 | + // loop thru questions |
|
446 | + foreach ($questions as $question) { |
|
447 | + if ($question instanceof EE_Question) { |
|
448 | + $identifier = $question->is_system_question() |
|
449 | + ? $question->system_ID() |
|
450 | + : $question->ID(); |
|
451 | + $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
452 | + } |
|
453 | + } |
|
454 | + $form_args['subsections'] = apply_filters( |
|
455 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
456 | + $form_args['subsections'], |
|
457 | + $registration, |
|
458 | + $question_group, |
|
459 | + $this |
|
460 | + ); |
|
461 | + // filter for additional content after questions |
|
462 | + $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
463 | + apply_filters( |
|
464 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
465 | + '', |
|
466 | + $registration, |
|
467 | + $question_group, |
|
468 | + $this |
|
469 | + ) |
|
470 | + ); |
|
471 | + // d($form_args); |
|
472 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
473 | + return apply_filters( |
|
474 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
475 | + $question_group_reg_form, |
|
476 | + $registration, |
|
477 | + $question_group, |
|
478 | + $this |
|
479 | + ); |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + /** |
|
484 | + * @param EE_Question_Group $question_group |
|
485 | + * @return EE_Form_Section_HTML |
|
486 | + */ |
|
487 | + private function _question_group_header(EE_Question_Group $question_group) |
|
488 | + { |
|
489 | + $html = ''; |
|
490 | + // group_name |
|
491 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
492 | + if ($this->checkout->admin_request) { |
|
493 | + $html .= EEH_HTML::br(); |
|
494 | + $html .= EEH_HTML::h3( |
|
495 | + $question_group->name(), |
|
496 | + '', |
|
497 | + 'ee-reg-form-qstn-grp-title title', |
|
498 | + 'font-size: 1.3em; padding-left:0;' |
|
499 | + ); |
|
500 | + } else { |
|
501 | + $html .= EEH_HTML::h4( |
|
502 | + $question_group->name(), |
|
503 | + '', |
|
504 | + 'ee-reg-form-qstn-grp-title section-title' |
|
505 | + ); |
|
506 | + } |
|
507 | + } |
|
508 | + // group_desc |
|
509 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
510 | + $html .= EEH_HTML::p( |
|
511 | + $question_group->desc(), |
|
512 | + '', |
|
513 | + $this->checkout->admin_request |
|
514 | + ? 'ee-reg-form-qstn-grp-desc-pg' |
|
515 | + : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
516 | + ); |
|
517 | + } |
|
518 | + return new EE_Form_Section_HTML($html); |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + /** |
|
523 | + * @return EE_Form_Section_Proper |
|
524 | + * @throws EE_Error |
|
525 | + * @throws InvalidArgumentException |
|
526 | + * @throws ReflectionException |
|
527 | + * @throws InvalidDataTypeException |
|
528 | + * @throws InvalidInterfaceException |
|
529 | + */ |
|
530 | + private function _copy_attendee_info_form() |
|
531 | + { |
|
532 | + // array of params to pass to parent constructor |
|
533 | + return new EE_Form_Section_Proper( |
|
534 | + array( |
|
535 | + 'subsections' => $this->_copy_attendee_info_inputs(), |
|
536 | + 'layout_strategy' => new EE_Template_Layout( |
|
537 | + array( |
|
538 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
539 | + . $this->_slug |
|
540 | + . '/copy_attendee_info.template.php', |
|
541 | + 'begin_template_file' => null, |
|
542 | + 'input_template_file' => null, |
|
543 | + 'subsection_template_file' => null, |
|
544 | + 'end_template_file' => null, |
|
545 | + ) |
|
546 | + ), |
|
547 | + ) |
|
548 | + ); |
|
549 | + } |
|
550 | + |
|
551 | + |
|
552 | + /** |
|
553 | + * @return EE_Form_Section_HTML |
|
554 | + * @throws DomainException |
|
555 | + * @throws InvalidArgumentException |
|
556 | + * @throws InvalidDataTypeException |
|
557 | + * @throws InvalidInterfaceException |
|
558 | + */ |
|
559 | + private function _auto_copy_attendee_info() |
|
560 | + { |
|
561 | + return new EE_Form_Section_HTML( |
|
562 | + EEH_Template::locate_template( |
|
563 | + SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php', |
|
564 | + apply_filters( |
|
565 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
566 | + array() |
|
567 | + ), |
|
568 | + true, |
|
569 | + true |
|
570 | + ) |
|
571 | + ); |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + /** |
|
576 | + * @return array |
|
577 | + * @throws EE_Error |
|
578 | + * @throws InvalidArgumentException |
|
579 | + * @throws ReflectionException |
|
580 | + * @throws InvalidDataTypeException |
|
581 | + * @throws InvalidInterfaceException |
|
582 | + */ |
|
583 | + private function _copy_attendee_info_inputs() |
|
584 | + { |
|
585 | + $copy_attendee_info_inputs = array(); |
|
586 | + $prev_ticket = null; |
|
587 | + // grab the saved registrations from the transaction |
|
588 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
589 | + foreach ($registrations as $registration) { |
|
590 | + // for all attendees other than the primary attendee |
|
591 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
592 | + // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
593 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
594 | + $item_name = $registration->ticket()->name(); |
|
595 | + $item_name .= $registration->ticket()->description() !== '' |
|
596 | + ? ' - ' . $registration->ticket()->description() |
|
597 | + : ''; |
|
598 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID( |
|
599 | + ) . ']' ] = |
|
600 | + new EE_Form_Section_HTML( |
|
601 | + '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
602 | + ); |
|
603 | + $prev_ticket = $registration->ticket()->ID(); |
|
604 | + } |
|
605 | + |
|
606 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
607 | + new EE_Checkbox_Multi_Input( |
|
608 | + array( |
|
609 | + $registration->ID() => sprintf( |
|
610 | + esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
611 | + $registration->count() |
|
612 | + ), |
|
613 | + ), |
|
614 | + array( |
|
615 | + 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
616 | + 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
617 | + 'display_html_label_text' => false, |
|
618 | + ) |
|
619 | + ); |
|
620 | + } |
|
621 | + } |
|
622 | + return $copy_attendee_info_inputs; |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + /** |
|
627 | + * @param EE_Registration $registration |
|
628 | + * @return EE_Form_Input_Base |
|
629 | + * @throws EE_Error |
|
630 | + */ |
|
631 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) |
|
632 | + { |
|
633 | + // generate hidden input |
|
634 | + return new EE_Hidden_Input( |
|
635 | + array( |
|
636 | + 'html_id' => 'primary_registrant', |
|
637 | + 'default' => $registration->reg_url_link(), |
|
638 | + ) |
|
639 | + ); |
|
640 | + } |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * @param EE_Registration $registration |
|
645 | + * @param EE_Question $question |
|
646 | + * @return EE_Form_Input_Base |
|
647 | + * @throws EE_Error |
|
648 | + * @throws InvalidArgumentException |
|
649 | + * @throws InvalidDataTypeException |
|
650 | + * @throws InvalidInterfaceException |
|
651 | + * @throws ReflectionException |
|
652 | + */ |
|
653 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) |
|
654 | + { |
|
655 | + |
|
656 | + // if this question was for an attendee detail, then check for that answer |
|
657 | + $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
658 | + $registration, |
|
659 | + $question->system_ID() |
|
660 | + ); |
|
661 | + $answer = $answer_value === null |
|
662 | + ? EEM_Answer::instance()->get_one( |
|
663 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
664 | + ) |
|
665 | + : null; |
|
666 | + // if NOT returning to edit an existing registration |
|
667 | + // OR if this question is for an attendee property |
|
668 | + // OR we still don't have an EE_Answer object |
|
669 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
670 | + // create an EE_Answer object for storing everything in |
|
671 | + $answer = EE_Answer::new_instance( |
|
672 | + array( |
|
673 | + 'QST_ID' => $question->ID(), |
|
674 | + 'REG_ID' => $registration->ID(), |
|
675 | + ) |
|
676 | + ); |
|
677 | + } |
|
678 | + // verify instance |
|
679 | + if ($answer instanceof EE_Answer) { |
|
680 | + if (! empty($answer_value)) { |
|
681 | + $answer->set('ANS_value', $answer_value); |
|
682 | + } |
|
683 | + $answer->cache('Question', $question); |
|
684 | + // remember system ID had a bug where sometimes it could be null |
|
685 | + $answer_cache_id = $question->is_system_question() |
|
686 | + ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
687 | + : $question->ID() . '-' . $registration->reg_url_link(); |
|
688 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
689 | + } |
|
690 | + return $this->_generate_question_input($registration, $question, $answer); |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * @param EE_Registration $registration |
|
696 | + * @param EE_Question $question |
|
697 | + * @param $answer |
|
698 | + * @return EE_Form_Input_Base |
|
699 | + * @throws EE_Error |
|
700 | + * @throws InvalidArgumentException |
|
701 | + * @throws ReflectionException |
|
702 | + * @throws InvalidDataTypeException |
|
703 | + * @throws InvalidInterfaceException |
|
704 | + */ |
|
705 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) |
|
706 | + { |
|
707 | + $identifier = $question->is_system_question() |
|
708 | + ? $question->system_ID() |
|
709 | + : $question->ID(); |
|
710 | + $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
711 | + add_filter( |
|
712 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
713 | + array($this, 'use_cached_countries_for_form_input'), |
|
714 | + 10, |
|
715 | + 4 |
|
716 | + ); |
|
717 | + add_filter( |
|
718 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
719 | + array($this, 'use_cached_states_for_form_input'), |
|
720 | + 10, |
|
721 | + 4 |
|
722 | + ); |
|
723 | + $input_constructor_args = array( |
|
724 | + 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
725 | + 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
726 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
727 | + 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
728 | + 'html_label_class' => 'ee-reg-qstn', |
|
729 | + ); |
|
730 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
731 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
732 | + $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
733 | + $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
734 | + $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
735 | + } |
|
736 | + $form_input = $question->generate_form_input( |
|
737 | + $registration, |
|
738 | + $answer, |
|
739 | + $input_constructor_args |
|
740 | + ); |
|
741 | + remove_filter( |
|
742 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
743 | + array($this, 'use_cached_countries_for_form_input') |
|
744 | + ); |
|
745 | + remove_filter( |
|
746 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
747 | + array($this, 'use_cached_states_for_form_input') |
|
748 | + ); |
|
749 | + return $form_input; |
|
750 | + } |
|
751 | + |
|
752 | + |
|
753 | + /** |
|
754 | + * Gets the list of countries for the form input |
|
755 | + * |
|
756 | + * @param array|null $countries_list |
|
757 | + * @param EE_Question $question |
|
758 | + * @param EE_Registration $registration |
|
759 | + * @param EE_Answer $answer |
|
760 | + * @return array 2d keys are country IDs, values are their names |
|
761 | + * @throws EE_Error |
|
762 | + * @throws InvalidArgumentException |
|
763 | + * @throws InvalidDataTypeException |
|
764 | + * @throws InvalidInterfaceException |
|
765 | + * @throws ReflectionException |
|
766 | + */ |
|
767 | + public function use_cached_countries_for_form_input( |
|
768 | + $countries_list, |
|
769 | + EE_Question $question = null, |
|
770 | + EE_Registration $registration = null, |
|
771 | + EE_Answer $answer = null |
|
772 | + ) { |
|
773 | + $country_options = array('' => ''); |
|
774 | + // get possibly cached list of countries |
|
775 | + $countries = $this->checkout->action === 'process_reg_step' |
|
776 | + ? EEM_Country::instance()->get_all_countries() |
|
777 | + : EEM_Country::instance()->get_all_active_countries(); |
|
778 | + if (! empty($countries)) { |
|
779 | + foreach ($countries as $country) { |
|
780 | + if ($country instanceof EE_Country) { |
|
781 | + $country_options[ $country->ID() ] = $country->name(); |
|
782 | + } |
|
783 | + } |
|
784 | + } |
|
785 | + if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
786 | + $answer = EEM_Answer::instance()->get_one( |
|
787 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
788 | + ); |
|
789 | + } else { |
|
790 | + $answer = EE_Answer::new_instance(); |
|
791 | + } |
|
792 | + $country_options = apply_filters( |
|
793 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
794 | + $country_options, |
|
795 | + $this, |
|
796 | + $registration, |
|
797 | + $question, |
|
798 | + $answer |
|
799 | + ); |
|
800 | + return $country_options; |
|
801 | + } |
|
802 | + |
|
803 | + |
|
804 | + /** |
|
805 | + * Gets the list of states for the form input |
|
806 | + * |
|
807 | + * @param array|null $states_list |
|
808 | + * @param EE_Question $question |
|
809 | + * @param EE_Registration $registration |
|
810 | + * @param EE_Answer $answer |
|
811 | + * @return array 2d keys are state IDs, values are their names |
|
812 | + * @throws EE_Error |
|
813 | + * @throws InvalidArgumentException |
|
814 | + * @throws InvalidDataTypeException |
|
815 | + * @throws InvalidInterfaceException |
|
816 | + * @throws ReflectionException |
|
817 | + */ |
|
818 | + public function use_cached_states_for_form_input( |
|
819 | + $states_list, |
|
820 | + EE_Question $question = null, |
|
821 | + EE_Registration $registration = null, |
|
822 | + EE_Answer $answer = null |
|
823 | + ) { |
|
824 | + $state_options = array('' => array('' => '')); |
|
825 | + $states = $this->checkout->action === 'process_reg_step' |
|
826 | + ? EEM_State::instance()->get_all_states() |
|
827 | + : EEM_State::instance()->get_all_active_states(); |
|
828 | + if (! empty($states)) { |
|
829 | + foreach ($states as $state) { |
|
830 | + if ($state instanceof EE_State) { |
|
831 | + $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
832 | + } |
|
833 | + } |
|
834 | + } |
|
835 | + $state_options = apply_filters( |
|
836 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
837 | + $state_options, |
|
838 | + $this, |
|
839 | + $registration, |
|
840 | + $question, |
|
841 | + $answer |
|
842 | + ); |
|
843 | + return $state_options; |
|
844 | + } |
|
845 | + |
|
846 | + |
|
847 | + /********************************************************************************************************/ |
|
848 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
849 | + /********************************************************************************************************/ |
|
850 | + |
|
851 | + |
|
852 | + /** |
|
853 | + * @return bool |
|
854 | + * @throws EE_Error |
|
855 | + * @throws InvalidArgumentException |
|
856 | + * @throws ReflectionException |
|
857 | + * @throws RuntimeException |
|
858 | + * @throws InvalidDataTypeException |
|
859 | + * @throws InvalidInterfaceException |
|
860 | + */ |
|
861 | + public function process_reg_step() |
|
862 | + { |
|
863 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
864 | + // grab validated data from form |
|
865 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
866 | + // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
867 | + // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
868 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
869 | + if (empty($valid_data)) { |
|
870 | + EE_Error::add_error( |
|
871 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
872 | + __FILE__, |
|
873 | + __FUNCTION__, |
|
874 | + __LINE__ |
|
875 | + ); |
|
876 | + return false; |
|
877 | + } |
|
878 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
879 | + EE_Error::add_error( |
|
880 | + esc_html__( |
|
881 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
882 | + 'event_espresso' |
|
883 | + ), |
|
884 | + __FILE__, |
|
885 | + __FUNCTION__, |
|
886 | + __LINE__ |
|
887 | + ); |
|
888 | + return false; |
|
889 | + } |
|
890 | + // get cached registrations |
|
891 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
892 | + // verify we got the goods |
|
893 | + if (empty($registrations)) { |
|
894 | + // combine the old translated string with a new one, in order to not break translations |
|
895 | + $error_message = esc_html__( |
|
896 | + 'Your form data could not be applied to any valid registrations.', |
|
897 | + 'event_espresso' |
|
898 | + ) |
|
899 | + . sprintf( |
|
900 | + esc_html_x( |
|
901 | + '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
902 | + '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
903 | + 'event_espresso' |
|
904 | + ), |
|
905 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
906 | + '</a>', |
|
907 | + '<br />' |
|
908 | + ); |
|
909 | + EE_Error::add_error( |
|
910 | + $error_message, |
|
911 | + __FILE__, |
|
912 | + __FUNCTION__, |
|
913 | + __LINE__ |
|
914 | + ); |
|
915 | + return false; |
|
916 | + } |
|
917 | + // extract attendee info from form data and save to model objects |
|
918 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
919 | + // if first pass thru SPCO, |
|
920 | + // then let's check processed registrations against the total number of tickets in the cart |
|
921 | + if ($registrations_processed === false) { |
|
922 | + // but return immediately if the previous step exited early due to errors |
|
923 | + return false; |
|
924 | + } |
|
925 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
926 | + // generate a correctly translated string for all possible singular/plural combinations |
|
927 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
928 | + $error_msg = sprintf( |
|
929 | + esc_html_x( |
|
930 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
931 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
932 | + 'event_espresso' |
|
933 | + ), |
|
934 | + $this->checkout->total_ticket_count, |
|
935 | + $registrations_processed |
|
936 | + ); |
|
937 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
938 | + $error_msg = sprintf( |
|
939 | + esc_html_x( |
|
940 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
941 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
942 | + 'event_espresso' |
|
943 | + ), |
|
944 | + $this->checkout->total_ticket_count, |
|
945 | + $registrations_processed |
|
946 | + ); |
|
947 | + } else { |
|
948 | + $error_msg = sprintf( |
|
949 | + esc_html__( |
|
950 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
951 | + 'event_espresso' |
|
952 | + ), |
|
953 | + $this->checkout->total_ticket_count, |
|
954 | + $registrations_processed |
|
955 | + ); |
|
956 | + } |
|
957 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
958 | + return false; |
|
959 | + } |
|
960 | + // mark this reg step as completed |
|
961 | + $this->set_completed(); |
|
962 | + $this->_set_success_message( |
|
963 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
964 | + ); |
|
965 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
966 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
967 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
968 | + return true; |
|
969 | + } |
|
970 | + |
|
971 | + |
|
972 | + /** |
|
973 | + * _process_registrations |
|
974 | + * |
|
975 | + * @param EE_Registration[] $registrations |
|
976 | + * @param array[][] $valid_data |
|
977 | + * @return bool|int |
|
978 | + * @throws EntityNotFoundException |
|
979 | + * @throws EE_Error |
|
980 | + * @throws InvalidArgumentException |
|
981 | + * @throws ReflectionException |
|
982 | + * @throws RuntimeException |
|
983 | + * @throws InvalidDataTypeException |
|
984 | + * @throws InvalidInterfaceException |
|
985 | + */ |
|
986 | + private function _process_registrations($registrations = array(), $valid_data = array()) |
|
987 | + { |
|
988 | + // load resources and set some defaults |
|
989 | + EE_Registry::instance()->load_model('Attendee'); |
|
990 | + // holder for primary registrant attendee object |
|
991 | + $this->checkout->primary_attendee_obj = null; |
|
992 | + // array for tracking reg form data for the primary registrant |
|
993 | + $primary_registrant = array( |
|
994 | + 'line_item_id' => null, |
|
995 | + ); |
|
996 | + $copy_primary = false; |
|
997 | + // reg form sections that do not contain inputs |
|
998 | + $non_input_form_sections = array( |
|
999 | + 'primary_registrant', |
|
1000 | + 'additional_attendee_reg_info', |
|
1001 | + 'spco_copy_attendee_chk', |
|
1002 | + ); |
|
1003 | + // attendee counter |
|
1004 | + $att_nmbr = 0; |
|
1005 | + // grab the saved registrations from the transaction |
|
1006 | + foreach ($registrations as $registration) { |
|
1007 | + // verify EE_Registration object |
|
1008 | + if (! $registration instanceof EE_Registration) { |
|
1009 | + EE_Error::add_error( |
|
1010 | + esc_html__( |
|
1011 | + 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
1012 | + 'event_espresso' |
|
1013 | + ), |
|
1014 | + __FILE__, |
|
1015 | + __FUNCTION__, |
|
1016 | + __LINE__ |
|
1017 | + ); |
|
1018 | + return false; |
|
1019 | + } |
|
1020 | + /** @var string $reg_url_link */ |
|
1021 | + $reg_url_link = $registration->reg_url_link(); |
|
1022 | + // reg_url_link exists ? |
|
1023 | + if (! empty($reg_url_link)) { |
|
1024 | + // should this registration be processed during this visit ? |
|
1025 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
1026 | + // if NOT revisiting, then let's save the registration now, |
|
1027 | + // so that we have a REG_ID to use when generating other objects |
|
1028 | + if (! $this->checkout->revisit) { |
|
1029 | + $registration->save(); |
|
1030 | + } |
|
1031 | + /** |
|
1032 | + * This allows plugins to trigger a fail on processing of a |
|
1033 | + * registration for any conditions they may have for it to pass. |
|
1034 | + * |
|
1035 | + * @var bool if true is returned by the plugin then the |
|
1036 | + * registration processing is halted. |
|
1037 | + */ |
|
1038 | + if (apply_filters( |
|
1039 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
1040 | + false, |
|
1041 | + $att_nmbr, |
|
1042 | + $registration, |
|
1043 | + $registrations, |
|
1044 | + $valid_data, |
|
1045 | + $this |
|
1046 | + )) { |
|
1047 | + return false; |
|
1048 | + } |
|
1049 | + |
|
1050 | + // Houston, we have a registration! |
|
1051 | + $att_nmbr++; |
|
1052 | + $this->_attendee_data[ $reg_url_link ] = array(); |
|
1053 | + // grab any existing related answer objects |
|
1054 | + $this->_registration_answers = $registration->answers(); |
|
1055 | + // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
1056 | + if (isset($valid_data[ $reg_url_link ])) { |
|
1057 | + // do we need to copy basic info from primary attendee ? |
|
1058 | + $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
1059 | + && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
1060 | + // filter form input data for this registration |
|
1061 | + $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
1062 | + 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
1063 | + $valid_data[ $reg_url_link ] |
|
1064 | + ); |
|
1065 | + if (isset($valid_data['primary_attendee'])) { |
|
1066 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
1067 | + ? $valid_data['primary_attendee'] |
|
1068 | + : false; |
|
1069 | + unset($valid_data['primary_attendee']); |
|
1070 | + } |
|
1071 | + // now loop through our array of valid post data && process attendee reg forms |
|
1072 | + foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
1073 | + if (! in_array($form_section, $non_input_form_sections, true)) { |
|
1074 | + foreach ($form_inputs as $form_input => $input_value) { |
|
1075 | + // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
1076 | + // check for critical inputs |
|
1077 | + if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1078 | + $form_input, |
|
1079 | + $input_value |
|
1080 | + ) |
|
1081 | + ) { |
|
1082 | + return false; |
|
1083 | + } |
|
1084 | + // store a bit of data about the primary attendee |
|
1085 | + if ($att_nmbr === 1 |
|
1086 | + && ! empty($input_value) |
|
1087 | + && $reg_url_link === $primary_registrant['line_item_id'] |
|
1088 | + ) { |
|
1089 | + $primary_registrant[ $form_input ] = $input_value; |
|
1090 | + } elseif ($copy_primary |
|
1091 | + && $input_value === null |
|
1092 | + && isset($primary_registrant[ $form_input ]) |
|
1093 | + ) { |
|
1094 | + $input_value = $primary_registrant[ $form_input ]; |
|
1095 | + } |
|
1096 | + // now attempt to save the input data |
|
1097 | + if (! $this->_save_registration_form_input( |
|
1098 | + $registration, |
|
1099 | + $form_input, |
|
1100 | + $input_value |
|
1101 | + ) |
|
1102 | + ) { |
|
1103 | + EE_Error::add_error( |
|
1104 | + sprintf( |
|
1105 | + esc_html_x( |
|
1106 | + 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
1107 | + 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
1108 | + 'event_espresso' |
|
1109 | + ), |
|
1110 | + $form_input, |
|
1111 | + $input_value |
|
1112 | + ), |
|
1113 | + __FILE__, |
|
1114 | + __FUNCTION__, |
|
1115 | + __LINE__ |
|
1116 | + ); |
|
1117 | + return false; |
|
1118 | + } |
|
1119 | + } |
|
1120 | + } |
|
1121 | + } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
1122 | + } |
|
1123 | + // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
1124 | + // this registration does not require additional attendee information ? |
|
1125 | + if ($copy_primary |
|
1126 | + && $att_nmbr > 1 |
|
1127 | + && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
1128 | + ) { |
|
1129 | + // just copy the primary registrant |
|
1130 | + $attendee = $this->checkout->primary_attendee_obj; |
|
1131 | + } else { |
|
1132 | + // ensure critical details are set for additional attendees |
|
1133 | + $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
1134 | + ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
1135 | + $this->_attendee_data[ $reg_url_link ] |
|
1136 | + ) |
|
1137 | + : $this->_attendee_data[ $reg_url_link ]; |
|
1138 | + // execute create attendee command (which may return an existing attendee) |
|
1139 | + $attendee = EE_Registry::instance()->BUS->execute( |
|
1140 | + new CreateAttendeeCommand( |
|
1141 | + $this->_attendee_data[ $reg_url_link ], |
|
1142 | + $registration |
|
1143 | + ) |
|
1144 | + ); |
|
1145 | + // who's #1 ? |
|
1146 | + if ($att_nmbr === 1) { |
|
1147 | + $this->checkout->primary_attendee_obj = $attendee; |
|
1148 | + } |
|
1149 | + } |
|
1150 | + // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
1151 | + // add relation to registration, set attendee ID, and cache attendee |
|
1152 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
1153 | + // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
1154 | + if (! $registration->attendee() instanceof EE_Attendee) { |
|
1155 | + EE_Error::add_error( |
|
1156 | + sprintf( |
|
1157 | + esc_html_x( |
|
1158 | + 'Registration %s has an invalid or missing Attendee object.', |
|
1159 | + 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
1160 | + 'event_espresso' |
|
1161 | + ), |
|
1162 | + $reg_url_link |
|
1163 | + ), |
|
1164 | + __FILE__, |
|
1165 | + __FUNCTION__, |
|
1166 | + __LINE__ |
|
1167 | + ); |
|
1168 | + return false; |
|
1169 | + } |
|
1170 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1171 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1172 | + // at this point, we should have enough details about the registrant to consider the registration |
|
1173 | + // NOT incomplete |
|
1174 | + $registration_processor->toggle_incomplete_registration_status_to_default( |
|
1175 | + $registration, |
|
1176 | + false, |
|
1177 | + new Context( |
|
1178 | + 'spco_reg_step_attendee_information_process_registrations', |
|
1179 | + esc_html__( |
|
1180 | + 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
1181 | + 'event_espresso' |
|
1182 | + ) |
|
1183 | + ) |
|
1184 | + ); |
|
1185 | + // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
1186 | + // abandoned |
|
1187 | + $this->checkout->transaction->toggle_failed_transaction_status(); |
|
1188 | + // if we've gotten this far, then let's save what we have |
|
1189 | + $registration->save(); |
|
1190 | + // add relation between TXN and registration |
|
1191 | + $this->_associate_registration_with_transaction($registration); |
|
1192 | + } |
|
1193 | + } else { |
|
1194 | + EE_Error::add_error( |
|
1195 | + esc_html__( |
|
1196 | + 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
1197 | + 'event_espresso' |
|
1198 | + ), |
|
1199 | + __FILE__, |
|
1200 | + __FUNCTION__, |
|
1201 | + __LINE__ |
|
1202 | + ); |
|
1203 | + // remove malformed data |
|
1204 | + unset($valid_data[ $reg_url_link ]); |
|
1205 | + return false; |
|
1206 | + } |
|
1207 | + } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
1208 | + return $att_nmbr; |
|
1209 | + } |
|
1210 | + |
|
1211 | + |
|
1212 | + /** |
|
1213 | + * _save_registration_form_input |
|
1214 | + * |
|
1215 | + * @param EE_Registration $registration |
|
1216 | + * @param string $form_input |
|
1217 | + * @param string $input_value |
|
1218 | + * @return bool |
|
1219 | + * @throws EE_Error |
|
1220 | + * @throws InvalidArgumentException |
|
1221 | + * @throws InvalidDataTypeException |
|
1222 | + * @throws InvalidInterfaceException |
|
1223 | + * @throws ReflectionException |
|
1224 | + */ |
|
1225 | + private function _save_registration_form_input( |
|
1226 | + EE_Registration $registration, |
|
1227 | + $form_input = '', |
|
1228 | + $input_value = '' |
|
1229 | + ) { |
|
1230 | + // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
1231 | + // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
1232 | + // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
1233 | + // allow for plugins to hook in and do their own processing of the form input. |
|
1234 | + // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
1235 | + if (apply_filters( |
|
1236 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
1237 | + false, |
|
1238 | + $registration, |
|
1239 | + $form_input, |
|
1240 | + $input_value, |
|
1241 | + $this |
|
1242 | + )) { |
|
1243 | + return true; |
|
1244 | + } |
|
1245 | + /* |
|
1246 | 1246 | * $answer_cache_id is the key used to find the EE_Answer we want |
1247 | 1247 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1248 | 1248 | */ |
1249 | - $answer_cache_id = $this->checkout->reg_url_link |
|
1250 | - ? $form_input . '-' . $registration->reg_url_link() |
|
1251 | - : $form_input; |
|
1252 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
1253 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
1254 | - // rename form_inputs if they are EE_Attendee properties |
|
1255 | - switch ((string) $form_input) { |
|
1256 | - case 'state': |
|
1257 | - case 'STA_ID': |
|
1258 | - $attendee_property = true; |
|
1259 | - $form_input = 'STA_ID'; |
|
1260 | - break; |
|
1261 | - |
|
1262 | - case 'country': |
|
1263 | - case 'CNT_ISO': |
|
1264 | - $attendee_property = true; |
|
1265 | - $form_input = 'CNT_ISO'; |
|
1266 | - break; |
|
1267 | - |
|
1268 | - default: |
|
1269 | - $ATT_input = 'ATT_' . $form_input; |
|
1270 | - // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
1271 | - $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1272 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1273 | - } |
|
1274 | - // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
1275 | - // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
1276 | - // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
1277 | - // if this form input has a corresponding attendee property |
|
1278 | - if ($attendee_property) { |
|
1279 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1280 | - if ($answer_is_obj) { |
|
1281 | - // and delete the corresponding answer since we won't be storing this data in that object |
|
1282 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
1283 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1284 | - } |
|
1285 | - return true; |
|
1286 | - } |
|
1287 | - if ($answer_is_obj) { |
|
1288 | - // save this data to the answer object |
|
1289 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
1290 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1291 | - return $result !== false; |
|
1292 | - } |
|
1293 | - foreach ($this->_registration_answers as $answer) { |
|
1294 | - if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1295 | - $answer->set_value($input_value); |
|
1296 | - $result = $answer->save(); |
|
1297 | - return $result !== false; |
|
1298 | - } |
|
1299 | - } |
|
1300 | - return false; |
|
1301 | - } |
|
1302 | - |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * _verify_critical_attendee_details_are_set |
|
1306 | - * |
|
1307 | - * @param string $form_input |
|
1308 | - * @param string $input_value |
|
1309 | - * @return boolean |
|
1310 | - */ |
|
1311 | - private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
1312 | - $form_input = '', |
|
1313 | - $input_value = '' |
|
1314 | - ) { |
|
1315 | - if (empty($input_value)) { |
|
1316 | - // if the form input isn't marked as being required, then just return |
|
1317 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
1318 | - return true; |
|
1319 | - } |
|
1320 | - switch ($form_input) { |
|
1321 | - case 'fname': |
|
1322 | - EE_Error::add_error( |
|
1323 | - esc_html__('First Name is a required value.', 'event_espresso'), |
|
1324 | - __FILE__, |
|
1325 | - __FUNCTION__, |
|
1326 | - __LINE__ |
|
1327 | - ); |
|
1328 | - return false; |
|
1329 | - break; |
|
1330 | - case 'lname': |
|
1331 | - EE_Error::add_error( |
|
1332 | - esc_html__('Last Name is a required value.', 'event_espresso'), |
|
1333 | - __FILE__, |
|
1334 | - __FUNCTION__, |
|
1335 | - __LINE__ |
|
1336 | - ); |
|
1337 | - return false; |
|
1338 | - break; |
|
1339 | - case 'email': |
|
1340 | - EE_Error::add_error( |
|
1341 | - esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
1342 | - __FILE__, |
|
1343 | - __FUNCTION__, |
|
1344 | - __LINE__ |
|
1345 | - ); |
|
1346 | - return false; |
|
1347 | - break; |
|
1348 | - } |
|
1349 | - } |
|
1350 | - return true; |
|
1351 | - } |
|
1352 | - |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * _associate_attendee_with_registration |
|
1356 | - * |
|
1357 | - * @param EE_Registration $registration |
|
1358 | - * @param EE_Attendee $attendee |
|
1359 | - * @return void |
|
1360 | - * @throws EE_Error |
|
1361 | - * @throws InvalidArgumentException |
|
1362 | - * @throws ReflectionException |
|
1363 | - * @throws RuntimeException |
|
1364 | - * @throws InvalidDataTypeException |
|
1365 | - * @throws InvalidInterfaceException |
|
1366 | - */ |
|
1367 | - private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
1368 | - { |
|
1369 | - // add relation to attendee |
|
1370 | - $registration->_add_relation_to($attendee, 'Attendee'); |
|
1371 | - $registration->set_attendee_id($attendee->ID()); |
|
1372 | - $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1373 | - } |
|
1374 | - |
|
1375 | - |
|
1376 | - /** |
|
1377 | - * _associate_registration_with_transaction |
|
1378 | - * |
|
1379 | - * @param EE_Registration $registration |
|
1380 | - * @return void |
|
1381 | - * @throws EE_Error |
|
1382 | - * @throws InvalidArgumentException |
|
1383 | - * @throws ReflectionException |
|
1384 | - * @throws InvalidDataTypeException |
|
1385 | - * @throws InvalidInterfaceException |
|
1386 | - */ |
|
1387 | - private function _associate_registration_with_transaction(EE_Registration $registration) |
|
1388 | - { |
|
1389 | - // add relation to registration |
|
1390 | - $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1391 | - $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1392 | - } |
|
1393 | - |
|
1394 | - |
|
1395 | - /** |
|
1396 | - * _copy_critical_attendee_details_from_primary_registrant |
|
1397 | - * ensures that all attendees at least have data for first name, last name, and email address |
|
1398 | - * |
|
1399 | - * @param array $attendee_data |
|
1400 | - * @return array |
|
1401 | - * @throws EE_Error |
|
1402 | - * @throws InvalidArgumentException |
|
1403 | - * @throws ReflectionException |
|
1404 | - * @throws InvalidDataTypeException |
|
1405 | - * @throws InvalidInterfaceException |
|
1406 | - */ |
|
1407 | - private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
1408 | - { |
|
1409 | - // bare minimum critical details include first name, last name, email address |
|
1410 | - $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1411 | - // add address info to critical details? |
|
1412 | - if (apply_filters( |
|
1413 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
1414 | - false |
|
1415 | - )) { |
|
1416 | - $address_details = array( |
|
1417 | - 'ATT_address', |
|
1418 | - 'ATT_address2', |
|
1419 | - 'ATT_city', |
|
1420 | - 'STA_ID', |
|
1421 | - 'CNT_ISO', |
|
1422 | - 'ATT_zip', |
|
1423 | - 'ATT_phone', |
|
1424 | - ); |
|
1425 | - $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1426 | - } |
|
1427 | - foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1428 | - if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
1429 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
1430 | - ) { |
|
1431 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1432 | - $critical_attendee_detail |
|
1433 | - ); |
|
1434 | - } |
|
1435 | - } |
|
1436 | - return $attendee_data; |
|
1437 | - } |
|
1438 | - |
|
1439 | - |
|
1440 | - /** |
|
1441 | - * update_reg_step |
|
1442 | - * this is the final step after a user revisits the site to edit their attendee information |
|
1443 | - * this gets called AFTER the process_reg_step() method above |
|
1444 | - * |
|
1445 | - * @return bool |
|
1446 | - * @throws EE_Error |
|
1447 | - * @throws InvalidArgumentException |
|
1448 | - * @throws ReflectionException |
|
1449 | - * @throws RuntimeException |
|
1450 | - * @throws InvalidDataTypeException |
|
1451 | - * @throws InvalidInterfaceException |
|
1452 | - */ |
|
1453 | - public function update_reg_step() |
|
1454 | - { |
|
1455 | - // save everything |
|
1456 | - if ($this->process_reg_step()) { |
|
1457 | - $this->checkout->redirect = true; |
|
1458 | - $this->checkout->redirect_url = add_query_arg( |
|
1459 | - array( |
|
1460 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
1461 | - 'revisit' => true, |
|
1462 | - ), |
|
1463 | - $this->checkout->thank_you_page_url |
|
1464 | - ); |
|
1465 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1466 | - return true; |
|
1467 | - } |
|
1468 | - return false; |
|
1469 | - } |
|
1249 | + $answer_cache_id = $this->checkout->reg_url_link |
|
1250 | + ? $form_input . '-' . $registration->reg_url_link() |
|
1251 | + : $form_input; |
|
1252 | + $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
1253 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
1254 | + // rename form_inputs if they are EE_Attendee properties |
|
1255 | + switch ((string) $form_input) { |
|
1256 | + case 'state': |
|
1257 | + case 'STA_ID': |
|
1258 | + $attendee_property = true; |
|
1259 | + $form_input = 'STA_ID'; |
|
1260 | + break; |
|
1261 | + |
|
1262 | + case 'country': |
|
1263 | + case 'CNT_ISO': |
|
1264 | + $attendee_property = true; |
|
1265 | + $form_input = 'CNT_ISO'; |
|
1266 | + break; |
|
1267 | + |
|
1268 | + default: |
|
1269 | + $ATT_input = 'ATT_' . $form_input; |
|
1270 | + // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
1271 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1272 | + $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1273 | + } |
|
1274 | + // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
1275 | + // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
1276 | + // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
1277 | + // if this form input has a corresponding attendee property |
|
1278 | + if ($attendee_property) { |
|
1279 | + $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1280 | + if ($answer_is_obj) { |
|
1281 | + // and delete the corresponding answer since we won't be storing this data in that object |
|
1282 | + $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
1283 | + $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1284 | + } |
|
1285 | + return true; |
|
1286 | + } |
|
1287 | + if ($answer_is_obj) { |
|
1288 | + // save this data to the answer object |
|
1289 | + $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
1290 | + $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1291 | + return $result !== false; |
|
1292 | + } |
|
1293 | + foreach ($this->_registration_answers as $answer) { |
|
1294 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1295 | + $answer->set_value($input_value); |
|
1296 | + $result = $answer->save(); |
|
1297 | + return $result !== false; |
|
1298 | + } |
|
1299 | + } |
|
1300 | + return false; |
|
1301 | + } |
|
1302 | + |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * _verify_critical_attendee_details_are_set |
|
1306 | + * |
|
1307 | + * @param string $form_input |
|
1308 | + * @param string $input_value |
|
1309 | + * @return boolean |
|
1310 | + */ |
|
1311 | + private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
1312 | + $form_input = '', |
|
1313 | + $input_value = '' |
|
1314 | + ) { |
|
1315 | + if (empty($input_value)) { |
|
1316 | + // if the form input isn't marked as being required, then just return |
|
1317 | + if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
1318 | + return true; |
|
1319 | + } |
|
1320 | + switch ($form_input) { |
|
1321 | + case 'fname': |
|
1322 | + EE_Error::add_error( |
|
1323 | + esc_html__('First Name is a required value.', 'event_espresso'), |
|
1324 | + __FILE__, |
|
1325 | + __FUNCTION__, |
|
1326 | + __LINE__ |
|
1327 | + ); |
|
1328 | + return false; |
|
1329 | + break; |
|
1330 | + case 'lname': |
|
1331 | + EE_Error::add_error( |
|
1332 | + esc_html__('Last Name is a required value.', 'event_espresso'), |
|
1333 | + __FILE__, |
|
1334 | + __FUNCTION__, |
|
1335 | + __LINE__ |
|
1336 | + ); |
|
1337 | + return false; |
|
1338 | + break; |
|
1339 | + case 'email': |
|
1340 | + EE_Error::add_error( |
|
1341 | + esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
1342 | + __FILE__, |
|
1343 | + __FUNCTION__, |
|
1344 | + __LINE__ |
|
1345 | + ); |
|
1346 | + return false; |
|
1347 | + break; |
|
1348 | + } |
|
1349 | + } |
|
1350 | + return true; |
|
1351 | + } |
|
1352 | + |
|
1353 | + |
|
1354 | + /** |
|
1355 | + * _associate_attendee_with_registration |
|
1356 | + * |
|
1357 | + * @param EE_Registration $registration |
|
1358 | + * @param EE_Attendee $attendee |
|
1359 | + * @return void |
|
1360 | + * @throws EE_Error |
|
1361 | + * @throws InvalidArgumentException |
|
1362 | + * @throws ReflectionException |
|
1363 | + * @throws RuntimeException |
|
1364 | + * @throws InvalidDataTypeException |
|
1365 | + * @throws InvalidInterfaceException |
|
1366 | + */ |
|
1367 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
1368 | + { |
|
1369 | + // add relation to attendee |
|
1370 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1371 | + $registration->set_attendee_id($attendee->ID()); |
|
1372 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1373 | + } |
|
1374 | + |
|
1375 | + |
|
1376 | + /** |
|
1377 | + * _associate_registration_with_transaction |
|
1378 | + * |
|
1379 | + * @param EE_Registration $registration |
|
1380 | + * @return void |
|
1381 | + * @throws EE_Error |
|
1382 | + * @throws InvalidArgumentException |
|
1383 | + * @throws ReflectionException |
|
1384 | + * @throws InvalidDataTypeException |
|
1385 | + * @throws InvalidInterfaceException |
|
1386 | + */ |
|
1387 | + private function _associate_registration_with_transaction(EE_Registration $registration) |
|
1388 | + { |
|
1389 | + // add relation to registration |
|
1390 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1391 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1392 | + } |
|
1393 | + |
|
1394 | + |
|
1395 | + /** |
|
1396 | + * _copy_critical_attendee_details_from_primary_registrant |
|
1397 | + * ensures that all attendees at least have data for first name, last name, and email address |
|
1398 | + * |
|
1399 | + * @param array $attendee_data |
|
1400 | + * @return array |
|
1401 | + * @throws EE_Error |
|
1402 | + * @throws InvalidArgumentException |
|
1403 | + * @throws ReflectionException |
|
1404 | + * @throws InvalidDataTypeException |
|
1405 | + * @throws InvalidInterfaceException |
|
1406 | + */ |
|
1407 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
1408 | + { |
|
1409 | + // bare minimum critical details include first name, last name, email address |
|
1410 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1411 | + // add address info to critical details? |
|
1412 | + if (apply_filters( |
|
1413 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
1414 | + false |
|
1415 | + )) { |
|
1416 | + $address_details = array( |
|
1417 | + 'ATT_address', |
|
1418 | + 'ATT_address2', |
|
1419 | + 'ATT_city', |
|
1420 | + 'STA_ID', |
|
1421 | + 'CNT_ISO', |
|
1422 | + 'ATT_zip', |
|
1423 | + 'ATT_phone', |
|
1424 | + ); |
|
1425 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1426 | + } |
|
1427 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1428 | + if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
1429 | + || empty($attendee_data[ $critical_attendee_detail ]) |
|
1430 | + ) { |
|
1431 | + $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1432 | + $critical_attendee_detail |
|
1433 | + ); |
|
1434 | + } |
|
1435 | + } |
|
1436 | + return $attendee_data; |
|
1437 | + } |
|
1438 | + |
|
1439 | + |
|
1440 | + /** |
|
1441 | + * update_reg_step |
|
1442 | + * this is the final step after a user revisits the site to edit their attendee information |
|
1443 | + * this gets called AFTER the process_reg_step() method above |
|
1444 | + * |
|
1445 | + * @return bool |
|
1446 | + * @throws EE_Error |
|
1447 | + * @throws InvalidArgumentException |
|
1448 | + * @throws ReflectionException |
|
1449 | + * @throws RuntimeException |
|
1450 | + * @throws InvalidDataTypeException |
|
1451 | + * @throws InvalidInterfaceException |
|
1452 | + */ |
|
1453 | + public function update_reg_step() |
|
1454 | + { |
|
1455 | + // save everything |
|
1456 | + if ($this->process_reg_step()) { |
|
1457 | + $this->checkout->redirect = true; |
|
1458 | + $this->checkout->redirect_url = add_query_arg( |
|
1459 | + array( |
|
1460 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
1461 | + 'revisit' => true, |
|
1462 | + ), |
|
1463 | + $this->checkout->thank_you_page_url |
|
1464 | + ); |
|
1465 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1466 | + return true; |
|
1467 | + } |
|
1468 | + return false; |
|
1469 | + } |
|
1470 | 1470 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ); |
152 | 152 | |
153 | 153 | // if this isn't a revisit, and they have the privacy consent box enalbed, add it |
154 | - if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
154 | + if ( ! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
155 | 155 | $extra_inputs_section->add_subsections( |
156 | 156 | array( |
157 | 157 | 'consent_box' => new EE_Form_Section_Proper( |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'layout_strategy' => |
160 | 160 | new EE_Template_Layout( |
161 | 161 | array( |
162 | - 'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php', |
|
162 | + 'input_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.'/privacy_consent.template.php', |
|
163 | 163 | ) |
164 | 164 | ), |
165 | 165 | 'subsections' => array( |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | if ($registration instanceof EE_Registration |
198 | 198 | && $this->checkout->visit_allows_processing_of_this_registration($registration) |
199 | 199 | ) { |
200 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
201 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
202 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
203 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
200 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
201 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
202 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
203 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
204 | 204 | ) |
205 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
205 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
206 | 206 | : 1; |
207 | 207 | $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
208 | 208 | $this->checkout->cart->get_grand_total(), |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $ticket_line_item = is_array($ticket_line_item) |
213 | 213 | ? reset($ticket_line_item) |
214 | 214 | : $ticket_line_item; |
215 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
215 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
216 | 216 | $Line_Item_Display->display_line_item($ticket_line_item); |
217 | 217 | if ($registration->is_primary_registrant()) { |
218 | 218 | $primary_registrant = $registration->reg_url_link(); |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | ? $this->_copy_attendee_info_form() |
226 | 226 | : $this->_auto_copy_attendee_info(); |
227 | 227 | // generate hidden input |
228 | - if (isset($subsections[ $primary_registrant ]) |
|
229 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
228 | + if (isset($subsections[$primary_registrant]) |
|
229 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
230 | 230 | ) { |
231 | - $subsections[ $primary_registrant ]->add_subsections( |
|
231 | + $subsections[$primary_registrant]->add_subsections( |
|
232 | 232 | $copy_options, |
233 | 233 | 'primary_registrant', |
234 | 234 | false |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | // Set the registration form template (default: one form per ticket details table). |
241 | 241 | // We decide the template to used based on the number of forms. |
242 | 242 | $this->_template = $this->reg_form_count > 1 |
243 | - ? SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php' |
|
244 | - : SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_single.template.php'; |
|
243 | + ? SPCO_REG_STEPS_PATH . $this->_slug.'/attendee_info_main.template.php' |
|
244 | + : SPCO_REG_STEPS_PATH.$this->_slug.'/attendee_info_single.template.php'; |
|
245 | 245 | |
246 | 246 | return new EE_Form_Section_Proper( |
247 | 247 | array( |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | if ($question_groups) { |
299 | 299 | // array of params to pass to parent constructor |
300 | 300 | $form_args = array( |
301 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
301 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
302 | 302 | 'html_class' => 'ee-reg-form-attendee-dv', |
303 | 303 | 'html_style' => $this->checkout->admin_request |
304 | 304 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ); |
321 | 321 | foreach ($question_groups as $question_group) { |
322 | 322 | if ($question_group instanceof EE_Question_Group) { |
323 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
323 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
324 | 324 | $registration, |
325 | 325 | $question_group |
326 | 326 | ); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $attendee_nmbr++; |
355 | 355 | |
356 | 356 | // Increment the reg forms number if form is valid. |
357 | - if (!empty($form_args)) { |
|
357 | + if ( ! empty($form_args)) { |
|
358 | 358 | $this->reg_form_count++; |
359 | 359 | } |
360 | 360 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | // generate hidden input |
378 | 378 | return new EE_Hidden_Input( |
379 | 379 | array( |
380 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
380 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
381 | 381 | 'default' => $additional_attendee_reg_info, |
382 | 382 | ) |
383 | 383 | ); |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | { |
399 | 399 | // array of params to pass to parent constructor |
400 | 400 | $form_args = array( |
401 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
401 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-'.$registration->ID(), |
|
402 | 402 | 'html_class' => $this->checkout->admin_request |
403 | 403 | ? 'form-table ee-reg-form-qstn-grp-dv' |
404 | 404 | : 'ee-reg-form-qstn-grp-dv', |
405 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
406 | - . $registration->ID() . '-lbl', |
|
405 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-' |
|
406 | + . $registration->ID().'-lbl', |
|
407 | 407 | 'subsections' => array( |
408 | 408 | 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
409 | 409 | ), |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | // where params |
415 | 415 | $query_params = array('QST_deleted' => 0); |
416 | 416 | // don't load admin only questions on the frontend |
417 | - if (! $this->checkout->admin_request) { |
|
417 | + if ( ! $this->checkout->admin_request) { |
|
418 | 418 | $query_params['QST_admin_only'] = array('!=', true); |
419 | 419 | } |
420 | 420 | $questions = $question_group->get_many_related( |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $identifier = $question->is_system_question() |
449 | 449 | ? $question->system_ID() |
450 | 450 | : $question->ID(); |
451 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
451 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | $form_args['subsections'] = apply_filters( |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | { |
561 | 561 | return new EE_Form_Section_HTML( |
562 | 562 | EEH_Template::locate_template( |
563 | - SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php', |
|
563 | + SPCO_REG_STEPS_PATH.$this->_slug.'/_auto_copy_attendee_info.template.php', |
|
564 | 564 | apply_filters( |
565 | 565 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
566 | 566 | array() |
@@ -593,17 +593,17 @@ discard block |
||
593 | 593 | if ($registration->ticket()->ID() !== $prev_ticket) { |
594 | 594 | $item_name = $registration->ticket()->name(); |
595 | 595 | $item_name .= $registration->ticket()->description() !== '' |
596 | - ? ' - ' . $registration->ticket()->description() |
|
596 | + ? ' - '.$registration->ticket()->description() |
|
597 | 597 | : ''; |
598 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID( |
|
599 | - ) . ']' ] = |
|
598 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID( |
|
599 | + ).']'] = |
|
600 | 600 | new EE_Form_Section_HTML( |
601 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
601 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
602 | 602 | ); |
603 | 603 | $prev_ticket = $registration->ticket()->ID(); |
604 | 604 | } |
605 | 605 | |
606 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
606 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = |
|
607 | 607 | new EE_Checkbox_Multi_Input( |
608 | 608 | array( |
609 | 609 | $registration->ID() => sprintf( |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | ), |
613 | 613 | ), |
614 | 614 | array( |
615 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
615 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
616 | 616 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
617 | 617 | 'display_html_label_text' => false, |
618 | 618 | ) |
@@ -677,14 +677,14 @@ discard block |
||
677 | 677 | } |
678 | 678 | // verify instance |
679 | 679 | if ($answer instanceof EE_Answer) { |
680 | - if (! empty($answer_value)) { |
|
680 | + if ( ! empty($answer_value)) { |
|
681 | 681 | $answer->set('ANS_value', $answer_value); |
682 | 682 | } |
683 | 683 | $answer->cache('Question', $question); |
684 | 684 | // remember system ID had a bug where sometimes it could be null |
685 | 685 | $answer_cache_id = $question->is_system_question() |
686 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
687 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
686 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
687 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
688 | 688 | $registration->cache('Answer', $answer, $answer_cache_id); |
689 | 689 | } |
690 | 690 | return $this->_generate_question_input($registration, $question, $answer); |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | $identifier = $question->is_system_question() |
708 | 708 | ? $question->system_ID() |
709 | 709 | : $question->ID(); |
710 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
710 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
711 | 711 | add_filter( |
712 | 712 | 'FHEE__EE_Question__generate_form_input__country_options', |
713 | 713 | array($this, 'use_cached_countries_for_form_input'), |
@@ -721,17 +721,17 @@ discard block |
||
721 | 721 | 4 |
722 | 722 | ); |
723 | 723 | $input_constructor_args = array( |
724 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
725 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
726 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
727 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
724 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
725 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
726 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
727 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
728 | 728 | 'html_label_class' => 'ee-reg-qstn', |
729 | 729 | ); |
730 | 730 | $input_constructor_args['html_label_id'] .= '-lbl'; |
731 | 731 | if ($answer instanceof EE_Answer && $answer->ID()) { |
732 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
733 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
734 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
732 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
733 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
734 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
735 | 735 | } |
736 | 736 | $form_input = $question->generate_form_input( |
737 | 737 | $registration, |
@@ -775,10 +775,10 @@ discard block |
||
775 | 775 | $countries = $this->checkout->action === 'process_reg_step' |
776 | 776 | ? EEM_Country::instance()->get_all_countries() |
777 | 777 | : EEM_Country::instance()->get_all_active_countries(); |
778 | - if (! empty($countries)) { |
|
778 | + if ( ! empty($countries)) { |
|
779 | 779 | foreach ($countries as $country) { |
780 | 780 | if ($country instanceof EE_Country) { |
781 | - $country_options[ $country->ID() ] = $country->name(); |
|
781 | + $country_options[$country->ID()] = $country->name(); |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | } |
@@ -825,10 +825,10 @@ discard block |
||
825 | 825 | $states = $this->checkout->action === 'process_reg_step' |
826 | 826 | ? EEM_State::instance()->get_all_states() |
827 | 827 | : EEM_State::instance()->get_all_active_states(); |
828 | - if (! empty($states)) { |
|
828 | + if ( ! empty($states)) { |
|
829 | 829 | foreach ($states as $state) { |
830 | 830 | if ($state instanceof EE_State) { |
831 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
831 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | } |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | ); |
876 | 876 | return false; |
877 | 877 | } |
878 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
878 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
879 | 879 | EE_Error::add_error( |
880 | 880 | esc_html__( |
881 | 881 | 'A valid transaction could not be initiated for processing your registrations.', |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
903 | 903 | 'event_espresso' |
904 | 904 | ), |
905 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
905 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
906 | 906 | '</a>', |
907 | 907 | '<br />' |
908 | 908 | ); |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | // but return immediately if the previous step exited early due to errors |
923 | 923 | return false; |
924 | 924 | } |
925 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
925 | + if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
926 | 926 | // generate a correctly translated string for all possible singular/plural combinations |
927 | 927 | if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
928 | 928 | $error_msg = sprintf( |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | // grab the saved registrations from the transaction |
1006 | 1006 | foreach ($registrations as $registration) { |
1007 | 1007 | // verify EE_Registration object |
1008 | - if (! $registration instanceof EE_Registration) { |
|
1008 | + if ( ! $registration instanceof EE_Registration) { |
|
1009 | 1009 | EE_Error::add_error( |
1010 | 1010 | esc_html__( |
1011 | 1011 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -1020,12 +1020,12 @@ discard block |
||
1020 | 1020 | /** @var string $reg_url_link */ |
1021 | 1021 | $reg_url_link = $registration->reg_url_link(); |
1022 | 1022 | // reg_url_link exists ? |
1023 | - if (! empty($reg_url_link)) { |
|
1023 | + if ( ! empty($reg_url_link)) { |
|
1024 | 1024 | // should this registration be processed during this visit ? |
1025 | 1025 | if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
1026 | 1026 | // if NOT revisiting, then let's save the registration now, |
1027 | 1027 | // so that we have a REG_ID to use when generating other objects |
1028 | - if (! $this->checkout->revisit) { |
|
1028 | + if ( ! $this->checkout->revisit) { |
|
1029 | 1029 | $registration->save(); |
1030 | 1030 | } |
1031 | 1031 | /** |
@@ -1049,18 +1049,18 @@ discard block |
||
1049 | 1049 | |
1050 | 1050 | // Houston, we have a registration! |
1051 | 1051 | $att_nmbr++; |
1052 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
1052 | + $this->_attendee_data[$reg_url_link] = array(); |
|
1053 | 1053 | // grab any existing related answer objects |
1054 | 1054 | $this->_registration_answers = $registration->answers(); |
1055 | 1055 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
1056 | - if (isset($valid_data[ $reg_url_link ])) { |
|
1056 | + if (isset($valid_data[$reg_url_link])) { |
|
1057 | 1057 | // do we need to copy basic info from primary attendee ? |
1058 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
1059 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
1058 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
1059 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0; |
|
1060 | 1060 | // filter form input data for this registration |
1061 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
1061 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
1062 | 1062 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
1063 | - $valid_data[ $reg_url_link ] |
|
1063 | + $valid_data[$reg_url_link] |
|
1064 | 1064 | ); |
1065 | 1065 | if (isset($valid_data['primary_attendee'])) { |
1066 | 1066 | $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
@@ -1069,12 +1069,12 @@ discard block |
||
1069 | 1069 | unset($valid_data['primary_attendee']); |
1070 | 1070 | } |
1071 | 1071 | // now loop through our array of valid post data && process attendee reg forms |
1072 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
1073 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
1072 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
1073 | + if ( ! in_array($form_section, $non_input_form_sections, true)) { |
|
1074 | 1074 | foreach ($form_inputs as $form_input => $input_value) { |
1075 | 1075 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
1076 | 1076 | // check for critical inputs |
1077 | - if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1077 | + if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1078 | 1078 | $form_input, |
1079 | 1079 | $input_value |
1080 | 1080 | ) |
@@ -1086,15 +1086,15 @@ discard block |
||
1086 | 1086 | && ! empty($input_value) |
1087 | 1087 | && $reg_url_link === $primary_registrant['line_item_id'] |
1088 | 1088 | ) { |
1089 | - $primary_registrant[ $form_input ] = $input_value; |
|
1089 | + $primary_registrant[$form_input] = $input_value; |
|
1090 | 1090 | } elseif ($copy_primary |
1091 | 1091 | && $input_value === null |
1092 | - && isset($primary_registrant[ $form_input ]) |
|
1092 | + && isset($primary_registrant[$form_input]) |
|
1093 | 1093 | ) { |
1094 | - $input_value = $primary_registrant[ $form_input ]; |
|
1094 | + $input_value = $primary_registrant[$form_input]; |
|
1095 | 1095 | } |
1096 | 1096 | // now attempt to save the input data |
1097 | - if (! $this->_save_registration_form_input( |
|
1097 | + if ( ! $this->_save_registration_form_input( |
|
1098 | 1098 | $registration, |
1099 | 1099 | $form_input, |
1100 | 1100 | $input_value |
@@ -1130,15 +1130,15 @@ discard block |
||
1130 | 1130 | $attendee = $this->checkout->primary_attendee_obj; |
1131 | 1131 | } else { |
1132 | 1132 | // ensure critical details are set for additional attendees |
1133 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
1133 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
1134 | 1134 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
1135 | - $this->_attendee_data[ $reg_url_link ] |
|
1135 | + $this->_attendee_data[$reg_url_link] |
|
1136 | 1136 | ) |
1137 | - : $this->_attendee_data[ $reg_url_link ]; |
|
1137 | + : $this->_attendee_data[$reg_url_link]; |
|
1138 | 1138 | // execute create attendee command (which may return an existing attendee) |
1139 | 1139 | $attendee = EE_Registry::instance()->BUS->execute( |
1140 | 1140 | new CreateAttendeeCommand( |
1141 | - $this->_attendee_data[ $reg_url_link ], |
|
1141 | + $this->_attendee_data[$reg_url_link], |
|
1142 | 1142 | $registration |
1143 | 1143 | ) |
1144 | 1144 | ); |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | // add relation to registration, set attendee ID, and cache attendee |
1152 | 1152 | $this->_associate_attendee_with_registration($registration, $attendee); |
1153 | 1153 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
1154 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
1154 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
1155 | 1155 | EE_Error::add_error( |
1156 | 1156 | sprintf( |
1157 | 1157 | esc_html_x( |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | __LINE__ |
1202 | 1202 | ); |
1203 | 1203 | // remove malformed data |
1204 | - unset($valid_data[ $reg_url_link ]); |
|
1204 | + unset($valid_data[$reg_url_link]); |
|
1205 | 1205 | return false; |
1206 | 1206 | } |
1207 | 1207 | } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
@@ -1247,10 +1247,10 @@ discard block |
||
1247 | 1247 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1248 | 1248 | */ |
1249 | 1249 | $answer_cache_id = $this->checkout->reg_url_link |
1250 | - ? $form_input . '-' . $registration->reg_url_link() |
|
1250 | + ? $form_input.'-'.$registration->reg_url_link() |
|
1251 | 1251 | : $form_input; |
1252 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
1253 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
1252 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
1253 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer; |
|
1254 | 1254 | // rename form_inputs if they are EE_Attendee properties |
1255 | 1255 | switch ((string) $form_input) { |
1256 | 1256 | case 'state': |
@@ -1266,28 +1266,28 @@ discard block |
||
1266 | 1266 | break; |
1267 | 1267 | |
1268 | 1268 | default: |
1269 | - $ATT_input = 'ATT_' . $form_input; |
|
1269 | + $ATT_input = 'ATT_'.$form_input; |
|
1270 | 1270 | // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
1271 | 1271 | $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
1272 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1272 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
1273 | 1273 | } |
1274 | 1274 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
1275 | 1275 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
1276 | 1276 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
1277 | 1277 | // if this form input has a corresponding attendee property |
1278 | 1278 | if ($attendee_property) { |
1279 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1279 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
1280 | 1280 | if ($answer_is_obj) { |
1281 | 1281 | // and delete the corresponding answer since we won't be storing this data in that object |
1282 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
1283 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1282 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
1283 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
1284 | 1284 | } |
1285 | 1285 | return true; |
1286 | 1286 | } |
1287 | 1287 | if ($answer_is_obj) { |
1288 | 1288 | // save this data to the answer object |
1289 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
1290 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1289 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
1290 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
1291 | 1291 | return $result !== false; |
1292 | 1292 | } |
1293 | 1293 | foreach ($this->_registration_answers as $answer) { |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | ) { |
1315 | 1315 | if (empty($input_value)) { |
1316 | 1316 | // if the form input isn't marked as being required, then just return |
1317 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
1317 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
1318 | 1318 | return true; |
1319 | 1319 | } |
1320 | 1320 | switch ($form_input) { |
@@ -1425,10 +1425,10 @@ discard block |
||
1425 | 1425 | $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
1426 | 1426 | } |
1427 | 1427 | foreach ($critical_attendee_details as $critical_attendee_detail) { |
1428 | - if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
1429 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
1428 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
1429 | + || empty($attendee_data[$critical_attendee_detail]) |
|
1430 | 1430 | ) { |
1431 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1431 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
1432 | 1432 | $critical_attendee_detail |
1433 | 1433 | ); |
1434 | 1434 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | if (! empty($stages)) { |
15 | - foreach ($stages as $filepath) { |
|
16 | - $matches = array(); |
|
17 | - preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
18 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
19 | - } |
|
15 | + foreach ($stages as $filepath) { |
|
16 | + $matches = array(); |
|
17 | + preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
18 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | // give addons a chance to autoload their stages too |
22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath); |
@@ -44,91 +44,91 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * EE_DMS_Core_4_1_0 constructor. |
|
49 | - * |
|
50 | - * @param TableManager $table_manager |
|
51 | - * @param TableAnalysis $table_analysis |
|
52 | - */ |
|
53 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
54 | - { |
|
55 | - $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso"); |
|
56 | - $this->_priority = 10; |
|
57 | - $this->_migration_stages = array( |
|
58 | - new EE_DMS_4_1_0_org_options(), |
|
59 | - new EE_DMS_4_1_0_shortcodes(), |
|
60 | - new EE_DMS_4_1_0_gateways(), |
|
61 | - new EE_DMS_4_1_0_events(), |
|
62 | - new EE_DMS_4_1_0_prices(), |
|
63 | - new EE_DMS_4_1_0_category_details(), |
|
64 | - new EE_DMS_4_1_0_event_category(), |
|
65 | - new EE_DMS_4_1_0_venues(), |
|
66 | - new EE_DMS_4_1_0_event_venue(), |
|
67 | - new EE_DMS_4_1_0_question_groups(), |
|
68 | - new EE_DMS_4_1_0_questions(), |
|
69 | - new EE_DMS_4_1_0_question_group_question(), |
|
70 | - new EE_DMS_4_1_0_event_question_group(), |
|
71 | - new EE_DMS_4_1_0_attendees(), |
|
72 | - new EE_DMS_4_1_0_line_items(), |
|
73 | - new EE_DMS_4_1_0_answers(), |
|
74 | - new EE_DMS_4_1_0_checkins(), |
|
75 | - ); |
|
76 | - parent::__construct($table_manager, $table_analysis); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins |
|
83 | - * |
|
84 | - * @global wpdb $wpdb |
|
85 | - * @return boolean |
|
86 | - */ |
|
87 | - private function _checkin_table_exists() |
|
88 | - { |
|
89 | - global $wpdb; |
|
90 | - $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'"); |
|
91 | - if ($results) { |
|
92 | - return true; |
|
93 | - } else { |
|
94 | - return false; |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - public function can_migrate_from_version($version_array) |
|
101 | - { |
|
102 | - $version_string = $version_array['Core']; |
|
103 | - if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) { |
|
47 | + /** |
|
48 | + * EE_DMS_Core_4_1_0 constructor. |
|
49 | + * |
|
50 | + * @param TableManager $table_manager |
|
51 | + * @param TableAnalysis $table_analysis |
|
52 | + */ |
|
53 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
54 | + { |
|
55 | + $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso"); |
|
56 | + $this->_priority = 10; |
|
57 | + $this->_migration_stages = array( |
|
58 | + new EE_DMS_4_1_0_org_options(), |
|
59 | + new EE_DMS_4_1_0_shortcodes(), |
|
60 | + new EE_DMS_4_1_0_gateways(), |
|
61 | + new EE_DMS_4_1_0_events(), |
|
62 | + new EE_DMS_4_1_0_prices(), |
|
63 | + new EE_DMS_4_1_0_category_details(), |
|
64 | + new EE_DMS_4_1_0_event_category(), |
|
65 | + new EE_DMS_4_1_0_venues(), |
|
66 | + new EE_DMS_4_1_0_event_venue(), |
|
67 | + new EE_DMS_4_1_0_question_groups(), |
|
68 | + new EE_DMS_4_1_0_questions(), |
|
69 | + new EE_DMS_4_1_0_question_group_question(), |
|
70 | + new EE_DMS_4_1_0_event_question_group(), |
|
71 | + new EE_DMS_4_1_0_attendees(), |
|
72 | + new EE_DMS_4_1_0_line_items(), |
|
73 | + new EE_DMS_4_1_0_answers(), |
|
74 | + new EE_DMS_4_1_0_checkins(), |
|
75 | + ); |
|
76 | + parent::__construct($table_manager, $table_analysis); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins |
|
83 | + * |
|
84 | + * @global wpdb $wpdb |
|
85 | + * @return boolean |
|
86 | + */ |
|
87 | + private function _checkin_table_exists() |
|
88 | + { |
|
89 | + global $wpdb; |
|
90 | + $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'"); |
|
91 | + if ($results) { |
|
92 | + return true; |
|
93 | + } else { |
|
94 | + return false; |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + public function can_migrate_from_version($version_array) |
|
101 | + { |
|
102 | + $version_string = $version_array['Core']; |
|
103 | + if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) { |
|
104 | 104 | // echo "$version_string can be migrated fro"; |
105 | - return true; |
|
106 | - } elseif (! $version_string) { |
|
105 | + return true; |
|
106 | + } elseif (! $version_string) { |
|
107 | 107 | // echo "no version string provided: $version_string"; |
108 | - // no version string provided... this must be pre 4.1 |
|
109 | - // because since 4.1 we're |
|
110 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
111 | - } else { |
|
108 | + // no version string provided... this must be pre 4.1 |
|
109 | + // because since 4.1 we're |
|
110 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
111 | + } else { |
|
112 | 112 | // echo "$version_string doesnt apply"; |
113 | - return false; |
|
114 | - } |
|
115 | - } |
|
113 | + return false; |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - public function schema_changes_before_migration() |
|
120 | - { |
|
121 | - // relies on 4.1's EEH_Activation::create_table |
|
122 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
123 | - $table_name = 'esp_answer'; |
|
124 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
119 | + public function schema_changes_before_migration() |
|
120 | + { |
|
121 | + // relies on 4.1's EEH_Activation::create_table |
|
122 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
123 | + $table_name = 'esp_answer'; |
|
124 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
125 | 125 | REG_ID int(10) unsigned NOT NULL, |
126 | 126 | QST_ID int(10) unsigned NOT NULL, |
127 | 127 | ANS_value text NOT NULL, |
128 | 128 | PRIMARY KEY (ANS_ID)"; |
129 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
130 | - $table_name = 'esp_attendee_meta'; |
|
131 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
129 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
130 | + $table_name = 'esp_attendee_meta'; |
|
131 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
132 | 132 | ATT_ID bigint(20) unsigned NOT NULL, |
133 | 133 | ATT_fname varchar(45) NOT NULL, |
134 | 134 | ATT_lname varchar(45) NOT NULL, |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | KEY ATT_fname (ATT_fname), |
145 | 145 | KEY ATT_lname (ATT_lname), |
146 | 146 | KEY ATT_email (ATT_email(191))"; |
147 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
148 | - $table_name = 'esp_country'; |
|
149 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
147 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
148 | + $table_name = 'esp_country'; |
|
149 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
150 | 150 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
151 | 151 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
152 | 152 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | CNT_is_EU tinyint(1) DEFAULT '0', |
163 | 163 | CNT_active tinyint(1) DEFAULT '0', |
164 | 164 | PRIMARY KEY (CNT_ISO)"; |
165 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
166 | - $table_name = 'esp_datetime'; |
|
167 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
166 | + $table_name = 'esp_datetime'; |
|
167 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
168 | 168 | EVT_ID bigint(20) unsigned NOT NULL, |
169 | 169 | DTT_EVT_start datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
170 | 170 | DTT_EVT_end datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | PRIMARY KEY (DTT_ID), |
178 | 178 | KEY EVT_ID (EVT_ID), |
179 | 179 | KEY DTT_is_primary (DTT_is_primary)"; |
180 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
181 | - $table_name = 'esp_event_meta'; |
|
182 | - $sql = " |
|
180 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
181 | + $table_name = 'esp_event_meta'; |
|
182 | + $sql = " |
|
183 | 183 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
184 | 184 | EVT_ID bigint(20) unsigned NOT NULL, |
185 | 185 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -194,31 +194,31 @@ discard block |
||
194 | 194 | EVT_external_URL varchar(200) NULL, |
195 | 195 | EVT_donations tinyint(1) NULL, |
196 | 196 | PRIMARY KEY (EVTM_ID)"; |
197 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_event_question_group'; |
|
199 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_event_question_group'; |
|
199 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | QSG_ID int(10) unsigned NOT NULL, |
202 | 202 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
203 | 203 | PRIMARY KEY (EQG_ID)"; |
204 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
205 | - $table_name = 'esp_event_venue'; |
|
206 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
204 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
205 | + $table_name = 'esp_event_venue'; |
|
206 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
207 | 207 | EVT_ID bigint(20) unsigned NOT NULL, |
208 | 208 | VNU_ID bigint(20) unsigned NOT NULL, |
209 | 209 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
210 | 210 | PRIMARY KEY (EVV_ID)"; |
211 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
212 | - $table_name = 'esp_extra_meta'; |
|
213 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
211 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
212 | + $table_name = 'esp_extra_meta'; |
|
213 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
214 | 214 | OBJ_ID int(11) DEFAULT NULL, |
215 | 215 | EXM_type varchar(45) DEFAULT NULL, |
216 | 216 | EXM_key varchar(45) DEFAULT NULL, |
217 | 217 | EXM_value text, |
218 | 218 | PRIMARY KEY (EXM_ID)"; |
219 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | - $table_name = 'esp_line_item'; |
|
221 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
219 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $table_name = 'esp_line_item'; |
|
221 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
222 | 222 | LIN_code varchar(245) NOT NULL DEFAULT '', |
223 | 223 | TXN_ID int(11) DEFAULT NULL, |
224 | 224 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -234,18 +234,18 @@ discard block |
||
234 | 234 | OBJ_ID int(11) DEFAULT NULL, |
235 | 235 | OBJ_type varchar(45)DEFAULT NULL, |
236 | 236 | PRIMARY KEY (LIN_ID)"; |
237 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
238 | - $table_name = 'esp_message_template'; |
|
239 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
237 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
238 | + $table_name = 'esp_message_template'; |
|
239 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
240 | 240 | GRP_ID int(10) unsigned NOT NULL, |
241 | 241 | MTP_context varchar(50) NOT NULL, |
242 | 242 | MTP_template_field varchar(30) NOT NULL, |
243 | 243 | MTP_content text NOT NULL, |
244 | 244 | PRIMARY KEY (MTP_ID), |
245 | 245 | KEY GRP_ID (GRP_ID)"; |
246 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | - $table_name = 'esp_message_template_group'; |
|
248 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
246 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | + $table_name = 'esp_message_template_group'; |
|
248 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
249 | 249 | EVT_ID bigint(20) unsigned DEFAULT NULL, |
250 | 250 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
251 | 251 | MTP_messenger varchar(30) NOT NULL, |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | PRIMARY KEY (GRP_ID), |
258 | 258 | KEY EVT_ID (EVT_ID), |
259 | 259 | KEY MTP_user_id (MTP_user_id)"; |
260 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
261 | - $table_name = 'esp_payment'; |
|
262 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
260 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
261 | + $table_name = 'esp_payment'; |
|
262 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
263 | 263 | TXN_ID int(10) unsigned DEFAULT NULL, |
264 | 264 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
265 | 265 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | PRIMARY KEY (PAY_ID), |
276 | 276 | KEY TXN_ID (TXN_ID), |
277 | 277 | KEY PAY_timestamp (PAY_timestamp)"; |
278 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
279 | - $table_name = "esp_ticket"; |
|
280 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
278 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
279 | + $table_name = "esp_ticket"; |
|
280 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
281 | 281 | TTM_ID int(10) unsigned NOT NULL, |
282 | 282 | TKT_name varchar(245) NOT NULL DEFAULT '', |
283 | 283 | TKT_description text NOT NULL, |
@@ -296,28 +296,28 @@ discard block |
||
296 | 296 | TKT_parent int(10) unsigned DEFAULT '0', |
297 | 297 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
298 | 298 | PRIMARY KEY (TKT_ID)"; |
299 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
300 | - $table_name = "esp_ticket_price"; |
|
301 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
299 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
300 | + $table_name = "esp_ticket_price"; |
|
301 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
302 | 302 | TKT_ID int(10) unsigned NOT NULL, |
303 | 303 | PRC_ID int(10) unsigned NOT NULL, |
304 | 304 | PRIMARY KEY (TKP_ID)"; |
305 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | - $table_name = "esp_datetime_ticket"; |
|
307 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
305 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | + $table_name = "esp_datetime_ticket"; |
|
307 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
308 | 308 | DTT_ID int(10) unsigned NOT NULL, |
309 | 309 | TKT_ID int(10) unsigned NOT NULL, |
310 | 310 | PRIMARY KEY (DTK_ID)"; |
311 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
312 | - $table_name = "esp_ticket_template"; |
|
313 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
311 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
312 | + $table_name = "esp_ticket_template"; |
|
313 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
314 | 314 | TTM_name varchar(45) NOT NULL, |
315 | 315 | TTM_description text, |
316 | 316 | TTM_file varchar(45), |
317 | 317 | PRIMARY KEY (TTM_ID)"; |
318 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
319 | - $table_name = "esp_price"; |
|
320 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
318 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
319 | + $table_name = "esp_price"; |
|
320 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
321 | 321 | PRT_ID tinyint(3) unsigned NOT NULL, |
322 | 322 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
323 | 323 | PRC_name varchar(245) NOT NULL, |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
329 | 329 | PRC_parent int(10) unsigned DEFAULT 0, |
330 | 330 | PRIMARY KEY (PRC_ID)"; |
331 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
332 | - $table_name = "esp_price_type"; |
|
333 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
331 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
332 | + $table_name = "esp_price_type"; |
|
333 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
334 | 334 | PRT_name varchar(45) NOT NULL, |
335 | 335 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
336 | 336 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
339 | 339 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
340 | 340 | PRIMARY KEY (PRT_ID)"; |
341 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | - $table_name = 'esp_question'; |
|
343 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
341 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | + $table_name = 'esp_question'; |
|
343 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
344 | 344 | QST_display_text text NOT NULL, |
345 | 345 | QST_admin_label varchar(255) NOT NULL, |
346 | 346 | QST_system varchar(25) DEFAULT NULL, |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | QST_wp_user bigint(20) unsigned NULL, |
353 | 353 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
354 | 354 | PRIMARY KEY (QST_ID)'; |
355 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
356 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
357 | - $table_name = 'esp_question_group'; |
|
358 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
355 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
356 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
357 | + $table_name = 'esp_question_group'; |
|
358 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
359 | 359 | QSG_name varchar(255) NOT NULL, |
360 | 360 | QSG_identifier varchar(100) NOT NULL, |
361 | 361 | QSG_desc text NULL, |
@@ -366,23 +366,23 @@ discard block |
||
366 | 366 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
367 | 367 | PRIMARY KEY (QSG_ID), |
368 | 368 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
369 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
370 | - $table_name = 'esp_question_group_question'; |
|
371 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
369 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
370 | + $table_name = 'esp_question_group_question'; |
|
371 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
372 | 372 | QSG_ID int(10) unsigned NOT NULL, |
373 | 373 | QST_ID int(10) unsigned NOT NULL, |
374 | 374 | PRIMARY KEY (QGQ_ID) "; |
375 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | - $table_name = 'esp_question_option'; |
|
377 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | + $table_name = 'esp_question_option'; |
|
377 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
378 | 378 | QSO_value varchar(255) NOT NULL, |
379 | 379 | QSO_desc text NOT NULL, |
380 | 380 | QST_ID int(10) unsigned NOT NULL, |
381 | 381 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
382 | 382 | PRIMARY KEY (QSO_ID)"; |
383 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | - $table_name = 'esp_registration'; |
|
385 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
383 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $table_name = 'esp_registration'; |
|
385 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
386 | 386 | EVT_ID bigint(20) unsigned NOT NULL, |
387 | 387 | ATT_ID bigint(20) unsigned NOT NULL, |
388 | 388 | TXN_ID int(10) unsigned NOT NULL, |
@@ -405,25 +405,25 @@ discard block |
||
405 | 405 | KEY STS_ID (STS_ID), |
406 | 406 | KEY REG_url_link (REG_url_link), |
407 | 407 | KEY REG_code (REG_code)"; |
408 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
409 | - $table_name = 'esp_checkin'; |
|
410 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
408 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
409 | + $table_name = 'esp_checkin'; |
|
410 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
411 | 411 | REG_ID int(10) unsigned NOT NULL, |
412 | 412 | DTT_ID int(10) unsigned NOT NULL, |
413 | 413 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
414 | 414 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
415 | 415 | PRIMARY KEY (CHK_ID)"; |
416 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | - $table_name = 'esp_state'; |
|
418 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | + $table_name = 'esp_state'; |
|
418 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
419 | 419 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
420 | 420 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
421 | 421 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
422 | 422 | STA_active tinyint(1) DEFAULT '1', |
423 | 423 | PRIMARY KEY (STA_ID)"; |
424 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | - $table_name = 'esp_status'; |
|
426 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
424 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | + $table_name = 'esp_status'; |
|
426 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
427 | 427 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
428 | 428 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
429 | 429 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
432 | 432 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
433 | 433 | KEY STS_type (STS_type)"; |
434 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
435 | - $table_name = 'esp_transaction'; |
|
436 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
434 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
435 | + $table_name = 'esp_transaction'; |
|
436 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
437 | 437 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
438 | 438 | TXN_total decimal(10,3) DEFAULT '0.00', |
439 | 439 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -443,9 +443,9 @@ discard block |
||
443 | 443 | PRIMARY KEY (TXN_ID), |
444 | 444 | KEY TXN_timestamp (TXN_timestamp), |
445 | 445 | KEY STS_ID (STS_ID)"; |
446 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
447 | - $table_name = 'esp_venue_meta'; |
|
448 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
446 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
447 | + $table_name = 'esp_venue_meta'; |
|
448 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
449 | 449 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
450 | 450 | VNU_address varchar(255) DEFAULT NULL, |
451 | 451 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -463,52 +463,52 @@ discard block |
||
463 | 463 | PRIMARY KEY (VNUM_ID), |
464 | 464 | KEY STA_ID (STA_ID), |
465 | 465 | KEY CNT_ISO (CNT_ISO)"; |
466 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | - // setting up the default stats and countries is also essential for the data migrations to run |
|
468 | - // (because many need to convert old string states to foreign keys into the states table) |
|
469 | - $this->insert_default_states(); |
|
470 | - $this->insert_default_countries(); |
|
471 | - // setting up default prices, price types, and tickets is also essential for the price migrations |
|
472 | - $this->insert_default_price_types(); |
|
473 | - $this->insert_default_prices(); |
|
474 | - $this->insert_default_tickets(); |
|
475 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
476 | - EE_Config::instance()->update_espresso_config(false, true); |
|
477 | - return true; |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * Yes we could have cleaned up the ee3 tables here. But just in case someone |
|
484 | - * didn't backup their DB, and decides they want ot keep using EE3, we'll |
|
485 | - * leave them for now. Mayeb remove them in 4.5 or something. |
|
486 | - * |
|
487 | - * @return boolean |
|
488 | - */ |
|
489 | - public function schema_changes_after_migration() |
|
490 | - { |
|
491 | - return true; |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * insert_default_states |
|
498 | - * |
|
499 | - * @access public |
|
500 | - * @static |
|
501 | - * @return void |
|
502 | - */ |
|
503 | - public function insert_default_states() |
|
504 | - { |
|
505 | - global $wpdb; |
|
506 | - $state_table = $wpdb->prefix . "esp_state"; |
|
507 | - if ($this->_get_table_analysis()->tableExists($state_table)) { |
|
508 | - $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
509 | - $states = $wpdb->get_var($SQL); |
|
510 | - if (! $states) { |
|
511 | - $SQL = "INSERT INTO " . $state_table . " |
|
466 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | + // setting up the default stats and countries is also essential for the data migrations to run |
|
468 | + // (because many need to convert old string states to foreign keys into the states table) |
|
469 | + $this->insert_default_states(); |
|
470 | + $this->insert_default_countries(); |
|
471 | + // setting up default prices, price types, and tickets is also essential for the price migrations |
|
472 | + $this->insert_default_price_types(); |
|
473 | + $this->insert_default_prices(); |
|
474 | + $this->insert_default_tickets(); |
|
475 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
476 | + EE_Config::instance()->update_espresso_config(false, true); |
|
477 | + return true; |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * Yes we could have cleaned up the ee3 tables here. But just in case someone |
|
484 | + * didn't backup their DB, and decides they want ot keep using EE3, we'll |
|
485 | + * leave them for now. Mayeb remove them in 4.5 or something. |
|
486 | + * |
|
487 | + * @return boolean |
|
488 | + */ |
|
489 | + public function schema_changes_after_migration() |
|
490 | + { |
|
491 | + return true; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * insert_default_states |
|
498 | + * |
|
499 | + * @access public |
|
500 | + * @static |
|
501 | + * @return void |
|
502 | + */ |
|
503 | + public function insert_default_states() |
|
504 | + { |
|
505 | + global $wpdb; |
|
506 | + $state_table = $wpdb->prefix . "esp_state"; |
|
507 | + if ($this->_get_table_analysis()->tableExists($state_table)) { |
|
508 | + $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
509 | + $states = $wpdb->get_var($SQL); |
|
510 | + if (! $states) { |
|
511 | + $SQL = "INSERT INTO " . $state_table . " |
|
512 | 512 | (STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES |
513 | 513 | (1, 'US', 'AK', 'Alaska', 1), |
514 | 514 | (2, 'US', 'AL', 'Alabama', 1), |
@@ -582,29 +582,29 @@ discard block |
||
582 | 582 | (70, 'CA', 'NT', 'Northwest Territories', 1), |
583 | 583 | (71, 'CA', 'NU', 'Nunavut', 1), |
584 | 584 | (72, 'CA', 'YT', 'Yukon', 1);"; |
585 | - $wpdb->query($SQL); |
|
586 | - } |
|
587 | - } |
|
588 | - } |
|
589 | - |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * insert_default_countries |
|
594 | - * |
|
595 | - * @access public |
|
596 | - * @static |
|
597 | - * @return void |
|
598 | - */ |
|
599 | - public function insert_default_countries() |
|
600 | - { |
|
601 | - global $wpdb; |
|
602 | - $country_table = $wpdb->prefix . "esp_country"; |
|
603 | - if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
604 | - $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
605 | - $countries = $wpdb->get_var($SQL); |
|
606 | - if (! $countries) { |
|
607 | - $SQL = "INSERT INTO " . $country_table . " |
|
585 | + $wpdb->query($SQL); |
|
586 | + } |
|
587 | + } |
|
588 | + } |
|
589 | + |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * insert_default_countries |
|
594 | + * |
|
595 | + * @access public |
|
596 | + * @static |
|
597 | + * @return void |
|
598 | + */ |
|
599 | + public function insert_default_countries() |
|
600 | + { |
|
601 | + global $wpdb; |
|
602 | + $country_table = $wpdb->prefix . "esp_country"; |
|
603 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
604 | + $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
605 | + $countries = $wpdb->get_var($SQL); |
|
606 | + if (! $countries) { |
|
607 | + $SQL = "INSERT INTO " . $country_table . " |
|
608 | 608 | (CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES |
609 | 609 | ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
610 | 610 | ('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0), |
@@ -832,984 +832,984 @@ discard block |
||
832 | 832 | ('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0), |
833 | 833 | ('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0), |
834 | 834 | ('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);"; |
835 | - $wpdb->query($SQL); |
|
836 | - } |
|
837 | - } |
|
838 | - } |
|
839 | - |
|
840 | - |
|
841 | - |
|
842 | - /** |
|
843 | - * insert_default_price_types |
|
844 | - * |
|
845 | - * @access public |
|
846 | - * @static |
|
847 | - * @return void |
|
848 | - */ |
|
849 | - public function insert_default_price_types() |
|
850 | - { |
|
851 | - global $wpdb; |
|
852 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
853 | - if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
854 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
855 | - $price_types_exist = $wpdb->get_var($SQL); |
|
856 | - if (! $price_types_exist) { |
|
857 | - $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
|
835 | + $wpdb->query($SQL); |
|
836 | + } |
|
837 | + } |
|
838 | + } |
|
839 | + |
|
840 | + |
|
841 | + |
|
842 | + /** |
|
843 | + * insert_default_price_types |
|
844 | + * |
|
845 | + * @access public |
|
846 | + * @static |
|
847 | + * @return void |
|
848 | + */ |
|
849 | + public function insert_default_price_types() |
|
850 | + { |
|
851 | + global $wpdb; |
|
852 | + $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
853 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
854 | + $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
855 | + $price_types_exist = $wpdb->get_var($SQL); |
|
856 | + if (! $price_types_exist) { |
|
857 | + $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
|
858 | 858 | (1, '" . esc_html__('Base Price', 'event_espresso') . "', 1, 0, 0, 0), |
859 | 859 | (2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2, 1, 20, 0), |
860 | 860 | (3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2, 0, 30, 0), |
861 | 861 | (4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, 0), |
862 | 862 | (5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3, 0, 50, 0);"; |
863 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
864 | - $wpdb->query($SQL); |
|
865 | - } |
|
866 | - } |
|
867 | - } |
|
868 | - |
|
869 | - |
|
870 | - |
|
871 | - /** |
|
872 | - * insert_default_prices. We assume we're upgrading to regular here. |
|
873 | - * If we're INSTALLING 4.1 CAF, then we add a few extra default prices |
|
874 | - * when EEH_Activaion's initialize_db_content is called via ahook in |
|
875 | - * EE_BRewing_regular |
|
876 | - * |
|
877 | - * @access public |
|
878 | - * @static |
|
879 | - * @return void |
|
880 | - */ |
|
881 | - public function insert_default_prices() |
|
882 | - { |
|
883 | - global $wpdb; |
|
884 | - $price_table = $wpdb->prefix . "esp_price"; |
|
885 | - if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
886 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
887 | - $prices_exist = $wpdb->get_var($SQL); |
|
888 | - if (! $prices_exist) { |
|
889 | - $SQL = "INSERT INTO $price_table |
|
863 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
864 | + $wpdb->query($SQL); |
|
865 | + } |
|
866 | + } |
|
867 | + } |
|
868 | + |
|
869 | + |
|
870 | + |
|
871 | + /** |
|
872 | + * insert_default_prices. We assume we're upgrading to regular here. |
|
873 | + * If we're INSTALLING 4.1 CAF, then we add a few extra default prices |
|
874 | + * when EEH_Activaion's initialize_db_content is called via ahook in |
|
875 | + * EE_BRewing_regular |
|
876 | + * |
|
877 | + * @access public |
|
878 | + * @static |
|
879 | + * @return void |
|
880 | + */ |
|
881 | + public function insert_default_prices() |
|
882 | + { |
|
883 | + global $wpdb; |
|
884 | + $price_table = $wpdb->prefix . "esp_price"; |
|
885 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
886 | + $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
887 | + $prices_exist = $wpdb->get_var($SQL); |
|
888 | + if (! $prices_exist) { |
|
889 | + $SQL = "INSERT INTO $price_table |
|
890 | 890 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES |
891 | 891 | (1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);"; |
892 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
893 | - $wpdb->query($SQL); |
|
894 | - } |
|
895 | - } |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - |
|
900 | - /** |
|
901 | - * insert default ticket |
|
902 | - * |
|
903 | - * @access public |
|
904 | - * @static |
|
905 | - * @return void |
|
906 | - */ |
|
907 | - public function insert_default_tickets() |
|
908 | - { |
|
909 | - global $wpdb; |
|
910 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
911 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
912 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
913 | - $tickets_exist = $wpdb->get_var($SQL); |
|
914 | - if (! $tickets_exist) { |
|
915 | - $SQL = "INSERT INTO $ticket_table |
|
892 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
893 | + $wpdb->query($SQL); |
|
894 | + } |
|
895 | + } |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + |
|
900 | + /** |
|
901 | + * insert default ticket |
|
902 | + * |
|
903 | + * @access public |
|
904 | + * @static |
|
905 | + * @return void |
|
906 | + */ |
|
907 | + public function insert_default_tickets() |
|
908 | + { |
|
909 | + global $wpdb; |
|
910 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
911 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
912 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
913 | + $tickets_exist = $wpdb->get_var($SQL); |
|
914 | + if (! $tickets_exist) { |
|
915 | + $SQL = "INSERT INTO $ticket_table |
|
916 | 916 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
917 | 917 | ( 1, 0, '" |
918 | - . esc_html__("Free Ticket", "event_espresso") |
|
919 | - . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
920 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
921 | - $wpdb->query($SQL); |
|
922 | - } |
|
923 | - } |
|
924 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
925 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
926 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
927 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
928 | - if (! $ticket_prc_exist) { |
|
929 | - $SQL = "INSERT INTO $ticket_price_table |
|
918 | + . esc_html__("Free Ticket", "event_espresso") |
|
919 | + . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
920 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
921 | + $wpdb->query($SQL); |
|
922 | + } |
|
923 | + } |
|
924 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
925 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
926 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
927 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
928 | + if (! $ticket_prc_exist) { |
|
929 | + $SQL = "INSERT INTO $ticket_price_table |
|
930 | 930 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
931 | 931 | ( 1, 1, 1 ) |
932 | 932 | "; |
933 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
934 | - $wpdb->query($SQL); |
|
935 | - } |
|
936 | - } |
|
937 | - } |
|
938 | - |
|
939 | - |
|
940 | - |
|
941 | - /** |
|
942 | - * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(), |
|
943 | - * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1 |
|
944 | - * country ID (int), a 2-letter ISO, 3-letter ISO, or name |
|
945 | - * |
|
946 | - * @global type $wpdb |
|
947 | - * @param string $country_name |
|
948 | - * @return array where keys are columns, values are column values |
|
949 | - */ |
|
950 | - public function get_or_create_country($country_name) |
|
951 | - { |
|
952 | - if (! $country_name) { |
|
953 | - throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso")); |
|
954 | - } |
|
955 | - global $wpdb; |
|
956 | - $country_table = $wpdb->prefix . "esp_country"; |
|
957 | - if (is_int($country_name)) { |
|
958 | - $country_name = $this->get_iso_from_3_1_country_id($country_name); |
|
959 | - } |
|
960 | - $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
|
933 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
934 | + $wpdb->query($SQL); |
|
935 | + } |
|
936 | + } |
|
937 | + } |
|
938 | + |
|
939 | + |
|
940 | + |
|
941 | + /** |
|
942 | + * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(), |
|
943 | + * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1 |
|
944 | + * country ID (int), a 2-letter ISO, 3-letter ISO, or name |
|
945 | + * |
|
946 | + * @global type $wpdb |
|
947 | + * @param string $country_name |
|
948 | + * @return array where keys are columns, values are column values |
|
949 | + */ |
|
950 | + public function get_or_create_country($country_name) |
|
951 | + { |
|
952 | + if (! $country_name) { |
|
953 | + throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso")); |
|
954 | + } |
|
955 | + global $wpdb; |
|
956 | + $country_table = $wpdb->prefix . "esp_country"; |
|
957 | + if (is_int($country_name)) { |
|
958 | + $country_name = $this->get_iso_from_3_1_country_id($country_name); |
|
959 | + } |
|
960 | + $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
|
961 | 961 | CNT_ISO LIKE %s OR |
962 | 962 | CNT_ISO3 LIKE %s OR |
963 | 963 | CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A); |
964 | - if (! $country) { |
|
965 | - // insert a new one then |
|
966 | - $cols_n_values = array( |
|
967 | - 'CNT_ISO' => $this->_find_available_country_iso(2), |
|
968 | - 'CNT_ISO3' => $this->_find_available_country_iso(3), |
|
969 | - 'RGN_ID' => 0, |
|
970 | - 'CNT_name' => $country_name, |
|
971 | - 'CNT_cur_code' => 'USD', |
|
972 | - 'CNT_cur_single' => 'Dollar', |
|
973 | - 'CNT_cur_plural' => 'Dollars', |
|
974 | - 'CNT_cur_sign' => '$', |
|
975 | - 'CNT_cur_sign_b4' => true, |
|
976 | - 'CNT_cur_dec_plc' => 2, |
|
977 | - 'CNT_cur_dec_mrk' => '.', |
|
978 | - 'CNT_cur_thsnds' => ',', |
|
979 | - 'CNT_tel_code' => '+1', |
|
980 | - 'CNT_is_EU' => false, |
|
981 | - 'CNT_active' => true, |
|
982 | - ); |
|
983 | - $data_types = array( |
|
984 | - '%s',// CNT_ISO |
|
985 | - '%s',// CNT_ISO3 |
|
986 | - '%d',// RGN_ID |
|
987 | - '%s',// CNT_name |
|
988 | - '%s',// CNT_cur_code |
|
989 | - '%s',// CNT_cur_single |
|
990 | - '%s',// CNT_cur_plural |
|
991 | - '%s',// CNT_cur_sign |
|
992 | - '%d',// CNT_cur_sign_b4 |
|
993 | - '%d',// CNT_cur_dec_plc |
|
994 | - '%s',// CNT_cur_dec_mrk |
|
995 | - '%s',// CNT_cur_thsnds |
|
996 | - '%s',// CNT_tel_code |
|
997 | - '%d',// CNT_is_EU |
|
998 | - '%d',// CNT_active |
|
999 | - ); |
|
1000 | - $success = $wpdb->insert( |
|
1001 | - $country_table, |
|
1002 | - $cols_n_values, |
|
1003 | - $data_types |
|
1004 | - ); |
|
1005 | - if (! $success) { |
|
1006 | - throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1007 | - 'N/A', |
|
1008 | - array('country_id' => $country_name), |
|
1009 | - $country_table, |
|
1010 | - $cols_n_values, |
|
1011 | - $data_types |
|
1012 | - )); |
|
1013 | - } |
|
1014 | - $country = $cols_n_values; |
|
1015 | - } |
|
1016 | - return $country; |
|
1017 | - } |
|
1018 | - |
|
1019 | - |
|
1020 | - |
|
1021 | - /** |
|
1022 | - * finds a country iso which hasnt been used yet |
|
1023 | - * |
|
1024 | - * @global type $wpdb |
|
1025 | - * @return string |
|
1026 | - */ |
|
1027 | - private function _find_available_country_iso($num_letters = 2) |
|
1028 | - { |
|
1029 | - global $wpdb; |
|
1030 | - $country_table = $wpdb->prefix . "esp_country"; |
|
1031 | - $attempts = 0; |
|
1032 | - do { |
|
1033 | - $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
|
1034 | - $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM " |
|
1035 | - . $country_table |
|
1036 | - . " WHERE CNT_ISO=%s", $current_iso)); |
|
1037 | - $attempts++; |
|
1038 | - // keep going until we find an available country code, or we arbitrarily |
|
1039 | - // decide we've tried this enough. Somehow they have way too many countries |
|
1040 | - // (probably because they're mis-using the EE3 country_id like a custom question) |
|
1041 | - } while (intval($country_with_that_iso) && $attempts < 200); |
|
1042 | - return $current_iso; |
|
1043 | - } |
|
1044 | - |
|
1045 | - |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but |
|
1049 | - * is independent of outside code which can change in future versions of EE |
|
1050 | - * |
|
1051 | - * @global type $wpdb |
|
1052 | - * @param string $state_name |
|
1053 | - * @return array where keys are columns, values are column values |
|
1054 | - */ |
|
1055 | - public function get_or_create_state($state_name, $country_name = '') |
|
1056 | - { |
|
1057 | - if (! $state_name) { |
|
1058 | - throw new EE_Error(esc_html__( |
|
1059 | - "Could not get-or-create state because no state name was provided", |
|
1060 | - "event_espresso" |
|
1061 | - )); |
|
1062 | - } |
|
1063 | - try { |
|
1064 | - $country = $this->get_or_create_country($country_name); |
|
1065 | - $country_iso = $country['CNT_ISO']; |
|
1066 | - } catch (EE_Error $e) { |
|
1067 | - $country_iso = $this->get_default_country_iso(); |
|
1068 | - } |
|
1069 | - global $wpdb; |
|
1070 | - $state_table = $wpdb->prefix . "esp_state"; |
|
1071 | - $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
|
964 | + if (! $country) { |
|
965 | + // insert a new one then |
|
966 | + $cols_n_values = array( |
|
967 | + 'CNT_ISO' => $this->_find_available_country_iso(2), |
|
968 | + 'CNT_ISO3' => $this->_find_available_country_iso(3), |
|
969 | + 'RGN_ID' => 0, |
|
970 | + 'CNT_name' => $country_name, |
|
971 | + 'CNT_cur_code' => 'USD', |
|
972 | + 'CNT_cur_single' => 'Dollar', |
|
973 | + 'CNT_cur_plural' => 'Dollars', |
|
974 | + 'CNT_cur_sign' => '$', |
|
975 | + 'CNT_cur_sign_b4' => true, |
|
976 | + 'CNT_cur_dec_plc' => 2, |
|
977 | + 'CNT_cur_dec_mrk' => '.', |
|
978 | + 'CNT_cur_thsnds' => ',', |
|
979 | + 'CNT_tel_code' => '+1', |
|
980 | + 'CNT_is_EU' => false, |
|
981 | + 'CNT_active' => true, |
|
982 | + ); |
|
983 | + $data_types = array( |
|
984 | + '%s',// CNT_ISO |
|
985 | + '%s',// CNT_ISO3 |
|
986 | + '%d',// RGN_ID |
|
987 | + '%s',// CNT_name |
|
988 | + '%s',// CNT_cur_code |
|
989 | + '%s',// CNT_cur_single |
|
990 | + '%s',// CNT_cur_plural |
|
991 | + '%s',// CNT_cur_sign |
|
992 | + '%d',// CNT_cur_sign_b4 |
|
993 | + '%d',// CNT_cur_dec_plc |
|
994 | + '%s',// CNT_cur_dec_mrk |
|
995 | + '%s',// CNT_cur_thsnds |
|
996 | + '%s',// CNT_tel_code |
|
997 | + '%d',// CNT_is_EU |
|
998 | + '%d',// CNT_active |
|
999 | + ); |
|
1000 | + $success = $wpdb->insert( |
|
1001 | + $country_table, |
|
1002 | + $cols_n_values, |
|
1003 | + $data_types |
|
1004 | + ); |
|
1005 | + if (! $success) { |
|
1006 | + throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1007 | + 'N/A', |
|
1008 | + array('country_id' => $country_name), |
|
1009 | + $country_table, |
|
1010 | + $cols_n_values, |
|
1011 | + $data_types |
|
1012 | + )); |
|
1013 | + } |
|
1014 | + $country = $cols_n_values; |
|
1015 | + } |
|
1016 | + return $country; |
|
1017 | + } |
|
1018 | + |
|
1019 | + |
|
1020 | + |
|
1021 | + /** |
|
1022 | + * finds a country iso which hasnt been used yet |
|
1023 | + * |
|
1024 | + * @global type $wpdb |
|
1025 | + * @return string |
|
1026 | + */ |
|
1027 | + private function _find_available_country_iso($num_letters = 2) |
|
1028 | + { |
|
1029 | + global $wpdb; |
|
1030 | + $country_table = $wpdb->prefix . "esp_country"; |
|
1031 | + $attempts = 0; |
|
1032 | + do { |
|
1033 | + $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
|
1034 | + $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM " |
|
1035 | + . $country_table |
|
1036 | + . " WHERE CNT_ISO=%s", $current_iso)); |
|
1037 | + $attempts++; |
|
1038 | + // keep going until we find an available country code, or we arbitrarily |
|
1039 | + // decide we've tried this enough. Somehow they have way too many countries |
|
1040 | + // (probably because they're mis-using the EE3 country_id like a custom question) |
|
1041 | + } while (intval($country_with_that_iso) && $attempts < 200); |
|
1042 | + return $current_iso; |
|
1043 | + } |
|
1044 | + |
|
1045 | + |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but |
|
1049 | + * is independent of outside code which can change in future versions of EE |
|
1050 | + * |
|
1051 | + * @global type $wpdb |
|
1052 | + * @param string $state_name |
|
1053 | + * @return array where keys are columns, values are column values |
|
1054 | + */ |
|
1055 | + public function get_or_create_state($state_name, $country_name = '') |
|
1056 | + { |
|
1057 | + if (! $state_name) { |
|
1058 | + throw new EE_Error(esc_html__( |
|
1059 | + "Could not get-or-create state because no state name was provided", |
|
1060 | + "event_espresso" |
|
1061 | + )); |
|
1062 | + } |
|
1063 | + try { |
|
1064 | + $country = $this->get_or_create_country($country_name); |
|
1065 | + $country_iso = $country['CNT_ISO']; |
|
1066 | + } catch (EE_Error $e) { |
|
1067 | + $country_iso = $this->get_default_country_iso(); |
|
1068 | + } |
|
1069 | + global $wpdb; |
|
1070 | + $state_table = $wpdb->prefix . "esp_state"; |
|
1071 | + $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
|
1072 | 1072 | (STA_abbrev LIKE %s OR |
1073 | 1073 | STA_name LIKE %s) AND |
1074 | 1074 | CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A); |
1075 | - if (! $state) { |
|
1076 | - // insert a new one then |
|
1077 | - $cols_n_values = array( |
|
1078 | - 'CNT_ISO' => $country_iso, |
|
1079 | - 'STA_abbrev' => substr($state_name, 0, 6), |
|
1080 | - 'STA_name' => $state_name, |
|
1081 | - 'STA_active' => true, |
|
1082 | - ); |
|
1083 | - $data_types = array( |
|
1084 | - '%s',// CNT_ISO |
|
1085 | - '%s',// STA_abbrev |
|
1086 | - '%s',// STA_name |
|
1087 | - '%d',// STA_active |
|
1088 | - ); |
|
1089 | - $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1090 | - if (! $success) { |
|
1091 | - throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1092 | - 'N/A', |
|
1093 | - array('state' => $state_name, 'country_id' => $country_name), |
|
1094 | - $state_table, |
|
1095 | - $cols_n_values, |
|
1096 | - $data_types |
|
1097 | - )); |
|
1098 | - } |
|
1099 | - $state = $cols_n_values; |
|
1100 | - $state['STA_ID'] = $wpdb->insert_id; |
|
1101 | - } |
|
1102 | - return $state; |
|
1103 | - } |
|
1104 | - |
|
1105 | - |
|
1106 | - |
|
1107 | - /** |
|
1108 | - * Fixes times like "5:00 PM" into the expected 24-hour format "17:00". |
|
1109 | - * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing |
|
1110 | - * |
|
1111 | - * @param type $timeString |
|
1112 | - * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes |
|
1113 | - * with leading zeros) |
|
1114 | - */ |
|
1115 | - public function convertTimeFromAMPM($timeString) |
|
1116 | - { |
|
1117 | - $matches = array(); |
|
1118 | - preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1119 | - if (! $matches || count($matches) < 3) { |
|
1120 | - $hour = '00'; |
|
1121 | - $minutes = '00'; |
|
1122 | - } else { |
|
1123 | - $hour = intval($matches[1]); |
|
1124 | - $minutes = $matches[2]; |
|
1125 | - } |
|
1126 | - if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1127 | - $hour = intval($hour) + 12; |
|
1128 | - } |
|
1129 | - $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1130 | - $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1131 | - return "$hour:$minutes"; |
|
1132 | - } |
|
1133 | - |
|
1134 | - |
|
1135 | - |
|
1136 | - /** |
|
1137 | - * Gets the ISO3 fora country given its 3.1 country ID. |
|
1138 | - * |
|
1139 | - * @param int $country_id |
|
1140 | - * @return string the country's ISO3 code |
|
1141 | - */ |
|
1142 | - public function get_iso_from_3_1_country_id($country_id) |
|
1143 | - { |
|
1144 | - $old_countries = array( |
|
1145 | - array(64, 'United States', 'US', 'USA', 1), |
|
1146 | - array(15, 'Australia', 'AU', 'AUS', 1), |
|
1147 | - array(39, 'Canada', 'CA', 'CAN', 1), |
|
1148 | - array(171, 'United Kingdom', 'GB', 'GBR', 1), |
|
1149 | - array(70, 'France', 'FR', 'FRA', 2), |
|
1150 | - array(111, 'Italy', 'IT', 'ITA', 2), |
|
1151 | - array(63, 'Spain', 'ES', 'ESP', 2), |
|
1152 | - array(1, 'Afghanistan', 'AF', 'AFG', 1), |
|
1153 | - array(2, 'Albania', 'AL', 'ALB', 1), |
|
1154 | - array(3, 'Germany', 'DE', 'DEU', 2), |
|
1155 | - array(198, 'Switzerland', 'CH', 'CHE', 1), |
|
1156 | - array(87, 'Netherlands', 'NL', 'NLD', 2), |
|
1157 | - array(197, 'Sweden', 'SE', 'SWE', 1), |
|
1158 | - array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2), |
|
1159 | - array(4, 'Andorra', 'AD', 'AND', 2), |
|
1160 | - array(5, 'Angola', 'AO', 'AGO', 1), |
|
1161 | - array(6, 'Anguilla', 'AI', 'AIA', 1), |
|
1162 | - array(7, 'Antarctica', 'AQ', 'ATA', 1), |
|
1163 | - array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1), |
|
1164 | - array(10, 'Saudi Arabia', 'SA', 'SAU', 1), |
|
1165 | - array(11, 'Algeria', 'DZ', 'DZA', 1), |
|
1166 | - array(12, 'Argentina', 'AR', 'ARG', 1), |
|
1167 | - array(13, 'Armenia', 'AM', 'ARM', 1), |
|
1168 | - array(14, 'Aruba', 'AW', 'ABW', 1), |
|
1169 | - array(16, 'Austria', 'AT', 'AUT', 2), |
|
1170 | - array(17, 'Azerbaijan', 'AZ', 'AZE', 1), |
|
1171 | - array(18, 'Bahamas', 'BS', 'BHS', 1), |
|
1172 | - array(19, 'Bahrain', 'BH', 'BHR', 1), |
|
1173 | - array(20, 'Bangladesh', 'BD', 'BGD', 1), |
|
1174 | - array(21, 'Barbados', 'BB', 'BRB', 1), |
|
1175 | - array(22, 'Belgium ', 'BE', 'BEL', 2), |
|
1176 | - array(23, 'Belize', 'BZ', 'BLZ', 1), |
|
1177 | - array(24, 'Benin', 'BJ', 'BEN', 1), |
|
1178 | - array(25, 'Bermudas', 'BM', 'BMU', 1), |
|
1179 | - array(26, 'Belarus', 'BY', 'BLR', 1), |
|
1180 | - array(27, 'Bolivia', 'BO', 'BOL', 1), |
|
1181 | - array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1), |
|
1182 | - array(29, 'Botswana', 'BW', 'BWA', 1), |
|
1183 | - array(96, 'Bouvet Island', 'BV', 'BVT', 1), |
|
1184 | - array(30, 'Brazil', 'BR', 'BRA', 1), |
|
1185 | - array(31, 'Brunei', 'BN', 'BRN', 1), |
|
1186 | - array(32, 'Bulgaria', 'BG', 'BGR', 1), |
|
1187 | - array(33, 'Burkina Faso', 'BF', 'BFA', 1), |
|
1188 | - array(34, 'Burundi', 'BI', 'BDI', 1), |
|
1189 | - array(35, 'Bhutan', 'BT', 'BTN', 1), |
|
1190 | - array(36, 'Cape Verde', 'CV', 'CPV', 1), |
|
1191 | - array(37, 'Cambodia', 'KH', 'KHM', 1), |
|
1192 | - array(38, 'Cameroon', 'CM', 'CMR', 1), |
|
1193 | - array(98, 'Cayman Islands', 'KY', 'CYM', 1), |
|
1194 | - array(172, 'Central African Republic', 'CF', 'CAF', 1), |
|
1195 | - array(40, 'Chad', 'TD', 'TCD', 1), |
|
1196 | - array(41, 'Chile', 'CL', 'CHL', 1), |
|
1197 | - array(42, 'China', 'CN', 'CHN', 1), |
|
1198 | - array(105, 'Christmas Island', 'CX', 'CXR', 1), |
|
1199 | - array(43, 'Cyprus', 'CY', 'CYP', 2), |
|
1200 | - array(99, 'Cocos Island', 'CC', 'CCK', 1), |
|
1201 | - array(100, 'Cook Islands', 'CK', 'COK', 1), |
|
1202 | - array(44, 'Colombia', 'CO', 'COL', 1), |
|
1203 | - array(45, 'Comoros', 'KM', 'COM', 1), |
|
1204 | - array(46, 'Congo', 'CG', 'COG', 1), |
|
1205 | - array(47, 'North Korea', 'KP', 'PRK', 1), |
|
1206 | - array(50, 'Costa Rica', 'CR', 'CRI', 1), |
|
1207 | - array(51, 'Croatia', 'HR', 'HRV', 1), |
|
1208 | - array(52, 'Cuba', 'CU', 'CUB', 1), |
|
1209 | - array(173, 'Czech Republic', 'CZ', 'CZE', 1), |
|
1210 | - array(53, 'Denmark', 'DK', 'DNK', 1), |
|
1211 | - array(54, 'Djibouti', 'DJ', 'DJI', 1), |
|
1212 | - array(55, 'Dominica', 'DM', 'DMA', 1), |
|
1213 | - array(174, 'Dominican Republic', 'DO', 'DOM', 1), |
|
1214 | - array(56, 'Ecuador', 'EC', 'ECU', 1), |
|
1215 | - array(57, 'Egypt', 'EG', 'EGY', 1), |
|
1216 | - array(58, 'El Salvador', 'SV', 'SLV', 1), |
|
1217 | - array(60, 'Eritrea', 'ER', 'ERI', 1), |
|
1218 | - array(61, 'Slovakia', 'SK', 'SVK', 2), |
|
1219 | - array(62, 'Slovenia', 'SI', 'SVN', 2), |
|
1220 | - array(65, 'Estonia', 'EE', 'EST', 2), |
|
1221 | - array(66, 'Ethiopia', 'ET', 'ETH', 1), |
|
1222 | - array(102, 'Faroe islands', 'FO', 'FRO', 1), |
|
1223 | - array(103, 'Falkland Islands', 'FK', 'FLK', 1), |
|
1224 | - array(67, 'Fiji', 'FJ', 'FJI', 1), |
|
1225 | - array(69, 'Finland', 'FI', 'FIN', 2), |
|
1226 | - array(71, 'Gabon', 'GA', 'GAB', 1), |
|
1227 | - array(72, 'Gambia', 'GM', 'GMB', 1), |
|
1228 | - array(73, 'Georgia', 'GE', 'GEO', 1), |
|
1229 | - array(74, 'Ghana', 'GH', 'GHA', 1), |
|
1230 | - array(75, 'Gibraltar', 'GI', 'GIB', 1), |
|
1231 | - array(76, 'Greece', 'GR', 'GRC', 2), |
|
1232 | - array(77, 'Grenada', 'GD', 'GRD', 1), |
|
1233 | - array(78, 'Greenland', 'GL', 'GRL', 1), |
|
1234 | - array(79, 'Guadeloupe', 'GP', 'GLP', 1), |
|
1235 | - array(80, 'Guam', 'GU', 'GUM', 1), |
|
1236 | - array(81, 'Guatemala', 'GT', 'GTM', 1), |
|
1237 | - array(82, 'Guinea', 'GN', 'GIN', 1), |
|
1238 | - array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1), |
|
1239 | - array(84, 'Guinea-Bissau', 'GW', 'GNB', 1), |
|
1240 | - array(85, 'Guyana', 'GY', 'GUY', 1), |
|
1241 | - array(86, 'Haiti', 'HT', 'HTI', 1), |
|
1242 | - array(88, 'Honduras', 'HN', 'HND', 1), |
|
1243 | - array(89, 'Hong Kong', 'HK', 'HKG', 1), |
|
1244 | - array(90, 'Hungary', 'HU', 'HUN', 1), |
|
1245 | - array(91, 'India', 'IN', 'IND', 1), |
|
1246 | - array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1), |
|
1247 | - array(92, 'Indonesia', 'ID', 'IDN', 1), |
|
1248 | - array(93, 'Iraq', 'IQ', 'IRQ', 1), |
|
1249 | - array(94, 'Iran', 'IR', 'IRN', 1), |
|
1250 | - array(95, 'Ireland', 'IE', 'IRL', 2), |
|
1251 | - array(97, 'Iceland', 'IS', 'ISL', 1), |
|
1252 | - array(110, 'Israel', 'IL', 'ISR', 1), |
|
1253 | - array(49, 'Ivory Coast ', 'CI', 'CIV', 1), |
|
1254 | - array(112, 'Jamaica', 'JM', 'JAM', 1), |
|
1255 | - array(113, 'Japan', 'JP', 'JPN', 1), |
|
1256 | - array(114, 'Jordan', 'JO', 'JOR', 1), |
|
1257 | - array(115, 'Kazakhstan', 'KZ', 'KAZ', 1), |
|
1258 | - array(116, 'Kenya', 'KE', 'KEN', 1), |
|
1259 | - array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1), |
|
1260 | - array(118, 'Kiribati', 'KI', 'KIR', 1), |
|
1261 | - array(48, 'South Korea', 'KR', 'KOR', 1), |
|
1262 | - array(228, 'Kosovo', 'XK', 'XKV', 2), |
|
1263 | - // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code |
|
1264 | - array(119, 'Kuwait', 'KW', 'KWT', 1), |
|
1265 | - array(120, 'Laos', 'LA', 'LAO', 1), |
|
1266 | - array(121, 'Latvia', 'LV', 'LVA', 2), |
|
1267 | - array(122, 'Lesotho', 'LS', 'LSO', 1), |
|
1268 | - array(123, 'Lebanon', 'LB', 'LBN', 1), |
|
1269 | - array(124, 'Liberia', 'LR', 'LBR', 1), |
|
1270 | - array(125, 'Libya', 'LY', 'LBY', 1), |
|
1271 | - array(126, 'Liechtenstein', 'LI', 'LIE', 1), |
|
1272 | - array(127, 'Lithuania', 'LT', 'LTU', 2), |
|
1273 | - array(128, 'Luxemburg', 'LU', 'LUX', 2), |
|
1274 | - array(129, 'Macao', 'MO', 'MAC', 1), |
|
1275 | - array(130, 'Macedonia', 'MK', 'MKD', 1), |
|
1276 | - array(131, 'Madagascar', 'MG', 'MDG', 1), |
|
1277 | - array(132, 'Malaysia', 'MY', 'MYS', 1), |
|
1278 | - array(133, 'Malawi', 'MW', 'MWI', 1), |
|
1279 | - array(134, 'Maldivas', 'MV', 'MDV', 1), |
|
1280 | - array(135, 'Mali', 'ML', 'MLI', 1), |
|
1281 | - array(136, 'Malta', 'MT', 'MLT', 2), |
|
1282 | - array(101, 'Northern Marianas', 'MP', 'MNP', 1), |
|
1283 | - array(137, 'Morocco', 'MA', 'MAR', 1), |
|
1284 | - array(104, 'Marshall islands', 'MH', 'MHL', 1), |
|
1285 | - array(138, 'Martinique', 'MQ', 'MTQ', 1), |
|
1286 | - array(139, 'Mauritius', 'MU', 'MUS', 1), |
|
1287 | - array(140, 'Mauritania', 'MR', 'MRT', 1), |
|
1288 | - array(141, 'Mayote', 'YT', 'MYT', 2), |
|
1289 | - array(142, 'Mexico', 'MX', 'MEX', 1), |
|
1290 | - array(143, 'Micronesia', 'FM', 'FSM', 1), |
|
1291 | - array(144, 'Moldova', 'MD', 'MDA', 1), |
|
1292 | - array(145, 'Monaco', 'MC', 'MCO', 2), |
|
1293 | - array(146, 'Mongolia', 'MN', 'MNG', 1), |
|
1294 | - array(147, 'Montserrat', 'MS', 'MSR', 1), |
|
1295 | - array(227, 'Montenegro', 'ME', 'MNE', 2), |
|
1296 | - array(148, 'Mozambique', 'MZ', 'MOZ', 1), |
|
1297 | - array(149, 'Myanmar', 'MM', 'MMR', 1), |
|
1298 | - array(150, 'Namibia', 'NA', 'NAM', 1), |
|
1299 | - array(151, 'Nauru', 'NR', 'NRU', 1), |
|
1300 | - array(152, 'Nepal', 'NP', 'NPL', 1), |
|
1301 | - array(9, 'Netherlands Antilles', 'AN', 'ANT', 1), |
|
1302 | - array(153, 'Nicaragua', 'NI', 'NIC', 1), |
|
1303 | - array(154, 'Niger', 'NE', 'NER', 1), |
|
1304 | - array(155, 'Nigeria', 'NG', 'NGA', 1), |
|
1305 | - array(156, 'Niue', 'NU', 'NIU', 1), |
|
1306 | - array(157, 'Norway', 'NO', 'NOR', 1), |
|
1307 | - array(158, 'New Caledonia', 'NC', 'NCL', 1), |
|
1308 | - array(159, 'New Zealand', 'NZ', 'NZL', 1), |
|
1309 | - array(160, 'Oman', 'OM', 'OMN', 1), |
|
1310 | - array(161, 'Pakistan', 'PK', 'PAK', 1), |
|
1311 | - array(162, 'Palau', 'PW', 'PLW', 1), |
|
1312 | - array(163, 'Panama', 'PA', 'PAN', 1), |
|
1313 | - array(164, 'Papua New Guinea', 'PG', 'PNG', 1), |
|
1314 | - array(165, 'Paraguay', 'PY', 'PRY', 1), |
|
1315 | - array(166, 'Peru', 'PE', 'PER', 1), |
|
1316 | - array(68, 'Philippines', 'PH', 'PHL', 1), |
|
1317 | - array(167, 'Poland', 'PL', 'POL', 1), |
|
1318 | - array(168, 'Portugal', 'PT', 'PRT', 2), |
|
1319 | - array(169, 'Puerto Rico', 'PR', 'PRI', 1), |
|
1320 | - array(170, 'Qatar', 'QA', 'QAT', 1), |
|
1321 | - array(176, 'Rwanda', 'RW', 'RWA', 1), |
|
1322 | - array(177, 'Romania', 'RO', 'ROM', 2), |
|
1323 | - array(178, 'Russia', 'RU', 'RUS', 1), |
|
1324 | - array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2), |
|
1325 | - array(180, 'Samoa', 'WS', 'WSM', 1), |
|
1326 | - array(181, 'American Samoa', 'AS', 'ASM', 1), |
|
1327 | - array(183, 'San Marino', 'SM', 'SMR', 2), |
|
1328 | - array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1), |
|
1329 | - array(185, 'Saint Helena', 'SH', 'SHN', 1), |
|
1330 | - array(186, 'Saint Lucia', 'LC', 'LCA', 1), |
|
1331 | - array(188, 'Senegal', 'SN', 'SEN', 1), |
|
1332 | - array(189, 'Seychelles', 'SC', 'SYC', 1), |
|
1333 | - array(190, 'Sierra Leona', 'SL', 'SLE', 1), |
|
1334 | - array(191, 'Singapore', 'SG', 'SGP', 1), |
|
1335 | - array(192, 'Syria', 'SY', 'SYR', 1), |
|
1336 | - array(193, 'Somalia', 'SO', 'SOM', 1), |
|
1337 | - array(194, 'Sri Lanka', 'LK', 'LKA', 1), |
|
1338 | - array(195, 'South Africa', 'ZA', 'ZAF', 1), |
|
1339 | - array(196, 'Sudan', 'SD', 'SDN', 1), |
|
1340 | - array(199, 'Suriname', 'SR', 'SUR', 1), |
|
1341 | - array(200, 'Swaziland', 'SZ', 'SWZ', 1), |
|
1342 | - array(201, 'Thailand', 'TH', 'THA', 1), |
|
1343 | - array(202, 'Taiwan', 'TW', 'TWN', 1), |
|
1344 | - array(203, 'Tanzania', 'TZ', 'TZA', 1), |
|
1345 | - array(204, 'Tajikistan', 'TJ', 'TJK', 1), |
|
1346 | - array(206, 'Timor-Leste', 'TL', 'TLS', 1), |
|
1347 | - array(207, 'Togo', 'TG', 'TGO', 1), |
|
1348 | - array(208, 'Tokelau', 'TK', 'TKL', 1), |
|
1349 | - array(209, 'Tonga', 'TO', 'TON', 1), |
|
1350 | - array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1), |
|
1351 | - array(211, 'Tunisia', 'TN', 'TUN', 1), |
|
1352 | - array(212, 'Turkmenistan', 'TM', 'TKM', 1), |
|
1353 | - array(213, 'Turkey', 'TR', 'TUR', 1), |
|
1354 | - array(214, 'Tuvalu', 'TV', 'TUV', 1), |
|
1355 | - array(215, 'Ukraine', 'UA', 'UKR', 1), |
|
1356 | - array(216, 'Uganda', 'UG', 'UGA', 1), |
|
1357 | - array(59, 'United Arab Emirates', 'AE', 'ARE', 1), |
|
1358 | - array(217, 'Uruguay', 'UY', 'URY', 1), |
|
1359 | - array(218, 'Uzbekistan', 'UZ', 'UZB', 1), |
|
1360 | - array(219, 'Vanuatu', 'VU', 'VUT', 1), |
|
1361 | - array(220, 'Vatican City', 'VA', 'VAT', 2), |
|
1362 | - array(221, 'Venezuela', 'VE', 'VEN', 1), |
|
1363 | - array(222, 'Vietnam', 'VN', 'VNM', 1), |
|
1364 | - array(108, 'Virgin Islands', 'VI', 'VIR', 1), |
|
1365 | - array(223, 'Yemen', 'YE', 'YEM', 1), |
|
1366 | - array(225, 'Zambia', 'ZM', 'ZMB', 1), |
|
1367 | - array(226, 'Zimbabwe', 'ZW', 'ZWE', 1), |
|
1368 | - ); |
|
1369 | - $country_iso = 'US'; |
|
1370 | - foreach ($old_countries as $country_array) { |
|
1371 | - // note: index 0 is the 3.1 country ID |
|
1372 | - if ($country_array[0] == $country_id) { |
|
1373 | - // note: index 2 is the ISO |
|
1374 | - $country_iso = $country_array[2]; |
|
1375 | - break; |
|
1376 | - } |
|
1377 | - } |
|
1378 | - return $country_iso; |
|
1379 | - } |
|
1380 | - |
|
1381 | - |
|
1382 | - |
|
1383 | - /** |
|
1384 | - * Gets the ISO3 for the |
|
1385 | - * |
|
1386 | - * @return string |
|
1387 | - */ |
|
1388 | - public function get_default_country_iso() |
|
1389 | - { |
|
1390 | - $old_org_options = get_option('events_organization_settings'); |
|
1391 | - $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
|
1392 | - return $iso; |
|
1393 | - } |
|
1394 | - |
|
1395 | - |
|
1396 | - |
|
1397 | - /** |
|
1398 | - * Converst a 3.1 payment status to its equivalent 4.1 regisration status |
|
1399 | - * |
|
1400 | - * @param string $payment_status possible value for 3.1's evens_attendee.payment_status |
|
1401 | - * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's |
|
1402 | - * default payment status, the event's default payment status, or |
|
1403 | - * the attendee's payment status) required pre-approval. |
|
1404 | - * @return string STS_ID for use in 4.1 |
|
1405 | - */ |
|
1406 | - public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) |
|
1407 | - { |
|
1408 | - // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
|
1409 | - if ($this_thing_required_pre_approval) { |
|
1410 | - return 'RNA'; |
|
1411 | - } else { |
|
1412 | - $mapping = $default_reg_stati_conversions = array( |
|
1413 | - 'Completed' => 'RAP', |
|
1414 | - '' => 'RPP', |
|
1415 | - 'Incomplete' => 'RPP', |
|
1416 | - 'Pending' => 'RAP', |
|
1417 | - // stati that only occurred on 3.1 attendees: |
|
1418 | - 'Payment Declined' => 'RPP', |
|
1419 | - 'Not Completed' => 'RPP', |
|
1420 | - 'Cancelled' => 'RPP', |
|
1421 | - 'Declined' => 'RPP', |
|
1422 | - ); |
|
1423 | - } |
|
1424 | - return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA'; |
|
1425 | - } |
|
1426 | - |
|
1427 | - |
|
1428 | - |
|
1429 | - /** |
|
1430 | - * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event |
|
1431 | - * and sets it as the featured image on the CPT event |
|
1432 | - * |
|
1433 | - * @param type $old_event |
|
1434 | - * @param type $new_cpt_id |
|
1435 | - * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
|
1436 | - * @return boolean whether or not we had to do the big job of creating an image attachment |
|
1437 | - */ |
|
1438 | - public function convert_image_url_to_attachment_and_attach_to_post( |
|
1439 | - $guid, |
|
1440 | - $new_cpt_id, |
|
1441 | - EE_Data_Migration_Script_Stage $migration_stage |
|
1442 | - ) { |
|
1443 | - $created_attachment_post = false; |
|
1444 | - $guid = $this->_get_original_guid($guid); |
|
1445 | - if ($guid) { |
|
1446 | - // check for an existing attachment post with this guid |
|
1447 | - $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
|
1448 | - if (! $attachment_post_id) { |
|
1449 | - // post thumbnail with that GUID doesn't exist, we should create one |
|
1450 | - $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
|
1451 | - $created_attachment_post = true; |
|
1452 | - } |
|
1453 | - // double-check we actually have an attachment post |
|
1454 | - if ($attachment_post_id) { |
|
1455 | - update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1456 | - } else { |
|
1457 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1458 | - "Could not update event image %s for CPT with ID %d, but attachments post ID is %d", |
|
1459 | - "event_espresso" |
|
1460 | - ), $guid, $new_cpt_id, $attachment_post_id)); |
|
1461 | - } |
|
1462 | - } |
|
1463 | - return $created_attachment_post; |
|
1464 | - } |
|
1465 | - |
|
1466 | - |
|
1467 | - |
|
1468 | - /** |
|
1469 | - * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead |
|
1470 | - * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype, |
|
1471 | - * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of |
|
1472 | - * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it |
|
1473 | - * exists |
|
1474 | - * |
|
1475 | - * @param string $guid_in_old_event |
|
1476 | - * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
|
1477 | - */ |
|
1478 | - private function _get_original_guid($guid_in_old_event) |
|
1479 | - { |
|
1480 | - $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1481 | - // do a head request to verify the file exists |
|
1482 | - $head_response = wp_remote_head($original_guid); |
|
1483 | - if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1484 | - return $original_guid; |
|
1485 | - } else { |
|
1486 | - return $guid_in_old_event; |
|
1487 | - } |
|
1488 | - } |
|
1489 | - |
|
1490 | - |
|
1491 | - |
|
1492 | - /** |
|
1493 | - * Creates an image attachment post for the GUID. If the GUID points to a remote image, |
|
1494 | - * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of |
|
1495 | - * thumbnails) |
|
1496 | - * |
|
1497 | - * @param type $guid |
|
1498 | - * @param EE_Data_Migration_Script_Stage $migration_stage |
|
1499 | - * @return int |
|
1500 | - */ |
|
1501 | - private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) |
|
1502 | - { |
|
1503 | - if (! $guid) { |
|
1504 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1505 | - "Cannot create image attachment for a blank GUID!", |
|
1506 | - "event_espresso" |
|
1507 | - ))); |
|
1508 | - return 0; |
|
1509 | - } |
|
1510 | - $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1511 | - $wp_upload_dir = wp_upload_dir(); |
|
1512 | - // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
|
1513 | - if (strpos($guid, $wp_upload_dir['url']) === false) { |
|
1514 | - // image is located remotely. download it and place it in the uploads directory |
|
1515 | - if (! is_readable($guid)) { |
|
1516 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1517 | - "Could not create image attachment from non-existent file: %s", |
|
1518 | - "event_espresso" |
|
1519 | - ), $guid)); |
|
1520 | - return 0; |
|
1521 | - } |
|
1522 | - $contents = file_get_contents($guid); |
|
1523 | - if ($contents === false) { |
|
1524 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1525 | - "Could not read image at %s, and therefore couldnt create an attachment post for it.", |
|
1526 | - "event_espresso" |
|
1527 | - ), $guid)); |
|
1528 | - return false; |
|
1529 | - } |
|
1530 | - $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid); |
|
1531 | - $savefile = fopen($local_filepath, 'w'); |
|
1532 | - fwrite($savefile, $contents); |
|
1533 | - fclose($savefile); |
|
1534 | - $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1535 | - } else { |
|
1536 | - $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1537 | - } |
|
1538 | - $attachment = array( |
|
1539 | - 'guid' => $guid, |
|
1540 | - 'post_mime_type' => $wp_filetype['type'], |
|
1541 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($guid)), |
|
1542 | - 'post_content' => '', |
|
1543 | - 'post_status' => 'inherit', |
|
1544 | - ); |
|
1545 | - $attach_id = wp_insert_attachment($attachment, $guid); |
|
1546 | - if (! $attach_id) { |
|
1547 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1548 | - "Could not create image attachment post from image '%s'. Attachment data was %s.", |
|
1549 | - "event_espresso" |
|
1550 | - ), $guid, $this->_json_encode($attachment))); |
|
1551 | - return $attach_id; |
|
1552 | - } |
|
1553 | - // you must first include the image.php file |
|
1554 | - // for the function wp_generate_attachment_metadata() to work |
|
1555 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1556 | - $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1557 | - if (! $attach_data) { |
|
1558 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1559 | - "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", |
|
1560 | - "event_espresso" |
|
1561 | - ), $attach_id, $local_filepath, $guid)); |
|
1562 | - return $attach_id; |
|
1563 | - } |
|
1564 | - $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1565 | - if (! $metadata_save_result) { |
|
1566 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1567 | - "Could not update attachment metadata for attachment %d with data %s", |
|
1568 | - "event_espresso" |
|
1569 | - ), $attach_id, $this->_json_encode($attach_data))); |
|
1570 | - } |
|
1571 | - return $attach_id; |
|
1572 | - } |
|
1573 | - |
|
1574 | - |
|
1575 | - |
|
1576 | - /** |
|
1577 | - * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself), |
|
1578 | - * and returns its ID. |
|
1579 | - * |
|
1580 | - * @global type $wpdb |
|
1581 | - * @param string $guid |
|
1582 | - * @return int |
|
1583 | - */ |
|
1584 | - private function _get_image_attachment_id_by_GUID($guid) |
|
1585 | - { |
|
1586 | - global $wpdb; |
|
1587 | - $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1588 | - return $attachment_id; |
|
1589 | - } |
|
1590 | - |
|
1591 | - |
|
1592 | - |
|
1593 | - /** |
|
1594 | - * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string |
|
1595 | - * (and optionally a timezone; if none is given, the wp default is used) |
|
1596 | - * |
|
1597 | - * @param EE_Data_Migration_Script_base $stage |
|
1598 | - * @param array $row_of_data , the row from the DB (as an array) we're trying to find the |
|
1599 | - * UTC time for |
|
1600 | - * @param string $DATETIME_string |
|
1601 | - * @param string $timezone |
|
1602 | - * @return string |
|
1603 | - */ |
|
1604 | - public function convert_date_string_to_utc( |
|
1605 | - EE_Data_Migration_Script_Stage $stage, |
|
1606 | - $row_of_data, |
|
1607 | - $DATETIME_string, |
|
1608 | - $timezone = null |
|
1609 | - ) { |
|
1610 | - $original_tz = $timezone; |
|
1611 | - if (! $timezone) { |
|
1612 | - $timezone = $this->_get_wp_timezone(); |
|
1613 | - } |
|
1614 | - if (! $timezone) { |
|
1615 | - $stage->add_error(sprintf( |
|
1616 | - esc_html__("Could not find timezone given %s for %s", "event_espresso"), |
|
1617 | - $original_tz, |
|
1618 | - $row_of_data |
|
1619 | - )); |
|
1620 | - $timezone = 'UTC'; |
|
1621 | - } |
|
1622 | - try { |
|
1623 | - $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1624 | - EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC')); |
|
1625 | - } catch (Exception $e) { |
|
1626 | - $stage->add_error(sprintf(esc_html__( |
|
1627 | - "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", |
|
1628 | - "event_espresso" |
|
1629 | - ), $DATETIME_string, $timezone)); |
|
1630 | - $date_obj = new DateTime(); |
|
1631 | - } |
|
1632 | - return $date_obj->format('Y-m-d H:i:s'); |
|
1633 | - } |
|
1634 | - |
|
1635 | - |
|
1636 | - |
|
1637 | - /** |
|
1638 | - * Gets the default timezone string from wordpress (even if they set a gmt offset) |
|
1639 | - * |
|
1640 | - * @return string |
|
1641 | - */ |
|
1642 | - private function _get_wp_timezone() |
|
1643 | - { |
|
1644 | - $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1645 | - // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
|
1646 | - if (empty($timezone)) { |
|
1647 | - // let's get a the WordPress UTC offset |
|
1648 | - $offset = get_option('gmt_offset'); |
|
1649 | - $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1650 | - } |
|
1651 | - return $timezone; |
|
1652 | - } |
|
1653 | - |
|
1654 | - |
|
1655 | - |
|
1656 | - /** |
|
1657 | - * Gets the wordpress timezone string from a UTC offset |
|
1658 | - * |
|
1659 | - * @param int $offset |
|
1660 | - * @return boolean |
|
1661 | - */ |
|
1662 | - private function timezone_convert_to_string_from_offset($offset) |
|
1663 | - { |
|
1664 | - // shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did not work as expected - its not reliable |
|
1665 | - $offset *= 3600; // convert hour offset to seconds |
|
1666 | - $abbrarray = timezone_abbreviations_list(); |
|
1667 | - foreach ($abbrarray as $abbr) { |
|
1668 | - foreach ($abbr as $city) { |
|
1669 | - if ($city['offset'] == $offset) { |
|
1670 | - return $city['timezone_id']; |
|
1671 | - } |
|
1672 | - } |
|
1673 | - } |
|
1674 | - return false; |
|
1675 | - } |
|
1676 | - |
|
1677 | - |
|
1678 | - |
|
1679 | - public function migration_page_hooks() |
|
1680 | - { |
|
1681 | - add_filter( |
|
1682 | - 'FHEE__ee_migration_page__header', |
|
1683 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1684 | - 10, |
|
1685 | - 3 |
|
1686 | - ); |
|
1687 | - add_filter( |
|
1688 | - 'FHEE__ee_migration_page__p_after_header', |
|
1689 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1690 | - 10, |
|
1691 | - 2 |
|
1692 | - ); |
|
1693 | - add_filter( |
|
1694 | - 'FHEE__ee_migration_page__option_1_main', |
|
1695 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1696 | - 10, |
|
1697 | - 3 |
|
1698 | - ); |
|
1699 | - add_filter( |
|
1700 | - 'FHEE__ee_migration_page__option_1_button_text', |
|
1701 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1702 | - 10, |
|
1703 | - 3 |
|
1704 | - ); |
|
1705 | - add_action( |
|
1706 | - 'AHEE__ee_migration_page__option_1_extra_details', |
|
1707 | - array($this, '_migration_page_hook_option_1_extra_details'), |
|
1708 | - 10, |
|
1709 | - 3 |
|
1710 | - ); |
|
1711 | - add_filter( |
|
1712 | - 'FHEE__ee_migration_page__option_2_main', |
|
1713 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1714 | - 10, |
|
1715 | - 4 |
|
1716 | - ); |
|
1717 | - add_filter( |
|
1718 | - 'FHEE__ee_migration_page__option_2_button_text', |
|
1719 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1720 | - 10, |
|
1721 | - 2 |
|
1722 | - ); |
|
1723 | - add_filter( |
|
1724 | - 'FHEE__ee_migration_page__option_2_details', |
|
1725 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1726 | - 10, |
|
1727 | - 2 |
|
1728 | - ); |
|
1729 | - add_action( |
|
1730 | - 'AHEE__ee_migration_page__after_migration_options_table', |
|
1731 | - array($this, '_migration_page_hook_after_migration_options_table') |
|
1732 | - ); |
|
1733 | - add_filter( |
|
1734 | - 'FHEE__ee_migration_page__done_migration_header', |
|
1735 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1736 | - 10, |
|
1737 | - 2 |
|
1738 | - ); |
|
1739 | - add_filter( |
|
1740 | - 'FHEE__ee_migration_page__p_after_done_migration_header', |
|
1741 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1742 | - 10, |
|
1743 | - 2 |
|
1744 | - ); |
|
1745 | - add_filter( |
|
1746 | - 'FHEE__ee_migration_page__migration_options_template', |
|
1747 | - array($this,'use_migration_options_from_ee3_template') |
|
1748 | - ); |
|
1749 | - } |
|
1750 | - |
|
1751 | - |
|
1752 | - |
|
1753 | - public function _migrate_page_hook_simplify_version_strings( |
|
1754 | - $old_content, |
|
1755 | - $current_db_state, |
|
1756 | - $next_db_state, |
|
1757 | - $ultimate_db_state = null |
|
1758 | - ) { |
|
1759 | - return str_replace( |
|
1760 | - array($current_db_state, $next_db_state, $ultimate_db_state), |
|
1761 | - array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')), |
|
1762 | - $old_content |
|
1763 | - ); |
|
1764 | - } |
|
1765 | - |
|
1766 | - |
|
1767 | - |
|
1768 | - public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) |
|
1769 | - { |
|
1770 | - return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content); |
|
1771 | - } |
|
1772 | - |
|
1773 | - |
|
1774 | - |
|
1775 | - public function _migration_page_hook_option_1_extra_details() |
|
1776 | - { |
|
1777 | - ?> |
|
1075 | + if (! $state) { |
|
1076 | + // insert a new one then |
|
1077 | + $cols_n_values = array( |
|
1078 | + 'CNT_ISO' => $country_iso, |
|
1079 | + 'STA_abbrev' => substr($state_name, 0, 6), |
|
1080 | + 'STA_name' => $state_name, |
|
1081 | + 'STA_active' => true, |
|
1082 | + ); |
|
1083 | + $data_types = array( |
|
1084 | + '%s',// CNT_ISO |
|
1085 | + '%s',// STA_abbrev |
|
1086 | + '%s',// STA_name |
|
1087 | + '%d',// STA_active |
|
1088 | + ); |
|
1089 | + $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1090 | + if (! $success) { |
|
1091 | + throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1092 | + 'N/A', |
|
1093 | + array('state' => $state_name, 'country_id' => $country_name), |
|
1094 | + $state_table, |
|
1095 | + $cols_n_values, |
|
1096 | + $data_types |
|
1097 | + )); |
|
1098 | + } |
|
1099 | + $state = $cols_n_values; |
|
1100 | + $state['STA_ID'] = $wpdb->insert_id; |
|
1101 | + } |
|
1102 | + return $state; |
|
1103 | + } |
|
1104 | + |
|
1105 | + |
|
1106 | + |
|
1107 | + /** |
|
1108 | + * Fixes times like "5:00 PM" into the expected 24-hour format "17:00". |
|
1109 | + * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing |
|
1110 | + * |
|
1111 | + * @param type $timeString |
|
1112 | + * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes |
|
1113 | + * with leading zeros) |
|
1114 | + */ |
|
1115 | + public function convertTimeFromAMPM($timeString) |
|
1116 | + { |
|
1117 | + $matches = array(); |
|
1118 | + preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1119 | + if (! $matches || count($matches) < 3) { |
|
1120 | + $hour = '00'; |
|
1121 | + $minutes = '00'; |
|
1122 | + } else { |
|
1123 | + $hour = intval($matches[1]); |
|
1124 | + $minutes = $matches[2]; |
|
1125 | + } |
|
1126 | + if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1127 | + $hour = intval($hour) + 12; |
|
1128 | + } |
|
1129 | + $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1130 | + $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1131 | + return "$hour:$minutes"; |
|
1132 | + } |
|
1133 | + |
|
1134 | + |
|
1135 | + |
|
1136 | + /** |
|
1137 | + * Gets the ISO3 fora country given its 3.1 country ID. |
|
1138 | + * |
|
1139 | + * @param int $country_id |
|
1140 | + * @return string the country's ISO3 code |
|
1141 | + */ |
|
1142 | + public function get_iso_from_3_1_country_id($country_id) |
|
1143 | + { |
|
1144 | + $old_countries = array( |
|
1145 | + array(64, 'United States', 'US', 'USA', 1), |
|
1146 | + array(15, 'Australia', 'AU', 'AUS', 1), |
|
1147 | + array(39, 'Canada', 'CA', 'CAN', 1), |
|
1148 | + array(171, 'United Kingdom', 'GB', 'GBR', 1), |
|
1149 | + array(70, 'France', 'FR', 'FRA', 2), |
|
1150 | + array(111, 'Italy', 'IT', 'ITA', 2), |
|
1151 | + array(63, 'Spain', 'ES', 'ESP', 2), |
|
1152 | + array(1, 'Afghanistan', 'AF', 'AFG', 1), |
|
1153 | + array(2, 'Albania', 'AL', 'ALB', 1), |
|
1154 | + array(3, 'Germany', 'DE', 'DEU', 2), |
|
1155 | + array(198, 'Switzerland', 'CH', 'CHE', 1), |
|
1156 | + array(87, 'Netherlands', 'NL', 'NLD', 2), |
|
1157 | + array(197, 'Sweden', 'SE', 'SWE', 1), |
|
1158 | + array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2), |
|
1159 | + array(4, 'Andorra', 'AD', 'AND', 2), |
|
1160 | + array(5, 'Angola', 'AO', 'AGO', 1), |
|
1161 | + array(6, 'Anguilla', 'AI', 'AIA', 1), |
|
1162 | + array(7, 'Antarctica', 'AQ', 'ATA', 1), |
|
1163 | + array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1), |
|
1164 | + array(10, 'Saudi Arabia', 'SA', 'SAU', 1), |
|
1165 | + array(11, 'Algeria', 'DZ', 'DZA', 1), |
|
1166 | + array(12, 'Argentina', 'AR', 'ARG', 1), |
|
1167 | + array(13, 'Armenia', 'AM', 'ARM', 1), |
|
1168 | + array(14, 'Aruba', 'AW', 'ABW', 1), |
|
1169 | + array(16, 'Austria', 'AT', 'AUT', 2), |
|
1170 | + array(17, 'Azerbaijan', 'AZ', 'AZE', 1), |
|
1171 | + array(18, 'Bahamas', 'BS', 'BHS', 1), |
|
1172 | + array(19, 'Bahrain', 'BH', 'BHR', 1), |
|
1173 | + array(20, 'Bangladesh', 'BD', 'BGD', 1), |
|
1174 | + array(21, 'Barbados', 'BB', 'BRB', 1), |
|
1175 | + array(22, 'Belgium ', 'BE', 'BEL', 2), |
|
1176 | + array(23, 'Belize', 'BZ', 'BLZ', 1), |
|
1177 | + array(24, 'Benin', 'BJ', 'BEN', 1), |
|
1178 | + array(25, 'Bermudas', 'BM', 'BMU', 1), |
|
1179 | + array(26, 'Belarus', 'BY', 'BLR', 1), |
|
1180 | + array(27, 'Bolivia', 'BO', 'BOL', 1), |
|
1181 | + array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1), |
|
1182 | + array(29, 'Botswana', 'BW', 'BWA', 1), |
|
1183 | + array(96, 'Bouvet Island', 'BV', 'BVT', 1), |
|
1184 | + array(30, 'Brazil', 'BR', 'BRA', 1), |
|
1185 | + array(31, 'Brunei', 'BN', 'BRN', 1), |
|
1186 | + array(32, 'Bulgaria', 'BG', 'BGR', 1), |
|
1187 | + array(33, 'Burkina Faso', 'BF', 'BFA', 1), |
|
1188 | + array(34, 'Burundi', 'BI', 'BDI', 1), |
|
1189 | + array(35, 'Bhutan', 'BT', 'BTN', 1), |
|
1190 | + array(36, 'Cape Verde', 'CV', 'CPV', 1), |
|
1191 | + array(37, 'Cambodia', 'KH', 'KHM', 1), |
|
1192 | + array(38, 'Cameroon', 'CM', 'CMR', 1), |
|
1193 | + array(98, 'Cayman Islands', 'KY', 'CYM', 1), |
|
1194 | + array(172, 'Central African Republic', 'CF', 'CAF', 1), |
|
1195 | + array(40, 'Chad', 'TD', 'TCD', 1), |
|
1196 | + array(41, 'Chile', 'CL', 'CHL', 1), |
|
1197 | + array(42, 'China', 'CN', 'CHN', 1), |
|
1198 | + array(105, 'Christmas Island', 'CX', 'CXR', 1), |
|
1199 | + array(43, 'Cyprus', 'CY', 'CYP', 2), |
|
1200 | + array(99, 'Cocos Island', 'CC', 'CCK', 1), |
|
1201 | + array(100, 'Cook Islands', 'CK', 'COK', 1), |
|
1202 | + array(44, 'Colombia', 'CO', 'COL', 1), |
|
1203 | + array(45, 'Comoros', 'KM', 'COM', 1), |
|
1204 | + array(46, 'Congo', 'CG', 'COG', 1), |
|
1205 | + array(47, 'North Korea', 'KP', 'PRK', 1), |
|
1206 | + array(50, 'Costa Rica', 'CR', 'CRI', 1), |
|
1207 | + array(51, 'Croatia', 'HR', 'HRV', 1), |
|
1208 | + array(52, 'Cuba', 'CU', 'CUB', 1), |
|
1209 | + array(173, 'Czech Republic', 'CZ', 'CZE', 1), |
|
1210 | + array(53, 'Denmark', 'DK', 'DNK', 1), |
|
1211 | + array(54, 'Djibouti', 'DJ', 'DJI', 1), |
|
1212 | + array(55, 'Dominica', 'DM', 'DMA', 1), |
|
1213 | + array(174, 'Dominican Republic', 'DO', 'DOM', 1), |
|
1214 | + array(56, 'Ecuador', 'EC', 'ECU', 1), |
|
1215 | + array(57, 'Egypt', 'EG', 'EGY', 1), |
|
1216 | + array(58, 'El Salvador', 'SV', 'SLV', 1), |
|
1217 | + array(60, 'Eritrea', 'ER', 'ERI', 1), |
|
1218 | + array(61, 'Slovakia', 'SK', 'SVK', 2), |
|
1219 | + array(62, 'Slovenia', 'SI', 'SVN', 2), |
|
1220 | + array(65, 'Estonia', 'EE', 'EST', 2), |
|
1221 | + array(66, 'Ethiopia', 'ET', 'ETH', 1), |
|
1222 | + array(102, 'Faroe islands', 'FO', 'FRO', 1), |
|
1223 | + array(103, 'Falkland Islands', 'FK', 'FLK', 1), |
|
1224 | + array(67, 'Fiji', 'FJ', 'FJI', 1), |
|
1225 | + array(69, 'Finland', 'FI', 'FIN', 2), |
|
1226 | + array(71, 'Gabon', 'GA', 'GAB', 1), |
|
1227 | + array(72, 'Gambia', 'GM', 'GMB', 1), |
|
1228 | + array(73, 'Georgia', 'GE', 'GEO', 1), |
|
1229 | + array(74, 'Ghana', 'GH', 'GHA', 1), |
|
1230 | + array(75, 'Gibraltar', 'GI', 'GIB', 1), |
|
1231 | + array(76, 'Greece', 'GR', 'GRC', 2), |
|
1232 | + array(77, 'Grenada', 'GD', 'GRD', 1), |
|
1233 | + array(78, 'Greenland', 'GL', 'GRL', 1), |
|
1234 | + array(79, 'Guadeloupe', 'GP', 'GLP', 1), |
|
1235 | + array(80, 'Guam', 'GU', 'GUM', 1), |
|
1236 | + array(81, 'Guatemala', 'GT', 'GTM', 1), |
|
1237 | + array(82, 'Guinea', 'GN', 'GIN', 1), |
|
1238 | + array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1), |
|
1239 | + array(84, 'Guinea-Bissau', 'GW', 'GNB', 1), |
|
1240 | + array(85, 'Guyana', 'GY', 'GUY', 1), |
|
1241 | + array(86, 'Haiti', 'HT', 'HTI', 1), |
|
1242 | + array(88, 'Honduras', 'HN', 'HND', 1), |
|
1243 | + array(89, 'Hong Kong', 'HK', 'HKG', 1), |
|
1244 | + array(90, 'Hungary', 'HU', 'HUN', 1), |
|
1245 | + array(91, 'India', 'IN', 'IND', 1), |
|
1246 | + array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1), |
|
1247 | + array(92, 'Indonesia', 'ID', 'IDN', 1), |
|
1248 | + array(93, 'Iraq', 'IQ', 'IRQ', 1), |
|
1249 | + array(94, 'Iran', 'IR', 'IRN', 1), |
|
1250 | + array(95, 'Ireland', 'IE', 'IRL', 2), |
|
1251 | + array(97, 'Iceland', 'IS', 'ISL', 1), |
|
1252 | + array(110, 'Israel', 'IL', 'ISR', 1), |
|
1253 | + array(49, 'Ivory Coast ', 'CI', 'CIV', 1), |
|
1254 | + array(112, 'Jamaica', 'JM', 'JAM', 1), |
|
1255 | + array(113, 'Japan', 'JP', 'JPN', 1), |
|
1256 | + array(114, 'Jordan', 'JO', 'JOR', 1), |
|
1257 | + array(115, 'Kazakhstan', 'KZ', 'KAZ', 1), |
|
1258 | + array(116, 'Kenya', 'KE', 'KEN', 1), |
|
1259 | + array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1), |
|
1260 | + array(118, 'Kiribati', 'KI', 'KIR', 1), |
|
1261 | + array(48, 'South Korea', 'KR', 'KOR', 1), |
|
1262 | + array(228, 'Kosovo', 'XK', 'XKV', 2), |
|
1263 | + // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code |
|
1264 | + array(119, 'Kuwait', 'KW', 'KWT', 1), |
|
1265 | + array(120, 'Laos', 'LA', 'LAO', 1), |
|
1266 | + array(121, 'Latvia', 'LV', 'LVA', 2), |
|
1267 | + array(122, 'Lesotho', 'LS', 'LSO', 1), |
|
1268 | + array(123, 'Lebanon', 'LB', 'LBN', 1), |
|
1269 | + array(124, 'Liberia', 'LR', 'LBR', 1), |
|
1270 | + array(125, 'Libya', 'LY', 'LBY', 1), |
|
1271 | + array(126, 'Liechtenstein', 'LI', 'LIE', 1), |
|
1272 | + array(127, 'Lithuania', 'LT', 'LTU', 2), |
|
1273 | + array(128, 'Luxemburg', 'LU', 'LUX', 2), |
|
1274 | + array(129, 'Macao', 'MO', 'MAC', 1), |
|
1275 | + array(130, 'Macedonia', 'MK', 'MKD', 1), |
|
1276 | + array(131, 'Madagascar', 'MG', 'MDG', 1), |
|
1277 | + array(132, 'Malaysia', 'MY', 'MYS', 1), |
|
1278 | + array(133, 'Malawi', 'MW', 'MWI', 1), |
|
1279 | + array(134, 'Maldivas', 'MV', 'MDV', 1), |
|
1280 | + array(135, 'Mali', 'ML', 'MLI', 1), |
|
1281 | + array(136, 'Malta', 'MT', 'MLT', 2), |
|
1282 | + array(101, 'Northern Marianas', 'MP', 'MNP', 1), |
|
1283 | + array(137, 'Morocco', 'MA', 'MAR', 1), |
|
1284 | + array(104, 'Marshall islands', 'MH', 'MHL', 1), |
|
1285 | + array(138, 'Martinique', 'MQ', 'MTQ', 1), |
|
1286 | + array(139, 'Mauritius', 'MU', 'MUS', 1), |
|
1287 | + array(140, 'Mauritania', 'MR', 'MRT', 1), |
|
1288 | + array(141, 'Mayote', 'YT', 'MYT', 2), |
|
1289 | + array(142, 'Mexico', 'MX', 'MEX', 1), |
|
1290 | + array(143, 'Micronesia', 'FM', 'FSM', 1), |
|
1291 | + array(144, 'Moldova', 'MD', 'MDA', 1), |
|
1292 | + array(145, 'Monaco', 'MC', 'MCO', 2), |
|
1293 | + array(146, 'Mongolia', 'MN', 'MNG', 1), |
|
1294 | + array(147, 'Montserrat', 'MS', 'MSR', 1), |
|
1295 | + array(227, 'Montenegro', 'ME', 'MNE', 2), |
|
1296 | + array(148, 'Mozambique', 'MZ', 'MOZ', 1), |
|
1297 | + array(149, 'Myanmar', 'MM', 'MMR', 1), |
|
1298 | + array(150, 'Namibia', 'NA', 'NAM', 1), |
|
1299 | + array(151, 'Nauru', 'NR', 'NRU', 1), |
|
1300 | + array(152, 'Nepal', 'NP', 'NPL', 1), |
|
1301 | + array(9, 'Netherlands Antilles', 'AN', 'ANT', 1), |
|
1302 | + array(153, 'Nicaragua', 'NI', 'NIC', 1), |
|
1303 | + array(154, 'Niger', 'NE', 'NER', 1), |
|
1304 | + array(155, 'Nigeria', 'NG', 'NGA', 1), |
|
1305 | + array(156, 'Niue', 'NU', 'NIU', 1), |
|
1306 | + array(157, 'Norway', 'NO', 'NOR', 1), |
|
1307 | + array(158, 'New Caledonia', 'NC', 'NCL', 1), |
|
1308 | + array(159, 'New Zealand', 'NZ', 'NZL', 1), |
|
1309 | + array(160, 'Oman', 'OM', 'OMN', 1), |
|
1310 | + array(161, 'Pakistan', 'PK', 'PAK', 1), |
|
1311 | + array(162, 'Palau', 'PW', 'PLW', 1), |
|
1312 | + array(163, 'Panama', 'PA', 'PAN', 1), |
|
1313 | + array(164, 'Papua New Guinea', 'PG', 'PNG', 1), |
|
1314 | + array(165, 'Paraguay', 'PY', 'PRY', 1), |
|
1315 | + array(166, 'Peru', 'PE', 'PER', 1), |
|
1316 | + array(68, 'Philippines', 'PH', 'PHL', 1), |
|
1317 | + array(167, 'Poland', 'PL', 'POL', 1), |
|
1318 | + array(168, 'Portugal', 'PT', 'PRT', 2), |
|
1319 | + array(169, 'Puerto Rico', 'PR', 'PRI', 1), |
|
1320 | + array(170, 'Qatar', 'QA', 'QAT', 1), |
|
1321 | + array(176, 'Rwanda', 'RW', 'RWA', 1), |
|
1322 | + array(177, 'Romania', 'RO', 'ROM', 2), |
|
1323 | + array(178, 'Russia', 'RU', 'RUS', 1), |
|
1324 | + array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2), |
|
1325 | + array(180, 'Samoa', 'WS', 'WSM', 1), |
|
1326 | + array(181, 'American Samoa', 'AS', 'ASM', 1), |
|
1327 | + array(183, 'San Marino', 'SM', 'SMR', 2), |
|
1328 | + array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1), |
|
1329 | + array(185, 'Saint Helena', 'SH', 'SHN', 1), |
|
1330 | + array(186, 'Saint Lucia', 'LC', 'LCA', 1), |
|
1331 | + array(188, 'Senegal', 'SN', 'SEN', 1), |
|
1332 | + array(189, 'Seychelles', 'SC', 'SYC', 1), |
|
1333 | + array(190, 'Sierra Leona', 'SL', 'SLE', 1), |
|
1334 | + array(191, 'Singapore', 'SG', 'SGP', 1), |
|
1335 | + array(192, 'Syria', 'SY', 'SYR', 1), |
|
1336 | + array(193, 'Somalia', 'SO', 'SOM', 1), |
|
1337 | + array(194, 'Sri Lanka', 'LK', 'LKA', 1), |
|
1338 | + array(195, 'South Africa', 'ZA', 'ZAF', 1), |
|
1339 | + array(196, 'Sudan', 'SD', 'SDN', 1), |
|
1340 | + array(199, 'Suriname', 'SR', 'SUR', 1), |
|
1341 | + array(200, 'Swaziland', 'SZ', 'SWZ', 1), |
|
1342 | + array(201, 'Thailand', 'TH', 'THA', 1), |
|
1343 | + array(202, 'Taiwan', 'TW', 'TWN', 1), |
|
1344 | + array(203, 'Tanzania', 'TZ', 'TZA', 1), |
|
1345 | + array(204, 'Tajikistan', 'TJ', 'TJK', 1), |
|
1346 | + array(206, 'Timor-Leste', 'TL', 'TLS', 1), |
|
1347 | + array(207, 'Togo', 'TG', 'TGO', 1), |
|
1348 | + array(208, 'Tokelau', 'TK', 'TKL', 1), |
|
1349 | + array(209, 'Tonga', 'TO', 'TON', 1), |
|
1350 | + array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1), |
|
1351 | + array(211, 'Tunisia', 'TN', 'TUN', 1), |
|
1352 | + array(212, 'Turkmenistan', 'TM', 'TKM', 1), |
|
1353 | + array(213, 'Turkey', 'TR', 'TUR', 1), |
|
1354 | + array(214, 'Tuvalu', 'TV', 'TUV', 1), |
|
1355 | + array(215, 'Ukraine', 'UA', 'UKR', 1), |
|
1356 | + array(216, 'Uganda', 'UG', 'UGA', 1), |
|
1357 | + array(59, 'United Arab Emirates', 'AE', 'ARE', 1), |
|
1358 | + array(217, 'Uruguay', 'UY', 'URY', 1), |
|
1359 | + array(218, 'Uzbekistan', 'UZ', 'UZB', 1), |
|
1360 | + array(219, 'Vanuatu', 'VU', 'VUT', 1), |
|
1361 | + array(220, 'Vatican City', 'VA', 'VAT', 2), |
|
1362 | + array(221, 'Venezuela', 'VE', 'VEN', 1), |
|
1363 | + array(222, 'Vietnam', 'VN', 'VNM', 1), |
|
1364 | + array(108, 'Virgin Islands', 'VI', 'VIR', 1), |
|
1365 | + array(223, 'Yemen', 'YE', 'YEM', 1), |
|
1366 | + array(225, 'Zambia', 'ZM', 'ZMB', 1), |
|
1367 | + array(226, 'Zimbabwe', 'ZW', 'ZWE', 1), |
|
1368 | + ); |
|
1369 | + $country_iso = 'US'; |
|
1370 | + foreach ($old_countries as $country_array) { |
|
1371 | + // note: index 0 is the 3.1 country ID |
|
1372 | + if ($country_array[0] == $country_id) { |
|
1373 | + // note: index 2 is the ISO |
|
1374 | + $country_iso = $country_array[2]; |
|
1375 | + break; |
|
1376 | + } |
|
1377 | + } |
|
1378 | + return $country_iso; |
|
1379 | + } |
|
1380 | + |
|
1381 | + |
|
1382 | + |
|
1383 | + /** |
|
1384 | + * Gets the ISO3 for the |
|
1385 | + * |
|
1386 | + * @return string |
|
1387 | + */ |
|
1388 | + public function get_default_country_iso() |
|
1389 | + { |
|
1390 | + $old_org_options = get_option('events_organization_settings'); |
|
1391 | + $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
|
1392 | + return $iso; |
|
1393 | + } |
|
1394 | + |
|
1395 | + |
|
1396 | + |
|
1397 | + /** |
|
1398 | + * Converst a 3.1 payment status to its equivalent 4.1 regisration status |
|
1399 | + * |
|
1400 | + * @param string $payment_status possible value for 3.1's evens_attendee.payment_status |
|
1401 | + * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's |
|
1402 | + * default payment status, the event's default payment status, or |
|
1403 | + * the attendee's payment status) required pre-approval. |
|
1404 | + * @return string STS_ID for use in 4.1 |
|
1405 | + */ |
|
1406 | + public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) |
|
1407 | + { |
|
1408 | + // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
|
1409 | + if ($this_thing_required_pre_approval) { |
|
1410 | + return 'RNA'; |
|
1411 | + } else { |
|
1412 | + $mapping = $default_reg_stati_conversions = array( |
|
1413 | + 'Completed' => 'RAP', |
|
1414 | + '' => 'RPP', |
|
1415 | + 'Incomplete' => 'RPP', |
|
1416 | + 'Pending' => 'RAP', |
|
1417 | + // stati that only occurred on 3.1 attendees: |
|
1418 | + 'Payment Declined' => 'RPP', |
|
1419 | + 'Not Completed' => 'RPP', |
|
1420 | + 'Cancelled' => 'RPP', |
|
1421 | + 'Declined' => 'RPP', |
|
1422 | + ); |
|
1423 | + } |
|
1424 | + return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA'; |
|
1425 | + } |
|
1426 | + |
|
1427 | + |
|
1428 | + |
|
1429 | + /** |
|
1430 | + * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event |
|
1431 | + * and sets it as the featured image on the CPT event |
|
1432 | + * |
|
1433 | + * @param type $old_event |
|
1434 | + * @param type $new_cpt_id |
|
1435 | + * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
|
1436 | + * @return boolean whether or not we had to do the big job of creating an image attachment |
|
1437 | + */ |
|
1438 | + public function convert_image_url_to_attachment_and_attach_to_post( |
|
1439 | + $guid, |
|
1440 | + $new_cpt_id, |
|
1441 | + EE_Data_Migration_Script_Stage $migration_stage |
|
1442 | + ) { |
|
1443 | + $created_attachment_post = false; |
|
1444 | + $guid = $this->_get_original_guid($guid); |
|
1445 | + if ($guid) { |
|
1446 | + // check for an existing attachment post with this guid |
|
1447 | + $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
|
1448 | + if (! $attachment_post_id) { |
|
1449 | + // post thumbnail with that GUID doesn't exist, we should create one |
|
1450 | + $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
|
1451 | + $created_attachment_post = true; |
|
1452 | + } |
|
1453 | + // double-check we actually have an attachment post |
|
1454 | + if ($attachment_post_id) { |
|
1455 | + update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1456 | + } else { |
|
1457 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1458 | + "Could not update event image %s for CPT with ID %d, but attachments post ID is %d", |
|
1459 | + "event_espresso" |
|
1460 | + ), $guid, $new_cpt_id, $attachment_post_id)); |
|
1461 | + } |
|
1462 | + } |
|
1463 | + return $created_attachment_post; |
|
1464 | + } |
|
1465 | + |
|
1466 | + |
|
1467 | + |
|
1468 | + /** |
|
1469 | + * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead |
|
1470 | + * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype, |
|
1471 | + * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of |
|
1472 | + * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it |
|
1473 | + * exists |
|
1474 | + * |
|
1475 | + * @param string $guid_in_old_event |
|
1476 | + * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
|
1477 | + */ |
|
1478 | + private function _get_original_guid($guid_in_old_event) |
|
1479 | + { |
|
1480 | + $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1481 | + // do a head request to verify the file exists |
|
1482 | + $head_response = wp_remote_head($original_guid); |
|
1483 | + if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1484 | + return $original_guid; |
|
1485 | + } else { |
|
1486 | + return $guid_in_old_event; |
|
1487 | + } |
|
1488 | + } |
|
1489 | + |
|
1490 | + |
|
1491 | + |
|
1492 | + /** |
|
1493 | + * Creates an image attachment post for the GUID. If the GUID points to a remote image, |
|
1494 | + * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of |
|
1495 | + * thumbnails) |
|
1496 | + * |
|
1497 | + * @param type $guid |
|
1498 | + * @param EE_Data_Migration_Script_Stage $migration_stage |
|
1499 | + * @return int |
|
1500 | + */ |
|
1501 | + private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) |
|
1502 | + { |
|
1503 | + if (! $guid) { |
|
1504 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1505 | + "Cannot create image attachment for a blank GUID!", |
|
1506 | + "event_espresso" |
|
1507 | + ))); |
|
1508 | + return 0; |
|
1509 | + } |
|
1510 | + $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1511 | + $wp_upload_dir = wp_upload_dir(); |
|
1512 | + // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
|
1513 | + if (strpos($guid, $wp_upload_dir['url']) === false) { |
|
1514 | + // image is located remotely. download it and place it in the uploads directory |
|
1515 | + if (! is_readable($guid)) { |
|
1516 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1517 | + "Could not create image attachment from non-existent file: %s", |
|
1518 | + "event_espresso" |
|
1519 | + ), $guid)); |
|
1520 | + return 0; |
|
1521 | + } |
|
1522 | + $contents = file_get_contents($guid); |
|
1523 | + if ($contents === false) { |
|
1524 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1525 | + "Could not read image at %s, and therefore couldnt create an attachment post for it.", |
|
1526 | + "event_espresso" |
|
1527 | + ), $guid)); |
|
1528 | + return false; |
|
1529 | + } |
|
1530 | + $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid); |
|
1531 | + $savefile = fopen($local_filepath, 'w'); |
|
1532 | + fwrite($savefile, $contents); |
|
1533 | + fclose($savefile); |
|
1534 | + $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1535 | + } else { |
|
1536 | + $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1537 | + } |
|
1538 | + $attachment = array( |
|
1539 | + 'guid' => $guid, |
|
1540 | + 'post_mime_type' => $wp_filetype['type'], |
|
1541 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($guid)), |
|
1542 | + 'post_content' => '', |
|
1543 | + 'post_status' => 'inherit', |
|
1544 | + ); |
|
1545 | + $attach_id = wp_insert_attachment($attachment, $guid); |
|
1546 | + if (! $attach_id) { |
|
1547 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1548 | + "Could not create image attachment post from image '%s'. Attachment data was %s.", |
|
1549 | + "event_espresso" |
|
1550 | + ), $guid, $this->_json_encode($attachment))); |
|
1551 | + return $attach_id; |
|
1552 | + } |
|
1553 | + // you must first include the image.php file |
|
1554 | + // for the function wp_generate_attachment_metadata() to work |
|
1555 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1556 | + $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1557 | + if (! $attach_data) { |
|
1558 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1559 | + "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", |
|
1560 | + "event_espresso" |
|
1561 | + ), $attach_id, $local_filepath, $guid)); |
|
1562 | + return $attach_id; |
|
1563 | + } |
|
1564 | + $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1565 | + if (! $metadata_save_result) { |
|
1566 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1567 | + "Could not update attachment metadata for attachment %d with data %s", |
|
1568 | + "event_espresso" |
|
1569 | + ), $attach_id, $this->_json_encode($attach_data))); |
|
1570 | + } |
|
1571 | + return $attach_id; |
|
1572 | + } |
|
1573 | + |
|
1574 | + |
|
1575 | + |
|
1576 | + /** |
|
1577 | + * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself), |
|
1578 | + * and returns its ID. |
|
1579 | + * |
|
1580 | + * @global type $wpdb |
|
1581 | + * @param string $guid |
|
1582 | + * @return int |
|
1583 | + */ |
|
1584 | + private function _get_image_attachment_id_by_GUID($guid) |
|
1585 | + { |
|
1586 | + global $wpdb; |
|
1587 | + $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1588 | + return $attachment_id; |
|
1589 | + } |
|
1590 | + |
|
1591 | + |
|
1592 | + |
|
1593 | + /** |
|
1594 | + * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string |
|
1595 | + * (and optionally a timezone; if none is given, the wp default is used) |
|
1596 | + * |
|
1597 | + * @param EE_Data_Migration_Script_base $stage |
|
1598 | + * @param array $row_of_data , the row from the DB (as an array) we're trying to find the |
|
1599 | + * UTC time for |
|
1600 | + * @param string $DATETIME_string |
|
1601 | + * @param string $timezone |
|
1602 | + * @return string |
|
1603 | + */ |
|
1604 | + public function convert_date_string_to_utc( |
|
1605 | + EE_Data_Migration_Script_Stage $stage, |
|
1606 | + $row_of_data, |
|
1607 | + $DATETIME_string, |
|
1608 | + $timezone = null |
|
1609 | + ) { |
|
1610 | + $original_tz = $timezone; |
|
1611 | + if (! $timezone) { |
|
1612 | + $timezone = $this->_get_wp_timezone(); |
|
1613 | + } |
|
1614 | + if (! $timezone) { |
|
1615 | + $stage->add_error(sprintf( |
|
1616 | + esc_html__("Could not find timezone given %s for %s", "event_espresso"), |
|
1617 | + $original_tz, |
|
1618 | + $row_of_data |
|
1619 | + )); |
|
1620 | + $timezone = 'UTC'; |
|
1621 | + } |
|
1622 | + try { |
|
1623 | + $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1624 | + EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC')); |
|
1625 | + } catch (Exception $e) { |
|
1626 | + $stage->add_error(sprintf(esc_html__( |
|
1627 | + "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", |
|
1628 | + "event_espresso" |
|
1629 | + ), $DATETIME_string, $timezone)); |
|
1630 | + $date_obj = new DateTime(); |
|
1631 | + } |
|
1632 | + return $date_obj->format('Y-m-d H:i:s'); |
|
1633 | + } |
|
1634 | + |
|
1635 | + |
|
1636 | + |
|
1637 | + /** |
|
1638 | + * Gets the default timezone string from wordpress (even if they set a gmt offset) |
|
1639 | + * |
|
1640 | + * @return string |
|
1641 | + */ |
|
1642 | + private function _get_wp_timezone() |
|
1643 | + { |
|
1644 | + $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1645 | + // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
|
1646 | + if (empty($timezone)) { |
|
1647 | + // let's get a the WordPress UTC offset |
|
1648 | + $offset = get_option('gmt_offset'); |
|
1649 | + $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1650 | + } |
|
1651 | + return $timezone; |
|
1652 | + } |
|
1653 | + |
|
1654 | + |
|
1655 | + |
|
1656 | + /** |
|
1657 | + * Gets the wordpress timezone string from a UTC offset |
|
1658 | + * |
|
1659 | + * @param int $offset |
|
1660 | + * @return boolean |
|
1661 | + */ |
|
1662 | + private function timezone_convert_to_string_from_offset($offset) |
|
1663 | + { |
|
1664 | + // shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did not work as expected - its not reliable |
|
1665 | + $offset *= 3600; // convert hour offset to seconds |
|
1666 | + $abbrarray = timezone_abbreviations_list(); |
|
1667 | + foreach ($abbrarray as $abbr) { |
|
1668 | + foreach ($abbr as $city) { |
|
1669 | + if ($city['offset'] == $offset) { |
|
1670 | + return $city['timezone_id']; |
|
1671 | + } |
|
1672 | + } |
|
1673 | + } |
|
1674 | + return false; |
|
1675 | + } |
|
1676 | + |
|
1677 | + |
|
1678 | + |
|
1679 | + public function migration_page_hooks() |
|
1680 | + { |
|
1681 | + add_filter( |
|
1682 | + 'FHEE__ee_migration_page__header', |
|
1683 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1684 | + 10, |
|
1685 | + 3 |
|
1686 | + ); |
|
1687 | + add_filter( |
|
1688 | + 'FHEE__ee_migration_page__p_after_header', |
|
1689 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1690 | + 10, |
|
1691 | + 2 |
|
1692 | + ); |
|
1693 | + add_filter( |
|
1694 | + 'FHEE__ee_migration_page__option_1_main', |
|
1695 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1696 | + 10, |
|
1697 | + 3 |
|
1698 | + ); |
|
1699 | + add_filter( |
|
1700 | + 'FHEE__ee_migration_page__option_1_button_text', |
|
1701 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1702 | + 10, |
|
1703 | + 3 |
|
1704 | + ); |
|
1705 | + add_action( |
|
1706 | + 'AHEE__ee_migration_page__option_1_extra_details', |
|
1707 | + array($this, '_migration_page_hook_option_1_extra_details'), |
|
1708 | + 10, |
|
1709 | + 3 |
|
1710 | + ); |
|
1711 | + add_filter( |
|
1712 | + 'FHEE__ee_migration_page__option_2_main', |
|
1713 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1714 | + 10, |
|
1715 | + 4 |
|
1716 | + ); |
|
1717 | + add_filter( |
|
1718 | + 'FHEE__ee_migration_page__option_2_button_text', |
|
1719 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1720 | + 10, |
|
1721 | + 2 |
|
1722 | + ); |
|
1723 | + add_filter( |
|
1724 | + 'FHEE__ee_migration_page__option_2_details', |
|
1725 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1726 | + 10, |
|
1727 | + 2 |
|
1728 | + ); |
|
1729 | + add_action( |
|
1730 | + 'AHEE__ee_migration_page__after_migration_options_table', |
|
1731 | + array($this, '_migration_page_hook_after_migration_options_table') |
|
1732 | + ); |
|
1733 | + add_filter( |
|
1734 | + 'FHEE__ee_migration_page__done_migration_header', |
|
1735 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1736 | + 10, |
|
1737 | + 2 |
|
1738 | + ); |
|
1739 | + add_filter( |
|
1740 | + 'FHEE__ee_migration_page__p_after_done_migration_header', |
|
1741 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1742 | + 10, |
|
1743 | + 2 |
|
1744 | + ); |
|
1745 | + add_filter( |
|
1746 | + 'FHEE__ee_migration_page__migration_options_template', |
|
1747 | + array($this,'use_migration_options_from_ee3_template') |
|
1748 | + ); |
|
1749 | + } |
|
1750 | + |
|
1751 | + |
|
1752 | + |
|
1753 | + public function _migrate_page_hook_simplify_version_strings( |
|
1754 | + $old_content, |
|
1755 | + $current_db_state, |
|
1756 | + $next_db_state, |
|
1757 | + $ultimate_db_state = null |
|
1758 | + ) { |
|
1759 | + return str_replace( |
|
1760 | + array($current_db_state, $next_db_state, $ultimate_db_state), |
|
1761 | + array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')), |
|
1762 | + $old_content |
|
1763 | + ); |
|
1764 | + } |
|
1765 | + |
|
1766 | + |
|
1767 | + |
|
1768 | + public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) |
|
1769 | + { |
|
1770 | + return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content); |
|
1771 | + } |
|
1772 | + |
|
1773 | + |
|
1774 | + |
|
1775 | + public function _migration_page_hook_option_1_extra_details() |
|
1776 | + { |
|
1777 | + ?> |
|
1778 | 1778 | <p><?php printf(esc_html__( |
1779 | - "Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", |
|
1780 | - "event_espresso" |
|
1781 | - )); ?></p><?php |
|
1782 | - } |
|
1779 | + "Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", |
|
1780 | + "event_espresso" |
|
1781 | + )); ?></p><?php |
|
1782 | + } |
|
1783 | 1783 | |
1784 | 1784 | |
1785 | 1785 | |
1786 | - public function _migration_page_hook_after_migration_options_table() |
|
1787 | - { |
|
1788 | - ?><p class="ee-attention"> |
|
1786 | + public function _migration_page_hook_after_migration_options_table() |
|
1787 | + { |
|
1788 | + ?><p class="ee-attention"> |
|
1789 | 1789 | <strong><span class="reminder-spn"> |
1790 | 1790 | <?php _e( |
1791 | - "Important note to those using Event Espresso 3 addons: ", |
|
1792 | - "event_espresso" |
|
1793 | - ); ?></span></strong> |
|
1791 | + "Important note to those using Event Espresso 3 addons: ", |
|
1792 | + "event_espresso" |
|
1793 | + ); ?></span></strong> |
|
1794 | 1794 | <br/> |
1795 | 1795 | <?php _e( |
1796 | - "Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", |
|
1797 | - "event_espresso" |
|
1798 | - ); ?> |
|
1796 | + "Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", |
|
1797 | + "event_espresso" |
|
1798 | + ); ?> |
|
1799 | 1799 | </p><?php |
1800 | - } |
|
1800 | + } |
|
1801 | 1801 | |
1802 | 1802 | |
1803 | 1803 | |
1804 | - /** |
|
1805 | - * When showing the migration options, show more options and info than normal (ie, give folks the option |
|
1806 | - * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because |
|
1807 | - * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea). |
|
1808 | - * @param $template_filepath |
|
1809 | - * @return string |
|
1810 | - */ |
|
1811 | - public function use_migration_options_from_ee3_template($template_filepath) |
|
1812 | - { |
|
1813 | - return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php'; |
|
1814 | - } |
|
1804 | + /** |
|
1805 | + * When showing the migration options, show more options and info than normal (ie, give folks the option |
|
1806 | + * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because |
|
1807 | + * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea). |
|
1808 | + * @param $template_filepath |
|
1809 | + * @return string |
|
1810 | + */ |
|
1811 | + public function use_migration_options_from_ee3_template($template_filepath) |
|
1812 | + { |
|
1813 | + return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php'; |
|
1814 | + } |
|
1815 | 1815 | } |
@@ -6,16 +6,16 @@ discard block |
||
6 | 6 | <?php if (!is_admin()) : ?> |
7 | 7 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
8 | 8 | <?php echo apply_filters( |
9 | - 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
10 | - sprintf( |
|
11 | - __( |
|
12 | - 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
13 | - 'event_espresso' |
|
14 | - ), |
|
15 | - '<br />', |
|
16 | - '<span class="asterisk">*</span>' |
|
17 | - ) |
|
18 | - ); ?> |
|
9 | + 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
10 | + sprintf( |
|
11 | + __( |
|
12 | + 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
13 | + 'event_espresso' |
|
14 | + ), |
|
15 | + '<br />', |
|
16 | + '<span class="asterisk">*</span>' |
|
17 | + ) |
|
18 | + ); ?> |
|
19 | 19 | </p> |
20 | 20 | <?php endif; ?> |
21 | 21 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $prev_ticket = 0; |
26 | 26 | |
27 | 27 | if (count($registrations) > 0) { |
28 | - ?> |
|
28 | + ?> |
|
29 | 29 | |
30 | 30 | <div id="spco-attendee-panel-dv-single" |
31 | 31 | class="spco-attendee-panel-dv spco-attendee-ticket-single"> |
@@ -40,52 +40,52 @@ discard block |
||
40 | 40 | <th scope="col" width="" class="jst-left"><?php _e('Name and Description', 'event_espresso'); ?></th> |
41 | 41 | <th scope="col" width="7.5%" class="jst-rght"> |
42 | 42 | <?php _e( |
43 | - 'Qty', |
|
44 | - 'event_espresso' |
|
45 | - ); ?></th> |
|
43 | + 'Qty', |
|
44 | + 'event_espresso' |
|
45 | + ); ?></th> |
|
46 | 46 | <th scope="col" width="17.5%" class="jst-rght"> |
47 | 47 | <?php _e( |
48 | - 'Price', |
|
49 | - 'event_espresso' |
|
50 | - ); ?></th> |
|
48 | + 'Price', |
|
49 | + 'event_espresso' |
|
50 | + ); ?></th> |
|
51 | 51 | <th scope="col" width="17.5%" class="jst-rght"> |
52 | 52 | <?php _e( |
53 | - 'Total', |
|
54 | - 'event_espresso' |
|
55 | - ); ?></th> |
|
53 | + 'Total', |
|
54 | + 'event_espresso' |
|
55 | + ); ?></th> |
|
56 | 56 | </tr> |
57 | 57 | </thead> |
58 | 58 | <tbody> |
59 | 59 | <?php |
60 | - // Store previous values to avoid duplicated rows. |
|
61 | - $prev_ticket = 0; |
|
62 | - // Display all tickets inside. |
|
63 | - foreach ($registrations as $registration) { |
|
64 | - if ($registration instanceof EE_Registration) { |
|
65 | - if ($registration->ticket()->ID() !== $prev_ticket) { |
|
66 | - echo $ticket_line_item[ $registration->ticket()->ID() ]; |
|
67 | - } |
|
60 | + // Store previous values to avoid duplicated rows. |
|
61 | + $prev_ticket = 0; |
|
62 | + // Display all tickets inside. |
|
63 | + foreach ($registrations as $registration) { |
|
64 | + if ($registration instanceof EE_Registration) { |
|
65 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
66 | + echo $ticket_line_item[ $registration->ticket()->ID() ]; |
|
67 | + } |
|
68 | 68 | |
69 | - $prev_ticket = $registration->ticket()->ID(); |
|
70 | - } |
|
71 | - } |
|
72 | - ?> |
|
69 | + $prev_ticket = $registration->ticket()->ID(); |
|
70 | + } |
|
71 | + } |
|
72 | + ?> |
|
73 | 73 | </tbody> |
74 | 74 | </table> |
75 | 75 | </div> |
76 | 76 | </div> |
77 | 77 | |
78 | 78 | <?php |
79 | - // Display the forms below the table. |
|
80 | - foreach ($registrations as $registration) { |
|
81 | - if ($registration instanceof EE_Registration) { |
|
82 | - // Attendee Questions. |
|
83 | - $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
84 | - echo ${$reg_form}; |
|
85 | - } // if ( $registration instanceof EE_Registration ) |
|
86 | - } // end foreach ( $registrations as $registration ) |
|
79 | + // Display the forms below the table. |
|
80 | + foreach ($registrations as $registration) { |
|
81 | + if ($registration instanceof EE_Registration) { |
|
82 | + // Attendee Questions. |
|
83 | + $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
84 | + echo ${$reg_form}; |
|
85 | + } // if ( $registration instanceof EE_Registration ) |
|
86 | + } // end foreach ( $registrations as $registration ) |
|
87 | 87 | |
88 | - echo $default_hidden_inputs; |
|
88 | + echo $default_hidden_inputs; |
|
89 | 89 | } // end if ( count( $registrations ) > 0 ) |
90 | 90 | |
91 | 91 | ?> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | /** @var array $ticket_line_item */ |
4 | 4 | /** @var string $default_hidden_inputs */ |
5 | 5 | ?> |
6 | -<?php if (!is_admin()) : ?> |
|
6 | +<?php if ( ! is_admin()) : ?> |
|
7 | 7 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
8 | 8 | <?php echo apply_filters( |
9 | 9 | 'FHEE__registration_page_attendee_information__attendee_information_pg', |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | class="spco-attendee-panel-dv spco-attendee-ticket-single"> |
32 | 32 | |
33 | 33 | <div class="spco-ticket-info-dv small-text"> |
34 | - <?php if (!is_admin()) : ?> |
|
34 | + <?php if ( ! is_admin()) : ?> |
|
35 | 35 | <h5><?php _e('Details', 'event_espresso'); ?></h5> |
36 | 36 | <?php endif; ?> |
37 | 37 | <table class="spco-ticket-details"> |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | foreach ($registrations as $registration) { |
64 | 64 | if ($registration instanceof EE_Registration) { |
65 | 65 | if ($registration->ticket()->ID() !== $prev_ticket) { |
66 | - echo $ticket_line_item[ $registration->ticket()->ID() ]; |
|
66 | + echo $ticket_line_item[$registration->ticket()->ID()]; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $prev_ticket = $registration->ticket()->ID(); |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.3.rc.000'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.3.rc.000'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -13,10 +13,10 @@ |
||
13 | 13 | interface AdminPageHeaderDecoratorInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param string $text |
|
18 | - * @return string |
|
19 | - * @since 4.10.2.p |
|
20 | - */ |
|
21 | - public function getHeaderText($text = ''); |
|
16 | + /** |
|
17 | + * @param string $text |
|
18 | + * @return string |
|
19 | + * @since 4.10.2.p |
|
20 | + */ |
|
21 | + public function getHeaderText($text = ''); |
|
22 | 22 | } |
@@ -24,63 +24,63 @@ |
||
24 | 24 | class EventFilterHeader extends AdminPageHeaderDecorator |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var EEM_Event $event_model |
|
29 | - */ |
|
30 | - private $event_model; |
|
27 | + /** |
|
28 | + * @var EEM_Event $event_model |
|
29 | + */ |
|
30 | + private $event_model; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * EventFilterHeader constructor. |
|
35 | - * |
|
36 | - * @param RequestInterface $request |
|
37 | - * @param EEM_Event $event_model |
|
38 | - */ |
|
39 | - public function __construct(RequestInterface $request, EEM_Event $event_model) |
|
40 | - { |
|
41 | - parent::__construct($request); |
|
42 | - $this->event_model = $event_model; |
|
43 | - } |
|
33 | + /** |
|
34 | + * EventFilterHeader constructor. |
|
35 | + * |
|
36 | + * @param RequestInterface $request |
|
37 | + * @param EEM_Event $event_model |
|
38 | + */ |
|
39 | + public function __construct(RequestInterface $request, EEM_Event $event_model) |
|
40 | + { |
|
41 | + parent::__construct($request); |
|
42 | + $this->event_model = $event_model; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @param string $text |
|
48 | - * @return string |
|
49 | - * @throws EE_Error |
|
50 | - * @throws InvalidDataTypeException |
|
51 | - * @throws InvalidInterfaceException |
|
52 | - * @throws InvalidArgumentException |
|
53 | - * @throws ReflectionException |
|
54 | - * @since 4.10.2.p |
|
55 | - */ |
|
56 | - public function getHeaderText($text = '') |
|
57 | - { |
|
58 | - $EVT_ID = $this->request->getRequestParam('EVT_ID'); |
|
59 | - $EVT_ID = $this->request->getRequestParam('event_id', $EVT_ID); |
|
60 | - $EVT_ID = absint($EVT_ID); |
|
61 | - if ($EVT_ID) { |
|
62 | - $event = $this->event_model->get_one_by_ID($EVT_ID); |
|
63 | - if ($event instanceof EE_Event) { |
|
64 | - $text .= sprintf( |
|
65 | - /* translators: %s: <h3> %s: <a href>Event Name</a> %s: </h3> */ |
|
66 | - // phpcs:ignore WordPress.WP.I18n.UnorderedPlaceholdersText |
|
67 | - esc_html__('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
68 | - '<h3 style="line-height:1.5em;">', |
|
69 | - ' <a href="' |
|
70 | - . EE_Admin_Page::add_query_args_and_nonce( |
|
71 | - array( |
|
72 | - 'action' => 'edit', |
|
73 | - 'post' => $event->ID(), |
|
74 | - ), |
|
75 | - EVENTS_ADMIN_URL |
|
76 | - ) |
|
77 | - . '">' |
|
78 | - . $event->get('EVT_name') |
|
79 | - . '</a> ', |
|
80 | - '</h3>' |
|
81 | - ); |
|
82 | - } |
|
83 | - } |
|
84 | - return $text; |
|
85 | - } |
|
46 | + /** |
|
47 | + * @param string $text |
|
48 | + * @return string |
|
49 | + * @throws EE_Error |
|
50 | + * @throws InvalidDataTypeException |
|
51 | + * @throws InvalidInterfaceException |
|
52 | + * @throws InvalidArgumentException |
|
53 | + * @throws ReflectionException |
|
54 | + * @since 4.10.2.p |
|
55 | + */ |
|
56 | + public function getHeaderText($text = '') |
|
57 | + { |
|
58 | + $EVT_ID = $this->request->getRequestParam('EVT_ID'); |
|
59 | + $EVT_ID = $this->request->getRequestParam('event_id', $EVT_ID); |
|
60 | + $EVT_ID = absint($EVT_ID); |
|
61 | + if ($EVT_ID) { |
|
62 | + $event = $this->event_model->get_one_by_ID($EVT_ID); |
|
63 | + if ($event instanceof EE_Event) { |
|
64 | + $text .= sprintf( |
|
65 | + /* translators: %s: <h3> %s: <a href>Event Name</a> %s: </h3> */ |
|
66 | + // phpcs:ignore WordPress.WP.I18n.UnorderedPlaceholdersText |
|
67 | + esc_html__('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
68 | + '<h3 style="line-height:1.5em;">', |
|
69 | + ' <a href="' |
|
70 | + . EE_Admin_Page::add_query_args_and_nonce( |
|
71 | + array( |
|
72 | + 'action' => 'edit', |
|
73 | + 'post' => $event->ID(), |
|
74 | + ), |
|
75 | + EVENTS_ADMIN_URL |
|
76 | + ) |
|
77 | + . '">' |
|
78 | + . $event->get('EVT_name') |
|
79 | + . '</a> ', |
|
80 | + '</h3>' |
|
81 | + ); |
|
82 | + } |
|
83 | + } |
|
84 | + return $text; |
|
85 | + } |
|
86 | 86 | } |