@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | 69 | |
70 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
70 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function _ajax_hooks() { |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'edit' => __('Update Event', 'event_espresso'), |
94 | 94 | 'add_category' => __('Save New Category', 'event_espresso'), |
95 | 95 | 'edit_category' => __('Update Category', 'event_espresso'), |
96 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
96 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function _set_page_routes() { |
102 | 102 | //load formatter helper |
103 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
103 | + EE_Registry::instance()->load_helper('Formatter'); |
|
104 | 104 | //load field generator helper |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $this->_page_routes = array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'help_tour' => array( |
321 | 321 | 'Event_Editor_Help_Tour' |
322 | 322 | ), |
323 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | 324 | 'require_nonce' => FALSE |
325 | 325 | ), |
326 | 326 | 'edit' => array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | 'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ), |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => FALSE |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'filename' => 'events_default_settings_status' |
399 | 399 | ) |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => FALSE |
403 | 403 | ), |
404 | 404 | //template settings |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'general_settings_templates' |
415 | 415 | ) |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ), |
420 | 420 | //event category stuff |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'label' => __('Edit Category', 'event_espresso'), |
439 | 439 | 'order' => 15, |
440 | 440 | 'persistent' => FALSE, |
441 | - '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 |
|
441 | + '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 |
|
442 | 442 | ), |
443 | 443 | 'help_tabs' => array( |
444 | 444 | 'edit_category_help_tab' => array( |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | |
509 | 509 | public function load_scripts_styles() { |
510 | 510 | |
511 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
511 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
513 | 513 | wp_enqueue_style('events-admin-css'); |
514 | 514 | wp_enqueue_style('ee-cat-admin'); |
515 | 515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
516 | 516 | //registers for all views |
517 | 517 | //scripts |
518 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
518 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function load_scripts_styles_edit() { |
534 | 534 | //styles |
535 | 535 | wp_enqueue_style('espresso-ui-theme'); |
536 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
536 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
537 | 537 | wp_enqueue_style('event-editor-css'); |
538 | 538 | |
539 | 539 | //scripts |
540 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
540 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
541 | 541 | wp_enqueue_script('event-datetime-metabox'); |
542 | 542 | |
543 | 543 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | public function admin_init() { |
575 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
575 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -593,35 +593,35 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function verify_event_edit($event = NULL) { |
595 | 595 | // no event? |
596 | - if ( empty( $event )) { |
|
596 | + if (empty($event)) { |
|
597 | 597 | // set event |
598 | 598 | $event = $this->_cpt_model_obj; |
599 | 599 | } |
600 | 600 | // STILL no event? |
601 | - if ( empty ( $event )) { |
|
601 | + if (empty ($event)) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | // first check if event is active. |
605 | - if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
|
605 | + if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) { |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | $orig_status = $event->status(); |
609 | 609 | //made it here so it IS active... next check that any of the tickets are sold. |
610 | - if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) { |
|
611 | - if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
612 | - EE_Error::add_attention( sprintf( |
|
613 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
614 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
610 | + if ($event->is_sold_out() || $event->is_sold_out(TRUE)) { |
|
611 | + if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) { |
|
612 | + EE_Error::add_attention(sprintf( |
|
613 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
614 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
615 | 615 | )); |
616 | 616 | } |
617 | 617 | return; |
618 | 618 | } |
619 | 619 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
620 | - if ( ! $event->tickets_on_sale() ) { |
|
620 | + if ( ! $event->tickets_on_sale()) { |
|
621 | 621 | return; |
622 | 622 | } |
623 | 623 | //made it here so show warning |
624 | - EE_Error::add_attention( $this->_edit_event_warning() ); |
|
624 | + EE_Error::add_attention($this->_edit_event_warning()); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | ), |
662 | 662 | ); |
663 | 663 | |
664 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
664 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
665 | 665 | $this->_views['trash'] = array( |
666 | 666 | 'slug' => 'trash', |
667 | 667 | 'label' => __('Trash', 'event_espresso'), |
@@ -691,39 +691,39 @@ discard block |
||
691 | 691 | 'desc' => __('View Registrations for Event', 'event_espresso') |
692 | 692 | ) |
693 | 693 | ); |
694 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
694 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
695 | 695 | $statuses = array( |
696 | 696 | 'sold_out_status' => array( |
697 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
698 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
697 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
698 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
699 | 699 | ), |
700 | 700 | 'active_status' => array( |
701 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
702 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
701 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
702 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
703 | 703 | ), |
704 | 704 | 'upcoming_status' => array( |
705 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
706 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
705 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
706 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
707 | 707 | ), |
708 | 708 | 'postponed_status' => array( |
709 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
710 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
709 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
710 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
711 | 711 | ), |
712 | 712 | 'cancelled_status' => array( |
713 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
714 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
713 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
714 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
715 | 715 | ), |
716 | 716 | 'expired_status' => array( |
717 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
718 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
717 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
718 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
719 | 719 | ), |
720 | 720 | 'inactive_status' => array( |
721 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
722 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
721 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
722 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
723 | 723 | ) |
724 | 724 | ); |
725 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
726 | - return array_merge( $items, $statuses ); |
|
725 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
726 | + return array_merge($items, $statuses); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | |
@@ -735,8 +735,8 @@ discard block |
||
735 | 735 | * @return EEM_Event |
736 | 736 | */ |
737 | 737 | private function _event_model() { |
738 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
739 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
738 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
739 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
740 | 740 | } |
741 | 741 | return $this->_event_model; |
742 | 742 | } |
@@ -755,12 +755,12 @@ discard block |
||
755 | 755 | * @param string $new_slug what the slug is |
756 | 756 | * @return string The new html string for the permalink area |
757 | 757 | */ |
758 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
758 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
759 | 759 | //make sure this is only when editing |
760 | - if ( !empty( $id ) ) { |
|
761 | - $post = get_post( $id ); |
|
762 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
763 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">'; |
|
760 | + if ( ! empty($id)) { |
|
761 | + $post = get_post($id); |
|
762 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
763 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">'; |
|
764 | 764 | } |
765 | 765 | return $return; |
766 | 766 | } |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | * @return string html for generated table |
777 | 777 | */ |
778 | 778 | protected function _events_overview_list_table() { |
779 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
780 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
779 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
780 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
781 | 781 | $this->_display_legend($this->_event_legend_items()); |
782 | 782 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
783 | 783 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -795,51 +795,51 @@ discard block |
||
795 | 795 | |
796 | 796 | |
797 | 797 | |
798 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
798 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
799 | 799 | |
800 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
800 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
801 | 801 | //getout we're not processing an event save. |
802 | 802 | return; |
803 | 803 | } |
804 | 804 | |
805 | 805 | $event_values = array( |
806 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
807 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
806 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
807 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
808 | 808 | 'EVT_additional_limit' => min( |
809 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
810 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
811 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
812 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
813 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
814 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
815 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
816 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
809 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
810 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
811 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
812 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
813 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
814 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
815 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
816 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
817 | 817 | ); |
818 | 818 | |
819 | 819 | //update event |
820 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
820 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
821 | 821 | |
822 | 822 | |
823 | 823 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_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! |
824 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
825 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
824 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
825 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
829 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
829 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
830 | 830 | |
831 | 831 | $att_success = TRUE; |
832 | 832 | |
833 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
834 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
835 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
833 | + foreach ($event_update_callbacks as $e_callback) { |
|
834 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
835 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | //any errors? |
839 | - if ( $success && FALSE === $att_success ) { |
|
840 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
841 | - } else if ( $success === FALSE ) { |
|
842 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
839 | + if ($success && FALSE === $att_success) { |
|
840 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
841 | + } else if ($success === FALSE) { |
|
842 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
843 | 843 | } |
844 | 844 | } |
845 | 845 | |
@@ -849,14 +849,14 @@ discard block |
||
849 | 849 | /** |
850 | 850 | * @see parent::restore_item() |
851 | 851 | */ |
852 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
852 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
853 | 853 | //copy existing event meta to new post |
854 | 854 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
855 | - if ( $post_evt instanceof EE_Event ) { |
|
855 | + if ($post_evt instanceof EE_Event) { |
|
856 | 856 | //meta revision restore |
857 | - $post_evt->restore_revision( $revision_id ); |
|
857 | + $post_evt->restore_revision($revision_id); |
|
858 | 858 | //related objs restore |
859 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
859 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
@@ -869,52 +869,52 @@ discard block |
||
869 | 869 | * @param array $data The request data from the form |
870 | 870 | * @return bool Success or fail. |
871 | 871 | */ |
872 | - protected function _default_venue_update( $evtobj, $data ) { |
|
873 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
872 | + protected function _default_venue_update($evtobj, $data) { |
|
873 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
874 | 874 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
875 | 875 | $rows_affected = NULL; |
876 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
876 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
877 | 877 | |
878 | 878 | // very important. If we don't have a venue name... |
879 | 879 | // then we'll get out because not necessary to create empty venue |
880 | - if ( empty( $data['venue_title'] ) ) { |
|
880 | + if (empty($data['venue_title'])) { |
|
881 | 881 | return false; |
882 | 882 | } |
883 | 883 | |
884 | 884 | $venue_array = array( |
885 | 885 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
886 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
887 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
888 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
889 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
890 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
891 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
892 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
893 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
894 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
895 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
896 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
897 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
898 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
899 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
900 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
901 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
886 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
887 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
888 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
889 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
890 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
891 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
892 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
893 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
894 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
895 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
896 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
897 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
898 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
899 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
900 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
901 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
902 | 902 | 'status' => 'publish' |
903 | 903 | ); |
904 | 904 | |
905 | 905 | |
906 | 906 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
907 | - if ( !empty( $venue_id ) ) { |
|
908 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
909 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
907 | + if ( ! empty($venue_id)) { |
|
908 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
909 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
910 | 910 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
911 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
911 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
912 | 912 | return $rows_affected > 0 ? TRUE : FALSE; |
913 | 913 | } else { |
914 | 914 | //we insert the venue |
915 | - $venue_id = $venue_model->insert( $venue_array ); |
|
916 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
917 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
915 | + $venue_id = $venue_model->insert($venue_array); |
|
916 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
917 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
918 | 918 | } |
919 | 919 | //when we have the ancestor come in it's already been handled by the revision save. |
920 | 920 | } |
@@ -928,55 +928,55 @@ discard block |
||
928 | 928 | * @param array $data The request data from the form |
929 | 929 | * @return bool success or fail |
930 | 930 | */ |
931 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
931 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
932 | 932 | $success = true; |
933 | 933 | $saved_dtt = null; |
934 | 934 | $saved_tickets = array(); |
935 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
935 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
936 | 936 | |
937 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
937 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
938 | 938 | //trim all values to ensure any excess whitespace is removed. |
939 | - $dtt = array_map( 'trim', $dtt ); |
|
940 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
939 | + $dtt = array_map('trim', $dtt); |
|
940 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
941 | 941 | $datetime_values = array( |
942 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
942 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
943 | 943 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
944 | 944 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
945 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
945 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
946 | 946 | 'DTT_order' => $row, |
947 | 947 | ); |
948 | 948 | |
949 | 949 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
950 | 950 | |
951 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
952 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
953 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
954 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
955 | - foreach ( $datetime_values as $field => $value ) { |
|
956 | - $DTM->set( $field, $value ); |
|
951 | + if ( ! empty($dtt['DTT_ID'])) { |
|
952 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
953 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
954 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
955 | + foreach ($datetime_values as $field => $value) { |
|
956 | + $DTM->set($field, $value); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
960 | 960 | $saved_dtts[$DTM->ID()] = $DTM; |
961 | 961 | } else { |
962 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
963 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
964 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
965 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
966 | - foreach ( $datetime_values as $field => $value ) { |
|
967 | - $DTM->set( $field, $value ); |
|
962 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
963 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
964 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
965 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
966 | + foreach ($datetime_values as $field => $value) { |
|
967 | + $DTM->set($field, $value); |
|
968 | 968 | } |
969 | 969 | } |
970 | 970 | $DTM->save(); |
971 | 971 | |
972 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
972 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
973 | 973 | |
974 | 974 | //load DTT helper |
975 | 975 | EE_Registry::instance()->load_helper('DTT_Helper'); |
976 | 976 | |
977 | 977 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
978 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
979 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
978 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
979 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
980 | 980 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
981 | 981 | $DTT->save(); |
982 | 982 | } |
@@ -984,45 +984,45 @@ discard block |
||
984 | 984 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
985 | 985 | $saved_dtt = $DTT; |
986 | 986 | |
987 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
987 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | //no dtts get deleted so we don't do any of that logic here. |
991 | 991 | //update tickets next |
992 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
993 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
994 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
992 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
993 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
994 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
995 | 995 | $update_prices = false; |
996 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
996 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
997 | 997 | |
998 | 998 | // trim inputs to ensure any excess whitespace is removed. |
999 | - $tkt = array_map( 'trim', $tkt ); |
|
999 | + $tkt = array_map('trim', $tkt); |
|
1000 | 1000 | |
1001 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1001 | + if (empty($tkt['TKT_start_date'])) { |
|
1002 | 1002 | //let's use now in the set timezone. |
1003 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1004 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1003 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1004 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1007 | + if (empty($tkt['TKT_end_date'])) { |
|
1008 | 1008 | //use the start date of the first datetime |
1009 | 1009 | $dtt = $evtobj->first_datetime(); |
1010 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1010 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | $TKT_values = array( |
1014 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1015 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1016 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1017 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1014 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1015 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1016 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1017 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1018 | 1018 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1019 | 1019 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1020 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1021 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1022 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1023 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1020 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1021 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1022 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1023 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1024 | 1024 | 'TKT_row' => $row, |
1025 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1025 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1026 | 1026 | 'TKT_price' => $ticket_price |
1027 | 1027 | ); |
1028 | 1028 | |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | |
1031 | 1031 | |
1032 | 1032 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1033 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1033 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1034 | 1034 | $TKT_values['TKT_ID'] = 0; |
1035 | 1035 | $TKT_values['TKT_is_default'] = 0; |
1036 | 1036 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1041,58 +1041,58 @@ discard block |
||
1041 | 1041 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1042 | 1042 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1043 | 1043 | |
1044 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1045 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1046 | - if ( $TKT instanceof EE_Ticket ) { |
|
1047 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1044 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1045 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1046 | + if ($TKT instanceof EE_Ticket) { |
|
1047 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1048 | 1048 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1049 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1050 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1051 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1049 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1050 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1051 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1052 | 1052 | //set new values |
1053 | - foreach ( $TKT_values as $field => $value ) { |
|
1054 | - if ( $field == 'TKT_qty' ) { |
|
1055 | - $TKT->set_qty( $value ); |
|
1053 | + foreach ($TKT_values as $field => $value) { |
|
1054 | + if ($field == 'TKT_qty') { |
|
1055 | + $TKT->set_qty($value); |
|
1056 | 1056 | } else { |
1057 | - $TKT->set( $field, $value ); |
|
1057 | + $TKT->set($field, $value); |
|
1058 | 1058 | } |
1059 | 1059 | } |
1060 | 1060 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1061 | - if ( $create_new_TKT ) { |
|
1061 | + if ($create_new_TKT) { |
|
1062 | 1062 | //archive the old ticket first |
1063 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1063 | + $TKT->set('TKT_deleted', 1); |
|
1064 | 1064 | $TKT->save(); |
1065 | 1065 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1066 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1066 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1067 | 1067 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1068 | 1068 | $TKT = clone $TKT; |
1069 | - $TKT->set( 'TKT_ID', 0 ); |
|
1070 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1071 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1072 | - $TKT->set( 'TKT_sold', 0 ); |
|
1069 | + $TKT->set('TKT_ID', 0); |
|
1070 | + $TKT->set('TKT_deleted', 0); |
|
1071 | + $TKT->set('TKT_price', $ticket_price); |
|
1072 | + $TKT->set('TKT_sold', 0); |
|
1073 | 1073 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1074 | 1074 | $update_prices = true; |
1075 | 1075 | } |
1076 | 1076 | //make sure price is set if it hasn't been already |
1077 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1077 | + $TKT->set('TKT_price', $ticket_price); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | } else { |
1081 | 1081 | //no TKT_id so a new TKT |
1082 | 1082 | $TKT_values['TKT_price'] = $ticket_price; |
1083 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1084 | - if ( $TKT instanceof EE_Ticket ) { |
|
1083 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1084 | + if ($TKT instanceof EE_Ticket) { |
|
1085 | 1085 | //need to reset values to properly account for the date formats |
1086 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1087 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1088 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1086 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1087 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1088 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1089 | 1089 | |
1090 | 1090 | //set new values |
1091 | - foreach ( $TKT_values as $field => $value ) { |
|
1092 | - if ( $field == 'TKT_qty' ) { |
|
1093 | - $TKT->set_qty( $value ); |
|
1091 | + foreach ($TKT_values as $field => $value) { |
|
1092 | + if ($field == 'TKT_qty') { |
|
1093 | + $TKT->set_qty($value); |
|
1094 | 1094 | } else { |
1095 | - $TKT->set( $field, $value ); |
|
1095 | + $TKT->set($field, $value); |
|
1096 | 1096 | } |
1097 | 1097 | } |
1098 | 1098 | |
@@ -1100,32 +1100,32 @@ discard block |
||
1100 | 1100 | } |
1101 | 1101 | } |
1102 | 1102 | // cap ticket qty by datetime reg limits |
1103 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1103 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1104 | 1104 | //update ticket. |
1105 | 1105 | $TKT->save(); |
1106 | 1106 | |
1107 | 1107 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1108 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1109 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1108 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1109 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1110 | 1110 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1111 | 1111 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1112 | 1112 | $TKT->save(); |
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | //initially let's add the ticket to the dtt |
1116 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1116 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1117 | 1117 | |
1118 | 1118 | $saved_tickets[$TKT->ID()] = $TKT; |
1119 | 1119 | |
1120 | 1120 | //add prices to ticket |
1121 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1121 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1122 | 1122 | } |
1123 | 1123 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1124 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1125 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1124 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1125 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1126 | 1126 | |
1127 | - foreach ( $tickets_removed as $id ) { |
|
1128 | - $id = absint( $id ); |
|
1127 | + foreach ($tickets_removed as $id) { |
|
1128 | + $id = absint($id); |
|
1129 | 1129 | |
1130 | 1130 | //get the ticket for this id |
1131 | 1131 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1134 | 1134 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1135 | 1135 | |
1136 | - foreach( $dtts as $dtt ) { |
|
1136 | + foreach ($dtts as $dtt) { |
|
1137 | 1137 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1138 | 1138 | } |
1139 | 1139 | |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1145 | 1145 | $tkt_to_remove->delete_permanently(); |
1146 | 1146 | } |
1147 | - return array( $saved_dtt, $saved_tickets ); |
|
1147 | + return array($saved_dtt, $saved_tickets); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | |
@@ -1159,31 +1159,31 @@ discard block |
||
1159 | 1159 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1160 | 1160 | * @return void |
1161 | 1161 | */ |
1162 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1163 | - foreach ( $prices as $row => $prc ) { |
|
1162 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1163 | + foreach ($prices as $row => $prc) { |
|
1164 | 1164 | $PRC_values = array( |
1165 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1166 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1167 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1168 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1169 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1165 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1166 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1167 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1168 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1169 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1170 | 1170 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1171 | 1171 | 'PRC_order' => $row |
1172 | 1172 | ); |
1173 | 1173 | |
1174 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1174 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1175 | 1175 | $PRC_values['PRC_ID'] = 0; |
1176 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1176 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1177 | 1177 | } else { |
1178 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1178 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1179 | 1179 | //update this price with new values |
1180 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1181 | - $PRC->set( $field, $newprc ); |
|
1180 | + foreach ($PRC_values as $field => $newprc) { |
|
1181 | + $PRC->set($field, $newprc); |
|
1182 | 1182 | } |
1183 | 1183 | $PRC->save(); |
1184 | 1184 | } |
1185 | 1185 | |
1186 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1186 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1187 | 1187 | } |
1188 | 1188 | } |
1189 | 1189 | |
@@ -1206,33 +1206,33 @@ discard block |
||
1206 | 1206 | |
1207 | 1207 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
1208 | 1208 | |
1209 | - $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
|
1209 | + $postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL; |
|
1210 | 1210 | |
1211 | 1211 | |
1212 | 1212 | //if no postid then get out cause we need it for stuff in here |
1213 | - if ( empty( $postid ) ) return; |
|
1213 | + if (empty($postid)) return; |
|
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | //handle datetime saves |
1217 | 1217 | $items = array(); |
1218 | 1218 | |
1219 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
|
1220 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
1219 | + $get_one_where = array($this->_event_model()->primary_key_name() => $postid); |
|
1220 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
1221 | 1221 | |
1222 | 1222 | //now let's get the attached datetimes from the most recent autosave |
1223 | 1223 | $dtts = $event->get_many_related('Datetime'); |
1224 | 1224 | |
1225 | 1225 | $dtt_ids = array(); |
1226 | - foreach( $dtts as $dtt ) { |
|
1226 | + foreach ($dtts as $dtt) { |
|
1227 | 1227 | $dtt_ids[] = $dtt->ID(); |
1228 | 1228 | $order = $dtt->order(); |
1229 | 1229 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
1230 | 1230 | } |
1231 | - $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
|
1231 | + $this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids); |
|
1232 | 1232 | |
1233 | 1233 | //handle DECAF venues |
1234 | 1234 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
1235 | - if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
|
1235 | + if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) { |
|
1236 | 1236 | $venue = $event->get_first_related('Venue'); |
1237 | 1237 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
1238 | 1238 | } |
@@ -1243,23 +1243,23 @@ discard block |
||
1243 | 1243 | |
1244 | 1244 | $ticket_ids = array(); |
1245 | 1245 | $price_ids = array(); |
1246 | - foreach ( $tickets as $ticket ) { |
|
1246 | + foreach ($tickets as $ticket) { |
|
1247 | 1247 | $ticket_ids[] = $price->ID(); |
1248 | 1248 | $ticket_order = $price->get('TKT_order'); |
1249 | - $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
|
1250 | - $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
|
1249 | + $this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID(); |
|
1250 | + $this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID(); |
|
1251 | 1251 | |
1252 | 1252 | //now we have to make sure the prices are updated appropriately |
1253 | 1253 | $prices = $ticket->get_many_related('Prices'); |
1254 | 1254 | |
1255 | - foreach ( $prices as $price ) { |
|
1255 | + foreach ($prices as $price) { |
|
1256 | 1256 | $price_ids[] = $price->ID(); |
1257 | 1257 | $price_order = $price->get('PRC_order'); |
1258 | - $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
|
1259 | - $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
|
1260 | - $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
|
1258 | + $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID(); |
|
1259 | + $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID(); |
|
1260 | + $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default'); |
|
1261 | 1261 | } |
1262 | - $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
|
1262 | + $this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids); |
|
1263 | 1263 | } |
1264 | 1264 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
1265 | 1265 | } |
@@ -1277,12 +1277,12 @@ discard block |
||
1277 | 1277 | private function _generate_publish_box_extra_content() { |
1278 | 1278 | |
1279 | 1279 | //load formatter helper |
1280 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1280 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1281 | 1281 | |
1282 | 1282 | //args for getting related registrations |
1283 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1284 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1285 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1283 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1284 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1285 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1286 | 1286 | |
1287 | 1287 | |
1288 | 1288 | // publish box |
@@ -1311,9 +1311,9 @@ discard block |
||
1311 | 1311 | ), |
1312 | 1312 | REG_ADMIN_URL |
1313 | 1313 | ), |
1314 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1315 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1316 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1314 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1315 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1316 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1317 | 1317 | 'misc_pub_section_class' => apply_filters( |
1318 | 1318 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1319 | 1319 | 'misc-pub-section' |
@@ -1332,9 +1332,9 @@ discard block |
||
1332 | 1332 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1333 | 1333 | $this->_cpt_model_obj |
1334 | 1334 | ); |
1335 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1335 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1336 | 1336 | // load template |
1337 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1337 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | |
@@ -1366,16 +1366,16 @@ discard block |
||
1366 | 1366 | $this->verify_cpt_object(); |
1367 | 1367 | add_meta_box( |
1368 | 1368 | 'espresso_event_editor_tickets', |
1369 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1370 | - array( $this, 'ticket_metabox' ), |
|
1369 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1370 | + array($this, 'ticket_metabox'), |
|
1371 | 1371 | $this->page_slug, |
1372 | 1372 | 'normal', |
1373 | 1373 | 'high' |
1374 | 1374 | ); |
1375 | 1375 | add_meta_box( |
1376 | 1376 | 'espresso_event_editor_event_options', |
1377 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1378 | - array( $this, 'registration_options_meta_box' ), |
|
1377 | + __('Event Registration Options', 'event_espresso'), |
|
1378 | + array($this, 'registration_options_meta_box'), |
|
1379 | 1379 | $this->page_slug, |
1380 | 1380 | 'side', |
1381 | 1381 | 'default' |
@@ -1405,38 +1405,38 @@ discard block |
||
1405 | 1405 | 'disabled' => '' |
1406 | 1406 | ); |
1407 | 1407 | |
1408 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1408 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1409 | 1409 | |
1410 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1410 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1411 | 1411 | |
1412 | 1412 | /** |
1413 | 1413 | * 1. Start with retrieving Datetimes |
1414 | 1414 | * 2. Fore each datetime get related tickets |
1415 | 1415 | * 3. For each ticket get related prices |
1416 | 1416 | */ |
1417 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1418 | - EE_Registry::instance()->load_helper('DTT_Helper' ); |
|
1417 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1418 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1419 | 1419 | /** @type EE_Datetime $first_datetime */ |
1420 | - $first_datetime = array_slice( $times, 0, 1 ); |
|
1420 | + $first_datetime = array_slice($times, 0, 1); |
|
1421 | 1421 | //do we get related tickets? |
1422 | - if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) { |
|
1423 | - foreach ( $times as $time ) { |
|
1424 | - if ( $time instanceof EE_Datetime ) { |
|
1422 | + if ($first_datetime[0]->get('DTT_ID') !== 0) { |
|
1423 | + foreach ($times as $time) { |
|
1424 | + if ($time instanceof EE_Datetime) { |
|
1425 | 1425 | $existing_datetime_ids[] = $time->get('DTT_ID'); |
1426 | 1426 | $template_args['time'] = $time; |
1427 | 1427 | $related_tickets = $time->tickets( |
1428 | 1428 | array( |
1429 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1429 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1430 | 1430 | 'default_where_conditions' => 'none' |
1431 | 1431 | ) |
1432 | 1432 | ); |
1433 | 1433 | |
1434 | - if ( !empty($related_tickets) ) { |
|
1434 | + if ( ! empty($related_tickets)) { |
|
1435 | 1435 | $template_args['total_ticket_rows'] = count($related_tickets); |
1436 | 1436 | $row = 0; |
1437 | - foreach ( $related_tickets as $ticket ) { |
|
1437 | + foreach ($related_tickets as $ticket) { |
|
1438 | 1438 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1439 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1439 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1440 | 1440 | |
1441 | 1441 | $row++; |
1442 | 1442 | } |
@@ -1444,7 +1444,7 @@ discard block |
||
1444 | 1444 | $template_args['total_ticket_rows'] = 1; |
1445 | 1445 | /** @type EE_Ticket $ticket */ |
1446 | 1446 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1447 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1447 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1448 | 1448 | } |
1449 | 1449 | } |
1450 | 1450 | } |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | $template_args['time'] = $times[0]; |
1453 | 1453 | /** @type EE_Ticket $ticket */ |
1454 | 1454 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1455 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1455 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1456 | 1456 | // NOTE: we're just sending the first default row |
1457 | 1457 | // (decaf can't manage default tickets so this should be sufficient); |
1458 | 1458 | } |
@@ -1461,8 +1461,8 @@ discard block |
||
1461 | 1461 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1462 | 1462 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1463 | 1463 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1464 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1465 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1464 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1465 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1466 | 1466 | EEH_Template::display_template($template, $template_args); |
1467 | 1467 | } |
1468 | 1468 | |
@@ -1477,21 +1477,21 @@ discard block |
||
1477 | 1477 | * @param int $row |
1478 | 1478 | * @return string generated html for the ticket row. |
1479 | 1479 | */ |
1480 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1480 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1481 | 1481 | $template_args = array( |
1482 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1483 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1482 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1483 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1484 | 1484 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1485 | 1485 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1486 | 1486 | 'TKT_name' => $ticket->get('TKT_name'), |
1487 | 1487 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1488 | 1488 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1489 | 1489 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1490 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1490 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1491 | 1491 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1492 | 1492 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1493 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1494 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1493 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1494 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1495 | 1495 | ); |
1496 | 1496 | |
1497 | 1497 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1507,23 +1507,23 @@ discard block |
||
1507 | 1507 | |
1508 | 1508 | //make sure we have default start and end dates if skeleton |
1509 | 1509 | //handle rows that should NOT be empty |
1510 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1510 | + if (empty($template_args['TKT_start_date'])) { |
|
1511 | 1511 | //if empty then the start date will be now. |
1512 | 1512 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1513 | 1513 | } |
1514 | 1514 | |
1515 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1515 | + if (empty($template_args['TKT_end_date'])) { |
|
1516 | 1516 | //get the earliest datetime (if present); |
1517 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1517 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1518 | 1518 | |
1519 | - if ( !empty( $earliest_dtt ) ) |
|
1519 | + if ( ! empty($earliest_dtt)) |
|
1520 | 1520 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1521 | 1521 | else |
1522 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1522 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | - $template_args = array_merge( $template_args, $price_args ); |
|
1526 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1525 | + $template_args = array_merge($template_args, $price_args); |
|
1526 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1527 | 1527 | return EEH_Template::display_template($template, $template_args, TRUE); |
1528 | 1528 | } |
1529 | 1529 | |
@@ -1552,8 +1552,8 @@ discard block |
||
1552 | 1552 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1553 | 1553 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1554 | 1554 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1555 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1556 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1555 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1556 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1557 | 1557 | EEH_Template::display_template($templatepath, $template_args); |
1558 | 1558 | } |
1559 | 1559 | |
@@ -1581,21 +1581,21 @@ discard block |
||
1581 | 1581 | $EEME = $this->_event_model(); |
1582 | 1582 | |
1583 | 1583 | $offset = ($current_page - 1) * $per_page; |
1584 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1584 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1585 | 1585 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1586 | 1586 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1587 | 1587 | |
1588 | 1588 | if (isset($this->_req_data['month_range'])) { |
1589 | 1589 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1590 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1591 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1590 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1591 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | $where = array(); |
1595 | 1595 | |
1596 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1596 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1597 | 1597 | //determine what post_status our condition will have for the query. |
1598 | - switch ( $status ) { |
|
1598 | + switch ($status) { |
|
1599 | 1599 | case 'month' : |
1600 | 1600 | case 'today' : |
1601 | 1601 | case NULL : |
@@ -1603,7 +1603,7 @@ discard block |
||
1603 | 1603 | break; |
1604 | 1604 | |
1605 | 1605 | case 'draft' : |
1606 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1606 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1607 | 1607 | break; |
1608 | 1608 | |
1609 | 1609 | default : |
@@ -1611,43 +1611,43 @@ discard block |
||
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | //categories? |
1614 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1614 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1615 | 1615 | |
1616 | - if ( !empty ( $category ) ) { |
|
1616 | + if ( ! empty ($category)) { |
|
1617 | 1617 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1618 | 1618 | $where['Term_Taxonomy.term_id'] = $category; |
1619 | 1619 | } |
1620 | 1620 | |
1621 | 1621 | //date where conditions |
1622 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1622 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1623 | 1623 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1624 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1625 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1626 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1627 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1624 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1625 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1626 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1627 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1628 | 1628 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1629 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1630 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1631 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1632 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1633 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1634 | - $now = date( 'Y-m-01' ); |
|
1635 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1636 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1637 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1638 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1629 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1630 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1631 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1632 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1633 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1634 | + $now = date('Y-m-01'); |
|
1635 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1636 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1637 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1638 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | |
1642 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1643 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1642 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1643 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1644 | 1644 | } else { |
1645 | - if ( ! isset( $where['status'] ) ) { |
|
1646 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1645 | + if ( ! isset($where['status'])) { |
|
1646 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1647 | 1647 | $where['OR'] = array( |
1648 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1648 | + 'status*restrict_private' => array('!=', 'private'), |
|
1649 | 1649 | 'AND' => array( |
1650 | - 'status*inclusive' => array( '=', 'private' ), |
|
1650 | + 'status*inclusive' => array('=', 'private'), |
|
1651 | 1651 | 'EVT_wp_user' => get_current_user_id() |
1652 | 1652 | ) |
1653 | 1653 | ); |
@@ -1655,16 +1655,16 @@ discard block |
||
1655 | 1655 | } |
1656 | 1656 | } |
1657 | 1657 | |
1658 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1659 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1658 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1659 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1660 | 1660 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1661 | 1661 | } |
1662 | 1662 | } |
1663 | 1663 | |
1664 | 1664 | |
1665 | 1665 | //search query handling |
1666 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1667 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1666 | + if (isset($this->_req_data['s'])) { |
|
1667 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1668 | 1668 | $where['OR'] = array( |
1669 | 1669 | 'EVT_name' => array('LIKE', $search_string), |
1670 | 1670 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1673,32 +1673,32 @@ discard block |
||
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | |
1676 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1677 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1676 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1677 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1678 | 1678 | |
1679 | 1679 | |
1680 | 1680 | //let's first check if we have special requests coming in. |
1681 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1682 | - switch ( $this->_req_data['active_status'] ) { |
|
1681 | + if (isset($this->_req_data['active_status'])) { |
|
1682 | + switch ($this->_req_data['active_status']) { |
|
1683 | 1683 | case 'upcoming' : |
1684 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1684 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1685 | 1685 | break; |
1686 | 1686 | |
1687 | 1687 | case 'expired' : |
1688 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1688 | + return $EEME->get_expired_events($query_params, $count); |
|
1689 | 1689 | break; |
1690 | 1690 | |
1691 | 1691 | case 'active' : |
1692 | - return $EEME->get_active_events( $query_params, $count ); |
|
1692 | + return $EEME->get_active_events($query_params, $count); |
|
1693 | 1693 | break; |
1694 | 1694 | |
1695 | 1695 | case 'inactive' : |
1696 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1696 | + return $EEME->get_inactive_events($query_params, $count); |
|
1697 | 1697 | break; |
1698 | 1698 | } |
1699 | 1699 | } |
1700 | 1700 | |
1701 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1701 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1702 | 1702 | |
1703 | 1703 | return $events; |
1704 | 1704 | } |
@@ -1707,23 +1707,23 @@ discard block |
||
1707 | 1707 | |
1708 | 1708 | |
1709 | 1709 | //handling for WordPress CPT actions (trash, restore, delete) |
1710 | - public function trash_cpt_item( $post_id ) { |
|
1710 | + public function trash_cpt_item($post_id) { |
|
1711 | 1711 | $this->_req_data['EVT_ID'] = $post_id; |
1712 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1712 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1713 | 1713 | } |
1714 | 1714 | |
1715 | 1715 | |
1716 | 1716 | |
1717 | 1717 | |
1718 | - public function restore_cpt_item( $post_id ) { |
|
1718 | + public function restore_cpt_item($post_id) { |
|
1719 | 1719 | $this->_req_data['EVT_ID'] = $post_id; |
1720 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1720 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1721 | 1721 | } |
1722 | 1722 | |
1723 | 1723 | |
1724 | - public function delete_cpt_item( $post_id ) { |
|
1724 | + public function delete_cpt_item($post_id) { |
|
1725 | 1725 | $this->_req_data['EVT_ID'] = $post_id; |
1726 | - $this->_delete_event( FALSE ); |
|
1726 | + $this->_delete_event(FALSE); |
|
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | * @param string $event_status |
1736 | 1736 | * @return void |
1737 | 1737 | */ |
1738 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1738 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1739 | 1739 | //determine the event id and set to array. |
1740 | 1740 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1741 | 1741 | // loop thru events |
@@ -1743,7 +1743,7 @@ discard block |
||
1743 | 1743 | // clean status |
1744 | 1744 | $event_status = sanitize_key($event_status); |
1745 | 1745 | // grab status |
1746 | - if (!empty($event_status)) { |
|
1746 | + if ( ! empty($event_status)) { |
|
1747 | 1747 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1748 | 1748 | } else { |
1749 | 1749 | $success = FALSE; |
@@ -1757,7 +1757,7 @@ discard block |
||
1757 | 1757 | } |
1758 | 1758 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1759 | 1759 | |
1760 | - if ( $redirect_after ) |
|
1760 | + if ($redirect_after) |
|
1761 | 1761 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1762 | 1762 | } |
1763 | 1763 | |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | // clean status |
1773 | 1773 | $event_status = sanitize_key($event_status); |
1774 | 1774 | // grab status |
1775 | - if (!empty($event_status)) { |
|
1775 | + if ( ! empty($event_status)) { |
|
1776 | 1776 | $success = TRUE; |
1777 | 1777 | //determine the event id and set to array. |
1778 | 1778 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1807,15 +1807,15 @@ discard block |
||
1807 | 1807 | * @param string $event_status |
1808 | 1808 | * @return bool |
1809 | 1809 | */ |
1810 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1810 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1811 | 1811 | // grab event id |
1812 | - if (!$EVT_ID) { |
|
1812 | + if ( ! $EVT_ID) { |
|
1813 | 1813 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1814 | 1814 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1815 | 1815 | return FALSE; |
1816 | 1816 | } |
1817 | 1817 | |
1818 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1818 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1819 | 1819 | |
1820 | 1820 | // clean status |
1821 | 1821 | $event_status = sanitize_key($event_status); |
@@ -1841,7 +1841,7 @@ discard block |
||
1841 | 1841 | $hook = FALSE; |
1842 | 1842 | } |
1843 | 1843 | //use class to change status |
1844 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1844 | + $this->_cpt_model_obj->set_status($event_status); |
|
1845 | 1845 | $success = $this->_cpt_model_obj->save(); |
1846 | 1846 | |
1847 | 1847 | if ($success === FALSE) { |
@@ -1863,15 +1863,15 @@ discard block |
||
1863 | 1863 | * @access protected |
1864 | 1864 | * @param bool $redirect_after |
1865 | 1865 | */ |
1866 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1866 | + protected function _delete_event($redirect_after = TRUE) { |
|
1867 | 1867 | //determine the event id and set to array. |
1868 | 1868 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1869 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1869 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1870 | 1870 | |
1871 | 1871 | |
1872 | 1872 | // loop thru events |
1873 | 1873 | if ($EVT_ID) { |
1874 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1874 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1875 | 1875 | // get list of events with no prices |
1876 | 1876 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1877 | 1877 | // remove this event from the list of events with no prices |
@@ -1885,7 +1885,7 @@ discard block |
||
1885 | 1885 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1886 | 1886 | } |
1887 | 1887 | |
1888 | - if ( $redirect_after ) |
|
1888 | + if ($redirect_after) |
|
1889 | 1889 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1890 | 1890 | } |
1891 | 1891 | |
@@ -1903,12 +1903,12 @@ discard block |
||
1903 | 1903 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1904 | 1904 | // loop thru events |
1905 | 1905 | foreach ($EVT_IDs as $EVT_ID) { |
1906 | - $EVT_ID = absint( $EVT_ID ); |
|
1907 | - if ( $EVT_ID ) { |
|
1908 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1906 | + $EVT_ID = absint($EVT_ID); |
|
1907 | + if ($EVT_ID) { |
|
1908 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1909 | 1909 | $success = $results !== FALSE ? $success : FALSE; |
1910 | 1910 | // remove this event from the list of events with no prices |
1911 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1911 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1912 | 1912 | } else { |
1913 | 1913 | $success = FALSE; |
1914 | 1914 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1928,21 +1928,21 @@ discard block |
||
1928 | 1928 | * @param int $EVT_ID |
1929 | 1929 | * @return bool |
1930 | 1930 | */ |
1931 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1931 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1932 | 1932 | // grab event id |
1933 | - if ( ! $EVT_ID ) { |
|
1933 | + if ( ! $EVT_ID) { |
|
1934 | 1934 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1935 | 1935 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1936 | 1936 | return FALSE; |
1937 | 1937 | } |
1938 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1938 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1939 | 1939 | |
1940 | 1940 | //need to delete related tickets and prices first. |
1941 | 1941 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1942 | - foreach ( $datetimes as $datetime ) { |
|
1942 | + foreach ($datetimes as $datetime) { |
|
1943 | 1943 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1944 | 1944 | $tickets = $datetime->get_many_related('Ticket'); |
1945 | - foreach ( $tickets as $ticket ) { |
|
1945 | + foreach ($tickets as $ticket) { |
|
1946 | 1946 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1947 | 1947 | $ticket->delete_related_permanently('Price'); |
1948 | 1948 | $ticket->delete_permanently(); |
@@ -1952,14 +1952,14 @@ discard block |
||
1952 | 1952 | |
1953 | 1953 | //what about related venues or terms? |
1954 | 1954 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1955 | - foreach ( $venues as $venue ) { |
|
1955 | + foreach ($venues as $venue) { |
|
1956 | 1956 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1957 | 1957 | } |
1958 | 1958 | |
1959 | 1959 | //any attached question groups? |
1960 | 1960 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1961 | - if ( !empty( $question_groups ) ) { |
|
1962 | - foreach ( $question_groups as $question_group ) { |
|
1961 | + if ( ! empty($question_groups)) { |
|
1962 | + foreach ($question_groups as $question_group) { |
|
1963 | 1963 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1964 | 1964 | } |
1965 | 1965 | } |
@@ -1968,12 +1968,12 @@ discard block |
||
1968 | 1968 | |
1969 | 1969 | |
1970 | 1970 | //Message Template Groups |
1971 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1971 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1972 | 1972 | |
1973 | 1973 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1974 | 1974 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1975 | 1975 | |
1976 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1976 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1977 | 1977 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1978 | 1978 | } |
1979 | 1979 | |
@@ -1987,7 +1987,7 @@ discard block |
||
1987 | 1987 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1988 | 1988 | return FALSE; |
1989 | 1989 | } |
1990 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted' ); |
|
1990 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted'); |
|
1991 | 1991 | return TRUE; |
1992 | 1992 | } |
1993 | 1993 | |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | */ |
2005 | 2005 | public function total_events() { |
2006 | 2006 | |
2007 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2007 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2008 | 2008 | return $count; |
2009 | 2009 | } |
2010 | 2010 | |
@@ -2019,10 +2019,10 @@ discard block |
||
2019 | 2019 | */ |
2020 | 2020 | public function total_events_draft() { |
2021 | 2021 | $where = array( |
2022 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
2022 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
2023 | 2023 | ); |
2024 | 2024 | |
2025 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2025 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2026 | 2026 | return $count; |
2027 | 2027 | } |
2028 | 2028 | |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | 'status' => 'trash' |
2042 | 2042 | ); |
2043 | 2043 | |
2044 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2044 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2045 | 2045 | return $count; |
2046 | 2046 | } |
2047 | 2047 | |
@@ -2069,11 +2069,11 @@ discard block |
||
2069 | 2069 | // translated |
2070 | 2070 | TRUE |
2071 | 2071 | ); |
2072 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2072 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2073 | 2073 | |
2074 | 2074 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2075 | 2075 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2076 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2076 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2077 | 2077 | $this->display_admin_page_with_sidebar(); |
2078 | 2078 | } |
2079 | 2079 | |
@@ -2099,9 +2099,9 @@ discard block |
||
2099 | 2099 | |
2100 | 2100 | protected function _template_settings() { |
2101 | 2101 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2102 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2103 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2104 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2102 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2103 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2104 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 | |
@@ -2114,22 +2114,22 @@ discard block |
||
2114 | 2114 | * @return void |
2115 | 2115 | */ |
2116 | 2116 | private function _set_category_object() { |
2117 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2117 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2118 | 2118 | return; //already have the category object so get out. |
2119 | 2119 | |
2120 | 2120 | //set default category object |
2121 | 2121 | $this->_set_empty_category_object(); |
2122 | 2122 | |
2123 | 2123 | //only set if we've got an id |
2124 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2124 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2125 | 2125 | return; |
2126 | 2126 | } |
2127 | 2127 | |
2128 | 2128 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2129 | 2129 | |
2130 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2130 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2131 | 2131 | |
2132 | - if ( !empty( $term ) ) { |
|
2132 | + if ( ! empty($term)) { |
|
2133 | 2133 | $this->_category->category_name = $term->name; |
2134 | 2134 | $this->_category->category_identifier = $term->slug; |
2135 | 2135 | $this->_category->category_desc = $term->description; |
@@ -2143,13 +2143,13 @@ discard block |
||
2143 | 2143 | |
2144 | 2144 | private function _set_empty_category_object() { |
2145 | 2145 | $this->_category = new stdClass(); |
2146 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2146 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2147 | 2147 | $this->_category->id = $this->_category->parent = 0; |
2148 | 2148 | } |
2149 | 2149 | |
2150 | 2150 | |
2151 | 2151 | protected function _category_list_table() { |
2152 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2152 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2153 | 2153 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2154 | 2154 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2155 | 2155 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2159,22 +2159,22 @@ discard block |
||
2159 | 2159 | protected function _category_details($view) { |
2160 | 2160 | |
2161 | 2161 | //load formatter helper |
2162 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
2162 | + EE_Registry::instance()->load_helper('Formatter'); |
|
2163 | 2163 | //load field generator helper |
2164 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2164 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2165 | 2165 | |
2166 | 2166 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2167 | 2167 | $this->_set_add_edit_form_tags($route); |
2168 | 2168 | |
2169 | 2169 | $this->_set_category_object(); |
2170 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2170 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2171 | 2171 | |
2172 | 2172 | $delete_action = 'delete_category'; |
2173 | 2173 | |
2174 | 2174 | //custom redirect |
2175 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2175 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2176 | 2176 | |
2177 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2177 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2178 | 2178 | |
2179 | 2179 | //take care of contents |
2180 | 2180 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2188,25 +2188,25 @@ discard block |
||
2188 | 2188 | 'type' => 'wp_editor', |
2189 | 2189 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2190 | 2190 | 'class' => 'my_editor_custom', |
2191 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2191 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2192 | 2192 | ); |
2193 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2193 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2194 | 2194 | |
2195 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2195 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2196 | 2196 | |
2197 | 2197 | //setup category select for term parents. |
2198 | 2198 | $category_select_values[] = array( |
2199 | 2199 | 'text' => __('No Parent', 'event_espresso'), |
2200 | 2200 | 'id' => 0 |
2201 | 2201 | ); |
2202 | - foreach ( $all_terms as $term ) { |
|
2202 | + foreach ($all_terms as $term) { |
|
2203 | 2203 | $category_select_values[] = array( |
2204 | 2204 | 'text' => $term->name, |
2205 | 2205 | 'id' => $term->term_id |
2206 | 2206 | ); |
2207 | 2207 | } |
2208 | 2208 | |
2209 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2209 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2210 | 2210 | |
2211 | 2211 | $template_args = array( |
2212 | 2212 | 'category' => $this->_category, |
@@ -2216,15 +2216,15 @@ discard block |
||
2216 | 2216 | 'disable' => '', |
2217 | 2217 | 'disabled_message' => FALSE |
2218 | 2218 | ); |
2219 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2220 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2219 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2220 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2221 | 2221 | } |
2222 | 2222 | |
2223 | 2223 | |
2224 | 2224 | protected function _delete_categories() { |
2225 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2225 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2226 | 2226 | |
2227 | - foreach ( $cat_ids as $cat_id ) { |
|
2227 | + foreach ($cat_ids as $cat_id) { |
|
2228 | 2228 | $this->_delete_category($cat_id); |
2229 | 2229 | } |
2230 | 2230 | |
@@ -2232,7 +2232,7 @@ discard block |
||
2232 | 2232 | $query_args = array( |
2233 | 2233 | 'action' => 'category_list' |
2234 | 2234 | ); |
2235 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2235 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2236 | 2236 | |
2237 | 2237 | } |
2238 | 2238 | |
@@ -2242,61 +2242,61 @@ discard block |
||
2242 | 2242 | |
2243 | 2243 | protected function _delete_category($cat_id) { |
2244 | 2244 | global $wpdb; |
2245 | - $cat_id = absint( $cat_id ); |
|
2246 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2245 | + $cat_id = absint($cat_id); |
|
2246 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2247 | 2247 | } |
2248 | 2248 | |
2249 | 2249 | |
2250 | 2250 | |
2251 | 2251 | protected function _insert_or_update_category($new_category) { |
2252 | 2252 | |
2253 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2253 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2254 | 2254 | $success = 0; //we already have a success message so lets not send another. |
2255 | 2255 | |
2256 | - if ( $cat_id ) { |
|
2256 | + if ($cat_id) { |
|
2257 | 2257 | $query_args = array( |
2258 | 2258 | 'action' => 'edit_category', |
2259 | 2259 | 'EVT_CAT_ID' => $cat_id |
2260 | 2260 | ); |
2261 | 2261 | } else { |
2262 | - $query_args = array( 'action' => 'add_category' ); |
|
2262 | + $query_args = array('action' => 'add_category'); |
|
2263 | 2263 | } |
2264 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2264 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2265 | 2265 | |
2266 | 2266 | } |
2267 | 2267 | |
2268 | 2268 | |
2269 | 2269 | |
2270 | - private function _insert_category( $update = FALSE ) { |
|
2270 | + private function _insert_category($update = FALSE) { |
|
2271 | 2271 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2272 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2273 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2274 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2272 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2273 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2274 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2275 | 2275 | |
2276 | - if ( empty( $category_name ) ) { |
|
2277 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2278 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2276 | + if (empty($category_name)) { |
|
2277 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2278 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2279 | 2279 | return false; |
2280 | 2280 | } |
2281 | 2281 | |
2282 | - $term_args=array( |
|
2282 | + $term_args = array( |
|
2283 | 2283 | 'name'=>$category_name, |
2284 | 2284 | 'description'=>$category_desc, |
2285 | 2285 | 'parent'=>$category_parent |
2286 | 2286 | ); |
2287 | 2287 | //was the category_identifier input disabled? |
2288 | - if(isset($this->_req_data['category_identifier'])){ |
|
2288 | + if (isset($this->_req_data['category_identifier'])) { |
|
2289 | 2289 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2290 | 2290 | } |
2291 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2291 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2292 | 2292 | |
2293 | - if ( !is_array( $insert_ids ) ) { |
|
2294 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2295 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2293 | + if ( ! is_array($insert_ids)) { |
|
2294 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2295 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2296 | 2296 | } else { |
2297 | 2297 | $cat_id = $insert_ids['term_id']; |
2298 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2299 | - EE_Error::add_success( $msg ); |
|
2298 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2299 | + EE_Error::add_success($msg); |
|
2300 | 2300 | } |
2301 | 2301 | |
2302 | 2302 | return $cat_id; |
@@ -2305,32 +2305,32 @@ discard block |
||
2305 | 2305 | |
2306 | 2306 | |
2307 | 2307 | |
2308 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2308 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2309 | 2309 | global $wpdb; |
2310 | 2310 | |
2311 | 2311 | //testing term stuff |
2312 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2313 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2314 | - $limit = ($current_page-1)*$per_page; |
|
2312 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2313 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2314 | + $limit = ($current_page - 1) * $per_page; |
|
2315 | 2315 | |
2316 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2316 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2317 | 2317 | |
2318 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2319 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2318 | + if (isset($this->_req_data['s'])) { |
|
2319 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2320 | 2320 | $where['OR'] = array( |
2321 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2322 | - 'description' => array( 'LIKE', $sstr ) |
|
2321 | + 'Term.name' => array('LIKE', $sstr), |
|
2322 | + 'description' => array('LIKE', $sstr) |
|
2323 | 2323 | ); |
2324 | 2324 | } |
2325 | 2325 | |
2326 | 2326 | $query_params = array( |
2327 | - $where , |
|
2328 | - 'order_by' => array( $orderby => $order ), |
|
2329 | - 'limit' => $limit . ',' . $per_page, |
|
2327 | + $where, |
|
2328 | + 'order_by' => array($orderby => $order), |
|
2329 | + 'limit' => $limit.','.$per_page, |
|
2330 | 2330 | 'force_join' => array('Term') |
2331 | 2331 | ); |
2332 | 2332 | |
2333 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2333 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2334 | 2334 | |
2335 | 2335 | return $categories; |
2336 | 2336 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -62,10 +62,10 @@ discard block |
||
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 |
||
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 | } |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | protected function _set_page_routes() { |
121 | 121 | |
122 | 122 | //load formatter helper |
123 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
123 | + EE_Registry::instance()->load_helper('Formatter'); |
|
124 | 124 | //load field generator helper |
125 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
125 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
126 | 126 | |
127 | 127 | //is there a vnu_id in the request? |
128 | - $vnu_id = ! empty( $this->_req_data['VNU_ID'] ) && ! is_array( $this->_req_data['VNU_ID'] ) ? $this->_req_data['VNU_ID'] : 0; |
|
129 | - $vnu_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $vnu_id; |
|
128 | + $vnu_id = ! empty($this->_req_data['VNU_ID']) && ! is_array($this->_req_data['VNU_ID']) ? $this->_req_data['VNU_ID'] : 0; |
|
129 | + $vnu_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $vnu_id; |
|
130 | 130 | |
131 | 131 | $this->_page_routes = array( |
132 | 132 | 'default' => array( |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | ), |
145 | 145 | 'trash_venue' => array( |
146 | 146 | 'func' => '_trash_or_restore_venue', |
147 | - 'args' => array( 'venue_status' => 'trash' ), |
|
147 | + 'args' => array('venue_status' => 'trash'), |
|
148 | 148 | 'noheader' => TRUE, |
149 | 149 | 'capability' => 'ee_delete_venue', |
150 | 150 | 'obj_id' => $vnu_id |
151 | 151 | ), |
152 | 152 | 'trash_venues' => array( |
153 | 153 | 'func' => '_trash_or_restore_venues', |
154 | - 'args' => array( 'venue_status' => 'trash' ), |
|
154 | + 'args' => array('venue_status' => 'trash'), |
|
155 | 155 | 'noheader' => TRUE, |
156 | 156 | 'capability' => 'ee_delete_venues' |
157 | 157 | ), |
158 | 158 | 'restore_venue' => array( |
159 | 159 | 'func' => '_trash_or_restore_venue', |
160 | - 'args' => array( 'venue_status' => 'draft' ), |
|
160 | + 'args' => array('venue_status' => 'draft'), |
|
161 | 161 | 'noheader' => TRUE, |
162 | 162 | 'capability' => 'ee_delete_venue', |
163 | 163 | 'obj_id' => $vnu_id |
164 | 164 | ), |
165 | 165 | 'restore_venues' => array( |
166 | 166 | 'func' => '_trash_or_restore_venues', |
167 | - 'args' => array( 'venue_status' => 'draft' ), |
|
167 | + 'args' => array('venue_status' => 'draft'), |
|
168 | 168 | 'noheader' => TRUE, |
169 | 169 | 'capability' => 'ee_delete_venues' |
170 | 170 | ), |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | 'filename' => 'venues_overview_views_bulk_actions_search' |
267 | 267 | ) |
268 | 268 | ), |
269 | - 'help_tour' => array( 'Venues_Overview_Help_Tour' ), |
|
269 | + 'help_tour' => array('Venues_Overview_Help_Tour'), |
|
270 | 270 | 'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'), |
271 | 271 | 'require_nonce' => FALSE |
272 | 272 | ), |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | 'filename' => 'venues_editor_other' |
303 | 303 | ) |
304 | 304 | ), |
305 | - 'help_tour' => array( 'Venues_Add_Venue_Help_Tour' ), |
|
305 | + 'help_tour' => array('Venues_Add_Venue_Help_Tour'), |
|
306 | 306 | 'metaboxes' => array('_venue_editor_metaboxes'), |
307 | 307 | 'require_nonce' => FALSE |
308 | 308 | ), |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | 'label' => __('Edit Venue', 'event_espresso'), |
312 | 312 | 'order' => 5, |
313 | 313 | 'persistent' => FALSE, |
314 | - 'url' => isset($this->_req_data['post']) ? add_query_arg(array('post' => $this->_req_data['post'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
314 | + 'url' => isset($this->_req_data['post']) ? add_query_arg(array('post' => $this->_req_data['post']), $this->_current_page_view_url) : $this->_admin_base_url |
|
315 | 315 | ), |
316 | 316 | 'help_tabs' => array( |
317 | 317 | 'venues_editor_help_tab' => array( |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | 'filename' => 'venues_editor_other' |
340 | 340 | ) |
341 | 341 | ), |
342 | - 'help_tour' => array( 'Venues_Edit_Venue_Help_Tour' ), |
|
342 | + 'help_tour' => array('Venues_Edit_Venue_Help_Tour'), |
|
343 | 343 | 'metaboxes' => array('_venue_editor_metaboxes'), |
344 | 344 | 'require_nonce' => FALSE |
345 | 345 | ), |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | 'label' => __('Google Maps'), |
349 | 349 | 'order' => 40 |
350 | 350 | ), |
351 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
351 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
352 | 352 | 'help_tabs' => array( |
353 | 353 | 'general_settings_google_maps_help_tab' => array( |
354 | 354 | 'title' => __('Google Maps', 'event_espresso'), |
355 | 355 | 'filename' => 'general_settings_google_maps' |
356 | 356 | ) |
357 | 357 | ), |
358 | - 'help_tour' => array( 'Google_Maps_Help_Tour' ), |
|
358 | + 'help_tour' => array('Google_Maps_Help_Tour'), |
|
359 | 359 | 'require_nonce' => FALSE |
360 | 360 | ), |
361 | 361 | //venue category stuff |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | 'filename' => 'venues_add_category' |
372 | 372 | ) |
373 | 373 | ), |
374 | - 'help_tour' => array( 'Venues_Add_Category_Help_Tour' ), |
|
374 | + 'help_tour' => array('Venues_Add_Category_Help_Tour'), |
|
375 | 375 | 'require_nonce' => FALSE |
376 | 376 | ), |
377 | 377 | 'edit_category' => array( |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | 'label' => __('Edit Category', 'event_espresso'), |
380 | 380 | 'order' => 15, |
381 | 381 | 'persistent' => FALSE, |
382 | - '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 |
|
382 | + '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 |
|
383 | 383 | ), |
384 | 384 | 'metaboxes' => array('_publish_post_box'), |
385 | 385 | 'help_tabs' => array( |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | 'filename' => 'venues_edit_category' |
389 | 389 | ) |
390 | 390 | ), |
391 | - 'help_tour' => array( 'Venues_Edit_Category_Help_Tour' ), |
|
391 | + 'help_tour' => array('Venues_Edit_Category_Help_Tour'), |
|
392 | 392 | 'require_nonce' => FALSE |
393 | 393 | ), |
394 | 394 | 'category_list' => array( |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | 'filename' => 'venues_categories_other' |
416 | 416 | ) |
417 | 417 | ), |
418 | - 'help_tour' => array( 'Venues_Categories_Help_Tour' ), |
|
418 | + 'help_tour' => array('Venues_Categories_Help_Tour'), |
|
419 | 419 | 'metaboxes' => $this->_default_espresso_metaboxes, |
420 | 420 | 'require_nonce' => FALSE |
421 | 421 | ) |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | |
473 | 473 | |
474 | 474 | public function load_scripts_styles() { |
475 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
475 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
476 | 476 | wp_enqueue_style('ee-cat-admin'); |
477 | 477 | } |
478 | 478 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | public function load_scripts_styles_edit() { |
496 | 496 | //styles |
497 | 497 | wp_enqueue_style('espresso-ui-theme'); |
498 | - wp_register_style( 'espresso_venues', EE_VENUES_ASSETS_URL . 'ee-venues-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
498 | + wp_register_style('espresso_venues', EE_VENUES_ASSETS_URL.'ee-venues-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
499 | 499 | wp_enqueue_style('espresso_venues'); |
500 | 500 | } |
501 | 501 | |
@@ -514,13 +514,13 @@ discard block |
||
514 | 514 | ) |
515 | 515 | ); |
516 | 516 | |
517 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_venues', 'espresso_venues_trash_venues' ) ) { |
|
517 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) { |
|
518 | 518 | $this->_views['all']['bulk_action'] = array( |
519 | 519 | 'trash_venues' => __('Move to Trash', 'event_espresso') |
520 | 520 | ); |
521 | 521 | $this->_views['trash'] = array( |
522 | 522 | 'slug' => 'trash', |
523 | - 'label' => __( 'Trash', 'event_espresso' ), |
|
523 | + 'label' => __('Trash', 'event_espresso'), |
|
524 | 524 | 'count' => 0, |
525 | 525 | 'bulk_action' => array( |
526 | 526 | 'restore_venues' => __('Restore from Trash', 'event_espresso'), |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | |
554 | 554 | |
555 | 555 | protected function _overview_list_table() { |
556 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
557 | - $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 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
557 | + $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'); |
|
558 | 558 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
559 | 559 | $this->_search_btn_label = __('Venues', 'event_espresso'); |
560 | 560 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | 'vnu_url' => $this->_cpt_model_obj->venue_url(), |
569 | 569 | 'vnu_phone' => $this->_cpt_model_obj->phone() |
570 | 570 | ); |
571 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php'; |
|
572 | - EEH_Template::display_template( $template, $extra_rows ); |
|
571 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_publish_box_extras.template.php'; |
|
572 | + EEH_Template::display_template($template, $extra_rows); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | |
@@ -584,115 +584,115 @@ discard block |
||
584 | 584 | $default_map_settings = new stdClass(); |
585 | 585 | $default_map_settings->use_google_maps = TRUE; |
586 | 586 | // for event details pages (reg page) |
587 | - $default_map_settings->event_details_map_width = 585; // ee_map_width_single |
|
588 | - $default_map_settings->event_details_map_height = 362; // ee_map_height_single |
|
589 | - $default_map_settings->event_details_map_zoom = 14; // ee_map_zoom_single |
|
590 | - $default_map_settings->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
591 | - $default_map_settings->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
592 | - $default_map_settings->event_details_control_type = 'default'; // ee_map_type_control_single |
|
593 | - $default_map_settings->event_details_map_align = 'center'; // ee_map_align_single |
|
587 | + $default_map_settings->event_details_map_width = 585; // ee_map_width_single |
|
588 | + $default_map_settings->event_details_map_height = 362; // ee_map_height_single |
|
589 | + $default_map_settings->event_details_map_zoom = 14; // ee_map_zoom_single |
|
590 | + $default_map_settings->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
591 | + $default_map_settings->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
592 | + $default_map_settings->event_details_control_type = 'default'; // ee_map_type_control_single |
|
593 | + $default_map_settings->event_details_map_align = 'center'; // ee_map_align_single |
|
594 | 594 | // for event list pages |
595 | - $default_map_settings->event_list_map_width = 300; // ee_map_width |
|
596 | - $default_map_settings->event_list_map_height = 185; // ee_map_height |
|
597 | - $default_map_settings->event_list_map_zoom = 12; // ee_map_zoom |
|
598 | - $default_map_settings->event_list_display_nav = FALSE; // ee_map_nav_display |
|
599 | - $default_map_settings->event_list_nav_size = TRUE; // ee_map_nav_size |
|
600 | - $default_map_settings->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
601 | - $default_map_settings->event_list_map_align = 'center'; // ee_map_align |
|
595 | + $default_map_settings->event_list_map_width = 300; // ee_map_width |
|
596 | + $default_map_settings->event_list_map_height = 185; // ee_map_height |
|
597 | + $default_map_settings->event_list_map_zoom = 12; // ee_map_zoom |
|
598 | + $default_map_settings->event_list_display_nav = FALSE; // ee_map_nav_display |
|
599 | + $default_map_settings->event_list_nav_size = TRUE; // ee_map_nav_size |
|
600 | + $default_map_settings->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
601 | + $default_map_settings->event_list_map_align = 'center'; // ee_map_align |
|
602 | 602 | |
603 | 603 | $this->_template_args['map_settings'] = |
604 | - isset( EE_Registry::instance()->CFG->map_settings ) && ! empty( EE_Registry::instance()->CFG->map_settings ) |
|
605 | - ? (object)array_merge( (array)$default_map_settings, (array)EE_Registry::instance()->CFG->map_settings ) |
|
604 | + isset(EE_Registry::instance()->CFG->map_settings) && ! empty(EE_Registry::instance()->CFG->map_settings) |
|
605 | + ? (object) array_merge((array) $default_map_settings, (array) EE_Registry::instance()->CFG->map_settings) |
|
606 | 606 | : $default_map_settings; |
607 | 607 | |
608 | - $this->_set_add_edit_form_tags( 'update_google_map_settings' ); |
|
609 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
610 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_VENUES_TEMPLATE_PATH . 'google_map.template.php', $this->_template_args, TRUE ); |
|
608 | + $this->_set_add_edit_form_tags('update_google_map_settings'); |
|
609 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
610 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_VENUES_TEMPLATE_PATH.'google_map.template.php', $this->_template_args, TRUE); |
|
611 | 611 | $this->display_admin_page_with_sidebar(); |
612 | 612 | } |
613 | 613 | |
614 | 614 | protected function _update_google_map_settings() { |
615 | 615 | |
616 | 616 | EE_Registry::instance()->CFG->map_settings->use_google_maps = |
617 | - isset( $this->_req_data['use_google_maps'] ) |
|
618 | - ? absint( $this->_req_data['use_google_maps'] ) |
|
617 | + isset($this->_req_data['use_google_maps']) |
|
618 | + ? absint($this->_req_data['use_google_maps']) |
|
619 | 619 | : EE_Registry::instance()->CFG->map_settings->use_google_maps; |
620 | 620 | |
621 | 621 | EE_Registry::instance()->CFG->map_settings->event_details_map_width = |
622 | - isset( $this->_req_data['event_details_map_width'] ) |
|
623 | - ? absint( $this->_req_data['event_details_map_width'] ) |
|
622 | + isset($this->_req_data['event_details_map_width']) |
|
623 | + ? absint($this->_req_data['event_details_map_width']) |
|
624 | 624 | : EE_Registry::instance()->CFG->map_settings->event_details_map_width; |
625 | 625 | |
626 | 626 | EE_Registry::instance()->CFG->map_settings->event_details_map_height = |
627 | - isset( $this->_req_data['event_details_map_height'] ) |
|
628 | - ? absint( $this->_req_data['event_details_map_height'] ) |
|
627 | + isset($this->_req_data['event_details_map_height']) |
|
628 | + ? absint($this->_req_data['event_details_map_height']) |
|
629 | 629 | : EE_Registry::instance()->CFG->map_settings->event_details_map_height; |
630 | 630 | |
631 | 631 | EE_Registry::instance()->CFG->map_settings->event_details_map_zoom = |
632 | - isset( $this->_req_data['event_details_map_zoom'] ) |
|
633 | - ? absint( $this->_req_data['event_details_map_zoom'] ) |
|
632 | + isset($this->_req_data['event_details_map_zoom']) |
|
633 | + ? absint($this->_req_data['event_details_map_zoom']) |
|
634 | 634 | : EE_Registry::instance()->CFG->map_settings->event_details_map_zoom; |
635 | 635 | |
636 | 636 | EE_Registry::instance()->CFG->map_settings->event_details_display_nav = |
637 | - isset( $this->_req_data['event_details_display_nav'] ) |
|
638 | - ? absint( $this->_req_data['event_details_display_nav'] ) |
|
637 | + isset($this->_req_data['event_details_display_nav']) |
|
638 | + ? absint($this->_req_data['event_details_display_nav']) |
|
639 | 639 | : EE_Registry::instance()->CFG->map_settings->event_details_display_nav; |
640 | 640 | |
641 | 641 | EE_Registry::instance()->CFG->map_settings->event_details_nav_size = |
642 | - isset( $this->_req_data['event_details_nav_size'] ) |
|
643 | - ? absint( $this->_req_data['event_details_nav_size'] ) |
|
642 | + isset($this->_req_data['event_details_nav_size']) |
|
643 | + ? absint($this->_req_data['event_details_nav_size']) |
|
644 | 644 | : EE_Registry::instance()->CFG->map_settings->event_details_nav_size; |
645 | 645 | |
646 | 646 | EE_Registry::instance()->CFG->map_settings->event_details_control_type = |
647 | - isset( $this->_req_data['event_details_control_type'] ) |
|
648 | - ? sanitize_text_field( $this->_req_data['event_details_control_type'] ) |
|
647 | + isset($this->_req_data['event_details_control_type']) |
|
648 | + ? sanitize_text_field($this->_req_data['event_details_control_type']) |
|
649 | 649 | : EE_Registry::instance()->CFG->map_settings->event_details_control_type; |
650 | 650 | |
651 | 651 | EE_Registry::instance()->CFG->map_settings->event_details_map_align = |
652 | - isset( $this->_req_data['event_details_map_align'] ) |
|
653 | - ? sanitize_text_field( $this->_req_data['event_details_map_align'] ) |
|
652 | + isset($this->_req_data['event_details_map_align']) |
|
653 | + ? sanitize_text_field($this->_req_data['event_details_map_align']) |
|
654 | 654 | : EE_Registry::instance()->CFG->map_settings->event_details_map_align; |
655 | 655 | |
656 | 656 | EE_Registry::instance()->CFG->map_settings->event_list_map_width = |
657 | - isset( $this->_req_data['event_list_map_width'] ) |
|
658 | - ? absint( $this->_req_data['event_list_map_width'] ) |
|
657 | + isset($this->_req_data['event_list_map_width']) |
|
658 | + ? absint($this->_req_data['event_list_map_width']) |
|
659 | 659 | : EE_Registry::instance()->CFG->map_settings->event_list_map_width; |
660 | 660 | |
661 | 661 | EE_Registry::instance()->CFG->map_settings->event_list_map_height = |
662 | - isset( $this->_req_data['event_list_map_height'] ) |
|
663 | - ? absint( $this->_req_data['event_list_map_height'] ) |
|
662 | + isset($this->_req_data['event_list_map_height']) |
|
663 | + ? absint($this->_req_data['event_list_map_height']) |
|
664 | 664 | : EE_Registry::instance()->CFG->map_settings->event_list_map_height; |
665 | 665 | |
666 | 666 | EE_Registry::instance()->CFG->map_settings->event_list_map_zoom = |
667 | - isset( $this->_req_data['event_list_map_zoom'] ) |
|
668 | - ? absint( $this->_req_data['event_list_map_zoom'] ) |
|
667 | + isset($this->_req_data['event_list_map_zoom']) |
|
668 | + ? absint($this->_req_data['event_list_map_zoom']) |
|
669 | 669 | : EE_Registry::instance()->CFG->map_settings->event_list_map_zoom; |
670 | 670 | |
671 | 671 | EE_Registry::instance()->CFG->map_settings->event_list_display_nav = |
672 | - isset( $this->_req_data['event_list_display_nav'] ) |
|
673 | - ? absint( $this->_req_data['event_list_display_nav'] ) |
|
672 | + isset($this->_req_data['event_list_display_nav']) |
|
673 | + ? absint($this->_req_data['event_list_display_nav']) |
|
674 | 674 | : EE_Registry::instance()->CFG->map_settings->event_list_display_nav; |
675 | 675 | |
676 | 676 | EE_Registry::instance()->CFG->map_settings->event_list_nav_size = |
677 | - isset( $this->_req_data['event_list_nav_size'] ) |
|
678 | - ? absint( $this->_req_data['event_list_nav_size'] ) |
|
677 | + isset($this->_req_data['event_list_nav_size']) |
|
678 | + ? absint($this->_req_data['event_list_nav_size']) |
|
679 | 679 | : EE_Registry::instance()->CFG->map_settings->event_list_nav_size; |
680 | 680 | |
681 | 681 | EE_Registry::instance()->CFG->map_settings->event_list_control_type = |
682 | - isset( $this->_req_data['event_list_control_type'] ) |
|
683 | - ? sanitize_text_field( $this->_req_data['event_list_control_type'] ) |
|
682 | + isset($this->_req_data['event_list_control_type']) |
|
683 | + ? sanitize_text_field($this->_req_data['event_list_control_type']) |
|
684 | 684 | : EE_Registry::instance()->CFG->map_settings->event_list_control_type; |
685 | 685 | |
686 | 686 | EE_Registry::instance()->CFG->map_settings->event_list_map_align = |
687 | - isset( $this->_req_data['event_list_map_align'] ) |
|
688 | - ? sanitize_text_field( $this->_req_data['event_list_map_align'] ) |
|
687 | + isset($this->_req_data['event_list_map_align']) |
|
688 | + ? sanitize_text_field($this->_req_data['event_list_map_align']) |
|
689 | 689 | : EE_Registry::instance()->CFG->map_settings->event_list_map_align; |
690 | 690 | |
691 | - EE_Registry::instance()->CFG->map_settings = apply_filters( 'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings', EE_Registry::instance()->CFG->map_settings ); |
|
691 | + EE_Registry::instance()->CFG->map_settings = apply_filters('FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings', EE_Registry::instance()->CFG->map_settings); |
|
692 | 692 | |
693 | 693 | $what = 'Google Map Settings'; |
694 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->map_settings, __FILE__, __FUNCTION__, __LINE__ ); |
|
695 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'google_map_settings' ) ); |
|
694 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->map_settings, __FILE__, __FUNCTION__, __LINE__); |
|
695 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'google_map_settings')); |
|
696 | 696 | |
697 | 697 | } |
698 | 698 | |
@@ -701,9 +701,9 @@ discard block |
||
701 | 701 | protected function _venue_editor_metaboxes() { |
702 | 702 | $this->verify_cpt_object(); |
703 | 703 | |
704 | - add_meta_box( 'espresso_venue_address_options', __('Physical Location', 'event_espresso'), array( $this, 'venue_address_metabox'), $this->page_slug, 'side', 'default' ); |
|
705 | - add_meta_box( 'espresso_venue_gmap_options', __('Google Map', 'event_espresso'), array( $this, 'venue_gmap_metabox'), $this->page_slug, 'side', 'default' ); |
|
706 | - add_meta_box( 'espresso_venue_virtual_loc_options', __('Virtual Location', 'event_espresso'), array( $this, 'venue_virtual_loc_metabox'), $this->page_slug, 'side', 'default' ); |
|
704 | + add_meta_box('espresso_venue_address_options', __('Physical Location', 'event_espresso'), array($this, 'venue_address_metabox'), $this->page_slug, 'side', 'default'); |
|
705 | + add_meta_box('espresso_venue_gmap_options', __('Google Map', 'event_espresso'), array($this, 'venue_gmap_metabox'), $this->page_slug, 'side', 'default'); |
|
706 | + add_meta_box('espresso_venue_virtual_loc_options', __('Virtual Location', 'event_espresso'), array($this, 'venue_virtual_loc_metabox'), $this->page_slug, 'side', 'default'); |
|
707 | 707 | |
708 | 708 | } |
709 | 709 | |
@@ -711,23 +711,23 @@ discard block |
||
711 | 711 | |
712 | 712 | public function venue_gmap_metabox() { |
713 | 713 | $template_args = array( |
714 | - '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() ), |
|
714 | + '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()), |
|
715 | 715 | 'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(), |
716 | 716 | ); |
717 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php'; |
|
718 | - EEH_Template::display_template( $template, $template_args ); |
|
717 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_gmap_metabox_content.template.php'; |
|
718 | + EEH_Template::display_template($template, $template_args); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | |
722 | 722 | |
723 | 723 | public function venue_address_metabox() { |
724 | 724 | |
725 | - $template_args['_venue'] =$this->_cpt_model_obj; |
|
725 | + $template_args['_venue'] = $this->_cpt_model_obj; |
|
726 | 726 | |
727 | 727 | $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input( |
728 | 728 | $QFI = new EE_Question_Form_Input( |
729 | - EE_Question::new_instance( array( 'QST_display_text' => 'State', 'QST_system' => 'state' )), |
|
730 | - EE_Answer::new_instance( array( 'ANS_value'=> $this->_cpt_model_obj->state_ID() )), |
|
729 | + EE_Question::new_instance(array('QST_display_text' => 'State', 'QST_system' => 'state')), |
|
730 | + EE_Answer::new_instance(array('ANS_value'=> $this->_cpt_model_obj->state_ID())), |
|
731 | 731 | array( |
732 | 732 | 'input_name' => 'sta_id', |
733 | 733 | 'input_id' => 'sta_id', |
@@ -739,8 +739,8 @@ discard block |
||
739 | 739 | ); |
740 | 740 | $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input( |
741 | 741 | $QFI = new EE_Question_Form_Input( |
742 | - EE_Question::new_instance( array( 'QST_display_text' => 'Country', 'QST_system' => 'country' )), |
|
743 | - EE_Answer::new_instance( array( 'ANS_value'=> $this->_cpt_model_obj->country_ID() )), |
|
742 | + EE_Question::new_instance(array('QST_display_text' => 'Country', 'QST_system' => 'country')), |
|
743 | + EE_Answer::new_instance(array('ANS_value'=> $this->_cpt_model_obj->country_ID())), |
|
744 | 744 | array( |
745 | 745 | 'input_name' => 'cnt_iso', |
746 | 746 | 'input_id' => 'cnt_iso', |
@@ -751,8 +751,8 @@ discard block |
||
751 | 751 | ) |
752 | 752 | ); |
753 | 753 | |
754 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php'; |
|
755 | - EEH_Template::display_template( $template, $template_args ); |
|
754 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_address_metabox_content.template.php'; |
|
755 | + EEH_Template::display_template($template, $template_args); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | $template_args = array( |
765 | 765 | '_venue' => $this->_cpt_model_obj |
766 | 766 | ); |
767 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php'; |
|
768 | - EEH_Template::display_template( $template, $template_args ); |
|
767 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_virtual_location_metabox_content.template.php'; |
|
768 | + EEH_Template::display_template($template, $template_args); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -788,52 +788,52 @@ discard block |
||
788 | 788 | * @param object $post Post object (with "blessed" WP properties) |
789 | 789 | * @return void |
790 | 790 | */ |
791 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
791 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
792 | 792 | |
793 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_venues' ) { |
|
794 | - return;// get out we're not processing the saving of venues. |
|
793 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') { |
|
794 | + return; // get out we're not processing the saving of venues. |
|
795 | 795 | } |
796 | 796 | |
797 | - $wheres = array( $this->_venue_model->primary_key_name() => $post_id ); |
|
797 | + $wheres = array($this->_venue_model->primary_key_name() => $post_id); |
|
798 | 798 | |
799 | 799 | $venue_values = array( |
800 | - 'VNU_address' => !empty( $this->_req_data['vnu_address'] ) ? $this->_req_data['vnu_address'] : NULL, |
|
801 | - 'VNU_address2' => !empty( $this->_req_data['vnu_address2'] ) ? $this->_req_data['vnu_address2'] : NULL, |
|
802 | - 'VNU_city' => !empty( $this->_req_data['vnu_city'] ) ? $this->_req_data['vnu_city'] : NULL, |
|
803 | - 'STA_ID' => !empty( $this->_req_data['sta_id'] ) ? $this->_req_data['sta_id'] : NULL, |
|
804 | - 'CNT_ISO' => !empty( $this->_req_data['cnt_iso'] ) ? $this->_req_data['cnt_iso'] : NULL, |
|
805 | - 'VNU_zip' => !empty( $this->_req_data['vnu_zip'] ) ? $this->_req_data['vnu_zip'] : NULL, |
|
806 | - 'VNU_phone' => !empty( $this->_req_data['vnu_phone'] ) ? $this->_req_data['vnu_phone'] : NULL, |
|
807 | - 'VNU_capacity' => !empty( $this->_req_data['vnu_capacity'] ) ? str_replace( ',', '', $this->_req_data['vnu_capacity'] ) : EE_INF, |
|
808 | - 'VNU_url' => !empty( $this->_req_data['vnu_url'] ) ? $this->_req_data['vnu_url'] : NULL, |
|
809 | - 'VNU_virtual_phone' => !empty( $this->_req_data['vnu_virtual_phone'] ) ? $this->_req_data['vnu_virtual_phone'] : NULL, |
|
810 | - 'VNU_virtual_url' => !empty( $this->_req_data['vnu_virtual_url'] ) ? $this->_req_data['vnu_virtual_url'] : NULL, |
|
811 | - 'VNU_enable_for_gmap' => !empty( $this->_req_data['vnu_enable_for_gmap'] ) ? TRUE : FALSE, |
|
812 | - 'VNU_google_map_link' => !empty( $this->_req_data['vnu_google_map_link'] ) ? $this->_req_data['vnu_google_map_link'] : NULL |
|
800 | + 'VNU_address' => ! empty($this->_req_data['vnu_address']) ? $this->_req_data['vnu_address'] : NULL, |
|
801 | + 'VNU_address2' => ! empty($this->_req_data['vnu_address2']) ? $this->_req_data['vnu_address2'] : NULL, |
|
802 | + 'VNU_city' => ! empty($this->_req_data['vnu_city']) ? $this->_req_data['vnu_city'] : NULL, |
|
803 | + 'STA_ID' => ! empty($this->_req_data['sta_id']) ? $this->_req_data['sta_id'] : NULL, |
|
804 | + 'CNT_ISO' => ! empty($this->_req_data['cnt_iso']) ? $this->_req_data['cnt_iso'] : NULL, |
|
805 | + 'VNU_zip' => ! empty($this->_req_data['vnu_zip']) ? $this->_req_data['vnu_zip'] : NULL, |
|
806 | + 'VNU_phone' => ! empty($this->_req_data['vnu_phone']) ? $this->_req_data['vnu_phone'] : NULL, |
|
807 | + 'VNU_capacity' => ! empty($this->_req_data['vnu_capacity']) ? str_replace(',', '', $this->_req_data['vnu_capacity']) : EE_INF, |
|
808 | + 'VNU_url' => ! empty($this->_req_data['vnu_url']) ? $this->_req_data['vnu_url'] : NULL, |
|
809 | + 'VNU_virtual_phone' => ! empty($this->_req_data['vnu_virtual_phone']) ? $this->_req_data['vnu_virtual_phone'] : NULL, |
|
810 | + 'VNU_virtual_url' => ! empty($this->_req_data['vnu_virtual_url']) ? $this->_req_data['vnu_virtual_url'] : NULL, |
|
811 | + 'VNU_enable_for_gmap' => ! empty($this->_req_data['vnu_enable_for_gmap']) ? TRUE : FALSE, |
|
812 | + 'VNU_google_map_link' => ! empty($this->_req_data['vnu_google_map_link']) ? $this->_req_data['vnu_google_map_link'] : NULL |
|
813 | 813 | ); |
814 | 814 | |
815 | 815 | //update venue |
816 | - $success = $this->_venue_model->update( $venue_values, array( $wheres ) ); |
|
816 | + $success = $this->_venue_model->update($venue_values, array($wheres)); |
|
817 | 817 | |
818 | 818 | //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! |
819 | - $get_one_where = array( $this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
820 | - $venue = $this->_venue_model->get_one( array( $get_one_where ) ); |
|
819 | + $get_one_where = array($this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
820 | + $venue = $this->_venue_model->get_one(array($get_one_where)); |
|
821 | 821 | |
822 | 822 | //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. |
823 | - $venue_update_callbacks = apply_filters( 'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks', array() ); |
|
823 | + $venue_update_callbacks = apply_filters('FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks', array()); |
|
824 | 824 | |
825 | 825 | $att_success = TRUE; |
826 | 826 | |
827 | - foreach ( $venue_update_callbacks as $v_callback ) { |
|
828 | - $_succ = call_user_func_array( $v_callback, array( $venue, $this->_req_data ) ); |
|
829 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
827 | + foreach ($venue_update_callbacks as $v_callback) { |
|
828 | + $_succ = call_user_func_array($v_callback, array($venue, $this->_req_data)); |
|
829 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | //any errors? |
833 | - if ( $success && !$att_success ) { |
|
834 | - EE_Error::add_error( __('Venue Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
835 | - } else if ( $success === FALSE ) { |
|
836 | - EE_Error::add_error( __('Venue Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
833 | + if ($success && ! $att_success) { |
|
834 | + EE_Error::add_error(__('Venue Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
835 | + } else if ($success === FALSE) { |
|
836 | + EE_Error::add_error(__('Venue Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
837 | 837 | } |
838 | 838 | } |
839 | 839 | |
@@ -841,9 +841,9 @@ discard block |
||
841 | 841 | |
842 | 842 | |
843 | 843 | |
844 | - public function trash_cpt_item( $post_id ) { |
|
844 | + public function trash_cpt_item($post_id) { |
|
845 | 845 | $this->_req_data['VNU_ID'] = $post_id; |
846 | - $this->_trash_or_restore_venue( 'trash', FALSE ); |
|
846 | + $this->_trash_or_restore_venue('trash', FALSE); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | |
@@ -851,18 +851,18 @@ discard block |
||
851 | 851 | |
852 | 852 | |
853 | 853 | |
854 | - public function restore_cpt_item( $post_id ) { |
|
854 | + public function restore_cpt_item($post_id) { |
|
855 | 855 | $this->_req_data['VNU_ID'] = $post_id; |
856 | - $this->_trash_or_restore_venue( 'draft', FALSE ); |
|
856 | + $this->_trash_or_restore_venue('draft', FALSE); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | |
860 | 860 | |
861 | 861 | |
862 | 862 | |
863 | - public function delete_cpt_item( $post_id ) { |
|
863 | + public function delete_cpt_item($post_id) { |
|
864 | 864 | $this->_req_data['VNU_ID'] = $post_id; |
865 | - $this->_delete_venue( FALSE ); |
|
865 | + $this->_delete_venue(FALSE); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -877,15 +877,15 @@ discard block |
||
877 | 877 | |
878 | 878 | |
879 | 879 | |
880 | - protected function _trash_or_restore_venue( $venue_status = 'trash', $redirect_after = TRUE ) { |
|
881 | - $VNU_ID = isset( $this->_req_data['VNU_ID'] ) ? absint( $this->_req_data['VNU_ID'] ) : FALSE; |
|
880 | + protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = TRUE) { |
|
881 | + $VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : FALSE; |
|
882 | 882 | |
883 | 883 | //loop thru venues |
884 | - if ( $VNU_ID ) { |
|
884 | + if ($VNU_ID) { |
|
885 | 885 | //clean status |
886 | - $venue_status = sanitize_key( $venue_status ); |
|
886 | + $venue_status = sanitize_key($venue_status); |
|
887 | 887 | // grab status |
888 | - if (!empty($venue_status)) { |
|
888 | + if ( ! empty($venue_status)) { |
|
889 | 889 | $success = $this->_change_venue_status($VNU_ID, $venue_status); |
890 | 890 | } else { |
891 | 891 | $success = FALSE; |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | } |
900 | 900 | $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
901 | 901 | |
902 | - if ( $redirect_after ) |
|
902 | + if ($redirect_after) |
|
903 | 903 | $this->_redirect_after_action($success, 'Venue', $action, array('action' => 'default')); |
904 | 904 | |
905 | 905 | } |
@@ -908,11 +908,11 @@ discard block |
||
908 | 908 | |
909 | 909 | |
910 | 910 | |
911 | - protected function _trash_or_restore_venues( $venue_status = 'trash' ) { |
|
911 | + protected function _trash_or_restore_venues($venue_status = 'trash') { |
|
912 | 912 | // clean status |
913 | 913 | $venue_status = sanitize_key($venue_status); |
914 | 914 | // grab status |
915 | - if (!empty($venue_status)) { |
|
915 | + if ( ! empty($venue_status)) { |
|
916 | 916 | $success = TRUE; |
917 | 917 | //determine the event id and set to array. |
918 | 918 | $VNU_IDs = isset($this->_req_data['venue_id']) ? (array) $this->_req_data['venue_id'] : array(); |
@@ -952,20 +952,20 @@ discard block |
||
952 | 952 | * @param string $venue_status |
953 | 953 | * @return void |
954 | 954 | */ |
955 | - private function _change_venue_status( $VNU_ID = 0, $venue_status = '' ) { |
|
955 | + private function _change_venue_status($VNU_ID = 0, $venue_status = '') { |
|
956 | 956 | // grab venue id |
957 | - if (! $VNU_ID) { |
|
957 | + if ( ! $VNU_ID) { |
|
958 | 958 | $msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
959 | 959 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
960 | 960 | return FALSE; |
961 | 961 | } |
962 | 962 | |
963 | - $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
963 | + $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
964 | 964 | |
965 | 965 | // clean status |
966 | 966 | $venue_status = sanitize_key($venue_status); |
967 | 967 | // grab status |
968 | - if ( ! $venue_status ) { |
|
968 | + if ( ! $venue_status) { |
|
969 | 969 | $msg = __('An error occurred. No Venue Status or an invalid Venue Status was received.', 'event_espresso'); |
970 | 970 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
971 | 971 | return FALSE; |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | $hook = FALSE; |
987 | 987 | } |
988 | 988 | //use class to change status |
989 | - $this->_cpt_model_obj->set_status( $venue_status ); |
|
989 | + $this->_cpt_model_obj->set_status($venue_status); |
|
990 | 990 | $success = $this->_cpt_model_obj->save(); |
991 | 991 | |
992 | 992 | if ($success === FALSE) { |
@@ -1005,21 +1005,21 @@ discard block |
||
1005 | 1005 | * @param bool $redirect_after |
1006 | 1006 | * @return void |
1007 | 1007 | */ |
1008 | - protected function _delete_venue( $redirect_after = true ) { |
|
1008 | + protected function _delete_venue($redirect_after = true) { |
|
1009 | 1009 | //determine the venue id and set to array. |
1010 | 1010 | $VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : NULL; |
1011 | - $VNU_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $VNU_ID; |
|
1011 | + $VNU_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $VNU_ID; |
|
1012 | 1012 | |
1013 | 1013 | |
1014 | 1014 | // loop thru venues |
1015 | 1015 | if ($VNU_ID) { |
1016 | - $success = $this->_delete_or_trash_venue( $VNU_ID ); |
|
1016 | + $success = $this->_delete_or_trash_venue($VNU_ID); |
|
1017 | 1017 | } else { |
1018 | 1018 | $success = FALSE; |
1019 | 1019 | $msg = __('An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.', 'event_espresso'); |
1020 | 1020 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1021 | 1021 | } |
1022 | - if ( $redirect_after ) |
|
1022 | + if ($redirect_after) |
|
1023 | 1023 | $this->_redirect_after_action($success, 'Venue', 'deleted', array('action' => 'default')); |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | //todo: put in parent |
1052 | 1052 | private function _delete_or_trash_venue($VNU_ID = FALSE) { |
1053 | 1053 | // grab event id |
1054 | - if (!$VNU_ID = absint($VNU_ID)) { |
|
1054 | + if ( ! $VNU_ID = absint($VNU_ID)) { |
|
1055 | 1055 | $msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
1056 | 1056 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1057 | 1057 | return FALSE; |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1072 | 1072 | return FALSE; |
1073 | 1073 | } |
1074 | - do_action( 'AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted' ); |
|
1074 | + do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted'); |
|
1075 | 1075 | return TRUE; |
1076 | 1076 | } |
1077 | 1077 | |
@@ -1082,11 +1082,11 @@ discard block |
||
1082 | 1082 | /* QUERIES */ |
1083 | 1083 | |
1084 | 1084 | |
1085 | - public function get_venues( $per_page = 10, $count = FALSE ) { |
|
1085 | + public function get_venues($per_page = 10, $count = FALSE) { |
|
1086 | 1086 | |
1087 | - $_orderby = !empty( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : ''; |
|
1087 | + $_orderby = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
1088 | 1088 | |
1089 | - switch ( $_orderby ) { |
|
1089 | + switch ($_orderby) { |
|
1090 | 1090 | case 'id': |
1091 | 1091 | $orderby = 'VNU_ID'; |
1092 | 1092 | break; |
@@ -1104,43 +1104,43 @@ discard block |
||
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | |
1107 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
1107 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
1108 | 1108 | |
1109 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1110 | - $per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
|
1111 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1109 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1110 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
1111 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1112 | 1112 | |
1113 | 1113 | |
1114 | - $offset = ($current_page-1)*$per_page; |
|
1114 | + $offset = ($current_page - 1) * $per_page; |
|
1115 | 1115 | $limit = array($offset, $per_page); |
1116 | 1116 | |
1117 | - $category = isset( $this->_req_data['category'] ) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL; |
|
1117 | + $category = isset($this->_req_data['category']) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL; |
|
1118 | 1118 | $where = array(); |
1119 | 1119 | |
1120 | 1120 | //only set initial status if it is in the incoming request. Otherwise the "all" view display's all statuses. |
1121 | - if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] != 'all' ) { |
|
1121 | + if (isset($this->_req_data['status']) && $this->_req_data['status'] != 'all') { |
|
1122 | 1122 | $where['status'] = $this->_req_data['status']; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - if ( isset( $this->_req_data['venue_status'] ) ) { |
|
1125 | + if (isset($this->_req_data['venue_status'])) { |
|
1126 | 1126 | $where['status'] = $this->_req_data['venue_status']; |
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | |
1130 | - if ( $category ) { |
|
1130 | + if ($category) { |
|
1131 | 1131 | $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories'; |
1132 | 1132 | $where['Term_Taxonomy.term_id'] = $category; |
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | |
1136 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_venues', 'get_venues' ) ) { |
|
1137 | - $where['VNU_wp_user'] = get_current_user_id(); |
|
1136 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
1137 | + $where['VNU_wp_user'] = get_current_user_id(); |
|
1138 | 1138 | } else { |
1139 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' ) ) { |
|
1139 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
1140 | 1140 | $where['OR'] = array( |
1141 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1141 | + 'status*restrict_private' => array('!=', 'private'), |
|
1142 | 1142 | 'AND' => array( |
1143 | - 'status*inclusive' => array( '=', 'private' ), |
|
1143 | + 'status*inclusive' => array('=', 'private'), |
|
1144 | 1144 | 'VNU_wp_user' => get_current_user_id() |
1145 | 1145 | ) |
1146 | 1146 | ); |
@@ -1150,30 +1150,30 @@ discard block |
||
1150 | 1150 | |
1151 | 1151 | |
1152 | 1152 | |
1153 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1154 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1153 | + if (isset($this->_req_data['s'])) { |
|
1154 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1155 | 1155 | $where['OR'] = array( |
1156 | - 'VNU_name' => array('LIKE',$sstr ), |
|
1157 | - 'VNU_desc' => array('LIKE',$sstr ), |
|
1158 | - 'VNU_short_desc' => array( 'LIKE',$sstr ), |
|
1159 | - 'VNU_address' => array( 'LIKE', $sstr ), |
|
1160 | - 'VNU_address2' => array( 'LIKE', $sstr ), |
|
1161 | - 'VNU_city' => array( 'LIKE', $sstr ), |
|
1162 | - 'VNU_zip' => array( 'LIKE', $sstr ), |
|
1163 | - 'VNU_phone' => array( 'LIKE', $sstr ), |
|
1164 | - 'VNU_url' => array( 'LIKE', $sstr ), |
|
1165 | - 'VNU_virtual_phone' => array( 'LIKE', $sstr ), |
|
1166 | - 'VNU_virtual_url' => array( 'LIKE', $sstr ), |
|
1167 | - 'VNU_google_map_link' => array( 'LIKE', $sstr ), |
|
1168 | - 'Event.EVT_name' => array('LIKE', $sstr ), |
|
1169 | - 'Event.EVT_desc' => array('LIKE', $sstr ), |
|
1170 | - 'Event.EVT_phone' => array('LIKE', $sstr ), |
|
1171 | - 'Event.EVT_external_URL' => array('LIKE', $sstr ), |
|
1156 | + 'VNU_name' => array('LIKE', $sstr), |
|
1157 | + 'VNU_desc' => array('LIKE', $sstr), |
|
1158 | + 'VNU_short_desc' => array('LIKE', $sstr), |
|
1159 | + 'VNU_address' => array('LIKE', $sstr), |
|
1160 | + 'VNU_address2' => array('LIKE', $sstr), |
|
1161 | + 'VNU_city' => array('LIKE', $sstr), |
|
1162 | + 'VNU_zip' => array('LIKE', $sstr), |
|
1163 | + 'VNU_phone' => array('LIKE', $sstr), |
|
1164 | + 'VNU_url' => array('LIKE', $sstr), |
|
1165 | + 'VNU_virtual_phone' => array('LIKE', $sstr), |
|
1166 | + 'VNU_virtual_url' => array('LIKE', $sstr), |
|
1167 | + 'VNU_google_map_link' => array('LIKE', $sstr), |
|
1168 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
1169 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1170 | + 'Event.EVT_phone' => array('LIKE', $sstr), |
|
1171 | + 'Event.EVT_external_URL' => array('LIKE', $sstr), |
|
1172 | 1172 | ); |
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | |
1176 | - $venues = $count ? $this->_venue_model->count( array($where), 'VNU_ID' ) : $this->_venue_model->get_all( array( $where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort ) ); |
|
1176 | + $venues = $count ? $this->_venue_model->count(array($where), 'VNU_ID') : $this->_venue_model->get_all(array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort)); |
|
1177 | 1177 | |
1178 | 1178 | return $venues; |
1179 | 1179 | |
@@ -1191,22 +1191,22 @@ discard block |
||
1191 | 1191 | * @return void |
1192 | 1192 | */ |
1193 | 1193 | private function _set_category_object() { |
1194 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
1194 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
1195 | 1195 | return; //already have the category object so get out. |
1196 | 1196 | |
1197 | 1197 | //set default category object |
1198 | 1198 | $this->_set_empty_category_object(); |
1199 | 1199 | |
1200 | 1200 | //only set if we've got an id |
1201 | - if ( !isset($this->_req_data['VEN_CAT_ID'] ) ) { |
|
1201 | + if ( ! isset($this->_req_data['VEN_CAT_ID'])) { |
|
1202 | 1202 | return; |
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | $category_id = absint($this->_req_data['VEN_CAT_ID']); |
1206 | - $term = get_term( $category_id, 'espresso_venue_categories' ); |
|
1206 | + $term = get_term($category_id, 'espresso_venue_categories'); |
|
1207 | 1207 | |
1208 | 1208 | |
1209 | - if ( !empty( $term ) ) { |
|
1209 | + if ( ! empty($term)) { |
|
1210 | 1210 | $this->_category->category_name = $term->name; |
1211 | 1211 | $this->_category->category_identifier = $term->slug; |
1212 | 1212 | $this->_category->category_desc = $term->description; |
@@ -1220,14 +1220,14 @@ discard block |
||
1220 | 1220 | |
1221 | 1221 | private function _set_empty_category_object() { |
1222 | 1222 | $this->_category = new stdClass(); |
1223 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
1223 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
1224 | 1224 | $this->_category->id = $this->_category->parent = 0; |
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | |
1228 | 1228 | |
1229 | 1229 | protected function _category_list_table() { |
1230 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1230 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1231 | 1231 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
1232 | 1232 | $this->_search_btn_label = __('Venue Categories', 'event_espresso'); |
1233 | 1233 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -1237,21 +1237,21 @@ discard block |
||
1237 | 1237 | protected function _category_details($view) { |
1238 | 1238 | |
1239 | 1239 | //load formatter helper |
1240 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1240 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1241 | 1241 | //load field generator helper |
1242 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
1242 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
1243 | 1243 | |
1244 | 1244 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
1245 | 1245 | $this->_set_add_edit_form_tags($route); |
1246 | 1246 | |
1247 | 1247 | $this->_set_category_object(); |
1248 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
1248 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
1249 | 1249 | |
1250 | 1250 | $delete_action = 'delete_category'; |
1251 | 1251 | |
1252 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'category_list' ), $this->_admin_base_url ); |
|
1252 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
1253 | 1253 | |
1254 | - $this->_set_publish_post_box_vars( 'VEN_CAT_ID', $id, $delete_action, $redirect ); |
|
1254 | + $this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect); |
|
1255 | 1255 | |
1256 | 1256 | //take care of contents |
1257 | 1257 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -1265,25 +1265,25 @@ discard block |
||
1265 | 1265 | 'type' => 'wp_editor', |
1266 | 1266 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
1267 | 1267 | 'class' => 'my_editor_custom', |
1268 | - 'wpeditor_args' => array( 'media_buttons' => FALSE ) |
|
1268 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
1269 | 1269 | ); |
1270 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
1270 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
1271 | 1271 | |
1272 | - $all_terms = get_terms( array('espresso_venue_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
1272 | + $all_terms = get_terms(array('espresso_venue_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
1273 | 1273 | |
1274 | 1274 | //setup category select for term parents. |
1275 | 1275 | $category_select_values[] = array( |
1276 | 1276 | 'text' => __('No Parent', 'event_espresso'), |
1277 | 1277 | 'id' => 0 |
1278 | 1278 | ); |
1279 | - foreach ( $all_terms as $term ) { |
|
1279 | + foreach ($all_terms as $term) { |
|
1280 | 1280 | $category_select_values[] = array( |
1281 | 1281 | 'text' => $term->name, |
1282 | 1282 | 'id' => $term->term_id |
1283 | 1283 | ); |
1284 | 1284 | } |
1285 | 1285 | |
1286 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
1286 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
1287 | 1287 | $template_args = array( |
1288 | 1288 | 'category' => $this->_category, |
1289 | 1289 | 'category_select' => $category_select, |
@@ -1292,15 +1292,15 @@ discard block |
||
1292 | 1292 | 'disable' => '', |
1293 | 1293 | 'disabled_message' =>FALSE |
1294 | 1294 | ); |
1295 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
1296 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
1295 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
1296 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | |
1300 | 1300 | protected function _delete_categories() { |
1301 | - $cat_ids = isset( $this->_req_data['VEN_CAT_ID'] ) ? (array) $this->_req_data['VEN_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
1301 | + $cat_ids = isset($this->_req_data['VEN_CAT_ID']) ? (array) $this->_req_data['VEN_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
1302 | 1302 | |
1303 | - foreach ( $cat_ids as $cat_id ) { |
|
1303 | + foreach ($cat_ids as $cat_id) { |
|
1304 | 1304 | $this->_delete_category($cat_id); |
1305 | 1305 | } |
1306 | 1306 | |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | $query_args = array( |
1309 | 1309 | 'action' => 'category_list' |
1310 | 1310 | ); |
1311 | - $this->_redirect_after_action(0,'','',$query_args); |
|
1311 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
1312 | 1312 | |
1313 | 1313 | } |
1314 | 1314 | |
@@ -1317,58 +1317,58 @@ discard block |
||
1317 | 1317 | |
1318 | 1318 | |
1319 | 1319 | protected function _delete_category($cat_id) { |
1320 | - $cat_id = absint( $cat_id ); |
|
1321 | - wp_delete_term( $cat_id, 'espresso_venue_categories' ); |
|
1320 | + $cat_id = absint($cat_id); |
|
1321 | + wp_delete_term($cat_id, 'espresso_venue_categories'); |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | |
1325 | 1325 | |
1326 | 1326 | protected function _insert_or_update_category($new_category) { |
1327 | 1327 | |
1328 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
1328 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
1329 | 1329 | $success = 0; //we already have a success message so lets not send another. |
1330 | - if ( $cat_id ) { |
|
1330 | + if ($cat_id) { |
|
1331 | 1331 | $query_args = array( |
1332 | 1332 | 'action' => 'edit_category', |
1333 | 1333 | 'VEN_CAT_ID' => $cat_id |
1334 | 1334 | ); |
1335 | 1335 | } else { |
1336 | - $query_args = array( 'action' => 'add_category' ); |
|
1336 | + $query_args = array('action' => 'add_category'); |
|
1337 | 1337 | } |
1338 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
1338 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
1339 | 1339 | |
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
1343 | 1343 | |
1344 | - private function _insert_category( $update = FALSE ) { |
|
1344 | + private function _insert_category($update = FALSE) { |
|
1345 | 1345 | $cat_id = $update ? $this->_req_data['VEN_CAT_ID'] : ''; |
1346 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
1347 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
1348 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
1346 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
1347 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
1348 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
1349 | 1349 | |
1350 | - if ( empty( $category_name ) ) { |
|
1351 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
1352 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1350 | + if (empty($category_name)) { |
|
1351 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
1352 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1353 | 1353 | return false; |
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | |
1357 | - $term_args=array( |
|
1357 | + $term_args = array( |
|
1358 | 1358 | 'name'=>$category_name, |
1359 | 1359 | 'description'=>$category_desc, |
1360 | 1360 | 'parent'=>$category_parent |
1361 | 1361 | ); |
1362 | 1362 | |
1363 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_venue_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_venue_categories', $term_args ); |
|
1363 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_venue_categories', $term_args) : wp_insert_term($category_name, 'espresso_venue_categories', $term_args); |
|
1364 | 1364 | |
1365 | - if ( !is_array( $insert_ids ) ) { |
|
1366 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
1367 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1365 | + if ( ! is_array($insert_ids)) { |
|
1366 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
1367 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1368 | 1368 | } else { |
1369 | 1369 | $cat_id = $insert_ids['term_id']; |
1370 | - $msg = sprintf ( __('The category %s was successfuly created', 'event_espresso'), $category_name ); |
|
1371 | - EE_Error::add_success( $msg ); |
|
1370 | + $msg = sprintf(__('The category %s was successfuly created', 'event_espresso'), $category_name); |
|
1371 | + EE_Error::add_success($msg); |
|
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | return $cat_id; |
@@ -1388,12 +1388,12 @@ discard block |
||
1388 | 1388 | 'category_ids' => $this->_req_data['VEN_CAT_ID'] |
1389 | 1389 | ); |
1390 | 1390 | |
1391 | - $this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
1391 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
1392 | 1392 | |
1393 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1394 | - if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) { |
|
1395 | - require_once( EE_CLASSES . 'EE_Export.class.php'); |
|
1396 | - $EE_Export = EE_Export::instance( $this->_req_data ); |
|
1393 | + EE_Registry::instance()->load_helper('File'); |
|
1394 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
1395 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
1396 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
1397 | 1397 | $EE_Export->export(); |
1398 | 1398 | } |
1399 | 1399 | |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | |
1406 | 1406 | protected function _import_categories() { |
1407 | 1407 | |
1408 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
1408 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
1409 | 1409 | EE_Import::instance()->import(); |
1410 | 1410 | |
1411 | 1411 | } |
@@ -1413,29 +1413,29 @@ discard block |
||
1413 | 1413 | |
1414 | 1414 | |
1415 | 1415 | |
1416 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
1416 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
1417 | 1417 | |
1418 | 1418 | //testing term stuff |
1419 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
1420 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
1421 | - $limit = ($current_page-1)*$per_page; |
|
1422 | - $where = array( 'taxonomy' => 'espresso_venue_categories' ); |
|
1423 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1424 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1419 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
1420 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
1421 | + $limit = ($current_page - 1) * $per_page; |
|
1422 | + $where = array('taxonomy' => 'espresso_venue_categories'); |
|
1423 | + if (isset($this->_req_data['s'])) { |
|
1424 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1425 | 1425 | $where['OR'] = array( |
1426 | - 'Term.name' => array( 'LIKE', $sstr), |
|
1427 | - 'description' => array( 'LIKE', $sstr ) |
|
1426 | + 'Term.name' => array('LIKE', $sstr), |
|
1427 | + 'description' => array('LIKE', $sstr) |
|
1428 | 1428 | ); |
1429 | 1429 | } |
1430 | 1430 | |
1431 | 1431 | $query_params = array( |
1432 | 1432 | $where, |
1433 | - 'order_by' => array( $orderby => $order ), |
|
1434 | - 'limit' => $limit . ',' . $per_page, |
|
1433 | + 'order_by' => array($orderby => $order), |
|
1434 | + 'limit' => $limit.','.$per_page, |
|
1435 | 1435 | 'force_join' => array('Term') |
1436 | 1436 | ); |
1437 | 1437 | |
1438 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
1438 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
1439 | 1439 | |
1440 | 1440 | return $categories; |
1441 | 1441 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
61 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
62 | 62 | |
63 | 63 | //if we were going to add our own metaboxes we'd use the below. |
64 | 64 | $this->_metaboxes = array( |
65 | 65 | 0 => array( |
66 | - 'page_route' => array('edit','create_new'), |
|
66 | + 'page_route' => array('edit', 'create_new'), |
|
67 | 67 | 'func' => 'pricing_metabox', |
68 | 68 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
69 | 69 | 'priority' => 'high', |
70 | 70 | 'context' => 'normal' |
71 | 71 | ), |
72 | 72 | |
73 | - );/**/ |
|
73 | + ); /**/ |
|
74 | 74 | |
75 | 75 | $this->_remove_metaboxes = array( |
76 | 76 | 0 => array( |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @var array Expected an array returned with 'date' and 'time' keys. |
91 | 91 | */ |
92 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
93 | 93 | 'date' => 'Y-m-d', |
94 | 94 | 'time' => 'h:i a' |
95 | 95 | )); |
96 | 96 | |
97 | 97 | //validate |
98 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
99 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
98 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
99 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
100 | 100 | |
101 | 101 | //validate format strings |
102 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
103 | - if ( is_array( $format_validation ) ) { |
|
104 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
105 | - foreach ( $format_validation as $error ) { |
|
106 | - $msg .= '<li>' . $error . '</li>'; |
|
102 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
103 | + if (is_array($format_validation)) { |
|
104 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
105 | + foreach ($format_validation as $error) { |
|
106 | + $msg .= '<li>'.$error.'</li>'; |
|
107 | 107 | } |
108 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
109 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
108 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
109 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | $this->_date_format_strings = array( |
111 | 111 | 'date' => 'Y-m-d', |
112 | 112 | 'time' => 'h:i a' |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | $this->_scripts_styles = array( |
118 | 118 | 'registers' => array( |
119 | 119 | 'ee-tickets-datetimes-css' => array( |
120 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
120 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
121 | 121 | 'type' => 'css' |
122 | 122 | ), |
123 | 123 | 'ee-dtt-ticket-metabox' => array( |
124 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
124 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
125 | 125 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
126 | 126 | ) |
127 | 127 | ), |
128 | 128 | 'deregisters' => array( |
129 | - 'event-editor-css' => array('type' => 'css' ), |
|
129 | + 'event-editor-css' => array('type' => 'css'), |
|
130 | 130 | 'event-datetime-metabox' => array('type' => 'js') |
131 | 131 | ), |
132 | 132 | 'enqueues' => array( |
133 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
134 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
133 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
134 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
135 | 135 | ), |
136 | 136 | 'localize' => array( |
137 | 137 | 'ee-dtt-ticket-metabox' => array( |
138 | 138 | 'DTT_TRASH_BLOCK' => array( |
139 | 139 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
140 | 140 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
141 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
141 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
142 | 142 | 'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
143 | 143 | 'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
144 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
144 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
145 | 145 | ), |
146 | 146 | 'DTT_ERROR_MSG' => array( |
147 | 147 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
148 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
148 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
149 | 149 | ), |
150 | 150 | 'DTT_OVERSELL_WARNING' => array( |
151 | 151 | 'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'), |
152 | 152 | 'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso') |
153 | 153 | ), |
154 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
155 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
154 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
155 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
156 | 156 | ) |
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | 160 | |
161 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
162 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
161 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
162 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - public function caf_updates( $update_callbacks ) { |
|
168 | - foreach ( $update_callbacks as $key => $callback ) { |
|
169 | - if ( $callback[1] == '_default_tickets_update' ) |
|
170 | - unset( $update_callbacks[$key] ); |
|
167 | + public function caf_updates($update_callbacks) { |
|
168 | + foreach ($update_callbacks as $key => $callback) { |
|
169 | + if ($callback[1] == '_default_tickets_update') |
|
170 | + unset($update_callbacks[$key]); |
|
171 | 171 | } |
172 | 172 | |
173 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
173 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
174 | 174 | return $update_callbacks; |
175 | 175 | } |
176 | 176 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param array $data The request data from the form |
184 | 184 | * @return bool success or fail |
185 | 185 | */ |
186 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
186 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
187 | 187 | //first we need to start with datetimes cause they are the "root" items attached to events. |
188 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
188 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
189 | 189 | //next tackle the tickets (and prices?) |
190 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
190 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,36 +198,36 @@ discard block |
||
198 | 198 | * @param array $data the request data from the form |
199 | 199 | * @return EE_Datetime[] |
200 | 200 | */ |
201 | - protected function _update_dtts( $evt_obj, $data ) { |
|
202 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
201 | + protected function _update_dtts($evt_obj, $data) { |
|
202 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
203 | 203 | $saved_dtt_ids = array(); |
204 | 204 | $saved_dtt_objs = array(); |
205 | 205 | |
206 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
206 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
207 | 207 | //trim all values to ensure any excess whitespace is removed. |
208 | - $dtt = array_map( 'trim', $dtt ); |
|
209 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
208 | + $dtt = array_map('trim', $dtt); |
|
209 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
210 | 210 | $datetime_values = array( |
211 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
212 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
213 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
211 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
212 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
213 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
214 | 214 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
215 | 215 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
216 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
217 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
216 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
217 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
218 | 218 | ); |
219 | 219 | |
220 | 220 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
221 | 221 | |
222 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
223 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
222 | + if ( ! empty($dtt['DTT_ID'])) { |
|
223 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
224 | 224 | |
225 | 225 | //set date and time format according to what is set in this class. |
226 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
227 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
226 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
227 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
228 | 228 | |
229 | - foreach ( $datetime_values as $field => $value ) { |
|
230 | - $DTM->set( $field, $value ); |
|
229 | + foreach ($datetime_values as $field => $value) { |
|
230 | + $DTM->set($field, $value); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -235,24 +235,24 @@ discard block |
||
235 | 235 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
236 | 236 | |
237 | 237 | } else { |
238 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
238 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
239 | 239 | |
240 | 240 | //reset date and times to match the format |
241 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
242 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
243 | - foreach( $datetime_values as $field => $value ) { |
|
244 | - $DTM->set( $field, $value ); |
|
241 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
242 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
243 | + foreach ($datetime_values as $field => $value) { |
|
244 | + $DTM->set($field, $value); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | $DTM->save(); |
250 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
250 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
251 | 251 | $evt_obj->save(); |
252 | 252 | |
253 | 253 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
254 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
255 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
254 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
255 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
256 | 256 | EE_Registry::instance()->load_helper('DTT_Helper'); |
257 | 257 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
258 | 258 | $DTM->save(); |
@@ -268,25 +268,25 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
271 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
271 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
272 | 272 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
273 | 273 | |
274 | - if ( is_array( $old_datetimes ) ) { |
|
275 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
276 | - foreach ( $dtts_to_delete as $id ) { |
|
277 | - $id = absint( $id ); |
|
278 | - if ( empty( $id ) ) |
|
274 | + if (is_array($old_datetimes)) { |
|
275 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
276 | + foreach ($dtts_to_delete as $id) { |
|
277 | + $id = absint($id); |
|
278 | + if (empty($id)) |
|
279 | 279 | continue; |
280 | 280 | |
281 | 281 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
282 | 282 | |
283 | 283 | //remove tkt relationships. |
284 | 284 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
285 | - foreach ( $related_tickets as $tkt ) { |
|
285 | + foreach ($related_tickets as $tkt) { |
|
286 | 286 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
287 | 287 | } |
288 | 288 | |
289 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
289 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
290 | 290 | $dtt_to_remove->refresh_cache_of_related_objects(); |
291 | 291 | |
292 | 292 | } |
@@ -307,81 +307,81 @@ discard block |
||
307 | 307 | * @param array $data incoming request data |
308 | 308 | * @return EE_Ticket[] |
309 | 309 | */ |
310 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
310 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
311 | 311 | |
312 | 312 | $new_tkt = null; |
313 | 313 | $new_default = null; |
314 | 314 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
315 | 315 | $data = stripslashes_deep($data); |
316 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
316 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
317 | 317 | $saved_tickets = $dtts_on_existing = array(); |
318 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
318 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
319 | 319 | |
320 | 320 | //load money helper |
321 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
321 | + EE_Registry::instance()->load_helper('Money'); |
|
322 | 322 | |
323 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
323 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
324 | 324 | |
325 | 325 | $update_prices = $create_new_TKT = FALSE; |
326 | 326 | |
327 | 327 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
328 | 328 | |
329 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
330 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
329 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
330 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
331 | 331 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
332 | 332 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
333 | 333 | |
334 | 334 | // trim inputs to ensure any excess whitespace is removed. |
335 | - $tkt = array_map( 'trim', $tkt ); |
|
335 | + $tkt = array_map('trim', $tkt); |
|
336 | 336 | |
337 | 337 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
338 | 338 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
339 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
339 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
340 | 340 | |
341 | 341 | //note incoming base price needs converted from localized value. |
342 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
342 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
343 | 343 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
344 | 344 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
345 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
345 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
346 | 346 | |
347 | 347 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
348 | 348 | |
349 | 349 | $now = null; |
350 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
350 | + if (empty($tkt['TKT_start_date'])) { |
|
351 | 351 | //lets' use now in the set timezone. |
352 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
353 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
352 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
353 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
354 | 354 | } |
355 | 355 | |
356 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
356 | + if (empty($tkt['TKT_end_date'])) { |
|
357 | 357 | /** |
358 | 358 | * set the TKT_end_date to the first datetime attached to the ticket. |
359 | 359 | */ |
360 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
361 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
360 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
361 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | $TKT_values = array( |
365 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
366 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
367 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
368 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
365 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
366 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
367 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
368 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
369 | 369 | 'TKT_start_date' => $tkt['TKT_start_date'], |
370 | 370 | 'TKT_end_date' => $tkt['TKT_end_date'], |
371 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
372 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
373 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
374 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
371 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
372 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
373 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
374 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
375 | 375 | 'TKT_row' => $row, |
376 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
377 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
378 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
376 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
377 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
378 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
379 | 379 | 'TKT_price' => $ticket_price |
380 | 380 | ); |
381 | 381 | |
382 | 382 | |
383 | 383 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
384 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
384 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
385 | 385 | $TKT_values['TKT_ID'] = 0; |
386 | 386 | $TKT_values['TKT_is_default'] = 0; |
387 | 387 | $update_prices = TRUE; |
@@ -393,21 +393,21 @@ discard block |
||
393 | 393 | // but DID have it's items modified. |
394 | 394 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
395 | 395 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
396 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
397 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
398 | - if ( $TKT instanceof EE_Ticket ) { |
|
396 | + if (absint($TKT_values['TKT_ID'])) { |
|
397 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
398 | + if ($TKT instanceof EE_Ticket) { |
|
399 | 399 | |
400 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
400 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
401 | 401 | // are there any registrations using this ticket ? |
402 | 402 | $tickets_sold = $TKT->count_related( |
403 | 403 | 'Registration', |
404 | - array( array( |
|
405 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
406 | - ) ) |
|
404 | + array(array( |
|
405 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
406 | + )) |
|
407 | 407 | ); |
408 | 408 | //set ticket formats |
409 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
410 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
409 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
410 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
411 | 411 | |
412 | 412 | // let's just check the total price for the existing ticket |
413 | 413 | // and determine if it matches the new total price. |
@@ -417,17 +417,17 @@ discard block |
||
417 | 417 | ? TRUE : FALSE; |
418 | 418 | |
419 | 419 | //set new values |
420 | - foreach ( $TKT_values as $field => $value ) { |
|
421 | - if ( $field === 'TKT_qty' ) { |
|
422 | - $TKT->set_qty( $value ); |
|
420 | + foreach ($TKT_values as $field => $value) { |
|
421 | + if ($field === 'TKT_qty') { |
|
422 | + $TKT->set_qty($value); |
|
423 | 423 | } else { |
424 | - $TKT->set( $field, $value ); |
|
424 | + $TKT->set($field, $value); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | 428 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
429 | - if ( $create_new_TKT ) { |
|
430 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
429 | + if ($create_new_TKT) { |
|
430 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
@@ -436,12 +436,12 @@ discard block |
||
436 | 436 | $TKT = EE_Ticket::new_instance( |
437 | 437 | $TKT_values, |
438 | 438 | $timezone, |
439 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
439 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
440 | 440 | ); |
441 | - if ( $TKT instanceof EE_Ticket ) { |
|
441 | + if ($TKT instanceof EE_Ticket) { |
|
442 | 442 | // make sure ticket has an ID of setting relations won't work |
443 | 443 | $TKT->save(); |
444 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
444 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
445 | 445 | $update_prices = TRUE; |
446 | 446 | } |
447 | 447 | } |
@@ -449,38 +449,38 @@ discard block |
||
449 | 449 | //$TKT->save(); |
450 | 450 | |
451 | 451 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
452 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
453 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
452 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
453 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
454 | 454 | EE_Registry::instance()->load_helper('DTT_Helper'); |
455 | 455 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
456 | 456 | } |
457 | 457 | |
458 | 458 | //let's make sure the base price is handled |
459 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
459 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
460 | 460 | |
461 | 461 | //add/update price_modifiers |
462 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
462 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
463 | 463 | |
464 | 464 | //need to make sue that the TKT_price is accurate after saving the prices. |
465 | 465 | $TKT->ensure_TKT_Price_correct(); |
466 | 466 | |
467 | 467 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
468 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
469 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
468 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
469 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
470 | 470 | $update_prices = TRUE; |
471 | 471 | $new_default = clone $TKT; |
472 | - $new_default->set( 'TKT_ID', 0 ); |
|
473 | - $new_default->set( 'TKT_is_default', 1 ); |
|
474 | - $new_default->set( 'TKT_row', 1 ); |
|
475 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
472 | + $new_default->set('TKT_ID', 0); |
|
473 | + $new_default->set('TKT_is_default', 1); |
|
474 | + $new_default->set('TKT_row', 1); |
|
475 | + $new_default->set('TKT_price', $ticket_price); |
|
476 | 476 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
477 | 477 | $new_default->_remove_relations('Datetime'); |
478 | 478 | //todo we need to add the current attached prices as new prices to the new default ticket. |
479 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
479 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
480 | 480 | //don't forget the base price! |
481 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
481 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
482 | 482 | $new_default->save(); |
483 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
483 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -491,19 +491,19 @@ discard block |
||
491 | 491 | //let's assign any tickets that have been setup to the saved_tickets tracker |
492 | 492 | //save existing TKT |
493 | 493 | $TKT->save(); |
494 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
494 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
495 | 495 | //save new TKT |
496 | 496 | $new_tkt->save(); |
497 | 497 | //add new ticket to array |
498 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
498 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
499 | 499 | |
500 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
500 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
501 | 501 | |
502 | 502 | } else { |
503 | 503 | //add tkt to saved tkts |
504 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
504 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
505 | 505 | |
506 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
506 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | } |
@@ -513,22 +513,22 @@ discard block |
||
513 | 513 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
514 | 514 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
515 | 515 | // No sense in keeping all the related data in the db! |
516 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
517 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
516 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
517 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
518 | 518 | |
519 | - foreach ( $tickets_removed as $id ) { |
|
520 | - $id = absint( $id ); |
|
519 | + foreach ($tickets_removed as $id) { |
|
520 | + $id = absint($id); |
|
521 | 521 | |
522 | 522 | //get the ticket for this id |
523 | 523 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
524 | 524 | |
525 | 525 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
526 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
526 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
527 | 527 | continue; |
528 | 528 | |
529 | 529 | // if this tkt has any registrations attached so then we just ARCHIVE |
530 | 530 | // because we don't actually permanently delete these tickets. |
531 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
531 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
532 | 532 | $tkt_to_remove->delete(); |
533 | 533 | continue; |
534 | 534 | } |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
538 | 538 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
539 | 539 | |
540 | - foreach( $dtts as $dtt ) { |
|
540 | + foreach ($dtts as $dtt) { |
|
541 | 541 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
542 | 542 | } |
543 | 543 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
546 | 546 | $tkt_to_remove->delete_related_permanently('Price'); |
547 | 547 | |
548 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
548 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
549 | 549 | |
550 | 550 | // finally let's delete this ticket |
551 | 551 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -577,39 +577,39 @@ discard block |
||
577 | 577 | // and removing the ticket from datetimes it got removed from. |
578 | 578 | |
579 | 579 | // first let's add datetimes |
580 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
581 | - foreach ( $added_datetimes as $row_id ) { |
|
582 | - $row_id = (int)$row_id; |
|
583 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
584 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
580 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
581 | + foreach ($added_datetimes as $row_id) { |
|
582 | + $row_id = (int) $row_id; |
|
583 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
584 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
585 | 585 | // Is this an existing ticket (has an ID) and does it have any sold? |
586 | 586 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
587 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
588 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
589 | - $saved_datetimes[ $row_id ]->save(); |
|
587 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
588 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
589 | + $saved_datetimes[$row_id]->save(); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | } |
593 | 593 | } |
594 | 594 | // then remove datetimes |
595 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
596 | - foreach ( $removed_datetimes as $row_id ) { |
|
597 | - $row_id = (int)$row_id; |
|
595 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
596 | + foreach ($removed_datetimes as $row_id) { |
|
597 | + $row_id = (int) $row_id; |
|
598 | 598 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
599 | 599 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
600 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
601 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
600 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
601 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
602 | 602 | // Is this an existing ticket (has an ID) and does it have any sold? |
603 | 603 | // If so, then we need to remove it's sold from the DTT_sold. |
604 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
605 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
606 | - $saved_datetimes[ $row_id ]->save(); |
|
604 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
605 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
606 | + $saved_datetimes[$row_id]->save(); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | } |
610 | 610 | } |
611 | 611 | // cap ticket qty by datetime reg limits |
612 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
612 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
613 | 613 | return $ticket; |
614 | 614 | } |
615 | 615 | |
@@ -630,39 +630,39 @@ discard block |
||
630 | 630 | EE_Ticket $ticket, |
631 | 631 | $price_rows = array(), |
632 | 632 | $ticket_price = 0, |
633 | - $base_price = 0 , |
|
633 | + $base_price = 0, |
|
634 | 634 | $base_price_id = 0 |
635 | 635 | ) { |
636 | 636 | |
637 | 637 | // create new ticket that's a copy of the existing |
638 | 638 | // except a new id of course (and not archived) |
639 | 639 | // AND has the new TKT_price associated with it. |
640 | - $new_ticket = clone( $ticket ); |
|
641 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
642 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
643 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
644 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
640 | + $new_ticket = clone($ticket); |
|
641 | + $new_ticket->set('TKT_ID', 0); |
|
642 | + $new_ticket->set('TKT_deleted', 0); |
|
643 | + $new_ticket->set('TKT_price', $ticket_price); |
|
644 | + $new_ticket->set('TKT_sold', 0); |
|
645 | 645 | // let's get a new ID for this ticket |
646 | 646 | $new_ticket->save(); |
647 | 647 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
648 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
648 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
649 | 649 | $new_ticket = $this->_update_ticket_datetimes( |
650 | 650 | $new_ticket, |
651 | 651 | $datetimes_on_existing, |
652 | - array_keys( $datetimes_on_existing ) |
|
652 | + array_keys($datetimes_on_existing) |
|
653 | 653 | ); |
654 | 654 | |
655 | 655 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
656 | 656 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
657 | 657 | // available. |
658 | - if ( $ticket->sold() > 0 ) { |
|
658 | + if ($ticket->sold() > 0) { |
|
659 | 659 | $new_qty = $ticket->qty() - $ticket->sold(); |
660 | - $new_ticket->set_qty( $new_qty ); |
|
660 | + $new_ticket->set_qty($new_qty); |
|
661 | 661 | } |
662 | 662 | //now we update the prices just for this ticket |
663 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
663 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
664 | 664 | //and we update the base price |
665 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
665 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
666 | 666 | return $new_ticket; |
667 | 667 | } |
668 | 668 | |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
683 | 683 | * @return EE_Ticket |
684 | 684 | */ |
685 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
685 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
686 | 686 | |
687 | 687 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
688 | 688 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | $updated_prices = array(); |
691 | 691 | |
692 | 692 | // if $base_price ! FALSE then updating a base price. |
693 | - if ( $base_price !== FALSE ) { |
|
693 | + if ($base_price !== FALSE) { |
|
694 | 694 | $prices[1] = array( |
695 | 695 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
696 | 696 | 'PRT_ID' => 1, |
@@ -701,47 +701,47 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | //possibly need to save tkt |
704 | - if ( ! $ticket->ID() ) |
|
704 | + if ( ! $ticket->ID()) |
|
705 | 705 | $ticket->save(); |
706 | 706 | |
707 | - foreach ( $prices as $row => $prc ) { |
|
708 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
709 | - if ( empty($prt_id) ) |
|
707 | + foreach ($prices as $row => $prc) { |
|
708 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
709 | + if (empty($prt_id)) |
|
710 | 710 | continue; //prices MUST have a price type id. |
711 | 711 | $PRC_values = array( |
712 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
712 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
713 | 713 | 'PRT_ID' => $prt_id, |
714 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
715 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
716 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
714 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
715 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
716 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
717 | 717 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
718 | 718 | 'PRC_order' => $row |
719 | 719 | ); |
720 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
720 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
721 | 721 | $PRC_values['PRC_ID'] = 0; |
722 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
722 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
723 | 723 | } else { |
724 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
724 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
725 | 725 | //update this price with new values |
726 | - foreach ( $PRC_values as $field => $newprc ) { |
|
727 | - $PRC->set( $field, $newprc ); |
|
726 | + foreach ($PRC_values as $field => $newprc) { |
|
727 | + $PRC->set($field, $newprc); |
|
728 | 728 | } |
729 | 729 | } |
730 | 730 | $PRC->save(); |
731 | 731 | $prcid = $PRC->ID(); |
732 | 732 | $updated_prices[$prcid] = $PRC; |
733 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
733 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | //now let's remove any prices that got removed from the ticket |
737 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
737 | + if ( ! empty ($current_prices_on_ticket)) { |
|
738 | 738 | $current = array_keys($current_prices_on_ticket); |
739 | 739 | $updated = array_keys($updated_prices); |
740 | 740 | $prices_to_remove = array_diff($current, $updated); |
741 | - if ( !empty( $prices_to_remove ) ) { |
|
742 | - foreach ( $prices_to_remove as $prc_id ) { |
|
741 | + if ( ! empty($prices_to_remove)) { |
|
742 | + foreach ($prices_to_remove as $prc_id) { |
|
743 | 743 | $p = $current_prices_on_ticket[$prc_id]; |
744 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
744 | + $ticket->_remove_relation_to($p, 'Price'); |
|
745 | 745 | |
746 | 746 | //delete permanently the price |
747 | 747 | $p->delete_permanently(); |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | |
755 | 755 | |
756 | 756 | |
757 | - public function autosave_handling( $event_admin_obj ) { |
|
757 | + public function autosave_handling($event_admin_obj) { |
|
758 | 758 | return $event_admin_obj; //doing nothing for the moment. |
759 | 759 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
760 | 760 | |
@@ -788,12 +788,12 @@ discard block |
||
788 | 788 | |
789 | 789 | //default main template args |
790 | 790 | $main_template_args = array( |
791 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
791 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
792 | 792 | 'existing_datetime_ids' => '', |
793 | 793 | 'total_dtt_rows' => 1, |
794 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
794 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
795 | 795 | 'datetime_rows' => '', |
796 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
796 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
797 | 797 | 'ticket_rows' => '', |
798 | 798 | 'existing_ticket_ids' => '', |
799 | 799 | 'total_ticket_rows' => 1, |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
805 | 805 | |
806 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
806 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
807 | 807 | |
808 | 808 | /** |
809 | 809 | * 1. Start with retrieving Datetimes |
@@ -811,25 +811,25 @@ discard block |
||
811 | 811 | * 3. For each ticket get related prices |
812 | 812 | */ |
813 | 813 | |
814 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
815 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
814 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
815 | + $times = $DTM->get_all_event_dates($evtID); |
|
816 | 816 | |
817 | 817 | |
818 | 818 | |
819 | 819 | $main_template_args['total_dtt_rows'] = count($times); |
820 | - foreach ( $times as $time ) { |
|
820 | + foreach ($times as $time) { |
|
821 | 821 | $dttid = $time->get('DTT_ID'); |
822 | 822 | $dttrow = $time->get('DTT_order'); |
823 | 823 | $existing_datetime_ids[] = $dttid; |
824 | 824 | |
825 | 825 | //tickets attached |
826 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
826 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
827 | 827 | |
828 | 828 | //if there are no related tickets this is likely a new event OR autodraft |
829 | 829 | // event so we need to generate the default tickets because dtts |
830 | 830 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
831 | 831 | // datetime on the event. |
832 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
832 | + if (empty ($related_tickets) && count($times) < 2) { |
|
833 | 833 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
834 | 834 | } |
835 | 835 | |
@@ -838,11 +838,11 @@ discard block |
||
838 | 838 | |
839 | 839 | //loop through and setup the ticket rows and make sure the order is set. |
840 | 840 | $order = 0; |
841 | - foreach ( $related_tickets as $ticket ) { |
|
841 | + foreach ($related_tickets as $ticket) { |
|
842 | 842 | $tktid = $ticket->get('TKT_ID'); |
843 | 843 | $tktrow = $ticket->get('TKT_row'); |
844 | 844 | //we only want unique tickets in our final display!! |
845 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
845 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
846 | 846 | $existing_ticket_ids[] = $tktid; |
847 | 847 | $all_tickets[] = $ticket; |
848 | 848 | } |
@@ -851,56 +851,56 @@ discard block |
||
851 | 851 | $datetime_tickets[$dttid][] = $tktrow; |
852 | 852 | |
853 | 853 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
854 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
854 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
855 | 855 | $ticket_datetimes[$tktid][] = $dttrow; |
856 | 856 | } |
857 | 857 | } |
858 | 858 | |
859 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
860 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
861 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
859 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
860 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
861 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
862 | 862 | |
863 | 863 | //sort $all_tickets by order |
864 | - usort( $all_tickets, function( $a, $b ) { |
|
864 | + usort($all_tickets, function($a, $b) { |
|
865 | 865 | $a_order = (int) $a->get('TKT_order'); |
866 | 866 | $b_order = (int) $b->get('TKT_order'); |
867 | - if ( $a_order == $b_order ) { |
|
867 | + if ($a_order == $b_order) { |
|
868 | 868 | return 0; |
869 | 869 | } |
870 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
870 | + return ($a_order < $b_order) ? -1 : 1; |
|
871 | 871 | }); |
872 | 872 | |
873 | 873 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
874 | 874 | $dttrow = 1; |
875 | - foreach ( $times as $time ) { |
|
876 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
875 | + foreach ($times as $time) { |
|
876 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
877 | 877 | $dttrow++; |
878 | 878 | } |
879 | 879 | |
880 | 880 | //then loop through all tickets for the ticket rows. |
881 | 881 | $tktrow = 1; |
882 | - foreach ( $all_tickets as $ticket ) { |
|
883 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
882 | + foreach ($all_tickets as $ticket) { |
|
883 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
884 | 884 | $tktrow++; |
885 | 885 | } |
886 | 886 | |
887 | 887 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
888 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
889 | - EEH_Template::display_template( $template, $main_template_args ); |
|
888 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
889 | + EEH_Template::display_template($template, $main_template_args); |
|
890 | 890 | return; |
891 | 891 | } |
892 | 892 | |
893 | 893 | |
894 | 894 | |
895 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
895 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
896 | 896 | |
897 | 897 | $dtt_display_template_args = array( |
898 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
899 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
898 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
899 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
900 | 900 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
901 | 901 | ); |
902 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
903 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
902 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
903 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | * |
919 | 919 | * @return string Generated edit row. |
920 | 920 | */ |
921 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
921 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
922 | 922 | |
923 | 923 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
924 | 924 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -926,30 +926,30 @@ discard block |
||
926 | 926 | $template_args = array( |
927 | 927 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
928 | 928 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
929 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
929 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
930 | 930 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
931 | 931 | 'DTT_name' => $default ? '' : $dtt->name(), |
932 | 932 | 'DTT_description' => $default ? '' : $dtt->description(), |
933 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
934 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
935 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
933 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
934 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
935 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
936 | 936 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
937 | 937 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
938 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
939 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
938 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
939 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
940 | 940 | ); |
941 | 941 | |
942 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
942 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
943 | 943 | |
944 | 944 | //allow filtering of template args at this point. |
945 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
945 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
946 | 946 | |
947 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
948 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
947 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
948 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | |
952 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
952 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
953 | 953 | |
954 | 954 | $template_args = array( |
955 | 955 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -957,47 +957,47 @@ discard block |
||
957 | 957 | 'DTT_description' => $default ? '' : $dtt->description(), |
958 | 958 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
959 | 959 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
960 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
960 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
961 | 961 | 'DTT_ID' => $default ? '' : $dtt->ID() |
962 | 962 | ); |
963 | 963 | |
964 | 964 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
965 | - if ( !$default ) { |
|
965 | + if ( ! $default) { |
|
966 | 966 | $tktrow = 1; |
967 | - foreach ( $all_tickets as $ticket ) { |
|
968 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
967 | + foreach ($all_tickets as $ticket) { |
|
968 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
969 | 969 | $tktrow++; |
970 | 970 | } |
971 | 971 | } |
972 | 972 | |
973 | 973 | //filter template args at this point |
974 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
974 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
975 | 975 | |
976 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
977 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
976 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
977 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | |
981 | 981 | |
982 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
983 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
984 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
982 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
983 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
984 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
985 | 985 | |
986 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
986 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
987 | 987 | $template_args = array( |
988 | 988 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
989 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
989 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
990 | 990 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
991 | 991 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
992 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
993 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
992 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
993 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
994 | 994 | ); |
995 | 995 | |
996 | 996 | //filter template args |
997 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
997 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
998 | 998 | |
999 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1000 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
999 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1000 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | |
@@ -1019,32 +1019,32 @@ discard block |
||
1019 | 1019 | * |
1020 | 1020 | * @return [type] [description] |
1021 | 1021 | */ |
1022 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1022 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1023 | 1023 | |
1024 | 1024 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1025 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1025 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1026 | 1026 | |
1027 | 1027 | |
1028 | - $prices = !empty($ticket) && !$default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1028 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1029 | 1029 | |
1030 | 1030 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1031 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1031 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1032 | 1032 | |
1033 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1033 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1034 | 1034 | |
1035 | 1035 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1036 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1036 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1037 | 1037 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1038 | 1038 | |
1039 | 1039 | //breaking out complicated condition for ticket_status |
1040 | - if ( $default ) { |
|
1041 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1040 | + if ($default) { |
|
1041 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1042 | 1042 | } else { |
1043 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1043 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | //breaking out complicated condition for TKT_taxable |
1047 | - if ( $default ) { |
|
1047 | + if ($default) { |
|
1048 | 1048 | $TKT_taxable = ''; |
1049 | 1049 | } else { |
1050 | 1050 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1059,19 +1059,19 @@ discard block |
||
1059 | 1059 | 'edit_tkt_expanded' => '', |
1060 | 1060 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1061 | 1061 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1062 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1063 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1064 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1062 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1063 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1064 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1065 | 1065 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1066 | 1066 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1067 | 1067 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1068 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1069 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1070 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1071 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1072 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1068 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1069 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1070 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1071 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1072 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1073 | 1073 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1074 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1074 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1075 | 1075 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1076 | 1076 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1077 | 1077 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1080,99 +1080,99 @@ discard block |
||
1080 | 1080 | 'ticket_price_rows' => '', |
1081 | 1081 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1082 | 1082 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1083 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1084 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1083 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1084 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1085 | 1085 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1086 | 1086 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1087 | 1087 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1088 | 1088 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1089 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1089 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1090 | 1090 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1091 | 1091 | 'TKT_taxable' => $TKT_taxable, |
1092 | 1092 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1093 | 1093 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1094 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1094 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1095 | 1095 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1096 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1097 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1096 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1097 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1098 | 1098 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1099 | 1099 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1100 | 1100 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1101 | 1101 | ); |
1102 | 1102 | |
1103 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1103 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1104 | 1104 | |
1105 | 1105 | //handle rows that should NOT be empty |
1106 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1106 | + if (empty($template_args['TKT_start_date'])) { |
|
1107 | 1107 | //if empty then the start date will be now. |
1108 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1109 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1108 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1109 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1112 | + if (empty($template_args['TKT_end_date'])) { |
|
1113 | 1113 | |
1114 | 1114 | //get the earliest datetime (if present); |
1115 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1115 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1116 | 1116 | |
1117 | - if ( !empty( $earliest_dtt ) ) { |
|
1118 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1117 | + if ( ! empty($earliest_dtt)) { |
|
1118 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1119 | 1119 | } else { |
1120 | 1120 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1121 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1121 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1122 | 1122 | } |
1123 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1123 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | //generate ticket_datetime items |
1127 | - if ( ! $default ) { |
|
1127 | + if ( ! $default) { |
|
1128 | 1128 | $dttrow = 1; |
1129 | - foreach ( $all_dtts as $dtt ) { |
|
1130 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1129 | + foreach ($all_dtts as $dtt) { |
|
1130 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1131 | 1131 | $dttrow++; |
1132 | 1132 | } |
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | $prcrow = 1; |
1136 | - foreach ( $prices as $price ) { |
|
1137 | - if ( $price->is_base_price() ) { |
|
1136 | + foreach ($prices as $price) { |
|
1137 | + if ($price->is_base_price()) { |
|
1138 | 1138 | $prcrow++; |
1139 | 1139 | continue; |
1140 | 1140 | } |
1141 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1142 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1143 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1141 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1142 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1143 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1144 | 1144 | $prcrow++; |
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | //filter $template_args |
1148 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1148 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1149 | 1149 | |
1150 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1151 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1150 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1151 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | |
1155 | 1155 | |
1156 | 1156 | |
1157 | 1157 | |
1158 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1158 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1159 | 1159 | $tax_rows = ''; |
1160 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1160 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1161 | 1161 | $template_args = array(); |
1162 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1163 | - foreach ( $taxes as $tax ) { |
|
1164 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1162 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1163 | + foreach ($taxes as $tax) { |
|
1164 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1165 | 1165 | $template_args = array( |
1166 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1166 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1167 | 1167 | 'tax_id' => $tax->ID(), |
1168 | 1168 | 'tkt_row' => $tktrow, |
1169 | 1169 | 'tax_label' => $tax->get('PRC_name'), |
1170 | 1170 | 'tax_added' => $tax_added, |
1171 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1171 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1172 | 1172 | 'tax_amount' => $tax->get('PRC_amount') |
1173 | 1173 | ); |
1174 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1175 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1174 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1175 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | |
@@ -1180,81 +1180,81 @@ discard block |
||
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | |
1183 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1184 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1183 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1184 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1185 | 1185 | return $subtotal * $tax->get('PRC_amount') / 100; |
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | |
1189 | 1189 | |
1190 | 1190 | |
1191 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1192 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1191 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1192 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1193 | 1193 | $template_args = array( |
1194 | 1194 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1195 | 1195 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1196 | 1196 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1197 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1197 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1198 | 1198 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1199 | 1199 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1200 | 1200 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1201 | 1201 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1202 | 1202 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1203 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1204 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1205 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1206 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1207 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1203 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1204 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1205 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1206 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1207 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1208 | 1208 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1209 | 1209 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1210 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1211 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1210 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1211 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1212 | 1212 | ); |
1213 | 1213 | |
1214 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1214 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1215 | 1215 | |
1216 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1217 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1216 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1217 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | |
1221 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1222 | - if ( $price->is_base_price() ) { |
|
1223 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1221 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1222 | + if ($price->is_base_price()) { |
|
1223 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1224 | 1224 | } else { |
1225 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1225 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | |
1231 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1231 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1232 | 1232 | $template_args = array( |
1233 | 1233 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1234 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1235 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1234 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1235 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1236 | 1236 | 'PRT_name' => __('Price', 'event_espresso'), |
1237 | 1237 | 'price_selected_operator' => '+', |
1238 | 1238 | 'price_selected_is_percent' => 0 |
1239 | 1239 | ); |
1240 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1240 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1241 | 1241 | |
1242 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1242 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1243 | 1243 | |
1244 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1244 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | |
1248 | 1248 | |
1249 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1250 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1251 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1252 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1253 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1254 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1249 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1250 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1251 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1252 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1253 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1254 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1255 | 1255 | $price_option_spans = ''; |
1256 | 1256 | //setup pricetypes for selector |
1257 | - foreach ( $price_types as $price_type ) { |
|
1257 | + foreach ($price_types as $price_type) { |
|
1258 | 1258 | $all_price_types[] = array( |
1259 | 1259 | 'id' => $price_type->ID(), |
1260 | 1260 | 'text' => $price_type->get('PRT_name'), |
@@ -1266,50 +1266,50 @@ discard block |
||
1266 | 1266 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1267 | 1267 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1268 | 1268 | ); |
1269 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1269 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1270 | 1270 | } |
1271 | 1271 | |
1272 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1272 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1273 | 1273 | $main_name = $select_name; |
1274 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1274 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1275 | 1275 | |
1276 | 1276 | $template_args = array( |
1277 | 1277 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1278 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1279 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1278 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1279 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1280 | 1280 | 'main_name' => $main_name, |
1281 | 1281 | 'selected_price_type_id' => $selected_price_type_id, |
1282 | 1282 | 'price_option_spans' => $price_option_spans, |
1283 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1284 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1283 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1284 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1285 | 1285 | 'disabled' => $disabled |
1286 | 1286 | ); |
1287 | 1287 | |
1288 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1288 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1289 | 1289 | |
1290 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1290 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1291 | 1291 | |
1292 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1292 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | |
1296 | 1296 | |
1297 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1298 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1299 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1300 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1297 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1298 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1299 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1300 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1301 | 1301 | $template_args = array( |
1302 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1302 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1303 | 1303 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1304 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1305 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1306 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1304 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1305 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1306 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1307 | 1307 | 'tkt_status_class' => '', |
1308 | 1308 | ); |
1309 | 1309 | |
1310 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1311 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1312 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1310 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1311 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1312 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | |
@@ -1317,53 +1317,53 @@ discard block |
||
1317 | 1317 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1318 | 1318 | $template_args = array( |
1319 | 1319 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1320 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1321 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1320 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1321 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1322 | 1322 | 'default_price_rows' => '', |
1323 | 1323 | 'default_base_price_amount' => 0, |
1324 | 1324 | 'default_base_price_name' => '', |
1325 | 1325 | 'default_base_price_description' => '', |
1326 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1327 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1326 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1327 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1328 | 1328 | 'existing_available_datetime_tickets_list' => '', |
1329 | 1329 | 'existing_available_ticket_datetimes_list' => '', |
1330 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1331 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1330 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1331 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1332 | 1332 | ); |
1333 | 1333 | |
1334 | 1334 | $tktrow = 1; |
1335 | - foreach ( $all_tickets as $ticket ) { |
|
1336 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1335 | + foreach ($all_tickets as $ticket) { |
|
1336 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1337 | 1337 | $tktrow++; |
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | |
1341 | 1341 | $dttrow = 1; |
1342 | - foreach ( $all_dtts as $dtt ) { |
|
1343 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1342 | + foreach ($all_dtts as $dtt) { |
|
1343 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1344 | 1344 | $dttrow++; |
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1348 | 1348 | $prcrow = 1; |
1349 | - foreach ( $default_prices as $price ) { |
|
1350 | - if ( $price->is_base_price() ) { |
|
1349 | + foreach ($default_prices as $price) { |
|
1350 | + if ($price->is_base_price()) { |
|
1351 | 1351 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1352 | 1352 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1353 | 1353 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1354 | 1354 | $prcrow++; |
1355 | 1355 | continue; |
1356 | 1356 | } |
1357 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1358 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1359 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1357 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1358 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1359 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1360 | 1360 | $prcrow++; |
1361 | 1361 | } |
1362 | 1362 | |
1363 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1363 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1364 | 1364 | |
1365 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1366 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1365 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1366 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | <?php _e('Adjust the settings for the Authorize.net AIM payment gateway.', 'event_espresso'); ?> |
4 | 4 | </p> |
5 | 5 | <p> |
6 | -<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Authorize.net AIM.', 'event_espresso' ), "<a href='http://www.authorize.net/international/' target='_blank'>","</a>" ); ?> |
|
6 | +<?php printf(__('See %1$shere%2$s for list of currencies supported by Authorize.net AIM.', 'event_espresso'), "<a href='http://www.authorize.net/international/' target='_blank'>", "</a>"); ?> |
|
7 | 7 | </p> |
8 | 8 | <h3><?php _e('Authorize.net AIM Settings', 'event_espresso'); ?></h3> |
9 | 9 | <ul> |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | <?php _e('By logging into Authorize.net, you can change which payment fields are required by Authorize.net when processing payments. These settings affect both the Advanced Integration Method (AIM, this) and the Simple Integration Method (SIM, different). The payment method settings "Excluded Payment Form Fields" and "Required Payment Form Fields" allow you to change the billing form in Event Espresso to reflect your payment form settings in Authorize.net.', 'event_espresso'); ?> |
29 | 29 | <br> |
30 | 30 | <?php printf( |
31 | - __( 'To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.'), |
|
31 | + __('To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.'), |
|
32 | 32 | '<a href="http://authorize.net" target="_blank">', |
33 | 33 | '</a>', |
34 | 34 | '<a href="https://monosnap.com/file/nebVteOkEXcdDIos88SojStWOifP23" target="_blank">', |
35 | 35 | '<a href="https://monosnap.com/file/WyxGJtev87TcDmdGBEZ2oi1xaBIQAm" target="_blank">', |
36 | - '<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank">');?> |
|
36 | + '<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank">'); ?> |
|
37 | 37 | </li> |
38 | 38 | <li> |
39 | 39 | <strong><?php _e('Button Image URL', 'event_espresso'); ?></strong><br /> |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public static function instance() { |
80 | 80 | // check if class object is instantiated |
81 | - if ( ! self::$_instance instanceof EE_CPT_Strategy ) { |
|
81 | + if ( ! self::$_instance instanceof EE_CPT_Strategy) { |
|
82 | 82 | self::$_instance = new self(); |
83 | 83 | } |
84 | 84 | return self::$_instance; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // d( $this->_CPT_endpoints ); |
102 | 102 | // d( $this->_CPT_taxonomies ); |
103 | 103 | |
104 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 5 ); |
|
104 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 5); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | private function _set_CPT_endpoints() { |
116 | 116 | $_CPT_endpoints = array(); |
117 | - if ( is_array( $this->_CPTs )) { |
|
118 | - foreach ( $this->_CPTs as $CPT_type => $CPT ) { |
|
119 | - $_CPT_endpoints [ $CPT['plural_slug'] ] = $CPT_type; |
|
117 | + if (is_array($this->_CPTs)) { |
|
118 | + foreach ($this->_CPTs as $CPT_type => $CPT) { |
|
119 | + $_CPT_endpoints [$CPT['plural_slug']] = $CPT_type; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $_CPT_endpoints; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param WP_Query $WP_Query |
132 | 132 | * @return void |
133 | 133 | */ |
134 | - private function _set_EE_tags_on_WP_Query( WP_Query $WP_Query) { |
|
134 | + private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query) { |
|
135 | 135 | $WP_Query->is_espresso_event_single = FALSE; |
136 | 136 | $WP_Query->is_espresso_event_archive = FALSE; |
137 | 137 | $WP_Query->is_espresso_event_taxonomy = FALSE; |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | */ |
159 | 159 | private function _set_CPT_taxonomies() { |
160 | 160 | // check if taxonomies have already been set |
161 | - if ( empty( $this->_CPT_taxonomies )) { |
|
161 | + if (empty($this->_CPT_taxonomies)) { |
|
162 | 162 | // and that this CPT has taxonomies registered for it |
163 | - if ( isset( $this->CPT['args'] ) && isset( $this->CPT['args']['taxonomies'] )) { |
|
163 | + if (isset($this->CPT['args']) && isset($this->CPT['args']['taxonomies'])) { |
|
164 | 164 | // if so then grab them, but we want the taxonomy name as the key |
165 | - $taxonomies = array_flip( $this->CPT['args']['taxonomies'] ); |
|
165 | + $taxonomies = array_flip($this->CPT['args']['taxonomies']); |
|
166 | 166 | // then grab the list of ALL taxonomies |
167 | 167 | $all_taxonomies = EE_Register_CPTs::get_taxonomies(); |
168 | - foreach ( $taxonomies as $taxonomy => $details ) { |
|
168 | + foreach ($taxonomies as $taxonomy => $details) { |
|
169 | 169 | // add details to our taxonomies if they exist |
170 | - $taxonomies[ $taxonomy ] = isset( $all_taxonomies[ $taxonomy ] ) ? $all_taxonomies[ $taxonomy ] : NULL; |
|
170 | + $taxonomies[$taxonomy] = isset($all_taxonomies[$taxonomy]) ? $all_taxonomies[$taxonomy] : NULL; |
|
171 | 171 | } |
172 | 172 | $this->_CPT_taxonomies = $taxonomies; |
173 | 173 | } |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | * @return void |
193 | 193 | */ |
194 | 194 | private function _set_CPT_terms() { |
195 | - if ( empty( $this->_CPT_terms )) { |
|
195 | + if (empty($this->_CPT_terms)) { |
|
196 | 196 | $terms = EEM_Term::instance()->get_all_CPT_post_tags(); |
197 | - foreach ( $terms as $term ) { |
|
198 | - $this->_CPT_terms[ $term->slug() ] = $term; |
|
197 | + foreach ($terms as $term) { |
|
198 | + $this->_CPT_terms[$term->slug()] = $term; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
@@ -209,24 +209,24 @@ discard block |
||
209 | 209 | * @param $WP_Query |
210 | 210 | * @return void |
211 | 211 | */ |
212 | - private function _set_post_type_for_terms( WP_Query $WP_Query ) { |
|
212 | + private function _set_post_type_for_terms(WP_Query $WP_Query) { |
|
213 | 213 | // is a tag set ? |
214 | - if ( isset( $WP_Query->query['tag'] )) { |
|
214 | + if (isset($WP_Query->query['tag'])) { |
|
215 | 215 | // set post_tags |
216 | 216 | $this->_set_CPT_terms(); |
217 | 217 | // is this tag archive term in the list of terms used by our CPTs ? |
218 | - $term = isset ( $this->_CPT_terms[ $WP_Query->query['tag'] ] ) ? $this->_CPT_terms[ $WP_Query->query['tag'] ] : NULL; |
|
218 | + $term = isset ($this->_CPT_terms[$WP_Query->query['tag']]) ? $this->_CPT_terms[$WP_Query->query['tag']] : NULL; |
|
219 | 219 | // verify the term |
220 | - if ( $term instanceof EE_Term ) { |
|
221 | - $term->post_type = array_merge( array( 'post', 'page' ), (array)$term->post_type ); |
|
222 | - $term->post_type = apply_filters( 'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term ); |
|
220 | + if ($term instanceof EE_Term) { |
|
221 | + $term->post_type = array_merge(array('post', 'page'), (array) $term->post_type); |
|
222 | + $term->post_type = apply_filters('FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term); |
|
223 | 223 | // if a post type is already set |
224 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
224 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
225 | 225 | // add to existing array |
226 | - $term->post_type = array_merge ( (array)$WP_Query->query_vars['post_type'], $term->post_type ); |
|
226 | + $term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type); |
|
227 | 227 | } |
228 | 228 | // just set post_type to our CPT |
229 | - $WP_Query->set( 'post_type', $term->post_type ); |
|
229 | + $WP_Query->set('post_type', $term->post_type); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -241,17 +241,17 @@ discard block |
||
241 | 241 | * in order for is_archive() and is_single() methods to work properly. |
242 | 242 | * @return void |
243 | 243 | */ |
244 | - public function _possibly_set_ee_request_var(){ |
|
244 | + public function _possibly_set_ee_request_var() { |
|
245 | 245 | // check if ee action var has been set |
246 | - if ( ! EE_Registry::instance()->REQ->is_set( 'ee' )) { |
|
246 | + if ( ! EE_Registry::instance()->REQ->is_set('ee')) { |
|
247 | 247 | // check that route exists for CPT archive slug |
248 | - if ( is_archive() && EE_Config::get_route( $this->CPT['plural_slug'] )) { |
|
248 | + if (is_archive() && EE_Config::get_route($this->CPT['plural_slug'])) { |
|
249 | 249 | // ie: set "ee" to "events" |
250 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['plural_slug'] ); |
|
250 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['plural_slug']); |
|
251 | 251 | // or does it match a single page CPT like /event/ |
252 | - } else if ( is_single() && EE_Config::get_route( $this->CPT['singular_slug'] )) { |
|
252 | + } else if (is_single() && EE_Config::get_route($this->CPT['singular_slug'])) { |
|
253 | 253 | // ie: set "ee" to "event" |
254 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
254 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | * @param WP_Query $WP_Query |
266 | 266 | * @return void |
267 | 267 | */ |
268 | - public function _set_paging( $WP_Query ) { |
|
269 | - if ( $WP_Query->is_main_query() && apply_filters( 'FHEE__EE_CPT_Strategy___set_paging', TRUE )) { |
|
270 | - $page = ( get_query_var('page') ) ? get_query_var('page') : NULL; |
|
271 | - $paged = ( get_query_var('paged') ) ? get_query_var('paged') : $page; |
|
272 | - $WP_Query->set( 'paged', $paged ); |
|
268 | + public function _set_paging($WP_Query) { |
|
269 | + if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', TRUE)) { |
|
270 | + $page = (get_query_var('page')) ? get_query_var('page') : NULL; |
|
271 | + $paged = (get_query_var('paged')) ? get_query_var('paged') : $page; |
|
272 | + $WP_Query->set('paged', $paged); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -286,35 +286,35 @@ discard block |
||
286 | 286 | * @param WP_Query $WP_Query |
287 | 287 | * @return void |
288 | 288 | */ |
289 | - public function pre_get_posts( $WP_Query ) { |
|
289 | + public function pre_get_posts($WP_Query) { |
|
290 | 290 | // check that post-type is set |
291 | - if ( ! $WP_Query instanceof WP_Query ) { |
|
291 | + if ( ! $WP_Query instanceof WP_Query) { |
|
292 | 292 | return; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // add our conditionals |
296 | - $this->_set_EE_tags_on_WP_Query( $WP_Query ); |
|
296 | + $this->_set_EE_tags_on_WP_Query($WP_Query); |
|
297 | 297 | // check for terms |
298 | - $this->_set_post_type_for_terms( $WP_Query ); |
|
298 | + $this->_set_post_type_for_terms($WP_Query); |
|
299 | 299 | // make sure paging is always set |
300 | - $this->_set_paging( $WP_Query ); |
|
300 | + $this->_set_paging($WP_Query); |
|
301 | 301 | |
302 | 302 | // is a taxonomy set ? |
303 | - if ( $WP_Query->is_tax ) { |
|
303 | + if ($WP_Query->is_tax) { |
|
304 | 304 | // loop thru our taxonomies |
305 | - foreach ( $this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details ) { |
|
305 | + foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) { |
|
306 | 306 | // check if one of our taxonomies is set as a query var |
307 | - if ( isset( $WP_Query->query[ $CPT_taxonomy ] )) { |
|
307 | + if (isset($WP_Query->query[$CPT_taxonomy])) { |
|
308 | 308 | // but which CPT does that correspond to??? hmmm... guess we gotta go looping |
309 | - foreach ( $this->_CPTs as $post_type => $CPT ) { |
|
309 | + foreach ($this->_CPTs as $post_type => $CPT) { |
|
310 | 310 | // verify our CPT has args, is public and has taxonomies set |
311 | - if ( isset( $CPT['args'] ) && $CPT['args']['public'] && ! empty( $CPT['args']['taxonomies'] )) { |
|
311 | + if (isset($CPT['args']) && $CPT['args']['public'] && ! empty($CPT['args']['taxonomies'])) { |
|
312 | 312 | // does the captured taxonomy belong to this CPT ? |
313 | - if ( in_array( $CPT_taxonomy, $CPT['args']['taxonomies'] )) { |
|
313 | + if (in_array($CPT_taxonomy, $CPT['args']['taxonomies'])) { |
|
314 | 314 | // if so, then add this CPT post_type to the current query's array of post_types' |
315 | - $WP_Query->query_vars['post_type'] = isset( $WP_Query->query_vars['post_type'] ) ? (array)$WP_Query->query_vars['post_type'] : array(); |
|
315 | + $WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type']) ? (array) $WP_Query->query_vars['post_type'] : array(); |
|
316 | 316 | $WP_Query->query_vars['post_type'][] = $post_type; |
317 | - switch( $post_type ) { |
|
317 | + switch ($post_type) { |
|
318 | 318 | case 'espresso_events' : |
319 | 319 | $WP_Query->is_espresso_event_taxonomy = TRUE; |
320 | 320 | break; |
@@ -335,24 +335,24 @@ discard block |
||
335 | 335 | // d( $CPT_taxonomy ); |
336 | 336 | // d( $WP_Query ); |
337 | 337 | |
338 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
338 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
339 | 339 | // loop thru post_types as array |
340 | - foreach ( (array)$WP_Query->query_vars['post_type'] as $post_type ) { |
|
340 | + foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) { |
|
341 | 341 | |
342 | 342 | // is current query for an EE CPT ? |
343 | - if ( isset( $this->_CPTs[ $post_type ] )) { |
|
343 | + if (isset($this->_CPTs[$post_type])) { |
|
344 | 344 | // is EE on or off ? |
345 | - if ( EE_Maintenance_Mode::instance()->level() ) { |
|
345 | + if (EE_Maintenance_Mode::instance()->level()) { |
|
346 | 346 | // reroute CPT template view to maintenance_mode.template.php |
347 | - if( ! has_filter( 'template_include',array( 'EE_Maintenance_Mode', 'template_include' ))){ |
|
348 | - add_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ), 99999 ); |
|
347 | + if ( ! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) { |
|
348 | + add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999); |
|
349 | 349 | } |
350 | 350 | return; |
351 | 351 | } |
352 | 352 | // load EE_Request_Handler (this was added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/9037 |
353 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
353 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
354 | 354 | // grab details for the CPT the current query is for |
355 | - $this->CPT = $this->_CPTs[ $post_type ]; |
|
355 | + $this->CPT = $this->_CPTs[$post_type]; |
|
356 | 356 | // set post type |
357 | 357 | $this->CPT['post_type'] = $post_type; |
358 | 358 | // set taxonomies |
@@ -360,27 +360,27 @@ discard block |
||
360 | 360 | // the post or category or term that is triggering EE |
361 | 361 | $this->CPT['espresso_page'] = EE_Registry::instance()->REQ->is_espresso_page(); |
362 | 362 | // requested post name |
363 | - $this->CPT['post_name'] = EE_Registry::instance()->REQ->get( 'post_name' ); |
|
363 | + $this->CPT['post_name'] = EE_Registry::instance()->REQ->get('post_name'); |
|
364 | 364 | //d( $this->CPT ); |
365 | 365 | // add support for viewing 'private', 'draft', or 'pending' posts |
366 | - if ( is_user_logged_in() && isset( $WP_Query->query_vars['p'] ) && $WP_Query->query_vars['p'] != 0 && current_user_can( 'edit_post', $WP_Query->query_vars['p'] )) { |
|
366 | + if (is_user_logged_in() && isset($WP_Query->query_vars['p']) && $WP_Query->query_vars['p'] != 0 && current_user_can('edit_post', $WP_Query->query_vars['p'])) { |
|
367 | 367 | // we can just inject directly into the WP_Query object |
368 | - $WP_Query->query['post_status'] = array( 'publish', 'private', 'draft', 'pending' ); |
|
368 | + $WP_Query->query['post_status'] = array('publish', 'private', 'draft', 'pending'); |
|
369 | 369 | // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s) |
370 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
370 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
371 | 371 | } |
372 | - $this->_possibly_set_ee_request_var( $post_type ); |
|
372 | + $this->_possibly_set_ee_request_var($post_type); |
|
373 | 373 | // convert post_type to model name |
374 | - $model_name = str_replace( 'EE_', '', $this->CPT['class_name'] ); |
|
374 | + $model_name = str_replace('EE_', '', $this->CPT['class_name']); |
|
375 | 375 | // get CPT table data via CPT Model |
376 | - $this->CPT_model = EE_Registry::instance()->load_model( $model_name ); |
|
376 | + $this->CPT_model = EE_Registry::instance()->load_model($model_name); |
|
377 | 377 | $this->CPT['tables'] = $this->CPT_model->get_tables(); |
378 | 378 | // is there a Meta Table for this CPT? |
379 | - $this->CPT['meta_table'] = isset( $this->CPT['tables'][ $model_name . '_Meta' ] ) ? $this->CPT['tables'][ $model_name . '_Meta' ] : FALSE; |
|
379 | + $this->CPT['meta_table'] = isset($this->CPT['tables'][$model_name.'_Meta']) ? $this->CPT['tables'][$model_name.'_Meta'] : FALSE; |
|
380 | 380 | // creates classname like: CPT_Event_Strategy |
381 | - $CPT_Strategy_class_name = 'CPT_' . $model_name . '_Strategy'; |
|
381 | + $CPT_Strategy_class_name = 'CPT_'.$model_name.'_Strategy'; |
|
382 | 382 | // load and instantiate |
383 | - $CPT_Strategy = EE_Registry::instance()->load_core ( $CPT_Strategy_class_name, array( 'WP_Query' => $WP_Query, 'CPT' => $this->CPT )); |
|
383 | + $CPT_Strategy = EE_Registry::instance()->load_core($CPT_Strategy_class_name, array('WP_Query' => $WP_Query, 'CPT' => $this->CPT)); |
|
384 | 384 | |
385 | 385 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
386 | 386 | // here's the list of available filters in the WP_Query object |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | // 'post_limits' |
393 | 393 | // 'posts_fields' |
394 | 394 | // 'posts_join' |
395 | - add_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
396 | - add_filter( 'posts_join', array( $this, 'posts_join' )); |
|
397 | - add_filter( 'get_' . $this->CPT['post_type'] . '_metadata', array( $CPT_Strategy, 'get_EE_post_type_metadata' ), 1, 4 ); |
|
398 | - add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 1 ); |
|
399 | - add_filter( 'get_edit_post_link', array( $this, 'get_edit_post_link' ), 10, 2 ); |
|
395 | + add_filter('posts_fields', array($this, 'posts_fields')); |
|
396 | + add_filter('posts_join', array($this, 'posts_join')); |
|
397 | + add_filter('get_'.$this->CPT['post_type'].'_metadata', array($CPT_Strategy, 'get_EE_post_type_metadata'), 1, 4); |
|
398 | + add_filter('the_posts', array($this, 'the_posts'), 1, 1); |
|
399 | + add_filter('get_edit_post_link', array($this, 'get_edit_post_link'), 10, 2); |
|
400 | 400 | |
401 | - $this->_do_template_filters( $WP_Query ); |
|
401 | + $this->_do_template_filters($WP_Query); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
@@ -413,13 +413,13 @@ discard block |
||
413 | 413 | * @param $SQL |
414 | 414 | * @return string |
415 | 415 | */ |
416 | - public function posts_fields( $SQL ) { |
|
416 | + public function posts_fields($SQL) { |
|
417 | 417 | // does this CPT have a meta table ? |
418 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
418 | + if ( ! empty($this->CPT['meta_table'])) { |
|
419 | 419 | // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement |
420 | - $SQL .= ', ' . $this->CPT['meta_table']->get_table_name() . '.* ' ; |
|
420 | + $SQL .= ', '.$this->CPT['meta_table']->get_table_name().'.* '; |
|
421 | 421 | } |
422 | - remove_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
422 | + remove_filter('posts_fields', array($this, 'posts_fields')); |
|
423 | 423 | return $SQL; |
424 | 424 | } |
425 | 425 | |
@@ -432,14 +432,14 @@ discard block |
||
432 | 432 | * @param $SQL |
433 | 433 | * @return string |
434 | 434 | */ |
435 | - public function posts_join( $SQL ) { |
|
435 | + public function posts_join($SQL) { |
|
436 | 436 | // does this CPT have a meta table ? |
437 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
437 | + if ( ! empty($this->CPT['meta_table'])) { |
|
438 | 438 | global $wpdb; |
439 | 439 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
440 | - $SQL .= ' LEFT JOIN ' . $this->CPT['meta_table']->get_table_name() . ' ON ( ' . $this->CPT['meta_table']->get_table_name() . '.' . $this->CPT['meta_table']->get_fk_on_table() . ' = ' . $wpdb->posts . '.ID ) '; |
|
440 | + $SQL .= ' LEFT JOIN '.$this->CPT['meta_table']->get_table_name().' ON ( '.$this->CPT['meta_table']->get_table_name().'.'.$this->CPT['meta_table']->get_fk_on_table().' = '.$wpdb->posts.'.ID ) '; |
|
441 | 441 | } |
442 | - remove_filter( 'posts_join', array( $this, 'posts_join' )); |
|
442 | + remove_filter('posts_join', array($this, 'posts_join')); |
|
443 | 443 | return $SQL; |
444 | 444 | } |
445 | 445 | |
@@ -452,18 +452,18 @@ discard block |
||
452 | 452 | * @param \WP_Post[] $posts |
453 | 453 | * @return \WP_Post[] |
454 | 454 | */ |
455 | - public function the_posts( $posts ) { |
|
455 | + public function the_posts($posts) { |
|
456 | 456 | // d( $posts ); |
457 | 457 | $CPT_class = $this->CPT['class_name']; |
458 | 458 | // loop thru posts |
459 | - if ( is_array( $posts )) { |
|
460 | - foreach( $posts as $key => $post ) { |
|
461 | - if ( isset( $this->_CPTs[ $post->post_type ] )) { |
|
462 | - $post->$CPT_class = $this->CPT_model->instantiate_class_from_post_object( $post ); |
|
459 | + if (is_array($posts)) { |
|
460 | + foreach ($posts as $key => $post) { |
|
461 | + if (isset($this->_CPTs[$post->post_type])) { |
|
462 | + $post->$CPT_class = $this->CPT_model->instantiate_class_from_post_object($post); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | } |
466 | - remove_filter( 'the_posts', array( $this, 'the_posts' ), 1, 1 ); |
|
466 | + remove_filter('the_posts', array($this, 'the_posts'), 1, 1); |
|
467 | 467 | return $posts; |
468 | 468 | } |
469 | 469 | |
@@ -474,17 +474,17 @@ discard block |
||
474 | 474 | * @param $ID |
475 | 475 | * @return string |
476 | 476 | */ |
477 | - function get_edit_post_link( $url, $ID ) { |
|
477 | + function get_edit_post_link($url, $ID) { |
|
478 | 478 | //need to make sure we only edit links if our cpt |
479 | 479 | global $post; |
480 | - if ( ! isset( $this->_CPTs[ $post->post_type ] )) { |
|
480 | + if ( ! isset($this->_CPTs[$post->post_type])) { |
|
481 | 481 | return $url; |
482 | 482 | } |
483 | 483 | //k made it here so all is good. |
484 | 484 | $scheme = is_ssl() ? 'https' : 'http'; |
485 | - $url = get_admin_url( EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme ); |
|
485 | + $url = get_admin_url(EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme); |
|
486 | 486 | // http://example.com/wp-admin/admin.php?page=espresso_events&action=edit&post=205&edit_nonce=0d403530d6 |
487 | - return wp_nonce_url( add_query_arg( array( 'page' => $this->CPT['post_type'], 'post' =>$ID, 'action' =>'edit' ), $url ), 'edit', 'edit_nonce' ); |
|
487 | + return wp_nonce_url(add_query_arg(array('page' => $this->CPT['post_type'], 'post' =>$ID, 'action' =>'edit'), $url), 'edit', 'edit_nonce'); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -498,11 +498,11 @@ discard block |
||
498 | 498 | * @param WP_Query $WP_Query |
499 | 499 | * @return void |
500 | 500 | */ |
501 | - protected function _do_template_filters( WP_Query $WP_Query ) { |
|
501 | + protected function _do_template_filters(WP_Query $WP_Query) { |
|
502 | 502 | // if it's the main query and requested cpt supports page_templates, |
503 | - if ( $WP_Query->is_main_query() && ! empty( $this->CPT['args']['page_templates'] ) ) { |
|
503 | + if ($WP_Query->is_main_query() && ! empty($this->CPT['args']['page_templates'])) { |
|
504 | 504 | // then let's hook into the appropriate query_template hook |
505 | - add_filter( 'single_template', array( $this, 'single_cpt_template' ) ); |
|
505 | + add_filter('single_template', array($this, 'single_cpt_template')); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -516,17 +516,17 @@ discard block |
||
516 | 516 | * @param string $current_template Existing default template path derived for this page call. |
517 | 517 | * @return string the path to the full template file. |
518 | 518 | */ |
519 | - public function single_cpt_template( $current_template ) { |
|
519 | + public function single_cpt_template($current_template) { |
|
520 | 520 | $object = get_queried_object(); |
521 | 521 | //does this called object HAVE a page template set that is something other than the default. |
522 | - $template = get_post_meta( $object->ID, '_wp_page_template', true ); |
|
522 | + $template = get_post_meta($object->ID, '_wp_page_template', true); |
|
523 | 523 | |
524 | 524 | //exit early if default or not set or invalid path (accounts for theme changes) |
525 | - if ( $template == 'default' || empty( $template ) || ! is_readable( get_stylesheet_directory() . '/' . $template ) ) { |
|
525 | + if ($template == 'default' || empty($template) || ! is_readable(get_stylesheet_directory().'/'.$template)) { |
|
526 | 526 | return $current_template; |
527 | 527 | } |
528 | 528 | //made it here so we SHOULD be able to just locate the template and then return it. |
529 | - $template = locate_template( array($template) ); |
|
529 | + $template = locate_template(array($template)); |
|
530 | 530 | |
531 | 531 | return $template; |
532 | 532 | } |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | * @param array $arguments |
575 | 575 | * @return \EE_CPT_Default_Strategy |
576 | 576 | */ |
577 | - public function __construct( $arguments = array() ) { |
|
578 | - $this->CPT = isset( $arguments['CPT'] ) ? $arguments['CPT'] : NULL; |
|
579 | - $WP_Query = isset( $arguments['WP_Query'] ) ? $arguments['WP_Query'] : NULL; |
|
577 | + public function __construct($arguments = array()) { |
|
578 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : NULL; |
|
579 | + $WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : NULL; |
|
580 | 580 | //EEH_Debug_Tools::printr( $this->CPT, '$this->CPT <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
581 | 581 | // add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), 999 ); |
582 | 582 | // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | * @param \WP_Query $WP_Query |
592 | 592 | * @return \WP_Query |
593 | 593 | */ |
594 | - public function pre_get_posts( WP_Query $WP_Query ) { |
|
594 | + public function pre_get_posts(WP_Query $WP_Query) { |
|
595 | 595 | //EEH_Debug_Tools::printr( $WP_Query, '$WP_Query <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
596 | - if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive() ) { |
|
596 | + if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
597 | 597 | return $WP_Query; |
598 | 598 | } |
599 | 599 | // $WP_Query->set( 'post_type', array( $this->CPT['post_type'] )); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * @param \WP_Query $WP_Query |
612 | 612 | * @return \WP_Post[] |
613 | 613 | */ |
614 | - public function the_posts( $posts, WP_Query $WP_Query ) { |
|
614 | + public function the_posts($posts, WP_Query $WP_Query) { |
|
615 | 615 | return $posts; |
616 | 616 | } |
617 | 617 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @param string $single |
628 | 628 | * @return mixed |
629 | 629 | */ |
630 | - public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) { |
|
630 | + public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) { |
|
631 | 631 | return $meta_value; |
632 | 632 | } |
633 | 633 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * date_format and the second value is the time format |
51 | 51 | * @return EE_Event |
52 | 52 | */ |
53 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
54 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
55 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
53 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
54 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
55 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * the website will be used. |
64 | 64 | * @return EE_Event |
65 | 65 | */ |
66 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
67 | - return new self( $props_n_values, TRUE, $timezone ); |
|
66 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
67 | + return new self($props_n_values, TRUE, $timezone); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @param array $query_params like EEM_Base::get_all |
76 | 76 | * @return EE_Datetime[] |
77 | 77 | */ |
78 | - public function datetimes( $query_params = array() ) { |
|
79 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
78 | + public function datetimes($query_params = array()) { |
|
79 | + return $this->get_many_related('Datetime', $query_params); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return EE_Datetime[] |
88 | 88 | */ |
89 | 89 | public function datetimes_in_chronological_order() { |
90 | - return $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) ); |
|
90 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * @param null $limit |
104 | 104 | * @return \EE_Datetime[] |
105 | 105 | */ |
106 | - public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) { |
|
107 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted, $limit ); |
|
106 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) { |
|
107 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted, $limit); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return EE_Datetime |
115 | 115 | */ |
116 | 116 | public function first_datetime() { |
117 | - return $this->get_first_related( 'Datetime' ); |
|
117 | + return $this->get_first_related('Datetime'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * @param bool $try_to_exclude_deleted |
126 | 126 | * @return EE_Datetime |
127 | 127 | */ |
128 | - public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) { |
|
129 | - if ( !empty ( $this->_Primary_Datetime ) ) { |
|
128 | + public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) { |
|
129 | + if ( ! empty ($this->_Primary_Datetime)) { |
|
130 | 130 | return $this->_Primary_Datetime; |
131 | 131 | } |
132 | - $this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted ); |
|
132 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted); |
|
133 | 133 | return $this->_Primary_Datetime; |
134 | 134 | } |
135 | 135 | |
@@ -140,30 +140,30 @@ discard block |
||
140 | 140 | * @param array $query_params like EEM_Base::get_all |
141 | 141 | * @return EE_Ticket[] |
142 | 142 | */ |
143 | - public function tickets( $query_params = array() ) { |
|
143 | + public function tickets($query_params = array()) { |
|
144 | 144 | //first get all datetimes |
145 | 145 | $datetimes = $this->datetimes_ordered(); |
146 | - if ( ! $datetimes ) { |
|
146 | + if ( ! $datetimes) { |
|
147 | 147 | return array(); |
148 | 148 | } |
149 | 149 | |
150 | 150 | $datetime_ids = array(); |
151 | - foreach ( $datetimes as $datetime ) { |
|
151 | + foreach ($datetimes as $datetime) { |
|
152 | 152 | $datetime_ids[] = $datetime->ID(); |
153 | 153 | } |
154 | 154 | |
155 | - $where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) ); |
|
155 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
156 | 156 | |
157 | 157 | //if incoming $query_params has where conditions let's merge but not override existing. |
158 | - if ( is_array( $query_params ) && isset( $query_params[0]) ) { |
|
159 | - $where_params = array_merge( $query_params[0], $where_params ); |
|
160 | - unset( $query_params[0] ); |
|
158 | + if (is_array($query_params) && isset($query_params[0])) { |
|
159 | + $where_params = array_merge($query_params[0], $where_params); |
|
160 | + unset($query_params[0]); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | //now add $where_params to $query_params |
164 | 164 | $query_params[0] = $where_params; |
165 | 165 | |
166 | - return EEM_Ticket::instance()->get_all( $query_params ); |
|
166 | + return EEM_Ticket::instance()->get_all($query_params); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return bool |
173 | 173 | */ |
174 | 174 | function additional_limit() { |
175 | - return $this->get( 'EVT_additional_limit' ); |
|
175 | + return $this->get('EVT_additional_limit'); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return bool |
182 | 182 | */ |
183 | 183 | function allow_overflow() { |
184 | - return $this->get( 'EVT_allow_overflow' ); |
|
184 | + return $this->get('EVT_allow_overflow'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return bool |
191 | 191 | */ |
192 | 192 | function created() { |
193 | - return $this->get( 'EVT_created' ); |
|
193 | + return $this->get('EVT_created'); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return bool |
200 | 200 | */ |
201 | 201 | function description() { |
202 | - return $this->get( 'EVT_desc' ); |
|
202 | + return $this->get('EVT_desc'); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return string of html |
210 | 210 | */ |
211 | 211 | function description_filtered() { |
212 | - return $this->get_pretty( 'EVT_desc' ); |
|
212 | + return $this->get_pretty('EVT_desc'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @return bool |
219 | 219 | */ |
220 | 220 | function display_description() { |
221 | - return $this->get( 'EVT_display_desc' ); |
|
221 | + return $this->get('EVT_display_desc'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @return bool |
228 | 228 | */ |
229 | 229 | function display_ticket_selector() { |
230 | - return (bool)$this->get( 'EVT_display_ticket_selector' ); |
|
230 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @return bool |
237 | 237 | */ |
238 | 238 | function external_url() { |
239 | - return $this->get( 'EVT_external_URL' ); |
|
239 | + return $this->get('EVT_external_URL'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @return bool |
246 | 246 | */ |
247 | 247 | function member_only() { |
248 | - return $this->get( 'EVT_member_only' ); |
|
248 | + return $this->get('EVT_member_only'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @return bool |
255 | 255 | */ |
256 | 256 | function phone() { |
257 | - return $this->get( 'EVT_phone' ); |
|
257 | + return $this->get('EVT_phone'); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @return bool |
264 | 264 | */ |
265 | 265 | function modified() { |
266 | - return $this->get( 'EVT_modified' ); |
|
266 | + return $this->get('EVT_modified'); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return bool |
273 | 273 | */ |
274 | 274 | function name() { |
275 | - return $this->get( 'EVT_name' ); |
|
275 | + return $this->get('EVT_name'); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @return bool |
282 | 282 | */ |
283 | 283 | function order() { |
284 | - return $this->get( 'EVT_order' ); |
|
284 | + return $this->get('EVT_order'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @return bool|string |
291 | 291 | */ |
292 | 292 | function default_registration_status() { |
293 | - $event_default_registration_status = $this->get( 'EVT_default_registration_status' ); |
|
294 | - return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
293 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
294 | + return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | * @param bool $not_full_desc |
303 | 303 | * @return bool|string |
304 | 304 | */ |
305 | - function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) { |
|
306 | - $short_desc = $this->get( 'EVT_short_desc' ); |
|
307 | - if ( !empty( $short_desc ) || $not_full_desc ) { |
|
305 | + function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) { |
|
306 | + $short_desc = $this->get('EVT_short_desc'); |
|
307 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
308 | 308 | return $short_desc; |
309 | 309 | } |
310 | 310 | else { |
311 | - $full_desc = $this->get( 'EVT_desc' ); |
|
312 | - return wp_trim_words( $full_desc, $num_words, $more ); |
|
311 | + $full_desc = $this->get('EVT_desc'); |
|
312 | + return wp_trim_words($full_desc, $num_words, $more); |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return bool |
320 | 320 | */ |
321 | 321 | function slug() { |
322 | - return $this->get( 'EVT_slug' ); |
|
322 | + return $this->get('EVT_slug'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return bool |
329 | 329 | */ |
330 | 330 | function timezone_string() { |
331 | - return $this->get( 'EVT_timezone_string' ); |
|
331 | + return $this->get('EVT_timezone_string'); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @return bool |
338 | 338 | */ |
339 | 339 | function visible_on() { |
340 | - return $this->get( 'EVT_visible_on' ); |
|
340 | + return $this->get('EVT_visible_on'); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @return bool |
347 | 347 | */ |
348 | 348 | function wp_user() { |
349 | - return $this->get( 'EVT_wp_user' ); |
|
349 | + return $this->get('EVT_wp_user'); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return bool |
356 | 356 | */ |
357 | 357 | function donations() { |
358 | - return $this->get( 'EVT_donations' ); |
|
358 | + return $this->get('EVT_donations'); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | /** |
364 | 364 | * @param $limit |
365 | 365 | */ |
366 | - function set_additional_limit( $limit ) { |
|
367 | - $this->set( 'EVT_additional_limit', $limit ); |
|
366 | + function set_additional_limit($limit) { |
|
367 | + $this->set('EVT_additional_limit', $limit); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | /** |
373 | 373 | * @param $created |
374 | 374 | */ |
375 | - function set_created( $created ) { |
|
376 | - $this->set( 'EVT_created', $created ); |
|
375 | + function set_created($created) { |
|
376 | + $this->set('EVT_created', $created); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | /** |
382 | 382 | * @param $desc |
383 | 383 | */ |
384 | - function set_description( $desc ) { |
|
385 | - $this->set( 'EVT_desc', $desc ); |
|
384 | + function set_description($desc) { |
|
385 | + $this->set('EVT_desc', $desc); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @param $display_desc |
392 | 392 | */ |
393 | - function set_display_description( $display_desc ) { |
|
394 | - $this->set( 'EVT_display_desc', $display_desc ); |
|
393 | + function set_display_description($display_desc) { |
|
394 | + $this->set('EVT_display_desc', $display_desc); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | /** |
400 | 400 | * @param $display_ticket_selector |
401 | 401 | */ |
402 | - function set_display_ticket_selector( $display_ticket_selector ) { |
|
403 | - $this->set( 'EVT_display_ticket_selector', $display_ticket_selector ); |
|
402 | + function set_display_ticket_selector($display_ticket_selector) { |
|
403 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | /** |
409 | 409 | * @param $external_url |
410 | 410 | */ |
411 | - function set_external_url( $external_url ) { |
|
412 | - $this->set( 'EVT_external_URL', $external_url ); |
|
411 | + function set_external_url($external_url) { |
|
412 | + $this->set('EVT_external_URL', $external_url); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | /** |
418 | 418 | * @param $member_only |
419 | 419 | */ |
420 | - function set_member_only( $member_only ) { |
|
421 | - $this->set( 'EVT_member_only', $member_only ); |
|
420 | + function set_member_only($member_only) { |
|
421 | + $this->set('EVT_member_only', $member_only); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | /** |
427 | 427 | * @param $event_phone |
428 | 428 | */ |
429 | - function set_event_phone( $event_phone ) { |
|
430 | - $this->set( 'EVT_phone', $event_phone ); |
|
429 | + function set_event_phone($event_phone) { |
|
430 | + $this->set('EVT_phone', $event_phone); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | /** |
436 | 436 | * @param $modified |
437 | 437 | */ |
438 | - function set_modified( $modified ) { |
|
439 | - $this->set( 'EVT_modified', $modified ); |
|
438 | + function set_modified($modified) { |
|
439 | + $this->set('EVT_modified', $modified); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | /** |
445 | 445 | * @param $name |
446 | 446 | */ |
447 | - function set_name( $name ) { |
|
448 | - $this->set( 'EVT_name', $name ); |
|
447 | + function set_name($name) { |
|
448 | + $this->set('EVT_name', $name); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | /** |
454 | 454 | * @param $order |
455 | 455 | */ |
456 | - function set_order( $order ) { |
|
457 | - $this->set( 'EVT_order', $order ); |
|
456 | + function set_order($order) { |
|
457 | + $this->set('EVT_order', $order); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | /** |
463 | 463 | * @param $short_desc |
464 | 464 | */ |
465 | - function set_short_description( $short_desc ) { |
|
466 | - $this->set( 'EVT_short_desc', $short_desc ); |
|
465 | + function set_short_description($short_desc) { |
|
466 | + $this->set('EVT_short_desc', $short_desc); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | /** |
472 | 472 | * @param $slug |
473 | 473 | */ |
474 | - function set_slug( $slug ) { |
|
475 | - $this->set( 'EVT_slug', $slug ); |
|
474 | + function set_slug($slug) { |
|
475 | + $this->set('EVT_slug', $slug); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | /** |
481 | 481 | * @param $timezone_string |
482 | 482 | */ |
483 | - function set_timezone_string( $timezone_string ) { |
|
484 | - $this->set( 'EVT_timezone_string', $timezone_string ); |
|
483 | + function set_timezone_string($timezone_string) { |
|
484 | + $this->set('EVT_timezone_string', $timezone_string); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | /** |
490 | 490 | * @param $visible_on |
491 | 491 | */ |
492 | - function set_visible_on( $visible_on ) { |
|
493 | - $this->set( 'EVT_visible_on', $visible_on ); |
|
492 | + function set_visible_on($visible_on) { |
|
493 | + $this->set('EVT_visible_on', $visible_on); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | /** |
499 | 499 | * @param $wp_user |
500 | 500 | */ |
501 | - function set_wp_user( $wp_user ) { |
|
502 | - $this->set( 'EVT_wp_user', $wp_user ); |
|
501 | + function set_wp_user($wp_user) { |
|
502 | + $this->set('EVT_wp_user', $wp_user); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | /** |
508 | 508 | * @param $default_registration_status |
509 | 509 | */ |
510 | - function set_default_registration_status( $default_registration_status ) { |
|
511 | - $this->set( 'EVT_default_registration_status', $default_registration_status ); |
|
510 | + function set_default_registration_status($default_registration_status) { |
|
511 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | /** |
517 | 517 | * @param $donations |
518 | 518 | */ |
519 | - function set_donations( $donations ) { |
|
520 | - $this->set( 'EVT_donations', $donations ); |
|
519 | + function set_donations($donations) { |
|
520 | + $this->set('EVT_donations', $donations); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | * @param EE_Venue /int $venue_id_or_obj |
528 | 528 | * @return EE_Venue |
529 | 529 | */ |
530 | - function add_venue( $venue_id_or_obj ) { |
|
531 | - return $this->_add_relation_to( $venue_id_or_obj, 'Venue' ); |
|
530 | + function add_venue($venue_id_or_obj) { |
|
531 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | * @param EE_Venue /int $venue_id_or_obj |
539 | 539 | * @return EE_Venue |
540 | 540 | */ |
541 | - function remove_venue( $venue_id_or_obj ) { |
|
542 | - return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' ); |
|
541 | + function remove_venue($venue_id_or_obj) { |
|
542 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @param array $query_params like EEM_Base::get_all's $query_params |
550 | 550 | * @return EE_Venue[] |
551 | 551 | */ |
552 | - function venues( $query_params = array() ) { |
|
553 | - return $this->get_many_related( 'Venue', $query_params ); |
|
552 | + function venues($query_params = array()) { |
|
553 | + return $this->get_many_related('Venue', $query_params); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | */ |
563 | 563 | private function _has_ID_and_is_published() { |
564 | 564 | // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
565 | - return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE; |
|
565 | + return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE; |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
@@ -574,21 +574,21 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function is_upcoming() { |
576 | 576 | // check if event id is present and if this event is published |
577 | - if ( $this->is_inactive() ) { |
|
577 | + if ($this->is_inactive()) { |
|
578 | 578 | return FALSE; |
579 | 579 | } |
580 | 580 | // set initial value |
581 | 581 | $upcoming = FALSE; |
582 | 582 | //next let's get all datetimes and loop through them |
583 | 583 | $datetimes = $this->datetimes_in_chronological_order(); |
584 | - foreach ( $datetimes as $datetime ) { |
|
585 | - if ( $datetime instanceof EE_Datetime ) { |
|
584 | + foreach ($datetimes as $datetime) { |
|
585 | + if ($datetime instanceof EE_Datetime) { |
|
586 | 586 | //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
587 | - if ( $datetime->is_expired() ) { |
|
587 | + if ($datetime->is_expired()) { |
|
588 | 588 | continue; |
589 | 589 | } |
590 | 590 | //if this dtt is active then we return false. |
591 | - if ( $datetime->is_active() ) { |
|
591 | + if ($datetime->is_active()) { |
|
592 | 592 | return FALSE; |
593 | 593 | } |
594 | 594 | //otherwise let's check upcoming status |
@@ -605,21 +605,21 @@ discard block |
||
605 | 605 | */ |
606 | 606 | public function is_active() { |
607 | 607 | // check if event id is present and if this event is published |
608 | - if ( $this->is_inactive() ) { |
|
608 | + if ($this->is_inactive()) { |
|
609 | 609 | return FALSE; |
610 | 610 | } |
611 | 611 | // set initial value |
612 | 612 | $active = FALSE; |
613 | 613 | //next let's get all datetimes and loop through them |
614 | 614 | $datetimes = $this->datetimes_in_chronological_order(); |
615 | - foreach ( $datetimes as $datetime ) { |
|
616 | - if ( $datetime instanceof EE_Datetime ) { |
|
615 | + foreach ($datetimes as $datetime) { |
|
616 | + if ($datetime instanceof EE_Datetime) { |
|
617 | 617 | //if this dtt is expired then we continue cause one of the other datetimes might be active. |
618 | - if ( $datetime->is_expired() ) { |
|
618 | + if ($datetime->is_expired()) { |
|
619 | 619 | continue; |
620 | 620 | } |
621 | 621 | //if this dtt is upcoming then we return false. |
622 | - if ( $datetime->is_upcoming() ) { |
|
622 | + if ($datetime->is_upcoming()) { |
|
623 | 623 | return FALSE; |
624 | 624 | } |
625 | 625 | //otherwise let's check active status |
@@ -636,17 +636,17 @@ discard block |
||
636 | 636 | */ |
637 | 637 | public function is_expired() { |
638 | 638 | // check if event id is present and if this event is published |
639 | - if ( $this->is_inactive() ) { |
|
639 | + if ($this->is_inactive()) { |
|
640 | 640 | return FALSE; |
641 | 641 | } |
642 | 642 | // set initial value |
643 | 643 | $expired = FALSE; |
644 | 644 | //first let's get all datetimes and loop through them |
645 | 645 | $datetimes = $this->datetimes_in_chronological_order(); |
646 | - foreach ( $datetimes as $datetime ) { |
|
647 | - if ( $datetime instanceof EE_Datetime ) { |
|
646 | + foreach ($datetimes as $datetime) { |
|
647 | + if ($datetime instanceof EE_Datetime) { |
|
648 | 648 | //if this dtt is upcoming or active then we return false. |
649 | - if ( $datetime->is_upcoming() || $datetime->is_active() ) { |
|
649 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
650 | 650 | return FALSE; |
651 | 651 | } |
652 | 652 | //otherwise let's check active status |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | public function is_inactive() { |
665 | 665 | // check if event id is present and if this event is published |
666 | - if ( $this->_has_ID_and_is_published() ) { |
|
666 | + if ($this->_has_ID_and_is_published()) { |
|
667 | 667 | return FALSE; |
668 | 668 | } |
669 | 669 | return TRUE; |
@@ -681,26 +681,26 @@ discard block |
||
681 | 681 | */ |
682 | 682 | public function perform_sold_out_status_check() { |
683 | 683 | // get all unexpired untrashed tickets |
684 | - $tickets = $this->tickets( array( |
|
684 | + $tickets = $this->tickets(array( |
|
685 | 685 | array( |
686 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
686 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
687 | 687 | 'TKT_deleted' => false |
688 | 688 | ) |
689 | 689 | )); |
690 | 690 | // if all the tickets are just expired, then don't update the event status to sold out |
691 | - if ( empty( $tickets )) { |
|
691 | + if (empty($tickets)) { |
|
692 | 692 | return true; |
693 | 693 | } |
694 | 694 | // set initial value |
695 | 695 | $spaces_remaining = 0; |
696 | - foreach( $tickets as $ticket ) { |
|
697 | - if ( $ticket instanceof EE_Ticket ) { |
|
698 | - $spaces_remaining += $ticket->qty( 'saleable' ); |
|
696 | + foreach ($tickets as $ticket) { |
|
697 | + if ($ticket instanceof EE_Ticket) { |
|
698 | + $spaces_remaining += $ticket->qty('saleable'); |
|
699 | 699 | } |
700 | 700 | } |
701 | - if ( $spaces_remaining === 0 ) { |
|
702 | - $this->set_status( EEM_Event::sold_out ); |
|
703 | - if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) { |
|
701 | + if ($spaces_remaining === 0) { |
|
702 | + $this->set_status(EEM_Event::sold_out); |
|
703 | + if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
704 | 704 | $this->save(); |
705 | 705 | } |
706 | 706 | $sold_out = TRUE; |
@@ -728,15 +728,15 @@ discard block |
||
728 | 728 | */ |
729 | 729 | public function spaces_remaining_for_sale() { |
730 | 730 | //first get total available spaces including consideration for tickets that have already sold. |
731 | - $spaces_available = $this->total_available_spaces( true ); |
|
731 | + $spaces_available = $this->total_available_spaces(true); |
|
732 | 732 | |
733 | 733 | //if total available = 0, then exit right away because that means everything is expired. |
734 | - if ( $spaces_available === 0 ) { |
|
734 | + if ($spaces_available === 0) { |
|
735 | 735 | return 0; |
736 | 736 | } |
737 | 737 | |
738 | 738 | //subtract total approved registrations from spaces available to get how many are remaining. |
739 | - $spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
739 | + $spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
740 | 740 | $spaces_remaining = $spaces_available - $spots_taken; |
741 | 741 | |
742 | 742 | return $spaces_remaining > 0 ? $spaces_remaining : 0; |
@@ -769,29 +769,29 @@ discard block |
||
769 | 769 | * |
770 | 770 | * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
771 | 771 | */ |
772 | - public function total_available_spaces( $current_total_available = false ) { |
|
772 | + public function total_available_spaces($current_total_available = false) { |
|
773 | 773 | $spaces_available = 0; |
774 | 774 | |
775 | 775 | //first get all tickets on the event and include expired tickets |
776 | - $tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) ); |
|
776 | + $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
777 | 777 | $ticket_sums = array(); |
778 | 778 | $datetime_limits = array(); |
779 | 779 | |
780 | 780 | //loop through tickets and normalize them |
781 | - foreach ( $tickets as $ticket ) { |
|
782 | - $datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
781 | + foreach ($tickets as $ticket) { |
|
782 | + $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
783 | 783 | |
784 | - if ( empty( $datetimes ) ) { |
|
784 | + if (empty($datetimes)) { |
|
785 | 785 | continue; |
786 | 786 | } |
787 | 787 | |
788 | 788 | //first datetime should be the lowest datetime |
789 | - $least_datetime = reset( $datetimes ); |
|
789 | + $least_datetime = reset($datetimes); |
|
790 | 790 | |
791 | 791 | //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
792 | 792 | //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
793 | - if ( $current_total_available ) { |
|
794 | - if ( $ticket->is_remaining() ) { |
|
793 | + if ($current_total_available) { |
|
794 | + if ($ticket->is_remaining()) { |
|
795 | 795 | $remaining = $ticket->remaining(); |
796 | 796 | } else { |
797 | 797 | $spaces_available += $ticket->sold(); |
@@ -799,23 +799,23 @@ discard block |
||
799 | 799 | continue; |
800 | 800 | } |
801 | 801 | } else { |
802 | - $remaining = min( $ticket->qty(), $least_datetime->reg_limit() ); |
|
802 | + $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
806 | - if ( $remaining == EE_INF ) { |
|
806 | + if ($remaining == EE_INF) { |
|
807 | 807 | return EE_INF; |
808 | 808 | } |
809 | 809 | |
810 | 810 | //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
811 | 811 | //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
812 | - $ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes ); |
|
812 | + $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
813 | 813 | $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
814 | - foreach ( $datetimes as $datetime ) { |
|
815 | - if ( $datetime->reg_limit() === EE_INF ) { |
|
814 | + foreach ($datetimes as $datetime) { |
|
815 | + if ($datetime->reg_limit() === EE_INF) { |
|
816 | 816 | $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
817 | 817 | } else { |
818 | - $ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
818 | + $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
819 | 819 | } |
820 | 820 | $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
821 | 821 | } |
@@ -826,74 +826,74 @@ discard block |
||
826 | 826 | //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
827 | 827 | //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
828 | 828 | //$current_total_available ) for the datetimes on the ticket. |
829 | - usort( $ticket_sums, function( $a, $b ) { |
|
830 | - if ( $a['sum'] == $b['sum'] ) { |
|
831 | - if ( $a['datetime_sums'] == $b['datetime_sums'] ) { |
|
829 | + usort($ticket_sums, function($a, $b) { |
|
830 | + if ($a['sum'] == $b['sum']) { |
|
831 | + if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
832 | 832 | return 0; |
833 | 833 | } |
834 | 834 | |
835 | 835 | return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
836 | 836 | } |
837 | - return ( $a['sum'] < $b['sum'] ) ? -1 : 1; |
|
837 | + return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
838 | 838 | }); |
839 | 839 | |
840 | 840 | //now let's loop through the sorted tickets and simulate sellouts |
841 | - foreach ( $ticket_sums as $ticket_info ) { |
|
842 | - if ( $ticket_info['ticket'] instanceof EE_Ticket ) { |
|
841 | + foreach ($ticket_sums as $ticket_info) { |
|
842 | + if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
843 | 843 | |
844 | - $datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
844 | + $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
845 | 845 | //need to sort these $datetimes by remaining (only if $current_total_available) |
846 | 846 | //setup datetimes for simulation |
847 | 847 | $ticket_datetimes_remaining = array(); |
848 | - foreach( $datetimes as $datetime ) { |
|
848 | + foreach ($datetimes as $datetime) { |
|
849 | 849 | $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
850 | 850 | $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
851 | 851 | } |
852 | - usort( $ticket_datetimes_remaining, function( $a, $b ) { |
|
853 | - if ( $a['rem'] == $b['rem'] ) { |
|
852 | + usort($ticket_datetimes_remaining, function($a, $b) { |
|
853 | + if ($a['rem'] == $b['rem']) { |
|
854 | 854 | return 0; |
855 | 855 | } |
856 | - return ( $a['rem'] < $b['rem'] ) ? -1 : 1; |
|
856 | + return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
857 | 857 | }); |
858 | 858 | |
859 | 859 | |
860 | 860 | //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
861 | 861 | //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
862 | - $lowest_datetime = reset( $ticket_datetimes_remaining ); |
|
862 | + $lowest_datetime = reset($ticket_datetimes_remaining); |
|
863 | 863 | |
864 | 864 | //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
865 | 865 | // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
866 | 866 | // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
867 | 867 | // to the next ticket. |
868 | - if ( $current_total_available ) { |
|
869 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() ); |
|
868 | + if ($current_total_available) { |
|
869 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
870 | 870 | } else { |
871 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->qty() ); |
|
871 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
875 | 875 | //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
876 | 876 | //available. |
877 | - if ( $remaining === EE_INF ) { |
|
877 | + if ($remaining === EE_INF) { |
|
878 | 878 | $spaces_available += $ticket_info['ticket']->qty(); |
879 | 879 | continue; |
880 | 880 | } |
881 | 881 | |
882 | 882 | //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
883 | - if ( $current_total_available ) { |
|
883 | + if ($current_total_available) { |
|
884 | 884 | $spaces_available += $ticket_info['ticket']->sold(); |
885 | 885 | } |
886 | 886 | |
887 | - if ( $remaining <= 0 ) { |
|
887 | + if ($remaining <= 0) { |
|
888 | 888 | continue; |
889 | 889 | } else { |
890 | 890 | $spaces_available += $remaining; |
891 | 891 | } |
892 | 892 | |
893 | 893 | //loop through the datetimes and sell them out! |
894 | - foreach ( $ticket_datetimes_remaining as $datetime_info ) { |
|
895 | - if ( $datetime_info['datetime'] instanceof EE_Datetime ) { |
|
896 | - $datetime_limits[ $datetime_info['datetime']->ID() ] += - $remaining; |
|
894 | + foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
895 | + if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
896 | + $datetime_limits[$datetime_info['datetime']->ID()] += - $remaining; |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | } |
@@ -909,8 +909,8 @@ discard block |
||
909 | 909 | * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event |
910 | 910 | * @return boolean |
911 | 911 | */ |
912 | - public function is_sold_out( $actual = FALSE ) { |
|
913 | - if ( ! $actual ) { |
|
912 | + public function is_sold_out($actual = FALSE) { |
|
913 | + if ( ! $actual) { |
|
914 | 914 | return $this->status() == EEM_Event::sold_out; |
915 | 915 | } |
916 | 916 | else { |
@@ -948,36 +948,36 @@ discard block |
||
948 | 948 | * @param bool $reset |
949 | 949 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
950 | 950 | */ |
951 | - public function get_active_status( $reset = FALSE ) { |
|
951 | + public function get_active_status($reset = FALSE) { |
|
952 | 952 | // if the active status has already been set, then just use that value (unless we are resetting it) |
953 | - if ( ! empty( $this->_active_status ) && ! $reset ) { |
|
953 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
954 | 954 | return $this->_active_status; |
955 | 955 | } |
956 | 956 | //first check if event id is present on this object |
957 | - if ( ! $this->ID() ) { |
|
957 | + if ( ! $this->ID()) { |
|
958 | 958 | return FALSE; |
959 | 959 | } |
960 | 960 | //first get all datetimes ordered by date |
961 | 961 | $datetimes = $this->datetimes_in_chronological_order(); |
962 | 962 | //next loop through $datetimes and setup status array |
963 | 963 | $status_array = array(); |
964 | - foreach ( $datetimes as $datetime ) { |
|
965 | - if ( $datetime instanceof EE_Datetime ) { |
|
964 | + foreach ($datetimes as $datetime) { |
|
965 | + if ($datetime instanceof EE_Datetime) { |
|
966 | 966 | $status_array[] = $datetime->get_active_status(); |
967 | 967 | } |
968 | 968 | } |
969 | 969 | //now we can conditionally determine status |
970 | - if ( $this->status() == 'publish' ) { |
|
971 | - if ( in_array( EE_Datetime::active, $status_array ) ) { |
|
970 | + if ($this->status() == 'publish') { |
|
971 | + if (in_array(EE_Datetime::active, $status_array)) { |
|
972 | 972 | $this->_active_status = EE_Datetime::active; |
973 | 973 | } else { |
974 | - if ( in_array( EE_Datetime::upcoming, $status_array ) ) { |
|
974 | + if (in_array(EE_Datetime::upcoming, $status_array)) { |
|
975 | 975 | $this->_active_status = EE_Datetime::upcoming; |
976 | 976 | } else { |
977 | - if ( in_array( EE_Datetime::expired, $status_array ) ) { |
|
977 | + if (in_array(EE_Datetime::expired, $status_array)) { |
|
978 | 978 | $this->_active_status = EE_Datetime::expired; |
979 | 979 | } else { |
980 | - if ( in_array( EE_Datetime::sold_out, $status_array ) ) { |
|
980 | + if (in_array(EE_Datetime::sold_out, $status_array)) { |
|
981 | 981 | $this->_active_status = EE_Datetime::sold_out; |
982 | 982 | } else { |
983 | 983 | $this->_active_status = EE_Datetime::expired; //catchall |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | } |
987 | 987 | } |
988 | 988 | } else { |
989 | - switch ( $this->status() ) { |
|
989 | + switch ($this->status()) { |
|
990 | 990 | case EEM_Event::sold_out : |
991 | 991 | $this->_active_status = EE_Datetime::sold_out; |
992 | 992 | break; |
@@ -1012,10 +1012,10 @@ discard block |
||
1012 | 1012 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1013 | 1013 | * @return mixed void|string |
1014 | 1014 | */ |
1015 | - public function pretty_active_status( $echo = TRUE ) { |
|
1015 | + public function pretty_active_status($echo = TRUE) { |
|
1016 | 1016 | $active_status = $this->get_active_status(); |
1017 | - $status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>'; |
|
1018 | - if ( $echo ) { |
|
1017 | + $status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>'; |
|
1018 | + if ($echo) { |
|
1019 | 1019 | echo $status; |
1020 | 1020 | return ''; |
1021 | 1021 | } |
@@ -1029,12 +1029,12 @@ discard block |
||
1029 | 1029 | */ |
1030 | 1030 | public function get_number_of_tickets_sold() { |
1031 | 1031 | $tkt_sold = 0; |
1032 | - if ( !$this->ID() ) { |
|
1032 | + if ( ! $this->ID()) { |
|
1033 | 1033 | return 0; |
1034 | 1034 | } |
1035 | 1035 | $datetimes = $this->datetimes(); |
1036 | - foreach ( $datetimes as $datetime ) { |
|
1037 | - if ( $datetime instanceof EE_Datetime ) { |
|
1036 | + foreach ($datetimes as $datetime) { |
|
1037 | + if ($datetime instanceof EE_Datetime) { |
|
1038 | 1038 | $tkt_sold += $datetime->sold(); |
1039 | 1039 | } |
1040 | 1040 | } |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | * @return int |
1050 | 1050 | */ |
1051 | 1051 | public function get_count_of_all_registrations() { |
1052 | - return EEM_Event::instance()->count_related( $this, 'Registration' ); |
|
1052 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | |
@@ -1059,9 +1059,9 @@ discard block |
||
1059 | 1059 | * @return EE_Ticket |
1060 | 1060 | */ |
1061 | 1061 | public function get_ticket_with_earliest_start_time() { |
1062 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1063 | - $query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) ); |
|
1064 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1062 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1063 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1064 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | |
@@ -1071,9 +1071,9 @@ discard block |
||
1071 | 1071 | * @return EE_Ticket |
1072 | 1072 | */ |
1073 | 1073 | public function get_ticket_with_latest_end_time() { |
1074 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1075 | - $query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) ); |
|
1076 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1074 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1075 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1076 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | |
@@ -1085,11 +1085,11 @@ discard block |
||
1085 | 1085 | public function tickets_on_sale() { |
1086 | 1086 | $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
1087 | 1087 | $latest_ticket = $this->get_ticket_with_latest_end_time(); |
1088 | - if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) { |
|
1088 | + if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
1089 | 1089 | return FALSE; |
1090 | 1090 | } |
1091 | 1091 | //check on sale for these two tickets. |
1092 | - if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) { |
|
1092 | + if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
1093 | 1093 | return TRUE; |
1094 | 1094 | } |
1095 | 1095 | return FALSE; |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | * @return string |
1104 | 1104 | */ |
1105 | 1105 | public function get_permalink() { |
1106 | - if ( $this->external_url() ) { |
|
1106 | + if ($this->external_url()) { |
|
1107 | 1107 | return $this->external_url(); |
1108 | 1108 | } |
1109 | 1109 | else { |
@@ -1118,10 +1118,10 @@ discard block |
||
1118 | 1118 | * @param array $query_params like EEM_Base::get_all |
1119 | 1119 | * @return EE_Term |
1120 | 1120 | */ |
1121 | - public function first_event_category( $query_params = array() ) { |
|
1122 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1123 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1124 | - return EEM_Term::instance()->get_one( $query_params ); |
|
1121 | + public function first_event_category($query_params = array()) { |
|
1122 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1123 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1124 | + return EEM_Term::instance()->get_one($query_params); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | |
@@ -1131,10 +1131,10 @@ discard block |
||
1131 | 1131 | * @param array $query_params |
1132 | 1132 | * @return EE_Term[] |
1133 | 1133 | */ |
1134 | - public function get_all_event_categories( $query_params = array() ) { |
|
1135 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1136 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1137 | - return EEM_Term::instance()->get_all( $query_params ); |
|
1134 | + public function get_all_event_categories($query_params = array()) { |
|
1135 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1136 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1137 | + return EEM_Term::instance()->get_all($query_params); |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | /** |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | * @param array $query_params @see EEM_Base::get_all |
1143 | 1143 | * @return EE_Question_Group[] |
1144 | 1144 | */ |
1145 | - public function question_groups($query_params = array()){ |
|
1146 | - $query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' )); |
|
1145 | + public function question_groups($query_params = array()) { |
|
1146 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1147 | 1147 | return $this->get_many_related('Question_Group', $query_params); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1183,12 +1183,12 @@ discard block |
||
1183 | 1183 | */ |
1184 | 1184 | public function get_admin_edit_link() { |
1185 | 1185 | EE_Registry::instance()->load_helper('URL'); |
1186 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1186 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1187 | 1187 | 'page' => 'espresso_events', |
1188 | 1188 | 'action' => 'edit', |
1189 | 1189 | 'post' => $this->ID() |
1190 | 1190 | ), |
1191 | - admin_url( 'admin.php' ) |
|
1191 | + admin_url('admin.php') |
|
1192 | 1192 | ); |
1193 | 1193 | } |
1194 | 1194 | |
@@ -1201,11 +1201,11 @@ discard block |
||
1201 | 1201 | */ |
1202 | 1202 | public function get_admin_settings_link() { |
1203 | 1203 | EE_Registry::instance()->load_helper('URL'); |
1204 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1204 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1205 | 1205 | 'page' => 'espresso_events', |
1206 | 1206 | 'action' => 'default_event_settings' |
1207 | 1207 | ), |
1208 | - admin_url( 'admin.php' ) |
|
1208 | + admin_url('admin.php') |
|
1209 | 1209 | ); |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1221,11 +1221,11 @@ discard block |
||
1221 | 1221 | public function get_admin_overview_link() { |
1222 | 1222 | |
1223 | 1223 | EE_Registry::instance()->load_helper('URL'); |
1224 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1224 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1225 | 1225 | 'page' => 'espresso_events', |
1226 | 1226 | 'action' => 'default' |
1227 | 1227 | ), |
1228 | - admin_url( 'admin.php' ) |
|
1228 | + admin_url('admin.php') |
|
1229 | 1229 | ); |
1230 | 1230 | } |
1231 | 1231 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Registration class |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * date_format and the second value is the time format |
42 | 42 | * @return EE_Registration |
43 | 43 | */ |
44 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
45 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
46 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
44 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
45 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
46 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * the website will be used. |
55 | 55 | * @return EE_Registration |
56 | 56 | */ |
57 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
58 | - return new self( $props_n_values, TRUE, $timezone ); |
|
57 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
58 | + return new self($props_n_values, TRUE, $timezone); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @access public |
67 | 67 | * @param int $EVT_ID Event ID |
68 | 68 | */ |
69 | - public function set_event( $EVT_ID = 0 ) { |
|
70 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
69 | + public function set_event($EVT_ID = 0) { |
|
70 | + $this->set('EVT_ID', $EVT_ID); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | * @param mixed $field_value |
79 | 79 | * @param bool $use_default |
80 | 80 | */ |
81 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
82 | - switch( $field_name ) { |
|
81 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
82 | + switch ($field_name) { |
|
83 | 83 | case 'REG_code' : |
84 | - if ( ! empty( $field_value ) && $this->reg_code() == '' ) { |
|
85 | - $this->set_reg_code( $field_value, $use_default ); |
|
84 | + if ( ! empty($field_value) && $this->reg_code() == '') { |
|
85 | + $this->set_reg_code($field_value, $use_default); |
|
86 | 86 | } |
87 | 87 | break; |
88 | 88 | case 'STS_ID' : |
89 | - $this->set_status( $field_value, $use_default ); |
|
89 | + $this->set_status($field_value, $use_default); |
|
90 | 90 | break; |
91 | 91 | default : |
92 | - parent::set( $field_name, $field_value, $use_default ); |
|
92 | + parent::set($field_name, $field_value, $use_default); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -106,30 +106,30 @@ discard block |
||
106 | 106 | * @param boolean $use_default |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
109 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
110 | 110 | // get current REG_Status |
111 | 111 | $old_STS_ID = $this->status_ID(); |
112 | 112 | // if status has changed |
113 | - if ( $old_STS_ID != $new_STS_ID ) { |
|
113 | + if ($old_STS_ID != $new_STS_ID) { |
|
114 | 114 | // TO approved |
115 | - if ( $new_STS_ID == EEM_Registration::status_id_approved ) { |
|
115 | + if ($new_STS_ID == EEM_Registration::status_id_approved) { |
|
116 | 116 | // reserve a space by incrementing ticket and datetime sold values |
117 | 117 | $this->_reserve_registration_space(); |
118 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
118 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
119 | 119 | // OR FROM approved |
120 | - } else if ( $old_STS_ID == EEM_Registration::status_id_approved ) { |
|
120 | + } else if ($old_STS_ID == EEM_Registration::status_id_approved) { |
|
121 | 121 | // release a space by decrementing ticket and datetime sold values |
122 | 122 | $this->_release_registration_space(); |
123 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
123 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
124 | 124 | } |
125 | 125 | // update status |
126 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
127 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
126 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
127 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
128 | 128 | return TRUE; |
129 | - }else{ |
|
129 | + } else { |
|
130 | 130 | //even though the old value matches the new value, it's still good to |
131 | 131 | //allow the parent set method to have a say |
132 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
132 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
133 | 133 | return TRUE; |
134 | 134 | } |
135 | 135 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @access public |
142 | 142 | */ |
143 | 143 | public function status_ID() { |
144 | - return $this->get( 'STS_ID' ); |
|
144 | + return $this->get('STS_ID'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * @param boolean $include_archived whether to include archived tickets or not. |
167 | 167 | * @return EE_Ticket |
168 | 168 | */ |
169 | - public function ticket( $include_archived = TRUE ) { |
|
169 | + public function ticket($include_archived = TRUE) { |
|
170 | 170 | $query_params = array(); |
171 | - if ( $include_archived ) { |
|
172 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
171 | + if ($include_archived) { |
|
172 | + $query_params['default_where_conditions'] = 'none'; |
|
173 | 173 | } |
174 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
174 | + return $this->get_first_related('Ticket', $query_params); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return EE_Event |
182 | 182 | */ |
183 | 183 | public function event() { |
184 | - return $this->get_first_related( 'Event' ); |
|
184 | + return $this->get_first_related('Event'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function wp_user() { |
197 | 197 | $event = $this->event(); |
198 | - if ( $event instanceof EE_Event ) { |
|
198 | + if ($event instanceof EE_Event) { |
|
199 | 199 | return $event->wp_user(); |
200 | 200 | } |
201 | 201 | return 0; |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @access public |
222 | 222 | * @param int $ATT_ID Attendee ID |
223 | 223 | */ |
224 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
225 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
224 | + public function set_attendee_id($ATT_ID = 0) { |
|
225 | + $this->set('ATT_ID', $ATT_ID); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @access public |
234 | 234 | * @param int $TXN_ID Transaction ID |
235 | 235 | */ |
236 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
237 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
236 | + public function set_transaction_id($TXN_ID = 0) { |
|
237 | + $this->set('TXN_ID', $TXN_ID); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @access public |
246 | 246 | * @param string $REG_session PHP Session ID |
247 | 247 | */ |
248 | - public function set_session( $REG_session = '' ) { |
|
249 | - $this->set( 'REG_session', $REG_session ); |
|
248 | + public function set_session($REG_session = '') { |
|
249 | + $this->set('REG_session', $REG_session); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @access public |
258 | 258 | * @param string $REG_url_link Registration URL Link |
259 | 259 | */ |
260 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
261 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
260 | + public function set_reg_url_link($REG_url_link = '') { |
|
261 | + $this->set('REG_url_link', $REG_url_link); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @access public |
270 | 270 | * @param int $REG_count Primary Attendee |
271 | 271 | */ |
272 | - public function set_count( $REG_count = 1 ) { |
|
273 | - $this->set( 'REG_count', $REG_count ); |
|
272 | + public function set_count($REG_count = 1) { |
|
273 | + $this->set('REG_count', $REG_count); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @access public |
282 | 282 | * @param boolean $REG_group_size Group Registration |
283 | 283 | */ |
284 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
285 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
284 | + public function set_group_size($REG_group_size = FALSE) { |
|
285 | + $this->set('REG_group_size', $REG_group_size); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @access public |
366 | 366 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
367 | 367 | */ |
368 | - public function set_reg_date( $REG_date = FALSE ) { |
|
369 | - $this->set( 'REG_date', $REG_date ); |
|
368 | + public function set_reg_date($REG_date = FALSE) { |
|
369 | + $this->set('REG_date', $REG_date); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * @access public |
378 | 378 | * @param float $REG_final_price |
379 | 379 | */ |
380 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
381 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
380 | + public function set_final_price($REG_final_price = 0.00) { |
|
381 | + $this->set('REG_final_price', $REG_final_price); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * @access public |
390 | 390 | * @param float $REG_paid |
391 | 391 | */ |
392 | - public function set_paid( $REG_paid = 0.00 ) { |
|
393 | - $this->set( 'REG_paid', $REG_paid ); |
|
392 | + public function set_paid($REG_paid = 0.00) { |
|
393 | + $this->set('REG_paid', $REG_paid); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | * @access public |
402 | 402 | * @param boolean $REG_att_is_going Attendee Is Going |
403 | 403 | */ |
404 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
405 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
404 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
405 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return EE_Attendee |
413 | 413 | */ |
414 | 414 | public function attendee() { |
415 | - return $this->get_first_related( 'Attendee' ); |
|
415 | + return $this->get_first_related('Attendee'); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @access public |
423 | 423 | */ |
424 | 424 | public function event_ID() { |
425 | - return $this->get( 'EVT_ID' ); |
|
425 | + return $this->get('EVT_ID'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function event_name() { |
435 | 435 | $event = $this->event_obj(); |
436 | - if ( $event ) { |
|
436 | + if ($event) { |
|
437 | 437 | return $event->name(); |
438 | 438 | } else { |
439 | 439 | return NULL; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @return EE_Event |
448 | 448 | */ |
449 | 449 | public function event_obj() { |
450 | - return $this->get_first_related( 'Event' ); |
|
450 | + return $this->get_first_related('Event'); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @access public |
458 | 458 | */ |
459 | 459 | public function attendee_ID() { |
460 | - return $this->get( 'ATT_ID' ); |
|
460 | + return $this->get('ATT_ID'); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @access public |
468 | 468 | */ |
469 | 469 | public function session_ID() { |
470 | - return $this->get( 'REG_session' ); |
|
470 | + return $this->get('REG_session'); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public function receipt_url( $messenger = 'html' ) { |
|
480 | + public function receipt_url($messenger = 'html') { |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | */ |
487 | 487 | EE_Registry::instance()->load_helper('Template'); |
488 | 488 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
489 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
489 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
490 | 490 | |
491 | - if ( $has_custom ) { |
|
492 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
491 | + if ($has_custom) { |
|
492 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
493 | 493 | } |
494 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
494 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public function invoice_url( $messenger = 'html' ) { |
|
505 | + public function invoice_url($messenger = 'html') { |
|
506 | 506 | /** |
507 | 507 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
508 | 508 | * |
@@ -510,21 +510,21 @@ discard block |
||
510 | 510 | */ |
511 | 511 | EE_Registry::instance()->load_helper('Template'); |
512 | 512 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
513 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
513 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
514 | 514 | |
515 | - if ( $has_custom ) { |
|
516 | - if ( $messenger == 'html' ) { |
|
517 | - return $this->invoice_url( 'launch' ); |
|
515 | + if ($has_custom) { |
|
516 | + if ($messenger == 'html') { |
|
517 | + return $this->invoice_url('launch'); |
|
518 | 518 | } |
519 | 519 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
520 | 520 | |
521 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
522 | - if ( $messenger == 'html' ) { |
|
521 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
522 | + if ($messenger == 'html') { |
|
523 | 523 | $query_args['html'] = TRUE; |
524 | 524 | } |
525 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
525 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
526 | 526 | } |
527 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
527 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @access public |
535 | 535 | */ |
536 | 536 | public function reg_url_link() { |
537 | - return $this->get( 'REG_url_link' ); |
|
537 | + return $this->get('REG_url_link'); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public function e_invoice_url( $type = 'launch' ) { |
|
548 | - echo $this->invoice_url( $type ); |
|
547 | + public function e_invoice_url($type = 'launch') { |
|
548 | + echo $this->invoice_url($type); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @return string |
566 | 566 | */ |
567 | 567 | public function payment_overview_url() { |
568 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
568 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @return string |
577 | 577 | */ |
578 | 578 | public function edit_attendee_information_url() { |
579 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
579 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
@@ -586,8 +586,8 @@ discard block |
||
586 | 586 | * @return string |
587 | 587 | */ |
588 | 588 | public function get_admin_edit_url() { |
589 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
590 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
589 | + EE_Registry::instance()->load_helper('URL'); |
|
590 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @access public |
598 | 598 | */ |
599 | 599 | public function is_primary_registrant() { |
600 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
600 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | * This returns the primary registration object for this registration group (which may be this object). |
607 | 607 | * @return EE_Registration |
608 | 608 | */ |
609 | - public function get_primary_registration() { |
|
610 | - if ( $this->is_primary_registrant() ) |
|
609 | + public function get_primary_registration() { |
|
610 | + if ($this->is_primary_registrant()) |
|
611 | 611 | return $this; |
612 | 612 | |
613 | 613 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
614 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
614 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
615 | 615 | return $primary_registrant; |
616 | 616 | } |
617 | 617 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @access public |
623 | 623 | */ |
624 | 624 | public function count() { |
625 | - return $this->get( 'REG_count' ); |
|
625 | + return $this->get('REG_count'); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @access public |
633 | 633 | */ |
634 | 634 | public function group_size() { |
635 | - return $this->get( 'REG_group_size' ); |
|
635 | + return $this->get('REG_group_size'); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @access public |
643 | 643 | */ |
644 | 644 | public function date() { |
645 | - return $this->get( 'REG_date' ); |
|
645 | + return $this->get('REG_date'); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $time_format |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
657 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
656 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
657 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * @return float |
668 | 668 | */ |
669 | 669 | public function final_price() { |
670 | - return $this->get( 'REG_final_price' ); |
|
670 | + return $this->get('REG_final_price'); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * @return string |
679 | 679 | */ |
680 | 680 | public function pretty_final_price() { |
681 | - return $this->get_pretty( 'REG_final_price' ); |
|
681 | + return $this->get_pretty('REG_final_price'); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | * @return float |
690 | 690 | */ |
691 | 691 | public function paid() { |
692 | - return $this->get( 'REG_paid' ); |
|
692 | + return $this->get('REG_paid'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @return float |
701 | 701 | */ |
702 | 702 | public function pretty_paid() { |
703 | - return $this->get_pretty( 'REG_paid' ); |
|
703 | + return $this->get_pretty('REG_paid'); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | * @param array $requires_payment |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
715 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
716 | 716 | // these reg statuses require payment (if event is not free) |
717 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
717 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
718 | 718 | if ( |
719 | - in_array( $this->status_ID(), $requires_payment ) && |
|
719 | + in_array($this->status_ID(), $requires_payment) && |
|
720 | 720 | $this->final_price() != 0 && |
721 | 721 | $this->final_price() != $this->paid() |
722 | 722 | ) { |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | * @param bool $show_icons |
734 | 734 | * @return void |
735 | 735 | */ |
736 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
737 | - echo $this->pretty_status( $show_icons ); |
|
736 | + public function e_pretty_status($show_icons = FALSE) { |
|
737 | + echo $this->pretty_status($show_icons); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | * @param bool $show_icons |
746 | 746 | * @return string |
747 | 747 | */ |
748 | - public function pretty_status( $show_icons = FALSE ) { |
|
749 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
748 | + public function pretty_status($show_icons = FALSE) { |
|
749 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
750 | 750 | $icon = ''; |
751 | - switch ( $this->status_ID() ) { |
|
751 | + switch ($this->status_ID()) { |
|
752 | 752 | case EEM_Registration::status_id_approved: |
753 | 753 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
754 | 754 | break; |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
769 | 769 | break; |
770 | 770 | } |
771 | - return $icon . $status[ $this->status_ID() ]; |
|
771 | + return $icon.$status[$this->status_ID()]; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @access public |
779 | 779 | */ |
780 | 780 | public function att_is_going() { |
781 | - return $this->get( 'REG_att_is_going' ); |
|
781 | + return $this->get('REG_att_is_going'); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | * @param array $query_params like EEM_Base::get_all |
789 | 789 | * @return EE_Answer[] |
790 | 790 | */ |
791 | - public function answers( $query_params = NULL ) { |
|
792 | - return $this->get_many_related( 'Answer', $query_params ); |
|
791 | + public function answers($query_params = NULL) { |
|
792 | + return $this->get_many_related('Answer', $query_params); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | * (because the answer might be an array of answer values, so passing pretty_value=true |
804 | 804 | * will convert it into some kind of string) |
805 | 805 | */ |
806 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
806 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
807 | 807 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
808 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
808 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | |
@@ -818,13 +818,13 @@ discard block |
||
818 | 818 | */ |
819 | 819 | public function question_groups() { |
820 | 820 | $question_groups = array(); |
821 | - if ( $this->event() instanceof EE_Event ) { |
|
821 | + if ($this->event() instanceof EE_Event) { |
|
822 | 822 | $question_groups = $this->event()->question_groups( |
823 | 823 | array( |
824 | 824 | array( |
825 | 825 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
826 | 826 | ), |
827 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
827 | + 'order_by' => array('QSG_order' => 'ASC') |
|
828 | 828 | ) |
829 | 829 | ); |
830 | 830 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | */ |
842 | 842 | public function count_question_groups() { |
843 | 843 | $qg_count = 0; |
844 | - if ( $this->event() instanceof EE_Event ) { |
|
844 | + if ($this->event() instanceof EE_Event) { |
|
845 | 845 | $qg_count = $this->event()->count_related( |
846 | 846 | 'Question_Group', |
847 | 847 | array( |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * @return string |
863 | 863 | */ |
864 | 864 | public function reg_date() { |
865 | - return $this->get_datetime( 'REG_date' ); |
|
865 | + return $this->get_datetime('REG_date'); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * @return EE_Datetime_Ticket |
875 | 875 | */ |
876 | 876 | public function datetime_ticket() { |
877 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
877 | + return $this->get_first_related('Datetime_Ticket'); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | |
@@ -884,15 +884,15 @@ discard block |
||
884 | 884 | * @param EE_Datetime_Ticket $datetime_ticket |
885 | 885 | * @return EE_Datetime_Ticket |
886 | 886 | */ |
887 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
888 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
887 | + public function set_datetime_ticket($datetime_ticket) { |
|
888 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
889 | 889 | } |
890 | 890 | /** |
891 | 891 | * Gets deleted |
892 | 892 | * @return boolean |
893 | 893 | */ |
894 | 894 | public function deleted() { |
895 | - return $this->get( 'REG_deleted' ); |
|
895 | + return $this->get('REG_deleted'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | * @return boolean |
902 | 902 | */ |
903 | 903 | public function set_deleted($deleted) { |
904 | - $this->set( 'REG_deleted', $deleted ); |
|
904 | + $this->set('REG_deleted', $deleted); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | * @return EE_Status |
912 | 912 | */ |
913 | 913 | public function status_obj() { |
914 | - return $this->get_first_related( 'Status' ); |
|
914 | + return $this->get_first_related('Status'); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @return int |
923 | 923 | */ |
924 | 924 | public function count_checkins() { |
925 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
925 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @return int |
933 | 933 | */ |
934 | 934 | public function count_checkins_not_checkedout() { |
935 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
935 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | |
@@ -945,20 +945,20 @@ discard block |
||
945 | 945 | * |
946 | 946 | * @return bool |
947 | 947 | */ |
948 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
949 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
948 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
949 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
950 | 950 | |
951 | 951 | //first check registration status |
952 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
952 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
953 | 953 | return false; |
954 | 954 | } |
955 | 955 | //is there a datetime ticket that matches this dtt_ID? |
956 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
956 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
957 | 957 | return false; |
958 | 958 | } |
959 | 959 | |
960 | 960 | //final check is against TKT_uses |
961 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
961 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | |
@@ -971,10 +971,10 @@ discard block |
||
971 | 971 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
972 | 972 | * @return bool true means can checkin. false means cannot checkin. |
973 | 973 | */ |
974 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
975 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
974 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
975 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
976 | 976 | |
977 | - if ( ! $DTT_ID ) { |
|
977 | + if ( ! $DTT_ID) { |
|
978 | 978 | return false; |
979 | 979 | } |
980 | 980 | |
@@ -982,23 +982,23 @@ discard block |
||
982 | 982 | |
983 | 983 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
984 | 984 | // or not. |
985 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
985 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
986 | 986 | return true; |
987 | 987 | } |
988 | 988 | |
989 | 989 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
990 | 990 | //go ahead and toggle. |
991 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
991 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
992 | 992 | return true; |
993 | 993 | } |
994 | 994 | |
995 | 995 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
996 | 996 | //disallows further check-ins. |
997 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
997 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
998 | 998 | // checkins have already reached their max number of uses |
999 | 999 | // so registrant can NOT checkin |
1000 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1001 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1000 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1001 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1002 | 1002 | return false; |
1003 | 1003 | } |
1004 | 1004 | return true; |
@@ -1019,15 +1019,15 @@ discard block |
||
1019 | 1019 | * @param bool $verify If true then can_checkin() is used to verify whether the person can be checked in or not. Otherwise this forces change in checkin status. |
1020 | 1020 | * @return int|BOOL the chk_in status toggled to OR false if nothing got changed. |
1021 | 1021 | */ |
1022 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1023 | - if ( empty( $DTT_ID ) ) { |
|
1022 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1023 | + if (empty($DTT_ID)) { |
|
1024 | 1024 | $datetime = $this->get_related_primary_datetime(); |
1025 | 1025 | $DTT_ID = $datetime->ID(); |
1026 | 1026 | // verify the registration can checkin for the given DTT_ID |
1027 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1027 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1028 | 1028 | EE_Error::add_error( |
1029 | 1029 | sprintf( |
1030 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), |
|
1030 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), |
|
1031 | 1031 | because the registration does not have access', 'event_espresso'), |
1032 | 1032 | $this->ID(), |
1033 | 1033 | $DTT_ID |
@@ -1042,8 +1042,8 @@ discard block |
||
1042 | 1042 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1043 | 1043 | ); |
1044 | 1044 | //start by getting the current status so we know what status we'll be changing to. |
1045 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1046 | - $status_to = $status_paths[ $cur_status ]; |
|
1045 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1046 | + $status_to = $status_paths[$cur_status]; |
|
1047 | 1047 | // database only records true for checked IN or false for checked OUT |
1048 | 1048 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1049 | 1049 | $new_status = $status_to == EE_Registration::checkin_status_in ? true : false; |
@@ -1051,24 +1051,24 @@ discard block |
||
1051 | 1051 | // because we are keeping track of Check-ins over time. |
1052 | 1052 | // Eventually we'll probably want to show a list table |
1053 | 1053 | // for the individual Check-ins so that they can be managed. |
1054 | - $checkin = EE_Checkin::new_instance( array( |
|
1054 | + $checkin = EE_Checkin::new_instance(array( |
|
1055 | 1055 | 'REG_ID' => $this->ID(), |
1056 | 1056 | 'DTT_ID' => $DTT_ID, |
1057 | 1057 | 'CHK_in' => $new_status |
1058 | - ) ); |
|
1058 | + )); |
|
1059 | 1059 | // if the record could not be saved then return false |
1060 | - if ( $checkin->save() === 0 ) { |
|
1061 | - if ( WP_DEBUG ) { |
|
1060 | + if ($checkin->save() === 0) { |
|
1061 | + if (WP_DEBUG) { |
|
1062 | 1062 | global $wpdb; |
1063 | 1063 | $error = sprintf( |
1064 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1064 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1065 | 1065 | '<br />', |
1066 | 1066 | $wpdb->last_error |
1067 | 1067 | ); |
1068 | 1068 | } else { |
1069 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1069 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1070 | 1070 | } |
1071 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1071 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1072 | 1072 | return false; |
1073 | 1073 | } |
1074 | 1074 | return $status_to; |
@@ -1092,19 +1092,19 @@ discard block |
||
1092 | 1092 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
1093 | 1093 | * @return int Integer representing Check-in status. |
1094 | 1094 | */ |
1095 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = NULL ) { |
|
1096 | - if ( empty( $DTT_ID ) && ! $checkin instanceof EE_Checkin ) { |
|
1095 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = NULL) { |
|
1096 | + if (empty($DTT_ID) && ! $checkin instanceof EE_Checkin) { |
|
1097 | 1097 | $datetime = $this->get_related_primary_datetime(); |
1098 | - if ( ! $datetime instanceof EE_Datetime ) { |
|
1098 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1099 | 1099 | return 0; |
1100 | 1100 | } |
1101 | 1101 | $DTT_ID = $datetime->ID(); |
1102 | 1102 | //verify the registration can checkin for the given DTT_ID |
1103 | 1103 | } |
1104 | 1104 | //get checkin object (if exists) |
1105 | - $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ), 'order_by' => array( 'CHK_timestamp' => 'DESC' ) ) ); |
|
1106 | - if ( $checkin instanceof EE_Checkin ) { |
|
1107 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1105 | + $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related('Checkin', array(array('DTT_ID' => $DTT_ID), 'order_by' => array('CHK_timestamp' => 'DESC'))); |
|
1106 | + if ($checkin instanceof EE_Checkin) { |
|
1107 | + if ($checkin->get('CHK_in')) { |
|
1108 | 1108 | return EE_Registration::checkin_status_in; //checked in |
1109 | 1109 | } else { |
1110 | 1110 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1122,28 +1122,28 @@ discard block |
||
1122 | 1122 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1123 | 1123 | * @return string internationalized message |
1124 | 1124 | */ |
1125 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1125 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1126 | 1126 | //let's get the attendee first so we can include the name of the attendee |
1127 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1128 | - if ( $attendee instanceof EE_Attendee ) { |
|
1129 | - if ( $error ) { |
|
1130 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1127 | + $attendee = $this->get_first_related('Attendee'); |
|
1128 | + if ($attendee instanceof EE_Attendee) { |
|
1129 | + if ($error) { |
|
1130 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1131 | 1131 | } |
1132 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1132 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1133 | 1133 | //what is the status message going to be? |
1134 | - switch ( $cur_status ) { |
|
1134 | + switch ($cur_status) { |
|
1135 | 1135 | case EE_Registration::checkin_status_never : |
1136 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1136 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1137 | 1137 | break; |
1138 | 1138 | case EE_Registration::checkin_status_in : |
1139 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1139 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1140 | 1140 | break; |
1141 | 1141 | case EE_Registration::checkin_status_out : |
1142 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1142 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1143 | 1143 | break; |
1144 | 1144 | } |
1145 | 1145 | } |
1146 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1146 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | 1149 | |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | * @return EE_Transaction |
1154 | 1154 | */ |
1155 | 1155 | public function transaction() { |
1156 | - return $this->get_first_related( 'Transaction' ); |
|
1156 | + return $this->get_first_related('Transaction'); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | * @access public |
1165 | 1165 | */ |
1166 | 1166 | public function reg_code() { |
1167 | - return $this->get( 'REG_code' ); |
|
1167 | + return $this->get('REG_code'); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * @access public |
1175 | 1175 | */ |
1176 | 1176 | public function transaction_ID() { |
1177 | - return $this->get( 'TXN_ID' ); |
|
1177 | + return $this->get('TXN_ID'); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | * @return int |
1184 | 1184 | */ |
1185 | 1185 | public function ticket_ID() { |
1186 | - return $this->get( 'TKT_ID' ); |
|
1186 | + return $this->get('TKT_ID'); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | |
@@ -1195,17 +1195,17 @@ discard block |
||
1195 | 1195 | * @param string $REG_code Registration Code |
1196 | 1196 | * @param boolean $use_default |
1197 | 1197 | */ |
1198 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1199 | - if ( empty( $REG_code )) { |
|
1200 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1198 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1199 | + if (empty($REG_code)) { |
|
1200 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1201 | 1201 | return; |
1202 | 1202 | } |
1203 | - if ( ! $this->reg_code() ) { |
|
1204 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1203 | + if ( ! $this->reg_code()) { |
|
1204 | + parent::set('REG_code', $REG_code, $use_default); |
|
1205 | 1205 | } else { |
1206 | 1206 | EE_Error::doing_it_wrong( |
1207 | - __CLASS__ . '::' . __FUNCTION__, |
|
1208 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1207 | + __CLASS__.'::'.__FUNCTION__, |
|
1208 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1209 | 1209 | '4.6.0' |
1210 | 1210 | ); |
1211 | 1211 | } |
@@ -1225,17 +1225,17 @@ discard block |
||
1225 | 1225 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1226 | 1226 | */ |
1227 | 1227 | public function get_all_other_registrations_in_group() { |
1228 | - if ( $this->group_size() < 2 ) { |
|
1228 | + if ($this->group_size() < 2) { |
|
1229 | 1229 | return array(); |
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | $query[0] = array( |
1233 | 1233 | 'TXN_ID' => $this->transaction_ID(), |
1234 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1234 | + 'REG_ID' => array('!=', $this->ID()), |
|
1235 | 1235 | 'TKT_ID' => $this->ticket_ID() |
1236 | 1236 | ); |
1237 | 1237 | |
1238 | - $registrations = $this->get_model()->get_all( $query ); |
|
1238 | + $registrations = $this->get_model()->get_all($query); |
|
1239 | 1239 | return $registrations; |
1240 | 1240 | } |
1241 | 1241 | |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | * @access public |
1248 | 1248 | */ |
1249 | 1249 | public function price_paid() { |
1250 | - EE_Error::doing_it_wrong( 'EE_Registration::price_paid()', __( 'This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1250 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1251 | 1251 | return $this->final_price(); |
1252 | 1252 | } |
1253 | 1253 | |
@@ -1259,9 +1259,9 @@ discard block |
||
1259 | 1259 | * @access public |
1260 | 1260 | * @param float $REG_final_price |
1261 | 1261 | */ |
1262 | - public function set_price_paid( $REG_final_price = 0.00 ) { |
|
1263 | - EE_Error::doing_it_wrong( 'EE_Registration::set_price_paid()', __( 'This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1264 | - $this->set_final_price( $REG_final_price ); |
|
1262 | + public function set_price_paid($REG_final_price = 0.00) { |
|
1263 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1264 | + $this->set_final_price($REG_final_price); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | * @return string |
1273 | 1273 | */ |
1274 | 1274 | public function pretty_price_paid() { |
1275 | - EE_Error::doing_it_wrong( 'EE_Registration::pretty_price_paid()', __( 'This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1275 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1276 | 1276 | return $this->pretty_final_price(); |
1277 | 1277 | } |
1278 | 1278 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,27 +35,27 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Datetime','event_espresso'); |
|
40 | - $this->plural_item = __('Datetimes','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
40 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Datetime'=>array( |
47 | - 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')), |
|
48 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
47 | + 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
48 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
49 | 49 | 'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''), |
50 | 50 | 'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''), |
51 | - 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ), |
|
52 | - 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ), |
|
53 | - 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF), |
|
54 | - 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ), |
|
55 | - 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false), |
|
51 | + 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
54 | + 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0), |
|
55 | + 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
56 | 56 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
57 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
58 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
57 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
58 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
59 | 59 | )); |
60 | 60 | $this->_model_relations = array( |
61 | 61 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | ); |
65 | 65 | $this->_model_chain_to_wp_user = 'Event'; |
66 | 66 | //this model is generally available for reading |
67 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
71 | - parent::__construct( $timezone ); |
|
67 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
71 | + parent::__construct($timezone); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | public function create_new_blank_datetime() { |
84 | 84 | $blank_datetime = EE_Datetime::new_instance( |
85 | 85 | array( |
86 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
87 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
86 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
88 | 88 | 'DTT_order' => 1, |
89 | 89 | 'DTT_reg_limit' => EE_INF |
90 | 90 | ), |
91 | 91 | $this->_timezone |
92 | 92 | ); |
93 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
94 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
95 | - return array( $blank_datetime ); |
|
93 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
94 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
95 | + return array($blank_datetime); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param int $EVT_ID |
107 | 107 | * @return EE_Datetime[] array on success, FALSE on fail |
108 | 108 | */ |
109 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
110 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
109 | + public function get_all_event_dates($EVT_ID = 0) { |
|
110 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
111 | 111 | return $this->create_new_blank_datetime(); |
112 | 112 | } |
113 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
113 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | 114 | |
115 | - if ( empty( $results ) ) { |
|
115 | + if (empty($results)) { |
|
116 | 116 | return $this->create_new_blank_datetime(); |
117 | 117 | } |
118 | 118 | |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | * the given number |
134 | 134 | * @return EE_Datetime[] |
135 | 135 | */ |
136 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
136 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
137 | 137 | |
138 | 138 | //sanitize EVT_ID |
139 | - $EVT_ID = intval( $EVT_ID ); |
|
139 | + $EVT_ID = intval($EVT_ID); |
|
140 | 140 | |
141 | 141 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
142 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
143 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
142 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
143 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
144 | 144 | |
145 | - $query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ); |
|
145 | + $query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none'); |
|
146 | 146 | |
147 | - if( ! $include_expired){ |
|
148 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
147 | + if ( ! $include_expired) { |
|
148 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
149 | 149 | } |
150 | - if( $include_deleted){ |
|
151 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
150 | + if ($include_deleted) { |
|
151 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
152 | 152 | } |
153 | 153 | |
154 | - $result = $this->get_all( $query_params ); |
|
155 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
154 | + $result = $this->get_all($query_params); |
|
155 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
156 | 156 | return $result; |
157 | 157 | } |
158 | 158 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param int $limit |
168 | 168 | * @return EE_Datetime[] |
169 | 169 | */ |
170 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
171 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
170 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
171 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
172 | 172 | 'limit'=>$limit, |
173 | 173 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
174 | 174 | 'default_where_conditions' => 'none')); |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param boolean $include_deleted |
184 | 184 | * @return EE_Datetime |
185 | 185 | */ |
186 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
187 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | - if($results){ |
|
186 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
187 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | + if ($results) { |
|
189 | 189 | return array_shift($results); |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return NULL; |
192 | 192 | } |
193 | 193 | } |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | * @param bool $try_to_exclude_deleted |
202 | 202 | * @return \EE_Datetime |
203 | 203 | */ |
204 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
205 | - if($try_to_exclude_expired){ |
|
206 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
207 | - if($non_expired){ |
|
204 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
205 | + if ($try_to_exclude_expired) { |
|
206 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
207 | + if ($non_expired) { |
|
208 | 208 | return $non_expired; |
209 | 209 | } |
210 | 210 | } |
211 | - if($try_to_exclude_deleted){ |
|
211 | + if ($try_to_exclude_deleted) { |
|
212 | 212 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
213 | - if($expired_even){ |
|
213 | + if ($expired_even) { |
|
214 | 214 | return $expired_even; |
215 | 215 | } |
216 | 216 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * @param int $limit |
230 | 230 | * @return EE_Datetime[] |
231 | 231 | */ |
232 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
232 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
233 | 233 | //sanitize EVT_ID |
234 | - $EVT_ID = intval( $EVT_ID ); |
|
234 | + $EVT_ID = intval($EVT_ID); |
|
235 | 235 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
236 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
237 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | - if( ! $include_expired){ |
|
239 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
236 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
237 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | + if ( ! $include_expired) { |
|
239 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
240 | 240 | } |
241 | - if( $include_deleted){ |
|
242 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
241 | + if ($include_deleted) { |
|
242 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
243 | 243 | } |
244 | - if($limit){ |
|
244 | + if ($limit) { |
|
245 | 245 | $query_params['limit'] = $limit; |
246 | 246 | } |
247 | - $result = $this->get_all( $query_params ); |
|
248 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
247 | + $result = $this->get_all($query_params); |
|
248 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
249 | 249 | return $result; |
250 | 250 | } |
251 | 251 | |
@@ -258,23 +258,23 @@ discard block |
||
258 | 258 | * @param int $limit |
259 | 259 | * @return EE_Datetime[] |
260 | 260 | */ |
261 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
261 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
262 | 262 | //sanitize TKT_ID |
263 | - $TKT_ID = intval( $TKT_ID ); |
|
263 | + $TKT_ID = intval($TKT_ID); |
|
264 | 264 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
265 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
266 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | - if( ! $include_expired){ |
|
268 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
265 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
266 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | + if ( ! $include_expired) { |
|
268 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
269 | 269 | } |
270 | - if( $include_deleted){ |
|
271 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
270 | + if ($include_deleted) { |
|
271 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
272 | 272 | } |
273 | - if($limit){ |
|
273 | + if ($limit) { |
|
274 | 274 | $query_params['limit'] = $limit; |
275 | 275 | } |
276 | - $result = $this->get_all( $query_params ); |
|
277 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
276 | + $result = $this->get_all($query_params); |
|
277 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
278 | 278 | return $result; |
279 | 279 | } |
280 | 280 | |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | * that number |
291 | 291 | * @return EE_Datetime[] |
292 | 292 | */ |
293 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
293 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
294 | 294 | //sanitize id. |
295 | - $TKT_ID = intval( $TKT_ID ); |
|
295 | + $TKT_ID = intval($TKT_ID); |
|
296 | 296 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
297 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
298 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
299 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
300 | - if( ! $include_expired){ |
|
301 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
297 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
298 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
299 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
300 | + if ( ! $include_expired) { |
|
301 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
302 | 302 | } |
303 | - if( $include_deleted){ |
|
304 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
303 | + if ($include_deleted) { |
|
304 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
305 | 305 | } |
306 | - if($limit){ |
|
306 | + if ($limit) { |
|
307 | 307 | $query_params['limit'] = $limit; |
308 | 308 | } |
309 | - $result = $this->get_all( $query_params ); |
|
310 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
309 | + $result = $this->get_all($query_params); |
|
310 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
311 | 311 | return $result; |
312 | 312 | } |
313 | 313 | |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | * @param int $EVT_ID |
319 | 319 | * @return EE_Datetime |
320 | 320 | */ |
321 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
321 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
322 | 322 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
323 | - if($results){ |
|
323 | + if ($results) { |
|
324 | 324 | return array_shift($results); |
325 | - }else{ |
|
325 | + } else { |
|
326 | 326 | return null; |
327 | 327 | } |
328 | 328 | } |
@@ -341,71 +341,71 @@ discard block |
||
341 | 341 | * - inactive = Events that are either not published. |
342 | 342 | * @return wpdb results array |
343 | 343 | */ |
344 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
344 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
345 | 345 | |
346 | - switch ( $evt_active_status ) { |
|
346 | + switch ($evt_active_status) { |
|
347 | 347 | case 'upcoming' : |
348 | 348 | $where_params['Event.status'] = 'publish'; |
349 | 349 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
350 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
350 | + if (isset($where_params['DTT_EVT_start'])) { |
|
351 | 351 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
352 | 352 | } |
353 | - $where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query( 'DTT_EVT_start' ) ); |
|
353 | + $where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query('DTT_EVT_start')); |
|
354 | 354 | break; |
355 | 355 | |
356 | 356 | case 'expired' : |
357 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
357 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
358 | 358 | //get events to exclude |
359 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $this->current_time_for_query( 'DTT_EVT_end' ) ) ) ); |
|
359 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $this->current_time_for_query('DTT_EVT_end')))); |
|
360 | 360 | //first get all events that have datetimes where its not expired. |
361 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
362 | - $event_ids = array_keys( $event_ids ); |
|
361 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
362 | + $event_ids = array_keys($event_ids); |
|
363 | 363 | |
364 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
364 | + if (isset($where_params['DTT_EVT_end'])) { |
|
365 | 365 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
366 | 366 | } |
367 | - $where_params['DTT_EVT_end'] = array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); |
|
368 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
367 | + $where_params['DTT_EVT_end'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); |
|
368 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
369 | 369 | break; |
370 | 370 | |
371 | 371 | case 'active' : |
372 | 372 | $where_params['Event.status'] = 'publish'; |
373 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
373 | + if (isset($where_params['DTT_EVT_start'])) { |
|
374 | 374 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
375 | 375 | } |
376 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
376 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
377 | 377 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
378 | 378 | } |
379 | - $where_params['DTT_EVT_start'] = array('<', $this->current_time_for_query( 'DTT_EVT_start' ) ); |
|
380 | - $where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query( 'DTT_EVT_end' ) ); |
|
379 | + $where_params['DTT_EVT_start'] = array('<', $this->current_time_for_query('DTT_EVT_start')); |
|
380 | + $where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query('DTT_EVT_end')); |
|
381 | 381 | break; |
382 | 382 | |
383 | 383 | case 'inactive' : |
384 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
385 | - if ( isset( $where_params['OR'] ) ) { |
|
384 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
385 | + if (isset($where_params['OR'])) { |
|
386 | 386 | $where_params['AND']['OR'] = $where_params['OR']; |
387 | 387 | } |
388 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
388 | + if (isset($where_params['DTT_EVT_end'])) { |
|
389 | 389 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
390 | - unset( $where_params['DTT_EVT_end'] ); |
|
390 | + unset($where_params['DTT_EVT_end']); |
|
391 | 391 | } |
392 | 392 | |
393 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
393 | + if (isset($where_params['DTT_EVT_start'])) { |
|
394 | 394 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
395 | - unset( $where_params['DTT_EVT_start'] ); |
|
395 | + unset($where_params['DTT_EVT_start']); |
|
396 | 396 | } |
397 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
397 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
398 | 398 | break; |
399 | 399 | } |
400 | 400 | |
401 | 401 | $query_params[0] = $where_params; |
402 | 402 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
403 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
403 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
404 | 404 | $columns_to_select = array( |
405 | 405 | 'dtt_year' => array('YEAR(DTT_EVT_start)', '%s'), |
406 | 406 | 'dtt_month' => array('MONTHNAME(DTT_EVT_start)', '%s') |
407 | 407 | ); |
408 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
408 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * for the tickets for each datetime) |
414 | 414 | * @param EE_Datetime[] $datetimes |
415 | 415 | */ |
416 | - public function update_sold($datetimes){ |
|
417 | - foreach($datetimes as $datetime){ |
|
416 | + public function update_sold($datetimes) { |
|
417 | + foreach ($datetimes as $datetime) { |
|
418 | 418 | $datetime->update_sold(); |
419 | 419 | } |
420 | 420 | } |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | * @param array $query_params |
430 | 430 | * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO tickets attached to datetime then FALSE is returned. |
431 | 431 | */ |
432 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
433 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
434 | - if ( $datetime instanceof EE_Datetime ) { |
|
435 | - return $datetime->tickets_remaining( $query_params ); |
|
432 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
433 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
434 | + if ($datetime instanceof EE_Datetime) { |
|
435 | + return $datetime->tickets_remaining($query_params); |
|
436 | 436 | } |
437 | 437 | return 0; |
438 | 438 | } |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Venue extends EEM_CPT_Base { |
27 | 27 | |
28 | 28 | // private instance of the Attendee object |
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | - protected function __construct( $timezone = NULL ) { |
|
32 | - $this->singular_item = __('Venue','event_espresso'); |
|
33 | - $this->plural_item = __('Venues','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Venue', 'event_espresso'); |
|
33 | + $this->plural_item = __('Venues', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Venue_CPT'=> new EE_Primary_Table('posts', 'ID'), |
36 | 36 | 'Venue_Meta'=>new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID') |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | 'Venue_CPT'=>array( |
40 | 40 | 'VNU_ID'=>new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
41 | 41 | 'VNU_name'=>new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), |
42 | - 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false,''), |
|
43 | - 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false,''), |
|
44 | - 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE,time()), |
|
45 | - 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true,''), |
|
46 | - 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE,time()), |
|
47 | - 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false ), |
|
48 | - 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false,0), |
|
42 | + 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), |
|
43 | + 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
44 | + 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, time()), |
|
45 | + 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), |
|
46 | + 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, time()), |
|
47 | + 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false), |
|
48 | + 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), |
|
49 | 49 | 'VNU_order'=>new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
50 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'),// EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
50 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'), // EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
51 | 51 | ), |
52 | 52 | 'Venue_Meta'=>array( |
53 | 53 | 'VNUM_ID'=>new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), |
54 | 54 | 'VNU_ID_fk'=>new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), |
55 | 55 | 'VNU_address'=>new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), |
56 | - 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true,''), |
|
56 | + 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), |
|
57 | 57 | 'VNU_city'=>new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), |
58 | 58 | 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), |
59 | 59 | 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), |
60 | 60 | 'VNU_zip'=>new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), |
61 | 61 | 'VNU_phone'=>new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), |
62 | - 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true,EE_INF), |
|
62 | + 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, EE_INF), |
|
63 | 63 | 'VNU_url'=>new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), |
64 | 64 | 'VNU_virtual_phone'=>new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), |
65 | - 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true ), |
|
66 | - 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true ), |
|
67 | - 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false ) |
|
65 | + 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), |
|
66 | + 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), |
|
67 | + 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false) |
|
68 | 68 | |
69 | 69 | )); |
70 | 70 | $this->_model_relations = array( |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | ); |
77 | 77 | $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_venues', 'VNUM_ID'); |
78 | 78 | //this model is generally available for reading |
79 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
80 | - parent::__construct( $timezone ); |
|
79 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
80 | + parent::__construct($timezone); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |