@@ -622,7 +622,7 @@ |
||
622 | 622 | /** |
623 | 623 | * @param EE_Registration $registration |
624 | 624 | * @param EE_Question $question |
625 | - * @param $answer |
|
625 | + * @param EE_Answer $answer |
|
626 | 626 | * @return EE_Form_Input_Base |
627 | 627 | * @throws EE_Error |
628 | 628 | * @throws InvalidArgumentException |
@@ -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 | } |
@@ -9,27 +9,27 @@ discard block |
||
9 | 9 | <h1><?php _e("Database Update Crash Report Sent", "event_espresso"); ?></h1> |
10 | 10 | <p> |
11 | 11 | <?php _e( |
12 | - "A crash report email was sent to Event Espresso. You should hear back from us soon.", |
|
13 | - "event_espresso" |
|
14 | - ); ?></p> |
|
12 | + "A crash report email was sent to Event Espresso. You should hear back from us soon.", |
|
13 | + "event_espresso" |
|
14 | + ); ?></p> |
|
15 | 15 | <?php } else {// didn't send email properly ?> |
16 | 16 | <h1><?php _e("Migration Report not sent", "event_espresso"); ?></h1> |
17 | 17 | <p> |
18 | 18 | <?php _e( |
19 | - "An error occurred and we were not able to automatically send a report to Event Espresso support.", |
|
20 | - "event_espresso" |
|
21 | - ); ?></p> |
|
19 | + "An error occurred and we were not able to automatically send a report to Event Espresso support.", |
|
20 | + "event_espresso" |
|
21 | + ); ?></p> |
|
22 | 22 | <p> |
23 | 23 | <?php printf( |
24 | - esc_html__("Please copy-and-paste the system information below to %s", "event_espresso"), |
|
25 | - '<a href="mailto:' . EE_SUPPORT_EMAIL . '">' . EE_SUPPORT_EMAIL . "</a>" |
|
26 | - ); ?></p> |
|
24 | + esc_html__("Please copy-and-paste the system information below to %s", "event_espresso"), |
|
25 | + '<a href="mailto:' . EE_SUPPORT_EMAIL . '">' . EE_SUPPORT_EMAIL . "</a>" |
|
26 | + ); ?></p> |
|
27 | 27 | <label> |
28 | 28 | <?php _e("system status info", "event_espresso"); ?> |
29 | 29 | <textarea name="system_status_info" class="system_status_info"> |
30 | 30 | <?php print_r( |
31 | - EEM_System_Status::instance()->get_system_stati() |
|
32 | - ); ?></textarea> |
|
31 | + EEM_System_Status::instance()->get_system_stati() |
|
32 | + ); ?></textarea> |
|
33 | 33 | </label> |
34 | 34 | <?php } ?> |
35 | 35 | |
@@ -50,32 +50,32 @@ discard block |
||
50 | 50 | <td> |
51 | 51 | <p> |
52 | 52 | <?php |
53 | - printf( |
|
54 | - esc_html__( |
|
55 | - 'First, %1$s check the forums %2$s to see if there is a solution before re-attempting the Database Update. Often it helps to deactivate other plugins which may have conflicts; or it may help to add %3$s to your %4$s wp-config.php%5$s (which will make the update run slower, but may resolve any memory exhaustion errors.', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - "<a href='" . EE_SUPPORT_EMAIL . "' target='_blank'>", |
|
59 | - '</a>', |
|
60 | - '<pre lang="php">define( \'EE_MIGRATION_STEP_SIZE\', 10 );</pre>', |
|
61 | - '<b>', |
|
62 | - '</b>' |
|
63 | - ); |
|
64 | - ?> |
|
53 | + printf( |
|
54 | + esc_html__( |
|
55 | + 'First, %1$s check the forums %2$s to see if there is a solution before re-attempting the Database Update. Often it helps to deactivate other plugins which may have conflicts; or it may help to add %3$s to your %4$s wp-config.php%5$s (which will make the update run slower, but may resolve any memory exhaustion errors.', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + "<a href='" . EE_SUPPORT_EMAIL . "' target='_blank'>", |
|
59 | + '</a>', |
|
60 | + '<pre lang="php">define( \'EE_MIGRATION_STEP_SIZE\', 10 );</pre>', |
|
61 | + '<b>', |
|
62 | + '</b>' |
|
63 | + ); |
|
64 | + ?> |
|
65 | 65 | </p> |
66 | 66 | |
67 | 67 | <p> |
68 | 68 | <?php |
69 | - printf( |
|
70 | - esc_html__( |
|
71 | - 'To retry updating your data: restore to the backup you made before the update and reactivate EE (and any addons you are using) and re-run the Database Update. If you did not make a database backup and are migrating from EE3: delete your EE4 data (use the %1$s Reset/Delete Data tab above%2$s), and then reactivate EE4, and then re-run the migration and updates. If you did not make a database backup, are only updating from a previous install of EE4, have found a solution to the fatal error you received, and are willing to possibly have some data lost, %3$sattempt to continue migrating%2$s.', |
|
72 | - 'event_espresso' |
|
73 | - ), |
|
74 | - "<a href='$reset_db_page_url'>", |
|
75 | - "</a>", |
|
76 | - "<a class='button-primary' href='$reattempt_action_url'>" |
|
77 | - ); |
|
78 | - ?> |
|
69 | + printf( |
|
70 | + esc_html__( |
|
71 | + 'To retry updating your data: restore to the backup you made before the update and reactivate EE (and any addons you are using) and re-run the Database Update. If you did not make a database backup and are migrating from EE3: delete your EE4 data (use the %1$s Reset/Delete Data tab above%2$s), and then reactivate EE4, and then re-run the migration and updates. If you did not make a database backup, are only updating from a previous install of EE4, have found a solution to the fatal error you received, and are willing to possibly have some data lost, %3$sattempt to continue migrating%2$s.', |
|
72 | + 'event_espresso' |
|
73 | + ), |
|
74 | + "<a href='$reset_db_page_url'>", |
|
75 | + "</a>", |
|
76 | + "<a class='button-primary' href='$reattempt_action_url'>" |
|
77 | + ); |
|
78 | + ?> |
|
79 | 79 | </p> |
80 | 80 | </td> |
81 | 81 | </tr> |
@@ -85,66 +85,66 @@ discard block |
||
85 | 85 | </td> |
86 | 86 | <td> |
87 | 87 | <?php |
88 | - printf( |
|
89 | - esc_html__( |
|
90 | - 'Just make sure you\'ve %1$s checked for a solution in the forums,%2$s and properly contacted Support. We will get back to you as soon as possible', |
|
91 | - 'event_espresso' |
|
92 | - ), |
|
93 | - "<a href='" . EE_SUPPORT_EMAIL . "'>", |
|
94 | - "</a>" |
|
95 | - ); |
|
96 | - ?> |
|
88 | + printf( |
|
89 | + esc_html__( |
|
90 | + 'Just make sure you\'ve %1$s checked for a solution in the forums,%2$s and properly contacted Support. We will get back to you as soon as possible', |
|
91 | + 'event_espresso' |
|
92 | + ), |
|
93 | + "<a href='" . EE_SUPPORT_EMAIL . "'>", |
|
94 | + "</a>" |
|
95 | + ); |
|
96 | + ?> |
|
97 | 97 | </td> |
98 | 98 | </tr> |
99 | 99 | <tr> |
100 | 100 | <td> |
101 | 101 | <p class='big-text'> |
102 | 102 | <?php printf( |
103 | - esc_html__('I don\'t need my old EE %s data', 'event_espresso'), |
|
104 | - $most_recent_migration->slug() |
|
105 | - ); ?></p> |
|
103 | + esc_html__('I don\'t need my old EE %s data', 'event_espresso'), |
|
104 | + $most_recent_migration->slug() |
|
105 | + ); ?></p> |
|
106 | 106 | </td> |
107 | 107 | <td> |
108 | 108 | <?php |
109 | - printf( |
|
110 | - esc_html__( |
|
111 | - 'If you are ok with losing all the EE %1$s data, you can skip the Database Updates and %2$s use EE4 with only default Data%3$s', |
|
112 | - 'event_espresso' |
|
113 | - ), |
|
114 | - $most_recent_migration->slug(), |
|
115 | - "<a id='do-not-migrate' class='do-not-migrate button-primary' href='$reset_db_action_url'>", |
|
116 | - "</a>" |
|
117 | - ); |
|
118 | - ?> |
|
109 | + printf( |
|
110 | + esc_html__( |
|
111 | + 'If you are ok with losing all the EE %1$s data, you can skip the Database Updates and %2$s use EE4 with only default Data%3$s', |
|
112 | + 'event_espresso' |
|
113 | + ), |
|
114 | + $most_recent_migration->slug(), |
|
115 | + "<a id='do-not-migrate' class='do-not-migrate button-primary' href='$reset_db_action_url'>", |
|
116 | + "</a>" |
|
117 | + ); |
|
118 | + ?> |
|
119 | 119 | </td> |
120 | 120 | </tr> |
121 | 121 | <tr> |
122 | 122 | <td> |
123 | 123 | <p class='big-text'> |
124 | 124 | <?php printf( |
125 | - esc_html__('I want to go back to my old version of EE %1$s', 'event_espresso'), |
|
126 | - $most_recent_migration->slug() |
|
127 | - ); ?> |
|
125 | + esc_html__('I want to go back to my old version of EE %1$s', 'event_espresso'), |
|
126 | + $most_recent_migration->slug() |
|
127 | + ); ?> |
|
128 | 128 | </td> |
129 | 129 | <td> |
130 | 130 | <p> |
131 | 131 | <?php |
132 | - printf( |
|
133 | - esc_html__( |
|
134 | - 'Then we suggest you re-activate the old version of EE %3$s and restore your database to the backup you made just before the Database Update . If you didn\'t backup your database and are migrating from EE3, you can also delete your EE4 data (use on the %1$s"Reset/Delete Data" tab above%2$s), and then reactivate EE3 from the plugins page. Note: some of your EE3 shortcodes may have been changed to their EE4 equivalents, so you will need to change them back.', |
|
135 | - 'event_espresso' |
|
136 | - ), |
|
137 | - "<a href='$reset_db_page_url'>", |
|
138 | - "</a>", |
|
139 | - $most_recent_migration->slug() |
|
140 | - ); |
|
141 | - ?> |
|
132 | + printf( |
|
133 | + esc_html__( |
|
134 | + 'Then we suggest you re-activate the old version of EE %3$s and restore your database to the backup you made just before the Database Update . If you didn\'t backup your database and are migrating from EE3, you can also delete your EE4 data (use on the %1$s"Reset/Delete Data" tab above%2$s), and then reactivate EE3 from the plugins page. Note: some of your EE3 shortcodes may have been changed to their EE4 equivalents, so you will need to change them back.', |
|
135 | + 'event_espresso' |
|
136 | + ), |
|
137 | + "<a href='$reset_db_page_url'>", |
|
138 | + "</a>", |
|
139 | + $most_recent_migration->slug() |
|
140 | + ); |
|
141 | + ?> |
|
142 | 142 | </p> |
143 | 143 | <p> |
144 | 144 | <?php _e( |
145 | - "If you ever decide to re-attempt using EE4, you will again be given the option to migrate your EE3 data or not.", |
|
146 | - 'event_espresso' |
|
147 | - ); ?></p> |
|
145 | + "If you ever decide to re-attempt using EE4, you will again be given the option to migrate your EE3 data or not.", |
|
146 | + 'event_espresso' |
|
147 | + ); ?></p> |
|
148 | 148 | </td> |
149 | 149 | </tr> |
150 | 150 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | <p> |
23 | 23 | <?php printf( |
24 | 24 | esc_html__("Please copy-and-paste the system information below to %s", "event_espresso"), |
25 | - '<a href="mailto:' . EE_SUPPORT_EMAIL . '">' . EE_SUPPORT_EMAIL . "</a>" |
|
25 | + '<a href="mailto:'.EE_SUPPORT_EMAIL.'">'.EE_SUPPORT_EMAIL."</a>" |
|
26 | 26 | ); ?></p> |
27 | 27 | <label> |
28 | 28 | <?php _e("system status info", "event_espresso"); ?> |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'First, %1$s check the forums %2$s to see if there is a solution before re-attempting the Database Update. Often it helps to deactivate other plugins which may have conflicts; or it may help to add %3$s to your %4$s wp-config.php%5$s (which will make the update run slower, but may resolve any memory exhaustion errors.', |
56 | 56 | 'event_espresso' |
57 | 57 | ), |
58 | - "<a href='" . EE_SUPPORT_EMAIL . "' target='_blank'>", |
|
58 | + "<a href='".EE_SUPPORT_EMAIL."' target='_blank'>", |
|
59 | 59 | '</a>', |
60 | 60 | '<pre lang="php">define( \'EE_MIGRATION_STEP_SIZE\', 10 );</pre>', |
61 | 61 | '<b>', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'Just make sure you\'ve %1$s checked for a solution in the forums,%2$s and properly contacted Support. We will get back to you as soon as possible', |
91 | 91 | 'event_espresso' |
92 | 92 | ), |
93 | - "<a href='" . EE_SUPPORT_EMAIL . "'>", |
|
93 | + "<a href='".EE_SUPPORT_EMAIL."'>", |
|
94 | 94 | "</a>" |
95 | 95 | ); |
96 | 96 | ?> |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $input->set_label_sizes(); |
23 | 23 | $label_size_class = $input->get_label_size_class(); |
24 | 24 | $html = ''; |
25 | - if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
25 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
26 | 26 | EE_Error::doing_it_wrong( |
27 | 27 | 'EE_Checkbox_Display_Strategy::display()', |
28 | 28 | sprintf( |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ), |
36 | 36 | $input->html_id(), |
37 | 37 | var_export($input->raw_value(), true), |
38 | - $input->html_name() . '[]' |
|
38 | + $input->html_name().'[]' |
|
39 | 39 | ), |
40 | 40 | '4.8.1' |
41 | 41 | ); |
@@ -54,19 +54,19 @@ discard block |
||
54 | 54 | . '">'; |
55 | 55 | $html .= EEH_HTML::nl(1, 'checkbox'); |
56 | 56 | $html .= '<input type="checkbox"'; |
57 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
58 | - $html .= ' id="' . $html_id . '"'; |
|
59 | - $html .= ' class="' . $input->html_class() . '"'; |
|
60 | - $html .= ' style="' . $input->html_style() . '"'; |
|
61 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
57 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
58 | + $html .= ' id="'.$html_id.'"'; |
|
59 | + $html .= ' class="'.$input->html_class().'"'; |
|
60 | + $html .= ' style="'.$input->html_style().'"'; |
|
61 | + $html .= ' value="'.esc_attr($value).'"'; |
|
62 | 62 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
63 | 63 | ? ' checked="checked"' |
64 | 64 | : ''; |
65 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
66 | - $html .= ' data-question_label="' . $input->html_label_id() . '"'; |
|
65 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
66 | + $html .= ' data-question_label="'.$input->html_label_id().'"'; |
|
67 | 67 | $html .= '> '; |
68 | 68 | $html .= $display_text; |
69 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
69 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
70 | 70 | } |
71 | 71 | return $html; |
72 | 72 | } |
@@ -12,60 +12,60 @@ |
||
12 | 12 | class EE_Checkbox_Display_Strategy extends EE_Compound_Input_Display_Strategy |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @throws EE_Error |
|
17 | - * @return string of html to display the field |
|
18 | - */ |
|
19 | - public function display() |
|
20 | - { |
|
21 | - $input = $this->get_input(); |
|
22 | - $input->set_label_sizes(); |
|
23 | - $label_size_class = $input->get_label_size_class(); |
|
24 | - $html = ''; |
|
25 | - if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
26 | - EE_Error::doing_it_wrong( |
|
27 | - 'EE_Checkbox_Display_Strategy::display()', |
|
28 | - sprintf( |
|
29 | - esc_html_x( |
|
30 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
31 | - 'Input values for checkboxes should be an array of values, but the value for input "form-input-id" is "form-input-value". Please verify that the input name is exactly "form_input_name[]"', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - $input->html_id(), |
|
35 | - var_export($input->raw_value(), true), |
|
36 | - $input->html_name() . '[]' |
|
37 | - ), |
|
38 | - '4.8.1' |
|
39 | - ); |
|
40 | - } |
|
41 | - $input_raw_value = (array) $input->raw_value(); |
|
42 | - foreach ($input->options() as $value => $display_text) { |
|
43 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
44 | - $html_id = $this->get_sub_input_id($value); |
|
45 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
46 | - $html .= '<label for="' |
|
47 | - . $html_id |
|
48 | - . '" id="' |
|
49 | - . $html_id |
|
50 | - . '-lbl" class="ee-checkbox-label-after' |
|
51 | - . $label_size_class |
|
52 | - . '">'; |
|
53 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
54 | - $html .= '<input type="checkbox"'; |
|
55 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
56 | - $html .= ' id="' . $html_id . '"'; |
|
57 | - $html .= ' class="' . $input->html_class() . '"'; |
|
58 | - $html .= ' style="' . $input->html_style() . '"'; |
|
59 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
60 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
61 | - ? ' checked="checked"' |
|
62 | - : ''; |
|
63 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
64 | - $html .= ' data-question_label="' . $input->html_label_id() . '"'; |
|
65 | - $html .= '> '; |
|
66 | - $html .= $display_text; |
|
67 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
68 | - } |
|
69 | - return $html; |
|
70 | - } |
|
15 | + /** |
|
16 | + * @throws EE_Error |
|
17 | + * @return string of html to display the field |
|
18 | + */ |
|
19 | + public function display() |
|
20 | + { |
|
21 | + $input = $this->get_input(); |
|
22 | + $input->set_label_sizes(); |
|
23 | + $label_size_class = $input->get_label_size_class(); |
|
24 | + $html = ''; |
|
25 | + if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
26 | + EE_Error::doing_it_wrong( |
|
27 | + 'EE_Checkbox_Display_Strategy::display()', |
|
28 | + sprintf( |
|
29 | + esc_html_x( |
|
30 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
31 | + 'Input values for checkboxes should be an array of values, but the value for input "form-input-id" is "form-input-value". Please verify that the input name is exactly "form_input_name[]"', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + $input->html_id(), |
|
35 | + var_export($input->raw_value(), true), |
|
36 | + $input->html_name() . '[]' |
|
37 | + ), |
|
38 | + '4.8.1' |
|
39 | + ); |
|
40 | + } |
|
41 | + $input_raw_value = (array) $input->raw_value(); |
|
42 | + foreach ($input->options() as $value => $display_text) { |
|
43 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
44 | + $html_id = $this->get_sub_input_id($value); |
|
45 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
46 | + $html .= '<label for="' |
|
47 | + . $html_id |
|
48 | + . '" id="' |
|
49 | + . $html_id |
|
50 | + . '-lbl" class="ee-checkbox-label-after' |
|
51 | + . $label_size_class |
|
52 | + . '">'; |
|
53 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
54 | + $html .= '<input type="checkbox"'; |
|
55 | + $html .= ' name="' . $input->html_name() . '[]"'; |
|
56 | + $html .= ' id="' . $html_id . '"'; |
|
57 | + $html .= ' class="' . $input->html_class() . '"'; |
|
58 | + $html .= ' style="' . $input->html_style() . '"'; |
|
59 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
60 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
61 | + ? ' checked="checked"' |
|
62 | + : ''; |
|
63 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
64 | + $html .= ' data-question_label="' . $input->html_label_id() . '"'; |
|
65 | + $html .= '> '; |
|
66 | + $html .= $display_text; |
|
67 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
68 | + } |
|
69 | + return $html; |
|
70 | + } |
|
71 | 71 | } |
@@ -18,117 +18,117 @@ |
||
18 | 18 | */ |
19 | 19 | class ExportAttendeeBillingData implements PersonalDataExporterInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @var EEM_Attendee |
|
23 | - */ |
|
24 | - protected $attendee_model; |
|
21 | + /** |
|
22 | + * @var EEM_Attendee |
|
23 | + */ |
|
24 | + protected $attendee_model; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var EEM_Payment_Method |
|
28 | - */ |
|
29 | - protected $payment_method_model; |
|
26 | + /** |
|
27 | + * @var EEM_Payment_Method |
|
28 | + */ |
|
29 | + protected $payment_method_model; |
|
30 | 30 | |
31 | - /** |
|
32 | - * ExportAttendeeBillingData constructor. |
|
33 | - * |
|
34 | - * @param EEM_Attendee $attendee_model |
|
35 | - */ |
|
36 | - public function __construct(EEM_Attendee $attendee_model, EEM_Payment_Method $payment_method_model) |
|
37 | - { |
|
38 | - $this->attendee_model = $attendee_model; |
|
39 | - $this->payment_method_model = $payment_method_model; |
|
40 | - } |
|
31 | + /** |
|
32 | + * ExportAttendeeBillingData constructor. |
|
33 | + * |
|
34 | + * @param EEM_Attendee $attendee_model |
|
35 | + */ |
|
36 | + public function __construct(EEM_Attendee $attendee_model, EEM_Payment_Method $payment_method_model) |
|
37 | + { |
|
38 | + $this->attendee_model = $attendee_model; |
|
39 | + $this->payment_method_model = $payment_method_model; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Returns data for export. |
|
44 | - * |
|
45 | - * @param string $email_address , |
|
46 | - * @param int $page starts at 1, not 0 |
|
47 | - * @return array { |
|
48 | - * @type array $data { |
|
49 | - * @type array { |
|
50 | - * @type string $group_id (not translated, same for all exports) |
|
51 | - * @type string $group_label (translated string) |
|
52 | - * @type string|int $item_id |
|
53 | - * @type array $data { |
|
54 | - * @type array { |
|
55 | - * @type string $name what's shown in the left-column of the export row |
|
56 | - * @type string $value what's showin the right-column of the export row |
|
57 | - * } |
|
58 | - * } |
|
59 | - * } |
|
60 | - * } |
|
61 | - * } |
|
62 | - */ |
|
63 | - public function export($email_address, $page = 1) |
|
64 | - { |
|
65 | - $page_size = 10; |
|
66 | - $attendees = $this->attendee_model->get_all( |
|
67 | - array( |
|
68 | - array( |
|
69 | - 'ATT_email' => $email_address, |
|
70 | - ), |
|
71 | - 'limit' => array( |
|
72 | - ($page - 1) * $page_size, |
|
73 | - $page_size, |
|
74 | - ), |
|
75 | - ) |
|
76 | - ); |
|
77 | - // get all payment methods, even inactive ones |
|
78 | - $payment_methods = $this->payment_method_model->get_all( |
|
79 | - array( |
|
80 | - 'group_by' => array('PMD_type'), |
|
81 | - ) |
|
82 | - ); |
|
83 | - $export_items = array(); |
|
84 | - $found_something = false; |
|
85 | - foreach ($attendees as $attendee) { |
|
86 | - foreach ($payment_methods as $payment_method) { |
|
87 | - try { |
|
88 | - $billing_info = $attendee->billing_info_for_payment_method($payment_method); |
|
89 | - } catch (EE_Error $e) { |
|
90 | - $billing_info = null; |
|
91 | - } |
|
92 | - if (! $billing_info instanceof EE_Form_Section_Proper) { |
|
93 | - continue; |
|
94 | - } |
|
95 | - $found_something = true; |
|
96 | - $data = array(); |
|
97 | - foreach ($billing_info->input_pretty_values(true, true) as $input_name => $display_value) { |
|
98 | - try { |
|
99 | - $input = $billing_info->get_input($input_name); |
|
100 | - $input_display_name = $input->html_label_text(); |
|
101 | - } catch (EE_Error $e) { |
|
102 | - $input_display_name = $input_name; |
|
103 | - } |
|
104 | - $data[] = array( |
|
105 | - 'name' => strip_tags($input_display_name), |
|
106 | - 'value' => $display_value, |
|
107 | - ); |
|
108 | - } |
|
109 | - $export_items[] = array( |
|
110 | - 'group_id' => 'billing_data', |
|
111 | - 'group_label' => esc_html__('Billing Data', 'event_espresso'), |
|
112 | - 'item_id' => $attendee->ID() . '-' . $payment_method->ID(), |
|
113 | - 'data' => $data, |
|
114 | - ); |
|
115 | - } |
|
116 | - } |
|
117 | - return array( |
|
118 | - 'data' => $export_items, |
|
119 | - 'done' => ! $found_something, |
|
120 | - ); |
|
121 | - } |
|
42 | + /** |
|
43 | + * Returns data for export. |
|
44 | + * |
|
45 | + * @param string $email_address , |
|
46 | + * @param int $page starts at 1, not 0 |
|
47 | + * @return array { |
|
48 | + * @type array $data { |
|
49 | + * @type array { |
|
50 | + * @type string $group_id (not translated, same for all exports) |
|
51 | + * @type string $group_label (translated string) |
|
52 | + * @type string|int $item_id |
|
53 | + * @type array $data { |
|
54 | + * @type array { |
|
55 | + * @type string $name what's shown in the left-column of the export row |
|
56 | + * @type string $value what's showin the right-column of the export row |
|
57 | + * } |
|
58 | + * } |
|
59 | + * } |
|
60 | + * } |
|
61 | + * } |
|
62 | + */ |
|
63 | + public function export($email_address, $page = 1) |
|
64 | + { |
|
65 | + $page_size = 10; |
|
66 | + $attendees = $this->attendee_model->get_all( |
|
67 | + array( |
|
68 | + array( |
|
69 | + 'ATT_email' => $email_address, |
|
70 | + ), |
|
71 | + 'limit' => array( |
|
72 | + ($page - 1) * $page_size, |
|
73 | + $page_size, |
|
74 | + ), |
|
75 | + ) |
|
76 | + ); |
|
77 | + // get all payment methods, even inactive ones |
|
78 | + $payment_methods = $this->payment_method_model->get_all( |
|
79 | + array( |
|
80 | + 'group_by' => array('PMD_type'), |
|
81 | + ) |
|
82 | + ); |
|
83 | + $export_items = array(); |
|
84 | + $found_something = false; |
|
85 | + foreach ($attendees as $attendee) { |
|
86 | + foreach ($payment_methods as $payment_method) { |
|
87 | + try { |
|
88 | + $billing_info = $attendee->billing_info_for_payment_method($payment_method); |
|
89 | + } catch (EE_Error $e) { |
|
90 | + $billing_info = null; |
|
91 | + } |
|
92 | + if (! $billing_info instanceof EE_Form_Section_Proper) { |
|
93 | + continue; |
|
94 | + } |
|
95 | + $found_something = true; |
|
96 | + $data = array(); |
|
97 | + foreach ($billing_info->input_pretty_values(true, true) as $input_name => $display_value) { |
|
98 | + try { |
|
99 | + $input = $billing_info->get_input($input_name); |
|
100 | + $input_display_name = $input->html_label_text(); |
|
101 | + } catch (EE_Error $e) { |
|
102 | + $input_display_name = $input_name; |
|
103 | + } |
|
104 | + $data[] = array( |
|
105 | + 'name' => strip_tags($input_display_name), |
|
106 | + 'value' => $display_value, |
|
107 | + ); |
|
108 | + } |
|
109 | + $export_items[] = array( |
|
110 | + 'group_id' => 'billing_data', |
|
111 | + 'group_label' => esc_html__('Billing Data', 'event_espresso'), |
|
112 | + 'item_id' => $attendee->ID() . '-' . $payment_method->ID(), |
|
113 | + 'data' => $data, |
|
114 | + ); |
|
115 | + } |
|
116 | + } |
|
117 | + return array( |
|
118 | + 'data' => $export_items, |
|
119 | + 'done' => ! $found_something, |
|
120 | + ); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Gets the Translated name of this exporter |
|
125 | - * |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public function name() |
|
129 | - { |
|
130 | - return esc_html__('Event Espresso Attendee Billing Data Exporter', 'event_espresso'); |
|
131 | - } |
|
123 | + /** |
|
124 | + * Gets the Translated name of this exporter |
|
125 | + * |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public function name() |
|
129 | + { |
|
130 | + return esc_html__('Event Espresso Attendee Billing Data Exporter', 'event_espresso'); |
|
131 | + } |
|
132 | 132 | } |
133 | 133 | // End of file ExportAttendeeBillingData.php |
134 | 134 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportAttendeeBillingData.php |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } catch (EE_Error $e) { |
90 | 90 | $billing_info = null; |
91 | 91 | } |
92 | - if (! $billing_info instanceof EE_Form_Section_Proper) { |
|
92 | + if ( ! $billing_info instanceof EE_Form_Section_Proper) { |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | $found_something = true; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $export_items[] = array( |
110 | 110 | 'group_id' => 'billing_data', |
111 | 111 | 'group_label' => esc_html__('Billing Data', 'event_espresso'), |
112 | - 'item_id' => $attendee->ID() . '-' . $payment_method->ID(), |
|
112 | + 'item_id' => $attendee->ID().'-'.$payment_method->ID(), |
|
113 | 113 | 'data' => $data, |
114 | 114 | ); |
115 | 115 | } |
@@ -16,88 +16,88 @@ |
||
16 | 16 | */ |
17 | 17 | class EraseAnswers implements PersonalDataEraserInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @var EEM_Answer |
|
21 | - */ |
|
22 | - protected $answer_model; |
|
19 | + /** |
|
20 | + * @var EEM_Answer |
|
21 | + */ |
|
22 | + protected $answer_model; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var EEM_Question |
|
26 | - */ |
|
27 | - protected $question_model; |
|
24 | + /** |
|
25 | + * @var EEM_Question |
|
26 | + */ |
|
27 | + protected $question_model; |
|
28 | 28 | |
29 | - /** |
|
30 | - * EraseAnswers constructor. |
|
31 | - * |
|
32 | - * @param EEM_Answer $answer_model |
|
33 | - * @param EEM_Question $question_model |
|
34 | - */ |
|
35 | - public function __construct(EEM_Answer $answer_model, EEM_Question $question_model) |
|
36 | - { |
|
37 | - $this->answer_model = $answer_model; |
|
38 | - $this->question_model = $question_model; |
|
39 | - } |
|
29 | + /** |
|
30 | + * EraseAnswers constructor. |
|
31 | + * |
|
32 | + * @param EEM_Answer $answer_model |
|
33 | + * @param EEM_Question $question_model |
|
34 | + */ |
|
35 | + public function __construct(EEM_Answer $answer_model, EEM_Question $question_model) |
|
36 | + { |
|
37 | + $this->answer_model = $answer_model; |
|
38 | + $this->question_model = $question_model; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * Gets a translated string name for the data eraser |
|
44 | - * |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function name() |
|
48 | - { |
|
49 | - return esc_html__('Event Espresso Registration Answers', 'event_espresso'); |
|
50 | - } |
|
42 | + /** |
|
43 | + * Gets a translated string name for the data eraser |
|
44 | + * |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function name() |
|
48 | + { |
|
49 | + return esc_html__('Event Espresso Registration Answers', 'event_espresso'); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Erases a "page" of personal user data |
|
54 | - * |
|
55 | - * @return array { |
|
56 | - * @type boolean $items_removed whether items were removed successfully or not |
|
57 | - * @type boolean $items_retained whether any items were skipped or not |
|
58 | - * @type array $messages values are messages to show |
|
59 | - * @type boolean $done whether this eraser is done or has more pages |
|
60 | - * } |
|
61 | - */ |
|
62 | - public function erase($email_address, $page = 1) |
|
63 | - { |
|
64 | - $multi_answer_enum_question_types = $this->question_model->question_types_in_category('multi-answer-enum'); |
|
65 | - $normal_questions_updated = $this->answer_model->update( |
|
66 | - array( |
|
67 | - 'ANS_value' => '', |
|
68 | - ), |
|
69 | - array( |
|
70 | - array( |
|
71 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
72 | - 'Question.QST_type' => array( |
|
73 | - 'NOT_IN', |
|
74 | - $multi_answer_enum_question_types, |
|
75 | - ), |
|
76 | - ), |
|
77 | - ) |
|
78 | - ); |
|
79 | - $multi_value_questions_updated = $this->answer_model->update( |
|
80 | - array( |
|
81 | - 'ANS_value' => array(), |
|
82 | - ), |
|
83 | - array( |
|
84 | - array( |
|
85 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
86 | - 'Question.QST_type' => array( |
|
87 | - 'IN', |
|
88 | - $multi_answer_enum_question_types, |
|
89 | - ), |
|
90 | - ), |
|
91 | - ) |
|
92 | - ); |
|
52 | + /** |
|
53 | + * Erases a "page" of personal user data |
|
54 | + * |
|
55 | + * @return array { |
|
56 | + * @type boolean $items_removed whether items were removed successfully or not |
|
57 | + * @type boolean $items_retained whether any items were skipped or not |
|
58 | + * @type array $messages values are messages to show |
|
59 | + * @type boolean $done whether this eraser is done or has more pages |
|
60 | + * } |
|
61 | + */ |
|
62 | + public function erase($email_address, $page = 1) |
|
63 | + { |
|
64 | + $multi_answer_enum_question_types = $this->question_model->question_types_in_category('multi-answer-enum'); |
|
65 | + $normal_questions_updated = $this->answer_model->update( |
|
66 | + array( |
|
67 | + 'ANS_value' => '', |
|
68 | + ), |
|
69 | + array( |
|
70 | + array( |
|
71 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
72 | + 'Question.QST_type' => array( |
|
73 | + 'NOT_IN', |
|
74 | + $multi_answer_enum_question_types, |
|
75 | + ), |
|
76 | + ), |
|
77 | + ) |
|
78 | + ); |
|
79 | + $multi_value_questions_updated = $this->answer_model->update( |
|
80 | + array( |
|
81 | + 'ANS_value' => array(), |
|
82 | + ), |
|
83 | + array( |
|
84 | + array( |
|
85 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
86 | + 'Question.QST_type' => array( |
|
87 | + 'IN', |
|
88 | + $multi_answer_enum_question_types, |
|
89 | + ), |
|
90 | + ), |
|
91 | + ) |
|
92 | + ); |
|
93 | 93 | |
94 | - return array( |
|
95 | - 'items_removed' => (bool) $normal_questions_updated || (bool) $multi_value_questions_updated, |
|
96 | - 'items_retained' => false, // always false in this example |
|
97 | - 'messages' => array(), // no messages in this example |
|
98 | - 'done' => true, |
|
99 | - ); |
|
100 | - } |
|
94 | + return array( |
|
95 | + 'items_removed' => (bool) $normal_questions_updated || (bool) $multi_value_questions_updated, |
|
96 | + 'items_retained' => false, // always false in this example |
|
97 | + 'messages' => array(), // no messages in this example |
|
98 | + 'done' => true, |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | // End of file EraseAnswers.php |
103 | 103 | // Location: EventEspresso\core\domain\services\privacy\erasure/EraseAnswers.php |
@@ -13,55 +13,55 @@ |
||
13 | 13 | class EE_Register_Privacy_Policy implements EEI_Plugin_API |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * FQCN for all privacy policy generators |
|
18 | - * |
|
19 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
20 | - */ |
|
21 | - protected static $privacy_policies = array(); |
|
16 | + /** |
|
17 | + * FQCN for all privacy policy generators |
|
18 | + * |
|
19 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
20 | + */ |
|
21 | + protected static $privacy_policies = array(); |
|
22 | 22 | |
23 | 23 | |
24 | - /* |
|
24 | + /* |
|
25 | 25 | * @param string $plugin_id |
26 | 26 | * @param array $FQNSs can be the fully qualified namespaces each containing only privacy policies, |
27 | 27 | * OR fully qualified class names of privacy policies |
28 | 28 | */ |
29 | - public static function register($plugin_id = null, $FQCNs = array()) |
|
30 | - { |
|
31 | - self::$privacy_policies[ $plugin_id ] = $FQCNs; |
|
32 | - // add to list of modules to be registered |
|
33 | - add_filter( |
|
34 | - 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
35 | - array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
36 | - ); |
|
37 | - } |
|
29 | + public static function register($plugin_id = null, $FQCNs = array()) |
|
30 | + { |
|
31 | + self::$privacy_policies[ $plugin_id ] = $FQCNs; |
|
32 | + // add to list of modules to be registered |
|
33 | + add_filter( |
|
34 | + 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
35 | + array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
36 | + ); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param null $ID |
|
42 | - */ |
|
43 | - public static function deregister($ID = null) |
|
44 | - { |
|
45 | - unset(self::$privacy_policies[ $ID ]); |
|
46 | - } |
|
40 | + /** |
|
41 | + * @param null $ID |
|
42 | + */ |
|
43 | + public static function deregister($ID = null) |
|
44 | + { |
|
45 | + unset(self::$privacy_policies[ $ID ]); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Adds our privacy policiy generators registered by add-ons |
|
51 | - * |
|
52 | - * @param string[] $privacy_policies |
|
53 | - * @return string[] |
|
54 | - */ |
|
55 | - public static function addPrivacyPolicies(array $privacy_policies) |
|
56 | - { |
|
57 | - foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
58 | - $privacy_policies = array_merge( |
|
59 | - $privacy_policies, |
|
60 | - $privacy_policies_per_addon |
|
61 | - ); |
|
62 | - } |
|
63 | - return $privacy_policies; |
|
64 | - } |
|
49 | + /** |
|
50 | + * Adds our privacy policiy generators registered by add-ons |
|
51 | + * |
|
52 | + * @param string[] $privacy_policies |
|
53 | + * @return string[] |
|
54 | + */ |
|
55 | + public static function addPrivacyPolicies(array $privacy_policies) |
|
56 | + { |
|
57 | + foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
58 | + $privacy_policies = array_merge( |
|
59 | + $privacy_policies, |
|
60 | + $privacy_policies_per_addon |
|
61 | + ); |
|
62 | + } |
|
63 | + return $privacy_policies; |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | // End of file EE_Register_Privacy_Policy.lib.php |
67 | 67 | // Location: ${NAMESPACE}/EE_Register_Privacy_Policy.lib.php |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function register($plugin_id = null, $FQCNs = array()) |
30 | 30 | { |
31 | - self::$privacy_policies[ $plugin_id ] = $FQCNs; |
|
31 | + self::$privacy_policies[$plugin_id] = $FQCNs; |
|
32 | 32 | // add to list of modules to be registered |
33 | 33 | add_filter( |
34 | 34 | 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function deregister($ID = null) |
44 | 44 | { |
45 | - unset(self::$privacy_policies[ $ID ]); |
|
45 | + unset(self::$privacy_policies[$ID]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -13,55 +13,55 @@ |
||
13 | 13 | class EE_Register_Personal_Data_Eraser implements EEI_Plugin_API |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * FQCN for all privacy policy generators |
|
18 | - * |
|
19 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
20 | - */ |
|
21 | - protected static $erasers = array(); |
|
16 | + /** |
|
17 | + * FQCN for all privacy policy generators |
|
18 | + * |
|
19 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
20 | + */ |
|
21 | + protected static $erasers = array(); |
|
22 | 22 | |
23 | 23 | |
24 | - /* |
|
24 | + /* |
|
25 | 25 | * @param string $plugin_id |
26 | 26 | * @param array $FQNSs can be the fully qualified namespaces each containing only privacy policies, |
27 | 27 | * OR fully qualified class names of privacy policies |
28 | 28 | */ |
29 | - public static function register($plugin_id = null, $FQCNs = array()) |
|
30 | - { |
|
31 | - self::$erasers[ $plugin_id ] = $FQCNs; |
|
32 | - // add to list of modules to be registered |
|
33 | - add_filter( |
|
34 | - 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
35 | - array('EE_Register_Personal_Data_Eraser', 'addErasers') |
|
36 | - ); |
|
37 | - } |
|
29 | + public static function register($plugin_id = null, $FQCNs = array()) |
|
30 | + { |
|
31 | + self::$erasers[ $plugin_id ] = $FQCNs; |
|
32 | + // add to list of modules to be registered |
|
33 | + add_filter( |
|
34 | + 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
35 | + array('EE_Register_Personal_Data_Eraser', 'addErasers') |
|
36 | + ); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param null $ID |
|
42 | - */ |
|
43 | - public static function deregister($ID = null) |
|
44 | - { |
|
45 | - unset(self::$erasers[ $ID ]); |
|
46 | - } |
|
40 | + /** |
|
41 | + * @param null $ID |
|
42 | + */ |
|
43 | + public static function deregister($ID = null) |
|
44 | + { |
|
45 | + unset(self::$erasers[ $ID ]); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Adds our personal data erasers registered by add-ons |
|
51 | - * |
|
52 | - * @param string[] $erasers |
|
53 | - * @return string[] |
|
54 | - */ |
|
55 | - public static function addErasers(array $erasers) |
|
56 | - { |
|
57 | - foreach (self::$erasers as $erasers_per_addon) { |
|
58 | - $erasers = array_merge( |
|
59 | - $erasers, |
|
60 | - $erasers_per_addon |
|
61 | - ); |
|
62 | - } |
|
63 | - return $erasers; |
|
64 | - } |
|
49 | + /** |
|
50 | + * Adds our personal data erasers registered by add-ons |
|
51 | + * |
|
52 | + * @param string[] $erasers |
|
53 | + * @return string[] |
|
54 | + */ |
|
55 | + public static function addErasers(array $erasers) |
|
56 | + { |
|
57 | + foreach (self::$erasers as $erasers_per_addon) { |
|
58 | + $erasers = array_merge( |
|
59 | + $erasers, |
|
60 | + $erasers_per_addon |
|
61 | + ); |
|
62 | + } |
|
63 | + return $erasers; |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | // End of file EE_Register_Personal_Data_Eraser.lib.php |
67 | 67 | // Location: ${NAMESPACE}/EE_Register_Personal_Data_Eraser.lib.php |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function register($plugin_id = null, $FQCNs = array()) |
30 | 30 | { |
31 | - self::$erasers[ $plugin_id ] = $FQCNs; |
|
31 | + self::$erasers[$plugin_id] = $FQCNs; |
|
32 | 32 | // add to list of modules to be registered |
33 | 33 | add_filter( |
34 | 34 | 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function deregister($ID = null) |
44 | 44 | { |
45 | - unset(self::$erasers[ $ID ]); |
|
45 | + unset(self::$erasers[$ID]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -13,55 +13,55 @@ |
||
13 | 13 | class EE_Register_Personal_Data_Exporter implements EEI_Plugin_API |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * FQCN for all privacy policy generators |
|
18 | - * |
|
19 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
20 | - */ |
|
21 | - protected static $exporters = array(); |
|
16 | + /** |
|
17 | + * FQCN for all privacy policy generators |
|
18 | + * |
|
19 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
20 | + */ |
|
21 | + protected static $exporters = array(); |
|
22 | 22 | |
23 | 23 | |
24 | - /* |
|
24 | + /* |
|
25 | 25 | * @param string $plugin_id |
26 | 26 | * @param array $FQNSs can be the fully qualified namespaces each containing only privacy policies, |
27 | 27 | * OR fully qualified class names of privacy policies |
28 | 28 | */ |
29 | - public static function register($plugin_id = null, $FQCNs = array()) |
|
30 | - { |
|
31 | - self::$exporters[ $plugin_id ] = $FQCNs; |
|
32 | - // add to list of modules to be registered |
|
33 | - add_filter( |
|
34 | - 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
35 | - array('EE_Register_Personal_Data_Exporter', 'addExporters') |
|
36 | - ); |
|
37 | - } |
|
29 | + public static function register($plugin_id = null, $FQCNs = array()) |
|
30 | + { |
|
31 | + self::$exporters[ $plugin_id ] = $FQCNs; |
|
32 | + // add to list of modules to be registered |
|
33 | + add_filter( |
|
34 | + 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
35 | + array('EE_Register_Personal_Data_Exporter', 'addExporters') |
|
36 | + ); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param null $ID |
|
42 | - */ |
|
43 | - public static function deregister($ID = null) |
|
44 | - { |
|
45 | - unset(self::$exporters[ $ID ]); |
|
46 | - } |
|
40 | + /** |
|
41 | + * @param null $ID |
|
42 | + */ |
|
43 | + public static function deregister($ID = null) |
|
44 | + { |
|
45 | + unset(self::$exporters[ $ID ]); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Adds our personal data exporters registered by add-ons |
|
51 | - * |
|
52 | - * @param string[] $exporters |
|
53 | - * @return string[] |
|
54 | - */ |
|
55 | - public static function addExporters(array $exporters) |
|
56 | - { |
|
57 | - foreach (self::$exporters as $exporters_per_addon) { |
|
58 | - $exporters = array_merge( |
|
59 | - $exporters, |
|
60 | - $exporters_per_addon |
|
61 | - ); |
|
62 | - } |
|
63 | - return $exporters; |
|
64 | - } |
|
49 | + /** |
|
50 | + * Adds our personal data exporters registered by add-ons |
|
51 | + * |
|
52 | + * @param string[] $exporters |
|
53 | + * @return string[] |
|
54 | + */ |
|
55 | + public static function addExporters(array $exporters) |
|
56 | + { |
|
57 | + foreach (self::$exporters as $exporters_per_addon) { |
|
58 | + $exporters = array_merge( |
|
59 | + $exporters, |
|
60 | + $exporters_per_addon |
|
61 | + ); |
|
62 | + } |
|
63 | + return $exporters; |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | // End of file EE_Register_Personal_Data_Exporter.lib.php |
67 | 67 | // Location: ${NAMESPACE}/EE_Register_Personal_Data_Exporter.lib.php |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function register($plugin_id = null, $FQCNs = array()) |
30 | 30 | { |
31 | - self::$exporters[ $plugin_id ] = $FQCNs; |
|
31 | + self::$exporters[$plugin_id] = $FQCNs; |
|
32 | 32 | // add to list of modules to be registered |
33 | 33 | add_filter( |
34 | 34 | 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function deregister($ID = null) |
44 | 44 | { |
45 | - unset(self::$exporters[ $ID ]); |
|
45 | + unset(self::$exporters[$ID]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -14,35 +14,35 @@ |
||
14 | 14 | */ |
15 | 15 | interface PersonalDataExporterInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * Gets the Translated name of this exporter |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function name(); |
|
17 | + /** |
|
18 | + * Gets the Translated name of this exporter |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function name(); |
|
23 | 23 | |
24 | - /** |
|
25 | - * Returns data for export. |
|
26 | - * |
|
27 | - * @param string $email_address , |
|
28 | - * @param int $page starts at 1, not 0 |
|
29 | - * @return array { |
|
30 | - * @type array $data { |
|
31 | - * @type array { |
|
32 | - * @type string $group_id (not translated, same for all exports) |
|
33 | - * @type string $group_label (translated string) |
|
34 | - * @type string|int $item_id |
|
35 | - * @type array $data { |
|
36 | - * @type array { |
|
37 | - * @type string $name what's shown in the left-column of the export row |
|
38 | - * @type string $value what's showin the right-column of the export row |
|
39 | - * } |
|
40 | - * } |
|
41 | - * } |
|
42 | - * } |
|
43 | - * } |
|
44 | - */ |
|
45 | - public function export($email_address, $page = 1); |
|
24 | + /** |
|
25 | + * Returns data for export. |
|
26 | + * |
|
27 | + * @param string $email_address , |
|
28 | + * @param int $page starts at 1, not 0 |
|
29 | + * @return array { |
|
30 | + * @type array $data { |
|
31 | + * @type array { |
|
32 | + * @type string $group_id (not translated, same for all exports) |
|
33 | + * @type string $group_label (translated string) |
|
34 | + * @type string|int $item_id |
|
35 | + * @type array $data { |
|
36 | + * @type array { |
|
37 | + * @type string $name what's shown in the left-column of the export row |
|
38 | + * @type string $value what's showin the right-column of the export row |
|
39 | + * } |
|
40 | + * } |
|
41 | + * } |
|
42 | + * } |
|
43 | + * } |
|
44 | + */ |
|
45 | + public function export($email_address, $page = 1); |
|
46 | 46 | } |
47 | 47 | // End of file PersonalDataExporterInterface.php |
48 | 48 | // Location: EventEspresso\core\domain\services\admin/PersonalDataExporterInterface.php |