Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Registrations_Admin_Page often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Registrations_Admin_Page, and based on these observations, apply Extract Interface, too.
1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
||
24 | class Registrations_Admin_Page extends EE_Admin_Page_CPT { |
||
25 | |||
26 | /** |
||
27 | * @var EE_Registration |
||
28 | */ |
||
29 | private $_registration; |
||
30 | |||
31 | /** |
||
32 | * @var EE_Event |
||
33 | */ |
||
34 | private $_reg_event; |
||
35 | |||
36 | /** |
||
37 | * @var EE_Session |
||
38 | */ |
||
39 | private $_session; |
||
40 | private static $_reg_status; |
||
41 | |||
42 | /** |
||
43 | * Form for displaying the custom questions for this registration. |
||
44 | * This gets used a few times throughout the request so its best to cache it |
||
45 | * @var EE_Registration_Custom_Questions_Form |
||
46 | */ |
||
47 | protected $_reg_custom_questions_form = null; |
||
48 | |||
49 | |||
50 | |||
51 | /** |
||
52 | * constructor |
||
53 | * |
||
54 | * @Constructor |
||
55 | * @access public |
||
56 | * @param bool $routing |
||
57 | * @return Registrations_Admin_Page |
||
|
|||
58 | */ |
||
59 | public function __construct( $routing = TRUE ) { |
||
60 | parent::__construct( $routing ); |
||
61 | add_action( 'wp_loaded', array( $this, 'wp_loaded' )); |
||
62 | } |
||
63 | |||
64 | |||
65 | |||
66 | public function wp_loaded() { |
||
67 | // when adding a new registration... |
||
68 | if ( isset( $this->_req_data[ 'action' ] ) && $this->_req_data[ 'action' ] == 'new_registration' ) { |
||
69 | EE_System::do_not_cache(); |
||
70 | if ( |
||
71 | ! isset( $this->_req_data[ 'processing_registration' ] ) |
||
72 | || absint( $this->_req_data[ 'processing_registration' ] ) !== 1 |
||
73 | ) { |
||
74 | // and it's NOT the attendee information reg step |
||
75 | // force cookie expiration by setting time to last week |
||
76 | setcookie( 'ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/' ); |
||
77 | // and update the global |
||
78 | $_COOKIE[ 'ee_registration_added' ] = 0; |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | |||
83 | |||
84 | |||
85 | |||
86 | |||
87 | |||
88 | protected function _init_page_props() { |
||
89 | $this->page_slug = REG_PG_SLUG; |
||
90 | $this->_admin_base_url = REG_ADMIN_URL; |
||
91 | $this->_admin_base_path = REG_ADMIN; |
||
92 | $this->page_label = __('Registrations', 'event_espresso'); |
||
93 | $this->_cpt_routes = array( |
||
94 | 'add_new_attendee' => 'espresso_attendees', |
||
95 | 'edit_attendee' => 'espresso_attendees', |
||
96 | 'insert_attendee' => 'espresso_attendees', |
||
97 | 'update_attendee' => 'espresso_attendees' |
||
98 | ); |
||
99 | $this->_cpt_model_names = array( |
||
100 | 'add_new_attendee' => 'EEM_Attendee', |
||
101 | 'edit_attendee' => 'EEM_Attendee' |
||
102 | ); |
||
103 | $this->_cpt_edit_routes = array( |
||
104 | 'espresso_attendees' => 'edit_attendee' |
||
105 | ); |
||
106 | $this->_pagenow_map = array( |
||
107 | 'add_new_attendee' => 'post-new.php', |
||
108 | 'edit_attendee' => 'post.php', |
||
109 | 'trash' => 'post.php' |
||
110 | ); |
||
111 | |||
112 | add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 ); |
||
113 | //add filters so that the comment urls don't take users to a confusing 404 page |
||
114 | add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 ); |
||
115 | } |
||
116 | |||
117 | |||
118 | public function clear_comment_link( $link, $comment, $args ) { |
||
125 | |||
126 | |||
127 | protected function _ajax_hooks() { |
||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | protected function _define_page_props() { |
||
157 | |||
158 | |||
159 | |||
160 | |||
161 | |||
162 | |||
163 | |||
164 | /** |
||
165 | * grab url requests and route them |
||
166 | * @access private |
||
167 | * @return void |
||
168 | */ |
||
169 | public function _set_page_routes() { |
||
170 | |||
171 | $this->_get_registration_status_array(); |
||
172 | |||
173 | $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
||
174 | $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0; |
||
175 | $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
||
176 | |||
177 | $this->_page_routes = array( |
||
178 | |||
179 | 'default' => array( |
||
180 | 'func' => '_registrations_overview_list_table', |
||
181 | 'capability' => 'ee_read_registrations' |
||
182 | ), |
||
183 | |||
184 | 'view_registration' => array( |
||
185 | 'func' => '_registration_details', |
||
186 | 'capability' => 'ee_read_registration', |
||
187 | 'obj_id' => $reg_id |
||
188 | ), |
||
189 | |||
190 | 'edit_registration' => array( |
||
191 | 'func' => '_update_attendee_registration_form', |
||
192 | 'noheader' => TRUE, |
||
193 | 'headers_sent_route'=>'view_registration', |
||
194 | 'capability' => 'ee_edit_registration', |
||
195 | 'obj_id' => $reg_id, |
||
196 | '_REG_ID' => $reg_id, |
||
197 | ), |
||
198 | |||
199 | 'trash_registrations' => array( |
||
200 | 'func' => '_trash_or_restore_registrations', |
||
201 | 'args' => array('trash' => TRUE), |
||
202 | 'noheader' => TRUE, |
||
203 | 'capability' => 'ee_delete_registrations' |
||
204 | ), |
||
205 | |||
206 | 'restore_registrations' => array( |
||
207 | 'func' => '_trash_or_restore_registrations', |
||
208 | 'args' => array( 'trash' => FALSE ), |
||
209 | 'noheader' => TRUE, |
||
210 | 'capability' => 'ee_delete_registrations' |
||
211 | ), |
||
212 | |||
213 | 'delete_registrations' => array( |
||
214 | 'func' => '_delete_registrations', |
||
215 | 'noheader' => TRUE, |
||
216 | 'capability' => 'ee_delete_registrations' |
||
217 | ), |
||
218 | |||
219 | 'new_registration' => array( |
||
220 | 'func' => 'new_registration', |
||
221 | 'capability' => 'ee_edit_registrations' |
||
222 | ), |
||
223 | |||
224 | 'process_reg_step' => array( |
||
225 | 'func' => 'process_reg_step', |
||
226 | 'noheader' => TRUE, |
||
227 | 'capability' => 'ee_edit_registrations' |
||
228 | ), |
||
229 | |||
230 | 'redirect_to_txn' => array( |
||
231 | 'func' => 'redirect_to_txn', |
||
232 | 'noheader' => TRUE, |
||
233 | 'capability' => 'ee_edit_registrations' |
||
234 | ), |
||
235 | |||
236 | 'change_reg_status' => array( |
||
237 | 'func' => '_change_reg_status', |
||
238 | 'noheader' => TRUE, |
||
239 | 'capability' => 'ee_edit_registration', |
||
240 | 'obj_id' => $reg_id |
||
241 | ), |
||
242 | |||
243 | 'approve_registration' => array( |
||
244 | 'func' => 'approve_registration', |
||
245 | 'noheader' => TRUE, |
||
246 | 'capability' => 'ee_edit_registration', |
||
247 | 'obj_id' => $reg_id |
||
248 | ), |
||
249 | |||
250 | 'approve_and_notify_registration' => array( |
||
251 | 'func' => 'approve_registration', |
||
252 | 'noheader' => TRUE, |
||
253 | 'args' => array(TRUE), |
||
254 | 'capability' => 'ee_edit_registration', |
||
255 | 'obj_id' => $reg_id |
||
256 | ), |
||
257 | |||
258 | 'decline_registration' => array( |
||
259 | 'func' => 'decline_registration', |
||
260 | 'noheader' => TRUE, |
||
261 | 'capability' => 'ee_edit_registration', |
||
262 | 'obj_id' => $reg_id |
||
263 | ), |
||
264 | |||
265 | 'decline_and_notify_registration' => array( |
||
266 | 'func' => 'decline_registration', |
||
267 | 'noheader' => TRUE, |
||
268 | 'args' => array(TRUE), |
||
269 | 'capability' => 'ee_edit_registration', |
||
270 | 'obj_id' => $reg_id |
||
271 | ), |
||
272 | |||
273 | 'pending_registration' => array( |
||
274 | 'func' => 'pending_registration', |
||
275 | 'noheader' => TRUE, |
||
276 | 'capability' => 'ee_edit_registration', |
||
277 | 'obj_id' => $reg_id |
||
278 | ), |
||
279 | |||
280 | 'pending_and_notify_registration' => array( |
||
281 | 'func' => 'pending_registration', |
||
282 | 'noheader' => TRUE, |
||
283 | 'args' => array(TRUE), |
||
284 | 'capability' => 'ee_edit_registration', |
||
285 | 'obj_id' => $reg_id |
||
286 | ), |
||
287 | |||
288 | 'no_approve_registration' => array( |
||
289 | 'func' => 'not_approve_registration', |
||
290 | 'noheader' => TRUE, |
||
291 | 'capability' => 'ee_edit_registration', |
||
292 | 'obj_id' => $reg_id |
||
293 | ), |
||
294 | |||
295 | 'no_approve_and_notify_registration' => array( |
||
296 | 'func' => 'not_approve_registration', |
||
297 | 'noheader' => TRUE, |
||
298 | 'args' => array(TRUE), |
||
299 | 'capability' => 'ee_edit_registration', |
||
300 | 'obj_id' => $reg_id |
||
301 | ), |
||
302 | |||
303 | 'cancel_registration' => array( |
||
304 | 'func' => 'cancel_registration', |
||
305 | 'noheader' => TRUE, |
||
306 | 'capability' => 'ee_edit_registration', |
||
307 | 'obj_id' => $reg_id |
||
308 | ), |
||
309 | |||
310 | 'cancel_and_notify_registration' => array( |
||
311 | 'func' => 'cancel_registration', |
||
312 | 'noheader' => TRUE, |
||
313 | 'args' => array(TRUE), |
||
314 | 'capability' => 'ee_edit_registration', |
||
315 | 'obj_id' => $reg_id |
||
316 | ), |
||
317 | |||
318 | 'contact_list' => array( |
||
319 | 'func' => '_attendee_contact_list_table', |
||
320 | 'capability' => 'ee_read_contacts' |
||
321 | ), |
||
322 | |||
323 | |||
324 | 'add_new_attendee' => array( |
||
325 | 'func' => '_create_new_cpt_item', |
||
326 | 'args' => array( |
||
327 | 'new_attendee' => TRUE, |
||
328 | 'capability' => 'ee_edit_contacts' |
||
329 | ) |
||
330 | ), |
||
331 | |||
332 | 'edit_attendee' => array( |
||
333 | 'func' => '_edit_cpt_item', |
||
334 | 'capability' => 'ee_edit_contacts', |
||
335 | 'obj_id' => $att_id |
||
336 | ), |
||
337 | |||
338 | 'duplicate_attendee' => array( |
||
339 | 'func' => '_duplicate_attendee', |
||
340 | 'noheader' => TRUE, |
||
341 | 'capability' => 'ee_edit_contacts', |
||
342 | 'obj_id' => $att_id |
||
343 | ), |
||
344 | |||
345 | 'insert_attendee' => array( |
||
346 | 'func' => '_insert_or_update_attendee', |
||
347 | 'args' => array( |
||
348 | 'new_attendee' => TRUE |
||
349 | ), |
||
350 | 'noheader' => TRUE, |
||
351 | 'capability' => 'ee_edit_contacts' |
||
352 | ), |
||
353 | |||
354 | 'update_attendee' => array( |
||
355 | 'func' => '_insert_or_update_attendee', |
||
356 | 'args' => array( |
||
357 | 'new_attendee' => FALSE |
||
358 | ), |
||
359 | 'noheader' => TRUE, |
||
360 | 'capability' => 'ee_edit_contacts', |
||
361 | 'obj_id' => $att_id |
||
362 | ), |
||
363 | |||
364 | 'trash_attendees' => array( |
||
365 | 'func' => '_trash_or_restore_attendees', |
||
366 | 'args' => array( |
||
367 | 'trash' => TRUE |
||
368 | ), |
||
369 | 'noheader' => TRUE, |
||
370 | 'capability' => 'ee_delete_contacts', |
||
371 | 'obj_id' => $att_id |
||
372 | ), |
||
373 | |||
374 | 'restore_attendees' => array( |
||
375 | 'func' => '_trash_or_restore_attendees', |
||
376 | 'args' => array( |
||
377 | 'trash' => FALSE |
||
378 | ), |
||
379 | 'noheader' => TRUE, |
||
380 | 'capability' => 'ee_delete_contacts', |
||
381 | 'obj_id' => $att_id |
||
382 | ), |
||
383 | 'resend_registration' => array( |
||
384 | 'func' => '_resend_registration', |
||
385 | 'noheader' => TRUE, |
||
386 | 'capability' => 'ee_send_message' |
||
387 | ), |
||
388 | 'registrations_report'=>array( |
||
389 | 'func'=>'_registrations_report', |
||
390 | 'noheader'=> TRUE, |
||
391 | 'capability' => 'ee_read_registrations' |
||
392 | ), |
||
393 | 'contact_list_export'=>array( |
||
394 | 'func'=>'_contact_list_export', |
||
395 | 'noheader'=>TRUE, |
||
396 | 'capability' => 'export' |
||
397 | ), |
||
398 | 'contact_list_report' => array( |
||
399 | 'func'=> '_contact_list_report', |
||
400 | 'noheader' => TRUE, |
||
401 | 'capability' => 'ee_read_contacts', |
||
402 | ) |
||
403 | ); |
||
404 | |||
405 | } |
||
406 | |||
407 | |||
408 | |||
409 | |||
410 | |||
411 | protected function _set_page_config() { |
||
412 | $this->_page_config = array( |
||
413 | |||
414 | 'default' => array( |
||
415 | 'nav' => array( |
||
416 | 'label' => __('Overview', 'event_espresso'), |
||
417 | 'order' => 5 |
||
418 | ), |
||
419 | 'help_tabs' => array( |
||
420 | 'registrations_overview_help_tab' => array( |
||
421 | 'title' => __('Registrations Overview', 'event_espresso'), |
||
422 | 'filename' => 'registrations_overview' |
||
423 | ), |
||
424 | 'registrations_overview_table_column_headings_help_tab' => array( |
||
425 | 'title' => __('Registrations Table Column Headings', 'event_espresso'), |
||
426 | 'filename' => 'registrations_overview_table_column_headings' |
||
427 | ), |
||
428 | 'registrations_overview_filters_help_tab' => array( |
||
429 | 'title' => __('Registration Filters', 'event_espresso'), |
||
430 | 'filename' => 'registrations_overview_filters' |
||
431 | ), |
||
432 | 'registrations_overview_views_help_tab' => array( |
||
433 | 'title' => __('Registration Views', 'event_espresso'), |
||
434 | 'filename' => 'registrations_overview_views' |
||
435 | ), |
||
436 | 'registrations_regoverview_other_help_tab' => array( |
||
437 | 'title' => __('Registrations Other', 'event_espresso'), |
||
438 | 'filename' => 'registrations_overview_other' |
||
439 | ) |
||
440 | ), |
||
441 | 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
||
442 | 'qtips' => array('Registration_List_Table_Tips'), |
||
443 | 'list_table' => 'EE_Registrations_List_Table', |
||
444 | 'require_nonce' => FALSE |
||
445 | ), |
||
446 | |||
447 | 'view_registration' => array( |
||
448 | 'nav' => array( |
||
449 | 'label' => __('REG Details', 'event_espresso'), |
||
450 | 'order' => 15, |
||
451 | 'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
||
452 | 'persistent' => FALSE |
||
453 | ), |
||
454 | 'help_tabs' => array( |
||
455 | 'registrations_details_help_tab' => array( |
||
456 | 'title' => __('Registration Details', 'event_espresso'), |
||
457 | 'filename' => 'registrations_details' |
||
458 | ), |
||
459 | 'registrations_details_table_help_tab' => array( |
||
460 | 'title' => __('Registration Details Table', 'event_espresso'), |
||
461 | 'filename' => 'registrations_details_table' |
||
462 | ), |
||
463 | 'registrations_details_form_answers_help_tab' => array( |
||
464 | 'title' => __('Registration Form Answers', 'event_espresso'), |
||
465 | 'filename' => 'registrations_details_form_answers' |
||
466 | ), |
||
467 | 'registrations_details_registrant_details_help_tab' => array( |
||
468 | 'title' => __('Contact Details', 'event_espresso'), |
||
469 | 'filename' => 'registrations_details_registrant_details' |
||
470 | ) |
||
471 | ), |
||
472 | 'help_tour' => array( 'Registration_Details_Help_Tour' ), |
||
473 | 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ), |
||
474 | 'require_nonce' => FALSE |
||
475 | ), |
||
476 | |||
477 | 'new_registration' => array( |
||
478 | 'nav' => array( |
||
479 | 'label' => __('Add New Registration', 'event_espresso'), |
||
480 | 'url' => '#', |
||
481 | 'order' => 15, |
||
482 | 'persistent' => FALSE |
||
483 | ), |
||
484 | 'metaboxes' => $this->_default_espresso_metaboxes, |
||
485 | 'labels' => array( |
||
486 | 'publishbox' => __('Save Registration', 'event_espresso') |
||
487 | ), |
||
488 | 'require_nonce' => FALSE |
||
489 | ), |
||
490 | |||
491 | 'add_new_attendee' => array( |
||
492 | 'nav' => array( |
||
493 | 'label' => __('Add Contact', 'event_espresso'), |
||
494 | 'order' => 15, |
||
495 | 'persistent' => FALSE |
||
496 | ), |
||
497 | 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ), |
||
498 | 'require_nonce' => FALSE |
||
499 | ), |
||
500 | |||
501 | 'edit_attendee' => array( |
||
502 | 'nav' => array( |
||
503 | 'label' => __('Edit Contact', 'event_espresso'), |
||
504 | 'order' => 15, |
||
505 | 'persistent' => FALSE, |
||
506 | 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
||
507 | ), |
||
508 | 'metaboxes' => array('attendee_editor_metaboxes'), |
||
509 | 'require_nonce' => FALSE |
||
510 | ), |
||
511 | |||
512 | 'contact_list' => array( |
||
513 | 'nav' => array( |
||
514 | 'label' => __('Contact List', 'event_espresso'), |
||
515 | 'order' => 20 |
||
516 | ), |
||
517 | 'list_table' => 'EE_Attendee_Contact_List_Table', |
||
518 | 'help_tabs' => array( |
||
519 | 'registrations_contact_list_help_tab' => array( |
||
520 | 'title' => __('Registrations Contact List', 'event_espresso'), |
||
521 | 'filename' => 'registrations_contact_list' |
||
522 | ), |
||
523 | 'registrations_contact-list_table_column_headings_help_tab' => array( |
||
524 | 'title' => __('Contact List Table Column Headings', 'event_espresso'), |
||
525 | 'filename' => 'registrations_contact_list_table_column_headings' |
||
526 | ), |
||
527 | 'registrations_contact_list_views_help_tab' => array( |
||
528 | 'title' => __('Contact List Views', 'event_espresso'), |
||
529 | 'filename' => 'registrations_contact_list_views' |
||
530 | ), |
||
531 | 'registrations_contact_list_other_help_tab' => array( |
||
532 | 'title' => __('Contact List Other', 'event_espresso'), |
||
533 | 'filename' => 'registrations_contact_list_other' |
||
534 | ) |
||
535 | ), |
||
536 | 'help_tour' => array( 'Contact_List_Help_Tour' ), |
||
537 | 'metaboxes' => array(), |
||
538 | 'require_nonce' => FALSE |
||
539 | ), |
||
540 | |||
541 | //override default cpt routes |
||
542 | 'create_new' => '', |
||
543 | 'edit' => '' |
||
544 | |||
545 | ); |
||
546 | } |
||
547 | |||
548 | |||
549 | /** |
||
550 | * The below methods aren't used by this class currently |
||
551 | */ |
||
552 | protected function _add_screen_options() {} |
||
554 | public function admin_init() { |
||
555 | EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' ); |
||
556 | } |
||
557 | public function admin_notices() {} |
||
559 | |||
560 | |||
561 | |||
562 | |||
563 | |||
564 | |||
565 | |||
566 | |||
567 | /** |
||
568 | * get list of registration statuses |
||
569 | * @access private |
||
570 | * @return void |
||
571 | */ |
||
572 | private function _get_registration_status_array() { |
||
575 | |||
576 | |||
577 | |||
578 | |||
579 | protected function _add_screen_options_default() { |
||
582 | |||
583 | View Code Duplication | protected function _add_screen_options_contact_list() { |
|
589 | |||
590 | |||
591 | |||
592 | |||
593 | View Code Duplication | public function load_scripts_styles() { |
|
603 | |||
604 | |||
605 | |||
606 | public function load_scripts_styles_edit_attendee() { |
||
614 | |||
615 | |||
616 | public function load_scripts_styles_view_registration() { |
||
623 | |||
624 | |||
625 | |||
626 | |||
627 | |||
628 | |||
629 | public function load_scripts_styles_contact_list() { |
||
634 | |||
635 | |||
636 | |||
637 | |||
638 | |||
639 | public function load_scripts_styles_new_registration() { |
||
647 | |||
648 | |||
649 | |||
650 | |||
651 | |||
652 | public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() { |
||
655 | |||
656 | |||
657 | |||
658 | public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() { |
||
661 | |||
662 | |||
663 | |||
664 | protected function _set_list_table_views_default() { |
||
749 | |||
750 | |||
751 | |||
752 | |||
753 | protected function _set_list_table_views_contact_list() { |
||
776 | |||
777 | |||
778 | |||
779 | |||
780 | |||
781 | protected function _registration_legend_items() { |
||
851 | |||
852 | |||
853 | |||
854 | /*************************************** REGISTRATION OVERVIEW ***************************************/ |
||
855 | |||
856 | |||
857 | |||
858 | |||
859 | |||
860 | |||
861 | protected function _registrations_overview_list_table() { |
||
873 | |||
874 | |||
875 | |||
876 | |||
877 | /** |
||
878 | * This sets the _registration property for the registration details screen |
||
879 | * |
||
880 | * @access private |
||
881 | * @return bool |
||
882 | */ |
||
883 | private function _set_registration_object() { |
||
902 | |||
903 | |||
904 | |||
905 | /** |
||
906 | * get registrations for given parameters (used by list table) |
||
907 | * |
||
908 | * @param int $per_page how many registrations displayed per page |
||
909 | * @param boolean $count return the count or objects |
||
910 | * @param boolean $this_month whether to return for just this month |
||
911 | * @param boolean $today whether to return results for just today |
||
912 | * @throws \EE_Error |
||
913 | * @return mixed (int|array) int = count || array of registration objects |
||
914 | */ |
||
915 | public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) { |
||
916 | $EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE; |
||
917 | $CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE; |
||
918 | $reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE; |
||
919 | $month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april |
||
920 | $today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
||
921 | $this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
||
922 | $start_date = FALSE; |
||
923 | $end_date = FALSE; |
||
924 | $_where = array(); |
||
925 | $trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
||
926 | $incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
||
927 | |||
928 | //set orderby |
||
929 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
||
930 | |||
931 | |||
932 | switch ( $this->_req_data['orderby'] ) { |
||
933 | case '_REG_ID': |
||
934 | $orderby = 'REG_ID'; |
||
935 | break; |
||
936 | case '_Reg_status': |
||
937 | $orderby = 'STS_ID'; |
||
938 | break; |
||
939 | case 'ATT_fname': |
||
940 | $orderby = 'Attendee.ATT_lname'; |
||
941 | break; |
||
942 | case 'event_name': |
||
943 | $orderby = 'Event.EVT_name'; |
||
944 | break; |
||
945 | case 'DTT_EVT_start': |
||
946 | $orderby = 'Event.Datetime.DTT_EVT_start'; |
||
947 | break; |
||
948 | default: //'REG_date' |
||
949 | $orderby = 'REG_date'; |
||
950 | } |
||
951 | |||
952 | $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
||
953 | $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
||
954 | $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
||
955 | |||
956 | |||
957 | $offset = ($current_page-1)*$per_page; |
||
958 | $limit = $count ? NULL : array( $offset, $per_page ); |
||
959 | |||
960 | if($EVT_ID){ |
||
961 | $_where['EVT_ID']=$EVT_ID; |
||
962 | } |
||
963 | if($CAT_ID){ |
||
964 | $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
||
965 | } |
||
966 | if ( $incomplete ) { |
||
967 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
||
968 | } else if ( ! $trash) { |
||
969 | $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
||
970 | } |
||
971 | if($reg_status){ |
||
972 | $_where['STS_ID'] = $reg_status; |
||
973 | } |
||
974 | |||
975 | |||
976 | |||
977 | $this_year_r = date('Y', current_time('timestamp')); |
||
978 | |||
979 | |||
980 | $time_start = ' 00:00:00'; |
||
981 | $time_end = ' 23:59:59'; |
||
982 | |||
983 | if($today_a || $today ){ |
||
984 | $curdate = date('Y-m-d', current_time('timestamp')); |
||
985 | $_where['REG_date']= array('BETWEEN', |
||
986 | array( |
||
987 | EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ), |
||
988 | EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ), |
||
989 | )); |
||
990 | }elseif($this_month_a || $this_month){ |
||
991 | $this_month_r = date('m', current_time('timestamp')); |
||
992 | $days_this_month = date( 't', current_time('timestamp') ); |
||
993 | $_where['REG_date']= array('BETWEEN', |
||
994 | array( |
||
995 | EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ), |
||
996 | EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ) |
||
997 | )); |
||
998 | }elseif($month_range){ |
||
999 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
||
1000 | $month_r = !empty($pieces[0]) ? date('m', strtotime( $month_range ) ) : ''; |
||
1001 | $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
||
1002 | $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01') ); |
||
1003 | $_where['REG_date']= array('BETWEEN', |
||
1004 | array( EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s' ) ) ); |
||
1005 | }elseif($start_date && $end_date){ |
||
1006 | throw new EE_Error("not yet supported"); |
||
1007 | }elseif($start_date){ |
||
1008 | throw new EE_Error("not yet supported"); |
||
1009 | }elseif($end_date){ |
||
1010 | throw new EE_Error("not yet supported"); |
||
1011 | } |
||
1012 | |||
1013 | if ( ! empty( $this->_req_data['s'] ) ) { |
||
1014 | $sstr = '%' . $this->_req_data['s'] . '%'; |
||
1015 | $_where['OR'] = array( |
||
1016 | 'Event.EVT_name' => array( 'LIKE', $sstr), |
||
1017 | 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
||
1018 | 'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
||
1019 | 'Attendee.ATT_full_name' => array( 'LIKE', $sstr ), |
||
1020 | 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
||
1021 | 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
||
1022 | 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
||
1023 | 'Attendee.ATT_email' => array('LIKE', $sstr ), |
||
1024 | 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
||
1025 | 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
||
1026 | 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
||
1027 | 'REG_final_price' => array( 'LIKE', $sstr ), |
||
1028 | 'REG_code' => array( 'LIKE', $sstr ), |
||
1029 | 'REG_count' => array( 'LIKE' , $sstr ), |
||
1030 | 'REG_group_size' => array( 'LIKE' , $sstr ), |
||
1031 | 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
||
1032 | 'Ticket.TKT_description' => array( 'LIKE', $sstr ), |
||
1033 | 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr ) |
||
1034 | ); |
||
1035 | } |
||
1036 | |||
1037 | //capability checks |
||
1038 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) { |
||
1039 | $_where['AND'] = array( |
||
1040 | 'Event.EVT_wp_user' => get_current_user_id() |
||
1041 | ); |
||
1042 | } |
||
1043 | |||
1044 | |||
1045 | if( $count ){ |
||
1046 | if ( $trash ) { |
||
1047 | return EEM_Registration::instance()->count_deleted( array( $_where )); |
||
1048 | } else if ( $incomplete ) { |
||
1049 | return EEM_Registration::instance()->count( array( $_where )); |
||
1050 | } else { |
||
1051 | return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' )); |
||
1052 | } |
||
1053 | } else { |
||
1054 | //make sure we remove default where conditions cause all registrations matching query are returned |
||
1055 | $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' ); |
||
1056 | if ( $per_page !== -1 ) { |
||
1057 | $query_params['limit'] = $limit; |
||
1058 | } |
||
1059 | $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
||
1060 | |||
1061 | |||
1062 | if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
||
1063 | $first_registration = $registrations[0]; |
||
1064 | //EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
||
1065 | $event_name = $first_registration->event_obj()->name(); |
||
1066 | $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
||
1067 | // edit event link |
||
1068 | View Code Duplication | if ( $event_name != '' ) { |
|
1069 | $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
||
1070 | $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
||
1071 | $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
||
1072 | } |
||
1073 | |||
1074 | $back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
||
1075 | $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
||
1076 | |||
1077 | $this->_template_args['before_admin_page_content'] = ' |
||
1078 | <div id="admin-page-header"> |
||
1079 | <h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
||
1080 | <h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
||
1081 | <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
||
1082 | </div> |
||
1083 | '; |
||
1084 | |||
1085 | } |
||
1086 | return $registrations; |
||
1087 | } |
||
1088 | } |
||
1089 | |||
1090 | |||
1091 | |||
1092 | |||
1093 | |||
1094 | |||
1095 | public function get_registration_status_array() { |
||
1098 | |||
1099 | |||
1100 | |||
1101 | |||
1102 | /*************************************** REGISTRATION DETAILS ***************************************/ |
||
1103 | |||
1104 | |||
1105 | |||
1106 | |||
1107 | |||
1108 | /** |
||
1109 | * generates HTML for the View Registration Details Admin page |
||
1110 | * @access protected |
||
1111 | * @return void |
||
1112 | */ |
||
1113 | protected function _registration_details() { |
||
1162 | |||
1163 | |||
1164 | |||
1165 | |||
1166 | |||
1167 | |||
1168 | protected function _registration_details_metaboxes() { |
||
1182 | |||
1183 | |||
1184 | |||
1185 | |||
1186 | |||
1187 | |||
1188 | /** |
||
1189 | * _set_approve_or_decline_reg_status_buttons |
||
1190 | * @access protected |
||
1191 | * @return string |
||
1192 | */ |
||
1193 | public function set_reg_status_buttons_metabox() { |
||
1219 | |||
1220 | |||
1221 | |||
1222 | |||
1223 | /** |
||
1224 | * Returns an array of all the buttons for the various statuses and switch status actions |
||
1225 | * @return array |
||
1226 | */ |
||
1227 | private function _get_reg_status_buttons() { |
||
1238 | |||
1239 | |||
1240 | /** |
||
1241 | * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
||
1242 | * |
||
1243 | * @param bool $status REG status given for changing registrations to. |
||
1244 | * @param bool $notify Whether to send messages notifications or not. |
||
1245 | * |
||
1246 | * @return array (array with reg_id(s) updated and whether update was successful. |
||
1247 | */ |
||
1248 | protected function _set_registration_status_from_request( $status = false, $notify = false ) { |
||
1260 | |||
1261 | |||
1262 | |||
1263 | /** |
||
1264 | * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an array). |
||
1265 | * |
||
1266 | * Note, this method does NOT take care of possible notifications. That is required by calling code. |
||
1267 | * |
||
1268 | * @param bool $REG_ID |
||
1269 | * @param bool $status |
||
1270 | * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations). |
||
1271 | */ |
||
1272 | protected function _set_registration_status( $REG_ID, $status = false ) { |
||
1298 | |||
1299 | |||
1300 | |||
1301 | |||
1302 | /** |
||
1303 | * Common logic for setting up success message and redirecting to appropriate route |
||
1304 | * @param string $STS_ID status id for the registration changed to |
||
1305 | * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
||
1306 | * @return void |
||
1307 | */ |
||
1308 | protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
||
1340 | |||
1341 | |||
1342 | |||
1343 | /** |
||
1344 | * incoming reg status change from reg details page. |
||
1345 | * @return void |
||
1346 | */ |
||
1347 | protected function _change_reg_status() { |
||
1376 | |||
1377 | |||
1378 | |||
1379 | /** |
||
1380 | * approve_registration |
||
1381 | * @access protected |
||
1382 | * @param bool $notify whether or not to notify the registrant about their approval. |
||
1383 | * @return void |
||
1384 | */ |
||
1385 | protected function approve_registration( $notify = false ) { |
||
1388 | |||
1389 | |||
1390 | |||
1391 | |||
1392 | /** |
||
1393 | * decline_registration |
||
1394 | * @access protected |
||
1395 | * @param bool $notify whether or not to notify the registrant about their approval. |
||
1396 | * @return void |
||
1397 | */ |
||
1398 | protected function decline_registration( $notify = false ) { |
||
1401 | |||
1402 | |||
1403 | |||
1404 | |||
1405 | /** |
||
1406 | * cancel_registration |
||
1407 | * @access protected |
||
1408 | * @param bool $notify whether or not to notify the registrant about their approval. |
||
1409 | * @return void |
||
1410 | */ |
||
1411 | protected function cancel_registration( $notify = false ) { |
||
1414 | |||
1415 | |||
1416 | |||
1417 | |||
1418 | |||
1419 | /** |
||
1420 | * not_approve_registration |
||
1421 | * @access protected |
||
1422 | * @param bool $notify whether or not to notify the registrant about their approval. |
||
1423 | * @return void |
||
1424 | */ |
||
1425 | protected function not_approve_registration( $notify = false ) { |
||
1428 | |||
1429 | |||
1430 | |||
1431 | /** |
||
1432 | * decline_registration |
||
1433 | * @access protected |
||
1434 | * @param bool $notify whether or not to notify the registrant about their approval. |
||
1435 | * @return void |
||
1436 | */ |
||
1437 | protected function pending_registration( $notify = false ) { |
||
1440 | |||
1441 | |||
1442 | |||
1443 | |||
1444 | /** |
||
1445 | * generates HTML for the Registration main meta box |
||
1446 | * @access public |
||
1447 | * @return void |
||
1448 | */ |
||
1449 | public function _reg_details_meta_box() { |
||
1523 | |||
1524 | /** |
||
1525 | * generates HTML for the Registration Questions meta box. |
||
1526 | * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
||
1527 | * otherwise uses new forms system |
||
1528 | * |
||
1529 | * @access public |
||
1530 | * @return void |
||
1531 | */ |
||
1532 | public function _reg_questions_meta_box() { |
||
1544 | |||
1545 | |||
1546 | |||
1547 | /** |
||
1548 | * form_before_question_group |
||
1549 | * |
||
1550 | * @deprecated as of 4.8.32.rc.000 |
||
1551 | * @access public |
||
1552 | * @param string $output |
||
1553 | * @return string |
||
1554 | */ |
||
1555 | View Code Duplication | public function form_before_question_group( $output ) { |
|
1568 | |||
1569 | |||
1570 | |||
1571 | /** |
||
1572 | * form_after_question_group |
||
1573 | * |
||
1574 | * @deprecated as of 4.8.32.rc.000 |
||
1575 | * @access public |
||
1576 | * @param string $output |
||
1577 | * @return string |
||
1578 | */ |
||
1579 | public function form_after_question_group( $output ) { |
||
1601 | |||
1602 | |||
1603 | |||
1604 | /** |
||
1605 | * form_form_field_label_wrap |
||
1606 | * |
||
1607 | * @deprecated as of 4.8.32.rc.000 |
||
1608 | * @access public |
||
1609 | * @param string $label |
||
1610 | * @return string |
||
1611 | */ |
||
1612 | View Code Duplication | public function form_form_field_label_wrap( $label ) { |
|
1626 | |||
1627 | |||
1628 | |||
1629 | /** |
||
1630 | * form_form_field_input__wrap |
||
1631 | * |
||
1632 | * @deprecated as of 4.8.32.rc.000 |
||
1633 | * @access public |
||
1634 | * @param string $input |
||
1635 | * @return string |
||
1636 | */ |
||
1637 | View Code Duplication | public function form_form_field_input__wrap( $input ) { |
|
1651 | |||
1652 | /** |
||
1653 | * Updates the registration's custom questions according to the form info, if the form is submitted. |
||
1654 | * If it's not a post, the "view_registrations" route will be called next on the SAME request |
||
1655 | * to display the page |
||
1656 | * |
||
1657 | * @access protected |
||
1658 | * @return void |
||
1659 | */ |
||
1660 | protected function _update_attendee_registration_form() { |
||
1672 | |||
1673 | /** |
||
1674 | * Gets the form for saving registrations custom questions (if done |
||
1675 | * previously retrieves the cached form object, which may have validation errors in it) |
||
1676 | * @param int $REG_ID |
||
1677 | * @return EE_Registration_Custom_Questions_Form |
||
1678 | */ |
||
1679 | protected function _get_reg_custom_questions_form( $REG_ID ) { |
||
1687 | |||
1688 | |||
1689 | |||
1690 | /** |
||
1691 | * Saves |
||
1692 | * @access private |
||
1693 | * @param bool $REG_ID |
||
1694 | * @return bool |
||
1695 | */ |
||
1696 | private function _save_reg_custom_questions_form( $REG_ID = FALSE ) { |
||
1730 | |||
1731 | /** |
||
1732 | * generates HTML for the Registration main meta box |
||
1733 | * @access public |
||
1734 | * @return void |
||
1735 | */ |
||
1736 | public function _reg_attendees_meta_box() { |
||
1737 | |||
1738 | $REG = EEM_Registration::instance(); |
||
1739 | //get all other registrations on this transaction, and cache |
||
1740 | //the attendees for them so we don't have to run another query using force_join |
||
1741 | $registrations = $REG->get_all(array( |
||
1742 | array( |
||
1743 | 'TXN_ID'=>$this->_registration->transaction_ID(), |
||
1744 | 'REG_ID'=>array('!=',$this->_registration->ID()) |
||
1745 | ), |
||
1746 | 'force_join'=>array('Attendee'))); |
||
1747 | |||
1748 | $this->_template_args['attendees'] = array(); |
||
1749 | $this->_template_args['attendee_notice'] = ''; |
||
1750 | if ( empty( $registrations) || ( is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations) ) ) { |
||
1751 | EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
||
1752 | $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
||
1753 | } else { |
||
1754 | |||
1755 | $att_nmbr = 1; |
||
1756 | foreach ( $registrations as $registration ) { |
||
1757 | /* @var $registration EE_Registration */ |
||
1758 | $attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object(); |
||
1759 | $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
||
1760 | $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
||
1761 | $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
||
1762 | $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
||
1763 | |||
1764 | $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() ); |
||
1765 | |||
1766 | $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
||
1767 | |||
1768 | $att_nmbr++; |
||
1769 | } |
||
1770 | |||
1771 | //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
||
1772 | |||
1773 | $this->_template_args['event_name'] = $this->_registration->event_obj()->name(); |
||
1774 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
||
1775 | |||
1776 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
||
1777 | } |
||
1778 | $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
||
1779 | echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
||
1780 | |||
1781 | } |
||
1782 | |||
1783 | |||
1784 | |||
1785 | |||
1786 | |||
1787 | |||
1788 | /** |
||
1789 | * generates HTML for the Edit Registration side meta box |
||
1790 | * @access public |
||
1791 | * @return void |
||
1792 | */ |
||
1793 | public function _reg_registrant_side_meta_box() { |
||
1794 | |||
1795 | /*@var $attendee EE_Attendee */ |
||
1796 | $att_check = $this->_registration->attendee(); |
||
1797 | $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
||
1798 | |||
1799 | //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show cereate button or not) |
||
1800 | if ( ! $this->_registration->is_primary_registrant() ) { |
||
1801 | $primary_registration = $this->_registration->get_primary_registration(); |
||
1802 | $primary_attendee = $primary_registration->attendee(); |
||
1803 | |||
1804 | if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) { |
||
1805 | //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
||
1806 | $primary_registration = NULL; |
||
1807 | } |
||
1808 | } else { |
||
1809 | $primary_registration = NULL; |
||
1810 | } |
||
1811 | |||
1812 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
||
1813 | $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
||
1814 | $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
||
1815 | $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
||
1816 | $this->_template_args['phone'] = $attendee->phone(); |
||
1817 | |||
1818 | $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee ); |
||
1819 | |||
1820 | |||
1821 | //edit link |
||
1822 | $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
||
1823 | $this->_template_args['att_edit_label'] = __('View/Edit Contact' ); |
||
1824 | |||
1825 | //create link |
||
1826 | $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): ''; |
||
1827 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
||
1828 | |||
1829 | $this->_template_args['att_check'] = $att_check; |
||
1830 | |||
1831 | |||
1832 | $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
||
1833 | echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
||
1834 | } |
||
1835 | |||
1836 | |||
1837 | |||
1838 | |||
1839 | |||
1840 | /** |
||
1841 | * trash or restore registrations |
||
1842 | * @param boolean $trash whether to archive or restore |
||
1843 | * @access protected |
||
1844 | * @return void |
||
1845 | */ |
||
1846 | protected function _trash_or_restore_registrations( $trash = TRUE ) { |
||
1914 | |||
1915 | |||
1916 | |||
1917 | |||
1918 | |||
1919 | /** |
||
1920 | * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the registration but also. |
||
1921 | * |
||
1922 | * 1. Removing relations to EE_Attendee |
||
1923 | * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are ALSO trashed. |
||
1924 | * 3. Deleting permanently any related Line items but only if the above conditions are met. |
||
1925 | * 4. Removing relationships between all tickets and the related registrations |
||
1926 | * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
||
1927 | * 6. Deleting permanently any related Checkins. |
||
1928 | * @return void |
||
1929 | */ |
||
1930 | protected function _delete_registrations() { |
||
1965 | |||
1966 | |||
1967 | |||
1968 | |||
1969 | |||
1970 | /** |
||
1971 | * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what models get affected. |
||
1972 | * @param EE_Registration $REG registration to be deleted permenantly |
||
1973 | * @return boolean true = successful deletion, false = fail. |
||
1974 | */ |
||
1975 | protected function _delete_registration( EE_Registration $REG ) { |
||
2031 | |||
2032 | |||
2033 | |||
2034 | /** |
||
2035 | * generates HTML for the Register New Attendee Admin page |
||
2036 | * |
||
2037 | * @access private |
||
2038 | * @throws \EE_Error |
||
2039 | * @return void |
||
2040 | */ |
||
2041 | public function new_registration() { |
||
2076 | |||
2077 | |||
2078 | |||
2079 | |||
2080 | /** |
||
2081 | * This returns the content for a registration step |
||
2082 | * |
||
2083 | * @access protected |
||
2084 | * @return string html |
||
2085 | */ |
||
2086 | protected function _get_registration_step_content() { |
||
2162 | |||
2163 | |||
2164 | |||
2165 | |||
2166 | |||
2167 | |||
2168 | /** |
||
2169 | * set_reg_event |
||
2170 | * @access private |
||
2171 | * @return boolean |
||
2172 | */ |
||
2173 | private function _set_reg_event() { |
||
2185 | |||
2186 | |||
2187 | |||
2188 | |||
2189 | |||
2190 | /** |
||
2191 | * process_reg_step |
||
2192 | * |
||
2193 | * @access public |
||
2194 | * @return string |
||
2195 | */ |
||
2196 | public function process_reg_step() { |
||
2280 | |||
2281 | |||
2282 | |||
2283 | /** |
||
2284 | * redirect_to_txn |
||
2285 | * |
||
2286 | * @access public |
||
2287 | * @return void |
||
2288 | */ |
||
2289 | public function redirect_to_txn() { |
||
2307 | |||
2308 | |||
2309 | |||
2310 | /** |
||
2311 | * generates HTML for the Attendee Contact List |
||
2312 | * @access protected |
||
2313 | * @return void |
||
2314 | */ |
||
2315 | protected function _attendee_contact_list_table() { |
||
2320 | |||
2321 | |||
2322 | |||
2323 | |||
2324 | |||
2325 | /** |
||
2326 | * get_attendees |
||
2327 | * @param bool $count whether to return count or data. |
||
2328 | * @access public |
||
2329 | * @return array |
||
2330 | */ |
||
2331 | public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
||
2407 | |||
2408 | |||
2409 | |||
2410 | |||
2411 | /** |
||
2412 | * This is just taking care of resending the registration confirmation |
||
2413 | * |
||
2414 | * @access protected |
||
2415 | * @return void |
||
2416 | */ |
||
2417 | protected function _resend_registration() { |
||
2424 | |||
2425 | |||
2426 | |||
2427 | |||
2428 | |||
2429 | |||
2430 | public function _registrations_report(){ |
||
2431 | if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
||
2432 | wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
||
2433 | array( |
||
2434 | 'page' => 'espresso_batch', |
||
2435 | 'batch' => 'file', |
||
2436 | 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
||
2437 | 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ), |
||
2438 | 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
||
2439 | )) ); |
||
2440 | } else { |
||
2441 | $new_request_args = array( |
||
2442 | 'export' => 'report', |
||
2443 | 'action' => 'registrations_report_for_event', |
||
2444 | 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
||
2445 | ); |
||
2446 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
||
2447 | |||
2448 | if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
||
2449 | require_once(EE_CLASSES . 'EE_Export.class.php'); |
||
2450 | $EE_Export = EE_Export::instance($this->_req_data); |
||
2451 | $EE_Export->export(); |
||
2452 | } |
||
2453 | } |
||
2454 | } |
||
2455 | |||
2456 | |||
2457 | |||
2458 | public function _contact_list_export(){ |
||
2459 | if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
||
2460 | require_once(EE_CLASSES . 'EE_Export.class.php'); |
||
2461 | $EE_Export = EE_Export::instance($this->_req_data); |
||
2462 | $EE_Export->export_attendees(); |
||
2463 | } |
||
2464 | } |
||
2465 | |||
2466 | public function _contact_list_report(){ |
||
2467 | if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
||
2468 | wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
||
2469 | array( |
||
2470 | 'page' => 'espresso_batch', |
||
2471 | 'batch' => 'file', |
||
2472 | 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ), |
||
2473 | 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
||
2474 | )) ); |
||
2475 | } else { |
||
2476 | if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
||
2477 | require_once(EE_CLASSES . 'EE_Export.class.php'); |
||
2478 | $EE_Export = EE_Export::instance($this->_req_data); |
||
2479 | $EE_Export->report_attendees(); |
||
2480 | } |
||
2481 | } |
||
2482 | } |
||
2483 | |||
2484 | |||
2485 | |||
2486 | |||
2487 | |||
2488 | |||
2489 | /*************************************** ATTENDEE DETAILS ***************************************/ |
||
2490 | |||
2491 | |||
2492 | /** |
||
2493 | * This duplicates the attendee object for the given incoming registration id and attendee_id. |
||
2494 | * @return void |
||
2495 | */ |
||
2496 | protected function _duplicate_attendee() { |
||
2526 | |||
2527 | |||
2528 | //related to cpt routes |
||
2529 | protected function _insert_update_cpt_item($post_id, $post) { |
||
2566 | |||
2567 | |||
2568 | |||
2569 | |||
2570 | public function trash_cpt_item($post_id) {} |
||
2574 | |||
2575 | |||
2576 | public function attendee_editor_metaboxes() { |
||
2595 | |||
2596 | |||
2597 | /** |
||
2598 | * Metabox for attendee contact info |
||
2599 | * @param WP_Post $post wp post object |
||
2600 | * @return string attendee contact info ( and form ) |
||
2601 | */ |
||
2602 | public function attendee_contact_info( $post ) { |
||
2608 | |||
2609 | |||
2610 | |||
2611 | /** |
||
2612 | * Metabox for attendee details |
||
2613 | * @param WP_Post $post wp post object |
||
2614 | * @return string attendee address details (and form) |
||
2615 | */ |
||
2616 | public function attendee_address_details($post) { |
||
2659 | |||
2660 | |||
2661 | /** |
||
2662 | * _attendee_details |
||
2663 | * @access protected |
||
2664 | * @return void |
||
2665 | */ |
||
2666 | public function attendee_registrations_meta_box( $post ) { |
||
2674 | |||
2675 | |||
2676 | |||
2677 | |||
2678 | /** |
||
2679 | * add in the form fields for the attendee edit |
||
2680 | * @param WP_Post $post wp post object |
||
2681 | * @return string html for new form. |
||
2682 | */ |
||
2683 | public function after_title_form_fields($post) { |
||
2690 | |||
2691 | |||
2692 | |||
2693 | |||
2694 | |||
2695 | |||
2696 | /** |
||
2697 | * _trash_or_restore_attendee |
||
2698 | * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
||
2699 | * @access protected |
||
2700 | * @return void |
||
2701 | */ |
||
2702 | protected function _trash_or_restore_attendees( $trash = TRUE ) { |
||
2739 | |||
2740 | } |
||
2741 | |||
2742 | |||
2743 | |||
2744 | // end of file: includes/core/admin/transactions/Registrations_Admin_Page.core.php |
||
2745 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.