@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -25,1090 +25,1090 @@ discard block |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @Constructor |
|
30 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
31 | - * @access public |
|
32 | - */ |
|
33 | - public function __construct($routing = true) |
|
34 | - { |
|
35 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS); |
|
36 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS); |
|
37 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
38 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS); |
|
39 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
40 | - parent::__construct($routing); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - protected function _extend_page_config() |
|
45 | - { |
|
46 | - $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
47 | - $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
48 | - $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0; |
|
49 | - |
|
50 | - $new_page_routes = array( |
|
51 | - 'question_groups' => array( |
|
52 | - 'func' => '_question_groups_overview_list_table', |
|
53 | - 'capability' => 'ee_read_question_groups', |
|
54 | - ), |
|
55 | - 'add_question' => array( |
|
56 | - 'func' => '_edit_question', |
|
57 | - 'capability' => 'ee_edit_questions', |
|
58 | - ), |
|
59 | - 'insert_question' => array( |
|
60 | - 'func' => '_insert_or_update_question', |
|
61 | - 'args' => array('new_question' => true), |
|
62 | - 'capability' => 'ee_edit_questions', |
|
63 | - 'noheader' => true, |
|
64 | - ), |
|
65 | - 'duplicate_question' => array( |
|
66 | - 'func' => '_duplicate_question', |
|
67 | - 'capability' => 'ee_edit_questions', |
|
68 | - 'noheader' => true, |
|
69 | - ), |
|
70 | - 'trash_question' => array( |
|
71 | - 'func' => '_trash_question', |
|
72 | - 'capability' => 'ee_delete_question', |
|
73 | - 'obj_id' => $qst_id, |
|
74 | - 'noheader' => true, |
|
75 | - ), |
|
76 | - |
|
77 | - 'restore_question' => array( |
|
78 | - 'func' => '_trash_or_restore_questions', |
|
79 | - 'capability' => 'ee_delete_question', |
|
80 | - 'obj_id' => $qst_id, |
|
81 | - 'args' => array('trash' => false), |
|
82 | - 'noheader' => true, |
|
83 | - ), |
|
84 | - |
|
85 | - 'delete_question' => array( |
|
86 | - 'func' => '_delete_question', |
|
87 | - 'capability' => 'ee_delete_question', |
|
88 | - 'obj_id' => $qst_id, |
|
89 | - 'noheader' => true, |
|
90 | - ), |
|
91 | - |
|
92 | - 'trash_questions' => array( |
|
93 | - 'func' => '_trash_or_restore_questions', |
|
94 | - 'capability' => 'ee_delete_questions', |
|
95 | - 'args' => array('trash' => true), |
|
96 | - 'noheader' => true, |
|
97 | - ), |
|
98 | - |
|
99 | - 'restore_questions' => array( |
|
100 | - 'func' => '_trash_or_restore_questions', |
|
101 | - 'capability' => 'ee_delete_questions', |
|
102 | - 'args' => array('trash' => false), |
|
103 | - 'noheader' => true, |
|
104 | - ), |
|
105 | - |
|
106 | - 'delete_questions' => array( |
|
107 | - 'func' => '_delete_questions', |
|
108 | - 'args' => array(), |
|
109 | - 'capability' => 'ee_delete_questions', |
|
110 | - 'noheader' => true, |
|
111 | - ), |
|
112 | - |
|
113 | - 'add_question_group' => array( |
|
114 | - 'func' => '_edit_question_group', |
|
115 | - 'capability' => 'ee_edit_question_groups', |
|
116 | - ), |
|
117 | - |
|
118 | - 'edit_question_group' => array( |
|
119 | - 'func' => '_edit_question_group', |
|
120 | - 'capability' => 'ee_edit_question_group', |
|
121 | - 'obj_id' => $qsg_id, |
|
122 | - 'args' => array('edit'), |
|
123 | - ), |
|
124 | - |
|
125 | - 'delete_question_groups' => array( |
|
126 | - 'func' => '_delete_question_groups', |
|
127 | - 'capability' => 'ee_delete_question_groups', |
|
128 | - 'noheader' => true, |
|
129 | - ), |
|
130 | - |
|
131 | - 'delete_question_group' => array( |
|
132 | - 'func' => '_delete_question_groups', |
|
133 | - 'capability' => 'ee_delete_question_group', |
|
134 | - 'obj_id' => $qsg_id, |
|
135 | - 'noheader' => true, |
|
136 | - ), |
|
137 | - |
|
138 | - 'trash_question_group' => array( |
|
139 | - 'func' => '_trash_or_restore_question_groups', |
|
140 | - 'args' => array('trash' => true), |
|
141 | - 'capability' => 'ee_delete_question_group', |
|
142 | - 'obj_id' => $qsg_id, |
|
143 | - 'noheader' => true, |
|
144 | - ), |
|
145 | - |
|
146 | - 'restore_question_group' => array( |
|
147 | - 'func' => '_trash_or_restore_question_groups', |
|
148 | - 'args' => array('trash' => false), |
|
149 | - 'capability' => 'ee_delete_question_group', |
|
150 | - 'obj_id' => $qsg_id, |
|
151 | - 'noheader' => true, |
|
152 | - ), |
|
153 | - |
|
154 | - 'insert_question_group' => array( |
|
155 | - 'func' => '_insert_or_update_question_group', |
|
156 | - 'args' => array('new_question_group' => true), |
|
157 | - 'capability' => 'ee_edit_question_groups', |
|
158 | - 'noheader' => true, |
|
159 | - ), |
|
160 | - |
|
161 | - 'update_question_group' => array( |
|
162 | - 'func' => '_insert_or_update_question_group', |
|
163 | - 'args' => array('new_question_group' => false), |
|
164 | - 'capability' => 'ee_edit_question_group', |
|
165 | - 'obj_id' => $qsg_id, |
|
166 | - 'noheader' => true, |
|
167 | - ), |
|
168 | - |
|
169 | - 'trash_question_groups' => array( |
|
170 | - 'func' => '_trash_or_restore_question_groups', |
|
171 | - 'args' => array('trash' => true), |
|
172 | - 'capability' => 'ee_delete_question_groups', |
|
173 | - 'noheader' => array('trash' => false), |
|
174 | - ), |
|
175 | - |
|
176 | - 'restore_question_groups' => array( |
|
177 | - 'func' => '_trash_or_restore_question_groups', |
|
178 | - 'args' => array('trash' => false), |
|
179 | - 'capability' => 'ee_delete_question_groups', |
|
180 | - 'noheader' => true, |
|
181 | - ), |
|
182 | - |
|
183 | - |
|
184 | - 'espresso_update_question_group_order' => array( |
|
185 | - 'func' => 'update_question_group_order', |
|
186 | - 'capability' => 'ee_edit_question_groups', |
|
187 | - 'noheader' => true, |
|
188 | - ), |
|
189 | - |
|
190 | - 'view_reg_form_settings' => array( |
|
191 | - 'func' => '_reg_form_settings', |
|
192 | - 'capability' => 'manage_options', |
|
193 | - ), |
|
194 | - |
|
195 | - 'update_reg_form_settings' => array( |
|
196 | - 'func' => '_update_reg_form_settings', |
|
197 | - 'capability' => 'manage_options', |
|
198 | - 'noheader' => true, |
|
199 | - ), |
|
200 | - ); |
|
201 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
202 | - |
|
203 | - $new_page_config = array( |
|
204 | - |
|
205 | - 'question_groups' => array( |
|
206 | - 'nav' => array( |
|
207 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
208 | - 'order' => 20, |
|
209 | - ), |
|
210 | - 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
211 | - 'help_tabs' => array( |
|
212 | - 'registration_form_question_groups_help_tab' => array( |
|
213 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
214 | - 'filename' => 'registration_form_question_groups', |
|
215 | - ), |
|
216 | - 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
217 | - 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
218 | - 'filename' => 'registration_form_question_groups_table_column_headings', |
|
219 | - ), |
|
220 | - 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
221 | - 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
222 | - 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
223 | - ), |
|
224 | - ), |
|
225 | - 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
226 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
227 | - 'require_nonce' => false, |
|
228 | - 'qtips' => array( |
|
229 | - 'EE_Registration_Form_Tips', |
|
230 | - ), |
|
231 | - ), |
|
232 | - |
|
233 | - 'add_question' => array( |
|
234 | - 'nav' => array( |
|
235 | - 'label' => esc_html__('Add Question', 'event_espresso'), |
|
236 | - 'order' => 5, |
|
237 | - 'persistent' => false, |
|
238 | - ), |
|
239 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
240 | - 'help_tabs' => array( |
|
241 | - 'registration_form_add_question_help_tab' => array( |
|
242 | - 'title' => esc_html__('Add Question', 'event_espresso'), |
|
243 | - 'filename' => 'registration_form_add_question', |
|
244 | - ), |
|
245 | - ), |
|
246 | - 'help_tour' => array('Registration_Form_Add_Question_Help_Tour'), |
|
247 | - 'require_nonce' => false, |
|
248 | - ), |
|
249 | - |
|
250 | - 'add_question_group' => array( |
|
251 | - 'nav' => array( |
|
252 | - 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
253 | - 'order' => 5, |
|
254 | - 'persistent' => false, |
|
255 | - ), |
|
256 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
257 | - 'help_tabs' => array( |
|
258 | - 'registration_form_add_question_group_help_tab' => array( |
|
259 | - 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
260 | - 'filename' => 'registration_form_add_question_group', |
|
261 | - ), |
|
262 | - ), |
|
263 | - 'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'), |
|
264 | - 'require_nonce' => false, |
|
265 | - ), |
|
266 | - |
|
267 | - 'edit_question_group' => array( |
|
268 | - 'nav' => array( |
|
269 | - 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
270 | - 'order' => 5, |
|
271 | - 'persistent' => false, |
|
272 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']), |
|
273 | - $this->_current_page_view_url) : $this->_admin_base_url, |
|
274 | - ), |
|
275 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
276 | - 'help_tabs' => array( |
|
277 | - 'registration_form_edit_question_group_help_tab' => array( |
|
278 | - 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
279 | - 'filename' => 'registration_form_edit_question_group', |
|
280 | - ), |
|
281 | - ), |
|
282 | - 'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'), |
|
283 | - 'require_nonce' => false, |
|
284 | - ), |
|
285 | - |
|
286 | - 'view_reg_form_settings' => array( |
|
287 | - 'nav' => array( |
|
288 | - 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
289 | - 'order' => 40, |
|
290 | - ), |
|
291 | - 'labels' => array( |
|
292 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
293 | - ), |
|
294 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
295 | - 'help_tabs' => array( |
|
296 | - 'registration_form_reg_form_settings_help_tab' => array( |
|
297 | - 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
298 | - 'filename' => 'registration_form_reg_form_settings', |
|
299 | - ), |
|
300 | - ), |
|
301 | - 'help_tour' => array('Registration_Form_Settings_Help_Tour'), |
|
302 | - 'require_nonce' => false, |
|
303 | - ), |
|
304 | - |
|
305 | - ); |
|
306 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
307 | - |
|
308 | - //change the list table we're going to use so it's the NEW list table! |
|
309 | - $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
310 | - |
|
311 | - |
|
312 | - //additional labels |
|
313 | - $new_labels = array( |
|
314 | - 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
315 | - 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
316 | - 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
317 | - 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
318 | - 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
319 | - ); |
|
320 | - $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
321 | - |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - protected function _ajax_hooks() |
|
326 | - { |
|
327 | - add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - public function load_scripts_styles_question_groups() |
|
332 | - { |
|
333 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - public function load_scripts_styles_add_question_group() |
|
338 | - { |
|
339 | - $this->load_scripts_styles_forms(); |
|
340 | - $this->load_sortable_question_script(); |
|
341 | - } |
|
342 | - |
|
343 | - public function load_scripts_styles_edit_question_group() |
|
344 | - { |
|
345 | - $this->load_scripts_styles_forms(); |
|
346 | - $this->load_sortable_question_script(); |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * registers and enqueues script for questions |
|
352 | - * |
|
353 | - * @return void |
|
354 | - */ |
|
355 | - public function load_sortable_question_script() |
|
356 | - { |
|
357 | - wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
358 | - array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
359 | - wp_enqueue_script('ee-question-sortable'); |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - protected function _set_list_table_views_default() |
|
364 | - { |
|
365 | - $this->_views = array( |
|
366 | - 'all' => array( |
|
367 | - 'slug' => 'all', |
|
368 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
369 | - 'count' => 0, |
|
370 | - 'bulk_action' => array( |
|
371 | - 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
372 | - ), |
|
373 | - ), |
|
374 | - ); |
|
375 | - |
|
376 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
377 | - 'espresso_registration_form_trash_questions') |
|
378 | - ) { |
|
379 | - $this->_views['trash'] = array( |
|
380 | - 'slug' => 'trash', |
|
381 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
382 | - 'count' => 0, |
|
383 | - 'bulk_action' => array( |
|
384 | - 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
385 | - 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
386 | - ), |
|
387 | - ); |
|
388 | - } |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - protected function _set_list_table_views_question_groups() |
|
393 | - { |
|
394 | - $this->_views = array( |
|
395 | - 'all' => array( |
|
396 | - 'slug' => 'all', |
|
397 | - 'label' => esc_html__('All', 'event_espresso'), |
|
398 | - 'count' => 0, |
|
399 | - 'bulk_action' => array( |
|
400 | - 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
401 | - ), |
|
402 | - ), |
|
403 | - ); |
|
404 | - |
|
405 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', |
|
406 | - 'espresso_registration_form_trash_question_groups') |
|
407 | - ) { |
|
408 | - $this->_views['trash'] = array( |
|
409 | - 'slug' => 'trash', |
|
410 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
411 | - 'count' => 0, |
|
412 | - 'bulk_action' => array( |
|
413 | - 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
414 | - 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
415 | - ), |
|
416 | - ); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - protected function _questions_overview_list_table() |
|
422 | - { |
|
423 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
424 | - 'add_question', |
|
425 | - 'add_question', |
|
426 | - array(), |
|
427 | - 'add-new-h2' |
|
428 | - ); |
|
429 | - parent::_questions_overview_list_table(); |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - protected function _question_groups_overview_list_table() |
|
434 | - { |
|
435 | - $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
436 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
437 | - 'add_question_group', |
|
438 | - 'add_question_group', |
|
439 | - array(), |
|
440 | - 'add-new-h2' |
|
441 | - ); |
|
442 | - $this->display_admin_list_table_page_with_sidebar(); |
|
443 | - } |
|
444 | - |
|
445 | - |
|
446 | - protected function _delete_question() |
|
447 | - { |
|
448 | - $success = $this->_delete_items($this->_question_model); |
|
449 | - $this->_redirect_after_action( |
|
450 | - $success, |
|
451 | - $this->_question_model->item_name($success), |
|
452 | - 'deleted', |
|
453 | - array('action' => 'default', 'status' => 'all') |
|
454 | - ); |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - protected function _delete_questions() |
|
459 | - { |
|
460 | - $success = $this->_delete_items($this->_question_model); |
|
461 | - $this->_redirect_after_action( |
|
462 | - $success, |
|
463 | - $this->_question_model->item_name($success), |
|
464 | - 'deleted permanently', |
|
465 | - array('action' => 'default', 'status' => 'trash') |
|
466 | - ); |
|
467 | - } |
|
468 | - |
|
469 | - |
|
470 | - /** |
|
471 | - * Performs the deletion of a single or multiple questions or question groups. |
|
472 | - * |
|
473 | - * @param EEM_Soft_Delete_Base $model |
|
474 | - * @return int number of items deleted permanently |
|
475 | - */ |
|
476 | - private function _delete_items(EEM_Soft_Delete_Base $model) |
|
477 | - { |
|
478 | - $success = 0; |
|
479 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
480 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
481 | - // if array has more than one element than success message should be plural |
|
482 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
483 | - // cycle thru bulk action checkboxes |
|
484 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
485 | - if (! $this->_delete_item($ID, $model)) { |
|
486 | - $success = 0; |
|
487 | - } |
|
488 | - } |
|
489 | - |
|
490 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
491 | - $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
492 | - |
|
493 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
494 | - $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
495 | - } else { |
|
496 | - EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
497 | - "event_espresso")), __FILE__, __FUNCTION__, __LINE__); |
|
498 | - } |
|
499 | - return $success; |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * Deletes the specified question (and its associated question options) or question group |
|
504 | - * |
|
505 | - * @param int $id |
|
506 | - * @param EEM_Soft_Delete_Base $model |
|
507 | - * @return boolean |
|
508 | - */ |
|
509 | - protected function _delete_item($id, $model) |
|
510 | - { |
|
511 | - if ($model instanceof EEM_Question) { |
|
512 | - EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
513 | - } |
|
514 | - return $model->delete_permanently_by_ID(absint($id)); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /****************************** QUESTION GROUPS ******************************/ |
|
519 | - |
|
520 | - |
|
521 | - protected function _edit_question_group($type = 'add') |
|
522 | - { |
|
523 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
524 | - $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : false; |
|
525 | - |
|
526 | - switch ($this->_req_action) { |
|
527 | - case 'add_question_group' : |
|
528 | - $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
529 | - break; |
|
530 | - case 'edit_question_group' : |
|
531 | - $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
532 | - break; |
|
533 | - default : |
|
534 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
535 | - } |
|
536 | - // add ID to title if editing |
|
537 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
538 | - if ($ID) { |
|
539 | - /** @var EE_Question_Group $questionGroup */ |
|
540 | - $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
541 | - $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
542 | - $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
543 | - } else { |
|
544 | - /** @var EE_Question_Group $questionGroup */ |
|
545 | - $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
546 | - $questionGroup->set_order_to_latest(); |
|
547 | - $this->_set_add_edit_form_tags('insert_question_group'); |
|
548 | - } |
|
549 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
550 | - $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
551 | - $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
552 | - $this->_template_args['question_group'] = $questionGroup; |
|
553 | - |
|
554 | - $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
555 | - $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
556 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
557 | - $this->_template_args, true); |
|
558 | - |
|
559 | - // the details template wrapper |
|
560 | - $this->display_admin_page_with_sidebar(); |
|
561 | - } |
|
562 | - |
|
563 | - |
|
564 | - protected function _delete_question_groups() |
|
565 | - { |
|
566 | - $success = $this->_delete_items($this->_question_group_model); |
|
567 | - $this->_redirect_after_action($success, $this->_question_group_model->item_name($success), |
|
568 | - 'deleted permanently', array('action' => 'question_groups', 'status' => 'trash')); |
|
569 | - } |
|
570 | - |
|
571 | - |
|
572 | - /** |
|
573 | - * @param bool $new_question_group |
|
574 | - */ |
|
575 | - protected function _insert_or_update_question_group($new_question_group = true) |
|
576 | - { |
|
577 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
578 | - $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
579 | - if ($new_question_group) { |
|
580 | - $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
581 | - $success = $QSG_ID ? 1 : 0; |
|
582 | - } else { |
|
583 | - $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
584 | - unset($set_column_values['QSG_ID']); |
|
585 | - $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
586 | - } |
|
587 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone); |
|
588 | - // update the existing related questions |
|
589 | - // BUT FIRST... delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group) |
|
590 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
591 | - // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
592 | - EEM_Question_Group_Question::instance()->delete(array( |
|
593 | - array( |
|
594 | - 'QST_ID' => $phone_question_id, |
|
595 | - 'QSG_ID' => array('!=', $QSG_ID), |
|
596 | - ), |
|
597 | - )); |
|
598 | - } |
|
599 | - /** @type EE_Question_Group $question_group */ |
|
600 | - $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
601 | - $questions = $question_group->questions(); |
|
602 | - // make sure system phone question is added to list of questions for this group |
|
603 | - if (! isset($questions[$phone_question_id])) { |
|
604 | - $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
605 | - } |
|
606 | - |
|
607 | - foreach ($questions as $question_ID => $question) { |
|
608 | - // first we always check for order. |
|
609 | - if (! empty($this->_req_data['question_orders'][$question_ID])) { |
|
610 | - //update question order |
|
611 | - $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]); |
|
612 | - } |
|
613 | - |
|
614 | - // then we always check if adding or removing. |
|
615 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
616 | - $question_group->add_question($question_ID); |
|
617 | - } else { |
|
618 | - // not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it) |
|
619 | - if ( |
|
620 | - in_array( |
|
621 | - $question->system_ID(), |
|
622 | - EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group()) |
|
623 | - ) |
|
624 | - ) { |
|
625 | - continue; |
|
626 | - } else { |
|
627 | - $question_group->remove_question($question_ID); |
|
628 | - } |
|
629 | - } |
|
630 | - } |
|
631 | - // save new related questions |
|
632 | - if (isset($this->_req_data['questions'])) { |
|
633 | - foreach ($this->_req_data['questions'] as $QST_ID) { |
|
634 | - $question_group->add_question($QST_ID); |
|
635 | - if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
636 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
637 | - } |
|
638 | - } |
|
639 | - } |
|
640 | - |
|
641 | - if ($success !== false) { |
|
642 | - $msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
643 | - $this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated', |
|
644 | - 'event_espresso'), $this->_question_group_model->item_name()); |
|
645 | - EE_Error::add_success($msg); |
|
646 | - } |
|
647 | - $this->_redirect_after_action(false, '', '', array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
648 | - true); |
|
649 | - |
|
650 | - } |
|
651 | - |
|
652 | - /** |
|
653 | - * duplicates a question and all its question options and redirects to the new question. |
|
654 | - */ |
|
655 | - public function _duplicate_question() |
|
656 | - { |
|
657 | - $question_ID = (int)$this->_req_data['QST_ID']; |
|
658 | - $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
659 | - if ($question instanceof EE_Question) { |
|
660 | - $new_question = $question->duplicate(); |
|
661 | - if ($new_question instanceof EE_Question) { |
|
662 | - $this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'), |
|
663 | - esc_html__('Duplicated', 'event_espresso'), |
|
664 | - array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), true); |
|
665 | - } else { |
|
666 | - global $wpdb; |
|
667 | - EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s', |
|
668 | - 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__); |
|
669 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
670 | - } |
|
671 | - } else { |
|
672 | - EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!', |
|
673 | - 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__); |
|
674 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
675 | - } |
|
676 | - } |
|
677 | - |
|
678 | - |
|
679 | - /** |
|
680 | - * @param bool $trash |
|
681 | - */ |
|
682 | - protected function _trash_or_restore_question_groups($trash = true) |
|
683 | - { |
|
684 | - $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
685 | - } |
|
686 | - |
|
687 | - |
|
688 | - /** |
|
689 | - *_trash_question |
|
690 | - */ |
|
691 | - protected function _trash_question() |
|
692 | - { |
|
693 | - $success = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']); |
|
694 | - $query_args = array('action' => 'default', 'status' => 'all'); |
|
695 | - $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
696 | - } |
|
697 | - |
|
698 | - |
|
699 | - /** |
|
700 | - * @param bool $trash |
|
701 | - */ |
|
702 | - protected function _trash_or_restore_questions($trash = true) |
|
703 | - { |
|
704 | - $this->_trash_or_restore_items($this->_question_model, $trash); |
|
705 | - } |
|
706 | - |
|
707 | - |
|
708 | - /** |
|
709 | - * Internally used to delete or restore items, using the request data. Meant to be |
|
710 | - * flexible between question or question groups |
|
711 | - * |
|
712 | - * @param EEM_Soft_Delete_Base $model |
|
713 | - * @param boolean $trash whether to trash or restore |
|
714 | - */ |
|
715 | - private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
716 | - { |
|
717 | - |
|
718 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
719 | - |
|
720 | - $success = 1; |
|
721 | - //Checkboxes |
|
722 | - //echo "trash $trash"; |
|
723 | - //var_dump($this->_req_data['checkbox']);die; |
|
724 | - if (isset($this->_req_data['checkbox'])) { |
|
725 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
726 | - // if array has more than one element than success message should be plural |
|
727 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
728 | - // cycle thru bulk action checkboxes |
|
729 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
730 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
731 | - $success = 0; |
|
732 | - } |
|
733 | - } |
|
734 | - |
|
735 | - } else { |
|
736 | - // grab single id and delete |
|
737 | - $ID = absint($this->_req_data['checkbox']); |
|
738 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
739 | - $success = 0; |
|
740 | - } |
|
741 | - } |
|
742 | - |
|
743 | - } else { |
|
744 | - // delete via trash link |
|
745 | - // grab single id and delete |
|
746 | - $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
747 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
748 | - $success = 0; |
|
749 | - } |
|
750 | - |
|
751 | - } |
|
752 | - |
|
753 | - |
|
754 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) ); |
|
755 | - //echo "action :$action"; |
|
756 | - //$action = 'questions' ? 'default' : $action; |
|
757 | - if ($trash) { |
|
758 | - $action_desc = 'trashed'; |
|
759 | - $status = 'trash'; |
|
760 | - } else { |
|
761 | - $action_desc = 'restored'; |
|
762 | - $status = 'all'; |
|
763 | - } |
|
764 | - $this->_redirect_after_action($success, $model->item_name($success), $action_desc, |
|
765 | - array('action' => $action, 'status' => $status)); |
|
766 | - } |
|
767 | - |
|
768 | - |
|
769 | - /** |
|
770 | - * @param $per_page |
|
771 | - * @param int $current_page |
|
772 | - * @param bool|false $count |
|
773 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
774 | - */ |
|
775 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
776 | - { |
|
777 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
778 | - |
|
779 | - if ($count) { |
|
780 | - //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
781 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
782 | - $results = $this->_question_model->count_deleted($where); |
|
783 | - } else { |
|
784 | - //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
785 | - $results = $this->_question_model->get_all_deleted($query_params); |
|
786 | - } |
|
787 | - return $results; |
|
788 | - } |
|
789 | - |
|
790 | - |
|
791 | - /** |
|
792 | - * @param $per_page |
|
793 | - * @param int $current_page |
|
794 | - * @param bool|false $count |
|
795 | - * @return \EE_Soft_Delete_Base_Class[] |
|
796 | - */ |
|
797 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
798 | - { |
|
799 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
800 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
801 | - if ($count) { |
|
802 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
803 | - $results = $questionGroupModel->count($where); |
|
804 | - } else { |
|
805 | - $results = $questionGroupModel->get_all($query_params); |
|
806 | - } |
|
807 | - return $results; |
|
808 | - } |
|
809 | - |
|
810 | - |
|
811 | - /** |
|
812 | - * @param $per_page |
|
813 | - * @param int $current_page |
|
814 | - * @param bool $count |
|
815 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
816 | - */ |
|
817 | - public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
818 | - { |
|
819 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
820 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
821 | - if ($count) { |
|
822 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
823 | - $query_params['limit'] = null; |
|
824 | - $results = $questionGroupModel->count_deleted($where); |
|
825 | - } else { |
|
826 | - $results = $questionGroupModel->get_all_deleted($query_params); |
|
827 | - } |
|
828 | - return $results; |
|
829 | - } |
|
830 | - |
|
831 | - |
|
832 | - /** |
|
833 | - * method for performing updates to question order |
|
834 | - * |
|
835 | - * @return array results array |
|
836 | - */ |
|
837 | - public function update_question_group_order() |
|
838 | - { |
|
839 | - |
|
840 | - $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
841 | - |
|
842 | - // grab our row IDs |
|
843 | - $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
844 | - ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
845 | - : array(); |
|
846 | - |
|
847 | - $perpage = ! empty($this->_req_data['perpage']) |
|
848 | - ? (int)$this->_req_data['perpage'] |
|
849 | - : null; |
|
850 | - $curpage = ! empty($this->_req_data['curpage']) |
|
851 | - ? (int)$this->_req_data['curpage'] |
|
852 | - : null; |
|
853 | - |
|
854 | - if (! empty($row_ids)) { |
|
855 | - //figure out where we start the row_id count at for the current page. |
|
856 | - $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
857 | - |
|
858 | - $row_count = count($row_ids); |
|
859 | - for ($i = 0; $i < $row_count; $i++) { |
|
860 | - //Update the questions when re-ordering |
|
861 | - $updated = EEM_Question_Group::instance()->update( |
|
862 | - array('QSG_order' => $qsgcount), |
|
863 | - array(array('QSG_ID' => $row_ids[$i])) |
|
864 | - ); |
|
865 | - if ($updated === false) { |
|
866 | - $success = false; |
|
867 | - } |
|
868 | - $qsgcount++; |
|
869 | - } |
|
870 | - } else { |
|
871 | - $success = false; |
|
872 | - } |
|
873 | - |
|
874 | - $errors = ! $success |
|
875 | - ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
876 | - : false; |
|
877 | - |
|
878 | - echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
879 | - die(); |
|
880 | - |
|
881 | - } |
|
882 | - |
|
883 | - |
|
884 | - |
|
885 | - /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
886 | - |
|
887 | - |
|
888 | - /** |
|
889 | - * _reg_form_settings |
|
890 | - * |
|
891 | - * @throws \EE_Error |
|
892 | - */ |
|
893 | - protected function _reg_form_settings() |
|
894 | - { |
|
895 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
896 | - add_action( |
|
897 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
898 | - array($this, 'email_validation_settings_form'), |
|
899 | - 2 |
|
900 | - ); |
|
901 | - $this->_template_args = (array)apply_filters( |
|
902 | - 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
903 | - $this->_template_args |
|
904 | - ); |
|
905 | - $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
906 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
907 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
908 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
909 | - $this->_template_args, |
|
910 | - true |
|
911 | - ); |
|
912 | - $this->display_admin_page_with_sidebar(); |
|
913 | - } |
|
914 | - |
|
915 | - |
|
916 | - /** |
|
917 | - * _update_reg_form_settings |
|
918 | - */ |
|
919 | - protected function _update_reg_form_settings() |
|
920 | - { |
|
921 | - EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
922 | - EE_Registry::instance()->CFG->registration |
|
923 | - ); |
|
924 | - EE_Registry::instance()->CFG->registration = apply_filters( |
|
925 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
926 | - EE_Registry::instance()->CFG->registration |
|
927 | - ); |
|
928 | - $success = $this->_update_espresso_configuration( |
|
929 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
930 | - EE_Registry::instance()->CFG, |
|
931 | - __FILE__, __FUNCTION__, __LINE__ |
|
932 | - ); |
|
933 | - $this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', |
|
934 | - array('action' => 'view_reg_form_settings')); |
|
935 | - } |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * email_validation_settings_form |
|
940 | - * |
|
941 | - * @access public |
|
942 | - * @return void |
|
943 | - * @throws \EE_Error |
|
944 | - */ |
|
945 | - public function email_validation_settings_form() |
|
946 | - { |
|
947 | - echo $this->_email_validation_settings_form()->get_html(); |
|
948 | - } |
|
949 | - |
|
950 | - |
|
951 | - /** |
|
952 | - * _email_validation_settings_form |
|
953 | - * |
|
954 | - * @access protected |
|
955 | - * @return EE_Form_Section_Proper |
|
956 | - * @throws \EE_Error |
|
957 | - */ |
|
958 | - protected function _email_validation_settings_form() |
|
959 | - { |
|
960 | - return new EE_Form_Section_Proper( |
|
961 | - array( |
|
962 | - 'name' => 'email_validation_settings', |
|
963 | - 'html_id' => 'email_validation_settings', |
|
964 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
965 | - 'subsections' => array( |
|
966 | - 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
967 | - EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
968 | - ), |
|
969 | - 'email_validation_level' => new EE_Select_Input( |
|
970 | - array( |
|
971 | - 'basic' => esc_html__('Basic', 'event_espresso'), |
|
972 | - 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
973 | - 'i18n' => esc_html__('International', 'event_espresso'), |
|
974 | - 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
975 | - ), |
|
976 | - array( |
|
977 | - 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
978 | - . EEH_Template::get_help_tab_link('email_validation_info'), |
|
979 | - 'html_help_text' => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
980 | - 'event_espresso'), |
|
981 | - 'default' => isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
982 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
983 | - : 'wp_default', |
|
984 | - 'required' => false, |
|
985 | - ) |
|
986 | - ), |
|
987 | - ), |
|
988 | - ) |
|
989 | - ); |
|
990 | - } |
|
991 | - |
|
992 | - |
|
993 | - /** |
|
994 | - * update_email_validation_settings_form |
|
995 | - * |
|
996 | - * @access public |
|
997 | - * @param \EE_Registration_Config $EE_Registration_Config |
|
998 | - * @return \EE_Registration_Config |
|
999 | - */ |
|
1000 | - public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1001 | - { |
|
1002 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1003 | - try { |
|
1004 | - $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1005 | - // if not displaying a form, then check for form submission |
|
1006 | - if ($email_validation_settings_form->was_submitted()) { |
|
1007 | - // capture form data |
|
1008 | - $email_validation_settings_form->receive_form_submission(); |
|
1009 | - // validate form data |
|
1010 | - if ($email_validation_settings_form->is_valid()) { |
|
1011 | - // grab validated data from form |
|
1012 | - $valid_data = $email_validation_settings_form->valid_data(); |
|
1013 | - if (isset($valid_data['email_validation_level'])) { |
|
1014 | - $email_validation_level = $valid_data['email_validation_level']; |
|
1015 | - // now if they want to use international email addresses |
|
1016 | - if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1017 | - // in case we need to reset their email validation level, |
|
1018 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1019 | - if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1020 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1021 | - // despite offering poor validation, supports i18n email addresses |
|
1022 | - $prev_email_validation_level = 'basic'; |
|
1023 | - } |
|
1024 | - // confirm our i18n email validation will work on the server |
|
1025 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1026 | - // or reset email validation level to previous value |
|
1027 | - $email_validation_level = $prev_email_validation_level; |
|
1028 | - } |
|
1029 | - } |
|
1030 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1031 | - } else { |
|
1032 | - EE_Error::add_error( |
|
1033 | - esc_html__( |
|
1034 | - 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1035 | - 'event_espresso' |
|
1036 | - ), |
|
1037 | - __FILE__, __FUNCTION__, __LINE__ |
|
1038 | - ); |
|
1039 | - } |
|
1040 | - } else { |
|
1041 | - if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1042 | - EE_Error::add_error( |
|
1043 | - $email_validation_settings_form->submission_error_message(), |
|
1044 | - __FILE__, __FUNCTION__, __LINE__ |
|
1045 | - ); |
|
1046 | - } |
|
1047 | - } |
|
1048 | - } |
|
1049 | - } catch (EE_Error $e) { |
|
1050 | - $e->get_error(); |
|
1051 | - } |
|
1052 | - return $EE_Registration_Config; |
|
1053 | - } |
|
1054 | - |
|
1055 | - |
|
1056 | - /** |
|
1057 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1058 | - * and that the PCRE version works with our i18n email validation |
|
1059 | - * |
|
1060 | - * @param \EE_Registration_Config $EE_Registration_Config |
|
1061 | - * @param string $email_validation_level |
|
1062 | - * @return bool |
|
1063 | - */ |
|
1064 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1065 | - { |
|
1066 | - // first check that PCRE is enabled |
|
1067 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1068 | - EE_Error::add_error( |
|
1069 | - sprintf( |
|
1070 | - esc_html__( |
|
1071 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1072 | - 'event_espresso' |
|
1073 | - ), |
|
1074 | - '<br />' |
|
1075 | - ), |
|
1076 | - __FILE__, |
|
1077 | - __FUNCTION__, |
|
1078 | - __LINE__ |
|
1079 | - ); |
|
1080 | - return false; |
|
1081 | - } else { |
|
1082 | - // PCRE support is enabled, but let's still |
|
1083 | - // perform a test to see if the server will support it. |
|
1084 | - // but first, save the updated validation level to the config, |
|
1085 | - // so that the validation strategy picks it up. |
|
1086 | - // this will get bumped back down if it doesn't work |
|
1087 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1088 | - try { |
|
1089 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1090 | - $i18n_email_address = apply_filters( |
|
1091 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1092 | - 'jägerjü[email protected]' |
|
1093 | - ); |
|
1094 | - $email_validator->validate($i18n_email_address); |
|
1095 | - } catch (Exception $e) { |
|
1096 | - EE_Error::add_error( |
|
1097 | - sprintf( |
|
1098 | - esc_html__( |
|
1099 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1100 | - 'event_espresso' |
|
1101 | - ), |
|
1102 | - '<br />', |
|
1103 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1104 | - ), |
|
1105 | - __FILE__, __FUNCTION__, __LINE__ |
|
1106 | - ); |
|
1107 | - return false; |
|
1108 | - } |
|
1109 | - } |
|
1110 | - return true; |
|
1111 | - } |
|
28 | + /** |
|
29 | + * @Constructor |
|
30 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
31 | + * @access public |
|
32 | + */ |
|
33 | + public function __construct($routing = true) |
|
34 | + { |
|
35 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS); |
|
36 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS); |
|
37 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
38 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS); |
|
39 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
40 | + parent::__construct($routing); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + protected function _extend_page_config() |
|
45 | + { |
|
46 | + $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
47 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
48 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0; |
|
49 | + |
|
50 | + $new_page_routes = array( |
|
51 | + 'question_groups' => array( |
|
52 | + 'func' => '_question_groups_overview_list_table', |
|
53 | + 'capability' => 'ee_read_question_groups', |
|
54 | + ), |
|
55 | + 'add_question' => array( |
|
56 | + 'func' => '_edit_question', |
|
57 | + 'capability' => 'ee_edit_questions', |
|
58 | + ), |
|
59 | + 'insert_question' => array( |
|
60 | + 'func' => '_insert_or_update_question', |
|
61 | + 'args' => array('new_question' => true), |
|
62 | + 'capability' => 'ee_edit_questions', |
|
63 | + 'noheader' => true, |
|
64 | + ), |
|
65 | + 'duplicate_question' => array( |
|
66 | + 'func' => '_duplicate_question', |
|
67 | + 'capability' => 'ee_edit_questions', |
|
68 | + 'noheader' => true, |
|
69 | + ), |
|
70 | + 'trash_question' => array( |
|
71 | + 'func' => '_trash_question', |
|
72 | + 'capability' => 'ee_delete_question', |
|
73 | + 'obj_id' => $qst_id, |
|
74 | + 'noheader' => true, |
|
75 | + ), |
|
76 | + |
|
77 | + 'restore_question' => array( |
|
78 | + 'func' => '_trash_or_restore_questions', |
|
79 | + 'capability' => 'ee_delete_question', |
|
80 | + 'obj_id' => $qst_id, |
|
81 | + 'args' => array('trash' => false), |
|
82 | + 'noheader' => true, |
|
83 | + ), |
|
84 | + |
|
85 | + 'delete_question' => array( |
|
86 | + 'func' => '_delete_question', |
|
87 | + 'capability' => 'ee_delete_question', |
|
88 | + 'obj_id' => $qst_id, |
|
89 | + 'noheader' => true, |
|
90 | + ), |
|
91 | + |
|
92 | + 'trash_questions' => array( |
|
93 | + 'func' => '_trash_or_restore_questions', |
|
94 | + 'capability' => 'ee_delete_questions', |
|
95 | + 'args' => array('trash' => true), |
|
96 | + 'noheader' => true, |
|
97 | + ), |
|
98 | + |
|
99 | + 'restore_questions' => array( |
|
100 | + 'func' => '_trash_or_restore_questions', |
|
101 | + 'capability' => 'ee_delete_questions', |
|
102 | + 'args' => array('trash' => false), |
|
103 | + 'noheader' => true, |
|
104 | + ), |
|
105 | + |
|
106 | + 'delete_questions' => array( |
|
107 | + 'func' => '_delete_questions', |
|
108 | + 'args' => array(), |
|
109 | + 'capability' => 'ee_delete_questions', |
|
110 | + 'noheader' => true, |
|
111 | + ), |
|
112 | + |
|
113 | + 'add_question_group' => array( |
|
114 | + 'func' => '_edit_question_group', |
|
115 | + 'capability' => 'ee_edit_question_groups', |
|
116 | + ), |
|
117 | + |
|
118 | + 'edit_question_group' => array( |
|
119 | + 'func' => '_edit_question_group', |
|
120 | + 'capability' => 'ee_edit_question_group', |
|
121 | + 'obj_id' => $qsg_id, |
|
122 | + 'args' => array('edit'), |
|
123 | + ), |
|
124 | + |
|
125 | + 'delete_question_groups' => array( |
|
126 | + 'func' => '_delete_question_groups', |
|
127 | + 'capability' => 'ee_delete_question_groups', |
|
128 | + 'noheader' => true, |
|
129 | + ), |
|
130 | + |
|
131 | + 'delete_question_group' => array( |
|
132 | + 'func' => '_delete_question_groups', |
|
133 | + 'capability' => 'ee_delete_question_group', |
|
134 | + 'obj_id' => $qsg_id, |
|
135 | + 'noheader' => true, |
|
136 | + ), |
|
137 | + |
|
138 | + 'trash_question_group' => array( |
|
139 | + 'func' => '_trash_or_restore_question_groups', |
|
140 | + 'args' => array('trash' => true), |
|
141 | + 'capability' => 'ee_delete_question_group', |
|
142 | + 'obj_id' => $qsg_id, |
|
143 | + 'noheader' => true, |
|
144 | + ), |
|
145 | + |
|
146 | + 'restore_question_group' => array( |
|
147 | + 'func' => '_trash_or_restore_question_groups', |
|
148 | + 'args' => array('trash' => false), |
|
149 | + 'capability' => 'ee_delete_question_group', |
|
150 | + 'obj_id' => $qsg_id, |
|
151 | + 'noheader' => true, |
|
152 | + ), |
|
153 | + |
|
154 | + 'insert_question_group' => array( |
|
155 | + 'func' => '_insert_or_update_question_group', |
|
156 | + 'args' => array('new_question_group' => true), |
|
157 | + 'capability' => 'ee_edit_question_groups', |
|
158 | + 'noheader' => true, |
|
159 | + ), |
|
160 | + |
|
161 | + 'update_question_group' => array( |
|
162 | + 'func' => '_insert_or_update_question_group', |
|
163 | + 'args' => array('new_question_group' => false), |
|
164 | + 'capability' => 'ee_edit_question_group', |
|
165 | + 'obj_id' => $qsg_id, |
|
166 | + 'noheader' => true, |
|
167 | + ), |
|
168 | + |
|
169 | + 'trash_question_groups' => array( |
|
170 | + 'func' => '_trash_or_restore_question_groups', |
|
171 | + 'args' => array('trash' => true), |
|
172 | + 'capability' => 'ee_delete_question_groups', |
|
173 | + 'noheader' => array('trash' => false), |
|
174 | + ), |
|
175 | + |
|
176 | + 'restore_question_groups' => array( |
|
177 | + 'func' => '_trash_or_restore_question_groups', |
|
178 | + 'args' => array('trash' => false), |
|
179 | + 'capability' => 'ee_delete_question_groups', |
|
180 | + 'noheader' => true, |
|
181 | + ), |
|
182 | + |
|
183 | + |
|
184 | + 'espresso_update_question_group_order' => array( |
|
185 | + 'func' => 'update_question_group_order', |
|
186 | + 'capability' => 'ee_edit_question_groups', |
|
187 | + 'noheader' => true, |
|
188 | + ), |
|
189 | + |
|
190 | + 'view_reg_form_settings' => array( |
|
191 | + 'func' => '_reg_form_settings', |
|
192 | + 'capability' => 'manage_options', |
|
193 | + ), |
|
194 | + |
|
195 | + 'update_reg_form_settings' => array( |
|
196 | + 'func' => '_update_reg_form_settings', |
|
197 | + 'capability' => 'manage_options', |
|
198 | + 'noheader' => true, |
|
199 | + ), |
|
200 | + ); |
|
201 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
202 | + |
|
203 | + $new_page_config = array( |
|
204 | + |
|
205 | + 'question_groups' => array( |
|
206 | + 'nav' => array( |
|
207 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
208 | + 'order' => 20, |
|
209 | + ), |
|
210 | + 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
211 | + 'help_tabs' => array( |
|
212 | + 'registration_form_question_groups_help_tab' => array( |
|
213 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
214 | + 'filename' => 'registration_form_question_groups', |
|
215 | + ), |
|
216 | + 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
217 | + 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
218 | + 'filename' => 'registration_form_question_groups_table_column_headings', |
|
219 | + ), |
|
220 | + 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
221 | + 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
222 | + 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
223 | + ), |
|
224 | + ), |
|
225 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
226 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
227 | + 'require_nonce' => false, |
|
228 | + 'qtips' => array( |
|
229 | + 'EE_Registration_Form_Tips', |
|
230 | + ), |
|
231 | + ), |
|
232 | + |
|
233 | + 'add_question' => array( |
|
234 | + 'nav' => array( |
|
235 | + 'label' => esc_html__('Add Question', 'event_espresso'), |
|
236 | + 'order' => 5, |
|
237 | + 'persistent' => false, |
|
238 | + ), |
|
239 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
240 | + 'help_tabs' => array( |
|
241 | + 'registration_form_add_question_help_tab' => array( |
|
242 | + 'title' => esc_html__('Add Question', 'event_espresso'), |
|
243 | + 'filename' => 'registration_form_add_question', |
|
244 | + ), |
|
245 | + ), |
|
246 | + 'help_tour' => array('Registration_Form_Add_Question_Help_Tour'), |
|
247 | + 'require_nonce' => false, |
|
248 | + ), |
|
249 | + |
|
250 | + 'add_question_group' => array( |
|
251 | + 'nav' => array( |
|
252 | + 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
253 | + 'order' => 5, |
|
254 | + 'persistent' => false, |
|
255 | + ), |
|
256 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
257 | + 'help_tabs' => array( |
|
258 | + 'registration_form_add_question_group_help_tab' => array( |
|
259 | + 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
260 | + 'filename' => 'registration_form_add_question_group', |
|
261 | + ), |
|
262 | + ), |
|
263 | + 'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'), |
|
264 | + 'require_nonce' => false, |
|
265 | + ), |
|
266 | + |
|
267 | + 'edit_question_group' => array( |
|
268 | + 'nav' => array( |
|
269 | + 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
270 | + 'order' => 5, |
|
271 | + 'persistent' => false, |
|
272 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']), |
|
273 | + $this->_current_page_view_url) : $this->_admin_base_url, |
|
274 | + ), |
|
275 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
276 | + 'help_tabs' => array( |
|
277 | + 'registration_form_edit_question_group_help_tab' => array( |
|
278 | + 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
279 | + 'filename' => 'registration_form_edit_question_group', |
|
280 | + ), |
|
281 | + ), |
|
282 | + 'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'), |
|
283 | + 'require_nonce' => false, |
|
284 | + ), |
|
285 | + |
|
286 | + 'view_reg_form_settings' => array( |
|
287 | + 'nav' => array( |
|
288 | + 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
289 | + 'order' => 40, |
|
290 | + ), |
|
291 | + 'labels' => array( |
|
292 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
293 | + ), |
|
294 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
295 | + 'help_tabs' => array( |
|
296 | + 'registration_form_reg_form_settings_help_tab' => array( |
|
297 | + 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
298 | + 'filename' => 'registration_form_reg_form_settings', |
|
299 | + ), |
|
300 | + ), |
|
301 | + 'help_tour' => array('Registration_Form_Settings_Help_Tour'), |
|
302 | + 'require_nonce' => false, |
|
303 | + ), |
|
304 | + |
|
305 | + ); |
|
306 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
307 | + |
|
308 | + //change the list table we're going to use so it's the NEW list table! |
|
309 | + $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
310 | + |
|
311 | + |
|
312 | + //additional labels |
|
313 | + $new_labels = array( |
|
314 | + 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
315 | + 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
316 | + 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
317 | + 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
318 | + 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
319 | + ); |
|
320 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
321 | + |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + protected function _ajax_hooks() |
|
326 | + { |
|
327 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + public function load_scripts_styles_question_groups() |
|
332 | + { |
|
333 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + public function load_scripts_styles_add_question_group() |
|
338 | + { |
|
339 | + $this->load_scripts_styles_forms(); |
|
340 | + $this->load_sortable_question_script(); |
|
341 | + } |
|
342 | + |
|
343 | + public function load_scripts_styles_edit_question_group() |
|
344 | + { |
|
345 | + $this->load_scripts_styles_forms(); |
|
346 | + $this->load_sortable_question_script(); |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * registers and enqueues script for questions |
|
352 | + * |
|
353 | + * @return void |
|
354 | + */ |
|
355 | + public function load_sortable_question_script() |
|
356 | + { |
|
357 | + wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
358 | + array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
359 | + wp_enqueue_script('ee-question-sortable'); |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + protected function _set_list_table_views_default() |
|
364 | + { |
|
365 | + $this->_views = array( |
|
366 | + 'all' => array( |
|
367 | + 'slug' => 'all', |
|
368 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
369 | + 'count' => 0, |
|
370 | + 'bulk_action' => array( |
|
371 | + 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
372 | + ), |
|
373 | + ), |
|
374 | + ); |
|
375 | + |
|
376 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
377 | + 'espresso_registration_form_trash_questions') |
|
378 | + ) { |
|
379 | + $this->_views['trash'] = array( |
|
380 | + 'slug' => 'trash', |
|
381 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
382 | + 'count' => 0, |
|
383 | + 'bulk_action' => array( |
|
384 | + 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
385 | + 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
386 | + ), |
|
387 | + ); |
|
388 | + } |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + protected function _set_list_table_views_question_groups() |
|
393 | + { |
|
394 | + $this->_views = array( |
|
395 | + 'all' => array( |
|
396 | + 'slug' => 'all', |
|
397 | + 'label' => esc_html__('All', 'event_espresso'), |
|
398 | + 'count' => 0, |
|
399 | + 'bulk_action' => array( |
|
400 | + 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
401 | + ), |
|
402 | + ), |
|
403 | + ); |
|
404 | + |
|
405 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', |
|
406 | + 'espresso_registration_form_trash_question_groups') |
|
407 | + ) { |
|
408 | + $this->_views['trash'] = array( |
|
409 | + 'slug' => 'trash', |
|
410 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
411 | + 'count' => 0, |
|
412 | + 'bulk_action' => array( |
|
413 | + 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
414 | + 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
415 | + ), |
|
416 | + ); |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + protected function _questions_overview_list_table() |
|
422 | + { |
|
423 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
424 | + 'add_question', |
|
425 | + 'add_question', |
|
426 | + array(), |
|
427 | + 'add-new-h2' |
|
428 | + ); |
|
429 | + parent::_questions_overview_list_table(); |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + protected function _question_groups_overview_list_table() |
|
434 | + { |
|
435 | + $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
436 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
437 | + 'add_question_group', |
|
438 | + 'add_question_group', |
|
439 | + array(), |
|
440 | + 'add-new-h2' |
|
441 | + ); |
|
442 | + $this->display_admin_list_table_page_with_sidebar(); |
|
443 | + } |
|
444 | + |
|
445 | + |
|
446 | + protected function _delete_question() |
|
447 | + { |
|
448 | + $success = $this->_delete_items($this->_question_model); |
|
449 | + $this->_redirect_after_action( |
|
450 | + $success, |
|
451 | + $this->_question_model->item_name($success), |
|
452 | + 'deleted', |
|
453 | + array('action' => 'default', 'status' => 'all') |
|
454 | + ); |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + protected function _delete_questions() |
|
459 | + { |
|
460 | + $success = $this->_delete_items($this->_question_model); |
|
461 | + $this->_redirect_after_action( |
|
462 | + $success, |
|
463 | + $this->_question_model->item_name($success), |
|
464 | + 'deleted permanently', |
|
465 | + array('action' => 'default', 'status' => 'trash') |
|
466 | + ); |
|
467 | + } |
|
468 | + |
|
469 | + |
|
470 | + /** |
|
471 | + * Performs the deletion of a single or multiple questions or question groups. |
|
472 | + * |
|
473 | + * @param EEM_Soft_Delete_Base $model |
|
474 | + * @return int number of items deleted permanently |
|
475 | + */ |
|
476 | + private function _delete_items(EEM_Soft_Delete_Base $model) |
|
477 | + { |
|
478 | + $success = 0; |
|
479 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
480 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
481 | + // if array has more than one element than success message should be plural |
|
482 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
483 | + // cycle thru bulk action checkboxes |
|
484 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
485 | + if (! $this->_delete_item($ID, $model)) { |
|
486 | + $success = 0; |
|
487 | + } |
|
488 | + } |
|
489 | + |
|
490 | + } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
491 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
492 | + |
|
493 | + } elseif (! empty($this->_req_data['QST_ID'])) { |
|
494 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
495 | + } else { |
|
496 | + EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
497 | + "event_espresso")), __FILE__, __FUNCTION__, __LINE__); |
|
498 | + } |
|
499 | + return $success; |
|
500 | + } |
|
501 | + |
|
502 | + /** |
|
503 | + * Deletes the specified question (and its associated question options) or question group |
|
504 | + * |
|
505 | + * @param int $id |
|
506 | + * @param EEM_Soft_Delete_Base $model |
|
507 | + * @return boolean |
|
508 | + */ |
|
509 | + protected function _delete_item($id, $model) |
|
510 | + { |
|
511 | + if ($model instanceof EEM_Question) { |
|
512 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
513 | + } |
|
514 | + return $model->delete_permanently_by_ID(absint($id)); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /****************************** QUESTION GROUPS ******************************/ |
|
519 | + |
|
520 | + |
|
521 | + protected function _edit_question_group($type = 'add') |
|
522 | + { |
|
523 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
524 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : false; |
|
525 | + |
|
526 | + switch ($this->_req_action) { |
|
527 | + case 'add_question_group' : |
|
528 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
529 | + break; |
|
530 | + case 'edit_question_group' : |
|
531 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
532 | + break; |
|
533 | + default : |
|
534 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
535 | + } |
|
536 | + // add ID to title if editing |
|
537 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
538 | + if ($ID) { |
|
539 | + /** @var EE_Question_Group $questionGroup */ |
|
540 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
541 | + $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
542 | + $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
543 | + } else { |
|
544 | + /** @var EE_Question_Group $questionGroup */ |
|
545 | + $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
546 | + $questionGroup->set_order_to_latest(); |
|
547 | + $this->_set_add_edit_form_tags('insert_question_group'); |
|
548 | + } |
|
549 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
550 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
551 | + $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
552 | + $this->_template_args['question_group'] = $questionGroup; |
|
553 | + |
|
554 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
555 | + $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
556 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
557 | + $this->_template_args, true); |
|
558 | + |
|
559 | + // the details template wrapper |
|
560 | + $this->display_admin_page_with_sidebar(); |
|
561 | + } |
|
562 | + |
|
563 | + |
|
564 | + protected function _delete_question_groups() |
|
565 | + { |
|
566 | + $success = $this->_delete_items($this->_question_group_model); |
|
567 | + $this->_redirect_after_action($success, $this->_question_group_model->item_name($success), |
|
568 | + 'deleted permanently', array('action' => 'question_groups', 'status' => 'trash')); |
|
569 | + } |
|
570 | + |
|
571 | + |
|
572 | + /** |
|
573 | + * @param bool $new_question_group |
|
574 | + */ |
|
575 | + protected function _insert_or_update_question_group($new_question_group = true) |
|
576 | + { |
|
577 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
578 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
579 | + if ($new_question_group) { |
|
580 | + $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
581 | + $success = $QSG_ID ? 1 : 0; |
|
582 | + } else { |
|
583 | + $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
584 | + unset($set_column_values['QSG_ID']); |
|
585 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
586 | + } |
|
587 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone); |
|
588 | + // update the existing related questions |
|
589 | + // BUT FIRST... delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group) |
|
590 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
591 | + // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
592 | + EEM_Question_Group_Question::instance()->delete(array( |
|
593 | + array( |
|
594 | + 'QST_ID' => $phone_question_id, |
|
595 | + 'QSG_ID' => array('!=', $QSG_ID), |
|
596 | + ), |
|
597 | + )); |
|
598 | + } |
|
599 | + /** @type EE_Question_Group $question_group */ |
|
600 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
601 | + $questions = $question_group->questions(); |
|
602 | + // make sure system phone question is added to list of questions for this group |
|
603 | + if (! isset($questions[$phone_question_id])) { |
|
604 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
605 | + } |
|
606 | + |
|
607 | + foreach ($questions as $question_ID => $question) { |
|
608 | + // first we always check for order. |
|
609 | + if (! empty($this->_req_data['question_orders'][$question_ID])) { |
|
610 | + //update question order |
|
611 | + $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]); |
|
612 | + } |
|
613 | + |
|
614 | + // then we always check if adding or removing. |
|
615 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
616 | + $question_group->add_question($question_ID); |
|
617 | + } else { |
|
618 | + // not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it) |
|
619 | + if ( |
|
620 | + in_array( |
|
621 | + $question->system_ID(), |
|
622 | + EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group()) |
|
623 | + ) |
|
624 | + ) { |
|
625 | + continue; |
|
626 | + } else { |
|
627 | + $question_group->remove_question($question_ID); |
|
628 | + } |
|
629 | + } |
|
630 | + } |
|
631 | + // save new related questions |
|
632 | + if (isset($this->_req_data['questions'])) { |
|
633 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
634 | + $question_group->add_question($QST_ID); |
|
635 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
636 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
637 | + } |
|
638 | + } |
|
639 | + } |
|
640 | + |
|
641 | + if ($success !== false) { |
|
642 | + $msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
643 | + $this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated', |
|
644 | + 'event_espresso'), $this->_question_group_model->item_name()); |
|
645 | + EE_Error::add_success($msg); |
|
646 | + } |
|
647 | + $this->_redirect_after_action(false, '', '', array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
648 | + true); |
|
649 | + |
|
650 | + } |
|
651 | + |
|
652 | + /** |
|
653 | + * duplicates a question and all its question options and redirects to the new question. |
|
654 | + */ |
|
655 | + public function _duplicate_question() |
|
656 | + { |
|
657 | + $question_ID = (int)$this->_req_data['QST_ID']; |
|
658 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
659 | + if ($question instanceof EE_Question) { |
|
660 | + $new_question = $question->duplicate(); |
|
661 | + if ($new_question instanceof EE_Question) { |
|
662 | + $this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'), |
|
663 | + esc_html__('Duplicated', 'event_espresso'), |
|
664 | + array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), true); |
|
665 | + } else { |
|
666 | + global $wpdb; |
|
667 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s', |
|
668 | + 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__); |
|
669 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
670 | + } |
|
671 | + } else { |
|
672 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!', |
|
673 | + 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__); |
|
674 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
675 | + } |
|
676 | + } |
|
677 | + |
|
678 | + |
|
679 | + /** |
|
680 | + * @param bool $trash |
|
681 | + */ |
|
682 | + protected function _trash_or_restore_question_groups($trash = true) |
|
683 | + { |
|
684 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
685 | + } |
|
686 | + |
|
687 | + |
|
688 | + /** |
|
689 | + *_trash_question |
|
690 | + */ |
|
691 | + protected function _trash_question() |
|
692 | + { |
|
693 | + $success = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']); |
|
694 | + $query_args = array('action' => 'default', 'status' => 'all'); |
|
695 | + $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
696 | + } |
|
697 | + |
|
698 | + |
|
699 | + /** |
|
700 | + * @param bool $trash |
|
701 | + */ |
|
702 | + protected function _trash_or_restore_questions($trash = true) |
|
703 | + { |
|
704 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
705 | + } |
|
706 | + |
|
707 | + |
|
708 | + /** |
|
709 | + * Internally used to delete or restore items, using the request data. Meant to be |
|
710 | + * flexible between question or question groups |
|
711 | + * |
|
712 | + * @param EEM_Soft_Delete_Base $model |
|
713 | + * @param boolean $trash whether to trash or restore |
|
714 | + */ |
|
715 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
716 | + { |
|
717 | + |
|
718 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
719 | + |
|
720 | + $success = 1; |
|
721 | + //Checkboxes |
|
722 | + //echo "trash $trash"; |
|
723 | + //var_dump($this->_req_data['checkbox']);die; |
|
724 | + if (isset($this->_req_data['checkbox'])) { |
|
725 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
726 | + // if array has more than one element than success message should be plural |
|
727 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
728 | + // cycle thru bulk action checkboxes |
|
729 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
730 | + if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
731 | + $success = 0; |
|
732 | + } |
|
733 | + } |
|
734 | + |
|
735 | + } else { |
|
736 | + // grab single id and delete |
|
737 | + $ID = absint($this->_req_data['checkbox']); |
|
738 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
739 | + $success = 0; |
|
740 | + } |
|
741 | + } |
|
742 | + |
|
743 | + } else { |
|
744 | + // delete via trash link |
|
745 | + // grab single id and delete |
|
746 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
747 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
748 | + $success = 0; |
|
749 | + } |
|
750 | + |
|
751 | + } |
|
752 | + |
|
753 | + |
|
754 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) ); |
|
755 | + //echo "action :$action"; |
|
756 | + //$action = 'questions' ? 'default' : $action; |
|
757 | + if ($trash) { |
|
758 | + $action_desc = 'trashed'; |
|
759 | + $status = 'trash'; |
|
760 | + } else { |
|
761 | + $action_desc = 'restored'; |
|
762 | + $status = 'all'; |
|
763 | + } |
|
764 | + $this->_redirect_after_action($success, $model->item_name($success), $action_desc, |
|
765 | + array('action' => $action, 'status' => $status)); |
|
766 | + } |
|
767 | + |
|
768 | + |
|
769 | + /** |
|
770 | + * @param $per_page |
|
771 | + * @param int $current_page |
|
772 | + * @param bool|false $count |
|
773 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
774 | + */ |
|
775 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
776 | + { |
|
777 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
778 | + |
|
779 | + if ($count) { |
|
780 | + //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
781 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
782 | + $results = $this->_question_model->count_deleted($where); |
|
783 | + } else { |
|
784 | + //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
785 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
786 | + } |
|
787 | + return $results; |
|
788 | + } |
|
789 | + |
|
790 | + |
|
791 | + /** |
|
792 | + * @param $per_page |
|
793 | + * @param int $current_page |
|
794 | + * @param bool|false $count |
|
795 | + * @return \EE_Soft_Delete_Base_Class[] |
|
796 | + */ |
|
797 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
798 | + { |
|
799 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
800 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
801 | + if ($count) { |
|
802 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
803 | + $results = $questionGroupModel->count($where); |
|
804 | + } else { |
|
805 | + $results = $questionGroupModel->get_all($query_params); |
|
806 | + } |
|
807 | + return $results; |
|
808 | + } |
|
809 | + |
|
810 | + |
|
811 | + /** |
|
812 | + * @param $per_page |
|
813 | + * @param int $current_page |
|
814 | + * @param bool $count |
|
815 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
816 | + */ |
|
817 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
818 | + { |
|
819 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
820 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
821 | + if ($count) { |
|
822 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
823 | + $query_params['limit'] = null; |
|
824 | + $results = $questionGroupModel->count_deleted($where); |
|
825 | + } else { |
|
826 | + $results = $questionGroupModel->get_all_deleted($query_params); |
|
827 | + } |
|
828 | + return $results; |
|
829 | + } |
|
830 | + |
|
831 | + |
|
832 | + /** |
|
833 | + * method for performing updates to question order |
|
834 | + * |
|
835 | + * @return array results array |
|
836 | + */ |
|
837 | + public function update_question_group_order() |
|
838 | + { |
|
839 | + |
|
840 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
841 | + |
|
842 | + // grab our row IDs |
|
843 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
844 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
845 | + : array(); |
|
846 | + |
|
847 | + $perpage = ! empty($this->_req_data['perpage']) |
|
848 | + ? (int)$this->_req_data['perpage'] |
|
849 | + : null; |
|
850 | + $curpage = ! empty($this->_req_data['curpage']) |
|
851 | + ? (int)$this->_req_data['curpage'] |
|
852 | + : null; |
|
853 | + |
|
854 | + if (! empty($row_ids)) { |
|
855 | + //figure out where we start the row_id count at for the current page. |
|
856 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
857 | + |
|
858 | + $row_count = count($row_ids); |
|
859 | + for ($i = 0; $i < $row_count; $i++) { |
|
860 | + //Update the questions when re-ordering |
|
861 | + $updated = EEM_Question_Group::instance()->update( |
|
862 | + array('QSG_order' => $qsgcount), |
|
863 | + array(array('QSG_ID' => $row_ids[$i])) |
|
864 | + ); |
|
865 | + if ($updated === false) { |
|
866 | + $success = false; |
|
867 | + } |
|
868 | + $qsgcount++; |
|
869 | + } |
|
870 | + } else { |
|
871 | + $success = false; |
|
872 | + } |
|
873 | + |
|
874 | + $errors = ! $success |
|
875 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
876 | + : false; |
|
877 | + |
|
878 | + echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
879 | + die(); |
|
880 | + |
|
881 | + } |
|
882 | + |
|
883 | + |
|
884 | + |
|
885 | + /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
886 | + |
|
887 | + |
|
888 | + /** |
|
889 | + * _reg_form_settings |
|
890 | + * |
|
891 | + * @throws \EE_Error |
|
892 | + */ |
|
893 | + protected function _reg_form_settings() |
|
894 | + { |
|
895 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
896 | + add_action( |
|
897 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
898 | + array($this, 'email_validation_settings_form'), |
|
899 | + 2 |
|
900 | + ); |
|
901 | + $this->_template_args = (array)apply_filters( |
|
902 | + 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
903 | + $this->_template_args |
|
904 | + ); |
|
905 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
906 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
907 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
908 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
909 | + $this->_template_args, |
|
910 | + true |
|
911 | + ); |
|
912 | + $this->display_admin_page_with_sidebar(); |
|
913 | + } |
|
914 | + |
|
915 | + |
|
916 | + /** |
|
917 | + * _update_reg_form_settings |
|
918 | + */ |
|
919 | + protected function _update_reg_form_settings() |
|
920 | + { |
|
921 | + EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
922 | + EE_Registry::instance()->CFG->registration |
|
923 | + ); |
|
924 | + EE_Registry::instance()->CFG->registration = apply_filters( |
|
925 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
926 | + EE_Registry::instance()->CFG->registration |
|
927 | + ); |
|
928 | + $success = $this->_update_espresso_configuration( |
|
929 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
930 | + EE_Registry::instance()->CFG, |
|
931 | + __FILE__, __FUNCTION__, __LINE__ |
|
932 | + ); |
|
933 | + $this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', |
|
934 | + array('action' => 'view_reg_form_settings')); |
|
935 | + } |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * email_validation_settings_form |
|
940 | + * |
|
941 | + * @access public |
|
942 | + * @return void |
|
943 | + * @throws \EE_Error |
|
944 | + */ |
|
945 | + public function email_validation_settings_form() |
|
946 | + { |
|
947 | + echo $this->_email_validation_settings_form()->get_html(); |
|
948 | + } |
|
949 | + |
|
950 | + |
|
951 | + /** |
|
952 | + * _email_validation_settings_form |
|
953 | + * |
|
954 | + * @access protected |
|
955 | + * @return EE_Form_Section_Proper |
|
956 | + * @throws \EE_Error |
|
957 | + */ |
|
958 | + protected function _email_validation_settings_form() |
|
959 | + { |
|
960 | + return new EE_Form_Section_Proper( |
|
961 | + array( |
|
962 | + 'name' => 'email_validation_settings', |
|
963 | + 'html_id' => 'email_validation_settings', |
|
964 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
965 | + 'subsections' => array( |
|
966 | + 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
967 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
968 | + ), |
|
969 | + 'email_validation_level' => new EE_Select_Input( |
|
970 | + array( |
|
971 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
972 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
973 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
974 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
975 | + ), |
|
976 | + array( |
|
977 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
978 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
979 | + 'html_help_text' => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
980 | + 'event_espresso'), |
|
981 | + 'default' => isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
982 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
983 | + : 'wp_default', |
|
984 | + 'required' => false, |
|
985 | + ) |
|
986 | + ), |
|
987 | + ), |
|
988 | + ) |
|
989 | + ); |
|
990 | + } |
|
991 | + |
|
992 | + |
|
993 | + /** |
|
994 | + * update_email_validation_settings_form |
|
995 | + * |
|
996 | + * @access public |
|
997 | + * @param \EE_Registration_Config $EE_Registration_Config |
|
998 | + * @return \EE_Registration_Config |
|
999 | + */ |
|
1000 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1001 | + { |
|
1002 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1003 | + try { |
|
1004 | + $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1005 | + // if not displaying a form, then check for form submission |
|
1006 | + if ($email_validation_settings_form->was_submitted()) { |
|
1007 | + // capture form data |
|
1008 | + $email_validation_settings_form->receive_form_submission(); |
|
1009 | + // validate form data |
|
1010 | + if ($email_validation_settings_form->is_valid()) { |
|
1011 | + // grab validated data from form |
|
1012 | + $valid_data = $email_validation_settings_form->valid_data(); |
|
1013 | + if (isset($valid_data['email_validation_level'])) { |
|
1014 | + $email_validation_level = $valid_data['email_validation_level']; |
|
1015 | + // now if they want to use international email addresses |
|
1016 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1017 | + // in case we need to reset their email validation level, |
|
1018 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1019 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1020 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1021 | + // despite offering poor validation, supports i18n email addresses |
|
1022 | + $prev_email_validation_level = 'basic'; |
|
1023 | + } |
|
1024 | + // confirm our i18n email validation will work on the server |
|
1025 | + if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1026 | + // or reset email validation level to previous value |
|
1027 | + $email_validation_level = $prev_email_validation_level; |
|
1028 | + } |
|
1029 | + } |
|
1030 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1031 | + } else { |
|
1032 | + EE_Error::add_error( |
|
1033 | + esc_html__( |
|
1034 | + 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1035 | + 'event_espresso' |
|
1036 | + ), |
|
1037 | + __FILE__, __FUNCTION__, __LINE__ |
|
1038 | + ); |
|
1039 | + } |
|
1040 | + } else { |
|
1041 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1042 | + EE_Error::add_error( |
|
1043 | + $email_validation_settings_form->submission_error_message(), |
|
1044 | + __FILE__, __FUNCTION__, __LINE__ |
|
1045 | + ); |
|
1046 | + } |
|
1047 | + } |
|
1048 | + } |
|
1049 | + } catch (EE_Error $e) { |
|
1050 | + $e->get_error(); |
|
1051 | + } |
|
1052 | + return $EE_Registration_Config; |
|
1053 | + } |
|
1054 | + |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1058 | + * and that the PCRE version works with our i18n email validation |
|
1059 | + * |
|
1060 | + * @param \EE_Registration_Config $EE_Registration_Config |
|
1061 | + * @param string $email_validation_level |
|
1062 | + * @return bool |
|
1063 | + */ |
|
1064 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1065 | + { |
|
1066 | + // first check that PCRE is enabled |
|
1067 | + if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1068 | + EE_Error::add_error( |
|
1069 | + sprintf( |
|
1070 | + esc_html__( |
|
1071 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1072 | + 'event_espresso' |
|
1073 | + ), |
|
1074 | + '<br />' |
|
1075 | + ), |
|
1076 | + __FILE__, |
|
1077 | + __FUNCTION__, |
|
1078 | + __LINE__ |
|
1079 | + ); |
|
1080 | + return false; |
|
1081 | + } else { |
|
1082 | + // PCRE support is enabled, but let's still |
|
1083 | + // perform a test to see if the server will support it. |
|
1084 | + // but first, save the updated validation level to the config, |
|
1085 | + // so that the validation strategy picks it up. |
|
1086 | + // this will get bumped back down if it doesn't work |
|
1087 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1088 | + try { |
|
1089 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1090 | + $i18n_email_address = apply_filters( |
|
1091 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1092 | + 'jägerjü[email protected]' |
|
1093 | + ); |
|
1094 | + $email_validator->validate($i18n_email_address); |
|
1095 | + } catch (Exception $e) { |
|
1096 | + EE_Error::add_error( |
|
1097 | + sprintf( |
|
1098 | + esc_html__( |
|
1099 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1100 | + 'event_espresso' |
|
1101 | + ), |
|
1102 | + '<br />', |
|
1103 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1104 | + ), |
|
1105 | + __FILE__, __FUNCTION__, __LINE__ |
|
1106 | + ); |
|
1107 | + return false; |
|
1108 | + } |
|
1109 | + } |
|
1110 | + return true; |
|
1111 | + } |
|
1112 | 1112 | |
1113 | 1113 | |
1114 | 1114 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function __construct($routing = true) |
34 | 34 | { |
35 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS); |
|
36 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS); |
|
37 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
38 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS); |
|
39 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
35 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS); |
|
36 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS); |
|
37 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/'); |
|
38 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS); |
|
39 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/'); |
|
40 | 40 | parent::__construct($routing); |
41 | 41 | } |
42 | 42 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
48 | 48 | $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0; |
49 | 49 | |
50 | - $new_page_routes = array( |
|
50 | + $new_page_routes = array( |
|
51 | 51 | 'question_groups' => array( |
52 | 52 | 'func' => '_question_groups_overview_list_table', |
53 | 53 | 'capability' => 'ee_read_question_groups', |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | |
312 | 312 | //additional labels |
313 | - $new_labels = array( |
|
313 | + $new_labels = array( |
|
314 | 314 | 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
315 | 315 | 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
316 | 316 | 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function load_sortable_question_script() |
356 | 356 | { |
357 | - wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
357 | + wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', |
|
358 | 358 | array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
359 | 359 | wp_enqueue_script('ee-question-sortable'); |
360 | 360 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | protected function _questions_overview_list_table() |
422 | 422 | { |
423 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
423 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
424 | 424 | 'add_question', |
425 | 425 | 'add_question', |
426 | 426 | array(), |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | protected function _question_groups_overview_list_table() |
434 | 434 | { |
435 | 435 | $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
436 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
436 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
437 | 437 | 'add_question_group', |
438 | 438 | 'add_question_group', |
439 | 439 | array(), |
@@ -477,20 +477,20 @@ discard block |
||
477 | 477 | { |
478 | 478 | $success = 0; |
479 | 479 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
480 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
480 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
481 | 481 | // if array has more than one element than success message should be plural |
482 | 482 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
483 | 483 | // cycle thru bulk action checkboxes |
484 | 484 | while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
485 | - if (! $this->_delete_item($ID, $model)) { |
|
485 | + if ( ! $this->_delete_item($ID, $model)) { |
|
486 | 486 | $success = 0; |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
490 | + } elseif ( ! empty($this->_req_data['QSG_ID'])) { |
|
491 | 491 | $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
492 | 492 | |
493 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
493 | + } elseif ( ! empty($this->_req_data['QST_ID'])) { |
|
494 | 494 | $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
495 | 495 | } else { |
496 | 496 | EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
535 | 535 | } |
536 | 536 | // add ID to title if editing |
537 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
537 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
538 | 538 | if ($ID) { |
539 | 539 | /** @var EE_Question_Group $questionGroup */ |
540 | 540 | $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
555 | 555 | $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
556 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
556 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', |
|
557 | 557 | $this->_template_args, true); |
558 | 558 | |
559 | 559 | // the details template wrapper |
@@ -600,13 +600,13 @@ discard block |
||
600 | 600 | $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
601 | 601 | $questions = $question_group->questions(); |
602 | 602 | // make sure system phone question is added to list of questions for this group |
603 | - if (! isset($questions[$phone_question_id])) { |
|
603 | + if ( ! isset($questions[$phone_question_id])) { |
|
604 | 604 | $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
605 | 605 | } |
606 | 606 | |
607 | 607 | foreach ($questions as $question_ID => $question) { |
608 | 608 | // first we always check for order. |
609 | - if (! empty($this->_req_data['question_orders'][$question_ID])) { |
|
609 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
610 | 610 | //update question order |
611 | 611 | $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]); |
612 | 612 | } |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | */ |
655 | 655 | public function _duplicate_question() |
656 | 656 | { |
657 | - $question_ID = (int)$this->_req_data['QST_ID']; |
|
657 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
658 | 658 | $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
659 | 659 | if ($question instanceof EE_Question) { |
660 | 660 | $new_question = $question->duplicate(); |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | */ |
691 | 691 | protected function _trash_question() |
692 | 692 | { |
693 | - $success = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']); |
|
693 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
694 | 694 | $query_args = array('action' => 'default', 'status' => 'all'); |
695 | 695 | $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
696 | 696 | } |
@@ -722,12 +722,12 @@ discard block |
||
722 | 722 | //echo "trash $trash"; |
723 | 723 | //var_dump($this->_req_data['checkbox']);die; |
724 | 724 | if (isset($this->_req_data['checkbox'])) { |
725 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
725 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
726 | 726 | // if array has more than one element than success message should be plural |
727 | 727 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
728 | 728 | // cycle thru bulk action checkboxes |
729 | 729 | while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
730 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
730 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
731 | 731 | $success = 0; |
732 | 732 | } |
733 | 733 | } |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | } else { |
736 | 736 | // grab single id and delete |
737 | 737 | $ID = absint($this->_req_data['checkbox']); |
738 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
738 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
739 | 739 | $success = 0; |
740 | 740 | } |
741 | 741 | } |
@@ -744,14 +744,14 @@ discard block |
||
744 | 744 | // delete via trash link |
745 | 745 | // grab single id and delete |
746 | 746 | $ID = absint($this->_req_data[$model->primary_key_name()]); |
747 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
747 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
748 | 748 | $success = 0; |
749 | 749 | } |
750 | 750 | |
751 | 751 | } |
752 | 752 | |
753 | 753 | |
754 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) ); |
|
754 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) ); |
|
755 | 755 | //echo "action :$action"; |
756 | 756 | //$action = 'questions' ? 'default' : $action; |
757 | 757 | if ($trash) { |
@@ -845,13 +845,13 @@ discard block |
||
845 | 845 | : array(); |
846 | 846 | |
847 | 847 | $perpage = ! empty($this->_req_data['perpage']) |
848 | - ? (int)$this->_req_data['perpage'] |
|
848 | + ? (int) $this->_req_data['perpage'] |
|
849 | 849 | : null; |
850 | 850 | $curpage = ! empty($this->_req_data['curpage']) |
851 | - ? (int)$this->_req_data['curpage'] |
|
851 | + ? (int) $this->_req_data['curpage'] |
|
852 | 852 | : null; |
853 | 853 | |
854 | - if (! empty($row_ids)) { |
|
854 | + if ( ! empty($row_ids)) { |
|
855 | 855 | //figure out where we start the row_id count at for the current page. |
856 | 856 | $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
857 | 857 | |
@@ -898,14 +898,14 @@ discard block |
||
898 | 898 | array($this, 'email_validation_settings_form'), |
899 | 899 | 2 |
900 | 900 | ); |
901 | - $this->_template_args = (array)apply_filters( |
|
901 | + $this->_template_args = (array) apply_filters( |
|
902 | 902 | 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
903 | 903 | $this->_template_args |
904 | 904 | ); |
905 | 905 | $this->_set_add_edit_form_tags('update_reg_form_settings'); |
906 | 906 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
907 | 907 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
908 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
908 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
909 | 909 | $this->_template_args, |
910 | 910 | true |
911 | 911 | ); |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
926 | 926 | EE_Registry::instance()->CFG->registration |
927 | 927 | ); |
928 | - $success = $this->_update_espresso_configuration( |
|
928 | + $success = $this->_update_espresso_configuration( |
|
929 | 929 | esc_html__('Registration Form Options', 'event_espresso'), |
930 | 930 | EE_Registry::instance()->CFG, |
931 | 931 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | $prev_email_validation_level = 'basic'; |
1023 | 1023 | } |
1024 | 1024 | // confirm our i18n email validation will work on the server |
1025 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1025 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1026 | 1026 | // or reset email validation level to previous value |
1027 | 1027 | $email_validation_level = $prev_email_validation_level; |
1028 | 1028 | } |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
1065 | 1065 | { |
1066 | 1066 | // first check that PCRE is enabled |
1067 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1067 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1068 | 1068 | EE_Error::add_error( |
1069 | 1069 | sprintf( |
1070 | 1070 | esc_html__( |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param string $value_to_normalize |
14 | - * @return int|mixed|string |
|
14 | + * @return integer|null |
|
15 | 15 | * @throws \EE_Validation_Error |
16 | 16 | */ |
17 | 17 | public function normalize($value_to_normalize) { |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) { |
23 | - return null; |
|
24 | - } |
|
23 | + return null; |
|
24 | + } |
|
25 | 25 | |
26 | 26 | if( ! is_string( $value_to_normalize )){ |
27 | 27 | throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) ); |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @return string |
57 | 57 | */ |
58 | 58 | public function unnormalize( $normalized_value ) { |
59 | - if ($normalized_value === null) { |
|
60 | - return ''; |
|
61 | - }elseif( empty( $normalized_value ) ){ |
|
59 | + if ($normalized_value === null) { |
|
60 | + return ''; |
|
61 | + }elseif( empty( $normalized_value ) ){ |
|
62 | 62 | return '0'; |
63 | 63 | }else{ |
64 | 64 | return "$normalized_value"; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @subpackage |
8 | 8 | * @author Mike Nelson |
9 | 9 | */ |
10 | -class EE_Int_Normalization extends EE_Normalization_Strategy_Base{ |
|
10 | +class EE_Int_Normalization extends EE_Normalization_Strategy_Base { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param string $value_to_normalize |
@@ -15,38 +15,38 @@ discard block |
||
15 | 15 | * @throws \EE_Validation_Error |
16 | 16 | */ |
17 | 17 | public function normalize($value_to_normalize) { |
18 | - if( is_int( $value_to_normalize ) ){ |
|
18 | + if (is_int($value_to_normalize)) { |
|
19 | 19 | return $value_to_normalize; |
20 | 20 | } |
21 | 21 | |
22 | - if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) { |
|
22 | + if (is_null($value_to_normalize) || $value_to_normalize === '') { |
|
23 | 23 | return null; |
24 | 24 | } |
25 | 25 | |
26 | - if( ! is_string( $value_to_normalize )){ |
|
27 | - throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) ); |
|
26 | + if ( ! is_string($value_to_normalize)) { |
|
27 | + throw new EE_Validation_Error(sprintf(__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), print_r($value_to_normalize, TRUE), gettype($value_to_normalize))); |
|
28 | 28 | } |
29 | 29 | $thousands_separator = EE_Config::instance()->currency->thsnds; |
30 | - $value_to_normalize = str_replace( $thousands_separator, "", $value_to_normalize ); |
|
31 | - $value_to_normalize = str_replace( array(" ","\t"), '', $value_to_normalize ); |
|
32 | - if ( preg_match( '/^\d+$/', $value_to_normalize )) { |
|
33 | - return intval( $value_to_normalize ); |
|
30 | + $value_to_normalize = str_replace($thousands_separator, "", $value_to_normalize); |
|
31 | + $value_to_normalize = str_replace(array(" ", "\t"), '', $value_to_normalize); |
|
32 | + if (preg_match('/^\d+$/', $value_to_normalize)) { |
|
33 | + return intval($value_to_normalize); |
|
34 | 34 | } else { |
35 | 35 | //find if this input has a int validation strategy |
36 | 36 | //in which case, use its message |
37 | 37 | $validation_error_message = NULL; |
38 | - foreach( $this->_input->get_validation_strategies() as $validation_strategy ){ |
|
39 | - if( $validation_strategy instanceof EE_Int_Validation_Strategy ){ |
|
38 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
39 | + if ($validation_strategy instanceof EE_Int_Validation_Strategy) { |
|
40 | 40 | $validation_error_message = $validation_strategy->get_validation_error_message(); |
41 | 41 | } |
42 | 42 | } |
43 | 43 | //this really shouldn't ever happen because fields with a int normalization strategy |
44 | 44 | //should also have a int validation strategy, but in case it doesnt use the default |
45 | - if( ! $validation_error_message ){ |
|
45 | + if ( ! $validation_error_message) { |
|
46 | 46 | $default_validation_strategy = new EE_Int_Validation_Strategy(); |
47 | 47 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
48 | 48 | } |
49 | - throw new EE_Validation_Error( $validation_error_message, 'numeric_only' ); |
|
49 | + throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @param int $normalized_value |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public function unnormalize( $normalized_value ) { |
|
58 | + public function unnormalize($normalized_value) { |
|
59 | 59 | if ($normalized_value === null) { |
60 | 60 | return ''; |
61 | - }elseif( empty( $normalized_value ) ){ |
|
61 | + }elseif (empty($normalized_value)) { |
|
62 | 62 | return '0'; |
63 | - }else{ |
|
63 | + } else { |
|
64 | 64 | return "$normalized_value"; |
65 | 65 | } |
66 | 66 | } |
@@ -58,9 +58,9 @@ |
||
58 | 58 | public function unnormalize( $normalized_value ) { |
59 | 59 | if ($normalized_value === null) { |
60 | 60 | return ''; |
61 | - }elseif( empty( $normalized_value ) ){ |
|
61 | + } elseif( empty( $normalized_value ) ){ |
|
62 | 62 | return '0'; |
63 | - }else{ |
|
63 | + } else{ |
|
64 | 64 | return "$normalized_value"; |
65 | 65 | } |
66 | 66 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function normalize($value_to_normalize) { |
17 | 17 | if(is_array($value_to_normalize)) { |
18 | - return array_shift($value_to_normalize); |
|
19 | - //consider `"null"` values to be equivalent to null. |
|
20 | - }elseif($value_to_normalize === '' || $value_to_normalize === null) { |
|
21 | - return null; |
|
18 | + return array_shift($value_to_normalize); |
|
19 | + //consider `"null"` values to be equivalent to null. |
|
20 | + }elseif($value_to_normalize === '' || $value_to_normalize === null) { |
|
21 | + return null; |
|
22 | 22 | }else{ |
23 | 23 | return $value_to_normalize; |
24 | 24 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * @return string |
30 | 30 | */ |
31 | 31 | public function unnormalize( $normalized_value ){ |
32 | - //account for default "select here" option values |
|
33 | - if ($normalized_value === null) { |
|
34 | - return ''; |
|
35 | - } |
|
32 | + //account for default "select here" option values |
|
33 | + if ($normalized_value === null) { |
|
34 | + return ''; |
|
35 | + } |
|
36 | 36 | return $normalized_value; |
37 | 37 | } |
38 | 38 | } |
@@ -7,19 +7,19 @@ discard block |
||
7 | 7 | * @subpackage |
8 | 8 | * @author Mike Nelson |
9 | 9 | */ |
10 | -class EE_Text_Normalization extends EE_Normalization_Strategy_Base{ |
|
10 | +class EE_Text_Normalization extends EE_Normalization_Strategy_Base { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param string $value_to_normalize |
14 | 14 | * @return array|mixed|string |
15 | 15 | */ |
16 | 16 | public function normalize($value_to_normalize) { |
17 | - if(is_array($value_to_normalize)) { |
|
17 | + if (is_array($value_to_normalize)) { |
|
18 | 18 | return array_shift($value_to_normalize); |
19 | 19 | //consider `"null"` values to be equivalent to null. |
20 | - }elseif($value_to_normalize === '' || $value_to_normalize === null) { |
|
20 | + }elseif ($value_to_normalize === '' || $value_to_normalize === null) { |
|
21 | 21 | return null; |
22 | - }else{ |
|
22 | + } else { |
|
23 | 23 | return $value_to_normalize; |
24 | 24 | } |
25 | 25 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param string $normalized_value |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - public function unnormalize( $normalized_value ){ |
|
31 | + public function unnormalize($normalized_value) { |
|
32 | 32 | //account for default "select here" option values |
33 | 33 | if ($normalized_value === null) { |
34 | 34 | return ''; |
@@ -17,9 +17,9 @@ |
||
17 | 17 | if(is_array($value_to_normalize)) { |
18 | 18 | return array_shift($value_to_normalize); |
19 | 19 | //consider `"null"` values to be equivalent to null. |
20 | - }elseif($value_to_normalize === '' || $value_to_normalize === null) { |
|
20 | + } elseif($value_to_normalize === '' || $value_to_normalize === null) { |
|
21 | 21 | return null; |
22 | - }else{ |
|
22 | + } else{ |
|
23 | 23 | return $value_to_normalize; |
24 | 24 | } |
25 | 25 | } |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
446 | 446 | $new_question->set_system_ID( null ); |
447 | 447 | $new_question->set_wp_user( get_current_user_id() ); |
448 | - //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
449 | - $new_question->set_deleted( false ); |
|
448 | + //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
449 | + $new_question->set_deleted( false ); |
|
450 | 450 | $success = $new_question->save(); |
451 | 451 | if( $success ) { |
452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | } |
502 | 502 | // has this question been answered ? |
503 | 503 | if ( $answer instanceof EE_Answer |
504 | - && $answer->value() !== '' |
|
505 | - ) { |
|
504 | + && $answer->value() !== '' |
|
505 | + ) { |
|
506 | 506 | //answer gets htmlspecialchars called on it, undo that please |
507 | 507 | //because the form input's display strategy may call esc_attr too |
508 | 508 | //which also does html special characters |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * date_format and the second value is the time format |
38 | 38 | * @return EE_Question |
39 | 39 | */ |
40 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
41 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
42 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
40 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
41 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
42 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * the website will be used. |
51 | 51 | * @return EE_Question |
52 | 52 | */ |
53 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
54 | - return new self( $props_n_values, TRUE, $timezone ); |
|
53 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
54 | + return new self($props_n_values, TRUE, $timezone); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @access public |
63 | 63 | * @param string $QST_display_text |
64 | 64 | */ |
65 | - public function set_display_text( $QST_display_text = '' ) { |
|
66 | - $this->set( 'QST_display_text', $QST_display_text ); |
|
65 | + public function set_display_text($QST_display_text = '') { |
|
66 | + $this->set('QST_display_text', $QST_display_text); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @access public |
75 | 75 | * @param string $QST_admin_label |
76 | 76 | */ |
77 | - public function set_admin_label( $QST_admin_label = '' ) { |
|
78 | - $this->set( 'QST_admin_label', $QST_admin_label ); |
|
77 | + public function set_admin_label($QST_admin_label = '') { |
|
78 | + $this->set('QST_admin_label', $QST_admin_label); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @access public |
87 | 87 | * @param mixed $QST_system |
88 | 88 | */ |
89 | - public function set_system_ID( $QST_system = '' ) { |
|
90 | - $this->set( 'QST_system', $QST_system ); |
|
89 | + public function set_system_ID($QST_system = '') { |
|
90 | + $this->set('QST_system', $QST_system); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @access public |
99 | 99 | * @param string $QST_type |
100 | 100 | */ |
101 | - public function set_question_type( $QST_type = '' ) { |
|
102 | - $this->set( 'QST_type', $QST_type ); |
|
101 | + public function set_question_type($QST_type = '') { |
|
102 | + $this->set('QST_type', $QST_type); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @access public |
111 | 111 | * @param bool $QST_required |
112 | 112 | */ |
113 | - public function set_required( $QST_required = FALSE ) { |
|
114 | - $this->set( 'QST_required', $QST_required ); |
|
113 | + public function set_required($QST_required = FALSE) { |
|
114 | + $this->set('QST_required', $QST_required); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @access public |
123 | 123 | * @param string $QST_required_text |
124 | 124 | */ |
125 | - public function set_required_text( $QST_required_text = '' ) { |
|
126 | - $this->set( 'QST_required_text', $QST_required_text ); |
|
125 | + public function set_required_text($QST_required_text = '') { |
|
126 | + $this->set('QST_required_text', $QST_required_text); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @access public |
135 | 135 | * @param int $QST_order |
136 | 136 | */ |
137 | - public function set_order( $QST_order = 0 ) { |
|
138 | - $this->set( 'QST_order', $QST_order ); |
|
137 | + public function set_order($QST_order = 0) { |
|
138 | + $this->set('QST_order', $QST_order); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | * @param bool $QST_admin_only |
148 | 148 | */ |
149 | - public function set_admin_only( $QST_admin_only = FALSE ) { |
|
150 | - $this->set( 'QST_admin_only', $QST_admin_only ); |
|
149 | + public function set_admin_only($QST_admin_only = FALSE) { |
|
150 | + $this->set('QST_admin_only', $QST_admin_only); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @access public |
159 | 159 | * @param int $QST_wp_user |
160 | 160 | */ |
161 | - public function set_wp_user( $QST_wp_user = 1 ) { |
|
162 | - $this->set( 'QST_wp_user', $QST_wp_user ); |
|
161 | + public function set_wp_user($QST_wp_user = 1) { |
|
162 | + $this->set('QST_wp_user', $QST_wp_user); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param bool $QST_deleted |
177 | 177 | */ |
178 | - public function set_deleted( $QST_deleted = FALSE ) { |
|
179 | - $this->set( 'QST_deleted', $QST_deleted ); |
|
178 | + public function set_deleted($QST_deleted = FALSE) { |
|
179 | + $this->set('QST_deleted', $QST_deleted); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return string |
188 | 188 | */ |
189 | 189 | public function display_text() { |
190 | - return $this->get( 'QST_display_text' ); |
|
190 | + return $this->get('QST_display_text'); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return string |
199 | 199 | */ |
200 | 200 | public function admin_label() { |
201 | - return $this->get( 'QST_admin_label' ); |
|
201 | + return $this->get('QST_admin_label'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return string |
210 | 210 | */ |
211 | 211 | public function system_ID() { |
212 | - return $this->get( 'QST_system' ); |
|
212 | + return $this->get('QST_system'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return boolean |
221 | 221 | */ |
222 | 222 | public function required() { |
223 | - return $this->get( 'QST_required' ); |
|
223 | + return $this->get('QST_required'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @return string |
233 | 233 | */ |
234 | 234 | public function required_text() { |
235 | - return $this->get( 'QST_required_text' ); |
|
235 | + return $this->get('QST_required_text'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return string |
244 | 244 | */ |
245 | 245 | public function type() { |
246 | - return $this->get( 'QST_type' ); |
|
246 | + return $this->get('QST_type'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return int |
256 | 256 | */ |
257 | 257 | public function order() { |
258 | - return $this->get( 'QST_order' ); |
|
258 | + return $this->get('QST_order'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return boolean |
268 | 268 | */ |
269 | 269 | public function admin_only() { |
270 | - return $this->get( 'QST_admin_only' ); |
|
270 | + return $this->get('QST_admin_only'); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return int |
279 | 279 | */ |
280 | 280 | public function wp_user() { |
281 | - return $this->get( 'QST_wp_user' ); |
|
281 | + return $this->get('QST_wp_user'); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | 291 | public function deleted() { |
292 | - return $this->get( 'QST_deleted' ); |
|
292 | + return $this->get('QST_deleted'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @return EE_Answer[] |
300 | 300 | */ |
301 | 301 | public function answers() { |
302 | - return $this->get_many_related( 'Answer' ); |
|
302 | + return $this->get_many_related('Answer'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return boolean true = has answers, false = no answers. |
310 | 310 | */ |
311 | 311 | public function has_answers() { |
312 | - return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE; |
|
312 | + return $this->count_related('Answer') > 0 ? TRUE : FALSE; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return EE_Question_Group[] |
320 | 320 | */ |
321 | 321 | public function question_groups() { |
322 | - return $this->get_many_related( 'Question_Group' ); |
|
322 | + return $this->get_many_related('Question_Group'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -333,24 +333,24 @@ discard block |
||
333 | 333 | * whether it was trashed or not. |
334 | 334 | * @return EE_Question_Option[] |
335 | 335 | */ |
336 | - public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) { |
|
337 | - if ( ! $this->ID() ) { |
|
336 | + public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) { |
|
337 | + if ( ! $this->ID()) { |
|
338 | 338 | return array(); |
339 | 339 | } |
340 | 340 | $query_params = array(); |
341 | - if ( $selected_value_to_always_include ) { |
|
342 | - if ( is_array( $selected_value_to_always_include ) ) { |
|
343 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include ); |
|
341 | + if ($selected_value_to_always_include) { |
|
342 | + if (is_array($selected_value_to_always_include)) { |
|
343 | + $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
344 | 344 | } else { |
345 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include; |
|
345 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
346 | 346 | } |
347 | 347 | } |
348 | - if ( $notDeletedOptionsOnly ) { |
|
349 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE; |
|
348 | + if ($notDeletedOptionsOnly) { |
|
349 | + $query_params[0]['OR*options-query']['QSO_deleted'] = FALSE; |
|
350 | 350 | } |
351 | 351 | //order by QSO_order |
352 | - $query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' ); |
|
353 | - return $this->get_many_related( 'Question_Option', $query_params ); |
|
352 | + $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
353 | + return $this->get_many_related('Question_Option', $query_params); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return \EE_Question_Option[] |
361 | 361 | */ |
362 | 362 | public function temp_options() { |
363 | - return $this->_model_relations[ 'Question_Option' ]; |
|
363 | + return $this->_model_relations['Question_Option']; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @param EE_Question_Option $option |
372 | 372 | * @return boolean success |
373 | 373 | */ |
374 | - public function add_option( EE_Question_Option $option ) { |
|
375 | - return $this->_add_relation_to( $option, 'Question_Option' ); |
|
374 | + public function add_option(EE_Question_Option $option) { |
|
375 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param EE_Question_Option $option |
383 | 383 | * @return boolean success |
384 | 384 | */ |
385 | - public function add_temp_option( EE_Question_Option $option ) { |
|
386 | - $this->_model_relations[ 'Question_Option' ][ ] = $option; |
|
385 | + public function add_temp_option(EE_Question_Option $option) { |
|
386 | + $this->_model_relations['Question_Option'][] = $option; |
|
387 | 387 | return TRUE; |
388 | 388 | } |
389 | 389 | |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | * @param EE_Question_Option $option |
395 | 395 | * @return boolean success |
396 | 396 | */ |
397 | - public function remove_option( EE_Question_Option $option ) { |
|
398 | - return $this->_remove_relation_to( $option, 'Question_Option' ); |
|
397 | + public function remove_option(EE_Question_Option $option) { |
|
398 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @return bool |
405 | 405 | */ |
406 | 406 | public function is_system_question() { |
407 | - $system_ID = $this->get( 'QST_system' ); |
|
408 | - return ! empty( $system_ID ) ? TRUE : FALSE; |
|
407 | + $system_ID = $this->get('QST_system'); |
|
408 | + return ! empty($system_ID) ? TRUE : FALSE; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function set_order_to_latest() { |
420 | 420 | $latest_order = $this->get_model()->get_latest_question_order(); |
421 | - $latest_order ++; |
|
422 | - $this->set( 'QST_order', $latest_order ); |
|
421 | + $latest_order++; |
|
422 | + $this->set('QST_order', $latest_order); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -438,20 +438,20 @@ discard block |
||
438 | 438 | * Duplicates this question and its question options |
439 | 439 | * @return \EE_Question |
440 | 440 | */ |
441 | - public function duplicate( $options = array() ) { |
|
441 | + public function duplicate($options = array()) { |
|
442 | 442 | $new_question = clone $this; |
443 | - $new_question->set( 'QST_ID', null ); |
|
444 | - $new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) ); |
|
445 | - $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
|
446 | - $new_question->set_system_ID( null ); |
|
447 | - $new_question->set_wp_user( get_current_user_id() ); |
|
443 | + $new_question->set('QST_ID', null); |
|
444 | + $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
445 | + $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
446 | + $new_question->set_system_ID(null); |
|
447 | + $new_question->set_wp_user(get_current_user_id()); |
|
448 | 448 | //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
449 | - $new_question->set_deleted( false ); |
|
449 | + $new_question->set_deleted(false); |
|
450 | 450 | $success = $new_question->save(); |
451 | - if( $success ) { |
|
451 | + if ($success) { |
|
452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
453 | - foreach( $this->options() as $question_option ) { |
|
454 | - $question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) ); |
|
453 | + foreach ($this->options() as $question_option) { |
|
454 | + $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
455 | 455 | } |
456 | 456 | return $new_question; |
457 | 457 | } else { |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return int|float |
465 | 465 | */ |
466 | 466 | public function max() { |
467 | - return $this->get( 'QST_max' ); |
|
467 | + return $this->get('QST_max'); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * @param int|float $new_max |
473 | 473 | * @return void |
474 | 474 | */ |
475 | - public function set_max( $new_max ) { |
|
476 | - $this->set( 'QST_max', $new_max ); |
|
475 | + public function set_max($new_max) { |
|
476 | + $this->set('QST_max', $new_max); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @param array $input_constructor_args |
486 | 486 | * @return EE_Form_Input_Base |
487 | 487 | */ |
488 | - public function generate_form_input( $registration = null, $answer = null, $input_constructor_args = array() ) { |
|
488 | + public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) { |
|
489 | 489 | $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
490 | 490 | |
491 | 491 | $input_constructor_args = array_merge( |
@@ -496,29 +496,29 @@ discard block |
||
496 | 496 | ), |
497 | 497 | $input_constructor_args |
498 | 498 | ); |
499 | - if( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration ) { |
|
500 | - $answer = EEM_Answer::instance()->get_registration_question_answer_object( $registration, $this->ID() ); |
|
499 | + if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
500 | + $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
501 | 501 | } |
502 | 502 | // has this question been answered ? |
503 | - if ( $answer instanceof EE_Answer |
|
503 | + if ($answer instanceof EE_Answer |
|
504 | 504 | && $answer->value() !== '' |
505 | 505 | ) { |
506 | 506 | //answer gets htmlspecialchars called on it, undo that please |
507 | 507 | //because the form input's display strategy may call esc_attr too |
508 | 508 | //which also does html special characters |
509 | 509 | $values_with_html_special_chars = $answer->value(); |
510 | - if( is_array( $values_with_html_special_chars ) ) { |
|
511 | - $default_value = array_map( 'htmlspecialchars_decode', $values_with_html_special_chars ); |
|
510 | + if (is_array($values_with_html_special_chars)) { |
|
511 | + $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
512 | 512 | } else { |
513 | - $default_value = htmlspecialchars_decode( $values_with_html_special_chars ); |
|
513 | + $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
514 | 514 | } |
515 | 515 | $input_constructor_args['default'] = $default_value; |
516 | 516 | } |
517 | - $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $this->system_ID() ); |
|
518 | - if( EEM_Question::instance()->question_type_is_in_category( $this->type(), 'text' ) ) { |
|
519 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy( |
|
517 | + $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
518 | + if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) { |
|
519 | + $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
520 | 520 | null, |
521 | - min( $max_max_for_question, $this->max() ) |
|
521 | + min($max_max_for_question, $this->max()) |
|
522 | 522 | ); |
523 | 523 | } |
524 | 524 | $input_constructor_args = apply_filters( |
@@ -530,22 +530,22 @@ discard block |
||
530 | 530 | ); |
531 | 531 | |
532 | 532 | $result = null; |
533 | - switch ( $this->type() ) { |
|
533 | + switch ($this->type()) { |
|
534 | 534 | // Text |
535 | 535 | case EEM_Question::QST_type_text : |
536 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
536 | + $result = new EE_Text_Input($input_constructor_args); |
|
537 | 537 | break; |
538 | 538 | // Textarea |
539 | 539 | case EEM_Question::QST_type_textarea : |
540 | - $result = new EE_Text_Area_Input( $input_constructor_args ); |
|
540 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
541 | 541 | break; |
542 | 542 | // Radio Buttons |
543 | 543 | case EEM_Question::QST_type_radio : |
544 | - $result = new EE_Radio_Button_Input( $this->options(), $input_constructor_args ); |
|
544 | + $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
545 | 545 | break; |
546 | 546 | // Dropdown |
547 | 547 | case EEM_Question::QST_type_dropdown : |
548 | - $result = new EE_Select_Input( $this->options(), $input_constructor_args ); |
|
548 | + $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
549 | 549 | break; |
550 | 550 | // State Dropdown |
551 | 551 | case EEM_Question::QST_type_state : |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | $registration, |
557 | 557 | $answer |
558 | 558 | ); |
559 | - $result = new EE_State_Select_Input( $state_options, $input_constructor_args ); |
|
559 | + $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
560 | 560 | break; |
561 | 561 | // Country Dropdown |
562 | 562 | case EEM_Question::QST_type_country : |
@@ -567,49 +567,49 @@ discard block |
||
567 | 567 | $registration, |
568 | 568 | $answer |
569 | 569 | ); |
570 | - $result = new EE_Country_Select_Input( $country_options, $input_constructor_args ); |
|
570 | + $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
571 | 571 | break; |
572 | 572 | // Checkboxes |
573 | 573 | case EEM_Question::QST_type_checkbox : |
574 | - $result = new EE_Checkbox_Multi_Input( $this->options(), $input_constructor_args ); |
|
574 | + $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
575 | 575 | break; |
576 | 576 | // Date |
577 | 577 | case EEM_Question::QST_type_date : |
578 | - $result = new EE_Datepicker_Input( $input_constructor_args ); |
|
578 | + $result = new EE_Datepicker_Input($input_constructor_args); |
|
579 | 579 | break; |
580 | 580 | case EEM_Question::QST_type_html_textarea : |
581 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy(); |
|
582 | - $result = new EE_Text_Area_Input( $input_constructor_args ); |
|
583 | - $result->remove_validation_strategy( 'EE_Plaintext_Validation_Strategy' ); |
|
581 | + $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
582 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
583 | + $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
584 | 584 | break; |
585 | 585 | case EEM_Question::QST_type_email : |
586 | - $result = new EE_Email_Input( $input_constructor_args ); |
|
586 | + $result = new EE_Email_Input($input_constructor_args); |
|
587 | 587 | break; |
588 | 588 | case EEM_Question::QST_type_us_phone : |
589 | - $result = new EE_Phone_Input( $input_constructor_args ); |
|
589 | + $result = new EE_Phone_Input($input_constructor_args); |
|
590 | 590 | break; |
591 | 591 | case EEM_Question::QST_type_int : |
592 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Int_Validation_Strategy(); |
|
593 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
592 | + $input_constructor_args['validation_strategies'][] = new EE_Int_Validation_Strategy(); |
|
593 | + $result = new EE_Text_Input($input_constructor_args); |
|
594 | 594 | break; |
595 | 595 | case EEM_Question::QST_type_decimal : |
596 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Float_Validation_Strategy(); |
|
597 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
596 | + $input_constructor_args['validation_strategies'][] = new EE_Float_Validation_Strategy(); |
|
597 | + $result = new EE_Text_Input($input_constructor_args); |
|
598 | 598 | break; |
599 | 599 | case EEM_Question::QST_type_url : |
600 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_URL_Validation_Strategy(); |
|
601 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
600 | + $input_constructor_args['validation_strategies'][] = new EE_URL_Validation_Strategy(); |
|
601 | + $result = new EE_Text_Input($input_constructor_args); |
|
602 | 602 | break; |
603 | 603 | case EEM_Question::QST_type_year : |
604 | 604 | $result = new EE_Year_Input( |
605 | 605 | $input_constructor_args, |
606 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this ), |
|
607 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this ), |
|
608 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this ) |
|
606 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this), |
|
607 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this), |
|
608 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this) |
|
609 | 609 | ); |
610 | 610 | break; |
611 | 611 | case EEM_Question::QST_type_multi_select : |
612 | - $result = new EE_Select_Multiple_Input( $this->options(), $input_constructor_args ); |
|
612 | + $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
613 | 613 | break; |
614 | 614 | // fallback |
615 | 615 | default : |
@@ -620,12 +620,12 @@ discard block |
||
620 | 620 | $this, |
621 | 621 | $input_constructor_args |
622 | 622 | ); |
623 | - if( ! $default_input ){ |
|
624 | - $default_input = new EE_Text_Input( $input_constructor_args ); |
|
623 | + if ( ! $default_input) { |
|
624 | + $default_input = new EE_Text_Input($input_constructor_args); |
|
625 | 625 | } |
626 | 626 | $result = $default_input; |
627 | 627 | } |
628 | - return apply_filters( 'FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer ); |
|
628 | + return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -16,314 +16,314 @@ discard block |
||
16 | 16 | class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * array of available options to choose as an answer |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $_options = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * whether to display the html_label_text above the checkbox/radio button options |
|
28 | - * |
|
29 | - * @var boolean |
|
30 | - */ |
|
31 | - protected $_display_html_label_text = true; |
|
32 | - |
|
33 | - /** |
|
34 | - * whether to display an question option description as part of the input label |
|
35 | - * |
|
36 | - * @var boolean |
|
37 | - */ |
|
38 | - protected $_use_desc_in_label = true; |
|
39 | - |
|
40 | - /** |
|
41 | - * strlen() result for the longest input value (what gets displayed in the label) |
|
42 | - * this is used to apply a css class to the input label |
|
43 | - * |
|
44 | - * @var int |
|
45 | - */ |
|
46 | - protected $_label_size = 0; |
|
47 | - |
|
48 | - /** |
|
49 | - * whether to enforce the label size value passed in the constructor |
|
50 | - * |
|
51 | - * @var boolean |
|
52 | - */ |
|
53 | - protected $_enforce_label_size = false; |
|
54 | - |
|
55 | - /** |
|
56 | - * whether to allow multiple selections (ie, the value of this input should be an array) |
|
57 | - * or not (ie, the value should be a simple int, string, etc) |
|
58 | - * |
|
59 | - * @var boolean |
|
60 | - */ |
|
61 | - protected $_multiple_selections = false; |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @param array $answer_options |
|
67 | - * @param array $input_settings { |
|
68 | - * @type int|string $label_size |
|
69 | - * @type boolean $display_html_label_text |
|
70 | - * } |
|
71 | - * And all the options accepted by EE_Form_Input_Base |
|
72 | - */ |
|
73 | - public function __construct($answer_options = array(), $input_settings = array()) |
|
74 | - { |
|
75 | - if (isset($input_settings['label_size'])) { |
|
76 | - $this->_set_label_size($input_settings['label_size']); |
|
77 | - if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) { |
|
78 | - $this->_enforce_label_size = true; |
|
79 | - } |
|
80 | - } |
|
81 | - if (isset($input_settings['display_html_label_text'])) { |
|
82 | - $this->set_display_html_label_text($input_settings['display_html_label_text']); |
|
83 | - } |
|
84 | - $this->set_select_options($answer_options); |
|
85 | - parent::__construct($input_settings); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * Sets the allowed options for this input. Also has the side-effect of |
|
92 | - * updating the normalization strategy to match the keys provided in the array |
|
93 | - * |
|
94 | - * @param array $answer_options |
|
95 | - * @return void just has the side-effect of setting the options for this input |
|
96 | - */ |
|
97 | - public function set_select_options($answer_options = array()) |
|
98 | - { |
|
99 | - $answer_options = is_array($answer_options) ? $answer_options : array($answer_options); |
|
100 | - //get the first item in the select options and check it's type |
|
101 | - $this->_options = reset($answer_options) instanceof EE_Question_Option |
|
102 | - ? $this->_process_question_options($answer_options) |
|
103 | - : $answer_options; |
|
104 | - //d( $this->_options ); |
|
105 | - $select_option_keys = array_keys($this->_options); |
|
106 | - // attempt to determine data type for values in order to set normalization type |
|
107 | - if ( |
|
108 | - count($this->_options) === 2 |
|
109 | - && ( |
|
110 | - (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true)) |
|
111 | - || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true)) |
|
112 | - ) |
|
113 | - ) { |
|
114 | - // values appear to be boolean, like TRUE, FALSE, 1, 0 |
|
115 | - $normalization = new EE_Boolean_Normalization(); |
|
116 | - } else { |
|
117 | - //are ALL the options ints? If so use int validation |
|
118 | - $all_ints = true; |
|
119 | - foreach ($select_option_keys as $value) { |
|
120 | - //allow for a default value which may be empty. |
|
121 | - if ( ! is_int($value) && $value !== '' && $value !== null) { |
|
122 | - $all_ints = false; |
|
123 | - break; |
|
124 | - } |
|
125 | - } |
|
126 | - if ($all_ints) { |
|
127 | - $normalization = new EE_Int_Normalization(); |
|
128 | - } else { |
|
129 | - $normalization = new EE_Text_Normalization(); |
|
130 | - } |
|
131 | - } |
|
132 | - // does input type have multiple options ? |
|
133 | - if ($this->_multiple_selections) { |
|
134 | - $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization)); |
|
135 | - } else { |
|
136 | - $this->_set_normalization_strategy($normalization); |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @return array |
|
144 | - */ |
|
145 | - public function options() |
|
146 | - { |
|
147 | - return $this->_options; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Returns an array which is guaranteed to not be multidimensional |
|
154 | - * |
|
155 | - * @return array |
|
156 | - */ |
|
157 | - public function flat_options() |
|
158 | - { |
|
159 | - return $this->_flatten_select_options($this->options()); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Makes sure $arr is a flat array, not a multidimensional one |
|
166 | - * |
|
167 | - * @param array $arr |
|
168 | - * @return array |
|
169 | - */ |
|
170 | - protected function _flatten_select_options($arr) |
|
171 | - { |
|
172 | - $flat_array = array(); |
|
173 | - if (EEH_Array::is_multi_dimensional_array($arr)) { |
|
174 | - foreach ($arr as $sub_array) { |
|
175 | - foreach ((array)$sub_array as $key => $value) { |
|
176 | - $flat_array[$key] = $value; |
|
177 | - $this->_set_label_size($value); |
|
178 | - } |
|
179 | - } |
|
180 | - } else { |
|
181 | - foreach ($arr as $key => $value) { |
|
182 | - $flat_array[$key] = $value; |
|
183 | - $this->_set_label_size($value); |
|
184 | - } |
|
185 | - } |
|
186 | - return $flat_array; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param EE_Question_Option[] $question_options_array |
|
193 | - * @return array |
|
194 | - */ |
|
195 | - protected function _process_question_options($question_options_array = array()) |
|
196 | - { |
|
197 | - $flat_array = array(); |
|
198 | - foreach ($question_options_array as $question_option) { |
|
199 | - if ($question_option instanceof EE_Question_Option) { |
|
200 | - $desc = ''; |
|
201 | - if ($this->_use_desc_in_label) { |
|
202 | - $desc = $question_option->desc(); |
|
203 | - $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : ''; |
|
204 | - } |
|
205 | - $value = $question_option->value(); |
|
206 | - // add value even if it's empty |
|
207 | - $flat_array[$value] = $value; |
|
208 | - // if both value and desc are not empty, then separate with a dash |
|
209 | - if ( ! empty($value) && ! empty($desc)) { |
|
210 | - $flat_array[$value] .= ' - ' . $desc; |
|
211 | - } else { |
|
212 | - // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary |
|
213 | - $flat_array[$value] .= $desc; |
|
214 | - } |
|
215 | - } elseif (is_array($question_option)) { |
|
216 | - $flat_array += $this->_flatten_select_options($question_option); |
|
217 | - } |
|
218 | - } |
|
219 | - return $flat_array; |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * set_label_sizes |
|
226 | - * |
|
227 | - * @return void |
|
228 | - */ |
|
229 | - public function set_label_sizes() |
|
230 | - { |
|
231 | - // did the input settings specifically say to NOT set the label size dynamically ? |
|
232 | - if ( ! $this->_enforce_label_size) { |
|
233 | - foreach ($this->_options as $option) { |
|
234 | - // calculate the strlen of the label |
|
235 | - $this->_set_label_size($option); |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * _set_label_size_class |
|
244 | - * |
|
245 | - * @param int|string $value |
|
246 | - * @return void |
|
247 | - */ |
|
248 | - private function _set_label_size($value = '') |
|
249 | - { |
|
250 | - // determine length of option value |
|
251 | - $val_size = is_int($value) ? $value : strlen($value); |
|
252 | - // use new value if bigger than existing |
|
253 | - $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * get_label_size_class |
|
260 | - * |
|
261 | - * @return string |
|
262 | - */ |
|
263 | - public function get_label_size_class() |
|
264 | - { |
|
265 | - $size = ' medium-lbl'; |
|
266 | - // use maximum option value length to determine label size |
|
267 | - if ($this->_label_size < 3) { |
|
268 | - $size = ' nano-lbl'; |
|
269 | - } else if ($this->_label_size < 6) { |
|
270 | - $size = ' micro-lbl'; |
|
271 | - } else if ($this->_label_size < 12) { |
|
272 | - $size = ' tiny-lbl'; |
|
273 | - } else if ($this->_label_size < 25) { |
|
274 | - $size = ' small-lbl'; |
|
275 | - } else if ($this->_label_size < 50) { |
|
276 | - $size = ' medium-lbl'; |
|
277 | - } else if ($this->_label_size >= 100) { |
|
278 | - $size = ' big-lbl'; |
|
279 | - } |
|
280 | - return $size; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * Returns the pretty value for the normalized value |
|
287 | - * |
|
288 | - * @return string |
|
289 | - */ |
|
290 | - public function pretty_value() |
|
291 | - { |
|
292 | - $options = $this->flat_options(); |
|
293 | - $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value); |
|
294 | - if ( ! $this->_multiple_selections) { |
|
295 | - $unnormalized_value_choices = array($unnormalized_value_choices); |
|
296 | - } |
|
297 | - $pretty_strings = array(); |
|
298 | - foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) { |
|
299 | - if (isset($options[$unnormalized_value_choice])) { |
|
300 | - $pretty_strings[] = $options[$unnormalized_value_choice]; |
|
301 | - } else { |
|
302 | - $pretty_strings[] = $this->normalized_value(); |
|
303 | - } |
|
304 | - } |
|
305 | - return implode(', ', $pretty_strings); |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * @return boolean |
|
312 | - */ |
|
313 | - public function display_html_label_text() |
|
314 | - { |
|
315 | - return $this->_display_html_label_text; |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * @param boolean $display_html_label_text |
|
322 | - */ |
|
323 | - public function set_display_html_label_text($display_html_label_text) |
|
324 | - { |
|
325 | - $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN); |
|
326 | - } |
|
19 | + /** |
|
20 | + * array of available options to choose as an answer |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $_options = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * whether to display the html_label_text above the checkbox/radio button options |
|
28 | + * |
|
29 | + * @var boolean |
|
30 | + */ |
|
31 | + protected $_display_html_label_text = true; |
|
32 | + |
|
33 | + /** |
|
34 | + * whether to display an question option description as part of the input label |
|
35 | + * |
|
36 | + * @var boolean |
|
37 | + */ |
|
38 | + protected $_use_desc_in_label = true; |
|
39 | + |
|
40 | + /** |
|
41 | + * strlen() result for the longest input value (what gets displayed in the label) |
|
42 | + * this is used to apply a css class to the input label |
|
43 | + * |
|
44 | + * @var int |
|
45 | + */ |
|
46 | + protected $_label_size = 0; |
|
47 | + |
|
48 | + /** |
|
49 | + * whether to enforce the label size value passed in the constructor |
|
50 | + * |
|
51 | + * @var boolean |
|
52 | + */ |
|
53 | + protected $_enforce_label_size = false; |
|
54 | + |
|
55 | + /** |
|
56 | + * whether to allow multiple selections (ie, the value of this input should be an array) |
|
57 | + * or not (ie, the value should be a simple int, string, etc) |
|
58 | + * |
|
59 | + * @var boolean |
|
60 | + */ |
|
61 | + protected $_multiple_selections = false; |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @param array $answer_options |
|
67 | + * @param array $input_settings { |
|
68 | + * @type int|string $label_size |
|
69 | + * @type boolean $display_html_label_text |
|
70 | + * } |
|
71 | + * And all the options accepted by EE_Form_Input_Base |
|
72 | + */ |
|
73 | + public function __construct($answer_options = array(), $input_settings = array()) |
|
74 | + { |
|
75 | + if (isset($input_settings['label_size'])) { |
|
76 | + $this->_set_label_size($input_settings['label_size']); |
|
77 | + if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) { |
|
78 | + $this->_enforce_label_size = true; |
|
79 | + } |
|
80 | + } |
|
81 | + if (isset($input_settings['display_html_label_text'])) { |
|
82 | + $this->set_display_html_label_text($input_settings['display_html_label_text']); |
|
83 | + } |
|
84 | + $this->set_select_options($answer_options); |
|
85 | + parent::__construct($input_settings); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * Sets the allowed options for this input. Also has the side-effect of |
|
92 | + * updating the normalization strategy to match the keys provided in the array |
|
93 | + * |
|
94 | + * @param array $answer_options |
|
95 | + * @return void just has the side-effect of setting the options for this input |
|
96 | + */ |
|
97 | + public function set_select_options($answer_options = array()) |
|
98 | + { |
|
99 | + $answer_options = is_array($answer_options) ? $answer_options : array($answer_options); |
|
100 | + //get the first item in the select options and check it's type |
|
101 | + $this->_options = reset($answer_options) instanceof EE_Question_Option |
|
102 | + ? $this->_process_question_options($answer_options) |
|
103 | + : $answer_options; |
|
104 | + //d( $this->_options ); |
|
105 | + $select_option_keys = array_keys($this->_options); |
|
106 | + // attempt to determine data type for values in order to set normalization type |
|
107 | + if ( |
|
108 | + count($this->_options) === 2 |
|
109 | + && ( |
|
110 | + (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true)) |
|
111 | + || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true)) |
|
112 | + ) |
|
113 | + ) { |
|
114 | + // values appear to be boolean, like TRUE, FALSE, 1, 0 |
|
115 | + $normalization = new EE_Boolean_Normalization(); |
|
116 | + } else { |
|
117 | + //are ALL the options ints? If so use int validation |
|
118 | + $all_ints = true; |
|
119 | + foreach ($select_option_keys as $value) { |
|
120 | + //allow for a default value which may be empty. |
|
121 | + if ( ! is_int($value) && $value !== '' && $value !== null) { |
|
122 | + $all_ints = false; |
|
123 | + break; |
|
124 | + } |
|
125 | + } |
|
126 | + if ($all_ints) { |
|
127 | + $normalization = new EE_Int_Normalization(); |
|
128 | + } else { |
|
129 | + $normalization = new EE_Text_Normalization(); |
|
130 | + } |
|
131 | + } |
|
132 | + // does input type have multiple options ? |
|
133 | + if ($this->_multiple_selections) { |
|
134 | + $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization)); |
|
135 | + } else { |
|
136 | + $this->_set_normalization_strategy($normalization); |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @return array |
|
144 | + */ |
|
145 | + public function options() |
|
146 | + { |
|
147 | + return $this->_options; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Returns an array which is guaranteed to not be multidimensional |
|
154 | + * |
|
155 | + * @return array |
|
156 | + */ |
|
157 | + public function flat_options() |
|
158 | + { |
|
159 | + return $this->_flatten_select_options($this->options()); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Makes sure $arr is a flat array, not a multidimensional one |
|
166 | + * |
|
167 | + * @param array $arr |
|
168 | + * @return array |
|
169 | + */ |
|
170 | + protected function _flatten_select_options($arr) |
|
171 | + { |
|
172 | + $flat_array = array(); |
|
173 | + if (EEH_Array::is_multi_dimensional_array($arr)) { |
|
174 | + foreach ($arr as $sub_array) { |
|
175 | + foreach ((array)$sub_array as $key => $value) { |
|
176 | + $flat_array[$key] = $value; |
|
177 | + $this->_set_label_size($value); |
|
178 | + } |
|
179 | + } |
|
180 | + } else { |
|
181 | + foreach ($arr as $key => $value) { |
|
182 | + $flat_array[$key] = $value; |
|
183 | + $this->_set_label_size($value); |
|
184 | + } |
|
185 | + } |
|
186 | + return $flat_array; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param EE_Question_Option[] $question_options_array |
|
193 | + * @return array |
|
194 | + */ |
|
195 | + protected function _process_question_options($question_options_array = array()) |
|
196 | + { |
|
197 | + $flat_array = array(); |
|
198 | + foreach ($question_options_array as $question_option) { |
|
199 | + if ($question_option instanceof EE_Question_Option) { |
|
200 | + $desc = ''; |
|
201 | + if ($this->_use_desc_in_label) { |
|
202 | + $desc = $question_option->desc(); |
|
203 | + $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : ''; |
|
204 | + } |
|
205 | + $value = $question_option->value(); |
|
206 | + // add value even if it's empty |
|
207 | + $flat_array[$value] = $value; |
|
208 | + // if both value and desc are not empty, then separate with a dash |
|
209 | + if ( ! empty($value) && ! empty($desc)) { |
|
210 | + $flat_array[$value] .= ' - ' . $desc; |
|
211 | + } else { |
|
212 | + // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary |
|
213 | + $flat_array[$value] .= $desc; |
|
214 | + } |
|
215 | + } elseif (is_array($question_option)) { |
|
216 | + $flat_array += $this->_flatten_select_options($question_option); |
|
217 | + } |
|
218 | + } |
|
219 | + return $flat_array; |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * set_label_sizes |
|
226 | + * |
|
227 | + * @return void |
|
228 | + */ |
|
229 | + public function set_label_sizes() |
|
230 | + { |
|
231 | + // did the input settings specifically say to NOT set the label size dynamically ? |
|
232 | + if ( ! $this->_enforce_label_size) { |
|
233 | + foreach ($this->_options as $option) { |
|
234 | + // calculate the strlen of the label |
|
235 | + $this->_set_label_size($option); |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * _set_label_size_class |
|
244 | + * |
|
245 | + * @param int|string $value |
|
246 | + * @return void |
|
247 | + */ |
|
248 | + private function _set_label_size($value = '') |
|
249 | + { |
|
250 | + // determine length of option value |
|
251 | + $val_size = is_int($value) ? $value : strlen($value); |
|
252 | + // use new value if bigger than existing |
|
253 | + $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * get_label_size_class |
|
260 | + * |
|
261 | + * @return string |
|
262 | + */ |
|
263 | + public function get_label_size_class() |
|
264 | + { |
|
265 | + $size = ' medium-lbl'; |
|
266 | + // use maximum option value length to determine label size |
|
267 | + if ($this->_label_size < 3) { |
|
268 | + $size = ' nano-lbl'; |
|
269 | + } else if ($this->_label_size < 6) { |
|
270 | + $size = ' micro-lbl'; |
|
271 | + } else if ($this->_label_size < 12) { |
|
272 | + $size = ' tiny-lbl'; |
|
273 | + } else if ($this->_label_size < 25) { |
|
274 | + $size = ' small-lbl'; |
|
275 | + } else if ($this->_label_size < 50) { |
|
276 | + $size = ' medium-lbl'; |
|
277 | + } else if ($this->_label_size >= 100) { |
|
278 | + $size = ' big-lbl'; |
|
279 | + } |
|
280 | + return $size; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * Returns the pretty value for the normalized value |
|
287 | + * |
|
288 | + * @return string |
|
289 | + */ |
|
290 | + public function pretty_value() |
|
291 | + { |
|
292 | + $options = $this->flat_options(); |
|
293 | + $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value); |
|
294 | + if ( ! $this->_multiple_selections) { |
|
295 | + $unnormalized_value_choices = array($unnormalized_value_choices); |
|
296 | + } |
|
297 | + $pretty_strings = array(); |
|
298 | + foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) { |
|
299 | + if (isset($options[$unnormalized_value_choice])) { |
|
300 | + $pretty_strings[] = $options[$unnormalized_value_choice]; |
|
301 | + } else { |
|
302 | + $pretty_strings[] = $this->normalized_value(); |
|
303 | + } |
|
304 | + } |
|
305 | + return implode(', ', $pretty_strings); |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * @return boolean |
|
312 | + */ |
|
313 | + public function display_html_label_text() |
|
314 | + { |
|
315 | + return $this->_display_html_label_text; |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * @param boolean $display_html_label_text |
|
322 | + */ |
|
323 | + public function set_display_html_label_text($display_html_label_text) |
|
324 | + { |
|
325 | + $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN); |
|
326 | + } |
|
327 | 327 | |
328 | 328 | |
329 | 329 |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $flat_array = array(); |
173 | 173 | if (EEH_Array::is_multi_dimensional_array($arr)) { |
174 | 174 | foreach ($arr as $sub_array) { |
175 | - foreach ((array)$sub_array as $key => $value) { |
|
175 | + foreach ((array) $sub_array as $key => $value) { |
|
176 | 176 | $flat_array[$key] = $value; |
177 | 177 | $this->_set_label_size($value); |
178 | 178 | } |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | $desc = ''; |
201 | 201 | if ($this->_use_desc_in_label) { |
202 | 202 | $desc = $question_option->desc(); |
203 | - $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : ''; |
|
203 | + $desc = ! empty($desc) ? '<span class="ee-question-option-desc">'.$desc.'</span>' : ''; |
|
204 | 204 | } |
205 | 205 | $value = $question_option->value(); |
206 | 206 | // add value even if it's empty |
207 | 207 | $flat_array[$value] = $value; |
208 | 208 | // if both value and desc are not empty, then separate with a dash |
209 | 209 | if ( ! empty($value) && ! empty($desc)) { |
210 | - $flat_array[$value] .= ' - ' . $desc; |
|
210 | + $flat_array[$value] .= ' - '.$desc; |
|
211 | 211 | } else { |
212 | 212 | // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary |
213 | 213 | $flat_array[$value] .= $desc; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $unnormalized_value_choices = array($unnormalized_value_choices); |
296 | 296 | } |
297 | 297 | $pretty_strings = array(); |
298 | - foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) { |
|
298 | + foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) { |
|
299 | 299 | if (isset($options[$unnormalized_value_choice])) { |
300 | 300 | $pretty_strings[] = $options[$unnormalized_value_choice]; |
301 | 301 | } else { |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | * @access protected |
38 | 38 | * @return EEM_Payment_Method |
39 | 39 | */ |
40 | - protected function __construct( $timezone = NULL ) { |
|
41 | - $this->singlular_item = __( 'Payment Method', 'event_espresso' ); |
|
42 | - $this->plural_item = __( 'Payment Methods', 'event_espresso' ); |
|
43 | - $this->_tables = array( 'Payment_Method' => new EE_Primary_Table( 'esp_payment_method', 'PMD_ID' ) ); |
|
40 | + protected function __construct($timezone = NULL) { |
|
41 | + $this->singlular_item = __('Payment Method', 'event_espresso'); |
|
42 | + $this->plural_item = __('Payment Methods', 'event_espresso'); |
|
43 | + $this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID')); |
|
44 | 44 | $this->_fields = array( |
45 | 45 | 'Payment_Method' => array( |
46 | - 'PMD_ID' => new EE_Primary_Key_Int_Field( 'PMD_ID', __( "ID", 'event_espresso' ) ), |
|
47 | - 'PMD_type' => new EE_Plain_Text_Field( 'PMD_type', __( "Payment Method Type", 'event_espresso' ), FALSE, 'Admin_Only' ), |
|
48 | - 'PMD_name' => new EE_Plain_Text_Field( 'PMD_name', __( "Name", 'event_espresso' ), FALSE ), |
|
49 | - 'PMD_desc' => new EE_Post_Content_Field( 'PMD_desc', __( "Description", 'event_espresso' ), FALSE, '' ), |
|
50 | - 'PMD_admin_name' => new EE_Plain_Text_Field( 'PMD_admin_name', __( "Admin-Only Name", 'event_espresso' ), TRUE ), |
|
51 | - 'PMD_admin_desc' => new EE_Post_Content_Field( 'PMD_admin_desc', __( "Admin-Only Description", 'event_espresso' ), TRUE ), |
|
52 | - 'PMD_slug' => new EE_Slug_Field( 'PMD_slug', __( "Slug", 'event_espresso' ), FALSE ), |
|
53 | - 'PMD_order' => new EE_Integer_Field( 'PMD_order', __( "Order", 'event_espresso' ), FALSE, 0 ), |
|
54 | - 'PMD_debug_mode' => new EE_Boolean_Field( 'PMD_debug_mode', __( "Debug Mode On?", 'event_espresso' ), FALSE, FALSE ), |
|
55 | - 'PMD_wp_user' => new EE_WP_User_Field( 'PMD_wp_user', __( "Payment Method Creator ID", 'event_espresso' ), FALSE ), |
|
56 | - 'PMD_open_by_default' => new EE_Boolean_Field( 'PMD_open_by_default', __( "Open by Default?", 'event_espresso' ), FALSE, FALSE ), 'PMD_button_url' => new EE_Plain_Text_Field( 'PMD_button_url', __( "Button URL", 'event_espresso' ), TRUE, '' ), |
|
57 | - 'PMD_scope' => new EE_Serialized_Text_Field( 'PMD_scope', __( "Usable From?", 'event_espresso' ), FALSE, array() ), //possible values currently are 'CART','ADMIN','API' |
|
46 | + 'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')), |
|
47 | + 'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), FALSE, 'Admin_Only'), |
|
48 | + 'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), FALSE), |
|
49 | + 'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), FALSE, ''), |
|
50 | + 'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), TRUE), |
|
51 | + 'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), TRUE), |
|
52 | + 'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), FALSE), |
|
53 | + 'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), FALSE, 0), |
|
54 | + 'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), FALSE, FALSE), |
|
55 | + 'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), FALSE), |
|
56 | + 'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), FALSE, FALSE), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), TRUE, ''), |
|
57 | + 'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), FALSE, array()), //possible values currently are 'CART','ADMIN','API' |
|
58 | 58 | ) ); |
59 | 59 | $this->_model_relations = array( |
60 | 60 | // 'Event'=>new EE_HABTM_Relation('Event_Payment_Method'), |
61 | 61 | 'Payment' => new EE_Has_Many_Relation(), |
62 | - 'Currency' => new EE_HABTM_Relation( 'Currency_Payment_Method' ), |
|
62 | + 'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'), |
|
63 | 63 | 'Transaction' => new EE_Has_Many_Relation(), |
64 | 64 | 'WP_User' => new EE_Belongs_To_Relation(), |
65 | 65 | ); |
66 | - parent::__construct( $timezone ); |
|
66 | + parent::__construct($timezone); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @param string $slug |
74 | 74 | * @return EE_Payment_Method |
75 | 75 | */ |
76 | - public function get_one_by_slug( $slug ) { |
|
77 | - return $this->get_one( array( array( 'PMD_slug' => $slug ) ) ); |
|
76 | + public function get_one_by_slug($slug) { |
|
77 | + return $this->get_one(array(array('PMD_slug' => $slug))); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | return apply_filters( |
89 | 89 | 'FHEE__EEM_Payment_Method__scopes', |
90 | 90 | array( |
91 | - self::scope_cart => __( "Front-end Registration Page", 'event_espresso' ), |
|
92 | - self::scope_admin => __( "Admin Registration Page (no online processing)", 'event_espresso' ) |
|
91 | + self::scope_cart => __("Front-end Registration Page", 'event_espresso'), |
|
92 | + self::scope_admin => __("Admin Registration Page (no online processing)", 'event_espresso') |
|
93 | 93 | ) |
94 | 94 | ); |
95 | 95 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | - public function is_valid_scope( $scope ) { |
|
104 | + public function is_valid_scope($scope) { |
|
105 | 105 | $scopes = $this->scopes(); |
106 | - if ( isset( $scopes[ $scope ] ) ) { |
|
106 | + if (isset($scopes[$scope])) { |
|
107 | 107 | return TRUE; |
108 | 108 | } else { |
109 | 109 | return FALSE; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @throws EE_Error |
120 | 120 | * @return EE_Payment_Method[] |
121 | 121 | */ |
122 | - public function get_all_active( $scope = NULL, $query_params = array() ) { |
|
123 | - if( ! isset( $query_params[ 'order_by' ] ) && ! isset( $query_params[ 'order' ] ) ) { |
|
124 | - $query_params['order_by'] = array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ); |
|
122 | + public function get_all_active($scope = NULL, $query_params = array()) { |
|
123 | + if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
124 | + $query_params['order_by'] = array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC'); |
|
125 | 125 | } |
126 | - return $this->get_all( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
126 | + return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param array $query_params |
133 | 133 | * @return int |
134 | 134 | */ |
135 | - public function count_active( $scope = NULL, $query_params = array() ){ |
|
136 | - return $this->count( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
135 | + public function count_active($scope = NULL, $query_params = array()) { |
|
136 | + return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | * @return array like param of EEM_Base::get_all() |
145 | 145 | * @throws EE_Error |
146 | 146 | */ |
147 | - protected function _get_query_params_for_all_active( $scope = NULL, $query_params = array() ){ |
|
148 | - if ( $scope ) { |
|
149 | - if ( $this->is_valid_scope( $scope ) ) { |
|
150 | - return array_replace_recursive( array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params ); |
|
147 | + protected function _get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
148 | + if ($scope) { |
|
149 | + if ($this->is_valid_scope($scope)) { |
|
150 | + return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params); |
|
151 | 151 | } else { |
152 | - throw new EE_Error( sprintf( __( "'%s' is not a valid scope for a payment method", "event_espresso" ), $scope ) ); |
|
152 | + throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope)); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | 155 | $acceptable_scopes = array(); |
156 | 156 | $count = 0; |
157 | - foreach ( $this->scopes() as $scope_name => $desc ) { |
|
157 | + foreach ($this->scopes() as $scope_name => $desc) { |
|
158 | 158 | $count++; |
159 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' ); |
|
159 | + $acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%'); |
|
160 | 160 | } |
161 | - return array_replace_recursive( array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params ); |
|
161 | + return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @return array like param of EEM_Base::get_all() |
171 | 171 | * @throws EE_Error |
172 | 172 | */ |
173 | - public function get_query_params_for_all_active( $scope = NULL, $query_params = array() ) { |
|
174 | - return $this->_get_query_params_for_all_active( $scope, $query_params ); |
|
173 | + public function get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
174 | + return $this->_get_query_params_for_all_active($scope, $query_params); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param array $query_params |
182 | 182 | * @return EE_Payment_Method |
183 | 183 | */ |
184 | - public function get_one_active( $scope = NULL, $query_params = array() ) { |
|
185 | - return $this->get_one( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
184 | + public function get_one_active($scope = NULL, $query_params = array()) { |
|
185 | + return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param string $type |
193 | 193 | * @return EE_Payment_Method |
194 | 194 | */ |
195 | - public function get_one_of_type( $type ) { |
|
196 | - return $this->get_one( array( array( 'PMD_type' => $type ) ) ); |
|
195 | + public function get_one_of_type($type) { |
|
196 | + return $this->get_one(array(array('PMD_type' => $type))); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | * @return EE_Payment_Method |
207 | 207 | * @throws EE_Error |
208 | 208 | */ |
209 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ) { |
|
209 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
210 | 210 | //first: check if it's a slug |
211 | - if( is_string( $base_class_obj_or_id ) ) { |
|
212 | - $obj = $this->get_one_by_slug( $base_class_obj_or_id ); |
|
213 | - if( $obj ) { |
|
211 | + if (is_string($base_class_obj_or_id)) { |
|
212 | + $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
213 | + if ($obj) { |
|
214 | 214 | return $obj; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | //ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
218 | 218 | try { |
219 | - return parent::ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db ); |
|
219 | + return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
220 | 220 | } |
221 | - catch ( EE_Error $e ) { |
|
221 | + catch (EE_Error $e) { |
|
222 | 222 | //handle it outside the catch |
223 | 223 | } |
224 | - throw new EE_Error( sprintf( __( "'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso" ), $base_class_obj_or_id ) ); |
|
224 | + throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id)); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | * @param mixed $base_obj_or_id_or_slug |
233 | 233 | * @return int |
234 | 234 | */ |
235 | - function ensure_is_ID( $base_obj_or_id_or_slug ) { |
|
236 | - if ( is_string( $base_obj_or_id_or_slug ) ) { |
|
235 | + function ensure_is_ID($base_obj_or_id_or_slug) { |
|
236 | + if (is_string($base_obj_or_id_or_slug)) { |
|
237 | 237 | //assume it's a slug |
238 | - $base_obj_or_id_or_slug = $this->get_one_by_slug( $base_obj_or_id_or_slug ); |
|
238 | + $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
239 | 239 | } |
240 | - return parent::ensure_is_ID( $base_obj_or_id_or_slug ); |
|
240 | + return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -246,36 +246,36 @@ discard block |
||
246 | 246 | * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default. |
247 | 247 | * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart |
248 | 248 | */ |
249 | - function verify_button_urls( $payment_methods = NULL ) { |
|
250 | - $payment_methods = is_array( $payment_methods ) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
251 | - foreach ( $payment_methods as $payment_method ) { |
|
249 | + function verify_button_urls($payment_methods = NULL) { |
|
250 | + $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
251 | + foreach ($payment_methods as $payment_method) { |
|
252 | 252 | try { |
253 | 253 | $current_button_url = $payment_method->button_url(); |
254 | - $buttons_urls_to_try = apply_filters( 'FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
255 | - 'current_ssl' => str_replace( "http://", "https://", $current_button_url ), |
|
256 | - 'current' => str_replace( "https://", "http://", $current_button_url ), |
|
257 | - 'default_ssl' => str_replace( "http://", "https://", $payment_method->type_obj()->default_button_url() ), |
|
258 | - 'default' => str_replace( "https://", "http://", $payment_method->type_obj()->default_button_url() ), |
|
259 | - ) ); |
|
260 | - foreach( $buttons_urls_to_try as $button_url_to_try ) { |
|
261 | - if( |
|
254 | + $buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
255 | + 'current_ssl' => str_replace("http://", "https://", $current_button_url), |
|
256 | + 'current' => str_replace("https://", "http://", $current_button_url), |
|
257 | + 'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()), |
|
258 | + 'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()), |
|
259 | + )); |
|
260 | + foreach ($buttons_urls_to_try as $button_url_to_try) { |
|
261 | + if ( |
|
262 | 262 | (//this is the current url and it exists, regardless of SSL issues |
263 | 263 | $button_url_to_try == $current_button_url && |
264 | 264 | EEH_URL::remote_file_exists( |
265 | 265 | $button_url_to_try, |
266 | 266 | array( |
267 | 267 | 'sslverify' => false, |
268 | - 'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
268 | + 'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
269 | 269 | ) ) |
270 | 270 | ) |
271 | 271 | || |
272 | 272 | (//this is NOT the current url and it exists with a working SSL cert |
273 | 273 | $button_url_to_try != $current_button_url && |
274 | - EEH_URL::remote_file_exists( $button_url_to_try ) |
|
274 | + EEH_URL::remote_file_exists($button_url_to_try) |
|
275 | 275 | ) ) { |
276 | - if( $current_button_url != $button_url_to_try ){ |
|
277 | - $payment_method->save( array( 'PMD_button_url' => $button_url_to_try ) ); |
|
278 | - EE_Error::add_attention( sprintf( __( "Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso" ), $payment_method->name(), $button_url_to_try ) ); |
|
276 | + if ($current_button_url != $button_url_to_try) { |
|
277 | + $payment_method->save(array('PMD_button_url' => $button_url_to_try)); |
|
278 | + EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try)); |
|
279 | 279 | } |
280 | 280 | //this image exists. So if wasn't set before, now it is; |
281 | 281 | //or if it was already set, we have nothing to do |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
286 | - catch ( EE_Error $e ) { |
|
287 | - $payment_method->set_active( FALSE ); |
|
286 | + catch (EE_Error $e) { |
|
287 | + $payment_method->set_active(FALSE); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
@@ -298,29 +298,29 @@ discard block |
||
298 | 298 | * @param array $rows |
299 | 299 | * @return EE_Payment_Method[] |
300 | 300 | */ |
301 | - protected function _create_objects( $rows = array() ) { |
|
302 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
303 | - $payment_methods = parent::_create_objects( $rows ); |
|
301 | + protected function _create_objects($rows = array()) { |
|
302 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
303 | + $payment_methods = parent::_create_objects($rows); |
|
304 | 304 | /* @var $payment_methods EE_Payment_Method[] */ |
305 | 305 | $usable_payment_methods = array(); |
306 | - foreach ( $payment_methods as $key => $payment_method ) { |
|
307 | - if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $payment_method->type() ) ) { |
|
308 | - $usable_payment_methods[ $key ] = $payment_method; |
|
306 | + foreach ($payment_methods as $key => $payment_method) { |
|
307 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
308 | + $usable_payment_methods[$key] = $payment_method; |
|
309 | 309 | //some payment methods enqueue their scripts in EE_PMT_*::__construct |
310 | 310 | //which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
311 | 311 | //its scripts). but for backwards-compat we should continue to do that |
312 | 312 | $payment_method->type_obj(); |
313 | - } elseif( $payment_method->active() ) { |
|
313 | + } elseif ($payment_method->active()) { |
|
314 | 314 | //only deactivate and notify the admin if the payment is active somewhere |
315 | 315 | $payment_method->deactivate(); |
316 | 316 | $payment_method->save(); |
317 | 317 | EE_Error::add_persistent_admin_notice( |
318 | - 'auto-deactivated-' . $payment_method->type(), |
|
318 | + 'auto-deactivated-'.$payment_method->type(), |
|
319 | 319 | sprintf( |
320 | - __( 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso' ), |
|
320 | + __('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'), |
|
321 | 321 | $payment_method->admin_name(), |
322 | 322 | '<br />', |
323 | - '<a href="' . admin_url('plugins.php') . '">', |
|
323 | + '<a href="'.admin_url('plugins.php').'">', |
|
324 | 324 | '</a>' |
325 | 325 | ), |
326 | 326 | true |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | * @param string $scope @see EEM_Payment_Method::get_all_for_events |
341 | 341 | * @return EE_Payment_Method[] |
342 | 342 | */ |
343 | - public function get_all_for_transaction( $transaction, $scope ) { |
|
343 | + public function get_all_for_transaction($transaction, $scope) { |
|
344 | 344 | //give addons a chance to override what payment methods are chosen based on the transaction |
345 | 345 | return apply_filters( |
346 | 346 | 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
347 | - $this->get_all_active( $scope ), |
|
347 | + $this->get_all_active($scope), |
|
348 | 348 | $transaction, |
349 | 349 | $scope |
350 | 350 | ); |
@@ -360,16 +360,16 @@ discard block |
||
360 | 360 | * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
361 | 361 | * @return EE_Payment|null |
362 | 362 | */ |
363 | - public function get_last_used_for_registration( $registration_or_reg_id ) { |
|
364 | - $registration_id = EEM_Registration::instance()->ensure_is_ID( $registration_or_reg_id ); |
|
363 | + public function get_last_used_for_registration($registration_or_reg_id) { |
|
364 | + $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
365 | 365 | |
366 | 366 | $query_params = array( |
367 | 367 | 0 => array( |
368 | 368 | 'Payment.Registration.REG_ID' => $registration_id, |
369 | 369 | ), |
370 | - 'order_by' => array( 'Payment.PAY_ID' => 'DESC' ) |
|
370 | + 'order_by' => array('Payment.PAY_ID' => 'DESC') |
|
371 | 371 | ); |
372 | - return $this->get_one( $query_params ); |
|
372 | + return $this->get_one($query_params); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
45 | 45 | * @return \Payments_Admin_Page |
46 | 46 | */ |
47 | - public function __construct( $routing = TRUE ) { |
|
48 | - parent::__construct( $routing ); |
|
47 | + public function __construct($routing = TRUE) { |
|
48 | + parent::__construct($routing); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | protected function _set_page_config() { |
131 | 131 | $payment_method_list_config = array( |
132 | 132 | 'nav' => array( |
133 | - 'label' => __( 'Payment Methods', 'event_espresso' ), |
|
133 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
134 | 134 | 'order' => 10 |
135 | 135 | ), |
136 | 136 | 'metaboxes' => $this->_default_espresso_metaboxes, |
137 | 137 | 'help_tabs' => array_merge( |
138 | 138 | array( |
139 | 139 | 'payment_methods_overview_help_tab' => array( |
140 | - 'title' => __( 'Payment Methods Overview', 'event_espresso' ), |
|
140 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
141 | 141 | 'filename' => 'payment_methods_overview' |
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | $this->_add_payment_method_help_tabs() ), |
145 | - 'help_tour' => array( 'Payment_Methods_Selection_Help_Tour' ), |
|
145 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
146 | 146 | 'require_nonce' => false |
147 | 147 | ); |
148 | 148 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ) |
161 | 161 | ), |
162 | 162 | //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
163 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | 164 | 'require_nonce' => FALSE |
165 | 165 | ), |
166 | 166 | 'payment_log'=>array( |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function _add_payment_method_help_tabs(){ |
|
182 | + protected function _add_payment_method_help_tabs() { |
|
183 | 183 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
184 | 184 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
185 | 185 | $all_pmt_help_tabs_config = array(); |
186 | - foreach( $payment_method_types as $payment_method_type ){ |
|
187 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
186 | + foreach ($payment_method_types as $payment_method_type) { |
|
187 | + if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | - foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){ |
|
191 | - $template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array(); |
|
192 | - $template_args[ 'admin_page_obj' ] = $this; |
|
190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
191 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
192 | + $template_args['admin_page_obj'] = $this; |
|
193 | 193 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
194 | 194 | 'title'=>$config['title'], |
195 | 195 | 'content'=>EEH_Template::display_template( |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | |
218 | 218 | public function load_scripts_styles() { |
219 | - wp_enqueue_script( 'ee_admin_js' ); |
|
220 | - wp_enqueue_script( 'ee-text-links' ); |
|
221 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
219 | + wp_enqueue_script('ee_admin_js'); |
|
220 | + wp_enqueue_script('ee-text-links'); |
|
221 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | |
228 | 228 | public function load_scripts_styles_default() { |
229 | 229 | //styles |
230 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
231 | - wp_enqueue_style( 'espresso_payments' ); |
|
232 | - wp_enqueue_style( 'ee-text-links' ); |
|
230 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
231 | + wp_enqueue_style('espresso_payments'); |
|
232 | + wp_enqueue_style('ee-text-links'); |
|
233 | 233 | //scripts |
234 | 234 | } |
235 | 235 | |
@@ -243,44 +243,44 @@ discard block |
||
243 | 243 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
244 | 244 | * recheck here. |
245 | 245 | */ |
246 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
246 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
247 | 247 | EEM_Payment_Method::instance()->verify_button_urls(); |
248 | 248 | //setup tabs, one for each payment method type |
249 | 249 | $tabs = array(); |
250 | 250 | $payment_methods = array(); |
251 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
251 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
252 | 252 | // we don't want to show admin-only PMTs for now |
253 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
253 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | //check access |
257 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
257 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | //check for any active pms of that type |
261 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
262 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
261 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
262 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
264 | 264 | array( |
265 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
265 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
266 | 266 | 'PMD_type' =>$pmt_obj->system_name(), |
267 | 267 | 'PMD_name' =>$pmt_obj->pretty_name(), |
268 | 268 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
269 | 269 | ) |
270 | 270 | ); |
271 | 271 | } |
272 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
272 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
273 | 273 | } |
274 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
275 | - foreach( $payment_methods as $payment_method ) { |
|
276 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
274 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
275 | + foreach ($payment_methods as $payment_method) { |
|
276 | + if ($payment_method instanceof EE_Payment_Method) { |
|
277 | 277 | add_meta_box( |
278 | 278 | //html id |
279 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
279 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
280 | 280 | //title |
281 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
281 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
282 | 282 | //callback |
283 | - array( $this, 'payment_method_settings_meta_box' ), |
|
283 | + array($this, 'payment_method_settings_meta_box'), |
|
284 | 284 | //post type |
285 | 285 | null, |
286 | 286 | //context |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | //priority |
289 | 289 | 'default', |
290 | 290 | //callback args |
291 | - array( 'payment_method' => $payment_method ) |
|
291 | + array('payment_method' => $payment_method) |
|
292 | 292 | ); |
293 | 293 | //setup for tabbed content |
294 | - $tabs[ $payment_method->slug() ] = array( |
|
294 | + $tabs[$payment_method->slug()] = array( |
|
295 | 295 | 'label' => $payment_method->admin_name(), |
296 | 296 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
297 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
298 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
297 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
298 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
299 | 299 | 'slug' => $payment_method->slug() |
300 | 300 | ); |
301 | 301 | } |
302 | 302 | } |
303 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
303 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
304 | 304 | $this->display_admin_page_with_sidebar(); |
305 | 305 | |
306 | 306 | } |
@@ -311,20 +311,20 @@ discard block |
||
311 | 311 | * _get_active_payment_method_slug |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - protected function _get_active_payment_method_slug(){ |
|
314 | + protected function _get_active_payment_method_slug() { |
|
315 | 315 | $payment_method_slug = FALSE; |
316 | 316 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
317 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
317 | + if (isset($this->_req_data['payment_method'])) { |
|
318 | 318 | // if they provided the current payment method, use it |
319 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
319 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
320 | 320 | } |
321 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
321 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
322 | 322 | // if that didn't work or wasn't provided, find another way to select the current pm |
323 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
323 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
324 | 324 | // like, looking for an active one |
325 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
325 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
326 | 326 | // test that one as well |
327 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
327 | + if ($this->_verify_payment_method($payment_method)) { |
|
328 | 328 | $payment_method_slug = $payment_method->slug(); |
329 | 329 | } else { |
330 | 330 | $payment_method_slug = 'paypal_standard'; |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | * @param \EE_Payment_Method $payment_method |
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | - protected function _verify_payment_method( $payment_method ){ |
|
345 | + protected function _verify_payment_method($payment_method) { |
|
346 | 346 | if ( |
347 | 347 | $payment_method instanceof EE_Payment_Method && |
348 | 348 | $payment_method->type_obj() instanceof EE_PMT_Base && |
349 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
349 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
350 | 350 | ) { |
351 | 351 | return TRUE; |
352 | 352 | } |
@@ -363,21 +363,21 @@ discard block |
||
363 | 363 | * @return string |
364 | 364 | * @throws EE_Error |
365 | 365 | */ |
366 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
367 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
368 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
369 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
366 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
367 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
368 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
369 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
370 | 370 | } |
371 | 371 | $payment_method_scopes = $payment_method->active(); |
372 | 372 | // if the payment method really exists show its form, otherwise the activation template |
373 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
374 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
375 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
376 | - $form->receive_form_submission( $this->_req_data ); |
|
373 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
374 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
375 | + if ($form->form_data_present_in($this->_req_data)) { |
|
376 | + $form->receive_form_submission($this->_req_data); |
|
377 | 377 | } |
378 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
378 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
379 | 379 | } else { |
380 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
380 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | * @param \EE_Payment_Method $payment_method |
391 | 391 | * @return \EE_Form_Section_Proper |
392 | 392 | */ |
393 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
394 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
393 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
394 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
395 | 395 | return new EE_Form_Section_Proper(); |
396 | 396 | } |
397 | 397 | return new EE_Form_Section_Proper( |
398 | 398 | array( |
399 | - 'name' => $payment_method->slug() . '_settings_form', |
|
400 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
399 | + 'name' => $payment_method->slug().'_settings_form', |
|
400 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
401 | 401 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
402 | 402 | array( |
403 | 403 | 'action' => 'update_payment_method', |
@@ -409,12 +409,12 @@ discard block |
||
409 | 409 | 'subsections' => apply_filters( |
410 | 410 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
411 | 411 | array( |
412 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
413 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
414 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
415 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
416 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
417 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
412 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
413 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
414 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
415 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
416 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
417 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
418 | 418 | ), |
419 | 419 | $payment_method |
420 | 420 | ) |
@@ -431,19 +431,19 @@ discard block |
||
431 | 431 | * @param \EE_Payment_Method $payment_method |
432 | 432 | * @return \EE_Form_Section_Proper |
433 | 433 | */ |
434 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
435 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
434 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
435 | + if ($payment_method->type_obj()->requires_https()) { |
|
436 | 436 | return new EE_Form_Section_HTML( |
437 | 437 | EEH_HTML::tr( |
438 | 438 | EEH_HTML::th( |
439 | 439 | EEH_HTML::label( |
440 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
440 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
441 | 441 | ) |
442 | - ) . |
|
442 | + ). |
|
443 | 443 | EEH_HTML::td( |
444 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
445 | - EEH_HTML::br() . |
|
446 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
444 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
445 | + EEH_HTML::br(). |
|
446 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
447 | 447 | ) |
448 | 448 | ) |
449 | 449 | ); |
@@ -461,19 +461,19 @@ discard block |
||
461 | 461 | * @param \EE_Payment_Method $payment_method |
462 | 462 | * @return \EE_Form_Section_Proper |
463 | 463 | */ |
464 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
465 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
464 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
465 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
466 | 466 | return new EE_Form_Section_HTML( |
467 | 467 | EEH_HTML::tr( |
468 | 468 | EEH_HTML::th( |
469 | 469 | EEH_HTML::label( |
470 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
470 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
471 | 471 | ) |
472 | - ) . |
|
472 | + ). |
|
473 | 473 | EEH_HTML::td( |
474 | 474 | EEH_HTML::strong( |
475 | 475 | sprintf( |
476 | - __( 'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
476 | + __('This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
477 | 477 | EE_Config::instance()->currency->code |
478 | 478 | ) |
479 | 479 | ) |
@@ -493,9 +493,9 @@ discard block |
||
493 | 493 | * @param \EE_Payment_Method $payment_method |
494 | 494 | * @return \EE_Form_Section_HTML |
495 | 495 | */ |
496 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
496 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
497 | 497 | //modify the form so we only have/show fields that will be implemented for this version |
498 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
498 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | * @return \EE_Payment_Method_Form |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
512 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
511 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
512 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
513 | 513 | $form_section->exclude( |
514 | 514 | array( |
515 | 515 | 'PMD_type', //dont want them changing the type |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | ); |
521 | 521 | return $form_section; |
522 | 522 | } else { |
523 | - throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name )); |
|
523 | + throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name)); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param \EE_Payment_Method $payment_method |
534 | 534 | * @return \EE_Form_Section_HTML |
535 | 535 | */ |
536 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
536 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
537 | 537 | $update_button = new EE_Submit_Input( |
538 | 538 | array( |
539 | 539 | 'name' => 'submit', |
540 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
541 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
540 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
541 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
542 | 542 | 'html_label' => EEH_HTML::nbsp() |
543 | 543 | ) |
544 | 544 | ); |
545 | 545 | return new EE_Form_Section_HTML( |
546 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
546 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
547 | 547 | EEH_HTML::tr( |
548 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
548 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
549 | 549 | EEH_HTML::td( |
550 | 550 | $update_button->get_html_for_input() |
551 | 551 | ) |
@@ -562,11 +562,11 @@ discard block |
||
562 | 562 | * @param \EE_Payment_Method $payment_method |
563 | 563 | * @return \EE_Form_Section_Proper |
564 | 564 | */ |
565 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
566 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
565 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
566 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
567 | 567 | return new EE_Form_Section_HTML( |
568 | 568 | EEH_HTML::tr( |
569 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
569 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
570 | 570 | EEH_HTML::td( |
571 | 571 | EEH_HTML::link( |
572 | 572 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | ), |
579 | 579 | $link_text_and_title, |
580 | 580 | $link_text_and_title, |
581 | - 'deactivate_' . $payment_method->slug(), |
|
581 | + 'deactivate_'.$payment_method->slug(), |
|
582 | 582 | 'espresso-button button-secondary' |
583 | 583 | ) |
584 | 584 | ) |
@@ -594,12 +594,12 @@ discard block |
||
594 | 594 | * @param \EE_Payment_Method $payment_method |
595 | 595 | * @return \EE_Form_Section_Proper |
596 | 596 | */ |
597 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
598 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
597 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
598 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
599 | 599 | return new EE_Form_Section_Proper( |
600 | 600 | array( |
601 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
602 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
601 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
602 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
603 | 603 | 'action' => '#', |
604 | 604 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
605 | 605 | 'subsections' => apply_filters( |
@@ -607,17 +607,17 @@ discard block |
||
607 | 607 | array( |
608 | 608 | new EE_Form_Section_HTML( |
609 | 609 | EEH_HTML::tr( |
610 | - EEH_HTML::td( $payment_method->type_obj()->introductory_html(), |
|
610 | + EEH_HTML::td($payment_method->type_obj()->introductory_html(), |
|
611 | 611 | '', |
612 | 612 | '', |
613 | 613 | '', |
614 | 614 | 'colspan="2"' |
615 | 615 | ) |
616 | - ) . |
|
616 | + ). |
|
617 | 617 | EEH_HTML::tr( |
618 | 618 | EEH_HTML::th( |
619 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
620 | - ) . |
|
619 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
620 | + ). |
|
621 | 621 | EEH_HTML::td( |
622 | 622 | EEH_HTML::link( |
623 | 623 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | ), |
630 | 630 | $link_text_and_title, |
631 | 631 | $link_text_and_title, |
632 | - 'activate_' . $payment_method->slug(), |
|
632 | + 'activate_'.$payment_method->slug(), |
|
633 | 633 | 'espresso-button-green button-primary' |
634 | 634 | ) |
635 | 635 | ) |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | protected function _fine_print() { |
652 | 652 | return new EE_Form_Section_HTML( |
653 | 653 | EEH_HTML::tr( |
654 | - EEH_HTML::th() . |
|
654 | + EEH_HTML::th(). |
|
655 | 655 | EEH_HTML::td( |
656 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
656 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
657 | 657 | ) |
658 | 658 | ) |
659 | 659 | ); |
@@ -665,15 +665,15 @@ discard block |
||
665 | 665 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
666 | 666 | * @global WP_User $current_user |
667 | 667 | */ |
668 | - protected function _activate_payment_method(){ |
|
669 | - if(isset($this->_req_data['payment_method_type'])){ |
|
668 | + protected function _activate_payment_method() { |
|
669 | + if (isset($this->_req_data['payment_method_type'])) { |
|
670 | 670 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
671 | 671 | //see if one exists |
672 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
673 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
672 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
673 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
674 | 674 | |
675 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
676 | - }else{ |
|
675 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
676 | + } else { |
|
677 | 677 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
678 | 678 | } |
679 | 679 | } |
@@ -681,14 +681,14 @@ discard block |
||
681 | 681 | /** |
682 | 682 | * Deactivates the payment method with the specified slug, and redirects. |
683 | 683 | */ |
684 | - protected function _deactivate_payment_method(){ |
|
685 | - if(isset($this->_req_data['payment_method'])){ |
|
684 | + protected function _deactivate_payment_method() { |
|
685 | + if (isset($this->_req_data['payment_method'])) { |
|
686 | 686 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
687 | 687 | //deactivate it |
688 | 688 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
689 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
690 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
691 | - }else{ |
|
689 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
690 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
691 | + } else { |
|
692 | 692 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
693 | 693 | } |
694 | 694 | } |
@@ -702,46 +702,46 @@ discard block |
||
702 | 702 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
703 | 703 | * @return void |
704 | 704 | */ |
705 | - protected function _update_payment_method(){ |
|
706 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
705 | + protected function _update_payment_method() { |
|
706 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
707 | 707 | //ok let's find which gateway form to use based on the form input |
708 | 708 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
709 | 709 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
710 | 710 | $correct_pmt_form_to_use = NULL; |
711 | 711 | $payment_method = NULL; |
712 | - foreach( EEM_Payment_Method::instance()->get_all() as $payment_method){ |
|
712 | + foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
713 | 713 | //get the form and simplify it, like what we do when we display it |
714 | - $pmt_form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
715 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
714 | + $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
715 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
716 | 716 | $correct_pmt_form_to_use = $pmt_form; |
717 | 717 | break; |
718 | 718 | } |
719 | 719 | } |
720 | 720 | //if we couldn't find the correct payment method type... |
721 | - if( ! $correct_pmt_form_to_use ){ |
|
721 | + if ( ! $correct_pmt_form_to_use) { |
|
722 | 722 | EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
723 | 723 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
724 | 724 | } |
725 | 725 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
726 | - if($correct_pmt_form_to_use->is_valid()){ |
|
727 | - $subsection_name = 'payment_method_settings_' . $payment_method->slug(); |
|
728 | - $payment_settings_subform = $correct_pmt_form_to_use->get_subsection( $subsection_name ); |
|
729 | - if( ! $payment_settings_subform instanceof EE_Payment_Method_Form ) { |
|
726 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
727 | + $subsection_name = 'payment_method_settings_'.$payment_method->slug(); |
|
728 | + $payment_settings_subform = $correct_pmt_form_to_use->get_subsection($subsection_name); |
|
729 | + if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
730 | 730 | throw new EE_Error( |
731 | 731 | sprintf( |
732 | - __( 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.','event_espresso' ), |
|
732 | + __('The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', 'event_espresso'), |
|
733 | 733 | $subsection_name |
734 | 734 | ) |
735 | 735 | ); |
736 | 736 | } |
737 | 737 | $payment_settings_subform->save(); |
738 | 738 | /** @var $pm EE_Payment_Method */ |
739 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
740 | - }else{ |
|
739 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
740 | + } else { |
|
741 | 741 | EE_Error::add_error( |
742 | 742 | sprintf( |
743 | 743 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
744 | - $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
744 | + $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
745 | 745 | ), |
746 | 746 | __FILE__, |
747 | 747 | __FUNCTION__, |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | protected function _payment_settings() { |
759 | 759 | |
760 | 760 | $this->_template_args['values'] = $this->_yes_no_values; |
761 | - $this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE; |
|
761 | + $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE; |
|
762 | 762 | |
763 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
764 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
765 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
763 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
764 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
765 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
766 | 766 | $this->display_admin_page_with_sidebar(); |
767 | 767 | |
768 | 768 | } |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | * @return array |
777 | 777 | */ |
778 | 778 | protected function _update_payment_settings() { |
779 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
780 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
779 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
780 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
781 | 781 | |
782 | 782 | // $superform = new EE_Form_Section_Proper( |
783 | 783 | // array( |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | // $this->_redirect_after_action( 0, 'settings', 'updated', array( 'action' => 'payment_settings' ) ); |
798 | 798 | // } |
799 | 799 | |
800 | - $what = __('Payment Settings','event_espresso'); |
|
801 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
802 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
800 | + $what = __('Payment Settings', 'event_espresso'); |
|
801 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
802 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
803 | 803 | |
804 | 804 | } |
805 | 805 | protected function _payment_log_overview_list_table() { |
@@ -825,18 +825,18 @@ discard block |
||
825 | 825 | * @param bool $count |
826 | 826 | * @return array |
827 | 827 | */ |
828 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
829 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
828 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
829 | + EE_Registry::instance()->load_model('Change_Log'); |
|
830 | 830 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
831 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
831 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
832 | 832 | //check if they've selected a specific payment method |
833 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
833 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
834 | 834 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
835 | 835 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
836 | 836 | } |
837 | 837 | //take into account search |
838 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
839 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
838 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
839 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
840 | 840 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
841 | 841 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
842 | 842 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -851,48 +851,48 @@ discard block |
||
851 | 851 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
852 | 852 | |
853 | 853 | } |
854 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
854 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
855 | 855 | //add date |
856 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
857 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
856 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
857 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
858 | 858 | //make sure our timestamps start and end right at the boundaries for each day |
859 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
860 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
859 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
860 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
861 | 861 | |
862 | 862 | //convert to timestamps |
863 | - $start_date = strtotime( $start_date ); |
|
864 | - $end_date = strtotime( $end_date ); |
|
863 | + $start_date = strtotime($start_date); |
|
864 | + $end_date = strtotime($end_date); |
|
865 | 865 | |
866 | 866 | //makes sure start date is the lowest value and vice versa |
867 | - $start_date = min( $start_date, $end_date ); |
|
868 | - $end_date = max( $start_date, $end_date ); |
|
867 | + $start_date = min($start_date, $end_date); |
|
868 | + $end_date = max($start_date, $end_date); |
|
869 | 869 | |
870 | 870 | //convert for query |
871 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
872 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
871 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
872 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
873 | 873 | |
874 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
874 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
875 | 875 | |
876 | 876 | } |
877 | - if($count){ |
|
877 | + if ($count) { |
|
878 | 878 | return EEM_Change_Log::instance()->count($query_params); |
879 | 879 | } |
880 | - if(isset($this->_req_data['order'])){ |
|
881 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
880 | + if (isset($this->_req_data['order'])) { |
|
881 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
882 | 882 | $query_params['order_by'] = array('LOG_time' => $sort); |
883 | - }else{ |
|
883 | + } else { |
|
884 | 884 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
885 | 885 | } |
886 | - $offset = ($current_page-1)*$per_page; |
|
886 | + $offset = ($current_page - 1) * $per_page; |
|
887 | 887 | |
888 | - if( ! isset($this->_req_data['download_results'])){ |
|
889 | - $query_params['limit'] = array( $offset, $per_page ); |
|
888 | + if ( ! isset($this->_req_data['download_results'])) { |
|
889 | + $query_params['limit'] = array($offset, $per_page); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
893 | 893 | |
894 | 894 | //now they've requested to instead just download the file instead of viewing it. |
895 | - if(isset($this->_req_data['download_results'])){ |
|
895 | + if (isset($this->_req_data['download_results'])) { |
|
896 | 896 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
897 | 897 | header('Content-Disposition: attachment'); |
898 | 898 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -914,36 +914,36 @@ discard block |
||
914 | 914 | * @param EE_Change_Log $logB |
915 | 915 | * @return int |
916 | 916 | */ |
917 | - protected function _sort_logs_again($logA,$logB){ |
|
917 | + protected function _sort_logs_again($logA, $logB) { |
|
918 | 918 | $timeA = $logA->get_raw('LOG_time'); |
919 | 919 | $timeB = $logB->get_raw('LOG_time'); |
920 | - if($timeA == $timeB){ |
|
920 | + if ($timeA == $timeB) { |
|
921 | 921 | return 0; |
922 | 922 | } |
923 | 923 | $comparison = $timeA < $timeB ? -1 : 1; |
924 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
924 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
925 | 925 | return $comparison * -1; |
926 | - }else{ |
|
926 | + } else { |
|
927 | 927 | return $comparison; |
928 | 928 | } |
929 | 929 | } |
930 | 930 | |
931 | 931 | protected function _payment_log_details() { |
932 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
932 | + EE_Registry::instance()->load_model('Change_Log'); |
|
933 | 933 | /** @var $payment_log EE_Change_Log */ |
934 | 934 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
935 | 935 | $payment_method = NULL; |
936 | 936 | $transaction = NULL; |
937 | - if( $payment_log instanceof EE_Change_Log ){ |
|
938 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
937 | + if ($payment_log instanceof EE_Change_Log) { |
|
938 | + if ($payment_log->object() instanceof EE_Payment) { |
|
939 | 939 | $payment_method = $payment_log->object()->payment_method(); |
940 | 940 | $transaction = $payment_log->object()->transaction(); |
941 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
941 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
942 | 942 | $payment_method = $payment_log->object(); |
943 | 943 | } |
944 | 944 | } |
945 | 945 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
946 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
946 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
947 | 947 | array( |
948 | 948 | 'payment_log'=>$payment_log, |
949 | 949 | 'payment_method'=>$payment_method, |
@@ -17,127 +17,127 @@ |
||
17 | 17 | class TicketSelectorStandard extends TicketSelector |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string $date_format |
|
22 | - */ |
|
23 | - protected $date_format; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string $time_format |
|
27 | - */ |
|
28 | - protected $time_format; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | - */ |
|
33 | - protected $ticket_selector_config; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var \EE_Tax_Config $tax_config |
|
37 | - */ |
|
38 | - protected $tax_config; |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * TicketSelectorSimple constructor. |
|
44 | - * |
|
45 | - * @param \EE_Event $event |
|
46 | - * @param \EE_Ticket[] $tickets |
|
47 | - * @param int $max_attendees |
|
48 | - * @param array $template_args |
|
49 | - * @param string $date_format |
|
50 | - * @param string $time_format |
|
51 | - * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | - * @param \EE_Tax_Config $tax_config |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - \EE_Event $event, |
|
56 | - array $tickets, |
|
57 | - $max_attendees, |
|
58 | - array $template_args, |
|
59 | - $date_format = 'Y-m-d', |
|
60 | - $time_format = 'g:i a', |
|
61 | - \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | - \EE_Tax_Config $tax_config = null |
|
63 | - ) { |
|
64 | - $this->date_format = $date_format; |
|
65 | - $this->time_format = $time_format; |
|
66 | - // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | - $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | - ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | - : new \EE_Ticket_Selector_Config(); |
|
70 | - // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | - // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | - // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | - $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | - ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | - : new \EE_Tax_Config(); |
|
76 | - parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * sets any and all template args that are required for this Ticket Selector |
|
83 | - * |
|
84 | - * @return void |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
87 | - protected function addTemplateArgs() |
|
88 | - { |
|
89 | - $row = 1; |
|
90 | - $ticket_row_html = ''; |
|
91 | - $required_ticket_sold_out = false; |
|
92 | - // flag to indicate that at least one taxable ticket has been encountered |
|
93 | - $taxable_tickets = false; |
|
94 | - $datetime_selector = null; |
|
95 | - $this->template_args['datetime_selector'] = ''; |
|
96 | - if ( |
|
97 | - $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | - !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | - ) { |
|
100 | - $datetime_selector = new DatetimeSelector( |
|
101 | - $this->event, |
|
102 | - $this->tickets, |
|
103 | - $this->ticket_selector_config, |
|
104 | - $this->date_format, |
|
105 | - $this->time_format |
|
106 | - ); |
|
107 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | - } |
|
109 | - // loop through tickets |
|
110 | - foreach ($this->tickets as $TKT_ID => $ticket) { |
|
111 | - if ($ticket instanceof \EE_Ticket) { |
|
112 | - $cols = 2; |
|
113 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
114 | - $ticket_selector_row = new TicketSelectorRowStandard( |
|
115 | - $ticket, |
|
116 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | - $this->ticket_selector_config, |
|
118 | - $this->tax_config, |
|
119 | - $this->max_attendees, |
|
120 | - $row, |
|
121 | - $cols, |
|
122 | - $required_ticket_sold_out, |
|
123 | - $this->template_args['event_status'], |
|
124 | - $this->template_args['date_format'], |
|
125 | - $datetime_selector instanceof DatetimeSelector |
|
126 | - ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
127 | - : '' |
|
128 | - ); |
|
129 | - $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
130 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
131 | - $row++; |
|
132 | - } |
|
133 | - } |
|
134 | - $this->template_args['row'] = $row; |
|
135 | - $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
136 | - $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
137 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
138 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
139 | - remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
140 | - } |
|
20 | + /** |
|
21 | + * @var string $date_format |
|
22 | + */ |
|
23 | + protected $date_format; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string $time_format |
|
27 | + */ |
|
28 | + protected $time_format; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | + */ |
|
33 | + protected $ticket_selector_config; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var \EE_Tax_Config $tax_config |
|
37 | + */ |
|
38 | + protected $tax_config; |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * TicketSelectorSimple constructor. |
|
44 | + * |
|
45 | + * @param \EE_Event $event |
|
46 | + * @param \EE_Ticket[] $tickets |
|
47 | + * @param int $max_attendees |
|
48 | + * @param array $template_args |
|
49 | + * @param string $date_format |
|
50 | + * @param string $time_format |
|
51 | + * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | + * @param \EE_Tax_Config $tax_config |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + \EE_Event $event, |
|
56 | + array $tickets, |
|
57 | + $max_attendees, |
|
58 | + array $template_args, |
|
59 | + $date_format = 'Y-m-d', |
|
60 | + $time_format = 'g:i a', |
|
61 | + \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | + \EE_Tax_Config $tax_config = null |
|
63 | + ) { |
|
64 | + $this->date_format = $date_format; |
|
65 | + $this->time_format = $time_format; |
|
66 | + // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | + $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | + ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | + : new \EE_Ticket_Selector_Config(); |
|
70 | + // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | + // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | + // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | + $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | + ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | + : new \EE_Tax_Config(); |
|
76 | + parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * sets any and all template args that are required for this Ticket Selector |
|
83 | + * |
|
84 | + * @return void |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | + protected function addTemplateArgs() |
|
88 | + { |
|
89 | + $row = 1; |
|
90 | + $ticket_row_html = ''; |
|
91 | + $required_ticket_sold_out = false; |
|
92 | + // flag to indicate that at least one taxable ticket has been encountered |
|
93 | + $taxable_tickets = false; |
|
94 | + $datetime_selector = null; |
|
95 | + $this->template_args['datetime_selector'] = ''; |
|
96 | + if ( |
|
97 | + $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | + !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | + ) { |
|
100 | + $datetime_selector = new DatetimeSelector( |
|
101 | + $this->event, |
|
102 | + $this->tickets, |
|
103 | + $this->ticket_selector_config, |
|
104 | + $this->date_format, |
|
105 | + $this->time_format |
|
106 | + ); |
|
107 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | + } |
|
109 | + // loop through tickets |
|
110 | + foreach ($this->tickets as $TKT_ID => $ticket) { |
|
111 | + if ($ticket instanceof \EE_Ticket) { |
|
112 | + $cols = 2; |
|
113 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
114 | + $ticket_selector_row = new TicketSelectorRowStandard( |
|
115 | + $ticket, |
|
116 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | + $this->ticket_selector_config, |
|
118 | + $this->tax_config, |
|
119 | + $this->max_attendees, |
|
120 | + $row, |
|
121 | + $cols, |
|
122 | + $required_ticket_sold_out, |
|
123 | + $this->template_args['event_status'], |
|
124 | + $this->template_args['date_format'], |
|
125 | + $datetime_selector instanceof DatetimeSelector |
|
126 | + ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
127 | + : '' |
|
128 | + ); |
|
129 | + $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
130 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
131 | + $row++; |
|
132 | + } |
|
133 | + } |
|
134 | + $this->template_args['row'] = $row; |
|
135 | + $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
136 | + $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
137 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
138 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
139 | + remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | 143 |
@@ -135,7 +135,7 @@ |
||
135 | 135 | $this->template_args['ticket_row_html'] = $ticket_row_html; |
136 | 136 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
137 | 137 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
138 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
138 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php'; |
|
139 | 139 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
140 | 140 | } |
141 | 141 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -12,165 +12,165 @@ discard block |
||
12 | 12 | class EE_Cron_Tasks extends EE_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
17 | - * so we'll set our retry time for just over 10 minutes to avoid that |
|
18 | - */ |
|
19 | - const reschedule_timeout = 605; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * @var EE_Cron_Tasks |
|
24 | - */ |
|
25 | - private static $_instance; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @return EE_Cron_Tasks |
|
30 | - */ |
|
31 | - public static function instance() |
|
32 | - { |
|
33 | - if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
34 | - self::$_instance = new self(); |
|
35 | - } |
|
36 | - return self::$_instance; |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @access private |
|
42 | - */ |
|
43 | - private function __construct() |
|
44 | - { |
|
45 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
46 | - // verify that WP Cron is enabled |
|
47 | - if ( |
|
48 | - defined('DISABLE_WP_CRON') |
|
49 | - && DISABLE_WP_CRON |
|
50 | - && is_admin() |
|
51 | - && ! get_option('ee_disabled_wp_cron_check') |
|
52 | - ) { |
|
53 | - /** |
|
54 | - * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
55 | - * config is loaded. |
|
56 | - * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
57 | - * wanting to not have this functionality can just register its own action at a priority after this one to |
|
58 | - * reverse any changes. |
|
59 | - */ |
|
60 | - add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
61 | - EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
62 | - EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
63 | - add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
64 | - }); |
|
65 | - } |
|
66 | - // UPDATE TRANSACTION WITH PAYMENT |
|
67 | - add_action( |
|
68 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
69 | - array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
70 | - 10, 2 |
|
71 | - ); |
|
72 | - // FINALIZE ABANDONED TRANSACTIONS |
|
73 | - add_action( |
|
74 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
75 | - array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
76 | - 10, 1 |
|
77 | - ); |
|
15 | + /** |
|
16 | + * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
17 | + * so we'll set our retry time for just over 10 minutes to avoid that |
|
18 | + */ |
|
19 | + const reschedule_timeout = 605; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * @var EE_Cron_Tasks |
|
24 | + */ |
|
25 | + private static $_instance; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @return EE_Cron_Tasks |
|
30 | + */ |
|
31 | + public static function instance() |
|
32 | + { |
|
33 | + if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
34 | + self::$_instance = new self(); |
|
35 | + } |
|
36 | + return self::$_instance; |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @access private |
|
42 | + */ |
|
43 | + private function __construct() |
|
44 | + { |
|
45 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
46 | + // verify that WP Cron is enabled |
|
47 | + if ( |
|
48 | + defined('DISABLE_WP_CRON') |
|
49 | + && DISABLE_WP_CRON |
|
50 | + && is_admin() |
|
51 | + && ! get_option('ee_disabled_wp_cron_check') |
|
52 | + ) { |
|
53 | + /** |
|
54 | + * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
55 | + * config is loaded. |
|
56 | + * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
57 | + * wanting to not have this functionality can just register its own action at a priority after this one to |
|
58 | + * reverse any changes. |
|
59 | + */ |
|
60 | + add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
61 | + EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
62 | + EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
63 | + add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
64 | + }); |
|
65 | + } |
|
66 | + // UPDATE TRANSACTION WITH PAYMENT |
|
67 | + add_action( |
|
68 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
69 | + array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
70 | + 10, 2 |
|
71 | + ); |
|
72 | + // FINALIZE ABANDONED TRANSACTIONS |
|
73 | + add_action( |
|
74 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
75 | + array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
76 | + 10, 1 |
|
77 | + ); |
|
78 | 78 | // EXPIRED TRANSACTION CHECK |
79 | 79 | add_action( |
80 | 80 | 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
81 | 81 | array( 'EE_Cron_Tasks', 'expired_transaction_check' ), |
82 | 82 | 10, 1 |
83 | 83 | ); |
84 | - // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
85 | - add_action( |
|
86 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
87 | - array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
88 | - ); |
|
89 | - // logging |
|
90 | - add_action( |
|
91 | - 'AHEE__EE_System__load_core_configuration__complete', |
|
92 | - array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
93 | - ); |
|
94 | - EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
95 | - //clean out old gateway logs |
|
96 | - add_action( |
|
97 | - 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
98 | - array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @access protected |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public static function log_scheduled_ee_crons() |
|
108 | - { |
|
109 | - $ee_crons = array( |
|
110 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
111 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
112 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
113 | - ); |
|
114 | - $crons = (array) get_option('cron'); |
|
115 | - if ( ! is_array($crons)) { |
|
116 | - return; |
|
117 | - } |
|
118 | - foreach ($crons as $timestamp => $cron) { |
|
119 | - foreach ($ee_crons as $ee_cron) { |
|
120 | - if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) { |
|
121 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
122 | - foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
123 | - if ( ! empty($ee_cron_details['args'])) { |
|
124 | - do_action( |
|
125 | - 'AHEE_log', |
|
126 | - __CLASS__, |
|
127 | - __FUNCTION__, |
|
128 | - print_r($ee_cron_details['args'], true), |
|
129 | - "{$ee_cron} args" |
|
130 | - ); |
|
131 | - } |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * reschedule_cron_for_transactions_if_maintenance_mode |
|
142 | - * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
143 | - * |
|
144 | - * @param string $cron_task |
|
145 | - * @param array $TXN_IDs |
|
146 | - * @return bool |
|
147 | - * @throws \DomainException |
|
148 | - */ |
|
84 | + // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
85 | + add_action( |
|
86 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
87 | + array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
88 | + ); |
|
89 | + // logging |
|
90 | + add_action( |
|
91 | + 'AHEE__EE_System__load_core_configuration__complete', |
|
92 | + array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
93 | + ); |
|
94 | + EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
95 | + //clean out old gateway logs |
|
96 | + add_action( |
|
97 | + 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
98 | + array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @access protected |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public static function log_scheduled_ee_crons() |
|
108 | + { |
|
109 | + $ee_crons = array( |
|
110 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
111 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
112 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
113 | + ); |
|
114 | + $crons = (array) get_option('cron'); |
|
115 | + if ( ! is_array($crons)) { |
|
116 | + return; |
|
117 | + } |
|
118 | + foreach ($crons as $timestamp => $cron) { |
|
119 | + foreach ($ee_crons as $ee_cron) { |
|
120 | + if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) { |
|
121 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
122 | + foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
123 | + if ( ! empty($ee_cron_details['args'])) { |
|
124 | + do_action( |
|
125 | + 'AHEE_log', |
|
126 | + __CLASS__, |
|
127 | + __FUNCTION__, |
|
128 | + print_r($ee_cron_details['args'], true), |
|
129 | + "{$ee_cron} args" |
|
130 | + ); |
|
131 | + } |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * reschedule_cron_for_transactions_if_maintenance_mode |
|
142 | + * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
143 | + * |
|
144 | + * @param string $cron_task |
|
145 | + * @param array $TXN_IDs |
|
146 | + * @return bool |
|
147 | + * @throws \DomainException |
|
148 | + */ |
|
149 | 149 | public static function reschedule_cron_for_transactions_if_maintenance_mode( $cron_task, array $TXN_IDs ) { |
150 | - if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
151 | - throw new \DomainException( |
|
152 | - sprintf( |
|
153 | - __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
154 | - $cron_task |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
150 | + if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
151 | + throw new \DomainException( |
|
152 | + sprintf( |
|
153 | + __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
154 | + $cron_task |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | 158 | // reschedule the cron if we can't hit the db right now |
159 | 159 | if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
160 | 160 | foreach( $TXN_IDs as $TXN_ID => $additional_vars ) { |
161 | - // ensure $additional_vars is an array |
|
162 | - $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
161 | + // ensure $additional_vars is an array |
|
162 | + $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
163 | 163 | // reset cron job for the TXN |
164 | - call_user_func_array( |
|
165 | - array('EE_Cron_Tasks', $cron_task), |
|
166 | - array_merge( |
|
167 | - array( |
|
168 | - time() + (10 * MINUTE_IN_SECONDS), |
|
169 | - $TXN_ID |
|
170 | - ), |
|
171 | - $additional_vars |
|
172 | - ) |
|
173 | - ); |
|
164 | + call_user_func_array( |
|
165 | + array('EE_Cron_Tasks', $cron_task), |
|
166 | + array_merge( |
|
167 | + array( |
|
168 | + time() + (10 * MINUTE_IN_SECONDS), |
|
169 | + $TXN_ID |
|
170 | + ), |
|
171 | + $additional_vars |
|
172 | + ) |
|
173 | + ); |
|
174 | 174 | } |
175 | 175 | return true; |
176 | 176 | } |
@@ -180,85 +180,85 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | |
183 | - /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * array of TXN IDs and the payment |
|
188 | - * |
|
189 | - * @var array |
|
190 | - */ |
|
191 | - protected static $_update_transactions_with_payment = array(); |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * schedule_update_transaction_with_payment |
|
196 | - * sets a wp_schedule_single_event() for updating any TXNs that may |
|
197 | - * require updating due to recently received payments |
|
198 | - * |
|
199 | - * @param int $timestamp |
|
200 | - * @param int $TXN_ID |
|
201 | - * @param int $PAY_ID |
|
202 | - */ |
|
203 | - public static function schedule_update_transaction_with_payment( |
|
204 | - $timestamp, |
|
205 | - $TXN_ID, |
|
206 | - $PAY_ID |
|
207 | - ) { |
|
208 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
209 | - // validate $TXN_ID and $timestamp |
|
210 | - $TXN_ID = absint($TXN_ID); |
|
211 | - $timestamp = absint($timestamp); |
|
212 | - if ($TXN_ID && $timestamp) { |
|
213 | - wp_schedule_single_event( |
|
214 | - $timestamp, |
|
215 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
216 | - array($TXN_ID, $PAY_ID) |
|
217 | - ); |
|
218 | - } |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * setup_update_for_transaction_with_payment |
|
224 | - * this is the callback for the action hook: |
|
225 | - * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
226 | - * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
227 | - * The passed TXN_ID and associated payment gets added to an array, and then |
|
228 | - * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
229 | - * 'shutdown' which will actually handle the processing of any |
|
230 | - * transactions requiring updating, because doing so now would be too early |
|
231 | - * and the required resources may not be available |
|
232 | - * |
|
233 | - * @param int $TXN_ID |
|
234 | - * @param int $PAY_ID |
|
235 | - */ |
|
236 | - public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
237 | - { |
|
238 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
239 | - if (absint($TXN_ID)) { |
|
240 | - self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
241 | - add_action( |
|
242 | - 'shutdown', |
|
243 | - array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
244 | - 5 |
|
245 | - ); |
|
246 | - } |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * update_transaction_with_payment |
|
252 | - * loops through the self::$_abandoned_transactions array |
|
253 | - * and attempts to finalize any TXNs that have not been completed |
|
254 | - * but have had their sessions expired, most likely due to a user not |
|
255 | - * returning from an off-site payment gateway |
|
256 | - * |
|
257 | - * @throws \EE_Error |
|
258 | - */ |
|
259 | - public static function update_transaction_with_payment() |
|
260 | - { |
|
261 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
183 | + /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * array of TXN IDs and the payment |
|
188 | + * |
|
189 | + * @var array |
|
190 | + */ |
|
191 | + protected static $_update_transactions_with_payment = array(); |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * schedule_update_transaction_with_payment |
|
196 | + * sets a wp_schedule_single_event() for updating any TXNs that may |
|
197 | + * require updating due to recently received payments |
|
198 | + * |
|
199 | + * @param int $timestamp |
|
200 | + * @param int $TXN_ID |
|
201 | + * @param int $PAY_ID |
|
202 | + */ |
|
203 | + public static function schedule_update_transaction_with_payment( |
|
204 | + $timestamp, |
|
205 | + $TXN_ID, |
|
206 | + $PAY_ID |
|
207 | + ) { |
|
208 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
209 | + // validate $TXN_ID and $timestamp |
|
210 | + $TXN_ID = absint($TXN_ID); |
|
211 | + $timestamp = absint($timestamp); |
|
212 | + if ($TXN_ID && $timestamp) { |
|
213 | + wp_schedule_single_event( |
|
214 | + $timestamp, |
|
215 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
216 | + array($TXN_ID, $PAY_ID) |
|
217 | + ); |
|
218 | + } |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * setup_update_for_transaction_with_payment |
|
224 | + * this is the callback for the action hook: |
|
225 | + * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
226 | + * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
227 | + * The passed TXN_ID and associated payment gets added to an array, and then |
|
228 | + * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
229 | + * 'shutdown' which will actually handle the processing of any |
|
230 | + * transactions requiring updating, because doing so now would be too early |
|
231 | + * and the required resources may not be available |
|
232 | + * |
|
233 | + * @param int $TXN_ID |
|
234 | + * @param int $PAY_ID |
|
235 | + */ |
|
236 | + public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
237 | + { |
|
238 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
239 | + if (absint($TXN_ID)) { |
|
240 | + self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
241 | + add_action( |
|
242 | + 'shutdown', |
|
243 | + array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
244 | + 5 |
|
245 | + ); |
|
246 | + } |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * update_transaction_with_payment |
|
252 | + * loops through the self::$_abandoned_transactions array |
|
253 | + * and attempts to finalize any TXNs that have not been completed |
|
254 | + * but have had their sessions expired, most likely due to a user not |
|
255 | + * returning from an off-site payment gateway |
|
256 | + * |
|
257 | + * @throws \EE_Error |
|
258 | + */ |
|
259 | + public static function update_transaction_with_payment() |
|
260 | + { |
|
261 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
262 | 262 | if ( |
263 | 263 | // are there any TXNs that need cleaning up ? |
264 | 264 | empty( self::$_update_transactions_with_payment ) |
@@ -268,119 +268,119 @@ discard block |
||
268 | 268 | self::$_update_transactions_with_payment |
269 | 269 | ) |
270 | 270 | ) { |
271 | - return; |
|
272 | - } |
|
273 | - /** @type EE_Payment_Processor $payment_processor */ |
|
274 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
275 | - // set revisit flag for payment processor |
|
276 | - $payment_processor->set_revisit(false); |
|
277 | - // load EEM_Transaction |
|
278 | - EE_Registry::instance()->load_model('Transaction'); |
|
279 | - foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
280 | - // reschedule the cron if we can't hit the db right now |
|
281 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
282 | - // reset cron job for updating the TXN |
|
283 | - EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
284 | - time() + EE_Cron_Tasks::reschedule_timeout, |
|
285 | - $TXN_ID, |
|
286 | - $PAY_ID |
|
287 | - ); |
|
288 | - continue; |
|
289 | - } |
|
290 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
291 | - $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
292 | - // verify transaction |
|
293 | - if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
294 | - // now try to update the TXN with any payments |
|
295 | - $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
296 | - } |
|
297 | - unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
298 | - } |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - |
|
303 | - /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
304 | - |
|
305 | - |
|
306 | - /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * array of TXN IDs |
|
311 | - * |
|
312 | - * @var array |
|
313 | - */ |
|
314 | - protected static $_abandoned_transactions = array(); |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * schedule_finalize_abandoned_transactions_check |
|
319 | - * sets a wp_schedule_single_event() for finalizing any TXNs that may |
|
320 | - * have been abandoned during the registration process |
|
321 | - * |
|
322 | - * @param int $timestamp |
|
323 | - * @param int $TXN_ID |
|
324 | - */ |
|
325 | - public static function schedule_finalize_abandoned_transactions_check( |
|
326 | - $timestamp, |
|
327 | - $TXN_ID |
|
328 | - ) { |
|
329 | - // validate $TXN_ID and $timestamp |
|
330 | - $TXN_ID = absint($TXN_ID); |
|
331 | - $timestamp = absint($timestamp); |
|
332 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
333 | - if ($TXN_ID && $timestamp) { |
|
334 | - wp_schedule_single_event( |
|
335 | - $timestamp, |
|
336 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
337 | - array($TXN_ID) |
|
338 | - ); |
|
339 | - } |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * check_for_abandoned_transactions |
|
345 | - * this is the callback for the action hook: |
|
346 | - * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions' |
|
347 | - * which is utilized by wp_schedule_single_event() |
|
348 | - * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing(). |
|
349 | - * The passed TXN_ID gets added to an array, and then the |
|
350 | - * espresso_finalize_abandoned_transactions() function is hooked into |
|
351 | - * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
352 | - * processing of any abandoned transactions, because doing so now would be |
|
353 | - * too early and the required resources may not be available |
|
354 | - * |
|
355 | - * @param int $TXN_ID |
|
356 | - */ |
|
357 | - public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
358 | - { |
|
359 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
360 | - if (absint($TXN_ID)) { |
|
361 | - self::$_abandoned_transactions[] = $TXN_ID; |
|
362 | - add_action( |
|
363 | - 'shutdown', |
|
364 | - array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
365 | - 5 |
|
366 | - ); |
|
367 | - } |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * finalize_abandoned_transactions |
|
373 | - * loops through the self::$_abandoned_transactions array |
|
374 | - * and attempts to finalize any TXNs that have not been completed |
|
375 | - * but have had their sessions expired, most likely due to a user not |
|
376 | - * returning from an off-site payment gateway |
|
377 | - * |
|
378 | - * @throws \EE_Error |
|
379 | - */ |
|
380 | - public static function finalize_abandoned_transactions() |
|
381 | - { |
|
382 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
383 | - if ( |
|
271 | + return; |
|
272 | + } |
|
273 | + /** @type EE_Payment_Processor $payment_processor */ |
|
274 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
275 | + // set revisit flag for payment processor |
|
276 | + $payment_processor->set_revisit(false); |
|
277 | + // load EEM_Transaction |
|
278 | + EE_Registry::instance()->load_model('Transaction'); |
|
279 | + foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
280 | + // reschedule the cron if we can't hit the db right now |
|
281 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
282 | + // reset cron job for updating the TXN |
|
283 | + EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
284 | + time() + EE_Cron_Tasks::reschedule_timeout, |
|
285 | + $TXN_ID, |
|
286 | + $PAY_ID |
|
287 | + ); |
|
288 | + continue; |
|
289 | + } |
|
290 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
291 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
292 | + // verify transaction |
|
293 | + if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
294 | + // now try to update the TXN with any payments |
|
295 | + $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
296 | + } |
|
297 | + unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
298 | + } |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + |
|
303 | + /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
304 | + |
|
305 | + |
|
306 | + /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * array of TXN IDs |
|
311 | + * |
|
312 | + * @var array |
|
313 | + */ |
|
314 | + protected static $_abandoned_transactions = array(); |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * schedule_finalize_abandoned_transactions_check |
|
319 | + * sets a wp_schedule_single_event() for finalizing any TXNs that may |
|
320 | + * have been abandoned during the registration process |
|
321 | + * |
|
322 | + * @param int $timestamp |
|
323 | + * @param int $TXN_ID |
|
324 | + */ |
|
325 | + public static function schedule_finalize_abandoned_transactions_check( |
|
326 | + $timestamp, |
|
327 | + $TXN_ID |
|
328 | + ) { |
|
329 | + // validate $TXN_ID and $timestamp |
|
330 | + $TXN_ID = absint($TXN_ID); |
|
331 | + $timestamp = absint($timestamp); |
|
332 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
333 | + if ($TXN_ID && $timestamp) { |
|
334 | + wp_schedule_single_event( |
|
335 | + $timestamp, |
|
336 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
337 | + array($TXN_ID) |
|
338 | + ); |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * check_for_abandoned_transactions |
|
345 | + * this is the callback for the action hook: |
|
346 | + * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions' |
|
347 | + * which is utilized by wp_schedule_single_event() |
|
348 | + * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing(). |
|
349 | + * The passed TXN_ID gets added to an array, and then the |
|
350 | + * espresso_finalize_abandoned_transactions() function is hooked into |
|
351 | + * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
352 | + * processing of any abandoned transactions, because doing so now would be |
|
353 | + * too early and the required resources may not be available |
|
354 | + * |
|
355 | + * @param int $TXN_ID |
|
356 | + */ |
|
357 | + public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
358 | + { |
|
359 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
360 | + if (absint($TXN_ID)) { |
|
361 | + self::$_abandoned_transactions[] = $TXN_ID; |
|
362 | + add_action( |
|
363 | + 'shutdown', |
|
364 | + array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
365 | + 5 |
|
366 | + ); |
|
367 | + } |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * finalize_abandoned_transactions |
|
373 | + * loops through the self::$_abandoned_transactions array |
|
374 | + * and attempts to finalize any TXNs that have not been completed |
|
375 | + * but have had their sessions expired, most likely due to a user not |
|
376 | + * returning from an off-site payment gateway |
|
377 | + * |
|
378 | + * @throws \EE_Error |
|
379 | + */ |
|
380 | + public static function finalize_abandoned_transactions() |
|
381 | + { |
|
382 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
383 | + if ( |
|
384 | 384 | // are there any TXNs that need cleaning up ? |
385 | 385 | empty( self::$_abandoned_transactions ) |
386 | 386 | // reschedule the cron if we can't hit the db right now |
@@ -389,45 +389,45 @@ discard block |
||
389 | 389 | self::$_abandoned_transactions |
390 | 390 | ) |
391 | 391 | ) { |
392 | - return; |
|
393 | - } |
|
394 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
395 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
396 | - // set revisit flag for txn processor |
|
397 | - $transaction_processor->set_revisit(false); |
|
398 | - /** @type EE_Payment_Processor $payment_processor */ |
|
399 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
400 | - // load EEM_Transaction |
|
401 | - EE_Registry::instance()->load_model('Transaction'); |
|
402 | - foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
403 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
404 | - // reschedule the cron if we can't hit the db right now |
|
405 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
406 | - // reset cron job for finalizing the TXN |
|
407 | - EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
|
408 | - time() + EE_Cron_Tasks::reschedule_timeout, |
|
409 | - $TXN_ID |
|
410 | - ); |
|
411 | - continue; |
|
412 | - } |
|
413 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
414 | - // verify transaction |
|
415 | - if ($transaction instanceof EE_Transaction) { |
|
416 | - // don't finalize the TXN if it has already been completed |
|
417 | - if ($transaction->all_reg_steps_completed() === true) { |
|
418 | - continue; |
|
419 | - } |
|
420 | - // let's simulate an IPN here which will trigger any notifications that need to go out |
|
421 | - $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, |
|
422 | - true); |
|
423 | - } |
|
424 | - unset(self::$_abandoned_transactions[$TXN_ID]); |
|
425 | - } |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - |
|
430 | - /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
392 | + return; |
|
393 | + } |
|
394 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
395 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
396 | + // set revisit flag for txn processor |
|
397 | + $transaction_processor->set_revisit(false); |
|
398 | + /** @type EE_Payment_Processor $payment_processor */ |
|
399 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
400 | + // load EEM_Transaction |
|
401 | + EE_Registry::instance()->load_model('Transaction'); |
|
402 | + foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
403 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
404 | + // reschedule the cron if we can't hit the db right now |
|
405 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
406 | + // reset cron job for finalizing the TXN |
|
407 | + EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
|
408 | + time() + EE_Cron_Tasks::reschedule_timeout, |
|
409 | + $TXN_ID |
|
410 | + ); |
|
411 | + continue; |
|
412 | + } |
|
413 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
414 | + // verify transaction |
|
415 | + if ($transaction instanceof EE_Transaction) { |
|
416 | + // don't finalize the TXN if it has already been completed |
|
417 | + if ($transaction->all_reg_steps_completed() === true) { |
|
418 | + continue; |
|
419 | + } |
|
420 | + // let's simulate an IPN here which will trigger any notifications that need to go out |
|
421 | + $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, |
|
422 | + true); |
|
423 | + } |
|
424 | + unset(self::$_abandoned_transactions[$TXN_ID]); |
|
425 | + } |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + |
|
430 | + /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
431 | 431 | |
432 | 432 | |
433 | 433 | /***************** EXPIRED TRANSACTION CHECK *****************/ |
@@ -496,12 +496,12 @@ discard block |
||
496 | 496 | |
497 | 497 | |
498 | 498 | |
499 | - /** |
|
500 | - * process_expired_transactions |
|
501 | - * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
502 | - * |
|
503 | - * @throws \EE_Error |
|
504 | - */ |
|
499 | + /** |
|
500 | + * process_expired_transactions |
|
501 | + * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
502 | + * |
|
503 | + * @throws \EE_Error |
|
504 | + */ |
|
505 | 505 | public static function process_expired_transactions() { |
506 | 506 | if ( |
507 | 507 | // are there any TXNs that need cleaning up ? |
@@ -512,58 +512,58 @@ discard block |
||
512 | 512 | self::$_expired_transactions |
513 | 513 | ) |
514 | 514 | ) { |
515 | - return; |
|
516 | - } |
|
517 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
518 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
519 | - // set revisit flag for txn processor |
|
520 | - $transaction_processor->set_revisit( false ); |
|
521 | - // load EEM_Transaction |
|
522 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
523 | - foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
524 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
525 | - // verify transaction and whether it is failed or not |
|
526 | - if ( $transaction instanceof EE_Transaction) { |
|
527 | - switch( $transaction->status_ID() ) { |
|
528 | - // Completed TXNs |
|
529 | - case EEM_Transaction::complete_status_code : |
|
530 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
531 | - break; |
|
532 | - // Overpaid TXNs |
|
533 | - case EEM_Transaction::overpaid_status_code : |
|
534 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
535 | - break; |
|
536 | - // Incomplete TXNs |
|
537 | - case EEM_Transaction::incomplete_status_code : |
|
538 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
539 | - // todo : merge the finalize_abandoned_transactions cron into this one... |
|
540 | - // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
541 | - break; |
|
542 | - // Failed TXNs |
|
543 | - case EEM_Transaction::failed_status_code : |
|
544 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
545 | - // todo : perform garbage collection here and remove clean_out_junk_transactions() |
|
546 | - //$registrations = $transaction->registrations(); |
|
547 | - //if ( ! empty( $registrations ) ) { |
|
548 | - // foreach ( $registrations as $registration ) { |
|
549 | - // if ( $registration instanceof EE_Registration ) { |
|
550 | - //$delete_registration = true; |
|
551 | - //if ( $registration->attendee() instanceof EE_Attendee ) { |
|
552 | - // $delete_registration = false; |
|
553 | - //} |
|
554 | - //if ( $delete_registration ) { |
|
555 | - // $registration->delete_permanently(); |
|
556 | - // $registration->delete_related_permanently(); |
|
557 | - //} |
|
558 | - // } |
|
559 | - // } |
|
560 | - //} |
|
561 | - break; |
|
562 | - } |
|
563 | - |
|
564 | - } |
|
565 | - unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
566 | - } |
|
515 | + return; |
|
516 | + } |
|
517 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
518 | + $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
519 | + // set revisit flag for txn processor |
|
520 | + $transaction_processor->set_revisit( false ); |
|
521 | + // load EEM_Transaction |
|
522 | + EE_Registry::instance()->load_model( 'Transaction' ); |
|
523 | + foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
524 | + $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
525 | + // verify transaction and whether it is failed or not |
|
526 | + if ( $transaction instanceof EE_Transaction) { |
|
527 | + switch( $transaction->status_ID() ) { |
|
528 | + // Completed TXNs |
|
529 | + case EEM_Transaction::complete_status_code : |
|
530 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
531 | + break; |
|
532 | + // Overpaid TXNs |
|
533 | + case EEM_Transaction::overpaid_status_code : |
|
534 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
535 | + break; |
|
536 | + // Incomplete TXNs |
|
537 | + case EEM_Transaction::incomplete_status_code : |
|
538 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
539 | + // todo : merge the finalize_abandoned_transactions cron into this one... |
|
540 | + // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
541 | + break; |
|
542 | + // Failed TXNs |
|
543 | + case EEM_Transaction::failed_status_code : |
|
544 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
545 | + // todo : perform garbage collection here and remove clean_out_junk_transactions() |
|
546 | + //$registrations = $transaction->registrations(); |
|
547 | + //if ( ! empty( $registrations ) ) { |
|
548 | + // foreach ( $registrations as $registration ) { |
|
549 | + // if ( $registration instanceof EE_Registration ) { |
|
550 | + //$delete_registration = true; |
|
551 | + //if ( $registration->attendee() instanceof EE_Attendee ) { |
|
552 | + // $delete_registration = false; |
|
553 | + //} |
|
554 | + //if ( $delete_registration ) { |
|
555 | + // $registration->delete_permanently(); |
|
556 | + // $registration->delete_related_permanently(); |
|
557 | + //} |
|
558 | + // } |
|
559 | + // } |
|
560 | + //} |
|
561 | + break; |
|
562 | + } |
|
563 | + |
|
564 | + } |
|
565 | + unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
566 | + } |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -571,33 +571,33 @@ discard block |
||
571 | 571 | /************* END OF EXPIRED TRANSACTION CHECK *************/ |
572 | 572 | |
573 | 573 | |
574 | - /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
575 | - |
|
576 | - //when a transaction is initially made, schedule this check. |
|
577 | - //if it has NO REG data by the time it has expired, forget about it |
|
578 | - public static function clean_out_junk_transactions() |
|
579 | - { |
|
580 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
581 | - EEM_Transaction::instance('')->delete_junk_transactions(); |
|
582 | - EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
583 | - EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
584 | - } |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
591 | - */ |
|
592 | - public static function clean_out_old_gateway_logs(){ |
|
593 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
594 | - $time_diff_for_comparison = apply_filters( |
|
595 | - 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
596 | - "-1 week" |
|
597 | - ); |
|
598 | - EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
599 | - } |
|
600 | - } |
|
574 | + /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
575 | + |
|
576 | + //when a transaction is initially made, schedule this check. |
|
577 | + //if it has NO REG data by the time it has expired, forget about it |
|
578 | + public static function clean_out_junk_transactions() |
|
579 | + { |
|
580 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
581 | + EEM_Transaction::instance('')->delete_junk_transactions(); |
|
582 | + EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
583 | + EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
584 | + } |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
591 | + */ |
|
592 | + public static function clean_out_old_gateway_logs(){ |
|
593 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
594 | + $time_diff_for_comparison = apply_filters( |
|
595 | + 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
596 | + "-1 week" |
|
597 | + ); |
|
598 | + EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
599 | + } |
|
600 | + } |
|
601 | 601 | |
602 | 602 | |
603 | 603 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * wanting to not have this functionality can just register its own action at a priority after this one to |
58 | 58 | * reverse any changes. |
59 | 59 | */ |
60 | - add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
60 | + add_action('AHEE__EE_System__load_core_configuration__complete', function() { |
|
61 | 61 | EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
62 | 62 | EE_Registry::instance()->NET_CFG->update_config(true, false); |
63 | 63 | add_option('ee_disabled_wp_cron_check', 1, '', false); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // EXPIRED TRANSACTION CHECK |
79 | 79 | add_action( |
80 | 80 | 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
81 | - array( 'EE_Cron_Tasks', 'expired_transaction_check' ), |
|
81 | + array('EE_Cron_Tasks', 'expired_transaction_check'), |
|
82 | 82 | 10, 1 |
83 | 83 | ); |
84 | 84 | // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @return bool |
147 | 147 | * @throws \DomainException |
148 | 148 | */ |
149 | - public static function reschedule_cron_for_transactions_if_maintenance_mode( $cron_task, array $TXN_IDs ) { |
|
150 | - if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
149 | + public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs) { |
|
150 | + if ( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
151 | 151 | throw new \DomainException( |
152 | 152 | sprintf( |
153 | 153 | __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | ); |
157 | 157 | } |
158 | 158 | // reschedule the cron if we can't hit the db right now |
159 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
160 | - foreach( $TXN_IDs as $TXN_ID => $additional_vars ) { |
|
159 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
160 | + foreach ($TXN_IDs as $TXN_ID => $additional_vars) { |
|
161 | 161 | // ensure $additional_vars is an array |
162 | 162 | $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
163 | 163 | // reset cron job for the TXN |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | do_action('AHEE_log', __CLASS__, __FUNCTION__); |
262 | 262 | if ( |
263 | 263 | // are there any TXNs that need cleaning up ? |
264 | - empty( self::$_update_transactions_with_payment ) |
|
264 | + empty(self::$_update_transactions_with_payment) |
|
265 | 265 | // reschedule the cron if we can't hit the db right now |
266 | 266 | || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
267 | 267 | 'schedule_update_transaction_with_payment', |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | do_action('AHEE_log', __CLASS__, __FUNCTION__); |
383 | 383 | if ( |
384 | 384 | // are there any TXNs that need cleaning up ? |
385 | - empty( self::$_abandoned_transactions ) |
|
385 | + empty(self::$_abandoned_transactions) |
|
386 | 386 | // reschedule the cron if we can't hit the db right now |
387 | 387 | || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
388 | 388 | 'schedule_finalize_abandoned_transactions_check', |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | $TXN_ID |
456 | 456 | ) { |
457 | 457 | // validate $TXN_ID and $timestamp |
458 | - $TXN_ID = absint( $TXN_ID ); |
|
459 | - $timestamp = absint( $timestamp ); |
|
460 | - if ( $TXN_ID && $timestamp ) { |
|
458 | + $TXN_ID = absint($TXN_ID); |
|
459 | + $timestamp = absint($timestamp); |
|
460 | + if ($TXN_ID && $timestamp) { |
|
461 | 461 | wp_schedule_single_event( |
462 | 462 | $timestamp, |
463 | 463 | 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
464 | - array( $TXN_ID ) |
|
464 | + array($TXN_ID) |
|
465 | 465 | ); |
466 | 466 | } |
467 | 467 | } |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @param int $TXN_ID |
485 | 485 | */ |
486 | - public static function expired_transaction_check( $TXN_ID = 0 ) { |
|
487 | - if ( absint( $TXN_ID )) { |
|
488 | - self::$_expired_transactions[ $TXN_ID ] = $TXN_ID; |
|
486 | + public static function expired_transaction_check($TXN_ID = 0) { |
|
487 | + if (absint($TXN_ID)) { |
|
488 | + self::$_expired_transactions[$TXN_ID] = $TXN_ID; |
|
489 | 489 | add_action( |
490 | 490 | 'shutdown', |
491 | - array( 'EE_Cron_Tasks', 'process_expired_transactions' ), |
|
491 | + array('EE_Cron_Tasks', 'process_expired_transactions'), |
|
492 | 492 | 5 |
493 | 493 | ); |
494 | 494 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | public static function process_expired_transactions() { |
506 | 506 | if ( |
507 | 507 | // are there any TXNs that need cleaning up ? |
508 | - empty( self::$_expired_transactions ) |
|
508 | + empty(self::$_expired_transactions) |
|
509 | 509 | // reschedule the cron if we can't hit the db right now |
510 | 510 | || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
511 | 511 | 'schedule_expired_transaction_check', |
@@ -515,33 +515,33 @@ discard block |
||
515 | 515 | return; |
516 | 516 | } |
517 | 517 | /** @type EE_Transaction_Processor $transaction_processor */ |
518 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
518 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
519 | 519 | // set revisit flag for txn processor |
520 | - $transaction_processor->set_revisit( false ); |
|
520 | + $transaction_processor->set_revisit(false); |
|
521 | 521 | // load EEM_Transaction |
522 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
523 | - foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
524 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
522 | + EE_Registry::instance()->load_model('Transaction'); |
|
523 | + foreach (self::$_expired_transactions as $TXN_ID) { |
|
524 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
525 | 525 | // verify transaction and whether it is failed or not |
526 | - if ( $transaction instanceof EE_Transaction) { |
|
527 | - switch( $transaction->status_ID() ) { |
|
526 | + if ($transaction instanceof EE_Transaction) { |
|
527 | + switch ($transaction->status_ID()) { |
|
528 | 528 | // Completed TXNs |
529 | 529 | case EEM_Transaction::complete_status_code : |
530 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
530 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction); |
|
531 | 531 | break; |
532 | 532 | // Overpaid TXNs |
533 | 533 | case EEM_Transaction::overpaid_status_code : |
534 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
534 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction); |
|
535 | 535 | break; |
536 | 536 | // Incomplete TXNs |
537 | 537 | case EEM_Transaction::incomplete_status_code : |
538 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
538 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction); |
|
539 | 539 | // todo : merge the finalize_abandoned_transactions cron into this one... |
540 | 540 | // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
541 | 541 | break; |
542 | 542 | // Failed TXNs |
543 | 543 | case EEM_Transaction::failed_status_code : |
544 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
544 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction); |
|
545 | 545 | // todo : perform garbage collection here and remove clean_out_junk_transactions() |
546 | 546 | //$registrations = $transaction->registrations(); |
547 | 547 | //if ( ! empty( $registrations ) ) { |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | } |
563 | 563 | |
564 | 564 | } |
565 | - unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
565 | + unset(self::$_expired_transactions[$TXN_ID]); |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | /** |
590 | 590 | * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
591 | 591 | */ |
592 | - public static function clean_out_old_gateway_logs(){ |
|
592 | + public static function clean_out_old_gateway_logs() { |
|
593 | 593 | if (EE_Maintenance_Mode::instance()->models_can_query()) { |
594 | 594 | $time_diff_for_comparison = apply_filters( |
595 | 595 | 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |