Completed
Branch FET-8385-datetime-ticket-selec... (f41f36)
by
unknown
184:03 queued 173:38
created
admin_pages/venues/Venues_Admin_Page.core.php 1 patch
Spacing   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 
63 63
 
64 64
 	protected function _init_page_props() {
65
-		require_once( EE_MODELS . 'EEM_Venue.model.php' );
65
+		require_once(EE_MODELS.'EEM_Venue.model.php');
66 66
 		$this->page_slug = EE_VENUES_PG_SLUG;
67 67
 		$this->_admin_base_url = EE_VENUES_ADMIN_URL;
68
-		$this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
68
+		$this->_admin_base_path = EE_ADMIN_PAGES.'venues';
69 69
 		$this->page_label = __('Event Venues', 'event_espresso');
70 70
 		$this->_cpt_model_names = array(
71 71
 			'create_new' => 'EEM_Venue',
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 				'edit' => __('Update Venue', 'event_espresso'),
109 109
 				'add_category' => __('Save New Category', 'event_espresso'),
110 110
 				'edit_category' => __('Update Category', 'event_espresso'),
111
-				'google_map_settings' => __( 'Update Settings', 'event_espresso' )
111
+				'google_map_settings' => __('Update Settings', 'event_espresso')
112 112
 				)
113 113
 		);
114 114
 	}
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 		//load field generator helper
124 124
 
125 125
 		//is there a vnu_id in the request?
126
-		$vnu_id = ! empty( $this->_req_data['VNU_ID'] ) && ! is_array( $this->_req_data['VNU_ID'] ) ? $this->_req_data['VNU_ID'] : 0;
127
-		$vnu_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $vnu_id;
126
+		$vnu_id = ! empty($this->_req_data['VNU_ID']) && ! is_array($this->_req_data['VNU_ID']) ? $this->_req_data['VNU_ID'] : 0;
127
+		$vnu_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $vnu_id;
128 128
 
129 129
 		$this->_page_routes = array(
130 130
 			'default' => array(
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 				),
143 143
 			'trash_venue' => array(
144 144
 				'func' => '_trash_or_restore_venue',
145
-				'args' => array( 'venue_status' => 'trash' ),
145
+				'args' => array('venue_status' => 'trash'),
146 146
 				'noheader' => TRUE,
147 147
 				'capability' => 'ee_delete_venue',
148 148
 				'obj_id' => $vnu_id
149 149
 				),
150 150
 			'trash_venues' => array(
151 151
 				'func' => '_trash_or_restore_venues',
152
-				'args' => array( 'venue_status' => 'trash' ),
152
+				'args' => array('venue_status' => 'trash'),
153 153
 				'noheader' => TRUE,
154 154
 				'capability' => 'ee_delete_venues'
155 155
 				),
156 156
 			'restore_venue' => array(
157 157
 				'func' => '_trash_or_restore_venue',
158
-				'args' => array( 'venue_status' => 'draft' ),
158
+				'args' => array('venue_status' => 'draft'),
159 159
 				'noheader' => TRUE,
160 160
 				'capability' => 'ee_delete_venue',
161 161
 				'obj_id' => $vnu_id
162 162
 				),
163 163
 			'restore_venues' => array(
164 164
 				'func' => '_trash_or_restore_venues',
165
-				'args' => array( 'venue_status' => 'draft' ),
165
+				'args' => array('venue_status' => 'draft'),
166 166
 				'noheader' => TRUE,
167 167
 				'capability' => 'ee_delete_venues'
168 168
 				),
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 						'filename' => 'venues_overview_views_bulk_actions_search'
265 265
 					)
266 266
 				),
267
-				'help_tour' => array( 'Venues_Overview_Help_Tour' ),
267
+				'help_tour' => array('Venues_Overview_Help_Tour'),
268 268
 				'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'),
269 269
 				'require_nonce' => FALSE
270 270
 			),
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 						'filename' => 'venues_editor_other'
301 301
 					)
302 302
 				),
303
-				'help_tour' => array( 'Venues_Add_Venue_Help_Tour' ),
303
+				'help_tour' => array('Venues_Add_Venue_Help_Tour'),
304 304
 				'metaboxes' => array('_venue_editor_metaboxes'),
305 305
 				'require_nonce' => FALSE
306 306
 				),
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 					'label' => __('Edit Venue', 'event_espresso'),
310 310
 					'order' => 5,
311 311
 					'persistent' => FALSE,
312
-					'url' => isset($this->_req_data['post']) ? add_query_arg(array('post' => $this->_req_data['post'] ), $this->_current_page_view_url )  : $this->_admin_base_url
312
+					'url' => isset($this->_req_data['post']) ? add_query_arg(array('post' => $this->_req_data['post']), $this->_current_page_view_url) : $this->_admin_base_url
313 313
 				),
314 314
 				'help_tabs' => array(
315 315
 					'venues_editor_help_tab' => array(
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 			),
344 344
 			'google_map_settings' => array(
345 345
 				'nav' => array(
346
-					'label' => esc_html__('Google Maps', 'event_espresso' ),
346
+					'label' => esc_html__('Google Maps', 'event_espresso'),
347 347
 					'order' => 40
348 348
 				),
349
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
349
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
350 350
 				'help_tabs' => array(
351 351
 					'general_settings_google_maps_help_tab' => array(
352 352
 						'title' => __('Google Maps', 'event_espresso'),
353 353
 						'filename' => 'general_settings_google_maps'
354 354
 					)
355 355
 				),
356
-				'help_tour' => array( 'Google_Maps_Help_Tour' ),
356
+				'help_tour' => array('Google_Maps_Help_Tour'),
357 357
 				'require_nonce' => FALSE
358 358
 			),
359 359
 			//venue category stuff
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 						'filename' => 'venues_add_category'
370 370
 					)
371 371
 				),
372
-				'help_tour' => array( 'Venues_Add_Category_Help_Tour' ),
372
+				'help_tour' => array('Venues_Add_Category_Help_Tour'),
373 373
 				'require_nonce' => FALSE
374 374
 				),
375 375
 			'edit_category' => array(
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 					'label' => __('Edit Category', 'event_espresso'),
378 378
 					'order' => 15,
379 379
 					'persistent' => FALSE,
380
-					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
380
+					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
381 381
 					),
382 382
 				'metaboxes' => array('_publish_post_box'),
383 383
 				'help_tabs' => array(
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 						'filename' => 'venues_categories_other'
414 414
 					)
415 415
 				),
416
-				'help_tour' => array( 'Venues_Categories_Help_Tour' ),
416
+				'help_tour' => array('Venues_Categories_Help_Tour'),
417 417
 				'metaboxes' => $this->_default_espresso_metaboxes,
418 418
 				'require_nonce' => FALSE
419 419
 				)
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 
471 471
 
472 472
 	public function load_scripts_styles() {
473
-		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION );
473
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
474 474
 		wp_enqueue_style('ee-cat-admin');
475 475
 	}
476 476
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	public function load_scripts_styles_edit() {
494 494
 		//styles
495 495
 		wp_enqueue_style('espresso-ui-theme');
496
-		wp_register_style( 'espresso_venues', EE_VENUES_ASSETS_URL . 'ee-venues-admin.css', array(), EVENT_ESPRESSO_VERSION );
496
+		wp_register_style('espresso_venues', EE_VENUES_ASSETS_URL.'ee-venues-admin.css', array(), EVENT_ESPRESSO_VERSION);
497 497
 		wp_enqueue_style('espresso_venues');
498 498
 	}
499 499
 
@@ -512,13 +512,13 @@  discard block
 block discarded – undo
512 512
 				)
513 513
 		);
514 514
 
515
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_venues', 'espresso_venues_trash_venues' ) ) {
515
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
516 516
 			$this->_views['all']['bulk_action'] = array(
517 517
 				'trash_venues' => __('Move to Trash', 'event_espresso')
518 518
 			);
519 519
 			$this->_views['trash'] = array(
520 520
 				'slug' => 'trash',
521
-				'label' => __( 'Trash', 'event_espresso' ),
521
+				'label' => __('Trash', 'event_espresso'),
522 522
 				'count' => 0,
523 523
 				'bulk_action' => array(
524 524
 					'restore_venues' => __('Restore from Trash', 'event_espresso'),
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 
552 552
 
553 553
 	protected function _overview_list_table() {
554
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
555
-		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_venues'), __("View Venue Archive Page", "event_espresso"), 'button' );
556
-		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
554
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
555
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_venues'), __("View Venue Archive Page", "event_espresso"), 'button');
556
+		$this->_admin_page_title .= ' '.$this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
557 557
 		$this->_search_btn_label = __('Venues', 'event_espresso');
558 558
 		$this->display_admin_list_table_page_with_sidebar();
559 559
 	}
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
 			'vnu_url' => $this->_cpt_model_obj->venue_url(),
567 567
 			'vnu_phone' => $this->_cpt_model_obj->phone()
568 568
 			);
569
-		$template = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
570
-		EEH_Template::display_template( $template, $extra_rows );
569
+		$template = EE_VENUES_TEMPLATE_PATH.'venue_publish_box_extras.template.php';
570
+		EEH_Template::display_template($template, $extra_rows);
571 571
 	}
572 572
 
573 573
 
@@ -583,31 +583,31 @@  discard block
 block discarded – undo
583 583
 		$default_map_settings->use_google_maps = TRUE;
584 584
 		$default_map_settings->google_map_api_key = '';
585 585
 		// for event details pages (reg page)
586
-		$default_map_settings->event_details_map_width = 585; 			// ee_map_width_single
587
-		$default_map_settings->event_details_map_height = 362; 			// ee_map_height_single
588
-		$default_map_settings->event_details_map_zoom = 14; 			// ee_map_zoom_single
589
-		$default_map_settings->event_details_display_nav = TRUE; 			// ee_map_nav_display_single
590
-		$default_map_settings->event_details_nav_size = FALSE; 			// ee_map_nav_size_single
591
-		$default_map_settings->event_details_control_type = 'default'; 		// ee_map_type_control_single
592
-		$default_map_settings->event_details_map_align = 'center'; 			// ee_map_align_single
586
+		$default_map_settings->event_details_map_width = 585; // ee_map_width_single
587
+		$default_map_settings->event_details_map_height = 362; // ee_map_height_single
588
+		$default_map_settings->event_details_map_zoom = 14; // ee_map_zoom_single
589
+		$default_map_settings->event_details_display_nav = TRUE; // ee_map_nav_display_single
590
+		$default_map_settings->event_details_nav_size = FALSE; // ee_map_nav_size_single
591
+		$default_map_settings->event_details_control_type = 'default'; // ee_map_type_control_single
592
+		$default_map_settings->event_details_map_align = 'center'; // ee_map_align_single
593 593
 		// for event list pages
594
-		$default_map_settings->event_list_map_width = 300; 			// ee_map_width
595
-		$default_map_settings->event_list_map_height = 185; 		// ee_map_height
596
-		$default_map_settings->event_list_map_zoom = 12; 			// ee_map_zoom
597
-		$default_map_settings->event_list_display_nav = FALSE; 		// ee_map_nav_display
598
-		$default_map_settings->event_list_nav_size = TRUE; 			// ee_map_nav_size
599
-		$default_map_settings->event_list_control_type = 'dropdown'; 		// ee_map_type_control
600
-		$default_map_settings->event_list_map_align = 'center'; 			// ee_map_align
594
+		$default_map_settings->event_list_map_width = 300; // ee_map_width
595
+		$default_map_settings->event_list_map_height = 185; // ee_map_height
596
+		$default_map_settings->event_list_map_zoom = 12; // ee_map_zoom
597
+		$default_map_settings->event_list_display_nav = FALSE; // ee_map_nav_display
598
+		$default_map_settings->event_list_nav_size = TRUE; // ee_map_nav_size
599
+		$default_map_settings->event_list_control_type = 'dropdown'; // ee_map_type_control
600
+		$default_map_settings->event_list_map_align = 'center'; // ee_map_align
601 601
 
602 602
 		$this->_template_args['map_settings'] =
603
-			isset( EE_Registry::instance()->CFG->map_settings ) && ! empty( EE_Registry::instance()->CFG->map_settings )
604
-				? (object)array_merge( (array)$default_map_settings, (array)EE_Registry::instance()->CFG->map_settings )
603
+			isset(EE_Registry::instance()->CFG->map_settings) && ! empty(EE_Registry::instance()->CFG->map_settings)
604
+				? (object) array_merge((array) $default_map_settings, (array) EE_Registry::instance()->CFG->map_settings)
605 605
 				: $default_map_settings;
606 606
 
607
-		$this->_set_add_edit_form_tags( 'update_google_map_settings' );
608
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
607
+		$this->_set_add_edit_form_tags('update_google_map_settings');
608
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
609 609
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
610
-			EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
610
+			EE_VENUES_TEMPLATE_PATH.'google_map.template.php',
611 611
 			$this->_template_args,
612 612
 			true
613 613
 		);
@@ -617,83 +617,83 @@  discard block
 block discarded – undo
617 617
 	protected function _update_google_map_settings() {
618 618
 
619 619
 		EE_Registry::instance()->CFG->map_settings->use_google_maps =
620
-			isset( $this->_req_data['use_google_maps'] )
621
-				? absint( $this->_req_data['use_google_maps'] )
620
+			isset($this->_req_data['use_google_maps'])
621
+				? absint($this->_req_data['use_google_maps'])
622 622
 				: EE_Registry::instance()->CFG->map_settings->use_google_maps;
623 623
 
624 624
 		EE_Registry::instance()->CFG->map_settings->google_map_api_key =
625
-			isset( $this->_req_data['google_map_api_key'] )
626
-				? sanitize_text_field( $this->_req_data['google_map_api_key'] )
625
+			isset($this->_req_data['google_map_api_key'])
626
+				? sanitize_text_field($this->_req_data['google_map_api_key'])
627 627
 				: EE_Registry::instance()->CFG->map_settings->google_map_api_key;
628 628
 
629 629
 		EE_Registry::instance()->CFG->map_settings->event_details_map_width =
630
-			isset( $this->_req_data['event_details_map_width'] )
631
-				? absint( $this->_req_data['event_details_map_width'] )
630
+			isset($this->_req_data['event_details_map_width'])
631
+				? absint($this->_req_data['event_details_map_width'])
632 632
 				: EE_Registry::instance()->CFG->map_settings->event_details_map_width;
633 633
 
634 634
 		EE_Registry::instance()->CFG->map_settings->event_details_map_height =
635
-			isset( $this->_req_data['event_details_map_height'] )
636
-				? absint( $this->_req_data['event_details_map_height'] )
635
+			isset($this->_req_data['event_details_map_height'])
636
+				? absint($this->_req_data['event_details_map_height'])
637 637
 				: EE_Registry::instance()->CFG->map_settings->event_details_map_height;
638 638
 
639 639
 		EE_Registry::instance()->CFG->map_settings->event_details_map_zoom =
640
-			isset( $this->_req_data['event_details_map_zoom'] )
641
-				? absint( $this->_req_data['event_details_map_zoom'] )
640
+			isset($this->_req_data['event_details_map_zoom'])
641
+				? absint($this->_req_data['event_details_map_zoom'])
642 642
 				: EE_Registry::instance()->CFG->map_settings->event_details_map_zoom;
643 643
 
644 644
 		EE_Registry::instance()->CFG->map_settings->event_details_display_nav =
645
-			isset( $this->_req_data['event_details_display_nav'] )
646
-				? absint( $this->_req_data['event_details_display_nav'] )
645
+			isset($this->_req_data['event_details_display_nav'])
646
+				? absint($this->_req_data['event_details_display_nav'])
647 647
 				: EE_Registry::instance()->CFG->map_settings->event_details_display_nav;
648 648
 
649 649
 		EE_Registry::instance()->CFG->map_settings->event_details_nav_size =
650
-			isset( $this->_req_data['event_details_nav_size'] )
651
-				? absint( $this->_req_data['event_details_nav_size'] )
650
+			isset($this->_req_data['event_details_nav_size'])
651
+				? absint($this->_req_data['event_details_nav_size'])
652 652
 				: EE_Registry::instance()->CFG->map_settings->event_details_nav_size;
653 653
 
654 654
 		EE_Registry::instance()->CFG->map_settings->event_details_control_type =
655
-			isset( $this->_req_data['event_details_control_type'] )
656
-				? sanitize_text_field( $this->_req_data['event_details_control_type'] )
655
+			isset($this->_req_data['event_details_control_type'])
656
+				? sanitize_text_field($this->_req_data['event_details_control_type'])
657 657
 				: EE_Registry::instance()->CFG->map_settings->event_details_control_type;
658 658
 
659 659
 		EE_Registry::instance()->CFG->map_settings->event_details_map_align =
660
-			isset( $this->_req_data['event_details_map_align'] )
661
-				? sanitize_text_field( $this->_req_data['event_details_map_align'] )
660
+			isset($this->_req_data['event_details_map_align'])
661
+				? sanitize_text_field($this->_req_data['event_details_map_align'])
662 662
 				: EE_Registry::instance()->CFG->map_settings->event_details_map_align;
663 663
 
664 664
 		EE_Registry::instance()->CFG->map_settings->event_list_map_width =
665
-			isset( $this->_req_data['event_list_map_width'] )
666
-				? absint( $this->_req_data['event_list_map_width'] )
665
+			isset($this->_req_data['event_list_map_width'])
666
+				? absint($this->_req_data['event_list_map_width'])
667 667
 				: EE_Registry::instance()->CFG->map_settings->event_list_map_width;
668 668
 
669 669
 		EE_Registry::instance()->CFG->map_settings->event_list_map_height =
670
-			isset( $this->_req_data['event_list_map_height'] )
671
-				? absint( $this->_req_data['event_list_map_height'] )
670
+			isset($this->_req_data['event_list_map_height'])
671
+				? absint($this->_req_data['event_list_map_height'])
672 672
 				: EE_Registry::instance()->CFG->map_settings->event_list_map_height;
673 673
 
674 674
 		EE_Registry::instance()->CFG->map_settings->event_list_map_zoom =
675
-			isset( $this->_req_data['event_list_map_zoom'] )
676
-				? absint( $this->_req_data['event_list_map_zoom'] )
675
+			isset($this->_req_data['event_list_map_zoom'])
676
+				? absint($this->_req_data['event_list_map_zoom'])
677 677
 				: EE_Registry::instance()->CFG->map_settings->event_list_map_zoom;
678 678
 
679 679
 		EE_Registry::instance()->CFG->map_settings->event_list_display_nav =
680
-			isset( $this->_req_data['event_list_display_nav'] )
681
-				? absint( $this->_req_data['event_list_display_nav'] )
680
+			isset($this->_req_data['event_list_display_nav'])
681
+				? absint($this->_req_data['event_list_display_nav'])
682 682
 				: EE_Registry::instance()->CFG->map_settings->event_list_display_nav;
683 683
 
684 684
 		EE_Registry::instance()->CFG->map_settings->event_list_nav_size =
685
-			isset( $this->_req_data['event_list_nav_size'] )
686
-				? absint( $this->_req_data['event_list_nav_size'] )
685
+			isset($this->_req_data['event_list_nav_size'])
686
+				? absint($this->_req_data['event_list_nav_size'])
687 687
 				: EE_Registry::instance()->CFG->map_settings->event_list_nav_size;
688 688
 
689 689
 		EE_Registry::instance()->CFG->map_settings->event_list_control_type =
690
-			isset( $this->_req_data['event_list_control_type'] )
691
-				? sanitize_text_field( $this->_req_data['event_list_control_type'] )
690
+			isset($this->_req_data['event_list_control_type'])
691
+				? sanitize_text_field($this->_req_data['event_list_control_type'])
692 692
 				: EE_Registry::instance()->CFG->map_settings->event_list_control_type;
693 693
 
694 694
 		EE_Registry::instance()->CFG->map_settings->event_list_map_align =
695
-			isset( $this->_req_data['event_list_map_align'] )
696
-				? sanitize_text_field( $this->_req_data['event_list_map_align'] )
695
+			isset($this->_req_data['event_list_map_align'])
696
+				? sanitize_text_field($this->_req_data['event_list_map_align'])
697 697
 				: EE_Registry::instance()->CFG->map_settings->event_list_map_align;
698 698
 
699 699
 		EE_Registry::instance()->CFG->map_settings = apply_filters(
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 			EE_Registry::instance()->CFG->map_settings,
708 708
 			__FILE__, __FUNCTION__, __LINE__
709 709
 		);
710
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'google_map_settings' ) );
710
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'google_map_settings'));
711 711
 
712 712
 	}
713 713
 
@@ -716,9 +716,9 @@  discard block
 block discarded – undo
716 716
 	protected function _venue_editor_metaboxes() {
717 717
 		$this->verify_cpt_object();
718 718
 
719
-		add_meta_box( 'espresso_venue_address_options', __('Physical Location', 'event_espresso'), array( $this, 'venue_address_metabox'), $this->page_slug, 'side', 'default' );
720
-		add_meta_box( 'espresso_venue_gmap_options', __('Google Map', 'event_espresso'), array( $this, 'venue_gmap_metabox'), $this->page_slug, 'side', 'default' );
721
-		add_meta_box( 'espresso_venue_virtual_loc_options', __('Virtual Location', 'event_espresso'), array( $this, 'venue_virtual_loc_metabox'), $this->page_slug, 'side', 'default' );
719
+		add_meta_box('espresso_venue_address_options', __('Physical Location', 'event_espresso'), array($this, 'venue_address_metabox'), $this->page_slug, 'side', 'default');
720
+		add_meta_box('espresso_venue_gmap_options', __('Google Map', 'event_espresso'), array($this, 'venue_gmap_metabox'), $this->page_slug, 'side', 'default');
721
+		add_meta_box('espresso_venue_virtual_loc_options', __('Virtual Location', 'event_espresso'), array($this, 'venue_virtual_loc_metabox'), $this->page_slug, 'side', 'default');
722 722
 
723 723
 	}
724 724
 
@@ -726,23 +726,23 @@  discard block
 block discarded – undo
726 726
 
727 727
 	public function venue_gmap_metabox() {
728 728
 		$template_args = array(
729
-			'vnu_enable_for_gmap' => EEH_Form_Fields::select_input('vnu_enable_for_gmap', $this->get_yes_no_values(), $this->_cpt_model_obj->enable_for_gmap() ),
729
+			'vnu_enable_for_gmap' => EEH_Form_Fields::select_input('vnu_enable_for_gmap', $this->get_yes_no_values(), $this->_cpt_model_obj->enable_for_gmap()),
730 730
 			'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
731 731
 			);
732
-		$template = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
733
-		EEH_Template::display_template( $template, $template_args );
732
+		$template = EE_VENUES_TEMPLATE_PATH.'venue_gmap_metabox_content.template.php';
733
+		EEH_Template::display_template($template, $template_args);
734 734
 	}
735 735
 
736 736
 
737 737
 
738 738
 	public function venue_address_metabox() {
739 739
 
740
-		$template_args['_venue'] =$this->_cpt_model_obj;
740
+		$template_args['_venue'] = $this->_cpt_model_obj;
741 741
 
742 742
 		$template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input(
743 743
 			$QFI = new EE_Question_Form_Input(
744
-				EE_Question::new_instance( array( 'QST_display_text' => esc_html__( 'State', 'event_espresso' ), 'QST_system' => 'state' )),
745
-				EE_Answer::new_instance( array(  'ANS_value'=> $this->_cpt_model_obj->state_ID() )),
744
+				EE_Question::new_instance(array('QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state')),
745
+				EE_Answer::new_instance(array('ANS_value'=> $this->_cpt_model_obj->state_ID())),
746 746
 				array(
747 747
 					'input_name' =>  'sta_id',
748 748
 					'input_id' => 'sta_id',
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
 		);
755 755
 		$template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
756 756
 			$QFI = new EE_Question_Form_Input(
757
-				EE_Question::new_instance( array( 'QST_display_text' => esc_html__( 'Country', 'event_espresso' ), 'QST_system' => 'country' )),
758
-				EE_Answer::new_instance( array(  'ANS_value'=> $this->_cpt_model_obj->country_ID() )),
757
+				EE_Question::new_instance(array('QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country')),
758
+				EE_Answer::new_instance(array('ANS_value'=> $this->_cpt_model_obj->country_ID())),
759 759
 				array(
760 760
 					'input_name' =>  'cnt_iso',
761 761
 					'input_id' => 'cnt_iso',
@@ -766,8 +766,8 @@  discard block
 block discarded – undo
766 766
 			)
767 767
 		);
768 768
 
769
-		$template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
770
-		EEH_Template::display_template( $template, $template_args );
769
+		$template = EE_VENUES_TEMPLATE_PATH.'venue_address_metabox_content.template.php';
770
+		EEH_Template::display_template($template, $template_args);
771 771
 	}
772 772
 
773 773
 
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
 		$template_args = array(
780 780
 			'_venue' => $this->_cpt_model_obj
781 781
 			);
782
-		$template = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
783
-		EEH_Template::display_template( $template, $template_args );
782
+		$template = EE_VENUES_TEMPLATE_PATH.'venue_virtual_location_metabox_content.template.php';
783
+		EEH_Template::display_template($template, $template_args);
784 784
 	}
785 785
 
786 786
 
@@ -803,52 +803,52 @@  discard block
 block discarded – undo
803 803
 	 * @param  object $post    Post object (with "blessed" WP properties)
804 804
 	 * @return void
805 805
 	 */
806
-	protected function _insert_update_cpt_item( $post_id, $post ) {
806
+	protected function _insert_update_cpt_item($post_id, $post) {
807 807
 
808
-		if ( $post instanceof WP_Post && $post->post_type !== 'espresso_venues' ) {
809
-			return;// get out we're not processing the saving of venues.
808
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
809
+			return; // get out we're not processing the saving of venues.
810 810
 		}
811 811
 
812
-		$wheres = array( $this->_venue_model->primary_key_name() => $post_id );
812
+		$wheres = array($this->_venue_model->primary_key_name() => $post_id);
813 813
 
814 814
 		$venue_values = array(
815
-			'VNU_address' => !empty( $this->_req_data['vnu_address'] ) ? $this->_req_data['vnu_address'] : NULL,
816
-			'VNU_address2' => !empty( $this->_req_data['vnu_address2'] ) ? $this->_req_data['vnu_address2'] : NULL,
817
-			'VNU_city' => !empty( $this->_req_data['vnu_city'] ) ? $this->_req_data['vnu_city'] : NULL,
818
-			'STA_ID' => !empty( $this->_req_data['sta_id'] ) ? $this->_req_data['sta_id'] : NULL,
819
-			'CNT_ISO' => !empty( $this->_req_data['cnt_iso'] ) ? $this->_req_data['cnt_iso'] : NULL,
820
-			'VNU_zip' => !empty( $this->_req_data['vnu_zip'] ) ? $this->_req_data['vnu_zip'] : NULL,
821
-			'VNU_phone' => !empty( $this->_req_data['vnu_phone'] ) ? $this->_req_data['vnu_phone'] : NULL,
822
-			'VNU_capacity' => !empty( $this->_req_data['vnu_capacity'] ) ? str_replace( ',', '', $this->_req_data['vnu_capacity'] ) : EE_INF,
823
-			'VNU_url' => !empty( $this->_req_data['vnu_url'] ) ? $this->_req_data['vnu_url'] : NULL,
824
-			'VNU_virtual_phone' => !empty( $this->_req_data['vnu_virtual_phone'] ) ? $this->_req_data['vnu_virtual_phone'] : NULL,
825
-			'VNU_virtual_url' => !empty( $this->_req_data['vnu_virtual_url'] ) ? $this->_req_data['vnu_virtual_url'] : NULL,
826
-			'VNU_enable_for_gmap' => !empty( $this->_req_data['vnu_enable_for_gmap'] ) ? TRUE : FALSE,
827
-			'VNU_google_map_link' => !empty( $this->_req_data['vnu_google_map_link'] ) ? $this->_req_data['vnu_google_map_link'] : NULL
815
+			'VNU_address' => ! empty($this->_req_data['vnu_address']) ? $this->_req_data['vnu_address'] : NULL,
816
+			'VNU_address2' => ! empty($this->_req_data['vnu_address2']) ? $this->_req_data['vnu_address2'] : NULL,
817
+			'VNU_city' => ! empty($this->_req_data['vnu_city']) ? $this->_req_data['vnu_city'] : NULL,
818
+			'STA_ID' => ! empty($this->_req_data['sta_id']) ? $this->_req_data['sta_id'] : NULL,
819
+			'CNT_ISO' => ! empty($this->_req_data['cnt_iso']) ? $this->_req_data['cnt_iso'] : NULL,
820
+			'VNU_zip' => ! empty($this->_req_data['vnu_zip']) ? $this->_req_data['vnu_zip'] : NULL,
821
+			'VNU_phone' => ! empty($this->_req_data['vnu_phone']) ? $this->_req_data['vnu_phone'] : NULL,
822
+			'VNU_capacity' => ! empty($this->_req_data['vnu_capacity']) ? str_replace(',', '', $this->_req_data['vnu_capacity']) : EE_INF,
823
+			'VNU_url' => ! empty($this->_req_data['vnu_url']) ? $this->_req_data['vnu_url'] : NULL,
824
+			'VNU_virtual_phone' => ! empty($this->_req_data['vnu_virtual_phone']) ? $this->_req_data['vnu_virtual_phone'] : NULL,
825
+			'VNU_virtual_url' => ! empty($this->_req_data['vnu_virtual_url']) ? $this->_req_data['vnu_virtual_url'] : NULL,
826
+			'VNU_enable_for_gmap' => ! empty($this->_req_data['vnu_enable_for_gmap']) ? TRUE : FALSE,
827
+			'VNU_google_map_link' => ! empty($this->_req_data['vnu_google_map_link']) ? $this->_req_data['vnu_google_map_link'] : NULL
828 828
 			);
829 829
 
830 830
 		//update venue
831
-		$success = $this->_venue_model->update( $venue_values, array( $wheres ) );
831
+		$success = $this->_venue_model->update($venue_values, array($wheres));
832 832
 
833 833
 		//get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_model->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
834
-		$get_one_where = array( $this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status  );
835
-		$venue = $this->_venue_model->get_one( array( $get_one_where ) );
834
+		$get_one_where = array($this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status);
835
+		$venue = $this->_venue_model->get_one(array($get_one_where));
836 836
 
837 837
 		//notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use.  So this is just here for addons to more easily hook into venue saves.
838
-		$venue_update_callbacks = apply_filters( 'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks', array() );
838
+		$venue_update_callbacks = apply_filters('FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks', array());
839 839
 
840 840
 		$att_success = TRUE;
841 841
 
842
-		foreach ( $venue_update_callbacks as $v_callback ) {
843
-			$_succ = call_user_func_array( $v_callback, array( $venue,  $this->_req_data ) );
844
-			$att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
842
+		foreach ($venue_update_callbacks as $v_callback) {
843
+			$_succ = call_user_func_array($v_callback, array($venue, $this->_req_data));
844
+			$att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
845 845
 		}
846 846
 
847 847
 		//any errors?
848
-		if ( $success && !$att_success ) {
849
-			EE_Error::add_error( __('Venue Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
850
-		} else if ( $success === FALSE ) {
851
-			EE_Error::add_error( __('Venue Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
848
+		if ($success && ! $att_success) {
849
+			EE_Error::add_error(__('Venue Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
850
+		} else if ($success === FALSE) {
851
+			EE_Error::add_error(__('Venue Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
852 852
 		}
853 853
 	}
854 854
 
@@ -856,9 +856,9 @@  discard block
 block discarded – undo
856 856
 
857 857
 
858 858
 
859
-	public function trash_cpt_item( $post_id ) {
859
+	public function trash_cpt_item($post_id) {
860 860
 		$this->_req_data['VNU_ID'] = $post_id;
861
-		$this->_trash_or_restore_venue( 'trash', FALSE );
861
+		$this->_trash_or_restore_venue('trash', FALSE);
862 862
 	}
863 863
 
864 864
 
@@ -866,18 +866,18 @@  discard block
 block discarded – undo
866 866
 
867 867
 
868 868
 
869
-	public function restore_cpt_item( $post_id ) {
869
+	public function restore_cpt_item($post_id) {
870 870
 		$this->_req_data['VNU_ID'] = $post_id;
871
-		$this->_trash_or_restore_venue( 'draft', FALSE );
871
+		$this->_trash_or_restore_venue('draft', FALSE);
872 872
 	}
873 873
 
874 874
 
875 875
 
876 876
 
877 877
 
878
-	public function delete_cpt_item( $post_id ) {
878
+	public function delete_cpt_item($post_id) {
879 879
 		$this->_req_data['VNU_ID'] = $post_id;
880
-		$this->_delete_venue( FALSE );
880
+		$this->_delete_venue(FALSE);
881 881
 	}
882 882
 
883 883
 
@@ -892,15 +892,15 @@  discard block
 block discarded – undo
892 892
 
893 893
 
894 894
 
895
-	protected function _trash_or_restore_venue( $venue_status = 'trash', $redirect_after = TRUE ) {
896
-		$VNU_ID = isset( $this->_req_data['VNU_ID'] ) ? absint( $this->_req_data['VNU_ID'] ) : FALSE;
895
+	protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = TRUE) {
896
+		$VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : FALSE;
897 897
 
898 898
 		//loop thru venues
899
-		if ( $VNU_ID ) {
899
+		if ($VNU_ID) {
900 900
 			//clean status
901
-			$venue_status = sanitize_key( $venue_status );
901
+			$venue_status = sanitize_key($venue_status);
902 902
 			// grab status
903
-			if (!empty($venue_status)) {
903
+			if ( ! empty($venue_status)) {
904 904
 				$success = $this->_change_venue_status($VNU_ID, $venue_status);
905 905
 			} else {
906 906
 				$success = FALSE;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 		}
915 915
 		$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
916 916
 
917
-		if ( $redirect_after )
917
+		if ($redirect_after)
918 918
 			$this->_redirect_after_action($success, 'Venue', $action, array('action' => 'default'));
919 919
 
920 920
 	}
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
 
924 924
 
925 925
 
926
-	protected function _trash_or_restore_venues( $venue_status = 'trash' ) {
926
+	protected function _trash_or_restore_venues($venue_status = 'trash') {
927 927
 		// clean status
928 928
 		$venue_status = sanitize_key($venue_status);
929 929
 		// grab status
930
-		if (!empty($venue_status)) {
930
+		if ( ! empty($venue_status)) {
931 931
 			$success = TRUE;
932 932
 			//determine the event id and set to array.
933 933
 			$VNU_IDs = isset($this->_req_data['venue_id']) ? (array) $this->_req_data['venue_id'] : array();
@@ -967,20 +967,20 @@  discard block
 block discarded – undo
967 967
 	 * @param  string $venue_status
968 968
 	 * @return void
969 969
 	 */
970
-	private function _change_venue_status( $VNU_ID = 0, $venue_status = '' ) {
970
+	private function _change_venue_status($VNU_ID = 0, $venue_status = '') {
971 971
 		// grab venue id
972
-		if (! $VNU_ID) {
972
+		if ( ! $VNU_ID) {
973 973
 			$msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
974 974
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
975 975
 			return FALSE;
976 976
 		}
977 977
 
978
-		$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
978
+		$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
979 979
 
980 980
 		// clean status
981 981
 		$venue_status = sanitize_key($venue_status);
982 982
 		// grab status
983
-		if ( ! $venue_status ) {
983
+		if ( ! $venue_status) {
984 984
 			$msg = __('An error occurred. No Venue Status or an invalid Venue Status was received.', 'event_espresso');
985 985
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
986 986
 			return FALSE;
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 				$hook = FALSE;
1002 1002
 		}
1003 1003
 		//use class to change status
1004
-		$this->_cpt_model_obj->set_status( $venue_status );
1004
+		$this->_cpt_model_obj->set_status($venue_status);
1005 1005
 		$success = $this->_cpt_model_obj->save();
1006 1006
 
1007 1007
 		if ($success === FALSE) {
@@ -1020,21 +1020,21 @@  discard block
 block discarded – undo
1020 1020
 	 * @param  bool $redirect_after
1021 1021
 	 * @return void
1022 1022
 	 */
1023
-	protected function _delete_venue( $redirect_after = true ) {
1023
+	protected function _delete_venue($redirect_after = true) {
1024 1024
 		//determine the venue id and set to array.
1025 1025
 		$VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : NULL;
1026
-		$VNU_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $VNU_ID;
1026
+		$VNU_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $VNU_ID;
1027 1027
 
1028 1028
 
1029 1029
 		// loop thru venues
1030 1030
 		if ($VNU_ID) {
1031
-			$success = $this->_delete_or_trash_venue( $VNU_ID );
1031
+			$success = $this->_delete_or_trash_venue($VNU_ID);
1032 1032
 		} else {
1033 1033
 			$success = FALSE;
1034 1034
 			$msg = __('An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.', 'event_espresso');
1035 1035
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1036 1036
 		}
1037
-		if ( $redirect_after )
1037
+		if ($redirect_after)
1038 1038
 			$this->_redirect_after_action($success, 'Venue', 'deleted', array('action' => 'default'));
1039 1039
 	}
1040 1040
 
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 	//todo: put in parent
1067 1067
 	private function _delete_or_trash_venue($VNU_ID = FALSE) {
1068 1068
 		// grab event id
1069
-		if (!$VNU_ID = absint($VNU_ID)) {
1069
+		if ( ! $VNU_ID = absint($VNU_ID)) {
1070 1070
 			$msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1071 1071
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1072 1072
 			return FALSE;
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1087 1087
 			return FALSE;
1088 1088
 		}
1089
-		do_action( 'AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted' );
1089
+		do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1090 1090
 		return TRUE;
1091 1091
 	}
1092 1092
 
@@ -1097,11 +1097,11 @@  discard block
 block discarded – undo
1097 1097
 	/* QUERIES */
1098 1098
 
1099 1099
 
1100
-	public function get_venues( $per_page = 10, $count = FALSE ) {
1100
+	public function get_venues($per_page = 10, $count = FALSE) {
1101 1101
 
1102
-		$_orderby = !empty( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : '';
1102
+		$_orderby = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1103 1103
 
1104
-		switch ( $_orderby ) {
1104
+		switch ($_orderby) {
1105 1105
 			case 'id':
1106 1106
 				$orderby = 'VNU_ID';
1107 1107
 				break;
@@ -1119,43 +1119,43 @@  discard block
 block discarded – undo
1119 1119
 		}
1120 1120
 
1121 1121
 
1122
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
1122
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
1123 1123
 
1124
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1125
-		$per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10;
1126
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1124
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1125
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
1126
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1127 1127
 
1128 1128
 
1129
-		$offset = ($current_page-1)*$per_page;
1129
+		$offset = ($current_page - 1) * $per_page;
1130 1130
 		$limit = array($offset, $per_page);
1131 1131
 
1132
-		$category = isset( $this->_req_data['category'] ) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL;
1132
+		$category = isset($this->_req_data['category']) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL;
1133 1133
 		$where = array();
1134 1134
 
1135 1135
 		//only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1136
-		if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] != 'all' ) {
1136
+		if (isset($this->_req_data['status']) && $this->_req_data['status'] != 'all') {
1137 1137
 			$where['status'] = $this->_req_data['status'];
1138 1138
 		}
1139 1139
 
1140
-		if ( isset( $this->_req_data['venue_status'] ) ) {
1140
+		if (isset($this->_req_data['venue_status'])) {
1141 1141
 			$where['status'] = $this->_req_data['venue_status'];
1142 1142
 		}
1143 1143
 
1144 1144
 
1145
-		if ( $category ) {
1145
+		if ($category) {
1146 1146
 			$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1147 1147
 			$where['Term_Taxonomy.term_id'] = $category;
1148 1148
 		}
1149 1149
 
1150 1150
 
1151
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_venues', 'get_venues' ) ) {
1152
-			$where['VNU_wp_user'] =  get_current_user_id();
1151
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1152
+			$where['VNU_wp_user'] = get_current_user_id();
1153 1153
 		} else {
1154
-				if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' ) ) {
1154
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1155 1155
 					$where['OR'] = array(
1156
-						'status*restrict_private' => array( '!=', 'private' ),
1156
+						'status*restrict_private' => array('!=', 'private'),
1157 1157
 						'AND'                     => array(
1158
-							'status*inclusive' => array( '=', 'private' ),
1158
+							'status*inclusive' => array('=', 'private'),
1159 1159
 							'VNU_wp_user'      => get_current_user_id()
1160 1160
 						)
1161 1161
 					);
@@ -1165,30 +1165,30 @@  discard block
 block discarded – undo
1165 1165
 
1166 1166
 
1167 1167
 
1168
-		if ( isset( $this->_req_data['s'] ) ) {
1169
-			$sstr = '%' . $this->_req_data['s'] . '%';
1168
+		if (isset($this->_req_data['s'])) {
1169
+			$sstr = '%'.$this->_req_data['s'].'%';
1170 1170
 			$where['OR'] = array(
1171
-				'VNU_name' => array('LIKE',$sstr ),
1172
-				'VNU_desc' => array('LIKE',$sstr ),
1173
-				'VNU_short_desc' => array( 'LIKE',$sstr ),
1174
-				'VNU_address' => array( 'LIKE', $sstr ),
1175
-				'VNU_address2' => array( 'LIKE', $sstr ),
1176
-				'VNU_city' => array( 'LIKE', $sstr ),
1177
-				'VNU_zip' => array( 'LIKE', $sstr ),
1178
-				'VNU_phone' => array( 'LIKE', $sstr ),
1179
-				'VNU_url' => array( 'LIKE', $sstr ),
1180
-				'VNU_virtual_phone' => array( 'LIKE', $sstr ),
1181
-				'VNU_virtual_url' => array( 'LIKE', $sstr ),
1182
-				'VNU_google_map_link' => array( 'LIKE', $sstr ),
1183
-				'Event.EVT_name' => array('LIKE', $sstr ),
1184
-				'Event.EVT_desc' => array('LIKE', $sstr ),
1185
-				'Event.EVT_phone' => array('LIKE', $sstr ),
1186
-				'Event.EVT_external_URL' => array('LIKE', $sstr ),
1171
+				'VNU_name' => array('LIKE', $sstr),
1172
+				'VNU_desc' => array('LIKE', $sstr),
1173
+				'VNU_short_desc' => array('LIKE', $sstr),
1174
+				'VNU_address' => array('LIKE', $sstr),
1175
+				'VNU_address2' => array('LIKE', $sstr),
1176
+				'VNU_city' => array('LIKE', $sstr),
1177
+				'VNU_zip' => array('LIKE', $sstr),
1178
+				'VNU_phone' => array('LIKE', $sstr),
1179
+				'VNU_url' => array('LIKE', $sstr),
1180
+				'VNU_virtual_phone' => array('LIKE', $sstr),
1181
+				'VNU_virtual_url' => array('LIKE', $sstr),
1182
+				'VNU_google_map_link' => array('LIKE', $sstr),
1183
+				'Event.EVT_name' => array('LIKE', $sstr),
1184
+				'Event.EVT_desc' => array('LIKE', $sstr),
1185
+				'Event.EVT_phone' => array('LIKE', $sstr),
1186
+				'Event.EVT_external_URL' => array('LIKE', $sstr),
1187 1187
 				);
1188 1188
 		}
1189 1189
 
1190 1190
 
1191
-		$venues = $count ? $this->_venue_model->count( array($where), 'VNU_ID' ) : $this->_venue_model->get_all( array( $where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort ) );
1191
+		$venues = $count ? $this->_venue_model->count(array($where), 'VNU_ID') : $this->_venue_model->get_all(array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort));
1192 1192
 
1193 1193
 		return $venues;
1194 1194
 
@@ -1206,22 +1206,22 @@  discard block
 block discarded – undo
1206 1206
 	 * @return void
1207 1207
 	 */
1208 1208
 	private function _set_category_object() {
1209
-		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) )
1209
+		if (isset($this->_category->id) && ! empty($this->_category->id))
1210 1210
 			return; //already have the category object so get out.
1211 1211
 
1212 1212
 		//set default category object
1213 1213
 		$this->_set_empty_category_object();
1214 1214
 
1215 1215
 		//only set if we've got an id
1216
-		if ( !isset($this->_req_data['VEN_CAT_ID'] ) ) {
1216
+		if ( ! isset($this->_req_data['VEN_CAT_ID'])) {
1217 1217
 			return;
1218 1218
 		}
1219 1219
 
1220 1220
 		$category_id = absint($this->_req_data['VEN_CAT_ID']);
1221
-		$term = get_term( $category_id, 'espresso_venue_categories' );
1221
+		$term = get_term($category_id, 'espresso_venue_categories');
1222 1222
 
1223 1223
 
1224
-		if ( !empty( $term ) ) {
1224
+		if ( ! empty($term)) {
1225 1225
 			$this->_category->category_name = $term->name;
1226 1226
 			$this->_category->category_identifier = $term->slug;
1227 1227
 			$this->_category->category_desc = $term->description;
@@ -1235,15 +1235,15 @@  discard block
 block discarded – undo
1235 1235
 
1236 1236
 	private function _set_empty_category_object() {
1237 1237
 		$this->_category = new stdClass();
1238
-		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc  = '';
1238
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1239 1239
 		$this->_category->id = $this->_category->parent = 0;
1240 1240
 	}
1241 1241
 
1242 1242
 
1243 1243
 
1244 1244
 	protected function _category_list_table() {
1245
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1246
-		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1245
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1246
+		$this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1247 1247
 		    'add_category',
1248 1248
             'add_category',
1249 1249
             array(),
@@ -1263,13 +1263,13 @@  discard block
 block discarded – undo
1263 1263
 		$this->_set_add_edit_form_tags($route);
1264 1264
 
1265 1265
 		$this->_set_category_object();
1266
-		$id = !empty($this->_category->id) ? $this->_category->id : '';
1266
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
1267 1267
 
1268 1268
 		$delete_action = 'delete_category';
1269 1269
 
1270
-		$redirect = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'category_list' ), $this->_admin_base_url );
1270
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url);
1271 1271
 
1272
-		$this->_set_publish_post_box_vars( 'VEN_CAT_ID', $id, $delete_action, $redirect );
1272
+		$this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1273 1273
 
1274 1274
 		//take care of contents
1275 1275
 		$this->_template_args['admin_page_content'] = $this->_category_details_content();
@@ -1283,25 +1283,25 @@  discard block
 block discarded – undo
1283 1283
 			'type' => 'wp_editor',
1284 1284
 			'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),
1285 1285
 			'class' => 'my_editor_custom',
1286
-			'wpeditor_args' => array( 'media_buttons' => FALSE )
1286
+			'wpeditor_args' => array('media_buttons' => FALSE)
1287 1287
 		);
1288
-		$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' );
1288
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
1289 1289
 
1290
-		$all_terms = get_terms( array('espresso_venue_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) );
1290
+		$all_terms = get_terms(array('espresso_venue_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id)));
1291 1291
 
1292 1292
 		//setup category select for term parents.
1293 1293
 		$category_select_values[] = array(
1294 1294
 			'text' => __('No Parent', 'event_espresso'),
1295 1295
 			'id' => 0
1296 1296
 			);
1297
-		foreach ( $all_terms as $term ) {
1297
+		foreach ($all_terms as $term) {
1298 1298
 			$category_select_values[] = array(
1299 1299
 				'text' => $term->name,
1300 1300
 				'id' => $term->term_id
1301 1301
 				);
1302 1302
 		}
1303 1303
 
1304
-		$category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent );
1304
+		$category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent);
1305 1305
 		$template_args = array(
1306 1306
 			'category' => $this->_category,
1307 1307
 			'category_select' => $category_select,
@@ -1310,15 +1310,15 @@  discard block
 block discarded – undo
1310 1310
 			'disable' => '',
1311 1311
 			'disabled_message' =>FALSE
1312 1312
 			);
1313
-		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1314
-		return EEH_Template::display_template($template, $template_args, TRUE );
1313
+		$template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
1314
+		return EEH_Template::display_template($template, $template_args, TRUE);
1315 1315
 	}
1316 1316
 
1317 1317
 
1318 1318
 	protected function _delete_categories() {
1319
-		$cat_ids = isset( $this->_req_data['VEN_CAT_ID'] ) ? (array) $this->_req_data['VEN_CAT_ID'] : (array) $this->_req_data['category_id'];
1319
+		$cat_ids = isset($this->_req_data['VEN_CAT_ID']) ? (array) $this->_req_data['VEN_CAT_ID'] : (array) $this->_req_data['category_id'];
1320 1320
 
1321
-		foreach ( $cat_ids as $cat_id ) {
1321
+		foreach ($cat_ids as $cat_id) {
1322 1322
 			$this->_delete_category($cat_id);
1323 1323
 		}
1324 1324
 
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 		$query_args = array(
1327 1327
 			'action' => 'category_list'
1328 1328
 			);
1329
-		$this->_redirect_after_action(0,'','',$query_args);
1329
+		$this->_redirect_after_action(0, '', '', $query_args);
1330 1330
 
1331 1331
 	}
1332 1332
 
@@ -1335,58 +1335,58 @@  discard block
 block discarded – undo
1335 1335
 
1336 1336
 
1337 1337
 	protected function _delete_category($cat_id) {
1338
-		$cat_id = absint( $cat_id );
1339
-		wp_delete_term( $cat_id, 'espresso_venue_categories' );
1338
+		$cat_id = absint($cat_id);
1339
+		wp_delete_term($cat_id, 'espresso_venue_categories');
1340 1340
 	}
1341 1341
 
1342 1342
 
1343 1343
 
1344 1344
 	protected function _insert_or_update_category($new_category) {
1345 1345
 
1346
-		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE );
1346
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE);
1347 1347
 		$success = 0; //we already have a success message so lets not send another.
1348
-		if ( $cat_id ) {
1348
+		if ($cat_id) {
1349 1349
 			$query_args = array(
1350 1350
 				'action'     => 'edit_category',
1351 1351
 				'VEN_CAT_ID' => $cat_id
1352 1352
 			);
1353 1353
 		} else {
1354
-			$query_args = array( 'action' => 'add_category' );
1354
+			$query_args = array('action' => 'add_category');
1355 1355
 		}
1356
-		$this->_redirect_after_action( $success, '','', $query_args, TRUE );
1356
+		$this->_redirect_after_action($success, '', '', $query_args, TRUE);
1357 1357
 
1358 1358
 	}
1359 1359
 
1360 1360
 
1361 1361
 
1362
-	private function _insert_category( $update = FALSE ) {
1362
+	private function _insert_category($update = FALSE) {
1363 1363
 		$cat_id = $update ? $this->_req_data['VEN_CAT_ID'] : '';
1364
-		$category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : '';
1365
-		$category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : '';
1366
-		$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0;
1364
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
1365
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
1366
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
1367 1367
 
1368
-		if ( empty( $category_name ) ) {
1369
-			$msg = __( 'You must add a name for the category.', 'event_espresso' );
1370
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1368
+		if (empty($category_name)) {
1369
+			$msg = __('You must add a name for the category.', 'event_espresso');
1370
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1371 1371
 			return false;
1372 1372
 		}
1373 1373
 
1374 1374
 
1375
-		$term_args=array(
1375
+		$term_args = array(
1376 1376
 			'name'=>$category_name,
1377 1377
 			'description'=>$category_desc,
1378 1378
 			'parent'=>$category_parent
1379 1379
 		);
1380 1380
 
1381
-		$insert_ids = $update ? wp_update_term( $cat_id, 'espresso_venue_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_venue_categories', $term_args );
1381
+		$insert_ids = $update ? wp_update_term($cat_id, 'espresso_venue_categories', $term_args) : wp_insert_term($category_name, 'espresso_venue_categories', $term_args);
1382 1382
 
1383
-		if ( !is_array( $insert_ids ) ) {
1384
-			$msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' );
1385
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1383
+		if ( ! is_array($insert_ids)) {
1384
+			$msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso');
1385
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1386 1386
 		} else {
1387 1387
 			$cat_id = $insert_ids['term_id'];
1388
-			$msg = sprintf ( __('The category %s was successfully created', 'event_espresso'), $category_name );
1389
-			EE_Error::add_success( $msg );
1388
+			$msg = sprintf(__('The category %s was successfully created', 'event_espresso'), $category_name);
1389
+			EE_Error::add_success($msg);
1390 1390
 		}
1391 1391
 
1392 1392
 		return $cat_id;
@@ -1406,11 +1406,11 @@  discard block
 block discarded – undo
1406 1406
 			'category_ids' => $this->_req_data['VEN_CAT_ID']
1407 1407
 			);
1408 1408
 
1409
-		$this->_req_data = array_merge( $this->_req_data, $new_request_args );
1409
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
1410 1410
 
1411
-		if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) {
1412
-			require_once( EE_CLASSES . 'EE_Export.class.php');
1413
-			$EE_Export = EE_Export::instance( $this->_req_data );
1411
+		if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
1412
+			require_once(EE_CLASSES.'EE_Export.class.php');
1413
+			$EE_Export = EE_Export::instance($this->_req_data);
1414 1414
 			$EE_Export->export();
1415 1415
 		}
1416 1416
 
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 
1423 1423
 	protected function _import_categories() {
1424 1424
 
1425
-		require_once(EE_CLASSES . 'EE_Import.class.php');
1425
+		require_once(EE_CLASSES.'EE_Import.class.php');
1426 1426
 		EE_Import::instance()->import();
1427 1427
 
1428 1428
 	}
@@ -1430,29 +1430,29 @@  discard block
 block discarded – undo
1430 1430
 
1431 1431
 
1432 1432
 
1433
-	public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) {
1433
+	public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) {
1434 1434
 
1435 1435
 		//testing term stuff
1436
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id';
1437
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC';
1438
-		$limit = ($current_page-1)*$per_page;
1439
-		$where = array( 'taxonomy' => 'espresso_venue_categories' );
1440
-		if ( isset( $this->_req_data['s'] ) ) {
1441
-			$sstr = '%' . $this->_req_data['s'] . '%';
1436
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
1437
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
1438
+		$limit = ($current_page - 1) * $per_page;
1439
+		$where = array('taxonomy' => 'espresso_venue_categories');
1440
+		if (isset($this->_req_data['s'])) {
1441
+			$sstr = '%'.$this->_req_data['s'].'%';
1442 1442
 			$where['OR'] = array(
1443
-				'Term.name' => array( 'LIKE', $sstr),
1444
-				'description' => array( 'LIKE', $sstr )
1443
+				'Term.name' => array('LIKE', $sstr),
1444
+				'description' => array('LIKE', $sstr)
1445 1445
 				);
1446 1446
 		}
1447 1447
 
1448 1448
 		$query_params = array(
1449 1449
 			$where,
1450
-			'order_by' => array( $orderby => $order ),
1451
-			'limit' => $limit . ',' . $per_page,
1450
+			'order_by' => array($orderby => $order),
1451
+			'limit' => $limit.','.$per_page,
1452 1452
 			'force_join' => array('Term')
1453 1453
 			);
1454 1454
 
1455
-		$categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params );
1455
+		$categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params);
1456 1456
 
1457 1457
 		return $categories;
1458 1458
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Registration.model.php 2 patches
Indentation   +728 added lines, -728 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\services\database\TableAnalysis;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -17,716 +17,716 @@  discard block
 block discarded – undo
17 17
 class EEM_Registration extends EEM_Soft_Delete_Base
18 18
 {
19 19
 
20
-    // private instance of the Registration object
21
-    protected static $_instance = null;
22
-
23
-    /**
24
-     * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values
25
-     * are status codes (eg, approved, cancelled, etc)
26
-     *
27
-     * @var array
28
-     */
29
-    private static $_reg_status;
30
-
31
-    /**
32
-     * The value of REG_count for a primary registrant
33
-     */
34
-    const PRIMARY_REGISTRANT_COUNT = 1;
35
-
36
-    /**
37
-     * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration.
38
-     * Initial status for registrations when they are first created
39
-     * Payments are NOT allowed.
40
-     * Automatically toggled to whatever the default Event registration status is upon completion of the attendee
41
-     * information reg step NO space reserved. Registration is NOT active
42
-     */
43
-    const status_id_incomplete = 'RIC';
44
-
45
-    /**
46
-     * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration.
47
-     * Payments are NOT allowed.
48
-     * Event Admin must manually toggle STS_ID for it to change
49
-     * No space reserved.
50
-     * Registration is active
51
-     */
52
-    const status_id_not_approved = 'RNA';
53
-
54
-    /**
55
-     * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT .
56
-     * Payments are allowed.
57
-     * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
58
-     * No space reserved.
59
-     * Registration is active
60
-     */
61
-    const status_id_pending_payment = 'RPP';
62
-
63
-    /**
64
-     * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST .
65
-     * Payments are allowed.
66
-     * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
67
-     * No space reserved.
68
-     * Registration is active
69
-     */
70
-    const status_id_wait_list = 'RWL';
71
-
72
-    /**
73
-     * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration.
74
-     * the TXN may or may not be completed ( paid in full )
75
-     * Payments are allowed.
76
-     * A space IS reserved.
77
-     * Registration is active
78
-     */
79
-    const status_id_approved = 'RAP';
80
-
81
-    /**
82
-     * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee.
83
-     * Payments are NOT allowed.
84
-     * NO space reserved.
85
-     * Registration is NOT active
86
-     */
87
-    const status_id_cancelled = 'RCN';
88
-
89
-    /**
90
-     * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin
91
-     * Payments are NOT allowed.
92
-     * No space reserved.
93
-     * Registration is NOT active
94
-     */
95
-    const status_id_declined = 'RDC';
96
-
97
-    /**
98
-     * @var TableAnalysis $table_analysis
99
-     */
100
-    protected $_table_analysis;
101
-
102
-
103
-
104
-    /**
105
-     *    private constructor to prevent direct creation
106
-     *
107
-     * @Constructor
108
-     * @access protected
109
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
110
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
111
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
112
-     *                         timezone in the 'timezone_string' wp option)
113
-     */
114
-    protected function __construct($timezone = null)
115
-    {
116
-        $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
117
-        $this->singular_item = __('Registration', 'event_espresso');
118
-        $this->plural_item = __('Registrations', 'event_espresso');
119
-        $this->_tables = array(
120
-            'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'),
121
-        );
122
-        $this->_fields = array(
123
-            'Registration' => array(
124
-                'REG_ID'           => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
125
-                'EVT_ID'           => new EE_Foreign_Key_Int_Field(
126
-                    'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'
127
-                ),
128
-                'ATT_ID'           => new EE_Foreign_Key_Int_Field(
129
-                    'ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'
130
-                ),
131
-                'TXN_ID'           => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'),
132
-                    false, 0, 'Transaction'
133
-                ),
134
-                'TKT_ID'           => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false,
135
-                    0, 'Ticket'
136
-                ),
137
-                'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
138
-                    false, EEM_Registration::status_id_incomplete, 'Status'
139
-                ),
140
-                'REG_date'         => new EE_Datetime_Field('REG_date',
141
-                    __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone
142
-                ),
143
-                'REG_final_price'  => new EE_Money_Field('REG_final_price',
144
-                    __('Registration\'s share of the transaction total', 'event_espresso'), false, 0
145
-                ),
146
-                'REG_paid'         => new EE_Money_Field('REG_paid',
147
-                    __('Amount paid to date towards registration', 'event_espresso'), false, 0
148
-                ),
149
-                'REG_session'      => new EE_Plain_Text_Field('REG_session',
150
-                    __('Session ID of registration', 'event_espresso'), false, ''
151
-                ),
152
-                'REG_code'         => new EE_Plain_Text_Field('REG_code',
153
-                    __('Unique Code for this registration', 'event_espresso'), false, ''
154
-                ),
155
-                'REG_url_link'     => new EE_Plain_Text_Field('REG_url_link',
156
-                    __('String to be used in URL for identifying registration', 'event_espresso'), false, ''
157
-                ),
158
-                'REG_count'        => new EE_Integer_Field('REG_count',
159
-                    __('Count of this registration in the group registration ', 'event_espresso'), true, 1
160
-                ),
161
-                'REG_group_size'   => new EE_Integer_Field('REG_group_size',
162
-                    __('Number of registrations on this group', 'event_espresso'), false, 1
163
-                ),
164
-                'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going',
165
-                    __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false
166
-                ),
167
-                'REG_deleted'      => new EE_Trashed_Flag_Field(
168
-                    'REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'),
169
-                    false, false
170
-                ),
171
-            ),
172
-        );
173
-        $this->_model_relations = array(
174
-            'Event'                => new EE_Belongs_To_Relation(),
175
-            'Attendee'             => new EE_Belongs_To_Relation(),
176
-            'Transaction'          => new EE_Belongs_To_Relation(),
177
-            'Ticket'               => new EE_Belongs_To_Relation(),
178
-            'Status'               => new EE_Belongs_To_Relation(),
179
-            'Answer'               => new EE_Has_Many_Relation(),
180
-            'Checkin'              => new EE_Has_Many_Relation(),
181
-            'Registration_Payment' => new EE_Has_Many_Relation(),
182
-            'Payment'              => new EE_HABTM_Relation('Registration_Payment'),
183
-            'Message'              => new EE_Has_Many_Any_Relation(false)
184
-            //allow deletes even if there are messages in the queue related
185
-        );
186
-        $this->_model_chain_to_wp_user = 'Event';
187
-        parent::__construct($timezone);
188
-    }
189
-
190
-
191
-
192
-    /**
193
-     * reg_statuses_that_allow_payment
194
-     * a filterable list of registration statuses that allow a registrant to make a payment
195
-     *
196
-     * @access public
197
-     * @return array
198
-     */
199
-    public static function reg_statuses_that_allow_payment()
200
-    {
201
-        return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
202
-            EEM_Registration::status_id_approved,
203
-            EEM_Registration::status_id_pending_payment,
204
-            EEM_Registration::status_id_wait_list,
205
-        ));
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     * inactive_reg_statuses
212
-     * a filterable list of registration statuses that are considered active
213
-     *
214
-     * @access public
215
-     * @return array
216
-     */
217
-    public static function active_reg_statuses()
218
-    {
219
-        return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
220
-            EEM_Registration::status_id_approved,
221
-            EEM_Registration::status_id_pending_payment,
222
-            EEM_Registration::status_id_wait_list,
223
-            EEM_Registration::status_id_not_approved,
224
-        ));
225
-    }
226
-
227
-
228
-
229
-    /**
230
-     * inactive_reg_statuses
231
-     * a filterable list of registration statuses that are not considered active
232
-     *
233
-     * @access public
234
-     * @return array
235
-     */
236
-    public static function inactive_reg_statuses()
237
-    {
238
-        return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
239
-            EEM_Registration::status_id_incomplete,
240
-            EEM_Registration::status_id_cancelled,
241
-            EEM_Registration::status_id_declined,
242
-        ));
243
-    }
244
-
245
-
246
-
247
-    /**
248
-     *    closed_reg_statuses
249
-     *    a filterable list of registration statuses that are considered "closed"
250
-     * meaning they should not be considered in any calculations involving monies owing
251
-     *
252
-     * @access public
253
-     * @return array
254
-     */
255
-    public static function closed_reg_statuses()
256
-    {
257
-        return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array(
258
-            EEM_Registration::status_id_cancelled,
259
-            EEM_Registration::status_id_declined,
260
-        ));
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     *        get list of registration statuses
267
-     *
268
-     * @access public
269
-     * @param array $exclude    The status ids to exclude from the returned results
270
-     * @param bool  $translated If true will return the values as singular localized strings
271
-     * @return array
272
-     */
273
-    public static function reg_status_array($exclude = array(), $translated = false)
274
-    {
275
-        EEM_Registration::instance()->_get_registration_status_array($exclude);
276
-        return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence')
277
-            : self::$_reg_status;
278
-    }
279
-
280
-
281
-
282
-    /**
283
-     *    get list of registration statuses
284
-     *
285
-     * @access private
286
-     * @param array $exclude
287
-     * @return array
288
-     */
289
-    private function _get_registration_status_array($exclude = array())
290
-    {
291
-        //in the very rare circumstance that we are deleting a model's table's data
292
-        //and the table hasn't actually been created, this could have an error
293
-        /** @type WPDB $wpdb */
294
-        global $wpdb;
295
-        if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
296
-            $results = $wpdb->get_results(
297
-                "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'"
298
-            );
299
-            self::$_reg_status = array();
300
-            foreach ($results as $status) {
301
-                if ( ! in_array($status->STS_ID, $exclude)) {
302
-                    self::$_reg_status[$status->STS_ID] = $status->STS_code;
303
-                }
304
-            }
305
-        }
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * Gets the injected table analyzer, or throws an exception
312
-     *
313
-     * @return TableAnalysis
314
-     * @throws \EE_Error
315
-     */
316
-    protected function _get_table_analysis()
317
-    {
318
-        if ($this->_table_analysis instanceof TableAnalysis) {
319
-            return $this->_table_analysis;
320
-        } else {
321
-            throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
322
-                get_class($this)));
323
-        }
324
-    }
325
-
326
-
327
-
328
-    /**
329
-     * This returns a wpdb->results array of all registration date month and years matching the incoming query params
330
-     * and grouped by month and year.
331
-     *
332
-     * @param  array $where_params Array of query_params as described in the comments for EEM_Base::get_all()
333
-     * @return array
334
-     * @throws \EE_Error
335
-     */
336
-    public function get_reg_months_and_years($where_params)
337
-    {
338
-        $query_params[0] = $where_params;
339
-        $query_params['group_by'] = array('reg_year', 'reg_month');
340
-        $query_params['order_by'] = array('REG_date' => 'DESC');
341
-        $columns_to_select = array(
342
-            'reg_year'  => array('YEAR(REG_date)', '%s'),
343
-            'reg_month' => array('MONTHNAME(REG_date)', '%s'),
344
-        );
345
-        return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
346
-    }
347
-
348
-
349
-
350
-    /**
351
-     *        retrieve ALL registrations for a particular Attendee from db
352
-     *
353
-     * @access        public
354
-     * @param        int $ATT_ID
355
-     * @return    EE_Registration[]
356
-     */
357
-    public function get_all_registrations_for_attendee($ATT_ID = 0)
358
-    {
359
-        if ( ! $ATT_ID) {
360
-            return false;
361
-        }
362
-        return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     * Gets a registration given their REG_url_link. Yes, this should usually
369
-     * be passed via a GET parameter.
370
-     *
371
-     * @param string $REG_url_link
372
-     * @return EE_Registration
373
-     */
374
-    public function get_registration_for_reg_url_link($REG_url_link)
375
-    {
376
-        if ( ! $REG_url_link) {
377
-            return false;
378
-        }
379
-        return $this->get_one(array(array('REG_url_link' => $REG_url_link)));
380
-    }
381
-
382
-
383
-
384
-    /**
385
-     *        retrieve registration for a specific transaction attendee from db
386
-     *
387
-     * @access        public
388
-     * @param    int $TXN_ID
389
-     * @param    int $ATT_ID
390
-     * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
391
-     *                         attendee number is required
392
-     * @return        mixed        array on success, FALSE on fail
393
-     */
394
-    public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
395
-    {
396
-        return $this->get_one(array(
397
-            array(
398
-                'TXN_ID' => $TXN_ID,
399
-                'ATT_ID' => $ATT_ID,
400
-            ),
401
-            'limit' => array(min(($att_nmbr - 1), 0), 1),
402
-        ));
403
-    }
404
-
405
-
406
-
407
-    /**
408
-     *        get the number of registrations per day  for the Registration Admin page Reports Tab.
409
-     *        (doesn't utilize models because it's a fairly specialized query)
410
-     *
411
-     * @access        public
412
-     * @param $period string which can be passed to php's strtotime function (eg "-1 month")
413
-     * @return stdClass[] with properties regDate and total
414
-     */
415
-    public function get_registrations_per_day_report($period = '-1 month')
416
-    {
417
-        $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
418
-            'Y-m-d H:i:s', 'UTC');
419
-        $where = array(
420
-            'REG_date' => array('>=', $sql_date),
421
-            'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
422
-        );
423
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
424
-            $where['Event.EVT_wp_user'] = get_current_user_id();
425
-        }
426
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
427
-        $results = $this->_get_all_wpdb_results(array(
428
-            $where,
429
-            'group_by' => 'regDate',
430
-            'order_by' => array('REG_date' => 'ASC'),
431
-        ), OBJECT, array(
432
-            'regDate' => array('DATE(' . $query_interval . ')', '%s'),
433
-            'total'   => array('count(REG_ID)', '%d'),
434
-        ));
435
-        return $results;
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * Get the number of registrations per day including the count of registrations for each Registration Status.
442
-     * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
443
-     *
444
-     * @param string $period
445
-     * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
446
-     *                    (i.e. RAP)
447
-     */
448
-    public function get_registrations_per_day_and_per_status_report($period = '-1 month')
449
-    {
450
-        global $wpdb;
451
-        $registration_table = $wpdb->prefix . 'esp_registration';
452
-        $event_table = $wpdb->posts;
453
-        $sql_date = date("Y-m-d H:i:s", strtotime($period));
454
-        //prepare the query interval for displaying offset
455
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
456
-        //inner date query
457
-        $inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
458
-        $inner_where = " WHERE";
459
-        //exclude events not authored by user if permissions in effect
460
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
461
-            $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
462
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
463
-        }
464
-        $inner_where .= " REG_date >= '$sql_date'";
465
-        $inner_date_query .= $inner_where;
466
-        //start main query
467
-        $select = "SELECT DATE($query_interval) as Registration_REG_date, ";
468
-        $join = '';
469
-        $join_parts = array();
470
-        $select_parts = array();
471
-        //loop through registration stati to do parts for each status.
472
-        foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
473
-            if ($STS_ID === EEM_Registration::status_id_incomplete) {
474
-                continue;
475
-            }
476
-            $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
477
-            $join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'";
478
-        }
479
-        //setup the selects
480
-        $select .= implode(', ', $select_parts);
481
-        $select .= " FROM ($inner_date_query) AS dates LEFT JOIN ";
482
-        //setup the joins
483
-        $join .= implode(" LEFT JOIN ", $join_parts);
484
-        //now let's put it all together
485
-        $query = $select . $join . ' GROUP BY Registration_REG_date';
486
-        //and execute it
487
-        $results = $wpdb->get_results($query, ARRAY_A);
488
-        return $results;
489
-    }
490
-
491
-
492
-
493
-    /**
494
-     *        get the number of registrations per event  for the Registration Admin page Reports Tab
495
-     *
496
-     * @access        public
497
-     * @param $period string which can be passed to php's strtotime function (eg "-1 month")
498
-     * @return stdClass[] each with properties event_name, reg_limit, and total
499
-     */
500
-    public function get_registrations_per_event_report($period = '-1 month')
501
-    {
502
-        $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
503
-            'Y-m-d H:i:s', 'UTC');
504
-        $where = array(
505
-            'REG_date' => array('>=', $date_sql),
506
-            'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
507
-        );
508
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
509
-            $where['Event.EVT_wp_user'] = get_current_user_id();
510
-        }
511
-        $results = $this->_get_all_wpdb_results(array(
512
-            $where,
513
-            'group_by' => 'Event.EVT_name',
514
-            'order_by' => 'Event.EVT_name',
515
-            'limit'    => array(0, 24),
516
-        ), OBJECT, array(
517
-            'event_name' => array('Event_CPT.post_title', '%s'),
518
-            'total'      => array('COUNT(REG_ID)', '%s'),
519
-        ));
520
-        return $results;
521
-    }
522
-
523
-
524
-
525
-    /**
526
-     * Get the number of registrations per event grouped by registration status.
527
-     * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
528
-     *
529
-     * @param string $period
530
-     * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
531
-     *                    (i.e. RAP)
532
-     */
533
-    public function get_registrations_per_event_and_per_status_report($period = '-1 month')
534
-    {
535
-        global $wpdb;
536
-        $registration_table = $wpdb->prefix . 'esp_registration';
537
-        $event_table = $wpdb->posts;
538
-        $sql_date = date("Y-m-d H:i:s", strtotime($period));
539
-        //inner date query
540
-        $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table ";
541
-        $inner_where = " WHERE";
542
-        //exclude events not authored by user if permissions in effect
543
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
544
-            $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
545
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
546
-        }
547
-        $inner_where .= " REG_date >= '$sql_date'";
548
-        $inner_date_query .= $inner_where;
549
-        //build main query
550
-        $select = "SELECT Event.post_title as Registration_Event, ";
551
-        $join = '';
552
-        $join_parts = array();
553
-        $select_parts = array();
554
-        //loop through registration stati to do parts for each status.
555
-        foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
556
-            if ($STS_ID === EEM_Registration::status_id_incomplete) {
557
-                continue;
558
-            }
559
-            $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
560
-            $join_parts[] = "$registration_table AS $STS_code ON $STS_code.EVT_ID = dates.EVT_ID AND $STS_code.STS_ID = '$STS_ID' AND $STS_code.REG_date = dates.REG_date";
561
-        }
562
-        //setup the selects
563
-        $select .= implode(', ', $select_parts);
564
-        $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
565
-        //setup remaining joins
566
-        $join .= implode(" LEFT JOIN ", $join_parts);
567
-        //now put it all together
568
-        $query = $select . $join . ' GROUP BY Registration_Event';
569
-        //and execute
570
-        $results = $wpdb->get_results($query, ARRAY_A);
571
-        return $results;
572
-    }
573
-
574
-
575
-
576
-    /**
577
-     * Returns the EE_Registration of the primary attendee on the transaction id provided
578
-     *
579
-     * @param int $TXN_ID
580
-     * @return EE_Registration
581
-     */
582
-    public function get_primary_registration_for_transaction_ID($TXN_ID = 0)
583
-    {
584
-        if ( ! $TXN_ID) {
585
-            return false;
586
-        }
587
-        return $this->get_one(array(
588
-            array(
589
-                'TXN_ID'    => $TXN_ID,
590
-                'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT,
591
-            ),
592
-        ));
593
-    }
594
-
595
-
596
-
597
-    /**
598
-     *        get_event_registration_count
599
-     *
600
-     * @access public
601
-     * @param int     $EVT_ID
602
-     * @param boolean $for_incomplete_payments
603
-     * @return int
604
-     */
605
-    public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false)
606
-    {
607
-        // we only count approved registrations towards registration limits
608
-        $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
609
-        if ($for_incomplete_payments) {
610
-            $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
611
-        }
612
-        return $this->count($query_params);
613
-    }
614
-
615
-
616
-
617
-    /**
618
-     * Deletes all registrations with no transactions. Note that this needs to be very efficient
619
-     * and so it uses wpdb directly
620
-     *
621
-     * @global WPDB $wpdb
622
-     * @return int number deleted
623
-     */
624
-    public function delete_registrations_with_no_transaction()
625
-    {
626
-        /** @type WPDB $wpdb */
627
-        global $wpdb;
628
-        return $wpdb->query('DELETE r FROM '
629
-                            . $this->table()
630
-                            . ' r LEFT JOIN '
631
-                            . EEM_Transaction::instance()->table()
632
-                            . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL');
633
-    }
634
-
635
-
636
-
637
-    /**
638
-     *  Count registrations checked into (or out of) a datetime
639
-     *
640
-     * @param int     $DTT_ID     datetime ID
641
-     * @param boolean $checked_in whether to count registrations checked IN or OUT
642
-     * @return int
643
-     */
644
-    public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true)
645
-    {
646
-        global $wpdb;
647
-        //subquery to get latest checkin
648
-        $query = $wpdb->prepare('SELECT '
649
-                                . 'COUNT( DISTINCT checkins.REG_ID ) '
650
-                                . 'FROM '
651
-                                . EEM_Checkin::instance()
652
-                                             ->table()
653
-                                . ' AS checkins INNER JOIN'
654
-                                . '( SELECT '
655
-                                . 'max( CHK_timestamp ) AS latest_checkin, '
656
-                                . 'REG_ID AS REG_ID '
657
-                                . 'FROM '
658
-                                . EEM_Checkin::instance()->table()
659
-                                . ' '
660
-                                . 'WHERE DTT_ID=%d '
661
-                                . 'GROUP BY REG_ID'
662
-                                . ') AS most_recent_checkin_per_reg '
663
-                                . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
664
-                                . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
665
-                                . 'WHERE '
666
-                                . 'checkins.CHK_in=%d', $DTT_ID, $checked_in);
667
-        return (int)$wpdb->get_var($query);
668
-    }
669
-
670
-
671
-
672
-    /**
673
-     *  Count registrations checked into (or out of) an event.
674
-     *
675
-     * @param int     $EVT_ID     event ID
676
-     * @param boolean $checked_in whether to count registrations checked IN or OUT
677
-     * @return int
678
-     */
679
-    public function count_registrations_checked_into_event($EVT_ID, $checked_in = true)
680
-    {
681
-        global $wpdb;
682
-        //subquery to get latest checkin
683
-        $query = $wpdb->prepare('SELECT '
684
-                                . 'COUNT( DISTINCT checkins.REG_ID ) '
685
-                                . 'FROM '
686
-                                . EEM_Checkin::instance()
687
-                                             ->table()
688
-                                . ' AS checkins INNER JOIN'
689
-                                . '( SELECT '
690
-                                . 'max( CHK_timestamp ) AS latest_checkin, '
691
-                                . 'REG_ID AS REG_ID '
692
-                                . 'FROM '
693
-                                . EEM_Checkin::instance()->table()
694
-                                . ' AS c '
695
-                                . 'INNER JOIN '
696
-                                . EEM_Datetime::instance()->table()
697
-                                . ' AS d '
698
-                                . 'ON c.DTT_ID=d.DTT_ID '
699
-                                . 'WHERE d.EVT_ID=%d '
700
-                                . 'GROUP BY REG_ID'
701
-                                . ') AS most_recent_checkin_per_reg '
702
-                                . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
703
-                                . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
704
-                                . 'WHERE '
705
-                                . 'checkins.CHK_in=%d', $EVT_ID, $checked_in);
706
-        return (int)$wpdb->get_var($query);
707
-    }
708
-
709
-
710
-
711
-    /**
712
-     * The purpose of this method is to retrieve an array of
713
-     * EE_Registration objects that represent the latest registration
714
-     * for each ATT_ID given in the function argument.
715
-     *
716
-     * @param array $attendee_ids
717
-     * @return EE_Registration[]
718
-     */
719
-    public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array())
720
-    {
721
-        //first do a native wp_query to get the latest REG_ID's matching these attendees.
722
-        global $wpdb;
723
-        $registration_table = $wpdb->prefix . 'esp_registration';
724
-        $attendee_table = $wpdb->posts;
725
-        $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids);
726
-        $attendee_ids = implode(',', $attendee_ids);
727
-        //first we do a query to get the registration ids
728
-        // (because a group by before order by causes the order by to be ignored.)
729
-        $registration_id_query = "
20
+	// private instance of the Registration object
21
+	protected static $_instance = null;
22
+
23
+	/**
24
+	 * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values
25
+	 * are status codes (eg, approved, cancelled, etc)
26
+	 *
27
+	 * @var array
28
+	 */
29
+	private static $_reg_status;
30
+
31
+	/**
32
+	 * The value of REG_count for a primary registrant
33
+	 */
34
+	const PRIMARY_REGISTRANT_COUNT = 1;
35
+
36
+	/**
37
+	 * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration.
38
+	 * Initial status for registrations when they are first created
39
+	 * Payments are NOT allowed.
40
+	 * Automatically toggled to whatever the default Event registration status is upon completion of the attendee
41
+	 * information reg step NO space reserved. Registration is NOT active
42
+	 */
43
+	const status_id_incomplete = 'RIC';
44
+
45
+	/**
46
+	 * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration.
47
+	 * Payments are NOT allowed.
48
+	 * Event Admin must manually toggle STS_ID for it to change
49
+	 * No space reserved.
50
+	 * Registration is active
51
+	 */
52
+	const status_id_not_approved = 'RNA';
53
+
54
+	/**
55
+	 * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT .
56
+	 * Payments are allowed.
57
+	 * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
58
+	 * No space reserved.
59
+	 * Registration is active
60
+	 */
61
+	const status_id_pending_payment = 'RPP';
62
+
63
+	/**
64
+	 * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST .
65
+	 * Payments are allowed.
66
+	 * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
67
+	 * No space reserved.
68
+	 * Registration is active
69
+	 */
70
+	const status_id_wait_list = 'RWL';
71
+
72
+	/**
73
+	 * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration.
74
+	 * the TXN may or may not be completed ( paid in full )
75
+	 * Payments are allowed.
76
+	 * A space IS reserved.
77
+	 * Registration is active
78
+	 */
79
+	const status_id_approved = 'RAP';
80
+
81
+	/**
82
+	 * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee.
83
+	 * Payments are NOT allowed.
84
+	 * NO space reserved.
85
+	 * Registration is NOT active
86
+	 */
87
+	const status_id_cancelled = 'RCN';
88
+
89
+	/**
90
+	 * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin
91
+	 * Payments are NOT allowed.
92
+	 * No space reserved.
93
+	 * Registration is NOT active
94
+	 */
95
+	const status_id_declined = 'RDC';
96
+
97
+	/**
98
+	 * @var TableAnalysis $table_analysis
99
+	 */
100
+	protected $_table_analysis;
101
+
102
+
103
+
104
+	/**
105
+	 *    private constructor to prevent direct creation
106
+	 *
107
+	 * @Constructor
108
+	 * @access protected
109
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
110
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
111
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
112
+	 *                         timezone in the 'timezone_string' wp option)
113
+	 */
114
+	protected function __construct($timezone = null)
115
+	{
116
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
117
+		$this->singular_item = __('Registration', 'event_espresso');
118
+		$this->plural_item = __('Registrations', 'event_espresso');
119
+		$this->_tables = array(
120
+			'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'),
121
+		);
122
+		$this->_fields = array(
123
+			'Registration' => array(
124
+				'REG_ID'           => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
125
+				'EVT_ID'           => new EE_Foreign_Key_Int_Field(
126
+					'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'
127
+				),
128
+				'ATT_ID'           => new EE_Foreign_Key_Int_Field(
129
+					'ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'
130
+				),
131
+				'TXN_ID'           => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'),
132
+					false, 0, 'Transaction'
133
+				),
134
+				'TKT_ID'           => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false,
135
+					0, 'Ticket'
136
+				),
137
+				'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
138
+					false, EEM_Registration::status_id_incomplete, 'Status'
139
+				),
140
+				'REG_date'         => new EE_Datetime_Field('REG_date',
141
+					__('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone
142
+				),
143
+				'REG_final_price'  => new EE_Money_Field('REG_final_price',
144
+					__('Registration\'s share of the transaction total', 'event_espresso'), false, 0
145
+				),
146
+				'REG_paid'         => new EE_Money_Field('REG_paid',
147
+					__('Amount paid to date towards registration', 'event_espresso'), false, 0
148
+				),
149
+				'REG_session'      => new EE_Plain_Text_Field('REG_session',
150
+					__('Session ID of registration', 'event_espresso'), false, ''
151
+				),
152
+				'REG_code'         => new EE_Plain_Text_Field('REG_code',
153
+					__('Unique Code for this registration', 'event_espresso'), false, ''
154
+				),
155
+				'REG_url_link'     => new EE_Plain_Text_Field('REG_url_link',
156
+					__('String to be used in URL for identifying registration', 'event_espresso'), false, ''
157
+				),
158
+				'REG_count'        => new EE_Integer_Field('REG_count',
159
+					__('Count of this registration in the group registration ', 'event_espresso'), true, 1
160
+				),
161
+				'REG_group_size'   => new EE_Integer_Field('REG_group_size',
162
+					__('Number of registrations on this group', 'event_espresso'), false, 1
163
+				),
164
+				'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going',
165
+					__('Flag indicating the registrant plans on attending', 'event_espresso'), false, false
166
+				),
167
+				'REG_deleted'      => new EE_Trashed_Flag_Field(
168
+					'REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'),
169
+					false, false
170
+				),
171
+			),
172
+		);
173
+		$this->_model_relations = array(
174
+			'Event'                => new EE_Belongs_To_Relation(),
175
+			'Attendee'             => new EE_Belongs_To_Relation(),
176
+			'Transaction'          => new EE_Belongs_To_Relation(),
177
+			'Ticket'               => new EE_Belongs_To_Relation(),
178
+			'Status'               => new EE_Belongs_To_Relation(),
179
+			'Answer'               => new EE_Has_Many_Relation(),
180
+			'Checkin'              => new EE_Has_Many_Relation(),
181
+			'Registration_Payment' => new EE_Has_Many_Relation(),
182
+			'Payment'              => new EE_HABTM_Relation('Registration_Payment'),
183
+			'Message'              => new EE_Has_Many_Any_Relation(false)
184
+			//allow deletes even if there are messages in the queue related
185
+		);
186
+		$this->_model_chain_to_wp_user = 'Event';
187
+		parent::__construct($timezone);
188
+	}
189
+
190
+
191
+
192
+	/**
193
+	 * reg_statuses_that_allow_payment
194
+	 * a filterable list of registration statuses that allow a registrant to make a payment
195
+	 *
196
+	 * @access public
197
+	 * @return array
198
+	 */
199
+	public static function reg_statuses_that_allow_payment()
200
+	{
201
+		return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
202
+			EEM_Registration::status_id_approved,
203
+			EEM_Registration::status_id_pending_payment,
204
+			EEM_Registration::status_id_wait_list,
205
+		));
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 * inactive_reg_statuses
212
+	 * a filterable list of registration statuses that are considered active
213
+	 *
214
+	 * @access public
215
+	 * @return array
216
+	 */
217
+	public static function active_reg_statuses()
218
+	{
219
+		return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
220
+			EEM_Registration::status_id_approved,
221
+			EEM_Registration::status_id_pending_payment,
222
+			EEM_Registration::status_id_wait_list,
223
+			EEM_Registration::status_id_not_approved,
224
+		));
225
+	}
226
+
227
+
228
+
229
+	/**
230
+	 * inactive_reg_statuses
231
+	 * a filterable list of registration statuses that are not considered active
232
+	 *
233
+	 * @access public
234
+	 * @return array
235
+	 */
236
+	public static function inactive_reg_statuses()
237
+	{
238
+		return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
239
+			EEM_Registration::status_id_incomplete,
240
+			EEM_Registration::status_id_cancelled,
241
+			EEM_Registration::status_id_declined,
242
+		));
243
+	}
244
+
245
+
246
+
247
+	/**
248
+	 *    closed_reg_statuses
249
+	 *    a filterable list of registration statuses that are considered "closed"
250
+	 * meaning they should not be considered in any calculations involving monies owing
251
+	 *
252
+	 * @access public
253
+	 * @return array
254
+	 */
255
+	public static function closed_reg_statuses()
256
+	{
257
+		return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array(
258
+			EEM_Registration::status_id_cancelled,
259
+			EEM_Registration::status_id_declined,
260
+		));
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 *        get list of registration statuses
267
+	 *
268
+	 * @access public
269
+	 * @param array $exclude    The status ids to exclude from the returned results
270
+	 * @param bool  $translated If true will return the values as singular localized strings
271
+	 * @return array
272
+	 */
273
+	public static function reg_status_array($exclude = array(), $translated = false)
274
+	{
275
+		EEM_Registration::instance()->_get_registration_status_array($exclude);
276
+		return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence')
277
+			: self::$_reg_status;
278
+	}
279
+
280
+
281
+
282
+	/**
283
+	 *    get list of registration statuses
284
+	 *
285
+	 * @access private
286
+	 * @param array $exclude
287
+	 * @return array
288
+	 */
289
+	private function _get_registration_status_array($exclude = array())
290
+	{
291
+		//in the very rare circumstance that we are deleting a model's table's data
292
+		//and the table hasn't actually been created, this could have an error
293
+		/** @type WPDB $wpdb */
294
+		global $wpdb;
295
+		if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
296
+			$results = $wpdb->get_results(
297
+				"SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'"
298
+			);
299
+			self::$_reg_status = array();
300
+			foreach ($results as $status) {
301
+				if ( ! in_array($status->STS_ID, $exclude)) {
302
+					self::$_reg_status[$status->STS_ID] = $status->STS_code;
303
+				}
304
+			}
305
+		}
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * Gets the injected table analyzer, or throws an exception
312
+	 *
313
+	 * @return TableAnalysis
314
+	 * @throws \EE_Error
315
+	 */
316
+	protected function _get_table_analysis()
317
+	{
318
+		if ($this->_table_analysis instanceof TableAnalysis) {
319
+			return $this->_table_analysis;
320
+		} else {
321
+			throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
322
+				get_class($this)));
323
+		}
324
+	}
325
+
326
+
327
+
328
+	/**
329
+	 * This returns a wpdb->results array of all registration date month and years matching the incoming query params
330
+	 * and grouped by month and year.
331
+	 *
332
+	 * @param  array $where_params Array of query_params as described in the comments for EEM_Base::get_all()
333
+	 * @return array
334
+	 * @throws \EE_Error
335
+	 */
336
+	public function get_reg_months_and_years($where_params)
337
+	{
338
+		$query_params[0] = $where_params;
339
+		$query_params['group_by'] = array('reg_year', 'reg_month');
340
+		$query_params['order_by'] = array('REG_date' => 'DESC');
341
+		$columns_to_select = array(
342
+			'reg_year'  => array('YEAR(REG_date)', '%s'),
343
+			'reg_month' => array('MONTHNAME(REG_date)', '%s'),
344
+		);
345
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
346
+	}
347
+
348
+
349
+
350
+	/**
351
+	 *        retrieve ALL registrations for a particular Attendee from db
352
+	 *
353
+	 * @access        public
354
+	 * @param        int $ATT_ID
355
+	 * @return    EE_Registration[]
356
+	 */
357
+	public function get_all_registrations_for_attendee($ATT_ID = 0)
358
+	{
359
+		if ( ! $ATT_ID) {
360
+			return false;
361
+		}
362
+		return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 * Gets a registration given their REG_url_link. Yes, this should usually
369
+	 * be passed via a GET parameter.
370
+	 *
371
+	 * @param string $REG_url_link
372
+	 * @return EE_Registration
373
+	 */
374
+	public function get_registration_for_reg_url_link($REG_url_link)
375
+	{
376
+		if ( ! $REG_url_link) {
377
+			return false;
378
+		}
379
+		return $this->get_one(array(array('REG_url_link' => $REG_url_link)));
380
+	}
381
+
382
+
383
+
384
+	/**
385
+	 *        retrieve registration for a specific transaction attendee from db
386
+	 *
387
+	 * @access        public
388
+	 * @param    int $TXN_ID
389
+	 * @param    int $ATT_ID
390
+	 * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
391
+	 *                         attendee number is required
392
+	 * @return        mixed        array on success, FALSE on fail
393
+	 */
394
+	public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
395
+	{
396
+		return $this->get_one(array(
397
+			array(
398
+				'TXN_ID' => $TXN_ID,
399
+				'ATT_ID' => $ATT_ID,
400
+			),
401
+			'limit' => array(min(($att_nmbr - 1), 0), 1),
402
+		));
403
+	}
404
+
405
+
406
+
407
+	/**
408
+	 *        get the number of registrations per day  for the Registration Admin page Reports Tab.
409
+	 *        (doesn't utilize models because it's a fairly specialized query)
410
+	 *
411
+	 * @access        public
412
+	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
413
+	 * @return stdClass[] with properties regDate and total
414
+	 */
415
+	public function get_registrations_per_day_report($period = '-1 month')
416
+	{
417
+		$sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
418
+			'Y-m-d H:i:s', 'UTC');
419
+		$where = array(
420
+			'REG_date' => array('>=', $sql_date),
421
+			'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
422
+		);
423
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
424
+			$where['Event.EVT_wp_user'] = get_current_user_id();
425
+		}
426
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
427
+		$results = $this->_get_all_wpdb_results(array(
428
+			$where,
429
+			'group_by' => 'regDate',
430
+			'order_by' => array('REG_date' => 'ASC'),
431
+		), OBJECT, array(
432
+			'regDate' => array('DATE(' . $query_interval . ')', '%s'),
433
+			'total'   => array('count(REG_ID)', '%d'),
434
+		));
435
+		return $results;
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * Get the number of registrations per day including the count of registrations for each Registration Status.
442
+	 * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
443
+	 *
444
+	 * @param string $period
445
+	 * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
446
+	 *                    (i.e. RAP)
447
+	 */
448
+	public function get_registrations_per_day_and_per_status_report($period = '-1 month')
449
+	{
450
+		global $wpdb;
451
+		$registration_table = $wpdb->prefix . 'esp_registration';
452
+		$event_table = $wpdb->posts;
453
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
454
+		//prepare the query interval for displaying offset
455
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
456
+		//inner date query
457
+		$inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
458
+		$inner_where = " WHERE";
459
+		//exclude events not authored by user if permissions in effect
460
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
461
+			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
462
+			$inner_where .= " post_author = " . get_current_user_id() . " AND";
463
+		}
464
+		$inner_where .= " REG_date >= '$sql_date'";
465
+		$inner_date_query .= $inner_where;
466
+		//start main query
467
+		$select = "SELECT DATE($query_interval) as Registration_REG_date, ";
468
+		$join = '';
469
+		$join_parts = array();
470
+		$select_parts = array();
471
+		//loop through registration stati to do parts for each status.
472
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
473
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
474
+				continue;
475
+			}
476
+			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
477
+			$join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'";
478
+		}
479
+		//setup the selects
480
+		$select .= implode(', ', $select_parts);
481
+		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN ";
482
+		//setup the joins
483
+		$join .= implode(" LEFT JOIN ", $join_parts);
484
+		//now let's put it all together
485
+		$query = $select . $join . ' GROUP BY Registration_REG_date';
486
+		//and execute it
487
+		$results = $wpdb->get_results($query, ARRAY_A);
488
+		return $results;
489
+	}
490
+
491
+
492
+
493
+	/**
494
+	 *        get the number of registrations per event  for the Registration Admin page Reports Tab
495
+	 *
496
+	 * @access        public
497
+	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
498
+	 * @return stdClass[] each with properties event_name, reg_limit, and total
499
+	 */
500
+	public function get_registrations_per_event_report($period = '-1 month')
501
+	{
502
+		$date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
503
+			'Y-m-d H:i:s', 'UTC');
504
+		$where = array(
505
+			'REG_date' => array('>=', $date_sql),
506
+			'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
507
+		);
508
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
509
+			$where['Event.EVT_wp_user'] = get_current_user_id();
510
+		}
511
+		$results = $this->_get_all_wpdb_results(array(
512
+			$where,
513
+			'group_by' => 'Event.EVT_name',
514
+			'order_by' => 'Event.EVT_name',
515
+			'limit'    => array(0, 24),
516
+		), OBJECT, array(
517
+			'event_name' => array('Event_CPT.post_title', '%s'),
518
+			'total'      => array('COUNT(REG_ID)', '%s'),
519
+		));
520
+		return $results;
521
+	}
522
+
523
+
524
+
525
+	/**
526
+	 * Get the number of registrations per event grouped by registration status.
527
+	 * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
528
+	 *
529
+	 * @param string $period
530
+	 * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
531
+	 *                    (i.e. RAP)
532
+	 */
533
+	public function get_registrations_per_event_and_per_status_report($period = '-1 month')
534
+	{
535
+		global $wpdb;
536
+		$registration_table = $wpdb->prefix . 'esp_registration';
537
+		$event_table = $wpdb->posts;
538
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
539
+		//inner date query
540
+		$inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table ";
541
+		$inner_where = " WHERE";
542
+		//exclude events not authored by user if permissions in effect
543
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
544
+			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
545
+			$inner_where .= " post_author = " . get_current_user_id() . " AND";
546
+		}
547
+		$inner_where .= " REG_date >= '$sql_date'";
548
+		$inner_date_query .= $inner_where;
549
+		//build main query
550
+		$select = "SELECT Event.post_title as Registration_Event, ";
551
+		$join = '';
552
+		$join_parts = array();
553
+		$select_parts = array();
554
+		//loop through registration stati to do parts for each status.
555
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
556
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
557
+				continue;
558
+			}
559
+			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
560
+			$join_parts[] = "$registration_table AS $STS_code ON $STS_code.EVT_ID = dates.EVT_ID AND $STS_code.STS_ID = '$STS_ID' AND $STS_code.REG_date = dates.REG_date";
561
+		}
562
+		//setup the selects
563
+		$select .= implode(', ', $select_parts);
564
+		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
565
+		//setup remaining joins
566
+		$join .= implode(" LEFT JOIN ", $join_parts);
567
+		//now put it all together
568
+		$query = $select . $join . ' GROUP BY Registration_Event';
569
+		//and execute
570
+		$results = $wpdb->get_results($query, ARRAY_A);
571
+		return $results;
572
+	}
573
+
574
+
575
+
576
+	/**
577
+	 * Returns the EE_Registration of the primary attendee on the transaction id provided
578
+	 *
579
+	 * @param int $TXN_ID
580
+	 * @return EE_Registration
581
+	 */
582
+	public function get_primary_registration_for_transaction_ID($TXN_ID = 0)
583
+	{
584
+		if ( ! $TXN_ID) {
585
+			return false;
586
+		}
587
+		return $this->get_one(array(
588
+			array(
589
+				'TXN_ID'    => $TXN_ID,
590
+				'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT,
591
+			),
592
+		));
593
+	}
594
+
595
+
596
+
597
+	/**
598
+	 *        get_event_registration_count
599
+	 *
600
+	 * @access public
601
+	 * @param int     $EVT_ID
602
+	 * @param boolean $for_incomplete_payments
603
+	 * @return int
604
+	 */
605
+	public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false)
606
+	{
607
+		// we only count approved registrations towards registration limits
608
+		$query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
609
+		if ($for_incomplete_payments) {
610
+			$query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
611
+		}
612
+		return $this->count($query_params);
613
+	}
614
+
615
+
616
+
617
+	/**
618
+	 * Deletes all registrations with no transactions. Note that this needs to be very efficient
619
+	 * and so it uses wpdb directly
620
+	 *
621
+	 * @global WPDB $wpdb
622
+	 * @return int number deleted
623
+	 */
624
+	public function delete_registrations_with_no_transaction()
625
+	{
626
+		/** @type WPDB $wpdb */
627
+		global $wpdb;
628
+		return $wpdb->query('DELETE r FROM '
629
+							. $this->table()
630
+							. ' r LEFT JOIN '
631
+							. EEM_Transaction::instance()->table()
632
+							. ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL');
633
+	}
634
+
635
+
636
+
637
+	/**
638
+	 *  Count registrations checked into (or out of) a datetime
639
+	 *
640
+	 * @param int     $DTT_ID     datetime ID
641
+	 * @param boolean $checked_in whether to count registrations checked IN or OUT
642
+	 * @return int
643
+	 */
644
+	public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true)
645
+	{
646
+		global $wpdb;
647
+		//subquery to get latest checkin
648
+		$query = $wpdb->prepare('SELECT '
649
+								. 'COUNT( DISTINCT checkins.REG_ID ) '
650
+								. 'FROM '
651
+								. EEM_Checkin::instance()
652
+											 ->table()
653
+								. ' AS checkins INNER JOIN'
654
+								. '( SELECT '
655
+								. 'max( CHK_timestamp ) AS latest_checkin, '
656
+								. 'REG_ID AS REG_ID '
657
+								. 'FROM '
658
+								. EEM_Checkin::instance()->table()
659
+								. ' '
660
+								. 'WHERE DTT_ID=%d '
661
+								. 'GROUP BY REG_ID'
662
+								. ') AS most_recent_checkin_per_reg '
663
+								. 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
664
+								. 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
665
+								. 'WHERE '
666
+								. 'checkins.CHK_in=%d', $DTT_ID, $checked_in);
667
+		return (int)$wpdb->get_var($query);
668
+	}
669
+
670
+
671
+
672
+	/**
673
+	 *  Count registrations checked into (or out of) an event.
674
+	 *
675
+	 * @param int     $EVT_ID     event ID
676
+	 * @param boolean $checked_in whether to count registrations checked IN or OUT
677
+	 * @return int
678
+	 */
679
+	public function count_registrations_checked_into_event($EVT_ID, $checked_in = true)
680
+	{
681
+		global $wpdb;
682
+		//subquery to get latest checkin
683
+		$query = $wpdb->prepare('SELECT '
684
+								. 'COUNT( DISTINCT checkins.REG_ID ) '
685
+								. 'FROM '
686
+								. EEM_Checkin::instance()
687
+											 ->table()
688
+								. ' AS checkins INNER JOIN'
689
+								. '( SELECT '
690
+								. 'max( CHK_timestamp ) AS latest_checkin, '
691
+								. 'REG_ID AS REG_ID '
692
+								. 'FROM '
693
+								. EEM_Checkin::instance()->table()
694
+								. ' AS c '
695
+								. 'INNER JOIN '
696
+								. EEM_Datetime::instance()->table()
697
+								. ' AS d '
698
+								. 'ON c.DTT_ID=d.DTT_ID '
699
+								. 'WHERE d.EVT_ID=%d '
700
+								. 'GROUP BY REG_ID'
701
+								. ') AS most_recent_checkin_per_reg '
702
+								. 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
703
+								. 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
704
+								. 'WHERE '
705
+								. 'checkins.CHK_in=%d', $EVT_ID, $checked_in);
706
+		return (int)$wpdb->get_var($query);
707
+	}
708
+
709
+
710
+
711
+	/**
712
+	 * The purpose of this method is to retrieve an array of
713
+	 * EE_Registration objects that represent the latest registration
714
+	 * for each ATT_ID given in the function argument.
715
+	 *
716
+	 * @param array $attendee_ids
717
+	 * @return EE_Registration[]
718
+	 */
719
+	public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array())
720
+	{
721
+		//first do a native wp_query to get the latest REG_ID's matching these attendees.
722
+		global $wpdb;
723
+		$registration_table = $wpdb->prefix . 'esp_registration';
724
+		$attendee_table = $wpdb->posts;
725
+		$attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids);
726
+		$attendee_ids = implode(',', $attendee_ids);
727
+		//first we do a query to get the registration ids
728
+		// (because a group by before order by causes the order by to be ignored.)
729
+		$registration_id_query = "
730 730
 			SELECT registrations.registration_ids as registration_id
731 731
 			FROM (
732 732
 				SELECT
@@ -740,23 +740,23 @@  discard block
 block discarded – undo
740 740
 			  ) AS registrations
741 741
 			  GROUP BY registrations.attendee_ids
742 742
 		";
743
-        $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A);
744
-        if (empty($registration_ids)) {
745
-            return array();
746
-        }
747
-        $ids_for_model_query = array();
748
-        //let's flatten the ids so they can be used in the model query.
749
-        foreach ($registration_ids as $registration_id) {
750
-            if (isset($registration_id['registration_id'])) {
751
-                $ids_for_model_query[] = $registration_id['registration_id'];
752
-            }
753
-        }
754
-        //construct query
755
-        $_where = array(
756
-            'REG_ID' => array('IN', $ids_for_model_query),
757
-        );
758
-        return $this->get_all(array($_where));
759
-    }
743
+		$registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A);
744
+		if (empty($registration_ids)) {
745
+			return array();
746
+		}
747
+		$ids_for_model_query = array();
748
+		//let's flatten the ids so they can be used in the model query.
749
+		foreach ($registration_ids as $registration_id) {
750
+			if (isset($registration_id['registration_id'])) {
751
+				$ids_for_model_query[] = $registration_id['registration_id'];
752
+			}
753
+		}
754
+		//construct query
755
+		$_where = array(
756
+			'REG_ID' => array('IN', $ids_for_model_query),
757
+		);
758
+		return $this->get_all(array($_where));
759
+	}
760 760
 
761 761
 
762 762
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
         //and the table hasn't actually been created, this could have an error
293 293
         /** @type WPDB $wpdb */
294 294
         global $wpdb;
295
-        if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
295
+        if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) {
296 296
             $results = $wpdb->get_results(
297 297
                 "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'"
298 298
             );
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             'group_by' => 'regDate',
430 430
             'order_by' => array('REG_date' => 'ASC'),
431 431
         ), OBJECT, array(
432
-            'regDate' => array('DATE(' . $query_interval . ')', '%s'),
432
+            'regDate' => array('DATE('.$query_interval.')', '%s'),
433 433
             'total'   => array('count(REG_ID)', '%d'),
434 434
         ));
435 435
         return $results;
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
     public function get_registrations_per_day_and_per_status_report($period = '-1 month')
449 449
     {
450 450
         global $wpdb;
451
-        $registration_table = $wpdb->prefix . 'esp_registration';
451
+        $registration_table = $wpdb->prefix.'esp_registration';
452 452
         $event_table = $wpdb->posts;
453 453
         $sql_date = date("Y-m-d H:i:s", strtotime($period));
454 454
         //prepare the query interval for displaying offset
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         //exclude events not authored by user if permissions in effect
460 460
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
461 461
             $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
462
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
462
+            $inner_where .= " post_author = ".get_current_user_id()." AND";
463 463
         }
464 464
         $inner_where .= " REG_date >= '$sql_date'";
465 465
         $inner_date_query .= $inner_where;
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         //setup the joins
483 483
         $join .= implode(" LEFT JOIN ", $join_parts);
484 484
         //now let's put it all together
485
-        $query = $select . $join . ' GROUP BY Registration_REG_date';
485
+        $query = $select.$join.' GROUP BY Registration_REG_date';
486 486
         //and execute it
487 487
         $results = $wpdb->get_results($query, ARRAY_A);
488 488
         return $results;
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
     public function get_registrations_per_event_and_per_status_report($period = '-1 month')
534 534
     {
535 535
         global $wpdb;
536
-        $registration_table = $wpdb->prefix . 'esp_registration';
536
+        $registration_table = $wpdb->prefix.'esp_registration';
537 537
         $event_table = $wpdb->posts;
538 538
         $sql_date = date("Y-m-d H:i:s", strtotime($period));
539 539
         //inner date query
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         //exclude events not authored by user if permissions in effect
543 543
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
544 544
             $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
545
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
545
+            $inner_where .= " post_author = ".get_current_user_id()." AND";
546 546
         }
547 547
         $inner_where .= " REG_date >= '$sql_date'";
548 548
         $inner_date_query .= $inner_where;
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
         //setup remaining joins
566 566
         $join .= implode(" LEFT JOIN ", $join_parts);
567 567
         //now put it all together
568
-        $query = $select . $join . ' GROUP BY Registration_Event';
568
+        $query = $select.$join.' GROUP BY Registration_Event';
569 569
         //and execute
570 570
         $results = $wpdb->get_results($query, ARRAY_A);
571 571
         return $results;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
                                 . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
665 665
                                 . 'WHERE '
666 666
                                 . 'checkins.CHK_in=%d', $DTT_ID, $checked_in);
667
-        return (int)$wpdb->get_var($query);
667
+        return (int) $wpdb->get_var($query);
668 668
     }
669 669
 
670 670
 
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
                                 . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
704 704
                                 . 'WHERE '
705 705
                                 . 'checkins.CHK_in=%d', $EVT_ID, $checked_in);
706
-        return (int)$wpdb->get_var($query);
706
+        return (int) $wpdb->get_var($query);
707 707
     }
708 708
 
709 709
 
@@ -720,9 +720,9 @@  discard block
 block discarded – undo
720 720
     {
721 721
         //first do a native wp_query to get the latest REG_ID's matching these attendees.
722 722
         global $wpdb;
723
-        $registration_table = $wpdb->prefix . 'esp_registration';
723
+        $registration_table = $wpdb->prefix.'esp_registration';
724 724
         $attendee_table = $wpdb->posts;
725
-        $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids);
725
+        $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int) $attendee_ids);
726 726
         $attendee_ids = implode(',', $attendee_ids);
727 727
         //first we do a query to get the registration ids
728 728
         // (because a group by before order by causes the order by to be ignored.)
Please login to merge, or discard this patch.
core/helpers/EEH_Event_Query.helper.php 1 patch
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function add_query_filters() {
87 87
 		//add query filters
88
-		add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 );
88
+		add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1);
89 89
 	}
90 90
 
91 91
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @param \WP_Query $WP_Query
98 98
 	 * @return bool
99 99
 	 */
100
-	public static function apply_query_filters( WP_Query $WP_Query ) {
101
-		return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) ||  apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false;
100
+	public static function apply_query_filters(WP_Query $WP_Query) {
101
+		return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false;
102 102
 	}
103 103
 
104 104
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 * @access    public
109 109
 	 * @param \WP_Query $WP_Query
110 110
 	 */
111
-	public static function filter_query_parts( WP_Query $WP_Query ) {
111
+	public static function filter_query_parts(WP_Query $WP_Query) {
112 112
 		//ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in.
113
-		if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) {
113
+		if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) {
114 114
 			// build event list query
115
-			add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 );
116
-			add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 );
117
-			add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 );
118
-			add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 );
119
-			add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 );
115
+			add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2);
116
+			add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2);
117
+			add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2);
118
+			add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2);
119
+			add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2);
120 120
 		}
121 121
 	}
122 122
 
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 	 * @param string $orderby
132 132
 	 * @param string $sort
133 133
 	 */
134
-	public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) {
134
+	public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') {
135 135
 		self::$_query_params = array();
136
-		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month );
137
-		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category );
138
-		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired );
139
-		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby );
140
-		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort );
136
+		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month);
137
+		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category);
138
+		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired);
139
+		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby);
140
+		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort);
141 141
 	}
142 142
 
143 143
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @param string $month
150 150
 	 * @return    string
151 151
 	 */
152
-	private static function _display_month( $month = '' ) {
153
-		return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month;
152
+	private static function _display_month($month = '') {
153
+		return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month;
154 154
 	}
155 155
 
156 156
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @param string $category
163 163
 	 * @return    string
164 164
 	 */
165
-	private static function _event_category_slug( $category = '' ) {
166
-		return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category;
165
+	private static function _event_category_slug($category = '') {
166
+		return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category;
167 167
 	}
168 168
 
169 169
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 * @param bool $show_expired
176 176
 	 * @return    boolean
177 177
 	 */
178
-	private static function _show_expired( $show_expired = FALSE ) {
178
+	private static function _show_expired($show_expired = FALSE) {
179 179
 		// override default expired option if set via filter
180
-		$_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired;
181
-		return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN );
180
+		$_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired;
181
+		return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN);
182 182
 	}
183 183
 
184 184
 
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
 	 * @param    string $orderby
191 191
 	 * @return    array
192 192
 	 */
193
-	private static function _orderby( $orderby = 'start_date' ) {
194
-		$event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby;
195
-		$event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby );
196
-		$event_query_orderby = array_map( 'trim', $event_query_orderby );
193
+	private static function _orderby($orderby = 'start_date') {
194
+		$event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby;
195
+		$event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby);
196
+		$event_query_orderby = array_map('trim', $event_query_orderby);
197 197
 		return $event_query_orderby;
198 198
 	}
199 199
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @param string $sort
207 207
 	 * @return    array
208 208
 	 */
209
-	private static function _sort( $sort = 'ASC' ) {
210
-		$sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort;
211
-		return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC';
209
+	private static function _sort($sort = 'ASC') {
210
+		$sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort;
211
+		return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC';
212 212
 	}
213 213
 
214 214
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return array   array of clauses
223 223
 	 */
224
-	public static function posts_clauses( $clauses, WP_Query $wp_query ) {
225
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
224
+	public static function posts_clauses($clauses, WP_Query $wp_query) {
225
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
226 226
 			global $wpdb;
227
-			$clauses['groupby'] = $wpdb->posts . '.ID ';
227
+			$clauses['groupby'] = $wpdb->posts.'.ID ';
228 228
 		}
229 229
 		return $clauses;
230 230
 	}
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	 * @param WP_Query $wp_query
240 240
 	 * @return    string
241 241
 	 */
242
-	public static function posts_fields( $SQL, WP_Query $wp_query ) {
243
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
242
+	public static function posts_fields($SQL, WP_Query $wp_query) {
243
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
244 244
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
245
-			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby );
245
+			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby);
246 246
 		}
247 247
 		return $SQL;
248 248
 	}
@@ -257,29 +257,29 @@  discard block
 block discarded – undo
257 257
 	 * @internal  param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
258 258
 	 * @return    string
259 259
 	 */
260
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
261
-		$SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ;
262
-		foreach( (array)$orderby_params as $orderby ) {
263
-			switch ( $orderby ) {
260
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
261
+		$SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date ';
262
+		foreach ((array) $orderby_params as $orderby) {
263
+			switch ($orderby) {
264 264
 
265 265
 				case 'ticket_start' :
266
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ;
266
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date';
267 267
 					break;
268 268
 
269 269
 				case 'ticket_end' :
270
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ;
270
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date';
271 271
 					break;
272 272
 
273 273
 				case 'venue_title' :
274
-					$SQL .= ', Venue.post_title AS venue_title' ;
274
+					$SQL .= ', Venue.post_title AS venue_title';
275 275
 					break;
276 276
 
277 277
 				case 'city' :
278
-					$SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ;
278
+					$SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city';
279 279
 					break;
280 280
 
281 281
 				case 'state' :
282
-					$SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ;
282
+					$SQL .= ', '.EEM_State::instance()->table().'.STA_name';
283 283
 					break;
284 284
 
285 285
 			}
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 	 * @param WP_Query $wp_query
298 298
 	 * @return    string
299 299
 	 */
300
-	public static function posts_join( $SQL = '', WP_Query $wp_query ) {
301
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
300
+	public static function posts_join($SQL = '', WP_Query $wp_query) {
301
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
302 302
 			// Category
303
-			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired );
304
-			$SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category );
305
-			$SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby );
303
+			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired);
304
+			$SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category);
305
+			$SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby);
306 306
 		}
307 307
 		return $SQL;
308 308
 	}
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
 	 * @param    boolean $show_expired if TRUE, then displayed past events
318 318
 	 * @return string
319 319
 	 */
320
-	public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) {
321
-		if ( ! $show_expired ) {
322
-			$join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
323
-			if ( strpos( $SQL, $join ) === FALSE ) {
324
-				$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) ';
320
+	public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) {
321
+		if ( ! $show_expired) {
322
+			$join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
323
+			if (strpos($SQL, $join) === FALSE) {
324
+				$SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) ';
325 325
 			}
326 326
 		}
327 327
 		return $SQL;
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	 * @param 	string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
338 338
 	 * @return 	string
339 339
 	 */
340
-	public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) {
341
-		if ( ! empty( $join_terms ) ) {
340
+	public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') {
341
+		if ( ! empty($join_terms)) {
342 342
 			global $wpdb;
343 343
 			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
344 344
 			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
 	 * @param 	array $orderby_params
359 359
 	 * @return 	string
360 360
 	 */
361
-	public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) {
362
-		foreach ( (array)$orderby_params as $orderby ) {
363
-			switch ( $orderby ) {
361
+	public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) {
362
+		foreach ((array) $orderby_params as $orderby) {
363
+			switch ($orderby) {
364 364
 				case 'ticket_start' :
365 365
 				case 'ticket_end' :
366
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() );
367
-					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )';
366
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name());
367
+					$SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )';
368 368
 					break;
369 369
 				case 'venue_title' :
370 370
 				case 'city' :
371
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
371
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
372 372
 					break;
373 373
 				case 'state' :
374
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
375
-					$SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL );
374
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
375
+					$SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL);
376 376
 					break;
377 377
 				case 'start_date' :
378 378
 				default :
379
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' );
379
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID');
380 380
 					break;
381 381
 
382 382
 			}
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 	 * @param string $join
395 395
 	 * @return string
396 396
 	 */
397
-	protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) {
398
-		if ( ! empty( $join )) {
399
-			$join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
400
-			if ( strpos( $SQL, $join ) === FALSE ) {
401
-				return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )';
397
+	protected static function _posts_join_for_datetime($SQL = '', $join = '') {
398
+		if ( ! empty($join)) {
399
+			$join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
400
+			if (strpos($SQL, $join) === FALSE) {
401
+				return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )';
402 402
 			}
403 403
 		}
404 404
 		return '';
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 	 * @param string $SQL
414 414
 	 * @return string
415 415
 	 */
416
-	protected static function _posts_join_for_event_venue( $SQL = '' ) {
416
+	protected static function _posts_join_for_event_venue($SQL = '') {
417 417
 		// Event Venue table name
418 418
 		$event_venue_table = EEM_Event_Venue::instance()->table();
419 419
 		// generate conditions for:  Event <=> Event Venue  JOIN clause
420
-		$event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name();
420
+		$event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name();
421 421
 		// don't add joins if they have already been added
422
-		if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) {
422
+		if (strpos($SQL, $event_to_event_venue_join) === FALSE) {
423 423
 			// Venue table name
424 424
 			$venue_table = EEM_Venue::instance()->table();
425 425
 			// Venue table pk
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 			$venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )";
433 433
 			// generate JOIN clause for: Venue <=> Venue Meta
434 434
 			$venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )";
435
-			unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table );
435
+			unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table);
436 436
 			return $venue_SQL;
437 437
 		}
438
-		unset( $event_venue_table, $event_to_event_venue_join );
438
+		unset($event_venue_table, $event_to_event_venue_join);
439 439
 		return '';
440 440
 	}
441 441
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 * @param string $SQL
449 449
 	 * @return string
450 450
 	 */
451
-	protected static function _posts_join_for_venue_state( $SQL = '' ) {
451
+	protected static function _posts_join_for_venue_state($SQL = '') {
452 452
 		// Venue Meta table name
453 453
 		$venue_meta_table = EEM_Venue::instance()->second_table();
454 454
 		// State table name
@@ -456,16 +456,16 @@  discard block
 block discarded – undo
456 456
 		// State table pk
457 457
 		$state_table_pk = EEM_State::instance()->primary_key_name();
458 458
 		// verify vars
459
-		if ( $venue_meta_table && $state_table && $state_table_pk ) {
459
+		if ($venue_meta_table && $state_table && $state_table_pk) {
460 460
 			// like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID
461 461
 			$join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk";
462 462
 			// don't add join if it has already been added
463
-			if ( strpos( $SQL, $join ) === FALSE ) {
464
-				unset( $state_table_pk, $venue_meta_table, $venue_table_pk );
463
+			if (strpos($SQL, $join) === FALSE) {
464
+				unset($state_table_pk, $venue_meta_table, $venue_table_pk);
465 465
 				return " LEFT JOIN $state_table ON ( $join )";
466 466
 			}
467 467
 		}
468
-		unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk );
468
+		unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk);
469 469
 		return '';
470 470
 	}
471 471
 
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 	 * @param WP_Query $wp_query
480 480
 	 * @return    string
481 481
 	 */
482
-	public static function posts_where( $SQL = '', WP_Query $wp_query ) {
483
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
482
+	public static function posts_where($SQL = '', WP_Query $wp_query) {
483
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
484 484
 			// Show Expired ?
485
-			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired  );
485
+			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired);
486 486
 			// Category
487
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category  );
487
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category);
488 488
 			// Start Date
489
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month );
489
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month);
490 490
 		}
491 491
 		return $SQL;
492 492
 	}
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param    boolean $show_expired if TRUE, then displayed past events
501 501
 	 * @return    string
502 502
 	 */
503
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
504
-		return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time( 'mysql', TRUE ) . '\' ' : '';
503
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
504
+		return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > \''.current_time('mysql', TRUE).'\' ' : '';
505 505
 	}
506 506
 
507 507
 
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 	 * @param    boolean $event_category_slug
514 514
 	 * @return    string
515 515
 	 */
516
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
516
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
517 517
 		global $wpdb;
518
-		return ! empty( $event_category_slug ) ? " AND {$wpdb->terms}.slug = '{$event_category_slug}' " : '';
518
+		return ! empty($event_category_slug) ? " AND {$wpdb->terms}.slug = '{$event_category_slug}' " : '';
519 519
 	}
520 520
 
521 521
 
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 	 * @param    boolean $month
528 528
 	 * @return    string
529 529
 	 */
530
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
530
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
531 531
 		$SQL = '';
532
-		if ( ! empty( $month ) ) {
532
+		if ( ! empty($month)) {
533 533
 			$datetime_table = EEM_Datetime::instance()->table();
534 534
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
535
-			$SQL = " AND {$datetime_table}.DTT_EVT_start <= '" . date( 'Y-m-t 23:59:59', strtotime( $month ) ) . "'";
535
+			$SQL = " AND {$datetime_table}.DTT_EVT_start <= '".date('Y-m-t 23:59:59', strtotime($month))."'";
536 536
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
537
-			$SQL .= " AND {$datetime_table}.DTT_EVT_end >= '" . date( 'Y-m-01 0:0:00', strtotime( $month ) ) . "' ";
537
+			$SQL .= " AND {$datetime_table}.DTT_EVT_end >= '".date('Y-m-01 0:0:00', strtotime($month))."' ";
538 538
 		}
539 539
 		return $SQL;
540 540
 	}
@@ -549,9 +549,9 @@  discard block
 block discarded – undo
549 549
 	 * @param WP_Query $wp_query
550 550
 	 * @return    string
551 551
 	 */
552
-	public static function posts_orderby( $SQL = '', WP_Query $wp_query ) {
553
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
554
-			$SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort );
552
+	public static function posts_orderby($SQL = '', WP_Query $wp_query) {
553
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
554
+			$SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort);
555 555
 		}
556 556
 		return $SQL;
557 557
 	}
@@ -582,63 +582,63 @@  discard block
 block discarded – undo
582 582
 	 * @param string     $sort
583 583
 	 * @return string
584 584
 	 */
585
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
585
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
586 586
 		global $wpdb;
587 587
 		$SQL = '';
588 588
 		$counter = 0;
589 589
 		//make sure 'orderby' is set in query params
590
-		if ( ! isset( self::$_query_params['orderby'] )) {
590
+		if ( ! isset(self::$_query_params['orderby'])) {
591 591
 			self::$_query_params['orderby'] = array();
592 592
 		}
593 593
 		// loop thru $orderby_params (type cast as array)
594
-		foreach ( (array)$orderby_params as $orderby ) {
594
+		foreach ((array) $orderby_params as $orderby) {
595 595
 			// check if we have already added this param
596
-			if ( isset( self::$_query_params['orderby'][ $orderby ] )) {
596
+			if (isset(self::$_query_params['orderby'][$orderby])) {
597 597
 				// if so then remove from the $orderby_params so that the count() method below is accurate
598
-				unset( $orderby_params[ $orderby ] );
598
+				unset($orderby_params[$orderby]);
599 599
 				// then bump ahead to the next param
600 600
 				continue;
601 601
 			}
602 602
 			// this will ad a comma depending on whether this is the first or last param
603
-			$glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', ';
603
+			$glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', ';
604 604
 			// ok what's we dealing with?
605
-			switch ( $orderby ) {
605
+			switch ($orderby) {
606 606
 				case 'id' :
607 607
 				case 'ID' :
608
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
608
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
609 609
 					break;
610 610
 				case 'end_date' :
611
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
611
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
612 612
 					break;
613 613
 				case 'event_name' :
614
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
614
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
615 615
 					break;
616 616
 				case 'category_slug' :
617
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
617
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
618 618
 					break;
619 619
 				case 'ticket_start' :
620
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
620
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
621 621
 					break;
622 622
 				case 'ticket_end' :
623
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
623
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
624 624
 					break;
625 625
 				case 'venue_title' :
626
-					$SQL .= $glue . 'venue_title ' . $sort;
626
+					$SQL .= $glue.'venue_title '.$sort;
627 627
 					break;
628 628
 				case 'city' :
629
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
629
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
630 630
 					break;
631 631
 				case 'state' :
632
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
632
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
633 633
 					break;
634 634
 				case 'start_date' :
635 635
 				default :
636
-					$SQL .= $glue . ' event_start_date ' . $sort;
636
+					$SQL .= $glue.' event_start_date '.$sort;
637 637
 					break;
638 638
 			}
639 639
 			// add to array of orderby params that have been added
640
-			self::$_query_params['orderby'][ $orderby ] = TRUE;
641
-			$counter ++;
640
+			self::$_query_params['orderby'][$orderby] = TRUE;
641
+			$counter++;
642 642
 		}
643 643
 		return $SQL;
644 644
 	}
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page.core.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
                 && $most_recent_migration->is_broken()
234 234
             )
235 235
         ) {
236
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
236
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php';
237 237
             $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
238 238
             $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
239 239
                                                                                         'success' => '0',
240 240
             ), EE_MAINTENANCE_ADMIN_URL);
241 241
         } elseif ($addons_should_be_upgraded_first) {
242
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
242
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php';
243 243
         } else {
244 244
             if ($most_recent_migration
245 245
                 && $most_recent_migration instanceof EE_Data_Migration_Script_Base
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                         $new_version, $plugin_slug) : null,
267 267
                 ));
268 268
             }
269
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
269
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php';
270 270
             $this->_template_args = array_merge(
271 271
                 $this->_template_args,
272 272
                 array(
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
                 'status_completed'                 => EE_Data_Migration_Manager::status_completed,
304 304
             ));
305 305
         }
306
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
306
+        $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration
307 307
         //now render the migration options part, and put it in a variable
308 308
         $migration_options_template_file = apply_filters(
309 309
             'FHEE__ee_migration_page__migration_options_template',
310
-            EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
310
+            EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee4.template.php'
311 311
         );
312
-        $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true);
312
+        $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args, true);
313 313
         $this->_template_args['migration_options_html'] = $migration_options_html;
314 314
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
315 315
             $this->_template_args, true);
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      */
368 368
     public function _data_reset_and_delete()
369 369
     {
370
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
370
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php';
371 371
         $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
372 372
             'reset_capabilities',
373 373
             'reset_capabilities',
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      */
423 423
     public function _system_status()
424 424
     {
425
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
425
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php';
426 426
         $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
427 427
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
428 428
             $this->_template_args, true);
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
         try {
440 440
             $success = wp_mail(EE_SUPPORT_EMAIL,
441 441
                 'Migration Crash Report',
442
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
442
+                $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true),
443 443
                 array(
444 444
                     "from:$from_name<$from>",
445 445
                     //					'content-type:text/html charset=UTF-8'
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             EE_MAINTENANCE_ADMIN_URL);
475 475
         $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
476 476
             EE_MAINTENANCE_ADMIN_URL);
477
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
477
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php';
478 478
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
479 479
             $this->_template_args, true);
480 480
         $this->display_admin_page_with_sidebar();
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
         wp_enqueue_script('ee_admin_js');
576 576
 //		wp_enqueue_media();
577 577
 //		wp_enqueue_script('media-upload');
578
-        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
578
+        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'),
579 579
             EVENT_ESPRESSO_VERSION, true);
580
-        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
580
+        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(),
581 581
             EVENT_ESPRESSO_VERSION);
582 582
         wp_enqueue_style('espresso_maintenance');
583 583
     }
Please login to merge, or discard this patch.
Indentation   +551 added lines, -551 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 
@@ -28,571 +28,571 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    public function __construct($routing = true)
32
-    {
33
-        parent::__construct($routing);
34
-    }
35
-
36
-
37
-
38
-    protected function _init_page_props()
39
-    {
40
-        $this->page_slug = EE_MAINTENANCE_PG_SLUG;
41
-        $this->page_label = EE_MAINTENANCE_LABEL;
42
-        $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;
43
-        $this->_admin_base_path = EE_MAINTENANCE_ADMIN;
44
-    }
45
-
46
-
47
-
48
-    protected function _ajax_hooks()
49
-    {
50
-        add_action('wp_ajax_migration_step', array($this, 'migration_step'));
51
-        add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran'));
52
-    }
53
-
54
-
55
-
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
-        $this->_labels = array(
60
-            'buttons' => array(
61
-                'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
62
-            ),
63
-        );
64
-    }
65
-
66
-
67
-
68
-    protected function _set_page_routes()
69
-    {
70
-        $this->_page_routes = array(
71
-            'default'                             => array(
72
-                'func'       => '_maintenance',
73
-                'capability' => 'manage_options',
74
-            ),
75
-            'change_maintenance_level'            => array(
76
-                'func'       => '_change_maintenance_level',
77
-                'capability' => 'manage_options',
78
-                'noheader'   => true,
79
-            ),
80
-            'system_status'                       => array(
81
-                'func'       => '_system_status',
82
-                'capability' => 'manage_options',
83
-            ),
84
-            'send_migration_crash_report'         => array(
85
-                'func'       => '_send_migration_crash_report',
86
-                'capability' => 'manage_options',
87
-                'noheader'   => true,
88
-            ),
89
-            'confirm_migration_crash_report_sent' => array(
90
-                'func'       => '_confirm_migration_crash_report_sent',
91
-                'capability' => 'manage_options',
92
-            ),
93
-            'data_reset'                          => array(
94
-                'func'       => '_data_reset_and_delete',
95
-                'capability' => 'manage_options',
96
-            ),
97
-            'reset_db'                            => array(
98
-                'func'       => '_reset_db',
99
-                'capability' => 'manage_options',
100
-                'noheader'   => true,
101
-                'args'       => array('nuke_old_ee4_data' => true),
102
-            ),
103
-            'start_with_fresh_ee4_db'             => array(
104
-                'func'       => '_reset_db',
105
-                'capability' => 'manage_options',
106
-                'noheader'   => true,
107
-                'args'       => array('nuke_old_ee4_data' => false),
108
-            ),
109
-            'delete_db'                           => array(
110
-                'func'       => '_delete_db',
111
-                'capability' => 'manage_options',
112
-                'noheader'   => true,
113
-            ),
114
-            'rerun_migration_from_ee3'            => array(
115
-                'func'       => '_rerun_migration_from_ee3',
116
-                'capability' => 'manage_options',
117
-                'noheader'   => true,
118
-            ),
119
-            'reset_capabilities'                  => array(
120
-                'func'       => '_reset_capabilities',
121
-                'capability' => 'manage_options',
122
-                'noheader'   => true,
123
-            ),
124
-            'reattempt_migration'                 => array(
125
-                'func'       => '_reattempt_migration',
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            ),
129
-        );
130
-    }
131
-
132
-
133
-
134
-    protected function _set_page_config()
135
-    {
136
-        $this->_page_config = array(
137
-            'default'       => array(
138
-                'nav'           => array(
139
-                    'label' => esc_html__('Maintenance', 'event_espresso'),
140
-                    'order' => 10,
141
-                ),
142
-                'require_nonce' => false,
143
-            ),
144
-            'data_reset'    => array(
145
-                'nav'           => array(
146
-                    'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
147
-                    'order' => 20,
148
-                ),
149
-                'require_nonce' => false,
150
-            ),
151
-            'system_status' => array(
152
-                'nav'           => array(
153
-                    'label' => esc_html__("System Information", "event_espresso"),
154
-                    'order' => 30,
155
-                ),
156
-                'require_nonce' => false,
157
-            ),
158
-        );
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * default maintenance page. If we're in maintenance mode level 2, then we need to show
165
-     * the migration scripts and all that UI.
166
-     */
167
-    public function _maintenance()
168
-    {
169
-        //it all depends if we're in maintenance model level 1 (frontend-only) or
170
-        //level 2 (everything except maintenance page)
171
-        try {
172
-            //get the current maintenance level and check if
173
-            //we are removed
174
-            $mm = EE_Maintenance_Mode::instance()->level();
175
-            $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
176
-            if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
177
-                //we just took the site out of maintenance mode, so notify the user.
178
-                //unfortunately this message appears to be echoed on the NEXT page load...
179
-                //oh well, we should really be checking for this on addon deactivation anyways
180
-                EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required',
181
-                    'event_espresso'));
182
-                $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false);
183
-            }
184
-            //in case an exception is thrown while trying to handle migrations
185
-            switch (EE_Maintenance_Mode::instance()->level()) {
186
-                case EE_Maintenance_Mode::level_0_not_in_maintenance:
187
-                case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
188
-                    $show_maintenance_switch = true;
189
-                    $show_backup_db_text = false;
190
-                    $show_migration_progress = false;
191
-                    $script_names = array();
192
-                    $addons_should_be_upgraded_first = false;
193
-                    break;
194
-                case EE_Maintenance_Mode::level_2_complete_maintenance:
195
-                    $show_maintenance_switch = false;
196
-                    $show_migration_progress = true;
197
-                    if (isset($this->_req_data['continue_migration'])) {
198
-                        $show_backup_db_text = false;
199
-                    } else {
200
-                        $show_backup_db_text = true;
201
-                    }
202
-                    $scripts_needing_to_run = EE_Data_Migration_Manager::instance()
203
-                                                                       ->check_for_applicable_data_migration_scripts();
204
-                    $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();
205
-                    $script_names = array();
206
-                    $current_script = null;
207
-                    foreach ($scripts_needing_to_run as $script) {
208
-                        if ($script instanceof EE_Data_Migration_Script_Base) {
209
-                            if ( ! $current_script) {
210
-                                $current_script = $script;
211
-                                $current_script->migration_page_hooks();
212
-                            }
213
-                            $script_names[] = $script->pretty_name();
214
-                        }
215
-                    }
216
-                    break;
217
-            }
218
-            $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
219
-            $exception_thrown = false;
220
-        } catch (EE_Error $e) {
221
-            EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
222
-            //now, just so we can display the page correctly, make a error migration script stage object
223
-            //and also put the error on it. It only persists for the duration of this request
224
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
225
-            $most_recent_migration->add_error($e->getMessage());
226
-            $exception_thrown = true;
227
-        }
228
-        $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();
229
-        $current_db_state = str_replace('.decaf', '', $current_db_state);
230
-        if ($exception_thrown
231
-            || ($most_recent_migration
232
-                && $most_recent_migration instanceof EE_Data_Migration_Script_Base
233
-                && $most_recent_migration->is_broken()
234
-            )
235
-        ) {
236
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
237
-            $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
238
-            $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
239
-                                                                                        'success' => '0',
240
-            ), EE_MAINTENANCE_ADMIN_URL);
241
-        } elseif ($addons_should_be_upgraded_first) {
242
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
243
-        } else {
244
-            if ($most_recent_migration
245
-                && $most_recent_migration instanceof EE_Data_Migration_Script_Base
246
-                && $most_recent_migration->can_continue()
247
-            ) {
248
-                $show_backup_db_text = false;
249
-                $show_continue_current_migration_script = true;
250
-                $show_most_recent_migration = true;
251
-            } elseif (isset($this->_req_data['continue_migration'])) {
252
-                $show_most_recent_migration = true;
253
-                $show_continue_current_migration_script = false;
254
-            } else {
255
-                $show_most_recent_migration = false;
256
-                $show_continue_current_migration_script = false;
257
-            }
258
-            if (isset($current_script)) {
259
-                $migrates_to = $current_script->migrates_to_version();
260
-                $plugin_slug = $migrates_to['slug'];
261
-                $new_version = $migrates_to['version'];
262
-                $this->_template_args = array_merge($this->_template_args, array(
263
-                    'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"),
264
-                        isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug),
265
-                    'next_db_state'    => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),
266
-                        $new_version, $plugin_slug) : null,
267
-                ));
268
-            }
269
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
270
-            $this->_template_args = array_merge(
271
-                $this->_template_args,
272
-                array(
273
-                    'show_most_recent_migration'             => $show_most_recent_migration,
274
-                    //flag for showing the most recent migration's status and/or errors
275
-                    'show_migration_progress'                => $show_migration_progress,
276
-                    //flag for showing the option to run migrations and see their progress
277
-                    'show_backup_db_text'                    => $show_backup_db_text,
278
-                    //flag for showing text telling the user to backup their DB
279
-                    'show_maintenance_switch'                => $show_maintenance_switch,
280
-                    //flag for showing the option to change maintenance mode between levels 0 and 1
281
-                    'script_names'                           => $script_names,
282
-                    //array of names of scripts that have run
283
-                    'show_continue_current_migration_script' => $show_continue_current_migration_script,
284
-                    //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
285
-                    'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
286
-                        EE_MAINTENANCE_ADMIN_URL),
287
-                    'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
288
-                        EE_MAINTENANCE_ADMIN_URL),
289
-                    'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'),
290
-                        EE_MAINTENANCE_ADMIN_URL),
291
-                    'ultimate_db_state'                      => sprintf(__("EE%s", 'event_espresso'),
292
-                        espresso_version()),
293
-                )
294
-            );
295
-            //make sure we have the form fields helper available. It usually is, but sometimes it isn't
296
-            //localize script stuff
297
-            wp_localize_script('ee-maintenance', 'ee_maintenance', array(
298
-                'migrating'                        => esc_html__("Updating Database...", "event_espresso"),
299
-                'next'                             => esc_html__("Next", "event_espresso"),
300
-                'fatal_error'                      => esc_html__("A Fatal Error Has Occurred", "event_espresso"),
301
-                'click_next_when_ready'            => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed",
302
-                    "event_espresso"),
303
-                'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
304
-                'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
305
-                'status_completed'                 => EE_Data_Migration_Manager::status_completed,
306
-            ));
307
-        }
308
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
309
-        //now render the migration options part, and put it in a variable
310
-        $migration_options_template_file = apply_filters(
311
-            'FHEE__ee_migration_page__migration_options_template',
312
-            EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
313
-        );
314
-        $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true);
315
-        $this->_template_args['migration_options_html'] = $migration_options_html;
316
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
317
-            $this->_template_args, true);
318
-        $this->display_admin_page_with_sidebar();
319
-    }
320
-
321
-
322
-
323
-    /**
324
-     * returns JSON and executes another step of the currently-executing data migration (called via ajax)
325
-     */
326
-    public function migration_step()
327
-    {
328
-        $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();
329
-        $this->_return_json();
330
-    }
331
-
332
-
333
-
334
-    /**
335
-     * Can be used by js when it notices a response with HTML in it in order
336
-     * to log the malformed response
337
-     */
338
-    public function add_error_to_migrations_ran()
339
-    {
340
-        EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);
341
-        $this->_template_args['data'] = array('ok' => true);
342
-        $this->_return_json();
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * changes the maintenance level, provided there are still no migration scripts that shoudl run
349
-     */
350
-    public function _change_maintenance_level()
351
-    {
352
-        $new_level = intval($this->_req_data['maintenance_mode_level']);
353
-        if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
354
-            EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);
355
-            $success = true;
356
-        } else {
357
-            EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
358
-            $success = false;
359
-        }
360
-        $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * a tab with options for resetting and/or deleting EE data
367
-     *
368
-     * @throws \EE_Error
369
-     */
370
-    public function _data_reset_and_delete()
371
-    {
372
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
373
-        $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
374
-            'reset_capabilities',
375
-            'reset_capabilities',
376
-            array(),
377
-            'button button-primary',
378
-            '',
379
-            false
380
-        );
381
-        $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
382
-            array('action' => 'delete_db'),
383
-            EE_MAINTENANCE_ADMIN_URL
384
-        );
385
-        $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
386
-            array('action' => 'reset_db'),
387
-            EE_MAINTENANCE_ADMIN_URL
388
-        );
389
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
390
-            $this->_template_path,
391
-            $this->_template_args,
392
-            true
393
-        );
394
-        $this->display_admin_page_with_sidebar();
395
-    }
396
-
397
-
398
-
399
-    protected function _reset_capabilities()
400
-    {
401
-        EE_Registry::instance()->CAP->init_caps(true);
402
-        EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.',
403
-            'event_espresso'));
404
-        $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true);
405
-    }
406
-
407
-
408
-
409
-    /**
410
-     * resets the DMSs so we can attempt to continue migrating after a fatal error
411
-     * (only a good idea when someone has somehow tried ot fix whatever caused
412
-     * the fatal error in teh first place)
413
-     */
414
-    protected function _reattempt_migration()
415
-    {
416
-        EE_Data_Migration_Manager::instance()->reattempt();
417
-        $this->_redirect_after_action(false, '', '', array('action' => 'default'), true);
418
-    }
419
-
420
-
421
-
422
-    /**
423
-     * shows the big ol' System Information page
424
-     */
425
-    public function _system_status()
426
-    {
427
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
428
-        $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
429
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
430
-            $this->_template_args, true);
431
-        $this->display_admin_page_with_sidebar();
432
-    }
433
-
434
-
435
-
436
-    public function _send_migration_crash_report()
437
-    {
438
-        $from = $this->_req_data['from'];
439
-        $from_name = $this->_req_data['from_name'];
440
-        $body = $this->_req_data['body'];
441
-        try {
442
-            $success = wp_mail(EE_SUPPORT_EMAIL,
443
-                'Migration Crash Report',
444
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
445
-                array(
446
-                    "from:$from_name<$from>",
447
-                    //					'content-type:text/html charset=UTF-8'
448
-                ));
449
-        } catch (Exception $e) {
450
-            $success = false;
451
-        }
452
-        $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"),
453
-            esc_html__("sent", "event_espresso"),
454
-            array('success' => $success, 'action' => 'confirm_migration_crash_report_sent'));
455
-    }
456
-
457
-
458
-
459
-    public function _confirm_migration_crash_report_sent()
460
-    {
461
-        try {
462
-            $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
463
-        } catch (EE_Error $e) {
464
-            EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
465
-            //now, just so we can display the page correctly, make a error migration script stage object
466
-            //and also put the error on it. It only persists for the duration of this request
467
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
468
-            $most_recent_migration->add_error($e->getMessage());
469
-        }
470
-        $success = $this->_req_data['success'] == '1' ? true : false;
471
-        $this->_template_args['success'] = $success;
472
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;
473
-        $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
474
-            EE_MAINTENANCE_ADMIN_URL);
475
-        $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
476
-            EE_MAINTENANCE_ADMIN_URL);
477
-        $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
478
-            EE_MAINTENANCE_ADMIN_URL);
479
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
480
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
481
-            $this->_template_args, true);
482
-        $this->display_admin_page_with_sidebar();
483
-    }
484
-
485
-
486
-
487
-    /**
488
-     * Resets the entire EE4 database.
489
-     * Currently basically only sets up ee4 database for a fresh install- doesn't
490
-     * actually clean out the old wp options, or cpts (although does erase old ee table data)
491
-     *
492
-     * @param boolean $nuke_old_ee4_data controls whether or not we
493
-     *                                   destroy the old ee4 data, or just try initializing ee4 default data
494
-     */
495
-    public function _reset_db($nuke_old_ee4_data = true)
496
-    {
497
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
498
-        if ($nuke_old_ee4_data) {
499
-            EEH_Activation::delete_all_espresso_cpt_data();
500
-            EEH_Activation::delete_all_espresso_tables_and_data(false);
501
-            EEH_Activation::remove_cron_tasks();
502
-        }
503
-        //make sure when we reset the registry's config that it
504
-        //switches to using the new singleton
505
-        EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
506
-        EE_System::instance()->initialize_db_if_no_migrations_required(true);
507
-        EE_System::instance()->redirect_to_about_ee();
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * Deletes ALL EE tables, Records, and Options from the database.
514
-     */
515
-    public function _delete_db()
516
-    {
517
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
518
-        EEH_Activation::delete_all_espresso_cpt_data();
519
-        EEH_Activation::delete_all_espresso_tables_and_data();
520
-        EEH_Activation::remove_cron_tasks();
521
-        EEH_Activation::deactivate_event_espresso();
522
-        wp_safe_redirect(admin_url('plugins.php'));
523
-        exit;
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     * sets up EE4 to rerun the migrations from ee3 to ee4
530
-     */
531
-    public function _rerun_migration_from_ee3()
532
-    {
533
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
534
-        EEH_Activation::delete_all_espresso_cpt_data();
535
-        EEH_Activation::delete_all_espresso_tables_and_data(false);
536
-        //set the db state to something that will require migrations
537
-        update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
538
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
539
-        $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso'));
540
-    }
541
-
542
-
543
-
544
-    //none of the below group are currently used for Gateway Settings
545
-    protected function _add_screen_options()
546
-    {
547
-    }
548
-
549
-
550
-
551
-    protected function _add_feature_pointers()
552
-    {
553
-    }
554
-
31
+	public function __construct($routing = true)
32
+	{
33
+		parent::__construct($routing);
34
+	}
35
+
36
+
37
+
38
+	protected function _init_page_props()
39
+	{
40
+		$this->page_slug = EE_MAINTENANCE_PG_SLUG;
41
+		$this->page_label = EE_MAINTENANCE_LABEL;
42
+		$this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;
43
+		$this->_admin_base_path = EE_MAINTENANCE_ADMIN;
44
+	}
45
+
46
+
47
+
48
+	protected function _ajax_hooks()
49
+	{
50
+		add_action('wp_ajax_migration_step', array($this, 'migration_step'));
51
+		add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran'));
52
+	}
53
+
54
+
55
+
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
+		$this->_labels = array(
60
+			'buttons' => array(
61
+				'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
62
+			),
63
+		);
64
+	}
65
+
66
+
67
+
68
+	protected function _set_page_routes()
69
+	{
70
+		$this->_page_routes = array(
71
+			'default'                             => array(
72
+				'func'       => '_maintenance',
73
+				'capability' => 'manage_options',
74
+			),
75
+			'change_maintenance_level'            => array(
76
+				'func'       => '_change_maintenance_level',
77
+				'capability' => 'manage_options',
78
+				'noheader'   => true,
79
+			),
80
+			'system_status'                       => array(
81
+				'func'       => '_system_status',
82
+				'capability' => 'manage_options',
83
+			),
84
+			'send_migration_crash_report'         => array(
85
+				'func'       => '_send_migration_crash_report',
86
+				'capability' => 'manage_options',
87
+				'noheader'   => true,
88
+			),
89
+			'confirm_migration_crash_report_sent' => array(
90
+				'func'       => '_confirm_migration_crash_report_sent',
91
+				'capability' => 'manage_options',
92
+			),
93
+			'data_reset'                          => array(
94
+				'func'       => '_data_reset_and_delete',
95
+				'capability' => 'manage_options',
96
+			),
97
+			'reset_db'                            => array(
98
+				'func'       => '_reset_db',
99
+				'capability' => 'manage_options',
100
+				'noheader'   => true,
101
+				'args'       => array('nuke_old_ee4_data' => true),
102
+			),
103
+			'start_with_fresh_ee4_db'             => array(
104
+				'func'       => '_reset_db',
105
+				'capability' => 'manage_options',
106
+				'noheader'   => true,
107
+				'args'       => array('nuke_old_ee4_data' => false),
108
+			),
109
+			'delete_db'                           => array(
110
+				'func'       => '_delete_db',
111
+				'capability' => 'manage_options',
112
+				'noheader'   => true,
113
+			),
114
+			'rerun_migration_from_ee3'            => array(
115
+				'func'       => '_rerun_migration_from_ee3',
116
+				'capability' => 'manage_options',
117
+				'noheader'   => true,
118
+			),
119
+			'reset_capabilities'                  => array(
120
+				'func'       => '_reset_capabilities',
121
+				'capability' => 'manage_options',
122
+				'noheader'   => true,
123
+			),
124
+			'reattempt_migration'                 => array(
125
+				'func'       => '_reattempt_migration',
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			),
129
+		);
130
+	}
131
+
132
+
133
+
134
+	protected function _set_page_config()
135
+	{
136
+		$this->_page_config = array(
137
+			'default'       => array(
138
+				'nav'           => array(
139
+					'label' => esc_html__('Maintenance', 'event_espresso'),
140
+					'order' => 10,
141
+				),
142
+				'require_nonce' => false,
143
+			),
144
+			'data_reset'    => array(
145
+				'nav'           => array(
146
+					'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
147
+					'order' => 20,
148
+				),
149
+				'require_nonce' => false,
150
+			),
151
+			'system_status' => array(
152
+				'nav'           => array(
153
+					'label' => esc_html__("System Information", "event_espresso"),
154
+					'order' => 30,
155
+				),
156
+				'require_nonce' => false,
157
+			),
158
+		);
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * default maintenance page. If we're in maintenance mode level 2, then we need to show
165
+	 * the migration scripts and all that UI.
166
+	 */
167
+	public function _maintenance()
168
+	{
169
+		//it all depends if we're in maintenance model level 1 (frontend-only) or
170
+		//level 2 (everything except maintenance page)
171
+		try {
172
+			//get the current maintenance level and check if
173
+			//we are removed
174
+			$mm = EE_Maintenance_Mode::instance()->level();
175
+			$placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
176
+			if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
177
+				//we just took the site out of maintenance mode, so notify the user.
178
+				//unfortunately this message appears to be echoed on the NEXT page load...
179
+				//oh well, we should really be checking for this on addon deactivation anyways
180
+				EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required',
181
+					'event_espresso'));
182
+				$this->_process_notices(array('page' => 'espresso_maintenance_settings'), false);
183
+			}
184
+			//in case an exception is thrown while trying to handle migrations
185
+			switch (EE_Maintenance_Mode::instance()->level()) {
186
+				case EE_Maintenance_Mode::level_0_not_in_maintenance:
187
+				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
188
+					$show_maintenance_switch = true;
189
+					$show_backup_db_text = false;
190
+					$show_migration_progress = false;
191
+					$script_names = array();
192
+					$addons_should_be_upgraded_first = false;
193
+					break;
194
+				case EE_Maintenance_Mode::level_2_complete_maintenance:
195
+					$show_maintenance_switch = false;
196
+					$show_migration_progress = true;
197
+					if (isset($this->_req_data['continue_migration'])) {
198
+						$show_backup_db_text = false;
199
+					} else {
200
+						$show_backup_db_text = true;
201
+					}
202
+					$scripts_needing_to_run = EE_Data_Migration_Manager::instance()
203
+																	   ->check_for_applicable_data_migration_scripts();
204
+					$addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();
205
+					$script_names = array();
206
+					$current_script = null;
207
+					foreach ($scripts_needing_to_run as $script) {
208
+						if ($script instanceof EE_Data_Migration_Script_Base) {
209
+							if ( ! $current_script) {
210
+								$current_script = $script;
211
+								$current_script->migration_page_hooks();
212
+							}
213
+							$script_names[] = $script->pretty_name();
214
+						}
215
+					}
216
+					break;
217
+			}
218
+			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
219
+			$exception_thrown = false;
220
+		} catch (EE_Error $e) {
221
+			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
222
+			//now, just so we can display the page correctly, make a error migration script stage object
223
+			//and also put the error on it. It only persists for the duration of this request
224
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
225
+			$most_recent_migration->add_error($e->getMessage());
226
+			$exception_thrown = true;
227
+		}
228
+		$current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();
229
+		$current_db_state = str_replace('.decaf', '', $current_db_state);
230
+		if ($exception_thrown
231
+			|| ($most_recent_migration
232
+				&& $most_recent_migration instanceof EE_Data_Migration_Script_Base
233
+				&& $most_recent_migration->is_broken()
234
+			)
235
+		) {
236
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
237
+			$this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
238
+			$this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
239
+																						'success' => '0',
240
+			), EE_MAINTENANCE_ADMIN_URL);
241
+		} elseif ($addons_should_be_upgraded_first) {
242
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
243
+		} else {
244
+			if ($most_recent_migration
245
+				&& $most_recent_migration instanceof EE_Data_Migration_Script_Base
246
+				&& $most_recent_migration->can_continue()
247
+			) {
248
+				$show_backup_db_text = false;
249
+				$show_continue_current_migration_script = true;
250
+				$show_most_recent_migration = true;
251
+			} elseif (isset($this->_req_data['continue_migration'])) {
252
+				$show_most_recent_migration = true;
253
+				$show_continue_current_migration_script = false;
254
+			} else {
255
+				$show_most_recent_migration = false;
256
+				$show_continue_current_migration_script = false;
257
+			}
258
+			if (isset($current_script)) {
259
+				$migrates_to = $current_script->migrates_to_version();
260
+				$plugin_slug = $migrates_to['slug'];
261
+				$new_version = $migrates_to['version'];
262
+				$this->_template_args = array_merge($this->_template_args, array(
263
+					'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"),
264
+						isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug),
265
+					'next_db_state'    => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),
266
+						$new_version, $plugin_slug) : null,
267
+				));
268
+			}
269
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
270
+			$this->_template_args = array_merge(
271
+				$this->_template_args,
272
+				array(
273
+					'show_most_recent_migration'             => $show_most_recent_migration,
274
+					//flag for showing the most recent migration's status and/or errors
275
+					'show_migration_progress'                => $show_migration_progress,
276
+					//flag for showing the option to run migrations and see their progress
277
+					'show_backup_db_text'                    => $show_backup_db_text,
278
+					//flag for showing text telling the user to backup their DB
279
+					'show_maintenance_switch'                => $show_maintenance_switch,
280
+					//flag for showing the option to change maintenance mode between levels 0 and 1
281
+					'script_names'                           => $script_names,
282
+					//array of names of scripts that have run
283
+					'show_continue_current_migration_script' => $show_continue_current_migration_script,
284
+					//flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
285
+					'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
286
+						EE_MAINTENANCE_ADMIN_URL),
287
+					'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
288
+						EE_MAINTENANCE_ADMIN_URL),
289
+					'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'),
290
+						EE_MAINTENANCE_ADMIN_URL),
291
+					'ultimate_db_state'                      => sprintf(__("EE%s", 'event_espresso'),
292
+						espresso_version()),
293
+				)
294
+			);
295
+			//make sure we have the form fields helper available. It usually is, but sometimes it isn't
296
+			//localize script stuff
297
+			wp_localize_script('ee-maintenance', 'ee_maintenance', array(
298
+				'migrating'                        => esc_html__("Updating Database...", "event_espresso"),
299
+				'next'                             => esc_html__("Next", "event_espresso"),
300
+				'fatal_error'                      => esc_html__("A Fatal Error Has Occurred", "event_espresso"),
301
+				'click_next_when_ready'            => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed",
302
+					"event_espresso"),
303
+				'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
304
+				'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
305
+				'status_completed'                 => EE_Data_Migration_Manager::status_completed,
306
+			));
307
+		}
308
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
309
+		//now render the migration options part, and put it in a variable
310
+		$migration_options_template_file = apply_filters(
311
+			'FHEE__ee_migration_page__migration_options_template',
312
+			EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
313
+		);
314
+		$migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true);
315
+		$this->_template_args['migration_options_html'] = $migration_options_html;
316
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
317
+			$this->_template_args, true);
318
+		$this->display_admin_page_with_sidebar();
319
+	}
320
+
321
+
322
+
323
+	/**
324
+	 * returns JSON and executes another step of the currently-executing data migration (called via ajax)
325
+	 */
326
+	public function migration_step()
327
+	{
328
+		$this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();
329
+		$this->_return_json();
330
+	}
331
+
332
+
333
+
334
+	/**
335
+	 * Can be used by js when it notices a response with HTML in it in order
336
+	 * to log the malformed response
337
+	 */
338
+	public function add_error_to_migrations_ran()
339
+	{
340
+		EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);
341
+		$this->_template_args['data'] = array('ok' => true);
342
+		$this->_return_json();
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * changes the maintenance level, provided there are still no migration scripts that shoudl run
349
+	 */
350
+	public function _change_maintenance_level()
351
+	{
352
+		$new_level = intval($this->_req_data['maintenance_mode_level']);
353
+		if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
354
+			EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);
355
+			$success = true;
356
+		} else {
357
+			EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
358
+			$success = false;
359
+		}
360
+		$this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * a tab with options for resetting and/or deleting EE data
367
+	 *
368
+	 * @throws \EE_Error
369
+	 */
370
+	public function _data_reset_and_delete()
371
+	{
372
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
373
+		$this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
374
+			'reset_capabilities',
375
+			'reset_capabilities',
376
+			array(),
377
+			'button button-primary',
378
+			'',
379
+			false
380
+		);
381
+		$this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
382
+			array('action' => 'delete_db'),
383
+			EE_MAINTENANCE_ADMIN_URL
384
+		);
385
+		$this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
386
+			array('action' => 'reset_db'),
387
+			EE_MAINTENANCE_ADMIN_URL
388
+		);
389
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
390
+			$this->_template_path,
391
+			$this->_template_args,
392
+			true
393
+		);
394
+		$this->display_admin_page_with_sidebar();
395
+	}
396
+
397
+
398
+
399
+	protected function _reset_capabilities()
400
+	{
401
+		EE_Registry::instance()->CAP->init_caps(true);
402
+		EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.',
403
+			'event_espresso'));
404
+		$this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true);
405
+	}
406
+
407
+
408
+
409
+	/**
410
+	 * resets the DMSs so we can attempt to continue migrating after a fatal error
411
+	 * (only a good idea when someone has somehow tried ot fix whatever caused
412
+	 * the fatal error in teh first place)
413
+	 */
414
+	protected function _reattempt_migration()
415
+	{
416
+		EE_Data_Migration_Manager::instance()->reattempt();
417
+		$this->_redirect_after_action(false, '', '', array('action' => 'default'), true);
418
+	}
419
+
420
+
421
+
422
+	/**
423
+	 * shows the big ol' System Information page
424
+	 */
425
+	public function _system_status()
426
+	{
427
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
428
+		$this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
429
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
430
+			$this->_template_args, true);
431
+		$this->display_admin_page_with_sidebar();
432
+	}
433
+
434
+
435
+
436
+	public function _send_migration_crash_report()
437
+	{
438
+		$from = $this->_req_data['from'];
439
+		$from_name = $this->_req_data['from_name'];
440
+		$body = $this->_req_data['body'];
441
+		try {
442
+			$success = wp_mail(EE_SUPPORT_EMAIL,
443
+				'Migration Crash Report',
444
+				$body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
445
+				array(
446
+					"from:$from_name<$from>",
447
+					//					'content-type:text/html charset=UTF-8'
448
+				));
449
+		} catch (Exception $e) {
450
+			$success = false;
451
+		}
452
+		$this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"),
453
+			esc_html__("sent", "event_espresso"),
454
+			array('success' => $success, 'action' => 'confirm_migration_crash_report_sent'));
455
+	}
456
+
457
+
458
+
459
+	public function _confirm_migration_crash_report_sent()
460
+	{
461
+		try {
462
+			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
463
+		} catch (EE_Error $e) {
464
+			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
465
+			//now, just so we can display the page correctly, make a error migration script stage object
466
+			//and also put the error on it. It only persists for the duration of this request
467
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
468
+			$most_recent_migration->add_error($e->getMessage());
469
+		}
470
+		$success = $this->_req_data['success'] == '1' ? true : false;
471
+		$this->_template_args['success'] = $success;
472
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;
473
+		$this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
474
+			EE_MAINTENANCE_ADMIN_URL);
475
+		$this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
476
+			EE_MAINTENANCE_ADMIN_URL);
477
+		$this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
478
+			EE_MAINTENANCE_ADMIN_URL);
479
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
480
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
481
+			$this->_template_args, true);
482
+		$this->display_admin_page_with_sidebar();
483
+	}
484
+
485
+
486
+
487
+	/**
488
+	 * Resets the entire EE4 database.
489
+	 * Currently basically only sets up ee4 database for a fresh install- doesn't
490
+	 * actually clean out the old wp options, or cpts (although does erase old ee table data)
491
+	 *
492
+	 * @param boolean $nuke_old_ee4_data controls whether or not we
493
+	 *                                   destroy the old ee4 data, or just try initializing ee4 default data
494
+	 */
495
+	public function _reset_db($nuke_old_ee4_data = true)
496
+	{
497
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
498
+		if ($nuke_old_ee4_data) {
499
+			EEH_Activation::delete_all_espresso_cpt_data();
500
+			EEH_Activation::delete_all_espresso_tables_and_data(false);
501
+			EEH_Activation::remove_cron_tasks();
502
+		}
503
+		//make sure when we reset the registry's config that it
504
+		//switches to using the new singleton
505
+		EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
506
+		EE_System::instance()->initialize_db_if_no_migrations_required(true);
507
+		EE_System::instance()->redirect_to_about_ee();
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * Deletes ALL EE tables, Records, and Options from the database.
514
+	 */
515
+	public function _delete_db()
516
+	{
517
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
518
+		EEH_Activation::delete_all_espresso_cpt_data();
519
+		EEH_Activation::delete_all_espresso_tables_and_data();
520
+		EEH_Activation::remove_cron_tasks();
521
+		EEH_Activation::deactivate_event_espresso();
522
+		wp_safe_redirect(admin_url('plugins.php'));
523
+		exit;
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 * sets up EE4 to rerun the migrations from ee3 to ee4
530
+	 */
531
+	public function _rerun_migration_from_ee3()
532
+	{
533
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
534
+		EEH_Activation::delete_all_espresso_cpt_data();
535
+		EEH_Activation::delete_all_espresso_tables_and_data(false);
536
+		//set the db state to something that will require migrations
537
+		update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
538
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
539
+		$this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso'));
540
+	}
541
+
542
+
543
+
544
+	//none of the below group are currently used for Gateway Settings
545
+	protected function _add_screen_options()
546
+	{
547
+	}
548
+
549
+
550
+
551
+	protected function _add_feature_pointers()
552
+	{
553
+	}
554
+
555 555
 
556 556
 
557
-    public function admin_init()
558
-    {
559
-    }
560
-
561
-
562
-
563
-    public function admin_notices()
564
-    {
565
-    }
566
-
557
+	public function admin_init()
558
+	{
559
+	}
560
+
561
+
562
+
563
+	public function admin_notices()
564
+	{
565
+	}
566
+
567 567
 
568 568
 
569
-    public function admin_footer_scripts()
570
-    {
571
-    }
569
+	public function admin_footer_scripts()
570
+	{
571
+	}
572 572
 
573 573
 
574 574
 
575
-    public function load_scripts_styles()
576
-    {
577
-        wp_enqueue_script('ee_admin_js');
575
+	public function load_scripts_styles()
576
+	{
577
+		wp_enqueue_script('ee_admin_js');
578 578
 //		wp_enqueue_media();
579 579
 //		wp_enqueue_script('media-upload');
580
-        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
581
-            EVENT_ESPRESSO_VERSION, true);
582
-        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
583
-            EVENT_ESPRESSO_VERSION);
584
-        wp_enqueue_style('espresso_maintenance');
585
-    }
580
+		wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
581
+			EVENT_ESPRESSO_VERSION, true);
582
+		wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
583
+			EVENT_ESPRESSO_VERSION);
584
+		wp_enqueue_style('espresso_maintenance');
585
+	}
586 586
 
587 587
 
588 588
 
589
-    public function load_scripts_styles_default()
590
-    {
591
-        //styles
589
+	public function load_scripts_styles_default()
590
+	{
591
+		//styles
592 592
 //		wp_enqueue_style('ee-text-links');
593 593
 //		//scripts
594 594
 //		wp_enqueue_script('ee-text-links');
595
-    }
595
+	}
596 596
 
597 597
 
598 598
 
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      *
92 92
      * @param  array $dir_ref original array of paths
93 93
      *
94
-     * @return array           appended paths
94
+     * @return string[]           appended paths
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
      * @param EE_Question[]  $questions        An array of questions indexed by answer id.
702 702
      * @param EE_Answer[]    $answers          An array of answer objects
703 703
      * @param string         $template         Template content to be parsed.
704
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
704
+     * @param string[]          $valid_shortcodes Valid shortcodes for the template being parsed.
705 705
      * @param array          $extra_data       Extra data that might be used when parsing the template.
706 706
      */
707 707
     protected function _parse_question_list_for_primary_or_recipient_registration(
Please login to merge, or discard this patch.
Indentation   +701 added lines, -701 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since           4.3.2
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -22,722 +22,722 @@  discard block
 block discarded – undo
22 22
 {
23 23
     
24 24
     
25
-    /**
26
-     * constructor.
27
-     */
28
-    public function __construct()
29
-    {
30
-        $this->_caf_hooks();
31
-    }
32
-    
33
-    
34
-    /**
35
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
36
-     *
37
-     * @since 4.3.2
38
-     *
39
-     * @return void
40
-     */
41
-    private function _caf_hooks()
42
-    {
43
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
-        add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
-            5, 2);
46
-        add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
-            2);
48
-        add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
-            2);
50
-        add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
-            2);
52
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
-        add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
-            2);
55
-        add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
-            array($this, 'new_default_templates'), 5, 7);
57
-        add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
-            2);
59
-        
60
-        //shortcode parsers
61
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
-            array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
-            array($this, 'additional_recipient_details_parser'), 5, 5);
67
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
-            array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
-            array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
-        
72
-        /**
73
-         * @since 4.2.0
74
-         */
75
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
-        
78
-        /**
79
-         * @since 4.3.0
80
-         */
81
-        //eat our own dog food!
82
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
-        do_action('EE_Brewing_Regular___messages_caf');
85
-    }
86
-    
87
-    
88
-    /**
89
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
-     * messages system.
91
-     *
92
-     * @param  array $dir_ref original array of paths
93
-     *
94
-     * @return array           appended paths
95
-     */
96
-    public function messages_autoload_paths($dir_ref)
97
-    {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
-        
100
-        return $dir_ref;
101
-    }
102
-    
103
-    
104
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
-    {
106
-        $validator_config['attendee_list'] = array(
107
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
-            'required'   => array('[ATTENDEE_LIST]')
109
-        );
110
-        $validator_config['question_list'] = array(
111
-            'shortcodes' => array('question'),
112
-            'required'   => array('[QUESTION_LIST]')
113
-        );
114
-        
115
-        return $validator_config;
116
-    }
117
-    
118
-    
119
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
-    {
121
-        $validator_config['attendee_list'] = array(
122
-            'shortcodes' => array('attendee', 'question_list'),
123
-            'required'   => array('[ATTENDEE_LIST]')
124
-        );
125
-        $validator_config['question_list'] = array(
126
-            'shortcodes' => array('question'),
127
-            'required'   => array('[QUESTION_LIST]')
128
-        );
129
-        
130
-        return $validator_config;
131
-    }
132
-    
133
-    
134
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
-    {
136
-        $validator_config['attendee_list'] = array(
137
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
-            'required'   => array('[ATTENDEE_LIST]')
139
-        );
140
-        $validator_config['question_list'] = array(
141
-            'shortcodes' => array('question'),
142
-            'required'   => array('[QUESTION_LIST]')
143
-        );
144
-        
145
-        return $validator_config;
146
-    }
147
-    
148
-    
149
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
-    {
151
-        $template_fields['extra']['content']['question_list'] = array(
152
-            'input'               => 'textarea',
153
-            'label'               => '[QUESTION_LIST]',
154
-            'type'                => 'string',
155
-            'required'            => true,
156
-            'validation'          => true,
157
-            'format'              => '%s',
158
-            'css_class'           => 'large-text',
159
-            'rows'                => '5',
160
-            'shortcodes_required' => array('[QUESTION_LIST]')
161
-        );
162
-        
163
-        return $template_fields;
164
-    }
165
-    
166
-    
167
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
-    {
169
-        $template_fields['extra']['content']['question_list'] = array(
170
-            'input'               => 'textarea',
171
-            'label'               => '[QUESTION_LIST]',
172
-            'type'                => 'string',
173
-            'required'            => true,
174
-            'validation'          => true,
175
-            'format'              => '%s',
176
-            'css_class'           => 'large-text',
177
-            'rows'                => '5',
178
-            'shortcodes_required' => array('[QUESTION_LIST]')
179
-        );
180
-        
181
-        return $template_fields;
182
-    }
183
-    
184
-    
185
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
-    {
187
-        $template_fields['extra']['content']['question_list'] = array(
188
-            'input'               => 'textarea',
189
-            'label'               => '[QUESTION_LIST]',
190
-            'type'                => 'string',
191
-            'required'            => true,
192
-            'validation'          => true,
193
-            'format'              => '%s',
194
-            'css_class'           => 'large-text',
195
-            'rows'                => '5',
196
-            'shortcodes_required' => array('[QUESTION_LIST]')
197
-        );
198
-        
199
-        return $template_fields;
200
-    }
201
-    
202
-    
203
-    public function new_default_templates(
204
-        $contents,
205
-        $actual_path,
206
-        EE_messenger $messenger,
207
-        EE_message_type $message_type,
208
-        $field,
209
-        $context,
210
-        EE_Messages_Template_Pack $template_pack
211
-    ) {
212
-        
213
-        //we're only modifying templates for the default template pack
214
-        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
-            return $contents;
216
-        }
217
-        
218
-        //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
-        
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
-        
224
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
25
+	/**
26
+	 * constructor.
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$this->_caf_hooks();
31
+	}
32
+    
33
+    
34
+	/**
35
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
36
+	 *
37
+	 * @since 4.3.2
38
+	 *
39
+	 * @return void
40
+	 */
41
+	private function _caf_hooks()
42
+	{
43
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
+		add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
+			5, 2);
46
+		add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
+			2);
48
+		add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
+			2);
50
+		add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
+			2);
52
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
+		add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
+			2);
55
+		add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
+			array($this, 'new_default_templates'), 5, 7);
57
+		add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
+			2);
59
+        
60
+		//shortcode parsers
61
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
+			array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
+			array($this, 'additional_recipient_details_parser'), 5, 5);
67
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
+			array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
+			array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
+        
72
+		/**
73
+		 * @since 4.2.0
74
+		 */
75
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
+        
78
+		/**
79
+		 * @since 4.3.0
80
+		 */
81
+		//eat our own dog food!
82
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
+		do_action('EE_Brewing_Regular___messages_caf');
85
+	}
86
+    
87
+    
88
+	/**
89
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
+	 * messages system.
91
+	 *
92
+	 * @param  array $dir_ref original array of paths
93
+	 *
94
+	 * @return array           appended paths
95
+	 */
96
+	public function messages_autoload_paths($dir_ref)
97
+	{
98
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
+        
100
+		return $dir_ref;
101
+	}
102
+    
103
+    
104
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
+	{
106
+		$validator_config['attendee_list'] = array(
107
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
+			'required'   => array('[ATTENDEE_LIST]')
109
+		);
110
+		$validator_config['question_list'] = array(
111
+			'shortcodes' => array('question'),
112
+			'required'   => array('[QUESTION_LIST]')
113
+		);
114
+        
115
+		return $validator_config;
116
+	}
117
+    
118
+    
119
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
+	{
121
+		$validator_config['attendee_list'] = array(
122
+			'shortcodes' => array('attendee', 'question_list'),
123
+			'required'   => array('[ATTENDEE_LIST]')
124
+		);
125
+		$validator_config['question_list'] = array(
126
+			'shortcodes' => array('question'),
127
+			'required'   => array('[QUESTION_LIST]')
128
+		);
129
+        
130
+		return $validator_config;
131
+	}
132
+    
133
+    
134
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
+	{
136
+		$validator_config['attendee_list'] = array(
137
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
+			'required'   => array('[ATTENDEE_LIST]')
139
+		);
140
+		$validator_config['question_list'] = array(
141
+			'shortcodes' => array('question'),
142
+			'required'   => array('[QUESTION_LIST]')
143
+		);
144
+        
145
+		return $validator_config;
146
+	}
147
+    
148
+    
149
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
+	{
151
+		$template_fields['extra']['content']['question_list'] = array(
152
+			'input'               => 'textarea',
153
+			'label'               => '[QUESTION_LIST]',
154
+			'type'                => 'string',
155
+			'required'            => true,
156
+			'validation'          => true,
157
+			'format'              => '%s',
158
+			'css_class'           => 'large-text',
159
+			'rows'                => '5',
160
+			'shortcodes_required' => array('[QUESTION_LIST]')
161
+		);
162
+        
163
+		return $template_fields;
164
+	}
165
+    
166
+    
167
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
+	{
169
+		$template_fields['extra']['content']['question_list'] = array(
170
+			'input'               => 'textarea',
171
+			'label'               => '[QUESTION_LIST]',
172
+			'type'                => 'string',
173
+			'required'            => true,
174
+			'validation'          => true,
175
+			'format'              => '%s',
176
+			'css_class'           => 'large-text',
177
+			'rows'                => '5',
178
+			'shortcodes_required' => array('[QUESTION_LIST]')
179
+		);
180
+        
181
+		return $template_fields;
182
+	}
183
+    
184
+    
185
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
+	{
187
+		$template_fields['extra']['content']['question_list'] = array(
188
+			'input'               => 'textarea',
189
+			'label'               => '[QUESTION_LIST]',
190
+			'type'                => 'string',
191
+			'required'            => true,
192
+			'validation'          => true,
193
+			'format'              => '%s',
194
+			'css_class'           => 'large-text',
195
+			'rows'                => '5',
196
+			'shortcodes_required' => array('[QUESTION_LIST]')
197
+		);
198
+        
199
+		return $template_fields;
200
+	}
201
+    
202
+    
203
+	public function new_default_templates(
204
+		$contents,
205
+		$actual_path,
206
+		EE_messenger $messenger,
207
+		EE_message_type $message_type,
208
+		$field,
209
+		$context,
210
+		EE_Messages_Template_Pack $template_pack
211
+	) {
212
+        
213
+		//we're only modifying templates for the default template pack
214
+		if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
+			return $contents;
216
+		}
217
+        
218
+		//the template file name we're replacing contents for.
219
+		$template_file_prefix = $field . '_' . $context;
220
+		$msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
+        
222
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
+        
224
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
226
-            switch ($template_file_prefix) {
226
+			switch ($template_file_prefix) {
227 227
                 
228
-                case 'question_list_admin' :
229
-                case 'question_list_attendee' :
230
-                case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
232
-                    $contents = EEH_Template::display_template($path, array(), true);
233
-                    break;
228
+				case 'question_list_admin' :
229
+				case 'question_list_attendee' :
230
+				case 'question_list_primary_attendee' :
231
+					$path     = $base_path . $msg_prefix . 'question_list.template.php';
232
+					$contents = EEH_Template::display_template($path, array(), true);
233
+					break;
234 234
                 
235
-                case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
-                    $contents = EEH_Template::display_template($path, array(), true);
238
-                    break;
235
+				case 'attendee_list_primary_attendee' :
236
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
+					$contents = EEH_Template::display_template($path, array(), true);
238
+					break;
239 239
                 
240
-                case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
-                    $contents = EEH_Template::display_template($path,
243
-                        array(), true);
244
-                    break;
240
+				case 'attendee_list_admin' :
241
+					$path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
+					$contents = EEH_Template::display_template($path,
243
+						array(), true);
244
+					break;
245 245
                 
246
-                case 'attendee_list_attendee' :
247
-                    $contents = '';
248
-                    break;
246
+				case 'attendee_list_attendee' :
247
+					$contents = '';
248
+					break;
249 249
                 
250
-                case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
-                    $contents = EEH_Template::display_template($path, array(), true);
253
-                    break;
254
-            }
255
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
-            switch ($template_file_prefix) {
250
+				case 'event_list_attendee' :
251
+					$path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
+					$contents = EEH_Template::display_template($path, array(), true);
253
+					break;
254
+			}
255
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
+			switch ($template_file_prefix) {
257 257
                 
258
-                case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
260
-                    $contents = EEH_Template::display_template($path, array(), true);
261
-                    break;
258
+				case 'content_attendee' :
259
+					$path     = $base_path . $msg_prefix . 'content.template.php';
260
+					$contents = EEH_Template::display_template($path, array(), true);
261
+					break;
262 262
                 
263
-                case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
-                    $contents = EEH_Template::display_template($path, array(), true);
266
-                    break;
263
+				case 'newsletter_content_attendee' :
264
+					$path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
+					$contents = EEH_Template::display_template($path, array(), true);
266
+					break;
267 267
                 
268
-                case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
270
-                    $contents = EEH_Template::display_template($path, array(), true);
271
-                    break;
272
-            }
273
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
-            switch ($template_file_prefix) {
275
-                case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
-                    $contents = EEH_Template::display_template($path, array(), true);
278
-                    break;
279
-            }
280
-        }
281
-        
282
-        return $contents;
283
-        
284
-    }
285
-    
286
-    
287
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
-    {
289
-        //make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
-        $include_with = array(
291
-            'registration',
292
-            'cancelled_registration',
293
-            'declined_registration',
294
-            'not_approved_registration',
295
-            'payment_declined',
296
-            'payment_failed',
297
-            'payment_cancelled',
298
-            'payment',
299
-            'payment_reminder',
300
-            'pending_approval',
301
-            'registration_summary',
302
-            'invoice',
303
-            'receipt'
304
-        );
305
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
-            $contexts = array_keys($msg->get_contexts());
307
-            foreach ($contexts as $context) {
308
-                $valid_shortcodes[$context][] = 'question_list';
309
-                $valid_shortcodes[$context][] = 'question';
310
-            }
311
-        }
312
-        
313
-        return $valid_shortcodes;
314
-    }
315
-    
316
-    
317
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
-    {
319
-        $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
-            'event_espresso');
321
-        
322
-        return $shortcodes;
323
-    }
324
-    
325
-    
326
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
-    {
328
-        
329
-        if (strpos($shortcode,
330
-                '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
-        ) {
332
-            return $parsed;
333
-        }
334
-        
335
-        //let's get the question from the code.
336
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
-        $shortcode = trim(str_replace(']', '', $shortcode));
338
-        
339
-        $registration = $data instanceof EE_Registration ? $data : null;
340
-        $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
-        
342
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
-        
345
-        if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
-            return $parsed;
347
-        }
348
-        
349
-        //now let's figure out which question has this text.
350
-        foreach ($aee->questions as $ansid => $question) {
351
-            if (
352
-                $question instanceof EE_Question
353
-                && trim($question->display_text()) == trim($shortcode)
354
-                && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
-            ) {
356
-                return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
-                    'no_wpautop');
358
-            }
359
-        }
360
-        
361
-        //nothing!
362
-        return $parsed;
363
-    }
364
-    
365
-    
366
-    /**
367
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
-     *
369
-     * @since  4.2
370
-     *
371
-     * @param  array                  $shortcodes         array of shortcodes and
372
-     *                                                    descriptions
373
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
-     *
375
-     * @return array                                        array of shortcodes and
376
-     *                                                        descriptions
377
-     */
378
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
-    {
380
-        $shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
-            'event_espresso');
382
-        $shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
-            'event_espresso');
384
-        $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
-            'event_espresso');
386
-        
387
-        return $shortcodes;
388
-    }
389
-    
390
-    
391
-    /**
392
-     * Callback for additional shortcodes parser filter used for adding parser for new
393
-     * Datetime shortcodes
394
-     *
395
-     * @since  4.2
396
-     *
397
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
-     * @param  string                 $shortcode  The shortcode being parsed.
399
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
-     *                                            Parser.
402
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
403
-     *
404
-     * @return string                   The new parsed string.
405
-     */
406
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
-    {
408
-        
409
-        if ( ! $data instanceof EE_Datetime) {
410
-            return ''; //get out because we can only parse with the datetime object.
411
-        }
412
-        
413
-        switch ($shortcode) {
414
-            case '[DTT_NAME]' :
415
-                return $data->name();
416
-                break;
417
-            case '[DTT_DESCRIPTION]' :
418
-                return $data->description();
419
-                break;
420
-            case '[DTT_NAME_OR_DATES]' :
421
-                return $data->get_dtt_display_name(true);
422
-                break;
423
-            default :
424
-                return $parsed;
425
-                break;
426
-        }
427
-    }
428
-    
429
-    
430
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
-    {
432
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
-            'event_espresso');
434
-        
435
-        return $shortcodes;
436
-    }
437
-    
438
-    
439
-    /**
440
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
-     *
442
-     * @param string         $parsed           The original parsed content for the shortcode
443
-     * @param string         $shortcode        The shortcode being parsed
444
-     * @param array          $data             The shortcode parser data array
445
-     * @param array          $extra_data       The shortcode parser extra data array
446
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
-     *
448
-     * @return string
449
-     */
450
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
-    {
452
-        
453
-        if (array($data) && ! isset($data['data'])) {
454
-            return $parsed;
455
-        }
456
-        
457
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
-        
460
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
461
-            return $parsed;
462
-        }
463
-        
464
-        switch ($shortcode) {
465
-            case '[RECIPIENT_QUESTION_LIST]' :
466
-                $att                       = $recipient->att_obj;
467
-                $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
-                $answers                   = array();
268
+				case 'newsletter_subject_attendee' :
269
+					$path     = $base_path . $msg_prefix . 'subject.template.php';
270
+					$contents = EEH_Template::display_template($path, array(), true);
271
+					break;
272
+			}
273
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
+			switch ($template_file_prefix) {
275
+				case 'attendee_list_purchaser' :
276
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
+					$contents = EEH_Template::display_template($path, array(), true);
278
+					break;
279
+			}
280
+		}
281
+        
282
+		return $contents;
283
+        
284
+	}
285
+    
286
+    
287
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
+	{
289
+		//make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
+		$include_with = array(
291
+			'registration',
292
+			'cancelled_registration',
293
+			'declined_registration',
294
+			'not_approved_registration',
295
+			'payment_declined',
296
+			'payment_failed',
297
+			'payment_cancelled',
298
+			'payment',
299
+			'payment_reminder',
300
+			'pending_approval',
301
+			'registration_summary',
302
+			'invoice',
303
+			'receipt'
304
+		);
305
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
+			$contexts = array_keys($msg->get_contexts());
307
+			foreach ($contexts as $context) {
308
+				$valid_shortcodes[$context][] = 'question_list';
309
+				$valid_shortcodes[$context][] = 'question';
310
+			}
311
+		}
312
+        
313
+		return $valid_shortcodes;
314
+	}
315
+    
316
+    
317
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
+	{
319
+		$shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
+			'event_espresso');
321
+        
322
+		return $shortcodes;
323
+	}
324
+    
325
+    
326
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
+	{
328
+        
329
+		if (strpos($shortcode,
330
+				'[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
+		) {
332
+			return $parsed;
333
+		}
334
+        
335
+		//let's get the question from the code.
336
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
+		$shortcode = trim(str_replace(']', '', $shortcode));
338
+        
339
+		$registration = $data instanceof EE_Registration ? $data : null;
340
+		$registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
+        
342
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
+        
345
+		if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
+			return $parsed;
347
+		}
348
+        
349
+		//now let's figure out which question has this text.
350
+		foreach ($aee->questions as $ansid => $question) {
351
+			if (
352
+				$question instanceof EE_Question
353
+				&& trim($question->display_text()) == trim($shortcode)
354
+				&& isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
+			) {
356
+				return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
+					'no_wpautop');
358
+			}
359
+		}
360
+        
361
+		//nothing!
362
+		return $parsed;
363
+	}
364
+    
365
+    
366
+	/**
367
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
+	 *
369
+	 * @since  4.2
370
+	 *
371
+	 * @param  array                  $shortcodes         array of shortcodes and
372
+	 *                                                    descriptions
373
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
+	 *
375
+	 * @return array                                        array of shortcodes and
376
+	 *                                                        descriptions
377
+	 */
378
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
+	{
380
+		$shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
+			'event_espresso');
382
+		$shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
+			'event_espresso');
384
+		$shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
+			'event_espresso');
386
+        
387
+		return $shortcodes;
388
+	}
389
+    
390
+    
391
+	/**
392
+	 * Callback for additional shortcodes parser filter used for adding parser for new
393
+	 * Datetime shortcodes
394
+	 *
395
+	 * @since  4.2
396
+	 *
397
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
+	 * @param  string                 $shortcode  The shortcode being parsed.
399
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
+	 *                                            Parser.
402
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
403
+	 *
404
+	 * @return string                   The new parsed string.
405
+	 */
406
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
+	{
408
+        
409
+		if ( ! $data instanceof EE_Datetime) {
410
+			return ''; //get out because we can only parse with the datetime object.
411
+		}
412
+        
413
+		switch ($shortcode) {
414
+			case '[DTT_NAME]' :
415
+				return $data->name();
416
+				break;
417
+			case '[DTT_DESCRIPTION]' :
418
+				return $data->description();
419
+				break;
420
+			case '[DTT_NAME_OR_DATES]' :
421
+				return $data->get_dtt_display_name(true);
422
+				break;
423
+			default :
424
+				return $parsed;
425
+				break;
426
+		}
427
+	}
428
+    
429
+    
430
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
+	{
432
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
+			'event_espresso');
434
+        
435
+		return $shortcodes;
436
+	}
437
+    
438
+    
439
+	/**
440
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
+	 *
442
+	 * @param string         $parsed           The original parsed content for the shortcode
443
+	 * @param string         $shortcode        The shortcode being parsed
444
+	 * @param array          $data             The shortcode parser data array
445
+	 * @param array          $extra_data       The shortcode parser extra data array
446
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
+	 *
448
+	 * @return string
449
+	 */
450
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
+	{
452
+        
453
+		if (array($data) && ! isset($data['data'])) {
454
+			return $parsed;
455
+		}
456
+        
457
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
+        
460
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
461
+			return $parsed;
462
+		}
463
+        
464
+		switch ($shortcode) {
465
+			case '[RECIPIENT_QUESTION_LIST]' :
466
+				$att                       = $recipient->att_obj;
467
+				$registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
+				$answers                   = array();
470 470
                 
471
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
-                $valid_shortcodes = array('question');
471
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
+				$valid_shortcodes = array('question');
473 473
                 
474
-                //if the context is main_content then get all answers for all registrations on this attendee
475
-                if ($data['data'] instanceof EE_Messages_Addressee) {
474
+				//if the context is main_content then get all answers for all registrations on this attendee
475
+				if ($data['data'] instanceof EE_Messages_Addressee) {
476 476
                     
477
-                    foreach ($registrations_on_attendee as $reg) {
478
-                        if ($reg instanceof EE_Registration) {
479
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
-                            foreach ($anss as $ans) {
481
-                                if ($ans instanceof EE_Answer) {
482
-                                    $answers[$ans->ID()] = $ans;
483
-                                }
484
-                            }
485
-                        }
486
-                    }
487
-                }
477
+					foreach ($registrations_on_attendee as $reg) {
478
+						if ($reg instanceof EE_Registration) {
479
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
+							foreach ($anss as $ans) {
481
+								if ($ans instanceof EE_Answer) {
482
+									$answers[$ans->ID()] = $ans;
483
+								}
484
+							}
485
+						}
486
+					}
487
+				}
488 488
                 
489
-                //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
490
-                if ($data['data'] instanceof EE_Event) {
491
-                    $event = $data['data'];
492
-                    foreach ($registrations_on_attendee as $reg) {
493
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
-                            foreach ($anss as $ans) {
496
-                                if ($ans instanceof EE_Answer) {
497
-                                    $answers[$ans->ID()] = $ans;
498
-                                }
499
-                            }
500
-                        }
501
-                    }
502
-                }
489
+				//if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
490
+				if ($data['data'] instanceof EE_Event) {
491
+					$event = $data['data'];
492
+					foreach ($registrations_on_attendee as $reg) {
493
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
+							foreach ($anss as $ans) {
496
+								if ($ans instanceof EE_Answer) {
497
+									$answers[$ans->ID()] = $ans;
498
+								}
499
+							}
500
+						}
501
+					}
502
+				}
503 503
                 
504
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
504
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
505 505
                 
506
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
-                //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
509
-                    $extra_data['data'] = $recipient;
510
-                }
506
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
+				//object on it.
508
+				if ( ! isset( $extra_data['data'] ) ) {
509
+					$extra_data['data'] = $recipient;
510
+				}
511 511
                 
512
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
513
-                    $shortcode_parser,
514
-                    $questions,
515
-                    $answers,
516
-                    $template,
517
-                    $valid_shortcodes,
518
-                    $extra_data
519
-                );
520
-                break;
512
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
513
+					$shortcode_parser,
514
+					$questions,
515
+					$answers,
516
+					$template,
517
+					$valid_shortcodes,
518
+					$extra_data
519
+				);
520
+				break;
521 521
             
522
-            default :
523
-                return $parsed;
524
-                break;
525
-        }
526
-    }
527
-    
528
-    
529
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
-    {
531
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
532
-            'event_espresso');
533
-        
534
-        return $shortcodes;
535
-    }
536
-    
537
-    
538
-    /**
539
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
-     *
541
-     * @param string         $parsed           The original parsed content for the shortcode
542
-     * @param string         $shortcode        The shortcode being parsed
543
-     * @param array          $data             The shortcode parser data array
544
-     * @param array          $extra_data       The shortcode parser extra data array
545
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
-     *
547
-     * @return string
548
-     */
549
-    public function additional_primary_registration_details_parser(
550
-        $parsed,
551
-        $shortcode,
552
-        $data,
553
-        $extra_data,
554
-        $shortcode_parser
555
-    ) {
556
-        if (array($data) && ! isset($data['data'])) {
557
-            return $parsed;
558
-        }
559
-        
560
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
-        
563
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
564
-            return $parsed;
565
-        }
566
-        
567
-        switch ($shortcode) {
568
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
-                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
-                    return '';
571
-                }
572
-                $registration     = $recipient->primary_reg_obj;
573
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
574
-                $valid_shortcodes = array('question');
575
-                $answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
576
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
577
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578
-                //object on it.
579
-                if ( ! isset( $extra_data['data'] ) ){
580
-                    $extra_data['data'] = $recipient;
581
-                }
582
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
583
-                    $shortcode_parser,
584
-                    $questions,
585
-                    $answers,
586
-                    $template,
587
-                    $valid_shortcodes,
588
-                    $extra_data
589
-                );
590
-                break;
522
+			default :
523
+				return $parsed;
524
+				break;
525
+		}
526
+	}
527
+    
528
+    
529
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
+	{
531
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
532
+			'event_espresso');
533
+        
534
+		return $shortcodes;
535
+	}
536
+    
537
+    
538
+	/**
539
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
+	 *
541
+	 * @param string         $parsed           The original parsed content for the shortcode
542
+	 * @param string         $shortcode        The shortcode being parsed
543
+	 * @param array          $data             The shortcode parser data array
544
+	 * @param array          $extra_data       The shortcode parser extra data array
545
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
+	 *
547
+	 * @return string
548
+	 */
549
+	public function additional_primary_registration_details_parser(
550
+		$parsed,
551
+		$shortcode,
552
+		$data,
553
+		$extra_data,
554
+		$shortcode_parser
555
+	) {
556
+		if (array($data) && ! isset($data['data'])) {
557
+			return $parsed;
558
+		}
559
+        
560
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
+        
563
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
564
+			return $parsed;
565
+		}
566
+        
567
+		switch ($shortcode) {
568
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
+				if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
+					return '';
571
+				}
572
+				$registration     = $recipient->primary_reg_obj;
573
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
574
+				$valid_shortcodes = array('question');
575
+				$answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
576
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
577
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578
+				//object on it.
579
+				if ( ! isset( $extra_data['data'] ) ){
580
+					$extra_data['data'] = $recipient;
581
+				}
582
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
583
+					$shortcode_parser,
584
+					$questions,
585
+					$answers,
586
+					$template,
587
+					$valid_shortcodes,
588
+					$extra_data
589
+				);
590
+				break;
591 591
             
592
-            default :
593
-                return $parsed;
594
-                break;
595
-        }
596
-    }
597
-    
598
-    
599
-    /**
600
-     * Takes care of registering the  message types that are only available in caffeinated EE.
601
-     *
602
-     * @since   4.3.2
603
-     *
604
-     * @return  void
605
-     */
606
-    public function register_caf_message_types()
607
-    {
608
-        //register newsletter message type
609
-        $setup_args = array(
610
-            'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611
-            'autoloadpaths'               => array(
612
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
613
-            ),
614
-            'messengers_to_activate_with' => array('email'),
615
-            'messengers_to_validate_with' => array('email')
616
-        );
617
-        EE_Register_Message_Type::register('newsletter', $setup_args);
618
-        
619
-        //register payment reminder message type
620
-        $setup_args = array(
621
-            'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
622
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
623
-            'messengers_to_activate_with' => array('email'),
624
-            'messengers_to_validate_with' => array('email')
625
-        );
626
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
627
-        
628
-        //register payment declined message type
629
-        $setup_args = array(
630
-            'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
631
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
632
-            'messengers_to_activate_with' => array('email'),
633
-            'messengers_to_validate_with' => array('email')
634
-        );
635
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
636
-        
637
-        //register registration declined message type
638
-        $setup_args = array(
639
-            'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
640
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
641
-            'messengers_to_activate_with' => array('email'),
642
-            'messengers_to_validate_with' => array('email')
643
-        );
644
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
645
-        
646
-        //register registration cancelled message type
647
-        $setup_args = array(
648
-            'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
649
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
650
-            'messengers_to_activate_with' => array('email'),
651
-            'messengers_to_validate_with' => array('email')
652
-        );
653
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
654
-        
655
-        
656
-        //register payment failed message type
657
-        $setup_args = array(
658
-            'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
659
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
660
-            'messengers_to_activate_with' => array('email'),
661
-            'messengers_to_validate_with' => array('email')
662
-        );
663
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
664
-        
665
-        //register payment declined message type
666
-        $setup_args = array(
667
-            'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
668
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
669
-            'messengers_to_activate_with' => array('email'),
670
-            'messengers_to_validate_with' => array('email')
671
-        );
672
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
673
-    }
674
-    
675
-    
676
-    /**
677
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
678
-     *
679
-     * @since   4.3.2
680
-     *
681
-     * @return void
682
-     */
683
-    public function register_caf_shortcodes()
684
-    {
685
-        $setup_args = array(
686
-            'autoloadpaths'                 => array(
687
-                EE_CAF_LIBRARIES . 'shortcodes/'
688
-            ),
689
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
690
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
691
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
692
-        );
693
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
694
-    }
695
-    
696
-    
697
-    /**
698
-     * Parses a question list shortcode using given data and template
699
-     *
700
-     * @param \EE_Shortcodes $shortcode_parser
701
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
702
-     * @param EE_Answer[]    $answers          An array of answer objects
703
-     * @param string         $template         Template content to be parsed.
704
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
705
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
706
-     */
707
-    protected function _parse_question_list_for_primary_or_recipient_registration(
708
-        $shortcode_parser,
709
-        $questions,
710
-        $answers,
711
-        $template,
712
-        $valid_shortcodes,
713
-        $extra_data
714
-    ) {
715
-        $question_list = '';
716
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
717
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
718
-        foreach ($answers as $answer) {
719
-            if ($answer instanceof EE_Answer) {
720
-                //first see if the question is in our $questions array. If not then try to get from answer object.
721
-                $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
722
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
723
-                if (
724
-                    ! $question instanceof EE_Question
725
-                    || (
726
-                        $question instanceof EE_Question
727
-                        && $question->admin_only()
728
-                    )
729
-                ) {
730
-                    continue;
731
-                }
732
-                $question_list .= $shortcode_helper->parse_question_list_template(
733
-                    $template,
734
-                    $answer,
735
-                    $valid_shortcodes,
736
-                    $extra_data
737
-                );
738
-            }
739
-        }
740
-        
741
-        return $question_list;
742
-    }
592
+			default :
593
+				return $parsed;
594
+				break;
595
+		}
596
+	}
597
+    
598
+    
599
+	/**
600
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
601
+	 *
602
+	 * @since   4.3.2
603
+	 *
604
+	 * @return  void
605
+	 */
606
+	public function register_caf_message_types()
607
+	{
608
+		//register newsletter message type
609
+		$setup_args = array(
610
+			'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611
+			'autoloadpaths'               => array(
612
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
613
+			),
614
+			'messengers_to_activate_with' => array('email'),
615
+			'messengers_to_validate_with' => array('email')
616
+		);
617
+		EE_Register_Message_Type::register('newsletter', $setup_args);
618
+        
619
+		//register payment reminder message type
620
+		$setup_args = array(
621
+			'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
622
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
623
+			'messengers_to_activate_with' => array('email'),
624
+			'messengers_to_validate_with' => array('email')
625
+		);
626
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
627
+        
628
+		//register payment declined message type
629
+		$setup_args = array(
630
+			'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
631
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
632
+			'messengers_to_activate_with' => array('email'),
633
+			'messengers_to_validate_with' => array('email')
634
+		);
635
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
636
+        
637
+		//register registration declined message type
638
+		$setup_args = array(
639
+			'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
640
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
641
+			'messengers_to_activate_with' => array('email'),
642
+			'messengers_to_validate_with' => array('email')
643
+		);
644
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
645
+        
646
+		//register registration cancelled message type
647
+		$setup_args = array(
648
+			'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
649
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
650
+			'messengers_to_activate_with' => array('email'),
651
+			'messengers_to_validate_with' => array('email')
652
+		);
653
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
654
+        
655
+        
656
+		//register payment failed message type
657
+		$setup_args = array(
658
+			'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
659
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
660
+			'messengers_to_activate_with' => array('email'),
661
+			'messengers_to_validate_with' => array('email')
662
+		);
663
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
664
+        
665
+		//register payment declined message type
666
+		$setup_args = array(
667
+			'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
668
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
669
+			'messengers_to_activate_with' => array('email'),
670
+			'messengers_to_validate_with' => array('email')
671
+		);
672
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
673
+	}
674
+    
675
+    
676
+	/**
677
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
678
+	 *
679
+	 * @since   4.3.2
680
+	 *
681
+	 * @return void
682
+	 */
683
+	public function register_caf_shortcodes()
684
+	{
685
+		$setup_args = array(
686
+			'autoloadpaths'                 => array(
687
+				EE_CAF_LIBRARIES . 'shortcodes/'
688
+			),
689
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
690
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
691
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
692
+		);
693
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
694
+	}
695
+    
696
+    
697
+	/**
698
+	 * Parses a question list shortcode using given data and template
699
+	 *
700
+	 * @param \EE_Shortcodes $shortcode_parser
701
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
702
+	 * @param EE_Answer[]    $answers          An array of answer objects
703
+	 * @param string         $template         Template content to be parsed.
704
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
705
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
706
+	 */
707
+	protected function _parse_question_list_for_primary_or_recipient_registration(
708
+		$shortcode_parser,
709
+		$questions,
710
+		$answers,
711
+		$template,
712
+		$valid_shortcodes,
713
+		$extra_data
714
+	) {
715
+		$question_list = '';
716
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
717
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
718
+		foreach ($answers as $answer) {
719
+			if ($answer instanceof EE_Answer) {
720
+				//first see if the question is in our $questions array. If not then try to get from answer object.
721
+				$question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
722
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
723
+				if (
724
+					! $question instanceof EE_Question
725
+					|| (
726
+						$question instanceof EE_Question
727
+						&& $question->admin_only()
728
+					)
729
+				) {
730
+					continue;
731
+				}
732
+				$question_list .= $shortcode_helper->parse_question_list_template(
733
+					$template,
734
+					$answer,
735
+					$valid_shortcodes,
736
+					$extra_data
737
+				);
738
+			}
739
+		}
740
+        
741
+		return $question_list;
742
+	}
743 743
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
98
+        $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/';
99 99
         
100 100
         return $dir_ref;
101 101
     }
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
         }
217 217
         
218 218
         //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
219
+        $template_file_prefix = $field.'_'.$context;
220
+        $msg_prefix           = $messenger->name.'_'.$message_type->name.'_';
221 221
         
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
222
+        $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/';
223 223
         
224 224
         if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
                 case 'question_list_admin' :
229 229
                 case 'question_list_attendee' :
230 230
                 case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
231
+                    $path     = $base_path.$msg_prefix.'question_list.template.php';
232 232
                     $contents = EEH_Template::display_template($path, array(), true);
233 233
                     break;
234 234
                 
235 235
                 case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
236
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
237 237
                     $contents = EEH_Template::display_template($path, array(), true);
238 238
                     break;
239 239
                 
240 240
                 case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
241
+                    $path     = $base_path.$msg_prefix.'attendee_list_admin.template.php';
242 242
                     $contents = EEH_Template::display_template($path,
243 243
                         array(), true);
244 244
                     break;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                     break;
249 249
                 
250 250
                 case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
251
+                    $path     = $base_path.$msg_prefix.'event_list_attendee.template.php';
252 252
                     $contents = EEH_Template::display_template($path, array(), true);
253 253
                     break;
254 254
             }
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
             switch ($template_file_prefix) {
257 257
                 
258 258
                 case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
259
+                    $path     = $base_path.$msg_prefix.'content.template.php';
260 260
                     $contents = EEH_Template::display_template($path, array(), true);
261 261
                     break;
262 262
                 
263 263
                 case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
264
+                    $path     = $base_path.$msg_prefix.'newsletter_content.template.php';
265 265
                     $contents = EEH_Template::display_template($path, array(), true);
266 266
                     break;
267 267
                 
268 268
                 case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
269
+                    $path     = $base_path.$msg_prefix.'subject.template.php';
270 270
                     $contents = EEH_Template::display_template($path, array(), true);
271 271
                     break;
272 272
             }
273 273
         } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274 274
             switch ($template_file_prefix) {
275 275
                 case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
276
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
277 277
                     $contents = EEH_Template::display_template($path, array(), true);
278 278
                     break;
279 279
             }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
                 
506 506
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507 507
                 //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
508
+                if ( ! isset($extra_data['data'])) {
509 509
                     $extra_data['data'] = $recipient;
510 510
                 }
511 511
                 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
                 $questions = isset($recipient->questions) ? $recipient->questions : array();
577 577
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578 578
                 //object on it.
579
-                if ( ! isset( $extra_data['data'] ) ){
579
+                if ( ! isset($extra_data['data'])) {
580 580
                     $extra_data['data'] = $recipient;
581 581
                 }
582 582
                 return $this->_parse_question_list_for_primary_or_recipient_registration(
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
         $setup_args = array(
610 610
             'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611 611
             'autoloadpaths'               => array(
612
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
612
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/'
613 613
             ),
614 614
             'messengers_to_activate_with' => array('email'),
615 615
             'messengers_to_validate_with' => array('email')
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
         //register payment reminder message type
620 620
         $setup_args = array(
621 621
             'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
622
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
622
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
623 623
             'messengers_to_activate_with' => array('email'),
624 624
             'messengers_to_validate_with' => array('email')
625 625
         );
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
         //register payment declined message type
629 629
         $setup_args = array(
630 630
             'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
631
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
631
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
632 632
             'messengers_to_activate_with' => array('email'),
633 633
             'messengers_to_validate_with' => array('email')
634 634
         );
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         //register registration declined message type
638 638
         $setup_args = array(
639 639
             'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
640
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
640
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
641 641
             'messengers_to_activate_with' => array('email'),
642 642
             'messengers_to_validate_with' => array('email')
643 643
         );
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
         //register registration cancelled message type
647 647
         $setup_args = array(
648 648
             'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
649
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
649
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
650 650
             'messengers_to_activate_with' => array('email'),
651 651
             'messengers_to_validate_with' => array('email')
652 652
         );
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
         //register payment failed message type
657 657
         $setup_args = array(
658 658
             'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
659
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
659
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
660 660
             'messengers_to_activate_with' => array('email'),
661 661
             'messengers_to_validate_with' => array('email')
662 662
         );
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
         //register payment declined message type
666 666
         $setup_args = array(
667 667
             'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
668
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
668
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
669 669
             'messengers_to_activate_with' => array('email'),
670 670
             'messengers_to_validate_with' => array('email')
671 671
         );
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
     {
685 685
         $setup_args = array(
686 686
             'autoloadpaths'                 => array(
687
-                EE_CAF_LIBRARIES . 'shortcodes/'
687
+                EE_CAF_LIBRARIES.'shortcodes/'
688 688
             ),
689 689
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
690 690
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
Please login to merge, or discard this patch.
caffeinated/core/libraries/shortcodes/EE_Question_List_Shortcodes.lib.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -36,80 +36,80 @@  discard block
 block discarded – undo
36 36
 {
37 37
     
38 38
     
39
-    public function __construct()
40
-    {
41
-        parent::__construct();
42
-    }
39
+	public function __construct()
40
+	{
41
+		parent::__construct();
42
+	}
43 43
     
44 44
     
45
-    protected function _init_props()
46
-    {
47
-        $this->label       = __('Questions and Answers Shortcodes', 'event_espresso');
48
-        $this->description = __('All shortcodes related to custom questions and answers', 'event_espresso');
49
-        $this->_shortcodes = array(
50
-            '[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant.  You place this within the "[attendee_list]" field.',
51
-                'event_espresso')
52
-        );
53
-    }
45
+	protected function _init_props()
46
+	{
47
+		$this->label       = __('Questions and Answers Shortcodes', 'event_espresso');
48
+		$this->description = __('All shortcodes related to custom questions and answers', 'event_espresso');
49
+		$this->_shortcodes = array(
50
+			'[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant.  You place this within the "[attendee_list]" field.',
51
+				'event_espresso')
52
+		);
53
+	}
54 54
     
55 55
     
56
-    protected function _parser($shortcode)
57
-    {
56
+	protected function _parser($shortcode)
57
+	{
58 58
         
59 59
         
60
-        switch ($shortcode) {
61
-            case '[QUESTION_LIST]' :
62
-                return $this->_get_question_list();
63
-                break;
64
-        }
60
+		switch ($shortcode) {
61
+			case '[QUESTION_LIST]' :
62
+				return $this->_get_question_list();
63
+				break;
64
+		}
65 65
         
66
-        return '';
67
-    }
66
+		return '';
67
+	}
68 68
     
69 69
     
70
-    protected function _get_question_list()
71
-    {
72
-        $this->_validate_list_requirements();
70
+	protected function _get_question_list()
71
+	{
72
+		$this->_validate_list_requirements();
73 73
         
74
-        //for when [QUESTION_LIST] is used in the [attendee_list] field.
75
-        if ($this->_data['data'] instanceof EE_Registration) {
76
-            return $this->_get_question_answer_list_for_attendee();
77
-        } //for when [QUESTION_LIST] is used in the main content field.
78
-        else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) {
79
-            return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj);
80
-        } else {
81
-            return '';
82
-        }
83
-    }
74
+		//for when [QUESTION_LIST] is used in the [attendee_list] field.
75
+		if ($this->_data['data'] instanceof EE_Registration) {
76
+			return $this->_get_question_answer_list_for_attendee();
77
+		} //for when [QUESTION_LIST] is used in the main content field.
78
+		else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) {
79
+			return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj);
80
+		} else {
81
+			return '';
82
+		}
83
+	}
84 84
     
85 85
     
86
-    /**
87
-     * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of
88
-     * answers for that attendee since that is what we really need (we can derive the questions from the answers);
89
-     * @return string parsed template.
90
-     */
91
-    private function _get_question_answer_list_for_attendee($reg_obj = null)
92
-    {
93
-        $valid_shortcodes = array('question');
94
-        $reg_obj          = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data'];
95
-        $template         = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : '';
96
-        $template         = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template;
97
-        $ans_result       = '';
98
-        $answers          = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array();
99
-        $questions        = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
100
-        foreach ($answers as $answer) {
101
-            //first see if the question is in our $questions array.  If not then try to get from answer object
102
-            $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
103
-            $question = ! $question instanceof EE_Question ? $answer->question() : $question;
104
-            if ($question instanceof EE_Question and $question->admin_only()) {
105
-                continue;
106
-            }
107
-            $ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes,
108
-                $this->_extra_data);
109
-        }
86
+	/**
87
+	 * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of
88
+	 * answers for that attendee since that is what we really need (we can derive the questions from the answers);
89
+	 * @return string parsed template.
90
+	 */
91
+	private function _get_question_answer_list_for_attendee($reg_obj = null)
92
+	{
93
+		$valid_shortcodes = array('question');
94
+		$reg_obj          = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data'];
95
+		$template         = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : '';
96
+		$template         = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template;
97
+		$ans_result       = '';
98
+		$answers          = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array();
99
+		$questions        = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
100
+		foreach ($answers as $answer) {
101
+			//first see if the question is in our $questions array.  If not then try to get from answer object
102
+			$question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
103
+			$question = ! $question instanceof EE_Question ? $answer->question() : $question;
104
+			if ($question instanceof EE_Question and $question->admin_only()) {
105
+				continue;
106
+			}
107
+			$ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes,
108
+				$this->_extra_data);
109
+		}
110 110
         
111
-        return $ans_result;
112
-    }
111
+		return $ans_result;
112
+	}
113 113
     
114 114
     
115 115
 } //end EE_Question_List_Shortcodes class
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
         $questions        = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
100 100
         foreach ($answers as $answer) {
101 101
             //first see if the question is in our $questions array.  If not then try to get from answer object
102
-            $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
102
+            $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
103 103
             $question = ! $question instanceof EE_Question ? $answer->question() : $question;
104 104
             if ($question instanceof EE_Question and $question->admin_only()) {
105 105
                 continue;
Please login to merge, or discard this patch.
help_tours/Registration_Form_Question_Groups_Help_Tour.class.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 /**
@@ -18,130 +18,130 @@  discard block
 block discarded – undo
18 18
 class Registration_Form_Question_Groups_Help_Tour extends EE_Help_Tour
19 19
 {
20 20
     
21
-    protected function _set_tour_properties()
22
-    {
23
-        $this->_label = __('Question Groups Tour', 'event_espresso');
24
-        $this->_slug  = $this->_is_caf ? 'question-groups-caf-overview-joyride' : 'question-groups-overview-joyride';
25
-    }
21
+	protected function _set_tour_properties()
22
+	{
23
+		$this->_label = __('Question Groups Tour', 'event_espresso');
24
+		$this->_slug  = $this->_is_caf ? 'question-groups-caf-overview-joyride' : 'question-groups-overview-joyride';
25
+	}
26 26
     
27 27
     
28
-    protected function _set_tour_stops()
29
-    {
30
-        $this->_stops = array(
31
-            10 => array(
32
-                'content' => $this->_start(),
33
-            )
34
-        );
28
+	protected function _set_tour_stops()
29
+	{
30
+		$this->_stops = array(
31
+			10 => array(
32
+				'content' => $this->_start(),
33
+			)
34
+		);
35 35
         
36
-        if ($this->_is_caf) {
37
-            $this->_stops[20] = array(
38
-                'id'      => 'name',
39
-                'content' => $this->_name_stop(),
40
-                'options' => array(
41
-                    'tipLocation'    => 'top',
42
-                    'tipAdjustmentY' => -30,
43
-                    'tipAdjustmentX' => 25
44
-                )
45
-            );
46
-            $this->_stops[30] = array(
47
-                'id'      => 'description',
48
-                'content' => $this->_description_stop(),
49
-                'options' => array(
50
-                    'tipLocation'    => 'top',
51
-                    'tipAdjustmentY' => -30,
52
-                    'tipAdjustmentX' => 20
53
-                )
54
-            );
55
-            $this->_stops[40] = array(
56
-                'id'      => 'show_group_name',
57
-                'content' => $this->_show_group_name_stop(),
58
-                'options' => array(
59
-                    'tipLocation'    => 'top',
60
-                    'tipAdjustmentY' => -30,
61
-                    'tipAdjustmentX' => 20
62
-                )
63
-            );
64
-            $this->_stops[50] = array(
65
-                'id'      => 'show_group_desc',
66
-                'content' => $this->_show_group_description_stop(),
67
-                'options' => array(
68
-                    'tipLocation'    => 'top',
69
-                    'tipAdjustmentY' => -30,
70
-                    'tipAdjustmentX' => 20
71
-                )
72
-            );
73
-            $this->_stops[60] = array(
74
-                'class'   => 'bulkactions',
75
-                'content' => $this->_bulk_actions_stop(),
76
-                'options' => array(
77
-                    'tipLocation'    => 'left',
78
-                    'tipAdjustmentY' => -50,
79
-                    'tipAdjustmentX' => -80
80
-                )
81
-            );
82
-            $this->_stops[70] = array(
83
-                'id'      => 'add-new-question-group',
84
-                'content' => $this->_add_new_question_group_stop(),
85
-                'options' => array(
86
-                    'tipLocation'    => 'right',
87
-                    'tipAdjustmentY' => -50,
88
-                    'tipAdjustmentX' => 15
89
-                )
90
-            );
91
-        }
92
-    }
36
+		if ($this->_is_caf) {
37
+			$this->_stops[20] = array(
38
+				'id'      => 'name',
39
+				'content' => $this->_name_stop(),
40
+				'options' => array(
41
+					'tipLocation'    => 'top',
42
+					'tipAdjustmentY' => -30,
43
+					'tipAdjustmentX' => 25
44
+				)
45
+			);
46
+			$this->_stops[30] = array(
47
+				'id'      => 'description',
48
+				'content' => $this->_description_stop(),
49
+				'options' => array(
50
+					'tipLocation'    => 'top',
51
+					'tipAdjustmentY' => -30,
52
+					'tipAdjustmentX' => 20
53
+				)
54
+			);
55
+			$this->_stops[40] = array(
56
+				'id'      => 'show_group_name',
57
+				'content' => $this->_show_group_name_stop(),
58
+				'options' => array(
59
+					'tipLocation'    => 'top',
60
+					'tipAdjustmentY' => -30,
61
+					'tipAdjustmentX' => 20
62
+				)
63
+			);
64
+			$this->_stops[50] = array(
65
+				'id'      => 'show_group_desc',
66
+				'content' => $this->_show_group_description_stop(),
67
+				'options' => array(
68
+					'tipLocation'    => 'top',
69
+					'tipAdjustmentY' => -30,
70
+					'tipAdjustmentX' => 20
71
+				)
72
+			);
73
+			$this->_stops[60] = array(
74
+				'class'   => 'bulkactions',
75
+				'content' => $this->_bulk_actions_stop(),
76
+				'options' => array(
77
+					'tipLocation'    => 'left',
78
+					'tipAdjustmentY' => -50,
79
+					'tipAdjustmentX' => -80
80
+				)
81
+			);
82
+			$this->_stops[70] = array(
83
+				'id'      => 'add-new-question-group',
84
+				'content' => $this->_add_new_question_group_stop(),
85
+				'options' => array(
86
+					'tipLocation'    => 'right',
87
+					'tipAdjustmentY' => -50,
88
+					'tipAdjustmentX' => 15
89
+				)
90
+			);
91
+		}
92
+	}
93 93
     
94 94
     
95
-    protected function _start()
96
-    {
97
-        $content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>';
98
-        if ($this->_is_caf) {
99
-            $content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
-                    'event_espresso') . '</p>';
101
-        } else {
102
-            $content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
-                    'event_espresso') . '</p>';
104
-        }
95
+	protected function _start()
96
+	{
97
+		$content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>';
98
+		if ($this->_is_caf) {
99
+			$content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
+					'event_espresso') . '</p>';
101
+		} else {
102
+			$content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
+					'event_espresso') . '</p>';
104
+		}
105 105
         
106
-        return $content;
107
-    }
106
+		return $content;
107
+	}
108 108
     
109
-    protected function _name_stop()
110
-    {
111
-        return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
-            'event_espresso') . '</p>';
113
-    }
109
+	protected function _name_stop()
110
+	{
111
+		return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
+			'event_espresso') . '</p>';
113
+	}
114 114
     
115
-    protected function _description_stop()
116
-    {
117
-        return '<p>' . __('View the question group description.', 'event_espresso') . '</p>';
118
-    }
115
+	protected function _description_stop()
116
+	{
117
+		return '<p>' . __('View the question group description.', 'event_espresso') . '</p>';
118
+	}
119 119
     
120
-    protected function _show_group_name_stop()
121
-    {
122
-        return '<p>' . __('View if the name of the question group should be shown to customers.',
123
-            'event_espresso') . '</p>';
124
-    }
120
+	protected function _show_group_name_stop()
121
+	{
122
+		return '<p>' . __('View if the name of the question group should be shown to customers.',
123
+			'event_espresso') . '</p>';
124
+	}
125 125
     
126
-    protected function _show_group_description_stop()
127
-    {
128
-        return '<p>' . __('View if the description of the question group should be shown to customers.',
129
-            'event_espresso') . '</p>';
130
-    }
126
+	protected function _show_group_description_stop()
127
+	{
128
+		return '<p>' . __('View if the description of the question group should be shown to customers.',
129
+			'event_espresso') . '</p>';
130
+	}
131 131
     
132
-    protected function _bulk_actions_stop()
133
-    {
134
-        return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>';
135
-    }
132
+	protected function _bulk_actions_stop()
133
+	{
134
+		return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>';
135
+	}
136 136
     
137
-    protected function _search_stop()
138
-    {
139
-        return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.',
140
-            'event_espresso') . '</p>';
141
-    }
137
+	protected function _search_stop()
138
+	{
139
+		return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.',
140
+			'event_espresso') . '</p>';
141
+	}
142 142
     
143
-    protected function _add_new_question_group_stop()
144
-    {
145
-        return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>';
146
-    }
143
+	protected function _add_new_question_group_stop()
144
+	{
145
+		return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>';
146
+	}
147 147
 }
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
     
95 95
     protected function _start()
96 96
     {
97
-        $content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>';
97
+        $content = '<h3>'.__('Question Groups', 'event_espresso').'</h3>';
98 98
         if ($this->_is_caf) {
99
-            $content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
-                    'event_espresso') . '</p>';
99
+            $content .= '<p>'.__('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
+                    'event_espresso').'</p>';
101 101
         } else {
102
-            $content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
-                    'event_espresso') . '</p>';
102
+            $content .= '<p>'.__('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
+                    'event_espresso').'</p>';
104 104
         }
105 105
         
106 106
         return $content;
@@ -108,40 +108,40 @@  discard block
 block discarded – undo
108 108
     
109 109
     protected function _name_stop()
110 110
     {
111
-        return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
-            'event_espresso') . '</p>';
111
+        return '<p>'.__('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
+            'event_espresso').'</p>';
113 113
     }
114 114
     
115 115
     protected function _description_stop()
116 116
     {
117
-        return '<p>' . __('View the question group description.', 'event_espresso') . '</p>';
117
+        return '<p>'.__('View the question group description.', 'event_espresso').'</p>';
118 118
     }
119 119
     
120 120
     protected function _show_group_name_stop()
121 121
     {
122
-        return '<p>' . __('View if the name of the question group should be shown to customers.',
123
-            'event_espresso') . '</p>';
122
+        return '<p>'.__('View if the name of the question group should be shown to customers.',
123
+            'event_espresso').'</p>';
124 124
     }
125 125
     
126 126
     protected function _show_group_description_stop()
127 127
     {
128
-        return '<p>' . __('View if the description of the question group should be shown to customers.',
129
-            'event_espresso') . '</p>';
128
+        return '<p>'.__('View if the description of the question group should be shown to customers.',
129
+            'event_espresso').'</p>';
130 130
     }
131 131
     
132 132
     protected function _bulk_actions_stop()
133 133
     {
134
-        return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>';
134
+        return '<p>'.__('Perform bulk actions to multiple question groups.', 'event_espresso').'</p>';
135 135
     }
136 136
     
137 137
     protected function _search_stop()
138 138
     {
139
-        return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.',
140
-            'event_espresso') . '</p>';
139
+        return '<p>'.__('Search through questions. The following sources will be searched: question group name and question group description.',
140
+            'event_espresso').'</p>';
141 141
     }
142 142
     
143 143
     protected function _add_new_question_group_stop()
144 144
     {
145
-        return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>';
145
+        return '<p>'.__('Click here to create a new question group.', 'event_espresso').'</p>';
146 146
     }
147 147
 }
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
general_settings/help_tours/Your_Organization_Help_Tour.class.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 /**
@@ -18,121 +18,121 @@  discard block
 block discarded – undo
18 18
 class Your_Organization_Help_Tour extends EE_Help_Tour
19 19
 {
20 20
     
21
-    protected function _set_tour_properties()
22
-    {
23
-        $this->_label = __('Your Organization Tour', 'event_espresso');
24
-        $this->_slug  = 'your-organization-joyride';
25
-    }
21
+	protected function _set_tour_properties()
22
+	{
23
+		$this->_label = __('Your Organization Tour', 'event_espresso');
24
+		$this->_slug  = 'your-organization-joyride';
25
+	}
26 26
     
27 27
     
28
-    protected function _set_tour_stops()
29
-    {
30
-        $this->_stops = array(
31
-            10 => array(
32
-                'content' => $this->_start(),
33
-            ),
34
-            30 => array(
35
-                'id'      => 'contact_info_h4',
36
-                'content' => $this->_contact_information_stop(),
37
-                'options' => array(
38
-                    'tipLocation'    => 'left',
39
-                    'tipAdjustmentY' => -50,
40
-                    'tipAdjustmentX' => 15
41
-                )
42
-            ),
43
-            40 => array(
44
-                'id'      => 'upload_image',
45
-                'content' => $this->_upload_image_stop(),
46
-                'options' => array(
47
-                    'tipLocation'    => 'right',
48
-                    'tipAdjustmentY' => -50,
49
-                    'tipAdjustmentX' => 15
50
-                )
51
-            ),
52
-            50 => array(
53
-                'id'      => 'organization_facebook',
54
-                'content' => $this->_organization_facebook_stop(),
55
-                'options' => array(
56
-                    'tipLocation'    => 'right',
57
-                    'tipAdjustmentY' => -50,
58
-                    'tipAdjustmentX' => 15
59
-                )
60
-            ),
61
-            60 => array(
62
-                'id'      => 'ueip_optin',
63
-                'content' => $this->_ueip_option_stop(),
64
-                'options' => array(
65
-                    'tipLocation'    => 'right',
66
-                    'tipAdjustmentY' => -50,
67
-                    'tipAdjustmentX' => 15
68
-                )
69
-            ),
70
-            70 => array(
71
-                'id'      => 'espresso_major_buttons_wrapper',
72
-                'content' => $this->_end_tour_stop(),
73
-                'options' => array(
74
-                    'tipLocation'    => 'right',
75
-                    'tipAdjustmentY' => -50,
76
-                    'tipAdjustmentX' => 185
77
-                )
78
-            )
79
-        );
28
+	protected function _set_tour_stops()
29
+	{
30
+		$this->_stops = array(
31
+			10 => array(
32
+				'content' => $this->_start(),
33
+			),
34
+			30 => array(
35
+				'id'      => 'contact_info_h4',
36
+				'content' => $this->_contact_information_stop(),
37
+				'options' => array(
38
+					'tipLocation'    => 'left',
39
+					'tipAdjustmentY' => -50,
40
+					'tipAdjustmentX' => 15
41
+				)
42
+			),
43
+			40 => array(
44
+				'id'      => 'upload_image',
45
+				'content' => $this->_upload_image_stop(),
46
+				'options' => array(
47
+					'tipLocation'    => 'right',
48
+					'tipAdjustmentY' => -50,
49
+					'tipAdjustmentX' => 15
50
+				)
51
+			),
52
+			50 => array(
53
+				'id'      => 'organization_facebook',
54
+				'content' => $this->_organization_facebook_stop(),
55
+				'options' => array(
56
+					'tipLocation'    => 'right',
57
+					'tipAdjustmentY' => -50,
58
+					'tipAdjustmentX' => 15
59
+				)
60
+			),
61
+			60 => array(
62
+				'id'      => 'ueip_optin',
63
+				'content' => $this->_ueip_option_stop(),
64
+				'options' => array(
65
+					'tipLocation'    => 'right',
66
+					'tipAdjustmentY' => -50,
67
+					'tipAdjustmentX' => 15
68
+				)
69
+			),
70
+			70 => array(
71
+				'id'      => 'espresso_major_buttons_wrapper',
72
+				'content' => $this->_end_tour_stop(),
73
+				'options' => array(
74
+					'tipLocation'    => 'right',
75
+					'tipAdjustmentY' => -50,
76
+					'tipAdjustmentX' => 185
77
+				)
78
+			)
79
+		);
80 80
         
81
-        if (is_main_site()) {
82
-            $this->_stops[20] = array(
83
-                'id' => 'site_license_key',
84
-                'content' => $this->_site_license_key_stop(),
85
-                'options' => array(
86
-                    'tipLocation' => 'right',
87
-                    'tipAdjustmentY' => -50,
88
-                    'tipAdjustmentX' => 15
89
-                )
90
-            );
91
-        }
92
-        ksort( $this->_stops );
93
-    }
81
+		if (is_main_site()) {
82
+			$this->_stops[20] = array(
83
+				'id' => 'site_license_key',
84
+				'content' => $this->_site_license_key_stop(),
85
+				'options' => array(
86
+					'tipLocation' => 'right',
87
+					'tipAdjustmentY' => -50,
88
+					'tipAdjustmentX' => 15
89
+				)
90
+			);
91
+		}
92
+		ksort( $this->_stops );
93
+	}
94 94
     
95 95
     
96
-    protected function _start()
97
-    {
98
-        $content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>';
99
-        $content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
-                'event_espresso') . '</p>';
96
+	protected function _start()
97
+	{
98
+		$content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>';
99
+		$content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
+				'event_espresso') . '</p>';
101 101
         
102
-        return $content;
103
-    }
102
+		return $content;
103
+	}
104 104
     
105
-    protected function _site_license_key_stop()
106
-    {
107
-        return '<p>' . __('Enter your support license key here to enable one-click updates.',
108
-            'event_espresso') . '</p>';
109
-    }
105
+	protected function _site_license_key_stop()
106
+	{
107
+		return '<p>' . __('Enter your support license key here to enable one-click updates.',
108
+			'event_espresso') . '</p>';
109
+	}
110 110
     
111
-    protected function _contact_information_stop()
112
-    {
113
-        return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
-            'event_espresso') . '</p>';
115
-    }
111
+	protected function _contact_information_stop()
112
+	{
113
+		return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
+			'event_espresso') . '</p>';
115
+	}
116 116
     
117
-    protected function _upload_image_stop()
118
-    {
119
-        return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>';
120
-    }
117
+	protected function _upload_image_stop()
118
+	{
119
+		return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>';
120
+	}
121 121
     
122
-    protected function _organization_facebook_stop()
123
-    {
124
-        return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>';
125
-    }
122
+	protected function _organization_facebook_stop()
123
+	{
124
+		return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>';
125
+	}
126 126
     
127
-    protected function _ueip_option_stop()
128
-    {
129
-        return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
-            'event_espresso') . '</p>';
131
-    }
127
+	protected function _ueip_option_stop()
128
+	{
129
+		return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
+			'event_espresso') . '</p>';
131
+	}
132 132
     
133
-    protected function _end_tour_stop()
134
-    {
135
-        return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
-            'event_espresso') . '</p>';
137
-    }
133
+	protected function _end_tour_stop()
134
+	{
135
+		return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
+			'event_espresso') . '</p>';
137
+	}
138 138
 }
139 139
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -89,50 +89,50 @@
 block discarded – undo
89 89
                 )
90 90
             );
91 91
         }
92
-        ksort( $this->_stops );
92
+        ksort($this->_stops);
93 93
     }
94 94
     
95 95
     
96 96
     protected function _start()
97 97
     {
98
-        $content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>';
99
-        $content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
-                'event_espresso') . '</p>';
98
+        $content = '<h3>'.__('Organization Settings', 'event_espresso').'</h3>';
99
+        $content .= '<p>'.__('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
+                'event_espresso').'</p>';
101 101
         
102 102
         return $content;
103 103
     }
104 104
     
105 105
     protected function _site_license_key_stop()
106 106
     {
107
-        return '<p>' . __('Enter your support license key here to enable one-click updates.',
108
-            'event_espresso') . '</p>';
107
+        return '<p>'.__('Enter your support license key here to enable one-click updates.',
108
+            'event_espresso').'</p>';
109 109
     }
110 110
     
111 111
     protected function _contact_information_stop()
112 112
     {
113
-        return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
-            'event_espresso') . '</p>';
113
+        return '<p>'.__('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
+            'event_espresso').'</p>';
115 115
     }
116 116
     
117 117
     protected function _upload_image_stop()
118 118
     {
119
-        return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>';
119
+        return '<p>'.__('Add a logo. This can be used for invoices and tickets.', 'event_espresso').'</p>';
120 120
     }
121 121
     
122 122
     protected function _organization_facebook_stop()
123 123
     {
124
-        return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>';
124
+        return '<p>'.__('Add links to various social media networks.', 'event_espresso').'</p>';
125 125
     }
126 126
     
127 127
     protected function _ueip_option_stop()
128 128
     {
129
-        return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
-            'event_espresso') . '</p>';
129
+        return '<p>'.__('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
+            'event_espresso').'</p>';
131 131
     }
132 132
     
133 133
     protected function _end_tour_stop()
134 134
     {
135
-        return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
-            'event_espresso') . '</p>';
135
+        return '<p>'.__('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
+            'event_espresso').'</p>';
137 137
     }
138 138
 }
139 139
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/maintenance/templates/migration_options_from_ee4.template.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
             <tr>
26 26
                 <td>
27 27
                     <?php
28
-                    echo apply_filters(
29
-                            'FHEE__ee_migration_page__option_1_main',
30
-                            esc_html__('Before updating your database, you should first create a database backup',
31
-                                    "event_espresso"),
32
-                            $current_db_state,
33
-                            $next_db_state
34
-                    );
35
-                    ?>
28
+					echo apply_filters(
29
+							'FHEE__ee_migration_page__option_1_main',
30
+							esc_html__('Before updating your database, you should first create a database backup',
31
+									"event_espresso"),
32
+							$current_db_state,
33
+							$next_db_state
34
+					);
35
+					?>
36 36
                     <a id="display-migration-details"
37 37
                        class="display-the-hidden lt-grey-text smaller-text hide-if-no-js"
38 38
                        rel="migration-details"><?php esc_html_e('How Do I Make a Database Backup?', "event_espresso"); ?>
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
                 <td>
42 42
                     <a id="db-backed-up"
43 43
                        class="toggle-migration-monitor button-primary"><?php echo apply_filters('FHEE__ee_migration_page__option_1_button_text',
44
-                                sprintf(esc_html__("My Database Is Backed Up, Continue", "event_espresso"), $current_db_state,
45
-                                        $next_db_state), $current_db_state, $next_db_state); ?></a>
44
+								sprintf(esc_html__("My Database Is Backed Up, Continue", "event_espresso"), $current_db_state,
45
+										$next_db_state), $current_db_state, $next_db_state); ?></a>
46 46
                 </td>
47 47
             </tr>
48 48
             <tr>
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
                     <div id="migration-details-dv" style="display: none; padding: 1em;">
51 51
                         <p>
52 52
                             <?php
53
-                            printf(
54
-                                    esc_html__('%1$sClick Here to Learn How To Backup your Database Yourself%2$s. Or have one of our dedicated support technicians help you by %3$spurchasing a Priority Support Token.%2$s',
55
-                                            "event_espresso"),
56
-                                    '<a target="_blank" href="http://eventespresso.com/wiki/how-to-back-up-your-site/">',
57
-                                    "</a>",
58
-                                    "<a target=\"_blank\" href='http://eventespresso.com/product/priority-support-tokens/'>"
59
-                            );
60
-                            ?>
53
+							printf(
54
+									esc_html__('%1$sClick Here to Learn How To Backup your Database Yourself%2$s. Or have one of our dedicated support technicians help you by %3$spurchasing a Priority Support Token.%2$s',
55
+											"event_espresso"),
56
+									'<a target="_blank" href="http://eventespresso.com/wiki/how-to-back-up-your-site/">',
57
+									"</a>",
58
+									"<a target=\"_blank\" href='http://eventespresso.com/product/priority-support-tokens/'>"
59
+							);
60
+							?>
61 61
                         </p>
62 62
                         <?php do_action('AHEE__ee_migration_page__option_1_extra_details'); ?>
63 63
                     </div>
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
         </table>
68 68
     </div>
69 69
     <p><?php esc_html_e('Don\'t want to keep your old Event Espresso data? Alternatively, you can delete it all and start fresh.',
70
-                'event_espresso'); ?> <a
70
+				'event_espresso'); ?> <a
71 71
                 href=""><?php esc_html_e('Visit the Maintenance Page and Reset Your Event Espresso Data',
72
-                    'event_espresso'); ?></a></p>
72
+					'event_espresso'); ?></a></p>
73 73
     <?php do_action('AHEE__ee_migration_page__after_migration_options_table'); ?>
74 74
 </div>
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
     </div>
69 69
     <p><?php esc_html_e('Don\'t want to keep your old Event Espresso data? Alternatively, you can delete it all and start fresh.',
70 70
                 'event_espresso'); ?> <a
71
-                href="<?php echo $data_reset_page;?>"><?php esc_html_e('Visit the Maintenance Page and Reset Your Event Espresso Data',
71
+                href="<?php echo $data_reset_page; ?>"><?php esc_html_e('Visit the Maintenance Page and Reset Your Event Espresso Data',
72 72
                     'event_espresso'); ?></a></p>
73 73
     <?php do_action('AHEE__ee_migration_page__after_migration_options_table'); ?>
74 74
 </div>
75 75
\ No newline at end of file
Please login to merge, or discard this patch.