@@ -10,20 +10,20 @@ discard block |
||
| 10 | 10 | * @since 4.6 |
| 11 | 11 | * |
| 12 | 12 | */ |
| 13 | -class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 13 | +class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param null $validation_error_message |
| 17 | 17 | */ |
| 18 | - public function __construct( $validation_error_message = NULL ) { |
|
| 19 | - if ( ! $validation_error_message ) { |
|
| 18 | + public function __construct($validation_error_message = NULL) { |
|
| 19 | + if ( ! $validation_error_message) { |
|
| 20 | 20 | $validation_error_message = sprintf( |
| 21 | - __( 'Only the following HTML tags are allowed:%1$s%2$s', "event_espresso" ), |
|
| 21 | + __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
|
| 22 | 22 | '<br />', |
| 23 | 23 | $this->get_list_of_allowed_tags() |
| 24 | 24 | ); |
| 25 | 25 | } |
| 26 | - parent::__construct( $validation_error_message ); |
|
| 26 | + parent::__construct($validation_error_message); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function get_list_of_allowed_tags() { |
| 39 | 39 | global $allowedposttags; |
| 40 | - ksort( $allowedposttags ); |
|
| 41 | - return implode( ', ', array_keys( $allowedposttags ) ); |
|
| 40 | + ksort($allowedposttags); |
|
| 41 | + return implode(', ', array_keys($allowedposttags)); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function validate($normalized_value) { |
| 51 | 51 | global $allowedposttags; |
| 52 | - parent::validate( $normalized_value ); |
|
| 53 | - $normalized_value_sans_tags = wp_kses( "$normalized_value", $allowedposttags ); |
|
| 54 | - if ( strlen( $normalized_value ) > strlen( $normalized_value_sans_tags ) ) { |
|
| 55 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'complex_html_tags' ); |
|
| 52 | + parent::validate($normalized_value); |
|
| 53 | + $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedposttags); |
|
| 54 | + if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
| 55 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @since 4.6 |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base{ |
|
| 11 | +class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Its important this media only get enqueued AFTER init, but before the footer... where the |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | * this input displayed. |
| 21 | 21 | * @deprecated. enqueue_js should be called automatically now |
| 22 | 22 | */ |
| 23 | - static function enqueue_scripts(){ |
|
| 24 | - EE_Error::doing_it_wrong( __FUNCTION__, __( 'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form'), '4.9.8.rc.015' ); |
|
| 23 | + static function enqueue_scripts() { |
|
| 24 | + EE_Error::doing_it_wrong(__FUNCTION__, __('EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form'), '4.9.8.rc.015'); |
|
| 25 | 25 | wp_enqueue_media(); |
| 26 | 26 | wp_enqueue_script('media-upload'); |
| 27 | - wp_enqueue_script('ee-payments',EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
| 27 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function enqueue_js() { |
| 34 | 34 | wp_enqueue_media(); |
| 35 | 35 | wp_enqueue_script('media-upload'); |
| 36 | - wp_enqueue_script('ee-payments',EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
| 36 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
| 37 | 37 | parent::enqueue_js(); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -44,19 +44,19 @@ discard block |
||
| 44 | 44 | * @return string of html to display the field |
| 45 | 45 | */ |
| 46 | 46 | |
| 47 | - function display(){ |
|
| 47 | + function display() { |
|
| 48 | 48 | // the actual input |
| 49 | 49 | $input = '<input type="text" size="34" '; |
| 50 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
| 51 | - $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' : 'class="large-text ee_media_url" '; |
|
| 52 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
| 53 | - $input .= $this->_input->other_html_attributes() . '>'; |
|
| 50 | + $input .= 'name="'.$this->_input->html_name().'" '; |
|
| 51 | + $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url '.$this->_input->html_class().'" ' : 'class="large-text ee_media_url" '; |
|
| 52 | + $input .= 'value="'.$this->_input->raw_value_in_form().'" '; |
|
| 53 | + $input .= $this->_input->other_html_attributes().'>'; |
|
| 54 | 54 | // image uploader |
| 55 | - $uploader = EEH_HTML::link( '#', '<img src="' . admin_url( 'images/media-button-image.gif' ) . '" >', __( 'click to add an image', 'event_espresso' ), '', 'ee_media_upload' ); |
|
| 55 | + $uploader = EEH_HTML::link('#', '<img src="'.admin_url('images/media-button-image.gif').'" >', __('click to add an image', 'event_espresso'), '', 'ee_media_upload'); |
|
| 56 | 56 | //only attempt to show the image if it at least exists |
| 57 | - $image = $this->src_exists( $this->_input->raw_value() ) ? EEH_HTML::br(2) . EEH_HTML::img( $this->_input->raw_value(), __( 'logo', 'event_espresso' ), '', 'ee_media_image' ) : ''; |
|
| 57 | + $image = $this->src_exists($this->_input->raw_value()) ? EEH_HTML::br(2).EEH_HTML::img($this->_input->raw_value(), __('logo', 'event_espresso'), '', 'ee_media_image') : ''; |
|
| 58 | 58 | // html string |
| 59 | - return EEH_HTML::div( $input . EEH_HTML::nbsp() . $uploader . $image, '', 'ee_media_uploader_area' ); |
|
| 59 | + return EEH_HTML::div($input.EEH_HTML::nbsp().$uploader.$image, '', 'ee_media_uploader_area'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | * @param string $src |
| 68 | 68 | * @return boolean |
| 69 | 69 | */ |
| 70 | - protected function src_exists( $src ){ |
|
| 71 | - $results = wp_remote_head( $src ); |
|
| 72 | - if( is_array( $results) && ! $results instanceof WP_Error){ |
|
| 73 | - return strpos($results['headers']['content-type'], "image" ) !== FALSE; |
|
| 74 | - }else{ |
|
| 70 | + protected function src_exists($src) { |
|
| 71 | + $results = wp_remote_head($src); |
|
| 72 | + if (is_array($results) && ! $results instanceof WP_Error) { |
|
| 73 | + return strpos($results['headers']['content-type'], "image") !== FALSE; |
|
| 74 | + } else { |
|
| 75 | 75 | return FALSE; |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -881,7 +881,7 @@ |
||
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | 883 | * @deprecated 4.9.0 |
| 884 | - * @return array |
|
| 884 | + * @return EE_messenger[] |
|
| 885 | 885 | */ |
| 886 | 886 | public function get_installed_messengers() { |
| 887 | 887 | // EE_messages has been deprecated |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | /** |
| 6 | 6 | * ************************************************************************ |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param \EE_Checkout $checkout |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
| 34 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
| 35 | 35 | // list of old filters |
| 36 | 36 | $deprecated_filters = array( |
| 37 | 37 | 'update_registration_details' => true, |
@@ -41,16 +41,16 @@ discard block |
||
| 41 | 41 | 'proceed_to' => true, |
| 42 | 42 | ); |
| 43 | 43 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
| 44 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
| 44 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
| 45 | 45 | // was this filter called ? |
| 46 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
| 46 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
| 47 | 47 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
| 48 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
| 48 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
| 49 | 49 | EE_Error::doing_it_wrong( |
| 50 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 50 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 51 | 51 | sprintf( |
| 52 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
| 53 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 52 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
| 53 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 54 | 54 | '<br />', |
| 55 | 55 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
| 56 | 56 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -59,24 +59,24 @@ discard block |
||
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | } else { |
| 62 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
| 62 | + unset($deprecated_filters[$deprecated_filter]); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | - if ( ! empty( $deprecated_filters )) { |
|
| 65 | + if ( ! empty($deprecated_filters)) { |
|
| 66 | 66 | |
| 67 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
| 68 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
| 69 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
| 70 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
| 71 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
| 72 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
| 67 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
| 68 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
| 69 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
| 70 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
| 71 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
| 72 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
| 73 | 73 | } |
| 74 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
| 75 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
| 76 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
| 74 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 75 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
| 76 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
| 77 | 77 | } |
| 78 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
| 79 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
| 78 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
| 79 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return $submit_button_text; |
| 85 | 85 | |
| 86 | 86 | } |
| 87 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
| 87 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | * @param \EE_Checkout $checkout |
| 96 | 96 | * @param boolean $status_updates |
| 97 | 97 | */ |
| 98 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
| 98 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
| 99 | 99 | $action_ref = NULL; |
| 100 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 101 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 102 | - if ( $action_ref ) { |
|
| 100 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 101 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 102 | + if ($action_ref) { |
|
| 103 | 103 | |
| 104 | 104 | EE_Error::doing_it_wrong( |
| 105 | 105 | $action_ref, |
| 106 | 106 | sprintf( |
| 107 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
| 107 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
| 108 | 108 | '<br />', |
| 109 | 109 | '/core/business/EE_Transaction_Processor.class.php', |
| 110 | 110 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -114,39 +114,39 @@ discard block |
||
| 114 | 114 | ), |
| 115 | 115 | '4.6.0' |
| 116 | 116 | ); |
| 117 | - switch ( $action_ref ) { |
|
| 117 | + switch ($action_ref) { |
|
| 118 | 118 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
| 119 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
| 119 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
| 120 | 120 | break; |
| 121 | 121 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
| 122 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
| 122 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
| 127 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
| 128 | 128 | /** |
| 129 | 129 | * ee_deprecated_finalize_registration |
| 130 | 130 | * |
| 131 | 131 | * @param EE_Registration $registration |
| 132 | 132 | */ |
| 133 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
| 134 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 135 | - if ( $action_ref ) { |
|
| 133 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
| 134 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 135 | + if ($action_ref) { |
|
| 136 | 136 | EE_Error::doing_it_wrong( |
| 137 | 137 | $action_ref, |
| 138 | 138 | sprintf( |
| 139 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
| 139 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
| 140 | 140 | '<br />', |
| 141 | 141 | '/core/business/EE_Registration_Processor.class.php', |
| 142 | 142 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
| 143 | 143 | ), |
| 144 | 144 | '4.6.0' |
| 145 | 145 | ); |
| 146 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
| 146 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
| 149 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
| 155 | 155 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
| 156 | 156 | */ |
| 157 | -function ee_deprecated_hooks(){ |
|
| 157 | +function ee_deprecated_hooks() { |
|
| 158 | 158 | /** |
| 159 | 159 | * @var $hooks array where keys are hook names, and their values are array{ |
| 160 | 160 | * @type string $version when deprecated |
@@ -165,25 +165,25 @@ discard block |
||
| 165 | 165 | $hooks = array( |
| 166 | 166 | 'AHEE__EE_System___do_setup_validations' => array( |
| 167 | 167 | 'version' => '4.6.0', |
| 168 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
| 168 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
| 169 | 169 | 'still_works' => FALSE |
| 170 | 170 | ) |
| 171 | 171 | ); |
| 172 | - foreach( $hooks as $name => $deprecation_info ){ |
|
| 173 | - if( has_action( $name ) ){ |
|
| 172 | + foreach ($hooks as $name => $deprecation_info) { |
|
| 173 | + if (has_action($name)) { |
|
| 174 | 174 | EE_Error::doing_it_wrong( |
| 175 | 175 | $name, |
| 176 | 176 | sprintf( |
| 177 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
| 178 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
| 179 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
| 177 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
| 178 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
| 179 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
| 180 | 180 | ), |
| 181 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
| 181 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
| 182 | 182 | ); |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
| 186 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
@@ -194,9 +194,9 @@ discard block |
||
| 194 | 194 | * @return boolean |
| 195 | 195 | */ |
| 196 | 196 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
| 197 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
| 198 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
| 199 | - if( $in_use ) { |
|
| 197 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
| 198 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
| 199 | + if ($in_use) { |
|
| 200 | 200 | $msg = __( |
| 201 | 201 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
| 202 | 202 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -205,18 +205,18 @@ discard block |
||
| 205 | 205 | 'event_espresso' ) |
| 206 | 206 | ; |
| 207 | 207 | EE_Error::doing_it_wrong( |
| 208 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 208 | + __CLASS__.'::'.__FUNCTION__, |
|
| 209 | 209 | $msg, |
| 210 | 210 | '4.8.32.rc.000' |
| 211 | 211 | ); |
| 212 | 212 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
| 213 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 214 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 213 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 214 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | return $in_use; |
| 218 | 218 | } |
| 219 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
| 219 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -225,34 +225,34 @@ discard block |
||
| 225 | 225 | * @param EE_Admin_Page $admin_page |
| 226 | 226 | * @return void |
| 227 | 227 | */ |
| 228 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
| 228 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
| 229 | 229 | //check if the old hooks are in use. If not, do the default |
| 230 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 231 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 230 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 231 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 232 | 232 | return; |
| 233 | 233 | } |
| 234 | 234 | $req_data = $admin_page->get_request_data(); |
| 235 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
| 236 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
| 237 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
| 238 | - if ( ! $REG_ID || ! $qstns ) { |
|
| 239 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 235 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
| 236 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
| 237 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
| 238 | + if ( ! $REG_ID || ! $qstns) { |
|
| 239 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 240 | 240 | } |
| 241 | 241 | $success = TRUE; |
| 242 | 242 | |
| 243 | 243 | // allow others to get in on this awesome fun :D |
| 244 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
| 244 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
| 245 | 245 | // loop thru questions... FINALLY!!! |
| 246 | 246 | |
| 247 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
| 247 | + foreach ($qstns as $QST_ID => $qstn) { |
|
| 248 | 248 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
| 249 | - if ( !is_array($qstn) ) { |
|
| 250 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
| 249 | + if ( ! is_array($qstn)) { |
|
| 250 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
| 251 | 251 | continue; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | |
| 255 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
| 255 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
| 256 | 256 | //get answer |
| 257 | 257 | $query_params = array( |
| 258 | 258 | 0 => array( |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | ); |
| 264 | 264 | $answer = EEM_Answer::instance()->get_one($query_params); |
| 265 | 265 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
| 266 | - if ( ! $answer instanceof EE_Answer ) { |
|
| 266 | + if ( ! $answer instanceof EE_Answer) { |
|
| 267 | 267 | $set_values = array( |
| 268 | 268 | 'QST_ID' => $QST_ID, |
| 269 | 269 | 'REG_ID' => $REG_ID, |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | $what = __('Registration Form', 'event_espresso'); |
| 281 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
| 282 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
| 281 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
| 282 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 283 | 283 | exit; |
| 284 | 284 | } |
| 285 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
| 285 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
| 286 | 286 | /** |
| 287 | 287 | * Render the registration admin page's custom questions area in the old fashion |
| 288 | 288 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -295,31 +295,31 @@ discard block |
||
| 295 | 295 | * @return bool |
| 296 | 296 | * @throws \EE_Error |
| 297 | 297 | */ |
| 298 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
| 298 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
| 299 | 299 | //check if the old hooks are in use. If not, do the default |
| 300 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 301 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 300 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 301 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 302 | 302 | return $do_default_action; |
| 303 | 303 | } |
| 304 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
| 305 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
| 306 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
| 307 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
| 304 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
| 305 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
| 306 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
| 307 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
| 308 | 308 | |
| 309 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
| 309 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
| 310 | 310 | |
| 311 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
| 311 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
| 312 | 312 | $template_args = array( |
| 313 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
| 313 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
| 314 | 314 | 'reg_questions_form_action' => 'edit_registration', |
| 315 | 315 | 'REG_ID' => $registration->ID() |
| 316 | 316 | ); |
| 317 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 318 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 317 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 318 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 319 | 319 | //indicate that we should not do the default admin page code |
| 320 | 320 | return false; |
| 321 | 321 | } |
| 322 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
| 322 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
| 323 | 323 | |
| 324 | 324 | |
| 325 | 325 | |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | '4.9.0' |
| 361 | 361 | ); |
| 362 | 362 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
| 363 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 364 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
| 365 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
| 363 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 364 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
| 365 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
| 366 | 366 | return EE_Registry::instance()->load_lib( |
| 367 | 367 | 'Messages_Template_Defaults', |
| 368 | 368 | array( |
@@ -427,15 +427,15 @@ discard block |
||
| 427 | 427 | /** |
| 428 | 428 | * @param string $method |
| 429 | 429 | */ |
| 430 | - public function _class_is_deprecated( $method ) { |
|
| 430 | + public function _class_is_deprecated($method) { |
|
| 431 | 431 | EE_Error::doing_it_wrong( |
| 432 | - 'EE_messages::' . $method, |
|
| 433 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
| 432 | + 'EE_messages::'.$method, |
|
| 433 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
| 434 | 434 | '4.9.0', |
| 435 | 435 | '4.10.0.p' |
| 436 | 436 | ); |
| 437 | 437 | // Please use EE_Message_Resource_Manager instead |
| 438 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 438 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
@@ -445,10 +445,10 @@ discard block |
||
| 445 | 445 | * @param string $messenger_name |
| 446 | 446 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 447 | 447 | */ |
| 448 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
| 448 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 449 | 449 | // EE_messages has been deprecated |
| 450 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 451 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
| 450 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 451 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
@@ -460,10 +460,10 @@ discard block |
||
| 460 | 460 | * @return bool true if it got activated (or was active) and false if not. |
| 461 | 461 | * @throws \EE_Error |
| 462 | 462 | */ |
| 463 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
| 463 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
| 464 | 464 | // EE_messages has been deprecated |
| 465 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 466 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
| 465 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 466 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | |
@@ -476,10 +476,10 @@ discard block |
||
| 476 | 476 | * they are already setup.) |
| 477 | 477 | * @return boolean an array of generated templates or false if nothing generated/activated. |
| 478 | 478 | */ |
| 479 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
| 479 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
| 480 | 480 | // EE_messages has been deprecated |
| 481 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 482 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
| 481 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 482 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | |
@@ -491,10 +491,10 @@ discard block |
||
| 491 | 491 | * |
| 492 | 492 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 493 | 493 | */ |
| 494 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 494 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 495 | 495 | // EE_messages has been deprecated |
| 496 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 497 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
| 496 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 497 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | |
@@ -504,10 +504,10 @@ discard block |
||
| 504 | 504 | * @param string $messenger |
| 505 | 505 | * @return EE_messenger | null |
| 506 | 506 | */ |
| 507 | - public function get_messenger_if_active( $messenger ) { |
|
| 507 | + public function get_messenger_if_active($messenger) { |
|
| 508 | 508 | // EE_messages has been deprecated |
| 509 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 510 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
| 509 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 510 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | |
@@ -528,9 +528,9 @@ discard block |
||
| 528 | 528 | * 'message_type' => null |
| 529 | 529 | * ) |
| 530 | 530 | */ |
| 531 | - public function validate_for_use( EE_Message $message ) { |
|
| 531 | + public function validate_for_use(EE_Message $message) { |
|
| 532 | 532 | // EE_messages has been deprecated |
| 533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 534 | 534 | return array( |
| 535 | 535 | 'messenger' => $message->messenger_object(), |
| 536 | 536 | 'message_type' => $message->message_type_object(), |
@@ -558,41 +558,41 @@ discard block |
||
| 558 | 558 | $send = true |
| 559 | 559 | ) { |
| 560 | 560 | // EE_messages has been deprecated |
| 561 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 561 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 562 | 562 | /** @type EE_Messages_Processor $processor */ |
| 563 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 563 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 564 | 564 | $error = false; |
| 565 | 565 | //try to intelligently determine what method we'll call based on the incoming data. |
| 566 | 566 | //if generating and sending are different then generate and send immediately. |
| 567 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
| 567 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
| 568 | 568 | //in the legacy system, when generating and sending were different, that means all the |
| 569 | 569 | //vars are already in the request object. So let's just use that. |
| 570 | 570 | try { |
| 571 | 571 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
| 572 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
| 573 | - $processor->generate_and_send_now( $mtg ); |
|
| 574 | - } catch ( EE_Error $e ) { |
|
| 572 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 573 | + $processor->generate_and_send_now($mtg); |
|
| 574 | + } catch (EE_Error $e) { |
|
| 575 | 575 | $error_msg = __( |
| 576 | 576 | 'Please note that a system message failed to send due to a technical issue.', |
| 577 | 577 | 'event_espresso' |
| 578 | 578 | ); |
| 579 | 579 | // add specific message for developers if WP_DEBUG in on |
| 580 | - $error_msg .= '||' . $e->getMessage(); |
|
| 581 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 580 | + $error_msg .= '||'.$e->getMessage(); |
|
| 581 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 582 | 582 | $error = true; |
| 583 | 583 | } |
| 584 | 584 | } else { |
| 585 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
| 585 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
| 586 | 586 | //let's find out if there were any errors and how many successfully were queued. |
| 587 | 587 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
| 588 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
| 588 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
| 589 | 589 | ); |
| 590 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 591 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
| 590 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 591 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
| 592 | 592 | $count_errors = $count_errors + $count_retry; |
| 593 | - if ( $count_errors > 0 ) { |
|
| 593 | + if ($count_errors > 0) { |
|
| 594 | 594 | $error = true; |
| 595 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
| 595 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
| 596 | 596 | $message = sprintf( |
| 597 | 597 | __( |
| 598 | 598 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | $count_errors, |
| 602 | 602 | $count_queued |
| 603 | 603 | ); |
| 604 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
| 604 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
| 605 | 605 | $message = sprintf( |
| 606 | 606 | __( |
| 607 | 607 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | $count_errors, |
| 611 | 611 | $count_queued |
| 612 | 612 | ); |
| 613 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
| 613 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
| 614 | 614 | $message = sprintf( |
| 615 | 615 | __( |
| 616 | 616 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -628,9 +628,9 @@ discard block |
||
| 628 | 628 | $count_errors |
| 629 | 629 | ); |
| 630 | 630 | } |
| 631 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 631 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
| 632 | 632 | } else { |
| 633 | - if ( $count_queued === 1 ) { |
|
| 633 | + if ($count_queued === 1) { |
|
| 634 | 634 | $message = sprintf( |
| 635 | 635 | __( |
| 636 | 636 | '%d message successfully queued for generation.', |
@@ -647,18 +647,18 @@ discard block |
||
| 647 | 647 | $count_queued |
| 648 | 648 | ); |
| 649 | 649 | } |
| 650 | - EE_Error::add_success( $message ); |
|
| 650 | + EE_Error::add_success($message); |
|
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | 653 | //if no error then return the generated message(s). |
| 654 | - if ( ! $error && ! $send ) { |
|
| 655 | - $generated_queue = $processor->generate_queue( false ); |
|
| 654 | + if ( ! $error && ! $send) { |
|
| 655 | + $generated_queue = $processor->generate_queue(false); |
|
| 656 | 656 | //get message and return. |
| 657 | 657 | $generated_queue->get_message_repository()->rewind(); |
| 658 | 658 | $messages = array(); |
| 659 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
| 659 | + while ($generated_queue->get_message_repository()->valid()) { |
|
| 660 | 660 | $message = $generated_queue->get_message_repository()->current(); |
| 661 | - if ( $message instanceof EE_Message ) { |
|
| 661 | + if ($message instanceof EE_Message) { |
|
| 662 | 662 | //set properties that might be expected by add-ons (backward compat) |
| 663 | 663 | $message->content = $message->content(); |
| 664 | 664 | $message->template_pack = $message->get_template_pack(); |
@@ -683,10 +683,10 @@ discard block |
||
| 683 | 683 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 684 | 684 | * @return string The body of the message. |
| 685 | 685 | */ |
| 686 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 686 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
| 687 | 687 | // EE_messages has been deprecated |
| 688 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 689 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
| 688 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 689 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | |
@@ -700,14 +700,14 @@ discard block |
||
| 700 | 700 | * |
| 701 | 701 | * @return bool success or fail. |
| 702 | 702 | */ |
| 703 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
| 703 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
| 704 | 704 | // EE_messages has been deprecated |
| 705 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 705 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 706 | 706 | //setup for sending to new method. |
| 707 | 707 | /** @type EE_Messages_Queue $queue */ |
| 708 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
| 708 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
| 709 | 709 | //make sure we have a proper message object |
| 710 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
| 710 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
| 711 | 711 | $msg = EE_Message_Factory::create( |
| 712 | 712 | array( |
| 713 | 713 | 'MSG_messenger' => $messenger, |
@@ -719,15 +719,15 @@ discard block |
||
| 719 | 719 | } else { |
| 720 | 720 | $msg = $message; |
| 721 | 721 | } |
| 722 | - if ( ! $msg instanceof EE_Message ) { |
|
| 722 | + if ( ! $msg instanceof EE_Message) { |
|
| 723 | 723 | return false; |
| 724 | 724 | } |
| 725 | 725 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
| 726 | - if ( ! empty( $msg->content ) ) { |
|
| 727 | - $msg->set( 'MSG_content', $msg->content ); |
|
| 726 | + if ( ! empty($msg->content)) { |
|
| 727 | + $msg->set('MSG_content', $msg->content); |
|
| 728 | 728 | } |
| 729 | - $queue->add( $msg ); |
|
| 730 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
| 729 | + $queue->add($msg); |
|
| 730 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | |
@@ -741,11 +741,11 @@ discard block |
||
| 741 | 741 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
| 742 | 742 | * @throws \EE_Error |
| 743 | 743 | */ |
| 744 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
| 744 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
| 745 | 745 | // EE_messages has been deprecated |
| 746 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 747 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 748 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
| 746 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 747 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 748 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | |
@@ -756,11 +756,11 @@ discard block |
||
| 756 | 756 | * @param string $message_type_name name of EE_message_type |
| 757 | 757 | * @return array |
| 758 | 758 | */ |
| 759 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
| 759 | + public function get_fields($messenger_name, $message_type_name) { |
|
| 760 | 760 | // EE_messages has been deprecated |
| 761 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 762 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 763 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
| 761 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 762 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 763 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | |
@@ -774,13 +774,13 @@ discard block |
||
| 774 | 774 | * @return array multidimensional array of messenger and message_type objects |
| 775 | 775 | * (messengers index, and message_type index); |
| 776 | 776 | */ |
| 777 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
| 777 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
| 778 | 778 | // EE_messages has been deprecated |
| 779 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 780 | - if ( $skip_cache ) { |
|
| 779 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 780 | + if ($skip_cache) { |
|
| 781 | 781 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
| 782 | 782 | } |
| 783 | - switch ( $type ) { |
|
| 783 | + switch ($type) { |
|
| 784 | 784 | case 'messengers' : |
| 785 | 785 | return array( |
| 786 | 786 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | */ |
| 810 | 810 | public function get_active_messengers() { |
| 811 | 811 | // EE_messages has been deprecated |
| 812 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 812 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 813 | 813 | return $this->_message_resource_manager->active_messengers(); |
| 814 | 814 | } |
| 815 | 815 | |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | */ |
| 822 | 822 | public function get_active_message_types() { |
| 823 | 823 | // EE_messages has been deprecated |
| 824 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 824 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 825 | 825 | return $this->_message_resource_manager->list_of_active_message_types(); |
| 826 | 826 | } |
| 827 | 827 | |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | public function get_active_message_type_objects() { |
| 835 | 835 | // EE_messages has been deprecated |
| 836 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 836 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 837 | 837 | return $this->_message_resource_manager->get_active_message_type_objects(); |
| 838 | 838 | } |
| 839 | 839 | |
@@ -845,10 +845,10 @@ discard block |
||
| 845 | 845 | * @param string $messenger The messenger being checked |
| 846 | 846 | * @return EE_message_type[] (or empty array if none present) |
| 847 | 847 | */ |
| 848 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
| 848 | + public function get_active_message_types_per_messenger($messenger) { |
|
| 849 | 849 | // EE_messages has been deprecated |
| 850 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 851 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
| 850 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 851 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | |
@@ -859,10 +859,10 @@ discard block |
||
| 859 | 859 | * @param string $message_type The string should correspond to a message type. |
| 860 | 860 | * @return EE_message_type|null |
| 861 | 861 | */ |
| 862 | - public function get_active_message_type( $messenger, $message_type ) { |
|
| 862 | + public function get_active_message_type($messenger, $message_type) { |
|
| 863 | 863 | // EE_messages has been deprecated |
| 864 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 865 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
| 864 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 865 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | */ |
| 874 | 874 | public function get_installed_message_types() { |
| 875 | 875 | // EE_messages has been deprecated |
| 876 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 876 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 877 | 877 | return $this->_message_resource_manager->installed_message_types(); |
| 878 | 878 | } |
| 879 | 879 | |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | */ |
| 886 | 886 | public function get_installed_messengers() { |
| 887 | 887 | // EE_messages has been deprecated |
| 888 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 888 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 889 | 889 | return $this->_message_resource_manager->installed_messengers(); |
| 890 | 890 | } |
| 891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
| 896 | 896 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 897 | 897 | * @return array |
| 898 | 898 | */ |
| 899 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 899 | + public function get_all_contexts($slugs_only = true) { |
|
| 900 | 900 | // EE_messages has been deprecated |
| 901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 902 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
| 901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 902 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * |
| 480 | 480 | * @final |
| 481 | 481 | * @access protected |
| 482 | - * @return void |
|
| 482 | + * @return false|null |
|
| 483 | 483 | */ |
| 484 | 484 | final protected function _page_setup() { |
| 485 | 485 | |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | * All this method does is verify the incoming request and make sure that routes exist for it. We do this early so we know if we need to drop out. |
| 754 | 754 | * |
| 755 | 755 | * @access protected |
| 756 | - * @return void |
|
| 756 | + * @return false|null |
|
| 757 | 757 | */ |
| 758 | 758 | protected function _verify_routes() { |
| 759 | 759 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | /** |
| 816 | 816 | * this method simply verifies a given route and makes sure its an actual route available for the loaded page |
| 817 | 817 | * @param string $route the route name we're verifying |
| 818 | - * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
|
| 818 | + * @return boolean (bool|Exception) we'll throw an exception if this isn't a valid route. |
|
| 819 | 819 | */ |
| 820 | 820 | protected function _verify_route( $route ) { |
| 821 | 821 | if ( array_key_exists( $this->_req_action, $this->_page_routes )) { |
@@ -3368,7 +3368,7 @@ discard block |
||
| 3368 | 3368 | |
| 3369 | 3369 | |
| 3370 | 3370 | /** |
| 3371 | - * @return mixed |
|
| 3371 | + * @return string[] |
|
| 3372 | 3372 | */ |
| 3373 | 3373 | public function default_espresso_metaboxes() { |
| 3374 | 3374 | return $this->_default_espresso_metaboxes; |
@@ -3386,7 +3386,7 @@ discard block |
||
| 3386 | 3386 | |
| 3387 | 3387 | |
| 3388 | 3388 | /** |
| 3389 | - * @return mixed |
|
| 3389 | + * @return string |
|
| 3390 | 3390 | */ |
| 3391 | 3391 | public function wp_page_slug() { |
| 3392 | 3392 | return $this->_wp_page_slug; |
@@ -3399,7 +3399,6 @@ discard block |
||
| 3399 | 3399 | * |
| 3400 | 3400 | * @access protected |
| 3401 | 3401 | * @param string $tab |
| 3402 | - * @param array $data |
|
| 3403 | 3402 | * @param string $file file where error occurred |
| 3404 | 3403 | * @param string $func function where error occurred |
| 3405 | 3404 | * @param string $line line no where error occurred |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Event Espresso |
| 4 | 6 | * |
@@ -160,8 +162,9 @@ discard block |
||
| 160 | 162 | */ |
| 161 | 163 | public function __construct( $routing = TRUE ) { |
| 162 | 164 | |
| 163 | - if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) |
|
| 164 | - $this->_is_caf = TRUE; |
|
| 165 | + if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) { |
|
| 166 | + $this->_is_caf = TRUE; |
|
| 167 | + } |
|
| 165 | 168 | |
| 166 | 169 | $this->_yes_no_values = array( |
| 167 | 170 | array('id' => TRUE, 'text' => __('Yes', 'event_espresso')), |
@@ -192,8 +195,9 @@ discard block |
||
| 192 | 195 | $this->_do_other_page_hooks(); |
| 193 | 196 | |
| 194 | 197 | //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
| 195 | - if ( method_exists( $this, '_before_page_setup' ) ) |
|
| 196 | - $this->_before_page_setup(); |
|
| 198 | + if ( method_exists( $this, '_before_page_setup' ) ) { |
|
| 199 | + $this->_before_page_setup(); |
|
| 200 | + } |
|
| 197 | 201 | |
| 198 | 202 | //set up page dependencies |
| 199 | 203 | $this->_page_setup(); |
@@ -500,7 +504,9 @@ discard block |
||
| 500 | 504 | global $ee_menu_slugs; |
| 501 | 505 | $ee_menu_slugs = (array) $ee_menu_slugs; |
| 502 | 506 | |
| 503 | - if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) return FALSE; |
|
| 507 | + if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) { |
|
| 508 | + return FALSE; |
|
| 509 | + } |
|
| 504 | 510 | |
| 505 | 511 | |
| 506 | 512 | // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
@@ -535,12 +541,14 @@ discard block |
||
| 535 | 541 | } |
| 536 | 542 | |
| 537 | 543 | //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
| 538 | - if ( method_exists( $this, '_extend_page_config' ) ) |
|
| 539 | - $this->_extend_page_config(); |
|
| 544 | + if ( method_exists( $this, '_extend_page_config' ) ) { |
|
| 545 | + $this->_extend_page_config(); |
|
| 546 | + } |
|
| 540 | 547 | |
| 541 | 548 | //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
| 542 | - if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) |
|
| 543 | - $this->_extend_page_config_for_cpt(); |
|
| 549 | + if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) { |
|
| 550 | + $this->_extend_page_config_for_cpt(); |
|
| 551 | + } |
|
| 544 | 552 | |
| 545 | 553 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
| 546 | 554 | $this->_page_routes = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this ); |
@@ -656,8 +664,9 @@ discard block |
||
| 656 | 664 | //add screen options - global, page child class, and view specific |
| 657 | 665 | $this->_add_global_screen_options(); |
| 658 | 666 | $this->_add_screen_options(); |
| 659 | - if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) |
|
| 660 | - call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
| 667 | + if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) { |
|
| 668 | + call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
| 669 | + } |
|
| 661 | 670 | |
| 662 | 671 | |
| 663 | 672 | //add help tab(s) and tours- set via page_config and qtips. |
@@ -668,28 +677,32 @@ discard block |
||
| 668 | 677 | //add feature_pointers - global, page child class, and view specific |
| 669 | 678 | $this->_add_feature_pointers(); |
| 670 | 679 | $this->_add_global_feature_pointers(); |
| 671 | - if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) |
|
| 672 | - call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
| 680 | + if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) { |
|
| 681 | + call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
| 682 | + } |
|
| 673 | 683 | |
| 674 | 684 | //enqueue scripts/styles - global, page class, and view specific |
| 675 | 685 | add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5 ); |
| 676 | 686 | add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10 ); |
| 677 | - if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) |
|
| 678 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
| 687 | + if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) { |
|
| 688 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
| 689 | + } |
|
| 679 | 690 | |
| 680 | 691 | add_action('admin_enqueue_scripts', array( $this, 'admin_footer_scripts_eei18n_js_strings' ), 100 ); |
| 681 | 692 | |
| 682 | 693 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
| 683 | 694 | add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_global' ), 99 ); |
| 684 | 695 | add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), 100 ); |
| 685 | - if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) |
|
| 686 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
| 696 | + if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) { |
|
| 697 | + add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
| 698 | + } |
|
| 687 | 699 | |
| 688 | 700 | //admin footer scripts |
| 689 | 701 | add_action('admin_footer', array( $this, 'admin_footer_global' ), 99 ); |
| 690 | 702 | add_action('admin_footer', array( $this, 'admin_footer'), 100 ); |
| 691 | - if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) |
|
| 692 | - add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
| 703 | + if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) { |
|
| 704 | + add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
| 705 | + } |
|
| 693 | 706 | |
| 694 | 707 | |
| 695 | 708 | do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug ); |
@@ -762,7 +775,9 @@ discard block |
||
| 762 | 775 | protected function _verify_routes() { |
| 763 | 776 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
| 764 | 777 | |
| 765 | - if ( !$this->_current_page && !defined( 'DOING_AJAX')) return FALSE; |
|
| 778 | + if ( !$this->_current_page && !defined( 'DOING_AJAX')) { |
|
| 779 | + return FALSE; |
|
| 780 | + } |
|
| 766 | 781 | |
| 767 | 782 | $this->_route = FALSE; |
| 768 | 783 | $func = FALSE; |
@@ -872,8 +887,9 @@ discard block |
||
| 872 | 887 | * @return void |
| 873 | 888 | */ |
| 874 | 889 | protected function _route_admin_request() { |
| 875 | - if ( ! $this->_is_UI_request ) |
|
| 876 | - $this->_verify_routes(); |
|
| 890 | + if ( ! $this->_is_UI_request ) { |
|
| 891 | + $this->_verify_routes(); |
|
| 892 | + } |
|
| 877 | 893 | |
| 878 | 894 | $nonce_check = isset( $this->_route_config['require_nonce'] ) ? $this->_route_config['require_nonce'] : TRUE; |
| 879 | 895 | |
@@ -883,8 +899,9 @@ discard block |
||
| 883 | 899 | $this->_verify_nonce( $nonce, $this->_req_nonce ); |
| 884 | 900 | } |
| 885 | 901 | //set the nav_tabs array but ONLY if this is UI_request |
| 886 | - if ( $this->_is_UI_request ) |
|
| 887 | - $this->_set_nav_tabs(); |
|
| 902 | + if ( $this->_is_UI_request ) { |
|
| 903 | + $this->_set_nav_tabs(); |
|
| 904 | + } |
|
| 888 | 905 | |
| 889 | 906 | // grab callback function |
| 890 | 907 | $func = is_array( $this->_route ) ? $this->_route['func'] : $this->_route; |
@@ -921,8 +938,9 @@ discard block |
||
| 921 | 938 | } |
| 922 | 939 | |
| 923 | 940 | |
| 924 | - if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) |
|
| 925 | - throw new EE_Error( $error_msg ); |
|
| 941 | + if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) { |
|
| 942 | + throw new EE_Error( $error_msg ); |
|
| 943 | + } |
|
| 926 | 944 | } |
| 927 | 945 | |
| 928 | 946 | //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
@@ -1049,8 +1067,9 @@ discard block |
||
| 1049 | 1067 | $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
| 1050 | 1068 | foreach ( $this->_help_tour['tours'] as $tour ) { |
| 1051 | 1069 | //if this is the end tour then we don't need to setup a button |
| 1052 | - if ( $tour instanceof EE_Help_Tour_final_stop ) |
|
| 1053 | - continue; |
|
| 1070 | + if ( $tour instanceof EE_Help_Tour_final_stop ) { |
|
| 1071 | + continue; |
|
| 1072 | + } |
|
| 1054 | 1073 | $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
| 1055 | 1074 | } |
| 1056 | 1075 | $tour_buttons .= implode('<br />', $tb); |
@@ -1060,8 +1079,9 @@ discard block |
||
| 1060 | 1079 | // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
| 1061 | 1080 | if ( is_array( $config ) && isset( $config['help_sidebar'] ) ) { |
| 1062 | 1081 | //check that the callback given is valid |
| 1063 | - if ( !method_exists($this, $config['help_sidebar'] ) ) |
|
| 1064 | - throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
| 1082 | + if ( !method_exists($this, $config['help_sidebar'] ) ) { |
|
| 1083 | + throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
| 1084 | + } |
|
| 1065 | 1085 | |
| 1066 | 1086 | $content = apply_filters( 'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func( array( $this, $config['help_sidebar'] ) ) ); |
| 1067 | 1087 | |
@@ -1085,18 +1105,23 @@ discard block |
||
| 1085 | 1105 | }/**/ |
| 1086 | 1106 | |
| 1087 | 1107 | |
| 1088 | - if ( !isset( $config['help_tabs'] ) ) return; //no help tabs for this route |
|
| 1108 | + if ( !isset( $config['help_tabs'] ) ) { |
|
| 1109 | + return; |
|
| 1110 | + } |
|
| 1111 | + //no help tabs for this route |
|
| 1089 | 1112 | |
| 1090 | 1113 | foreach ( (array) $config['help_tabs'] as $tab_id => $cfg ) { |
| 1091 | 1114 | //we're here so there ARE help tabs! |
| 1092 | 1115 | |
| 1093 | 1116 | //make sure we've got what we need |
| 1094 | - if ( !isset( $cfg['title'] ) ) |
|
| 1095 | - throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
| 1117 | + if ( !isset( $cfg['title'] ) ) { |
|
| 1118 | + throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
| 1119 | + } |
|
| 1096 | 1120 | |
| 1097 | 1121 | |
| 1098 | - if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) |
|
| 1099 | - throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
| 1122 | + if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) { |
|
| 1123 | + throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
| 1124 | + } |
|
| 1100 | 1125 | |
| 1101 | 1126 | |
| 1102 | 1127 | |
@@ -1159,14 +1184,16 @@ discard block |
||
| 1159 | 1184 | $this->_help_tour = array(); |
| 1160 | 1185 | |
| 1161 | 1186 | //exit early if help tours are turned off globally |
| 1162 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) |
|
| 1163 | - return; |
|
| 1187 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) { |
|
| 1188 | + return; |
|
| 1189 | + } |
|
| 1164 | 1190 | |
| 1165 | 1191 | //loop through _page_config to find any help_tour defined |
| 1166 | 1192 | foreach ( $this->_page_config as $route => $config ) { |
| 1167 | 1193 | //we're only going to set things up for this route |
| 1168 | - if ( $route !== $this->_req_action ) |
|
| 1169 | - continue; |
|
| 1194 | + if ( $route !== $this->_req_action ) { |
|
| 1195 | + continue; |
|
| 1196 | + } |
|
| 1170 | 1197 | |
| 1171 | 1198 | if ( isset( $config['help_tour'] ) ) { |
| 1172 | 1199 | |
@@ -1201,8 +1228,9 @@ discard block |
||
| 1201 | 1228 | } |
| 1202 | 1229 | } |
| 1203 | 1230 | |
| 1204 | - if ( !empty( $tours ) ) |
|
| 1205 | - $this->_help_tour['tours'] = $tours; |
|
| 1231 | + if ( !empty( $tours ) ) { |
|
| 1232 | + $this->_help_tour['tours'] = $tours; |
|
| 1233 | + } |
|
| 1206 | 1234 | |
| 1207 | 1235 | //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
| 1208 | 1236 | } |
@@ -1242,15 +1270,21 @@ discard block |
||
| 1242 | 1270 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
| 1243 | 1271 | $i = 0; |
| 1244 | 1272 | foreach ( $this->_page_config as $slug => $config ) { |
| 1245 | - if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) |
|
| 1246 | - continue; //no nav tab for this config |
|
| 1273 | + if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) { |
|
| 1274 | + continue; |
|
| 1275 | + } |
|
| 1276 | + //no nav tab for this config |
|
| 1247 | 1277 | |
| 1248 | 1278 | //check for persistent flag |
| 1249 | - if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) |
|
| 1250 | - continue; //nav tab is only to appear when route requested. |
|
| 1279 | + if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) { |
|
| 1280 | + continue; |
|
| 1281 | + } |
|
| 1282 | + //nav tab is only to appear when route requested. |
|
| 1251 | 1283 | |
| 1252 | - if ( ! $this->check_user_access( $slug, TRUE ) ) |
|
| 1253 | - continue; //no nav tab becasue current user does not have access. |
|
| 1284 | + if ( ! $this->check_user_access( $slug, TRUE ) ) { |
|
| 1285 | + continue; |
|
| 1286 | + } |
|
| 1287 | + //no nav tab becasue current user does not have access. |
|
| 1254 | 1288 | |
| 1255 | 1289 | $css_class = isset( $config['css_class'] ) ? $config['css_class'] . ' ' : ''; |
| 1256 | 1290 | $this->_nav_tabs[$slug] = array( |
@@ -1486,10 +1520,11 @@ discard block |
||
| 1486 | 1520 | $content .= EEH_Template::display_template( $template_path, $template_args, TRUE ); |
| 1487 | 1521 | } |
| 1488 | 1522 | |
| 1489 | - if ( $display ) |
|
| 1490 | - echo $content; |
|
| 1491 | - else |
|
| 1492 | - return $content; |
|
| 1523 | + if ( $display ) { |
|
| 1524 | + echo $content; |
|
| 1525 | + } else { |
|
| 1526 | + return $content; |
|
| 1527 | + } |
|
| 1493 | 1528 | } |
| 1494 | 1529 | |
| 1495 | 1530 | |
@@ -1506,8 +1541,9 @@ discard block |
||
| 1506 | 1541 | $method_name = '_help_popup_content_' . $this->_req_action; |
| 1507 | 1542 | |
| 1508 | 1543 | //if method doesn't exist let's get out. |
| 1509 | - if ( !method_exists( $this, $method_name ) ) |
|
| 1510 | - return array(); |
|
| 1544 | + if ( !method_exists( $this, $method_name ) ) { |
|
| 1545 | + return array(); |
|
| 1546 | + } |
|
| 1511 | 1547 | |
| 1512 | 1548 | //k we're good to go let's retrieve the help array |
| 1513 | 1549 | $help_array = call_user_func( array( $this, $method_name ) ); |
@@ -1538,7 +1574,9 @@ discard block |
||
| 1538 | 1574 | */ |
| 1539 | 1575 | protected function _set_help_trigger( $trigger_id, $display = TRUE, $dimensions = array( '400', '640') ) { |
| 1540 | 1576 | |
| 1541 | - if ( defined('DOING_AJAX') ) return; |
|
| 1577 | + if ( defined('DOING_AJAX') ) { |
|
| 1578 | + return; |
|
| 1579 | + } |
|
| 1542 | 1580 | |
| 1543 | 1581 | //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
| 1544 | 1582 | $help_array = $this->_get_help_content(); |
@@ -1556,10 +1594,11 @@ discard block |
||
| 1556 | 1594 | $content = '<a class="ee-dialog" href="?height='. $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
| 1557 | 1595 | $content = $content . $help_content; |
| 1558 | 1596 | |
| 1559 | - if ( $display ) |
|
| 1560 | - echo $content; |
|
| 1561 | - else |
|
| 1562 | - return $content; |
|
| 1597 | + if ( $display ) { |
|
| 1598 | + echo $content; |
|
| 1599 | + } else { |
|
| 1600 | + return $content; |
|
| 1601 | + } |
|
| 1563 | 1602 | } |
| 1564 | 1603 | |
| 1565 | 1604 | |
@@ -1785,8 +1824,10 @@ discard block |
||
| 1785 | 1824 | protected function _set_list_table() { |
| 1786 | 1825 | |
| 1787 | 1826 | //first is this a list_table view? |
| 1788 | - if ( !isset($this->_route_config['list_table']) ) |
|
| 1789 | - return; //not a list_table view so get out. |
|
| 1827 | + if ( !isset($this->_route_config['list_table']) ) { |
|
| 1828 | + return; |
|
| 1829 | + } |
|
| 1830 | + //not a list_table view so get out. |
|
| 1790 | 1831 | |
| 1791 | 1832 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
| 1792 | 1833 | |
@@ -2148,8 +2189,9 @@ discard block |
||
| 2148 | 2189 | protected function _espresso_sponsors_post_box() { |
| 2149 | 2190 | |
| 2150 | 2191 | $show_sponsors = apply_filters( 'FHEE_show_sponsors_meta_box', TRUE ); |
| 2151 | - if ( $show_sponsors ) |
|
| 2152 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2192 | + if ( $show_sponsors ) { |
|
| 2193 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2194 | + } |
|
| 2153 | 2195 | } |
| 2154 | 2196 | |
| 2155 | 2197 | |
@@ -2446,8 +2488,9 @@ discard block |
||
| 2446 | 2488 | |
| 2447 | 2489 | $template_path = $sidebar ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
| 2448 | 2490 | |
| 2449 | - if ( defined('DOING_AJAX' ) ) |
|
| 2450 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2491 | + if ( defined('DOING_AJAX' ) ) { |
|
| 2492 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2493 | + } |
|
| 2451 | 2494 | |
| 2452 | 2495 | $template_path = !empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
| 2453 | 2496 | |
@@ -2586,10 +2629,11 @@ discard block |
||
| 2586 | 2629 | true |
| 2587 | 2630 | ); |
| 2588 | 2631 | // the final template wrapper |
| 2589 | - if ( $sidebar ) |
|
| 2590 | - $this->display_admin_page_with_sidebar(); |
|
| 2591 | - else |
|
| 2592 | - $this->display_admin_page_with_no_sidebar(); |
|
| 2632 | + if ( $sidebar ) { |
|
| 2633 | + $this->display_admin_page_with_sidebar(); |
|
| 2634 | + } else { |
|
| 2635 | + $this->display_admin_page_with_no_sidebar(); |
|
| 2636 | + } |
|
| 2593 | 2637 | } |
| 2594 | 2638 | |
| 2595 | 2639 | |
@@ -2657,8 +2701,9 @@ discard block |
||
| 2657 | 2701 | |
| 2658 | 2702 | |
| 2659 | 2703 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
| 2660 | - if ( NULL === error_get_last() || ! headers_sent() ) |
|
| 2661 | - header('Content-Type: application/json; charset=UTF-8'); |
|
| 2704 | + if ( NULL === error_get_last() || ! headers_sent() ) { |
|
| 2705 | + header('Content-Type: application/json; charset=UTF-8'); |
|
| 2706 | + } |
|
| 2662 | 2707 | if( function_exists( 'wp_json_encode' ) ) { |
| 2663 | 2708 | echo wp_json_encode( $json ); |
| 2664 | 2709 | } else { |
@@ -2674,10 +2719,9 @@ discard block |
||
| 2674 | 2719 | * @return json_obj|EE_Error |
| 2675 | 2720 | */ |
| 2676 | 2721 | public function return_json() { |
| 2677 | - if ( defined('DOING_AJAX') && DOING_AJAX ) |
|
| 2678 | - $this->_return_json(); |
|
| 2679 | - |
|
| 2680 | - else { |
|
| 2722 | + if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
| 2723 | + $this->_return_json(); |
|
| 2724 | + } else { |
|
| 2681 | 2725 | throw new EE_Error( sprintf( __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__ ) ); |
| 2682 | 2726 | } |
| 2683 | 2727 | } |
@@ -2824,7 +2868,9 @@ discard block |
||
| 2824 | 2868 | $id = $this->_current_view . '_' . $ref; |
| 2825 | 2869 | $name = !empty($actions) ? $actions[$key] : $ref; |
| 2826 | 2870 | $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
| 2827 | - if ( !$both ) break; |
|
| 2871 | + if ( !$both ) { |
|
| 2872 | + break; |
|
| 2873 | + } |
|
| 2828 | 2874 | } |
| 2829 | 2875 | |
| 2830 | 2876 | } |
@@ -3163,13 +3209,15 @@ discard block |
||
| 3163 | 3209 | if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
| 3164 | 3210 | check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
| 3165 | 3211 | |
| 3166 | - if ( !$user = wp_get_current_user() ) |
|
| 3167 | - return; |
|
| 3212 | + if ( !$user = wp_get_current_user() ) { |
|
| 3213 | + return; |
|
| 3214 | + } |
|
| 3168 | 3215 | $option = $_POST['wp_screen_options']['option']; |
| 3169 | 3216 | $value = $_POST['wp_screen_options']['value']; |
| 3170 | 3217 | |
| 3171 | - if ( $option != sanitize_key( $option ) ) |
|
| 3172 | - return; |
|
| 3218 | + if ( $option != sanitize_key( $option ) ) { |
|
| 3219 | + return; |
|
| 3220 | + } |
|
| 3173 | 3221 | |
| 3174 | 3222 | $map_option = $option; |
| 3175 | 3223 | |
@@ -3178,13 +3226,15 @@ discard block |
||
| 3178 | 3226 | switch ( $map_option ) { |
| 3179 | 3227 | case $this->_current_page . '_' . $this->_current_view . '_per_page': |
| 3180 | 3228 | $value = (int) $value; |
| 3181 | - if ( $value < 1 || $value > 999 ) |
|
| 3182 | - return; |
|
| 3229 | + if ( $value < 1 || $value > 999 ) { |
|
| 3230 | + return; |
|
| 3231 | + } |
|
| 3183 | 3232 | break; |
| 3184 | 3233 | default: |
| 3185 | 3234 | $value = apply_filters( 'FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value ); |
| 3186 | - if ( false === $value ) |
|
| 3187 | - return; |
|
| 3235 | + if ( false === $value ) { |
|
| 3236 | + return; |
|
| 3237 | + } |
|
| 3188 | 3238 | break; |
| 3189 | 3239 | } |
| 3190 | 3240 | |
@@ -3220,8 +3270,9 @@ discard block |
||
| 3220 | 3270 | protected function _add_transient( $route, $data, $notices = FALSE, $skip_route_verify = FALSE ) { |
| 3221 | 3271 | $user_id = get_current_user_id(); |
| 3222 | 3272 | |
| 3223 | - if ( !$skip_route_verify ) |
|
| 3224 | - $this->_verify_route($route); |
|
| 3273 | + if ( !$skip_route_verify ) { |
|
| 3274 | + $this->_verify_route($route); |
|
| 3275 | + } |
|
| 3225 | 3276 | |
| 3226 | 3277 | |
| 3227 | 3278 | //now let's set the string for what kind of transient we're setting |
@@ -1311,8 +1311,8 @@ discard block |
||
| 1311 | 1311 | * verifies user access for this admin page |
| 1312 | 1312 | * @param string $route_to_check if present then the capability for the route matching this string is checked. |
| 1313 | 1313 | * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
| 1314 | - * @return BOOL|wp_die() |
|
| 1315 | - */ |
|
| 1314 | + * @return BOOL|wp_die() |
|
| 1315 | + */ |
|
| 1316 | 1316 | public function check_user_access( $route_to_check = '', $verify_only = FALSE ) { |
| 1317 | 1317 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
| 1318 | 1318 | $route_to_check = empty( $route_to_check ) ? $this->_req_action : $route_to_check; |
@@ -1698,11 +1698,11 @@ discard block |
||
| 1698 | 1698 | |
| 1699 | 1699 | |
| 1700 | 1700 | /** |
| 1701 | - * admin_footer_scripts_eei18n_js_strings |
|
| 1702 | - * |
|
| 1703 | - * @access public |
|
| 1704 | - * @return void |
|
| 1705 | - */ |
|
| 1701 | + * admin_footer_scripts_eei18n_js_strings |
|
| 1702 | + * |
|
| 1703 | + * @access public |
|
| 1704 | + * @return void |
|
| 1705 | + */ |
|
| 1706 | 1706 | public function admin_footer_scripts_eei18n_js_strings() { |
| 1707 | 1707 | |
| 1708 | 1708 | EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
@@ -1758,11 +1758,11 @@ discard block |
||
| 1758 | 1758 | |
| 1759 | 1759 | |
| 1760 | 1760 | /** |
| 1761 | - * load enhanced xdebug styles for ppl with failing eyesight |
|
| 1762 | - * |
|
| 1763 | - * @access public |
|
| 1764 | - * @return void |
|
| 1765 | - */ |
|
| 1761 | + * load enhanced xdebug styles for ppl with failing eyesight |
|
| 1762 | + * |
|
| 1763 | + * @access public |
|
| 1764 | + * @return void |
|
| 1765 | + */ |
|
| 1766 | 1766 | public function add_xdebug_style() { |
| 1767 | 1767 | echo '<style>.xdebug-error { font-size:1.5em; }</style>'; |
| 1768 | 1768 | } |
@@ -1819,9 +1819,9 @@ discard block |
||
| 1819 | 1819 | |
| 1820 | 1820 | /** |
| 1821 | 1821 | * set current view for List Table |
| 1822 | - * @access public |
|
| 1823 | - * @return array |
|
| 1824 | - */ |
|
| 1822 | + * @access public |
|
| 1823 | + * @return array |
|
| 1824 | + */ |
|
| 1825 | 1825 | protected function _set_list_table_view() { |
| 1826 | 1826 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
| 1827 | 1827 | |
@@ -1910,7 +1910,7 @@ discard block |
||
| 1910 | 1910 | * @access protected |
| 1911 | 1911 | * @param int $max_entries total number of rows in the table |
| 1912 | 1912 | * @return string |
| 1913 | - */ |
|
| 1913 | + */ |
|
| 1914 | 1914 | protected function _entries_per_page_dropdown( $max_entries = FALSE ) { |
| 1915 | 1915 | |
| 1916 | 1916 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -1955,9 +1955,9 @@ discard block |
||
| 1955 | 1955 | |
| 1956 | 1956 | /** |
| 1957 | 1957 | * _set_search_attributes |
| 1958 | - * @access protected |
|
| 1959 | - * @return void |
|
| 1960 | - */ |
|
| 1958 | + * @access protected |
|
| 1959 | + * @return void |
|
| 1960 | + */ |
|
| 1961 | 1961 | public function _set_search_attributes() { |
| 1962 | 1962 | $this->_template_args['search']['btn_label'] = sprintf( __( 'Search %s', 'event_espresso' ), empty( $this->_search_btn_label ) ? $this->page_label : $this->_search_btn_label ); |
| 1963 | 1963 | $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
@@ -1977,7 +1977,7 @@ discard block |
||
| 1977 | 1977 | * @link http://codex.wordpress.org/Function_Reference/add_meta_box |
| 1978 | 1978 | * @access private |
| 1979 | 1979 | * @return void |
| 1980 | - */ |
|
| 1980 | + */ |
|
| 1981 | 1981 | private function _add_registered_meta_boxes() { |
| 1982 | 1982 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
| 1983 | 1983 | |
@@ -2209,7 +2209,6 @@ discard block |
||
| 2209 | 2209 | * Note: currently there is no validation for this. However if you want the delete button, the |
| 2210 | 2210 | * save, and save and close buttons to work properly, then you will want to include a |
| 2211 | 2211 | * values for the name and id arguments. |
| 2212 | - |
|
| 2213 | 2212 | * |
| 2214 | 2213 | *@todo Add in validation for name/id arguments. |
| 2215 | 2214 | * @param string $name key used for the action ID (i.e. event_id) |
@@ -2268,9 +2267,9 @@ discard block |
||
| 2268 | 2267 | |
| 2269 | 2268 | /** |
| 2270 | 2269 | * displays an error message to ppl who have javascript disabled |
| 2271 | - * @access private |
|
| 2272 | - * @return string |
|
| 2273 | - */ |
|
| 2270 | + * @access private |
|
| 2271 | + * @return string |
|
| 2272 | + */ |
|
| 2274 | 2273 | private function _display_no_javascript_warning() { |
| 2275 | 2274 | ?> |
| 2276 | 2275 | <noscript> |
@@ -2293,9 +2292,9 @@ discard block |
||
| 2293 | 2292 | |
| 2294 | 2293 | /** |
| 2295 | 2294 | * displays espresso success and/or error notices |
| 2296 | - * @access private |
|
| 2297 | - * @return string |
|
| 2298 | - */ |
|
| 2295 | + * @access private |
|
| 2296 | + * @return string |
|
| 2297 | + */ |
|
| 2299 | 2298 | private function _display_espresso_notices() { |
| 2300 | 2299 | $notices = $this->_get_transient( TRUE ); |
| 2301 | 2300 | echo stripslashes($notices); |
@@ -2307,10 +2306,10 @@ discard block |
||
| 2307 | 2306 | |
| 2308 | 2307 | |
| 2309 | 2308 | /** |
| 2310 | - * spinny things pacify the masses |
|
| 2311 | - * @access private |
|
| 2312 | - * @return string |
|
| 2313 | - */ |
|
| 2309 | + * spinny things pacify the masses |
|
| 2310 | + * @access private |
|
| 2311 | + * @return string |
|
| 2312 | + */ |
|
| 2314 | 2313 | protected function _add_admin_page_ajax_loading_img() { |
| 2315 | 2314 | ?> |
| 2316 | 2315 | <div id="espresso-ajax-loading" class="ajax-loading-grey"> |
@@ -2324,10 +2323,10 @@ discard block |
||
| 2324 | 2323 | |
| 2325 | 2324 | |
| 2326 | 2325 | /** |
| 2327 | - * add admin page overlay for modal boxes |
|
| 2328 | - * @access private |
|
| 2329 | - * @return string |
|
| 2330 | - */ |
|
| 2326 | + * add admin page overlay for modal boxes |
|
| 2327 | + * @access private |
|
| 2328 | + * @return string |
|
| 2329 | + */ |
|
| 2331 | 2330 | protected function _add_admin_page_overlay() { |
| 2332 | 2331 | ?> |
| 2333 | 2332 | <div id="espresso-admin-page-overlay-dv" class=""></div> |
@@ -2389,10 +2388,10 @@ discard block |
||
| 2389 | 2388 | |
| 2390 | 2389 | |
| 2391 | 2390 | /** |
| 2392 | - * generates HTML wrapper for an admin details page |
|
| 2393 | - * @access public |
|
| 2394 | - * @return void |
|
| 2395 | - */ |
|
| 2391 | + * generates HTML wrapper for an admin details page |
|
| 2392 | + * @access public |
|
| 2393 | + * @return void |
|
| 2394 | + */ |
|
| 2396 | 2395 | public function display_admin_page_with_sidebar() { |
| 2397 | 2396 | |
| 2398 | 2397 | $this->_display_admin_page(TRUE); |
@@ -2402,10 +2401,10 @@ discard block |
||
| 2402 | 2401 | |
| 2403 | 2402 | |
| 2404 | 2403 | /** |
| 2405 | - * generates HTML wrapper for an admin details page (except no sidebar) |
|
| 2406 | - * @access public |
|
| 2407 | - * @return void |
|
| 2408 | - */ |
|
| 2404 | + * generates HTML wrapper for an admin details page (except no sidebar) |
|
| 2405 | + * @access public |
|
| 2406 | + * @return void |
|
| 2407 | + */ |
|
| 2409 | 2408 | public function display_admin_page_with_no_sidebar() { |
| 2410 | 2409 | $this->_display_admin_page(); |
| 2411 | 2410 | } |
@@ -2662,11 +2661,11 @@ discard block |
||
| 2662 | 2661 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
| 2663 | 2662 | if ( NULL === error_get_last() || ! headers_sent() ) |
| 2664 | 2663 | header('Content-Type: application/json; charset=UTF-8'); |
| 2665 | - if( function_exists( 'wp_json_encode' ) ) { |
|
| 2666 | - echo wp_json_encode( $json ); |
|
| 2667 | - } else { |
|
| 2668 | - echo json_encode( $json ); |
|
| 2669 | - } |
|
| 2664 | + if( function_exists( 'wp_json_encode' ) ) { |
|
| 2665 | + echo wp_json_encode( $json ); |
|
| 2666 | + } else { |
|
| 2667 | + echo json_encode( $json ); |
|
| 2668 | + } |
|
| 2670 | 2669 | exit(); |
| 2671 | 2670 | } |
| 2672 | 2671 | |
@@ -2705,11 +2704,11 @@ discard block |
||
| 2705 | 2704 | |
| 2706 | 2705 | |
| 2707 | 2706 | /** |
| 2708 | - * generates HTML wrapper with Tabbed nav for an admin page |
|
| 2709 | - * @access public |
|
| 2710 | - * @param boolean $about whether to use the special about page wrapper or default. |
|
| 2711 | - * @return void |
|
| 2712 | - */ |
|
| 2707 | + * generates HTML wrapper with Tabbed nav for an admin page |
|
| 2708 | + * @access public |
|
| 2709 | + * @param boolean $about whether to use the special about page wrapper or default. |
|
| 2710 | + * @return void |
|
| 2711 | + */ |
|
| 2713 | 2712 | public function admin_page_wrapper($about = FALSE) { |
| 2714 | 2713 | |
| 2715 | 2714 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -2766,9 +2765,9 @@ discard block |
||
| 2766 | 2765 | */ |
| 2767 | 2766 | private function _sort_nav_tabs( $a, $b ) { |
| 2768 | 2767 | if ($a['order'] == $b['order']) { |
| 2769 | - return 0; |
|
| 2770 | - } |
|
| 2771 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
| 2768 | + return 0; |
|
| 2769 | + } |
|
| 2770 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
| 2772 | 2771 | } |
| 2773 | 2772 | |
| 2774 | 2773 | |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
| 159 | 159 | * @access public |
| 160 | 160 | */ |
| 161 | - public function __construct( $routing = TRUE ) { |
|
| 161 | + public function __construct($routing = TRUE) { |
|
| 162 | 162 | |
| 163 | - if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) |
|
| 163 | + if (strpos($this->_get_dir(), 'caffeinated') !== false) |
|
| 164 | 164 | $this->_is_caf = TRUE; |
| 165 | 165 | |
| 166 | 166 | $this->_yes_no_values = array( |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | //set the _req_data property. |
| 174 | - $this->_req_data = array_merge( $_GET, $_POST ); |
|
| 174 | + $this->_req_data = array_merge($_GET, $_POST); |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | //routing enabled? |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $this->_do_other_page_hooks(); |
| 193 | 193 | |
| 194 | 194 | //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
| 195 | - if ( method_exists( $this, '_before_page_setup' ) ) |
|
| 195 | + if (method_exists($this, '_before_page_setup')) |
|
| 196 | 196 | $this->_before_page_setup(); |
| 197 | 197 | |
| 198 | 198 | //set up page dependencies |
@@ -462,16 +462,16 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | protected function _global_ajax_hooks() { |
| 464 | 464 | //for lazy loading of metabox content |
| 465 | - add_action( 'wp_ajax_espresso-ajax-content', array( $this, 'ajax_metabox_content'), 10 ); |
|
| 465 | + add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | |
| 469 | 469 | |
| 470 | 470 | public function ajax_metabox_content() { |
| 471 | - $contentid = isset( $this->_req_data['contentid'] ) ? $this->_req_data['contentid'] : ''; |
|
| 472 | - $url = isset( $this->_req_data['contenturl'] ) ? $this->_req_data['contenturl'] : ''; |
|
| 471 | + $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : ''; |
|
| 472 | + $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : ''; |
|
| 473 | 473 | |
| 474 | - self::cached_rss_display( $contentid, $url ); |
|
| 474 | + self::cached_rss_display($contentid, $url); |
|
| 475 | 475 | wp_die(); |
| 476 | 476 | } |
| 477 | 477 | |
@@ -490,87 +490,87 @@ discard block |
||
| 490 | 490 | //requires? |
| 491 | 491 | |
| 492 | 492 | //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can. But keep in mind, not everything is available from the EE_Admin Page object at this point. |
| 493 | - add_action( 'admin_init', array( $this, 'admin_init_global' ), 5 ); |
|
| 493 | + add_action('admin_init', array($this, 'admin_init_global'), 5); |
|
| 494 | 494 | |
| 495 | 495 | |
| 496 | 496 | //next verify if we need to load anything... |
| 497 | - $this->_current_page = !empty( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : ''; |
|
| 498 | - $this->page_folder = strtolower( str_replace( '_Admin_Page', '', str_replace( 'Extend_', '', get_class($this) ) ) ); |
|
| 497 | + $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
|
| 498 | + $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
|
| 499 | 499 | |
| 500 | 500 | global $ee_menu_slugs; |
| 501 | 501 | $ee_menu_slugs = (array) $ee_menu_slugs; |
| 502 | 502 | |
| 503 | - if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) return FALSE; |
|
| 503 | + if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) return FALSE; |
|
| 504 | 504 | |
| 505 | 505 | |
| 506 | 506 | // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
| 507 | - if ( isset( $this->_req_data['action2'] ) && $this->_req_data['action'] == -1 ) { |
|
| 508 | - $this->_req_data['action'] = ! empty( $this->_req_data['action2'] ) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
| 507 | + if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) { |
|
| 508 | + $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
| 509 | 509 | } |
| 510 | 510 | // then set blank or -1 action values to 'default' |
| 511 | - $this->_req_action = isset( $this->_req_data['action'] ) && ! empty( $this->_req_data['action'] ) && $this->_req_data['action'] != -1 ? sanitize_key( $this->_req_data['action'] ) : 'default'; |
|
| 511 | + $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default'; |
|
| 512 | 512 | |
| 513 | 513 | //if action is 'default' after the above BUT we have 'route' var set, then let's use the route as the action. This covers cases where we're coming in from a list table that isn't on the default route. |
| 514 | - $this->_req_action = $this->_req_action == 'default' && isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : $this->_req_action; |
|
| 514 | + $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
| 515 | 515 | |
| 516 | 516 | //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
| 517 | 517 | $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
| 518 | 518 | |
| 519 | 519 | $this->_current_view = $this->_req_action; |
| 520 | - $this->_req_nonce = $this->_req_action . '_nonce'; |
|
| 520 | + $this->_req_nonce = $this->_req_action.'_nonce'; |
|
| 521 | 521 | $this->_define_page_props(); |
| 522 | 522 | |
| 523 | - $this->_current_page_view_url = add_query_arg( array( 'page' => $this->_current_page, 'action' => $this->_current_view ), $this->_admin_base_url ); |
|
| 523 | + $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
|
| 524 | 524 | |
| 525 | 525 | //default things |
| 526 | - $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box' ); |
|
| 526 | + $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box'); |
|
| 527 | 527 | |
| 528 | 528 | //set page configs |
| 529 | 529 | $this->_set_page_routes(); |
| 530 | 530 | $this->_set_page_config(); |
| 531 | 531 | |
| 532 | 532 | //let's include any referrer data in our default_query_args for this route for "stickiness". |
| 533 | - if ( isset( $this->_req_data['wp_referer'] ) ) { |
|
| 533 | + if (isset($this->_req_data['wp_referer'])) { |
|
| 534 | 534 | $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer']; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
| 538 | - if ( method_exists( $this, '_extend_page_config' ) ) |
|
| 538 | + if (method_exists($this, '_extend_page_config')) |
|
| 539 | 539 | $this->_extend_page_config(); |
| 540 | 540 | |
| 541 | 541 | //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
| 542 | - if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) |
|
| 542 | + if (method_exists($this, '_extend_page_config_for_cpt')) |
|
| 543 | 543 | $this->_extend_page_config_for_cpt(); |
| 544 | 544 | |
| 545 | 545 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
| 546 | - $this->_page_routes = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this ); |
|
| 547 | - $this->_page_config = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this ); |
|
| 546 | + $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this); |
|
| 547 | + $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this); |
|
| 548 | 548 | |
| 549 | 549 | |
| 550 | 550 | //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
| 551 | - if ( method_exists( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ) ) { |
|
| 552 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ), 10, 2 ); |
|
| 551 | + if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) { |
|
| 552 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | |
| 556 | 556 | //next route only if routing enabled |
| 557 | - if ( $this->_routing && !defined('DOING_AJAX') ) { |
|
| 557 | + if ($this->_routing && ! defined('DOING_AJAX')) { |
|
| 558 | 558 | |
| 559 | 559 | $this->_verify_routes(); |
| 560 | 560 | |
| 561 | 561 | //next let's just check user_access and kill if no access |
| 562 | 562 | $this->check_user_access(); |
| 563 | 563 | |
| 564 | - if ( $this->_is_UI_request ) { |
|
| 564 | + if ($this->_is_UI_request) { |
|
| 565 | 565 | //admin_init stuff - global, all views for this page class, specific view |
| 566 | - add_action( 'admin_init', array( $this, 'admin_init' ), 10 ); |
|
| 567 | - if ( method_exists( $this, 'admin_init_' . $this->_current_view )) { |
|
| 568 | - add_action( 'admin_init', array( $this, 'admin_init_' . $this->_current_view ), 15 ); |
|
| 566 | + add_action('admin_init', array($this, 'admin_init'), 10); |
|
| 567 | + if (method_exists($this, 'admin_init_'.$this->_current_view)) { |
|
| 568 | + add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | } else { |
| 572 | 572 | //hijack regular WP loading and route admin request immediately |
| 573 | - @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
| 573 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
| 574 | 574 | $this->route_admin_request(); |
| 575 | 575 | } |
| 576 | 576 | } |
@@ -587,18 +587,18 @@ discard block |
||
| 587 | 587 | * @return void |
| 588 | 588 | */ |
| 589 | 589 | private function _do_other_page_hooks() { |
| 590 | - $registered_pages = apply_filters( 'FHEE_do_other_page_hooks_' . $this->page_slug, array() ); |
|
| 590 | + $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array()); |
|
| 591 | 591 | |
| 592 | - foreach ( $registered_pages as $page ) { |
|
| 592 | + foreach ($registered_pages as $page) { |
|
| 593 | 593 | |
| 594 | 594 | //now let's setup the file name and class that should be present |
| 595 | 595 | $classname = str_replace('.class.php', '', $page); |
| 596 | 596 | |
| 597 | 597 | //autoloaders should take care of loading file |
| 598 | - if ( !class_exists( $classname ) ) { |
|
| 599 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s admin hooks page.', 'event_espresso' ), $page); |
|
| 600 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname ); |
|
| 601 | - throw new EE_Error( implode( '||', $error_msg )); |
|
| 598 | + if ( ! class_exists($classname)) { |
|
| 599 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
| 600 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname); |
|
| 601 | + throw new EE_Error(implode('||', $error_msg)); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $a = new ReflectionClass($classname); |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | public function load_page_dependencies() { |
| 614 | 614 | try { |
| 615 | 615 | $this->_load_page_dependencies(); |
| 616 | - } catch ( EE_Error $e ) { |
|
| 616 | + } catch (EE_Error $e) { |
|
| 617 | 617 | $e->get_error(); |
| 618 | 618 | } |
| 619 | 619 | } |
@@ -631,16 +631,16 @@ discard block |
||
| 631 | 631 | $this->_current_screen = get_current_screen(); |
| 632 | 632 | |
| 633 | 633 | //load admin_notices - global, page class, and view specific |
| 634 | - add_action( 'admin_notices', array( $this, 'admin_notices_global'), 5 ); |
|
| 635 | - add_action( 'admin_notices', array( $this, 'admin_notices' ), 10 ); |
|
| 636 | - if ( method_exists( $this, 'admin_notices_' . $this->_current_view ) ) { |
|
| 637 | - add_action( 'admin_notices', array( $this, 'admin_notices_' . $this->_current_view ), 15 ); |
|
| 634 | + add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
|
| 635 | + add_action('admin_notices', array($this, 'admin_notices'), 10); |
|
| 636 | + if (method_exists($this, 'admin_notices_'.$this->_current_view)) { |
|
| 637 | + add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | //load network admin_notices - global, page class, and view specific |
| 641 | - add_action( 'network_admin_notices', array( $this, 'network_admin_notices_global'), 5 ); |
|
| 642 | - if ( method_exists( $this, 'network_admin_notices_' . $this->_current_view ) ) { |
|
| 643 | - add_action( 'network_admin_notices', array( $this, 'network_admin_notices_' . $this->_current_view ) ); |
|
| 641 | + add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
|
| 642 | + if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) { |
|
| 643 | + add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view)); |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | //this will save any per_page screen options if they are present |
@@ -656,8 +656,8 @@ discard block |
||
| 656 | 656 | //add screen options - global, page child class, and view specific |
| 657 | 657 | $this->_add_global_screen_options(); |
| 658 | 658 | $this->_add_screen_options(); |
| 659 | - if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) |
|
| 660 | - call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
| 659 | + if (method_exists($this, '_add_screen_options_'.$this->_current_view)) |
|
| 660 | + call_user_func(array($this, '_add_screen_options_'.$this->_current_view)); |
|
| 661 | 661 | |
| 662 | 662 | |
| 663 | 663 | //add help tab(s) and tours- set via page_config and qtips. |
@@ -668,33 +668,33 @@ discard block |
||
| 668 | 668 | //add feature_pointers - global, page child class, and view specific |
| 669 | 669 | $this->_add_feature_pointers(); |
| 670 | 670 | $this->_add_global_feature_pointers(); |
| 671 | - if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) |
|
| 672 | - call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
| 671 | + if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) |
|
| 672 | + call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view)); |
|
| 673 | 673 | |
| 674 | 674 | //enqueue scripts/styles - global, page class, and view specific |
| 675 | - add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5 ); |
|
| 676 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10 ); |
|
| 677 | - if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) |
|
| 678 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
| 675 | + add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
|
| 676 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
|
| 677 | + if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) |
|
| 678 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15); |
|
| 679 | 679 | |
| 680 | - add_action('admin_enqueue_scripts', array( $this, 'admin_footer_scripts_eei18n_js_strings' ), 100 ); |
|
| 680 | + add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
|
| 681 | 681 | |
| 682 | 682 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
| 683 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_global' ), 99 ); |
|
| 684 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), 100 ); |
|
| 685 | - if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) |
|
| 686 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
| 683 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
|
| 684 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
|
| 685 | + if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) |
|
| 686 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101); |
|
| 687 | 687 | |
| 688 | 688 | //admin footer scripts |
| 689 | - add_action('admin_footer', array( $this, 'admin_footer_global' ), 99 ); |
|
| 690 | - add_action('admin_footer', array( $this, 'admin_footer'), 100 ); |
|
| 691 | - if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) |
|
| 692 | - add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
| 689 | + add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
|
| 690 | + add_action('admin_footer', array($this, 'admin_footer'), 100); |
|
| 691 | + if (method_exists($this, 'admin_footer_'.$this->_current_view)) |
|
| 692 | + add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101); |
|
| 693 | 693 | |
| 694 | 694 | |
| 695 | - do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug ); |
|
| 695 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
|
| 696 | 696 | //targeted hook |
| 697 | - do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action ); |
|
| 697 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action); |
|
| 698 | 698 | |
| 699 | 699 | } |
| 700 | 700 | |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | private function _set_defaults() { |
| 710 | 710 | $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = NULL; |
| 711 | 711 | |
| 712 | - $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
| 712 | + $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
| 713 | 713 | |
| 714 | 714 | $this->default_nav_tab_name = 'overview'; |
| 715 | 715 | |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | public function route_admin_request() { |
| 737 | 737 | try { |
| 738 | 738 | $this->_route_admin_request(); |
| 739 | - } catch ( EE_Error $e ) { |
|
| 739 | + } catch (EE_Error $e) { |
|
| 740 | 740 | $e->get_error(); |
| 741 | 741 | } |
| 742 | 742 | } |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | $this->_wp_page_slug = $wp_page_slug; |
| 748 | 748 | |
| 749 | 749 | //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls... |
| 750 | - if ( is_network_admin() ) { |
|
| 750 | + if (is_network_admin()) { |
|
| 751 | 751 | $this->_wp_page_slug .= '-network'; |
| 752 | 752 | } |
| 753 | 753 | } |
@@ -760,53 +760,53 @@ discard block |
||
| 760 | 760 | * @return void |
| 761 | 761 | */ |
| 762 | 762 | protected function _verify_routes() { |
| 763 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 763 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 764 | 764 | |
| 765 | - if ( !$this->_current_page && !defined( 'DOING_AJAX')) return FALSE; |
|
| 765 | + if ( ! $this->_current_page && ! defined('DOING_AJAX')) return FALSE; |
|
| 766 | 766 | |
| 767 | 767 | $this->_route = FALSE; |
| 768 | 768 | $func = FALSE; |
| 769 | 769 | $args = array(); |
| 770 | 770 | |
| 771 | 771 | // check that the page_routes array is not empty |
| 772 | - if ( empty( $this->_page_routes )) { |
|
| 772 | + if (empty($this->_page_routes)) { |
|
| 773 | 773 | // user error msg |
| 774 | - $error_msg = sprintf( __('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title ); |
|
| 774 | + $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 775 | 775 | // developer error msg |
| 776 | - $error_msg .= '||' . $error_msg . __( ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso' ); |
|
| 777 | - throw new EE_Error( $error_msg ); |
|
| 776 | + $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
| 777 | + throw new EE_Error($error_msg); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | // and that the requested page route exists |
| 781 | - if ( array_key_exists( $this->_req_action, $this->_page_routes )) { |
|
| 782 | - $this->_route = $this->_page_routes[ $this->_req_action ]; |
|
| 781 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
| 782 | + $this->_route = $this->_page_routes[$this->_req_action]; |
|
| 783 | 783 | $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array(); |
| 784 | 784 | } else { |
| 785 | 785 | // user error msg |
| 786 | - $error_msg = sprintf( __( 'The requested page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
| 786 | + $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 787 | 787 | // developer error msg |
| 788 | - $error_msg .= '||' . $error_msg . sprintf( __( ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso' ), $this->_req_action ); |
|
| 789 | - throw new EE_Error( $error_msg ); |
|
| 788 | + $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
| 789 | + throw new EE_Error($error_msg); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | // and that a default route exists |
| 793 | - if ( ! array_key_exists( 'default', $this->_page_routes )) { |
|
| 793 | + if ( ! array_key_exists('default', $this->_page_routes)) { |
|
| 794 | 794 | // user error msg |
| 795 | - $error_msg = sprintf( __( 'A default page route has not been set for the % admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
| 795 | + $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 796 | 796 | // developer error msg |
| 797 | - $error_msg .= '||' . $error_msg . __( ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso' ); |
|
| 798 | - throw new EE_Error( $error_msg ); |
|
| 797 | + $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
| 798 | + throw new EE_Error($error_msg); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | |
| 802 | 802 | //first lets' catch if the UI request has EVER been set. |
| 803 | - if ( $this->_is_UI_request === NULL ) { |
|
| 803 | + if ($this->_is_UI_request === NULL) { |
|
| 804 | 804 | //lets set if this is a UI request or not. |
| 805 | - $this->_is_UI_request = ( ! isset( $this->_req_data['noheader'] ) || $this->_req_data['noheader'] !== TRUE ) ? TRUE : FALSE; |
|
| 805 | + $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== TRUE) ? TRUE : FALSE; |
|
| 806 | 806 | |
| 807 | 807 | |
| 808 | 808 | //wait a minute... we might have a noheader in the route array |
| 809 | - $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader'] ) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request; |
|
| 809 | + $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request; |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | $this->_set_current_labels(); |
@@ -821,15 +821,15 @@ discard block |
||
| 821 | 821 | * @param string $route the route name we're verifying |
| 822 | 822 | * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
| 823 | 823 | */ |
| 824 | - protected function _verify_route( $route ) { |
|
| 825 | - if ( array_key_exists( $this->_req_action, $this->_page_routes )) { |
|
| 824 | + protected function _verify_route($route) { |
|
| 825 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
| 826 | 826 | return true; |
| 827 | 827 | } else { |
| 828 | 828 | // user error msg |
| 829 | - $error_msg = sprintf( __( 'The given page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
| 829 | + $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 830 | 830 | // developer error msg |
| 831 | - $error_msg .= '||' . $error_msg . sprintf( __( ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso' ), $route ); |
|
| 832 | - throw new EE_Error( $error_msg ); |
|
| 831 | + $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
| 832 | + throw new EE_Error($error_msg); |
|
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | |
@@ -843,18 +843,18 @@ discard block |
||
| 843 | 843 | * @param string $nonce_ref The nonce reference string (name0) |
| 844 | 844 | * @return mixed (bool|die) |
| 845 | 845 | */ |
| 846 | - protected function _verify_nonce( $nonce, $nonce_ref ) { |
|
| 846 | + protected function _verify_nonce($nonce, $nonce_ref) { |
|
| 847 | 847 | // verify nonce against expected value |
| 848 | - if ( ! wp_verify_nonce( $nonce, $nonce_ref) ) { |
|
| 848 | + if ( ! wp_verify_nonce($nonce, $nonce_ref)) { |
|
| 849 | 849 | // these are not the droids you are looking for !!! |
| 850 | - $msg = sprintf(__('%sNonce Fail.%s' , 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>' ); |
|
| 851 | - if ( WP_DEBUG ) { |
|
| 852 | - $msg .= "\n " . sprintf( __('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso' ), __CLASS__ ); |
|
| 850 | + $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
|
| 851 | + if (WP_DEBUG) { |
|
| 852 | + $msg .= "\n ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
| 853 | 853 | } |
| 854 | - if ( ! defined( 'DOING_AJAX' )) { |
|
| 855 | - wp_die( $msg ); |
|
| 854 | + if ( ! defined('DOING_AJAX')) { |
|
| 855 | + wp_die($msg); |
|
| 856 | 856 | } else { |
| 857 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 857 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 858 | 858 | $this->_return_json(); |
| 859 | 859 | } |
| 860 | 860 | } |
@@ -872,63 +872,63 @@ discard block |
||
| 872 | 872 | * @return void |
| 873 | 873 | */ |
| 874 | 874 | protected function _route_admin_request() { |
| 875 | - if ( ! $this->_is_UI_request ) |
|
| 875 | + if ( ! $this->_is_UI_request) |
|
| 876 | 876 | $this->_verify_routes(); |
| 877 | 877 | |
| 878 | - $nonce_check = isset( $this->_route_config['require_nonce'] ) ? $this->_route_config['require_nonce'] : TRUE; |
|
| 878 | + $nonce_check = isset($this->_route_config['require_nonce']) ? $this->_route_config['require_nonce'] : TRUE; |
|
| 879 | 879 | |
| 880 | - if ( $this->_req_action != 'default' && $nonce_check ) { |
|
| 880 | + if ($this->_req_action != 'default' && $nonce_check) { |
|
| 881 | 881 | // set nonce from post data |
| 882 | - $nonce = isset($this->_req_data[ $this->_req_nonce ]) ? sanitize_text_field( $this->_req_data[ $this->_req_nonce ] ) : ''; |
|
| 883 | - $this->_verify_nonce( $nonce, $this->_req_nonce ); |
|
| 882 | + $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 883 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 884 | 884 | } |
| 885 | 885 | //set the nav_tabs array but ONLY if this is UI_request |
| 886 | - if ( $this->_is_UI_request ) |
|
| 886 | + if ($this->_is_UI_request) |
|
| 887 | 887 | $this->_set_nav_tabs(); |
| 888 | 888 | |
| 889 | 889 | // grab callback function |
| 890 | - $func = is_array( $this->_route ) ? $this->_route['func'] : $this->_route; |
|
| 890 | + $func = is_array($this->_route) ? $this->_route['func'] : $this->_route; |
|
| 891 | 891 | |
| 892 | 892 | // check if callback has args |
| 893 | - $args = is_array( $this->_route ) && isset( $this->_route['args'] ) ? $this->_route['args'] : array(); |
|
| 893 | + $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array(); |
|
| 894 | 894 | |
| 895 | 895 | $error_msg = ''; |
| 896 | 896 | |
| 897 | 897 | //action right before calling route (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request') |
| 898 | - if ( !did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
| 899 | - do_action( 'AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this ); |
|
| 898 | + if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
| 899 | + do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | //right before calling the route, let's remove _wp_http_referer from the $_SERVER[REQUEST_URI] global (its now in _req_data for route processing). |
| 903 | - $_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
| 903 | + $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI'])); |
|
| 904 | 904 | |
| 905 | - if ( ! empty( $func )) { |
|
| 905 | + if ( ! empty($func)) { |
|
| 906 | 906 | $base_call = $addon_call = FALSE; |
| 907 | 907 | //try to access page route via this class |
| 908 | - if ( ! is_array( $func ) && method_exists( $this, $func ) && ( $base_call = call_user_func_array( array( $this, &$func ), $args ) ) === FALSE ) { |
|
| 908 | + if ( ! is_array($func) && method_exists($this, $func) && ($base_call = call_user_func_array(array($this, &$func), $args)) === FALSE) { |
|
| 909 | 909 | // user error msg |
| 910 | - $error_msg = __( 'An error occurred. The requested page route could not be found.', 'event_espresso' ); |
|
| 910 | + $error_msg = __('An error occurred. The requested page route could not be found.', 'event_espresso'); |
|
| 911 | 911 | // developer error msg |
| 912 | - $error_msg .= '||' . sprintf( __( 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso' ), $func ); |
|
| 912 | + $error_msg .= '||'.sprintf(__('Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso'), $func); |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | //for pluggability by addons first let's see if just the function exists (this will also work in the case where $func is an array indicating class/method) |
| 916 | 916 | $args['admin_page_object'] = $this; //send along this admin page object for access by addons. |
| 917 | 917 | |
| 918 | - if ( $base_call === FALSE && ( $addon_call = call_user_func_array( $func, $args ) )=== FALSE ) { |
|
| 919 | - $error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso' ); |
|
| 920 | - $error_msg .= '||' . sprintf( __('Page route "%s" could not be called. Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func ); |
|
| 918 | + if ($base_call === FALSE && ($addon_call = call_user_func_array($func, $args)) === FALSE) { |
|
| 919 | + $error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso'); |
|
| 920 | + $error_msg .= '||'.sprintf(__('Page route "%s" could not be called. Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | |
| 924 | - if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) |
|
| 925 | - throw new EE_Error( $error_msg ); |
|
| 924 | + if ( ! empty($error_msg) && $base_call === FALSE && $addon_call === FALSE) |
|
| 925 | + throw new EE_Error($error_msg); |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
| 929 | 929 | //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent. |
| 930 | - if ( $this->_is_UI_request === FALSE && is_array( $this->_route) && ! empty( $this->_route['headers_sent_route'] ) ) { |
|
| 931 | - $this->_reset_routing_properties( $this->_route['headers_sent_route'] ); |
|
| 930 | + if ($this->_is_UI_request === FALSE && is_array($this->_route) && ! empty($this->_route['headers_sent_route'])) { |
|
| 931 | + $this->_reset_routing_properties($this->_route['headers_sent_route']); |
|
| 932 | 932 | } |
| 933 | 933 | } |
| 934 | 934 | |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | * @param string $new_route New (non header) route to redirect to. |
| 945 | 945 | * @return void |
| 946 | 946 | */ |
| 947 | - protected function _reset_routing_properties( $new_route ) { |
|
| 947 | + protected function _reset_routing_properties($new_route) { |
|
| 948 | 948 | $this->_is_UI_request = TRUE; |
| 949 | 949 | //now we set the current route to whatever the headers_sent_route is set at |
| 950 | 950 | $this->_req_data['action'] = $new_route; |
@@ -990,23 +990,23 @@ discard block |
||
| 990 | 990 | * @param bool $exclude_nonce If true, the the nonce will be excluded from the generated nonce. |
| 991 | 991 | * @return string |
| 992 | 992 | */ |
| 993 | - public static function add_query_args_and_nonce( $args = array(), $url = false, $sticky = false, $exclude_nonce = false ) { |
|
| 993 | + public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) { |
|
| 994 | 994 | |
| 995 | 995 | //if there is a _wp_http_referer include the values from the request but only if sticky = true |
| 996 | - if ( $sticky ) { |
|
| 996 | + if ($sticky) { |
|
| 997 | 997 | $request = $_REQUEST; |
| 998 | - unset( $request['_wp_http_referer'] ); |
|
| 999 | - unset( $request['wp_referer'] ); |
|
| 1000 | - foreach ( $request as $key => $value ) { |
|
| 998 | + unset($request['_wp_http_referer']); |
|
| 999 | + unset($request['wp_referer']); |
|
| 1000 | + foreach ($request as $key => $value) { |
|
| 1001 | 1001 | //do not add nonces |
| 1002 | - if ( strpos( $key, 'nonce' ) !== false ) { |
|
| 1002 | + if (strpos($key, 'nonce') !== false) { |
|
| 1003 | 1003 | continue; |
| 1004 | 1004 | } |
| 1005 | - $args['wp_referer[' . $key . ']'] = $value; |
|
| 1005 | + $args['wp_referer['.$key.']'] = $value; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - return EEH_URL::add_query_args_and_nonce( $args, $url, $exclude_nonce ); |
|
| 1009 | + return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
|
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | |
@@ -1022,8 +1022,8 @@ discard block |
||
| 1022 | 1022 | * @uses EEH_Template::get_help_tab_link() |
| 1023 | 1023 | * @return string generated link |
| 1024 | 1024 | */ |
| 1025 | - protected function _get_help_tab_link( $help_tab_id, $icon_style = FALSE, $help_text = FALSE ) { |
|
| 1026 | - return EEH_Template::get_help_tab_link( $help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text ); |
|
| 1025 | + protected function _get_help_tab_link($help_tab_id, $icon_style = FALSE, $help_text = FALSE) { |
|
| 1026 | + return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text); |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | |
@@ -1040,30 +1040,30 @@ discard block |
||
| 1040 | 1040 | */ |
| 1041 | 1041 | protected function _add_help_tabs() { |
| 1042 | 1042 | $tour_buttons = ''; |
| 1043 | - if ( isset( $this->_page_config[$this->_req_action] ) ) { |
|
| 1043 | + if (isset($this->_page_config[$this->_req_action])) { |
|
| 1044 | 1044 | $config = $this->_page_config[$this->_req_action]; |
| 1045 | 1045 | |
| 1046 | 1046 | //is there a help tour for the current route? if there is let's setup the tour buttons |
| 1047 | - if ( isset( $this->_help_tour[$this->_req_action]) ) { |
|
| 1047 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
| 1048 | 1048 | $tb = array(); |
| 1049 | 1049 | $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
| 1050 | - foreach ( $this->_help_tour['tours'] as $tour ) { |
|
| 1050 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
| 1051 | 1051 | //if this is the end tour then we don't need to setup a button |
| 1052 | - if ( $tour instanceof EE_Help_Tour_final_stop ) |
|
| 1052 | + if ($tour instanceof EE_Help_Tour_final_stop) |
|
| 1053 | 1053 | continue; |
| 1054 | - $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
| 1054 | + $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>'; |
|
| 1055 | 1055 | } |
| 1056 | 1056 | $tour_buttons .= implode('<br />', $tb); |
| 1057 | 1057 | $tour_buttons .= '</div></div>'; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
| 1061 | - if ( is_array( $config ) && isset( $config['help_sidebar'] ) ) { |
|
| 1061 | + if (is_array($config) && isset($config['help_sidebar'])) { |
|
| 1062 | 1062 | //check that the callback given is valid |
| 1063 | - if ( !method_exists($this, $config['help_sidebar'] ) ) |
|
| 1064 | - throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
| 1063 | + if ( ! method_exists($this, $config['help_sidebar'])) |
|
| 1064 | + throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this))); |
|
| 1065 | 1065 | |
| 1066 | - $content = apply_filters( 'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func( array( $this, $config['help_sidebar'] ) ) ); |
|
| 1066 | + $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
| 1067 | 1067 | |
| 1068 | 1068 | $content .= $tour_buttons; //add help tour buttons. |
| 1069 | 1069 | |
@@ -1072,49 +1072,49 @@ discard block |
||
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar. |
| 1075 | - if ( !isset( $config['help_sidebar'] ) && !empty( $tour_buttons ) ) { |
|
| 1075 | + if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) { |
|
| 1076 | 1076 | $this->_current_screen->set_help_sidebar($tour_buttons); |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | //handle if no help_tabs are set so the sidebar will still show for the help tour buttons |
| 1080 | - if ( !isset( $config['help_tabs'] ) && !empty($tour_buttons) ) { |
|
| 1080 | + if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
|
| 1081 | 1081 | $_ht['id'] = $this->page_slug; |
| 1082 | 1082 | $_ht['title'] = __('Help Tours', 'event_espresso'); |
| 1083 | - $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
| 1083 | + $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>'; |
|
| 1084 | 1084 | $this->_current_screen->add_help_tab($_ht); |
| 1085 | 1085 | }/**/ |
| 1086 | 1086 | |
| 1087 | 1087 | |
| 1088 | - if ( !isset( $config['help_tabs'] ) ) return; //no help tabs for this route |
|
| 1088 | + if ( ! isset($config['help_tabs'])) return; //no help tabs for this route |
|
| 1089 | 1089 | |
| 1090 | - foreach ( (array) $config['help_tabs'] as $tab_id => $cfg ) { |
|
| 1090 | + foreach ((array) $config['help_tabs'] as $tab_id => $cfg) { |
|
| 1091 | 1091 | //we're here so there ARE help tabs! |
| 1092 | 1092 | |
| 1093 | 1093 | //make sure we've got what we need |
| 1094 | - if ( !isset( $cfg['title'] ) ) |
|
| 1095 | - throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
| 1094 | + if ( ! isset($cfg['title'])) |
|
| 1095 | + throw new EE_Error(__('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso')); |
|
| 1096 | 1096 | |
| 1097 | 1097 | |
| 1098 | - if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) |
|
| 1099 | - throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
| 1098 | + if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) |
|
| 1099 | + throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso')); |
|
| 1100 | 1100 | |
| 1101 | 1101 | |
| 1102 | 1102 | |
| 1103 | 1103 | //first priority goes to content. |
| 1104 | - if ( !empty($cfg['content'] ) ) { |
|
| 1105 | - $content = !empty($cfg['content']) ? $cfg['content'] : NULL; |
|
| 1104 | + if ( ! empty($cfg['content'])) { |
|
| 1105 | + $content = ! empty($cfg['content']) ? $cfg['content'] : NULL; |
|
| 1106 | 1106 | |
| 1107 | 1107 | //second priority goes to filename |
| 1108 | - } else if ( !empty($cfg['filename'] ) ) { |
|
| 1109 | - $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
| 1108 | + } else if ( ! empty($cfg['filename'])) { |
|
| 1109 | + $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php'; |
|
| 1110 | 1110 | |
| 1111 | 1111 | |
| 1112 | 1112 | //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
| 1113 | - $file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
| 1113 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path; |
|
| 1114 | 1114 | |
| 1115 | 1115 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
| 1116 | - if ( !is_readable($file_path) && !isset($cfg['callback']) ) { |
|
| 1117 | - EE_Error::add_error( sprintf( __('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1116 | + if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
|
| 1117 | + EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__); |
|
| 1118 | 1118 | return; |
| 1119 | 1119 | } |
| 1120 | 1120 | $template_args['admin_page_obj'] = $this; |
@@ -1125,21 +1125,21 @@ discard block |
||
| 1125 | 1125 | |
| 1126 | 1126 | |
| 1127 | 1127 | //check if callback is valid |
| 1128 | - if ( empty($content) && ( !isset($cfg['callback']) || !method_exists( $this, $cfg['callback'] ) ) ) { |
|
| 1129 | - EE_Error::add_error( sprintf( __('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1128 | + if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) { |
|
| 1129 | + EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__); |
|
| 1130 | 1130 | return; |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | //setup config array for help tab method |
| 1134 | - $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
| 1134 | + $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id; |
|
| 1135 | 1135 | $_ht = array( |
| 1136 | 1136 | 'id' => $id, |
| 1137 | 1137 | 'title' => $cfg['title'], |
| 1138 | - 'callback' => isset( $cfg['callback'] ) && empty($content) ? array( $this, $cfg['callback'] ) : NULL, |
|
| 1138 | + 'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : NULL, |
|
| 1139 | 1139 | 'content' => $content |
| 1140 | 1140 | ); |
| 1141 | 1141 | |
| 1142 | - $this->_current_screen->add_help_tab( $_ht ); |
|
| 1142 | + $this->_current_screen->add_help_tab($_ht); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | 1145 | } |
@@ -1159,49 +1159,49 @@ discard block |
||
| 1159 | 1159 | $this->_help_tour = array(); |
| 1160 | 1160 | |
| 1161 | 1161 | //exit early if help tours are turned off globally |
| 1162 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) |
|
| 1162 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) |
|
| 1163 | 1163 | return; |
| 1164 | 1164 | |
| 1165 | 1165 | //loop through _page_config to find any help_tour defined |
| 1166 | - foreach ( $this->_page_config as $route => $config ) { |
|
| 1166 | + foreach ($this->_page_config as $route => $config) { |
|
| 1167 | 1167 | //we're only going to set things up for this route |
| 1168 | - if ( $route !== $this->_req_action ) |
|
| 1168 | + if ($route !== $this->_req_action) |
|
| 1169 | 1169 | continue; |
| 1170 | 1170 | |
| 1171 | - if ( isset( $config['help_tour'] ) ) { |
|
| 1171 | + if (isset($config['help_tour'])) { |
|
| 1172 | 1172 | |
| 1173 | - foreach( $config['help_tour'] as $tour ) { |
|
| 1174 | - $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
| 1173 | + foreach ($config['help_tour'] as $tour) { |
|
| 1174 | + $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php'; |
|
| 1175 | 1175 | //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
| 1176 | - $file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
| 1176 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path; |
|
| 1177 | 1177 | |
| 1178 | 1178 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
| 1179 | - if ( !is_readable($file_path) ) { |
|
| 1180 | - EE_Error::add_error( sprintf( __('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1179 | + if ( ! is_readable($file_path)) { |
|
| 1180 | + EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour), __FILE__, __FUNCTION__, __LINE__); |
|
| 1181 | 1181 | return; |
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | require_once $file_path; |
| 1185 | - if ( !class_exists( $tour ) ) { |
|
| 1186 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso' ), $tour); |
|
| 1187 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this) ); |
|
| 1188 | - throw new EE_Error( implode( '||', $error_msg )); |
|
| 1185 | + if ( ! class_exists($tour)) { |
|
| 1186 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
|
| 1187 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
|
| 1188 | + throw new EE_Error(implode('||', $error_msg)); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | $a = new ReflectionClass($tour); |
| 1191 | 1191 | $tour_obj = $a->newInstance($this->_is_caf); |
| 1192 | 1192 | |
| 1193 | 1193 | $tours[] = $tour_obj; |
| 1194 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $tour_obj ); |
|
| 1194 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | //let's inject the end tour stop element common to all pages... this will only get seen once per machine. |
| 1198 | 1198 | $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf); |
| 1199 | 1199 | $tours[] = $end_stop_tour; |
| 1200 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $end_stop_tour ); |
|
| 1200 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour); |
|
| 1201 | 1201 | } |
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | - if ( !empty( $tours ) ) |
|
| 1204 | + if ( ! empty($tours)) |
|
| 1205 | 1205 | $this->_help_tour['tours'] = $tours; |
| 1206 | 1206 | |
| 1207 | 1207 | //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
@@ -1217,12 +1217,12 @@ discard block |
||
| 1217 | 1217 | * @return void |
| 1218 | 1218 | */ |
| 1219 | 1219 | protected function _add_qtips() { |
| 1220 | - if ( isset( $this->_route_config['qtips'] ) ) { |
|
| 1220 | + if (isset($this->_route_config['qtips'])) { |
|
| 1221 | 1221 | $qtips = (array) $this->_route_config['qtips']; |
| 1222 | 1222 | //load qtip loader |
| 1223 | 1223 | $path = array( |
| 1224 | - $this->_get_dir() . '/qtips/', |
|
| 1225 | - EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/' |
|
| 1224 | + $this->_get_dir().'/qtips/', |
|
| 1225 | + EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/' |
|
| 1226 | 1226 | ); |
| 1227 | 1227 | EEH_Qtip_Loader::instance()->register($qtips, $path); |
| 1228 | 1228 | } |
@@ -1239,41 +1239,41 @@ discard block |
||
| 1239 | 1239 | * @return void |
| 1240 | 1240 | */ |
| 1241 | 1241 | protected function _set_nav_tabs() { |
| 1242 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1242 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1243 | 1243 | $i = 0; |
| 1244 | - foreach ( $this->_page_config as $slug => $config ) { |
|
| 1245 | - if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) |
|
| 1244 | + foreach ($this->_page_config as $slug => $config) { |
|
| 1245 | + if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) |
|
| 1246 | 1246 | continue; //no nav tab for this config |
| 1247 | 1247 | |
| 1248 | 1248 | //check for persistent flag |
| 1249 | - if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) |
|
| 1249 | + if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) |
|
| 1250 | 1250 | continue; //nav tab is only to appear when route requested. |
| 1251 | 1251 | |
| 1252 | - if ( ! $this->check_user_access( $slug, TRUE ) ) |
|
| 1252 | + if ( ! $this->check_user_access($slug, TRUE)) |
|
| 1253 | 1253 | continue; //no nav tab becasue current user does not have access. |
| 1254 | 1254 | |
| 1255 | - $css_class = isset( $config['css_class'] ) ? $config['css_class'] . ' ' : ''; |
|
| 1255 | + $css_class = isset($config['css_class']) ? $config['css_class'].' ' : ''; |
|
| 1256 | 1256 | $this->_nav_tabs[$slug] = array( |
| 1257 | - 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce( array( 'action'=>$slug ), $this->_admin_base_url ), |
|
| 1258 | - 'link_text' => isset( $config['nav']['label'] ) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug ) ), |
|
| 1259 | - 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
| 1260 | - 'order' => isset( $config['nav']['order'] ) ? $config['nav']['order'] : $i |
|
| 1257 | + 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action'=>$slug), $this->_admin_base_url), |
|
| 1258 | + 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
|
| 1259 | + 'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class, |
|
| 1260 | + 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i |
|
| 1261 | 1261 | ); |
| 1262 | 1262 | $i++; |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | //if $this->_nav_tabs is empty then lets set the default |
| 1266 | - if ( empty( $this->_nav_tabs ) ) { |
|
| 1266 | + if (empty($this->_nav_tabs)) { |
|
| 1267 | 1267 | $this->_nav_tabs[$this->default_nav_tab_name] = array( |
| 1268 | 1268 | 'url' => $this->admin_base_url, |
| 1269 | - 'link_text' => ucwords( str_replace( '_', ' ', $this->default_nav_tab_name ) ), |
|
| 1269 | + 'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)), |
|
| 1270 | 1270 | 'css_class' => 'nav-tab-active', |
| 1271 | 1271 | 'order' => 10 |
| 1272 | 1272 | ); |
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | //now let's sort the tabs according to order |
| 1276 | - usort( $this->_nav_tabs, array($this, '_sort_nav_tabs' )); |
|
| 1276 | + usort($this->_nav_tabs, array($this, '_sort_nav_tabs')); |
|
| 1277 | 1277 | |
| 1278 | 1278 | } |
| 1279 | 1279 | |
@@ -1289,10 +1289,10 @@ discard block |
||
| 1289 | 1289 | * @return void |
| 1290 | 1290 | */ |
| 1291 | 1291 | private function _set_current_labels() { |
| 1292 | - if ( is_array($this->_route_config) && isset($this->_route_config['labels']) ) { |
|
| 1293 | - foreach ( $this->_route_config['labels'] as $label => $text ) { |
|
| 1294 | - if ( is_array($text) ) { |
|
| 1295 | - foreach ( $text as $sublabel => $subtext ) { |
|
| 1292 | + if (is_array($this->_route_config) && isset($this->_route_config['labels'])) { |
|
| 1293 | + foreach ($this->_route_config['labels'] as $label => $text) { |
|
| 1294 | + if (is_array($text)) { |
|
| 1295 | + foreach ($text as $sublabel => $subtext) { |
|
| 1296 | 1296 | $this->_labels[$label][$sublabel] = $subtext; |
| 1297 | 1297 | } |
| 1298 | 1298 | } else { |
@@ -1313,24 +1313,24 @@ discard block |
||
| 1313 | 1313 | * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
| 1314 | 1314 | * @return BOOL|wp_die() |
| 1315 | 1315 | */ |
| 1316 | - public function check_user_access( $route_to_check = '', $verify_only = FALSE ) { |
|
| 1317 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1318 | - $route_to_check = empty( $route_to_check ) ? $this->_req_action : $route_to_check; |
|
| 1319 | - $capability = ! empty( $route_to_check ) && isset( $this->_page_routes[$route_to_check] ) && is_array( $this->_page_routes[$route_to_check] ) && ! empty( $this->_page_routes[$route_to_check]['capability'] ) ? $this->_page_routes[$route_to_check]['capability'] : NULL; |
|
| 1316 | + public function check_user_access($route_to_check = '', $verify_only = FALSE) { |
|
| 1317 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1318 | + $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check; |
|
| 1319 | + $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) ? $this->_page_routes[$route_to_check]['capability'] : NULL; |
|
| 1320 | 1320 | |
| 1321 | - if ( empty( $capability ) && empty( $route_to_check ) ) { |
|
| 1322 | - $capability = is_array( $this->_route ) && empty( $this->_route['capability'] ) ? 'manage_options' : $this->_route['capability']; |
|
| 1321 | + if (empty($capability) && empty($route_to_check)) { |
|
| 1322 | + $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability']; |
|
| 1323 | 1323 | } else { |
| 1324 | - $capability = empty( $capability ) ? 'manage_options' : $capability; |
|
| 1324 | + $capability = empty($capability) ? 'manage_options' : $capability; |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | - $id = is_array( $this->_route ) && ! empty( $this->_route['obj_id'] ) ? $this->_route['obj_id'] : 0; |
|
| 1327 | + $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
|
| 1328 | 1328 | |
| 1329 | - if (( ! function_exists( 'is_admin' ) || ! EE_Registry::instance()->CAP->current_user_can( $capability, $this->page_slug . '_' . $route_to_check, $id ) ) && ! defined( 'DOING_AJAX')) { |
|
| 1330 | - if ( $verify_only ) { |
|
| 1329 | + if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
| 1330 | + if ($verify_only) { |
|
| 1331 | 1331 | return FALSE; |
| 1332 | 1332 | } else { |
| 1333 | - wp_die( __('You do not have access to this route.', 'event_espresso' ) ); |
|
| 1333 | + wp_die(__('You do not have access to this route.', 'event_espresso')); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | } |
| 1336 | 1336 | return TRUE; |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | $this->_add_admin_page_overlay(); |
| 1408 | 1408 | |
| 1409 | 1409 | //if metaboxes are present we need to add the nonce field |
| 1410 | - if ( ( isset($this->_route_config['metaboxes']) || ( isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'] ) || isset($this->_route_config['list_table']) ) ) { |
|
| 1410 | + if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) { |
|
| 1411 | 1411 | wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
| 1412 | 1412 | wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
| 1413 | 1413 | } |
@@ -1426,19 +1426,19 @@ discard block |
||
| 1426 | 1426 | */ |
| 1427 | 1427 | public function admin_footer_global() { |
| 1428 | 1428 | //dialog container for dialog helper |
| 1429 | - $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
| 1429 | + $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n"; |
|
| 1430 | 1430 | $d_cont .= '<div class="ee-notices"></div>'; |
| 1431 | 1431 | $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
| 1432 | 1432 | $d_cont .= '</div>'; |
| 1433 | 1433 | echo $d_cont; |
| 1434 | 1434 | |
| 1435 | 1435 | //help tour stuff? |
| 1436 | - if ( isset( $this->_help_tour[$this->_req_action] ) ) { |
|
| 1436 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
| 1437 | 1437 | echo implode('<br />', $this->_help_tour[$this->_req_action]); |
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | //current set timezone for timezone js |
| 1441 | - echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
| 1441 | + echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>'; |
|
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | |
@@ -1462,18 +1462,18 @@ discard block |
||
| 1462 | 1462 | * @access protected |
| 1463 | 1463 | * @return string content |
| 1464 | 1464 | */ |
| 1465 | - protected function _set_help_popup_content( $help_array = array(), $display = FALSE ) { |
|
| 1465 | + protected function _set_help_popup_content($help_array = array(), $display = FALSE) { |
|
| 1466 | 1466 | $content = ''; |
| 1467 | 1467 | |
| 1468 | - $help_array = empty( $help_array ) ? $this->_get_help_content() : $help_array; |
|
| 1469 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
| 1468 | + $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
|
| 1469 | + $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php'; |
|
| 1470 | 1470 | |
| 1471 | 1471 | |
| 1472 | 1472 | //loop through the array and setup content |
| 1473 | - foreach ( $help_array as $trigger => $help ) { |
|
| 1473 | + foreach ($help_array as $trigger => $help) { |
|
| 1474 | 1474 | //make sure the array is setup properly |
| 1475 | - if ( !isset($help['title']) || !isset($help['content'] ) ) { |
|
| 1476 | - throw new EE_Error( __('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso') ); |
|
| 1475 | + if ( ! isset($help['title']) || ! isset($help['content'])) { |
|
| 1476 | + throw new EE_Error(__('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso')); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | //we're good so let'd setup the template vars and then assign parsed template content to our content. |
@@ -1483,10 +1483,10 @@ discard block |
||
| 1483 | 1483 | 'help_popup_content' => $help['content'] |
| 1484 | 1484 | ); |
| 1485 | 1485 | |
| 1486 | - $content .= EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 1486 | + $content .= EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | - if ( $display ) |
|
| 1489 | + if ($display) |
|
| 1490 | 1490 | echo $content; |
| 1491 | 1491 | else |
| 1492 | 1492 | return $content; |
@@ -1503,18 +1503,18 @@ discard block |
||
| 1503 | 1503 | */ |
| 1504 | 1504 | private function _get_help_content() { |
| 1505 | 1505 | //what is the method we're looking for? |
| 1506 | - $method_name = '_help_popup_content_' . $this->_req_action; |
|
| 1506 | + $method_name = '_help_popup_content_'.$this->_req_action; |
|
| 1507 | 1507 | |
| 1508 | 1508 | //if method doesn't exist let's get out. |
| 1509 | - if ( !method_exists( $this, $method_name ) ) |
|
| 1509 | + if ( ! method_exists($this, $method_name)) |
|
| 1510 | 1510 | return array(); |
| 1511 | 1511 | |
| 1512 | 1512 | //k we're good to go let's retrieve the help array |
| 1513 | - $help_array = call_user_func( array( $this, $method_name ) ); |
|
| 1513 | + $help_array = call_user_func(array($this, $method_name)); |
|
| 1514 | 1514 | |
| 1515 | 1515 | //make sure we've got an array! |
| 1516 | - if ( !is_array($help_array) ) { |
|
| 1517 | - throw new EE_Error( __('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso' ) ); |
|
| 1516 | + if ( ! is_array($help_array)) { |
|
| 1517 | + throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso')); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | return $help_array; |
@@ -1536,27 +1536,27 @@ discard block |
||
| 1536 | 1536 | * @param array $dimensions an array of dimensions for the box (array(h,w)) |
| 1537 | 1537 | * @return string |
| 1538 | 1538 | */ |
| 1539 | - protected function _set_help_trigger( $trigger_id, $display = TRUE, $dimensions = array( '400', '640') ) { |
|
| 1539 | + protected function _set_help_trigger($trigger_id, $display = TRUE, $dimensions = array('400', '640')) { |
|
| 1540 | 1540 | |
| 1541 | - if ( defined('DOING_AJAX') ) return; |
|
| 1541 | + if (defined('DOING_AJAX')) return; |
|
| 1542 | 1542 | |
| 1543 | 1543 | //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
| 1544 | 1544 | $help_array = $this->_get_help_content(); |
| 1545 | 1545 | $help_content = ''; |
| 1546 | 1546 | |
| 1547 | - if ( empty( $help_array ) || !isset( $help_array[$trigger_id] ) ) { |
|
| 1547 | + if (empty($help_array) || ! isset($help_array[$trigger_id])) { |
|
| 1548 | 1548 | $help_array[$trigger_id] = array( |
| 1549 | 1549 | 'title' => __('Missing Content', 'event_espresso'), |
| 1550 | 1550 | 'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', 'event_espresso') |
| 1551 | 1551 | ); |
| 1552 | - $help_content = $this->_set_help_popup_content( $help_array, FALSE ); |
|
| 1552 | + $help_content = $this->_set_help_popup_content($help_array, FALSE); |
|
| 1553 | 1553 | } |
| 1554 | 1554 | |
| 1555 | 1555 | //let's setup the trigger |
| 1556 | - $content = '<a class="ee-dialog" href="?height='. $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
| 1557 | - $content = $content . $help_content; |
|
| 1556 | + $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
| 1557 | + $content = $content.$help_content; |
|
| 1558 | 1558 | |
| 1559 | - if ( $display ) |
|
| 1559 | + if ($display) |
|
| 1560 | 1560 | echo $content; |
| 1561 | 1561 | else |
| 1562 | 1562 | return $content; |
@@ -1613,15 +1613,15 @@ discard block |
||
| 1613 | 1613 | public function load_global_scripts_styles() { |
| 1614 | 1614 | /** STYLES **/ |
| 1615 | 1615 | // add debugging styles |
| 1616 | - if ( WP_DEBUG ) { |
|
| 1617 | - add_action('admin_head', array( $this, 'add_xdebug_style' )); |
|
| 1616 | + if (WP_DEBUG) { |
|
| 1617 | + add_action('admin_head', array($this, 'add_xdebug_style')); |
|
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | 1620 | //register all styles |
| 1621 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(),EVENT_ESPRESSO_VERSION ); |
|
| 1622 | - wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1621 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1622 | + wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1623 | 1623 | //helpers styles |
| 1624 | - wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 1624 | + wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1625 | 1625 | //enqueue global styles |
| 1626 | 1626 | wp_enqueue_style('ee-admin-css'); |
| 1627 | 1627 | |
@@ -1629,66 +1629,66 @@ discard block |
||
| 1629 | 1629 | /** SCRIPTS **/ |
| 1630 | 1630 | |
| 1631 | 1631 | //register all scripts |
| 1632 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1633 | - wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1634 | - wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array( 'espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true ); |
|
| 1632 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1633 | + wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1634 | + wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
| 1635 | 1635 | |
| 1636 | - wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true ); |
|
| 1636 | + wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
| 1637 | 1637 | // register jQuery Validate - see /includes/functions/wp_hooks.php |
| 1638 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
| 1638 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
| 1639 | 1639 | add_filter('FHEE_load_joyride', '__return_true'); |
| 1640 | 1640 | |
| 1641 | 1641 | //script for sorting tables |
| 1642 | - wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1642 | + wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1643 | 1643 | //script for parsing uri's |
| 1644 | - wp_register_script( 'ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1644 | + wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1645 | 1645 | //and parsing associative serialized form elements |
| 1646 | - wp_register_script( 'ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1646 | + wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1647 | 1647 | //helpers scripts |
| 1648 | - wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1649 | - wp_register_script( 'ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1650 | - wp_register_script( 'ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1651 | - wp_register_script( 'ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon','ee-moment'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1648 | + wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1649 | + wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1650 | + wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1651 | + wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1652 | 1652 | |
| 1653 | 1653 | //google charts |
| 1654 | - wp_register_script( 'google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false ); |
|
| 1654 | + wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
|
| 1655 | 1655 | |
| 1656 | 1656 | //enqueue global scripts |
| 1657 | 1657 | |
| 1658 | 1658 | //taking care of metaboxes |
| 1659 | - if ( ( isset($this->_route_config['metaboxes'] ) || isset($this->_route_config['has_metaboxes']) ) && empty( $this->_cpt_route) ) { |
|
| 1659 | + if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) { |
|
| 1660 | 1660 | wp_enqueue_script('dashboard'); |
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | //enqueue thickbox for ee help popups. default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups |
| 1664 | - if ( ! isset( $this->_route_config['has_help_popups']) || ( isset( $this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'] ) ) { |
|
| 1664 | + if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) { |
|
| 1665 | 1665 | wp_enqueue_script('ee_admin_js'); |
| 1666 | 1666 | wp_enqueue_style('ee-admin-css'); |
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | |
| 1670 | 1670 | //localize script for ajax lazy loading |
| 1671 | - $lazy_loader_container_ids = apply_filters( 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content') ); |
|
| 1672 | - wp_localize_script( 'ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
| 1671 | + $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content')); |
|
| 1672 | + wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
| 1673 | 1673 | |
| 1674 | 1674 | |
| 1675 | 1675 | /** |
| 1676 | 1676 | * help tour stuff |
| 1677 | 1677 | */ |
| 1678 | - if ( !empty( $this->_help_tour ) ) { |
|
| 1678 | + if ( ! empty($this->_help_tour)) { |
|
| 1679 | 1679 | |
| 1680 | 1680 | //register the js for kicking things off |
| 1681 | - wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1681 | + wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1682 | 1682 | |
| 1683 | 1683 | //setup tours for the js tour object |
| 1684 | - foreach ( $this->_help_tour['tours'] as $tour ) { |
|
| 1684 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
| 1685 | 1685 | $tours[] = array( |
| 1686 | 1686 | 'id' => $tour->get_slug(), |
| 1687 | 1687 | 'options' => $tour->get_options() |
| 1688 | 1688 | ); |
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | - wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours ) ); |
|
| 1691 | + wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours)); |
|
| 1692 | 1692 | |
| 1693 | 1693 | //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour |
| 1694 | 1694 | } |
@@ -1706,52 +1706,52 @@ discard block |
||
| 1706 | 1706 | public function admin_footer_scripts_eei18n_js_strings() { |
| 1707 | 1707 | |
| 1708 | 1708 | EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
| 1709 | - EE_Registry::$i18n_js_strings['confirm_delete'] = __( 'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso' ); |
|
| 1710 | - |
|
| 1711 | - EE_Registry::$i18n_js_strings['January'] = __( 'January', 'event_espresso' ); |
|
| 1712 | - EE_Registry::$i18n_js_strings['February'] = __( 'February', 'event_espresso' ); |
|
| 1713 | - EE_Registry::$i18n_js_strings['March'] = __( 'March', 'event_espresso' ); |
|
| 1714 | - EE_Registry::$i18n_js_strings['April'] = __( 'April', 'event_espresso' ); |
|
| 1715 | - EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' ); |
|
| 1716 | - EE_Registry::$i18n_js_strings['June'] = __( 'June', 'event_espresso' ); |
|
| 1717 | - EE_Registry::$i18n_js_strings['July'] = __( 'July', 'event_espresso' ); |
|
| 1718 | - EE_Registry::$i18n_js_strings['August'] = __( 'August', 'event_espresso' ); |
|
| 1719 | - EE_Registry::$i18n_js_strings['September'] = __( 'September', 'event_espresso' ); |
|
| 1720 | - EE_Registry::$i18n_js_strings['October'] = __( 'October', 'event_espresso' ); |
|
| 1721 | - EE_Registry::$i18n_js_strings['November'] = __( 'November', 'event_espresso' ); |
|
| 1722 | - EE_Registry::$i18n_js_strings['December'] = __( 'December', 'event_espresso' ); |
|
| 1723 | - EE_Registry::$i18n_js_strings['Jan'] = __( 'Jan', 'event_espresso' ); |
|
| 1724 | - EE_Registry::$i18n_js_strings['Feb'] = __( 'Feb', 'event_espresso' ); |
|
| 1725 | - EE_Registry::$i18n_js_strings['Mar'] = __( 'Mar', 'event_espresso' ); |
|
| 1726 | - EE_Registry::$i18n_js_strings['Apr'] = __( 'Apr', 'event_espresso' ); |
|
| 1727 | - EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' ); |
|
| 1728 | - EE_Registry::$i18n_js_strings['Jun'] = __( 'Jun', 'event_espresso' ); |
|
| 1729 | - EE_Registry::$i18n_js_strings['Jul'] = __( 'Jul', 'event_espresso' ); |
|
| 1730 | - EE_Registry::$i18n_js_strings['Aug'] = __( 'Aug', 'event_espresso' ); |
|
| 1731 | - EE_Registry::$i18n_js_strings['Sep'] = __( 'Sep', 'event_espresso' ); |
|
| 1732 | - EE_Registry::$i18n_js_strings['Oct'] = __( 'Oct', 'event_espresso' ); |
|
| 1733 | - EE_Registry::$i18n_js_strings['Nov'] = __( 'Nov', 'event_espresso' ); |
|
| 1734 | - EE_Registry::$i18n_js_strings['Dec'] = __( 'Dec', 'event_espresso' ); |
|
| 1735 | - |
|
| 1736 | - EE_Registry::$i18n_js_strings['Sunday'] = __( 'Sunday', 'event_espresso' ); |
|
| 1737 | - EE_Registry::$i18n_js_strings['Monday'] = __( 'Monday', 'event_espresso' ); |
|
| 1738 | - EE_Registry::$i18n_js_strings['Tuesday'] = __( 'Tuesday', 'event_espresso' ); |
|
| 1739 | - EE_Registry::$i18n_js_strings['Wednesday'] = __( 'Wednesday', 'event_espresso' ); |
|
| 1740 | - EE_Registry::$i18n_js_strings['Thursday'] = __( 'Thursday', 'event_espresso' ); |
|
| 1741 | - EE_Registry::$i18n_js_strings['Friday'] = __( 'Friday', 'event_espresso' ); |
|
| 1742 | - EE_Registry::$i18n_js_strings['Saturday'] = __( 'Saturday', 'event_espresso' ); |
|
| 1743 | - EE_Registry::$i18n_js_strings['Sun'] = __( 'Sun', 'event_espresso' ); |
|
| 1744 | - EE_Registry::$i18n_js_strings['Mon'] = __( 'Mon', 'event_espresso' ); |
|
| 1745 | - EE_Registry::$i18n_js_strings['Tue'] = __( 'Tue', 'event_espresso' ); |
|
| 1746 | - EE_Registry::$i18n_js_strings['Wed'] = __( 'Wed', 'event_espresso' ); |
|
| 1747 | - EE_Registry::$i18n_js_strings['Thu'] = __( 'Thu', 'event_espresso' ); |
|
| 1748 | - EE_Registry::$i18n_js_strings['Fri'] = __( 'Fri', 'event_espresso' ); |
|
| 1749 | - EE_Registry::$i18n_js_strings['Sat'] = __( 'Sat', 'event_espresso' ); |
|
| 1709 | + EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso'); |
|
| 1710 | + |
|
| 1711 | + EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso'); |
|
| 1712 | + EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso'); |
|
| 1713 | + EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso'); |
|
| 1714 | + EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso'); |
|
| 1715 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
| 1716 | + EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso'); |
|
| 1717 | + EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso'); |
|
| 1718 | + EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso'); |
|
| 1719 | + EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso'); |
|
| 1720 | + EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso'); |
|
| 1721 | + EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso'); |
|
| 1722 | + EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso'); |
|
| 1723 | + EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso'); |
|
| 1724 | + EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso'); |
|
| 1725 | + EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso'); |
|
| 1726 | + EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso'); |
|
| 1727 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
| 1728 | + EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso'); |
|
| 1729 | + EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso'); |
|
| 1730 | + EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso'); |
|
| 1731 | + EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso'); |
|
| 1732 | + EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso'); |
|
| 1733 | + EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso'); |
|
| 1734 | + EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso'); |
|
| 1735 | + |
|
| 1736 | + EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso'); |
|
| 1737 | + EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso'); |
|
| 1738 | + EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso'); |
|
| 1739 | + EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso'); |
|
| 1740 | + EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso'); |
|
| 1741 | + EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso'); |
|
| 1742 | + EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso'); |
|
| 1743 | + EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso'); |
|
| 1744 | + EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso'); |
|
| 1745 | + EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso'); |
|
| 1746 | + EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso'); |
|
| 1747 | + EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso'); |
|
| 1748 | + EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso'); |
|
| 1749 | + EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso'); |
|
| 1750 | 1750 | |
| 1751 | 1751 | //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance |
| 1752 | 1752 | //admin page when in maintenance mode and ee_admin_js is not loaded then. This works everywhere else because |
| 1753 | 1753 | //espresso_core is listed as a dependency of ee_admin_js. |
| 1754 | - wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
| 1754 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
| 1755 | 1755 | |
| 1756 | 1756 | } |
| 1757 | 1757 | |
@@ -1785,23 +1785,23 @@ discard block |
||
| 1785 | 1785 | protected function _set_list_table() { |
| 1786 | 1786 | |
| 1787 | 1787 | //first is this a list_table view? |
| 1788 | - if ( !isset($this->_route_config['list_table']) ) |
|
| 1788 | + if ( ! isset($this->_route_config['list_table'])) |
|
| 1789 | 1789 | return; //not a list_table view so get out. |
| 1790 | 1790 | |
| 1791 | 1791 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
| 1792 | 1792 | |
| 1793 | - if ( call_user_func( array( $this, '_set_list_table_views_' . $this->_req_action ) ) === FALSE ) { |
|
| 1793 | + if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === FALSE) { |
|
| 1794 | 1794 | //user error msg |
| 1795 | - $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso' ); |
|
| 1795 | + $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
|
| 1796 | 1796 | //developer error msg |
| 1797 | - $error_msg .= '||' . sprintf( __('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso' ), $this->_req_action, '_set_list_table_views_' . $this->_req_action ); |
|
| 1798 | - throw new EE_Error( $error_msg ); |
|
| 1797 | + $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), $this->_req_action, '_set_list_table_views_'.$this->_req_action); |
|
| 1798 | + throw new EE_Error($error_msg); |
|
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | 1801 | //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
| 1802 | - $this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views ); |
|
| 1803 | - $this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug, $this->_views ); |
|
| 1804 | - $this->_views = apply_filters( 'FHEE_list_table_views', $this->_views ); |
|
| 1802 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views); |
|
| 1803 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views); |
|
| 1804 | + $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
|
| 1805 | 1805 | |
| 1806 | 1806 | $this->_set_list_table_view(); |
| 1807 | 1807 | $this->_set_list_table_object(); |
@@ -1823,14 +1823,14 @@ discard block |
||
| 1823 | 1823 | * @return array |
| 1824 | 1824 | */ |
| 1825 | 1825 | protected function _set_list_table_view() { |
| 1826 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1826 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1827 | 1827 | |
| 1828 | 1828 | |
| 1829 | 1829 | // looking at active items or dumpster diving ? |
| 1830 | - if ( ! isset( $this->_req_data['status'] ) || ! array_key_exists( $this->_req_data['status'], $this->_views )) { |
|
| 1831 | - $this->_view = isset( $this->_views['in_use'] ) ? 'in_use' : 'all'; |
|
| 1830 | + if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) { |
|
| 1831 | + $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all'; |
|
| 1832 | 1832 | } else { |
| 1833 | - $this->_view = sanitize_key( $this->_req_data['status'] ); |
|
| 1833 | + $this->_view = sanitize_key($this->_req_data['status']); |
|
| 1834 | 1834 | } |
| 1835 | 1835 | } |
| 1836 | 1836 | |
@@ -1843,8 +1843,8 @@ discard block |
||
| 1843 | 1843 | * @throws \EE_Error |
| 1844 | 1844 | */ |
| 1845 | 1845 | protected function _set_list_table_object() { |
| 1846 | - if ( isset( $this->_route_config['list_table'] ) ) { |
|
| 1847 | - if ( ! class_exists( $this->_route_config['list_table'] ) ) { |
|
| 1846 | + if (isset($this->_route_config['list_table'])) { |
|
| 1847 | + if ( ! class_exists($this->_route_config['list_table'])) { |
|
| 1848 | 1848 | throw new EE_Error( |
| 1849 | 1849 | sprintf( |
| 1850 | 1850 | __( |
@@ -1852,12 +1852,12 @@ discard block |
||
| 1852 | 1852 | 'event_espresso' |
| 1853 | 1853 | ), |
| 1854 | 1854 | $this->_route_config['list_table'], |
| 1855 | - get_class( $this ) |
|
| 1855 | + get_class($this) |
|
| 1856 | 1856 | ) |
| 1857 | 1857 | ); |
| 1858 | 1858 | } |
| 1859 | 1859 | $list_table = $this->_route_config['list_table']; |
| 1860 | - $this->_list_table_object = new $list_table( $this ); |
|
| 1860 | + $this->_list_table_object = new $list_table($this); |
|
| 1861 | 1861 | } |
| 1862 | 1862 | } |
| 1863 | 1863 | |
@@ -1874,27 +1874,27 @@ discard block |
||
| 1874 | 1874 | * |
| 1875 | 1875 | * @return array |
| 1876 | 1876 | */ |
| 1877 | - public function get_list_table_view_RLs( $extra_query_args = array() ) { |
|
| 1877 | + public function get_list_table_view_RLs($extra_query_args = array()) { |
|
| 1878 | 1878 | |
| 1879 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1879 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1880 | 1880 | |
| 1881 | - if ( empty( $this->_views )) { |
|
| 1881 | + if (empty($this->_views)) { |
|
| 1882 | 1882 | $this->_views = array(); |
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | 1885 | // cycle thru views |
| 1886 | - foreach ( $this->_views as $key => $view ) { |
|
| 1886 | + foreach ($this->_views as $key => $view) { |
|
| 1887 | 1887 | $query_args = array(); |
| 1888 | 1888 | // check for current view |
| 1889 | - $this->_views[ $key ]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
| 1889 | + $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
| 1890 | 1890 | $query_args['action'] = $this->_req_action; |
| 1891 | - $query_args[$this->_req_action.'_nonce'] = wp_create_nonce( $query_args['action'] . '_nonce' ); |
|
| 1891 | + $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
| 1892 | 1892 | $query_args['status'] = $view['slug']; |
| 1893 | 1893 | //merge any other arguments sent in. |
| 1894 | - if ( isset( $extra_query_args[$view['slug']] ) ) { |
|
| 1895 | - $query_args = array_merge( $query_args, $extra_query_args[$view['slug']] ); |
|
| 1894 | + if (isset($extra_query_args[$view['slug']])) { |
|
| 1895 | + $query_args = array_merge($query_args, $extra_query_args[$view['slug']]); |
|
| 1896 | 1896 | } |
| 1897 | - $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
| 1897 | + $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | return $this->_views; |
@@ -1911,15 +1911,15 @@ discard block |
||
| 1911 | 1911 | * @param int $max_entries total number of rows in the table |
| 1912 | 1912 | * @return string |
| 1913 | 1913 | */ |
| 1914 | - protected function _entries_per_page_dropdown( $max_entries = FALSE ) { |
|
| 1914 | + protected function _entries_per_page_dropdown($max_entries = FALSE) { |
|
| 1915 | 1915 | |
| 1916 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1917 | - $values = array( 10, 25, 50, 100 ); |
|
| 1918 | - $per_page = ( ! empty( $this->_req_data['per_page'] )) ? absint( $this->_req_data['per_page'] ) : 10; |
|
| 1916 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1917 | + $values = array(10, 25, 50, 100); |
|
| 1918 | + $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10; |
|
| 1919 | 1919 | |
| 1920 | - if ( $max_entries ) { |
|
| 1920 | + if ($max_entries) { |
|
| 1921 | 1921 | $values[] = $max_entries; |
| 1922 | - sort( $values ); |
|
| 1922 | + sort($values); |
|
| 1923 | 1923 | } |
| 1924 | 1924 | |
| 1925 | 1925 | $entries_per_page_dropdown = ' |
@@ -1928,15 +1928,15 @@ discard block |
||
| 1928 | 1928 | Show |
| 1929 | 1929 | <select id="entries-per-page-slct" name="entries-per-page-slct">'; |
| 1930 | 1930 | |
| 1931 | - foreach ( $values as $value ) { |
|
| 1932 | - if ( $value < $max_entries ) { |
|
| 1933 | - $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1931 | + foreach ($values as $value) { |
|
| 1932 | + if ($value < $max_entries) { |
|
| 1933 | + $selected = $value == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
| 1934 | 1934 | $entries_per_page_dropdown .= ' |
| 1935 | 1935 | <option value="'.$value.'"'.$selected.'>'.$value.' </option>'; |
| 1936 | 1936 | } |
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | - $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1939 | + $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
| 1940 | 1940 | $entries_per_page_dropdown .= ' |
| 1941 | 1941 | <option value="'.$max_entries.'"'.$selected.'>All </option>'; |
| 1942 | 1942 | |
@@ -1959,8 +1959,8 @@ discard block |
||
| 1959 | 1959 | * @return void |
| 1960 | 1960 | */ |
| 1961 | 1961 | public function _set_search_attributes() { |
| 1962 | - $this->_template_args['search']['btn_label'] = sprintf( __( 'Search %s', 'event_espresso' ), empty( $this->_search_btn_label ) ? $this->page_label : $this->_search_btn_label ); |
|
| 1963 | - $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
| 1962 | + $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
|
| 1963 | + $this->_template_args['search']['callback'] = 'search_'.$this->page_slug; |
|
| 1964 | 1964 | } |
| 1965 | 1965 | |
| 1966 | 1966 | /*** END LIST TABLE METHODS **/ |
@@ -1979,10 +1979,10 @@ discard block |
||
| 1979 | 1979 | * @return void |
| 1980 | 1980 | */ |
| 1981 | 1981 | private function _add_registered_meta_boxes() { |
| 1982 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1982 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1983 | 1983 | |
| 1984 | 1984 | //we only add meta boxes if the page_route calls for it |
| 1985 | - if ( is_array( $this->_route_config ) && isset( $this->_route_config['metaboxes'] ) |
|
| 1985 | + if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) |
|
| 1986 | 1986 | && is_array( |
| 1987 | 1987 | $this->_route_config['metaboxes'] |
| 1988 | 1988 | ) |
@@ -1990,27 +1990,27 @@ discard block |
||
| 1990 | 1990 | // this simply loops through the callbacks provided |
| 1991 | 1991 | // and checks if there is a corresponding callback registered by the child |
| 1992 | 1992 | // if there is then we go ahead and process the metabox loader. |
| 1993 | - foreach ( $this->_route_config['metaboxes'] as $metabox_callback ) { |
|
| 1993 | + foreach ($this->_route_config['metaboxes'] as $metabox_callback) { |
|
| 1994 | 1994 | // first check for Closures |
| 1995 | - if ( $metabox_callback instanceof Closure ) { |
|
| 1995 | + if ($metabox_callback instanceof Closure) { |
|
| 1996 | 1996 | $result = $metabox_callback(); |
| 1997 | - } else if ( is_array( $metabox_callback ) && isset( $metabox_callback[0], $metabox_callback[1] ) ) { |
|
| 1998 | - $result = call_user_func( array( $metabox_callback[0], $metabox_callback[1] ) ); |
|
| 1997 | + } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) { |
|
| 1998 | + $result = call_user_func(array($metabox_callback[0], $metabox_callback[1])); |
|
| 1999 | 1999 | } else { |
| 2000 | - $result = call_user_func( array( $this, &$metabox_callback ) ); |
|
| 2000 | + $result = call_user_func(array($this, &$metabox_callback)); |
|
| 2001 | 2001 | } |
| 2002 | - if ( $result === FALSE ) { |
|
| 2002 | + if ($result === FALSE) { |
|
| 2003 | 2003 | // user error msg |
| 2004 | - $error_msg = __( 'An error occurred. The requested metabox could not be found.', 'event_espresso' ); |
|
| 2004 | + $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
|
| 2005 | 2005 | // developer error msg |
| 2006 | - $error_msg .= '||' . sprintf( |
|
| 2006 | + $error_msg .= '||'.sprintf( |
|
| 2007 | 2007 | __( |
| 2008 | 2008 | 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
| 2009 | 2009 | 'event_espresso' |
| 2010 | 2010 | ), |
| 2011 | 2011 | $metabox_callback |
| 2012 | 2012 | ); |
| 2013 | - throw new EE_Error( $error_msg ); |
|
| 2013 | + throw new EE_Error($error_msg); |
|
| 2014 | 2014 | } |
| 2015 | 2015 | } |
| 2016 | 2016 | } |
@@ -2027,17 +2027,17 @@ discard block |
||
| 2027 | 2027 | * @return void |
| 2028 | 2028 | */ |
| 2029 | 2029 | private function _add_screen_columns() { |
| 2030 | - if ( is_array($this->_route_config) && isset( $this->_route_config['columns'] ) && is_array($this->_route_config['columns']) && count( $this->_route_config['columns'] == 2 ) ) { |
|
| 2030 | + if (is_array($this->_route_config) && isset($this->_route_config['columns']) && is_array($this->_route_config['columns']) && count($this->_route_config['columns'] == 2)) { |
|
| 2031 | 2031 | |
| 2032 | - add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1] ) ); |
|
| 2032 | + add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1])); |
|
| 2033 | 2033 | $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
| 2034 | 2034 | $screen_id = $this->_current_screen->id; |
| 2035 | 2035 | $screen_columns = (int) get_user_option("screen_layout_$screen_id"); |
| 2036 | - $total_columns = !empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
| 2037 | - $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
| 2036 | + $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
| 2037 | + $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns; |
|
| 2038 | 2038 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
| 2039 | 2039 | $this->_template_args['screen'] = $this->_current_screen; |
| 2040 | - $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
| 2040 | + $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php'; |
|
| 2041 | 2041 | |
| 2042 | 2042 | //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
| 2043 | 2043 | $this->_route_config['has_metaboxes'] = TRUE; |
@@ -2054,11 +2054,11 @@ discard block |
||
| 2054 | 2054 | */ |
| 2055 | 2055 | |
| 2056 | 2056 | private function _espresso_news_post_box() { |
| 2057 | - $news_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __( 'New @ Event Espresso', 'event_espresso' ) ); |
|
| 2058 | - add_meta_box( 'espresso_news_post_box', $news_box_title, array( |
|
| 2057 | + $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso')); |
|
| 2058 | + add_meta_box('espresso_news_post_box', $news_box_title, array( |
|
| 2059 | 2059 | $this, |
| 2060 | 2060 | 'espresso_news_post_box' |
| 2061 | - ), $this->_wp_page_slug, 'side' ); |
|
| 2061 | + ), $this->_wp_page_slug, 'side'); |
|
| 2062 | 2062 | } |
| 2063 | 2063 | |
| 2064 | 2064 | |
@@ -2066,14 +2066,14 @@ discard block |
||
| 2066 | 2066 | * Code for setting up espresso ratings request metabox. |
| 2067 | 2067 | */ |
| 2068 | 2068 | protected function _espresso_ratings_request() { |
| 2069 | - if ( ! apply_filters( 'FHEE_show_ratings_request_meta_box', true ) ) { |
|
| 2069 | + if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) { |
|
| 2070 | 2070 | return ''; |
| 2071 | 2071 | } |
| 2072 | - $ratings_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso') ); |
|
| 2073 | - add_meta_box( 'espresso_ratings_request', $ratings_box_title, array( |
|
| 2072 | + $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso')); |
|
| 2073 | + add_meta_box('espresso_ratings_request', $ratings_box_title, array( |
|
| 2074 | 2074 | $this, |
| 2075 | 2075 | 'espresso_ratings_request' |
| 2076 | - ), $this->_wp_page_slug, 'side' ); |
|
| 2076 | + ), $this->_wp_page_slug, 'side'); |
|
| 2077 | 2077 | } |
| 2078 | 2078 | |
| 2079 | 2079 | |
@@ -2081,34 +2081,34 @@ discard block |
||
| 2081 | 2081 | * Code for setting up espresso ratings request metabox content. |
| 2082 | 2082 | */ |
| 2083 | 2083 | public function espresso_ratings_request() { |
| 2084 | - $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
| 2085 | - EEH_Template::display_template( $template_path, array() ); |
|
| 2084 | + $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php'; |
|
| 2085 | + EEH_Template::display_template($template_path, array()); |
|
| 2086 | 2086 | } |
| 2087 | 2087 | |
| 2088 | 2088 | |
| 2089 | 2089 | |
| 2090 | 2090 | |
| 2091 | - public static function cached_rss_display( $rss_id, $url ) { |
|
| 2092 | - $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>'; |
|
| 2093 | - $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 2094 | - $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
| 2095 | - $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
| 2096 | - $post = '</div>' . "\n"; |
|
| 2091 | + public static function cached_rss_display($rss_id, $url) { |
|
| 2092 | + $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading…').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>'; |
|
| 2093 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
| 2094 | + $pre = '<div class="espresso-rss-display">'."\n\t"; |
|
| 2095 | + $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>'; |
|
| 2096 | + $post = '</div>'."\n"; |
|
| 2097 | 2097 | |
| 2098 | - $cache_key = 'ee_rss_' . md5( $rss_id ); |
|
| 2099 | - if ( FALSE != ( $output = get_transient( $cache_key ) ) ) { |
|
| 2100 | - echo $pre . $output . $post; |
|
| 2098 | + $cache_key = 'ee_rss_'.md5($rss_id); |
|
| 2099 | + if (FALSE != ($output = get_transient($cache_key))) { |
|
| 2100 | + echo $pre.$output.$post; |
|
| 2101 | 2101 | return TRUE; |
| 2102 | 2102 | } |
| 2103 | 2103 | |
| 2104 | - if ( ! $doing_ajax ) { |
|
| 2105 | - echo $pre . $loading . $post; |
|
| 2104 | + if ( ! $doing_ajax) { |
|
| 2105 | + echo $pre.$loading.$post; |
|
| 2106 | 2106 | return FALSE; |
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | ob_start(); |
| 2110 | - wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5) ); |
|
| 2111 | - set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); |
|
| 2110 | + wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5)); |
|
| 2111 | + set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); |
|
| 2112 | 2112 | return TRUE; |
| 2113 | 2113 | |
| 2114 | 2114 | } |
@@ -2120,13 +2120,13 @@ discard block |
||
| 2120 | 2120 | <div id="espresso_news_post_box_content" class="infolinks"> |
| 2121 | 2121 | <?php |
| 2122 | 2122 | // Get RSS Feed(s) |
| 2123 | - $feed_url = apply_filters( 'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/' ); |
|
| 2123 | + $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/'); |
|
| 2124 | 2124 | $url = urlencode($feed_url); |
| 2125 | - self::cached_rss_display( 'espresso_news_post_box_content', $url ); |
|
| 2125 | + self::cached_rss_display('espresso_news_post_box_content', $url); |
|
| 2126 | 2126 | |
| 2127 | 2127 | ?> |
| 2128 | 2128 | </div> |
| 2129 | - <?php do_action( 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
|
| 2129 | + <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
|
| 2130 | 2130 | </div> |
| 2131 | 2131 | <?php |
| 2132 | 2132 | } |
@@ -2147,32 +2147,32 @@ discard block |
||
| 2147 | 2147 | |
| 2148 | 2148 | protected function _espresso_sponsors_post_box() { |
| 2149 | 2149 | |
| 2150 | - $show_sponsors = apply_filters( 'FHEE_show_sponsors_meta_box', TRUE ); |
|
| 2151 | - if ( $show_sponsors ) |
|
| 2152 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2150 | + $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', TRUE); |
|
| 2151 | + if ($show_sponsors) |
|
| 2152 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | 2155 | |
| 2156 | 2156 | public function espresso_sponsors_post_box() { |
| 2157 | - $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
| 2158 | - EEH_Template::display_template( $templatepath ); |
|
| 2157 | + $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
| 2158 | + EEH_Template::display_template($templatepath); |
|
| 2159 | 2159 | } |
| 2160 | 2160 | |
| 2161 | 2161 | |
| 2162 | 2162 | |
| 2163 | 2163 | private function _publish_post_box() { |
| 2164 | - $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
| 2164 | + $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview'; |
|
| 2165 | 2165 | |
| 2166 | 2166 | //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
| 2167 | - if ( !empty( $this->_labels['publishbox'] ) ) { |
|
| 2168 | - $box_label = is_array( $this->_labels['publishbox'] ) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
| 2167 | + if ( ! empty($this->_labels['publishbox'])) { |
|
| 2168 | + $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
| 2169 | 2169 | } else { |
| 2170 | 2170 | $box_label = __('Publish', 'event_espresso'); |
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | - $box_label = apply_filters( 'FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this ); |
|
| 2173 | + $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this); |
|
| 2174 | 2174 | |
| 2175 | - add_meta_box( $meta_box_ref, $box_label, array( $this, 'editor_overview' ), $this->_current_screen->id, 'side', 'high' ); |
|
| 2175 | + add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high'); |
|
| 2176 | 2176 | |
| 2177 | 2177 | } |
| 2178 | 2178 | |
@@ -2180,9 +2180,9 @@ discard block |
||
| 2180 | 2180 | |
| 2181 | 2181 | public function editor_overview() { |
| 2182 | 2182 | //if we have extra content set let's add it in if not make sure its empty |
| 2183 | - $this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2184 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
| 2185 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 2183 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2184 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php'; |
|
| 2185 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 2186 | 2186 | } |
| 2187 | 2187 | |
| 2188 | 2188 | |
@@ -2198,8 +2198,8 @@ discard block |
||
| 2198 | 2198 | * @see $this->_set_publish_post_box_vars for param details |
| 2199 | 2199 | * @since 4.6.0 |
| 2200 | 2200 | */ |
| 2201 | - public function set_publish_post_box_vars( $name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true ) { |
|
| 2202 | - $this->_set_publish_post_box_vars( $name, $id, $delete, $save_close_redirect_URL, $both_btns ); |
|
| 2201 | + public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) { |
|
| 2202 | + $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns); |
|
| 2203 | 2203 | } |
| 2204 | 2204 | |
| 2205 | 2205 | |
@@ -2227,17 +2227,17 @@ discard block |
||
| 2227 | 2227 | $both_btns = true |
| 2228 | 2228 | ) { |
| 2229 | 2229 | // if Save & Close, use a custom redirect URL or default to the main page? |
| 2230 | - $save_close_redirect_URL = ! empty( $save_close_redirect_URL ) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
| 2230 | + $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
| 2231 | 2231 | // create the Save & Close and Save buttons |
| 2232 | - $this->_set_save_buttons( $both_btns, array(), array(), $save_close_redirect_URL ); |
|
| 2232 | + $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL); |
|
| 2233 | 2233 | //if we have extra content set let's add it in if not make sure its empty |
| 2234 | - $this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2234 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2235 | 2235 | |
| 2236 | 2236 | |
| 2237 | - if ( $delete && ! empty( $id ) ) { |
|
| 2237 | + if ($delete && ! empty($id)) { |
|
| 2238 | 2238 | //make sure we have a default if just true is sent. |
| 2239 | 2239 | $delete = ! empty($delete) ? $delete : 'delete'; |
| 2240 | - $delete_link_args = array( $name => $id ); |
|
| 2240 | + $delete_link_args = array($name => $id); |
|
| 2241 | 2241 | $delete = $this->get_action_link_or_button( |
| 2242 | 2242 | $delete, |
| 2243 | 2243 | $delete, |
@@ -2248,8 +2248,8 @@ discard block |
||
| 2248 | 2248 | ); |
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | - $this->_template_args['publish_delete_link'] = !empty( $id ) ? $delete : ''; |
|
| 2252 | - if ( ! empty( $name ) && ! empty( $id ) ) { |
|
| 2251 | + $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : ''; |
|
| 2252 | + if ( ! empty($name) && ! empty($id)) { |
|
| 2253 | 2253 | $hidden_field_arr[$name] = array( |
| 2254 | 2254 | 'type' => 'hidden', |
| 2255 | 2255 | 'value' => $id |
@@ -2259,7 +2259,7 @@ discard block |
||
| 2259 | 2259 | $hf = ''; |
| 2260 | 2260 | } |
| 2261 | 2261 | // add hidden field |
| 2262 | - $this->_template_args['publish_hidden_fields'] = ! empty( $hf ) ? $hf[$name]['field'] : $hf; |
|
| 2262 | + $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf; |
|
| 2263 | 2263 | |
| 2264 | 2264 | } |
| 2265 | 2265 | |
@@ -2276,8 +2276,8 @@ discard block |
||
| 2276 | 2276 | <noscript> |
| 2277 | 2277 | <div id="no-js-message" class="error"> |
| 2278 | 2278 | <p style="font-size:1.3em;"> |
| 2279 | - <span style="color:red;"><?php _e( 'Warning!', 'event_espresso' ); ?></span> |
|
| 2280 | - <?php _e( 'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso' ); ?> |
|
| 2279 | + <span style="color:red;"><?php _e('Warning!', 'event_espresso'); ?></span> |
|
| 2280 | + <?php _e('Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso'); ?> |
|
| 2281 | 2281 | </p> |
| 2282 | 2282 | </div> |
| 2283 | 2283 | </noscript> |
@@ -2297,7 +2297,7 @@ discard block |
||
| 2297 | 2297 | * @return string |
| 2298 | 2298 | */ |
| 2299 | 2299 | private function _display_espresso_notices() { |
| 2300 | - $notices = $this->_get_transient( TRUE ); |
|
| 2300 | + $notices = $this->_get_transient(TRUE); |
|
| 2301 | 2301 | echo stripslashes($notices); |
| 2302 | 2302 | } |
| 2303 | 2303 | |
@@ -2349,11 +2349,11 @@ discard block |
||
| 2349 | 2349 | * @param string $priority give this metabox a priority (using accepted priorities for wp meta boxes) |
| 2350 | 2350 | * @param boolean $create_func default is true. Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box. |
| 2351 | 2351 | */ |
| 2352 | - public function _add_admin_page_meta_box( $action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true ) { |
|
| 2353 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, $callback ); |
|
| 2352 | + public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) { |
|
| 2353 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $callback); |
|
| 2354 | 2354 | |
| 2355 | 2355 | //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated. |
| 2356 | - if ( empty( $callback_args ) && $create_func ) { |
|
| 2356 | + if (empty($callback_args) && $create_func) { |
|
| 2357 | 2357 | $callback_args = array( |
| 2358 | 2358 | 'template_path' => $this->_template_path, |
| 2359 | 2359 | 'template_args' => $this->_template_args, |
@@ -2363,7 +2363,7 @@ discard block |
||
| 2363 | 2363 | //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
| 2364 | 2364 | $call_back_func = $create_func ? create_function('$post, $metabox', 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
| 2365 | 2365 | |
| 2366 | - add_meta_box( str_replace( '_', '-', $action ) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args ); |
|
| 2366 | + add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | |
| 2369 | 2369 | |
@@ -2376,7 +2376,7 @@ discard block |
||
| 2376 | 2376 | */ |
| 2377 | 2377 | public function display_admin_page_with_metabox_columns() { |
| 2378 | 2378 | $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content']; |
| 2379 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_column_template_path, $this->_template_args, TRUE); |
|
| 2379 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, TRUE); |
|
| 2380 | 2380 | |
| 2381 | 2381 | //the final wrapper |
| 2382 | 2382 | $this->admin_page_wrapper(); |
@@ -2419,7 +2419,7 @@ discard block |
||
| 2419 | 2419 | * @return void |
| 2420 | 2420 | */ |
| 2421 | 2421 | public function display_about_admin_page() { |
| 2422 | - $this->_display_admin_page( FALSE, TRUE ); |
|
| 2422 | + $this->_display_admin_page(FALSE, TRUE); |
|
| 2423 | 2423 | } |
| 2424 | 2424 | |
| 2425 | 2425 | |
@@ -2435,26 +2435,26 @@ discard block |
||
| 2435 | 2435 | * @return void |
| 2436 | 2436 | */ |
| 2437 | 2437 | private function _display_admin_page($sidebar = false, $about = FALSE) { |
| 2438 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 2438 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2439 | 2439 | |
| 2440 | 2440 | //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages. |
| 2441 | - do_action( 'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes' ); |
|
| 2441 | + do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'); |
|
| 2442 | 2442 | |
| 2443 | 2443 | // set current wp page slug - looks like: event-espresso_page_event_categories |
| 2444 | 2444 | // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated. |
| 2445 | 2445 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
| 2446 | 2446 | |
| 2447 | - $template_path = $sidebar ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
| 2447 | + $template_path = $sidebar ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php'; |
|
| 2448 | 2448 | |
| 2449 | - if ( defined('DOING_AJAX' ) ) |
|
| 2450 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2449 | + if (defined('DOING_AJAX')) |
|
| 2450 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2451 | 2451 | |
| 2452 | - $template_path = !empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
| 2452 | + $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
| 2453 | 2453 | |
| 2454 | - $this->_template_args['post_body_content'] = isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : ''; |
|
| 2454 | + $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
|
| 2455 | 2455 | $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''; |
| 2456 | 2456 | $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''; |
| 2457 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 2457 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 2458 | 2458 | |
| 2459 | 2459 | |
| 2460 | 2460 | // the final template wrapper |
@@ -2472,7 +2472,7 @@ discard block |
||
| 2472 | 2472 | * @return void |
| 2473 | 2473 | * @throws \EE_Error |
| 2474 | 2474 | */ |
| 2475 | - public function display_admin_caf_preview_page( $utm_campaign_source = '', $display_sidebar = TRUE ) { |
|
| 2475 | + public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = TRUE) { |
|
| 2476 | 2476 | //let's generate a default preview action button if there isn't one already present. |
| 2477 | 2477 | $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso'); |
| 2478 | 2478 | $buy_now_url = add_query_arg( |
@@ -2485,7 +2485,7 @@ discard block |
||
| 2485 | 2485 | ), |
| 2486 | 2486 | 'http://eventespresso.com/pricing/' |
| 2487 | 2487 | ); |
| 2488 | - $this->_template_args['preview_action_button'] = ! isset( $this->_template_args['preview_action_button'] ) |
|
| 2488 | + $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) |
|
| 2489 | 2489 | ? $this->get_action_link_or_button( |
| 2490 | 2490 | '', |
| 2491 | 2491 | 'buy_now', |
@@ -2495,13 +2495,13 @@ discard block |
||
| 2495 | 2495 | true |
| 2496 | 2496 | ) |
| 2497 | 2497 | : $this->_template_args['preview_action_button']; |
| 2498 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
| 2498 | + $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php'; |
|
| 2499 | 2499 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 2500 | 2500 | $template_path, |
| 2501 | 2501 | $this->_template_args, |
| 2502 | 2502 | true |
| 2503 | 2503 | ); |
| 2504 | - $this->_display_admin_page( $display_sidebar ); |
|
| 2504 | + $this->_display_admin_page($display_sidebar); |
|
| 2505 | 2505 | } |
| 2506 | 2506 | |
| 2507 | 2507 | |
@@ -2535,49 +2535,49 @@ discard block |
||
| 2535 | 2535 | * @param boolean $sidebar whether to display with sidebar or not. |
| 2536 | 2536 | * @return void |
| 2537 | 2537 | */ |
| 2538 | - private function _display_admin_list_table_page( $sidebar = false ) { |
|
| 2538 | + private function _display_admin_list_table_page($sidebar = false) { |
|
| 2539 | 2539 | //setup search attributes |
| 2540 | 2540 | $this->_set_search_attributes(); |
| 2541 | 2541 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
| 2542 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
| 2542 | + $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php'; |
|
| 2543 | 2543 | |
| 2544 | - $this->_template_args['table_url'] = defined( 'DOING_AJAX') |
|
| 2545 | - ? add_query_arg( array( 'noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url ) |
|
| 2546 | - : add_query_arg( array( 'route' => $this->_req_action), $this->_admin_base_url); |
|
| 2544 | + $this->_template_args['table_url'] = defined('DOING_AJAX') |
|
| 2545 | + ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
|
| 2546 | + : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
|
| 2547 | 2547 | $this->_template_args['list_table'] = $this->_list_table_object; |
| 2548 | 2548 | $this->_template_args['current_route'] = $this->_req_action; |
| 2549 | - $this->_template_args['list_table_class'] = get_class( $this->_list_table_object ); |
|
| 2549 | + $this->_template_args['list_table_class'] = get_class($this->_list_table_object); |
|
| 2550 | 2550 | |
| 2551 | 2551 | $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
| 2552 | - if( ! empty( $ajax_sorting_callback )) { |
|
| 2552 | + if ( ! empty($ajax_sorting_callback)) { |
|
| 2553 | 2553 | $sortable_list_table_form_fields = wp_nonce_field( |
| 2554 | - $ajax_sorting_callback . '_nonce', |
|
| 2555 | - $ajax_sorting_callback . '_nonce', |
|
| 2554 | + $ajax_sorting_callback.'_nonce', |
|
| 2555 | + $ajax_sorting_callback.'_nonce', |
|
| 2556 | 2556 | FALSE, |
| 2557 | 2557 | FALSE |
| 2558 | 2558 | ); |
| 2559 | 2559 | // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
| 2560 | 2560 | // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
| 2561 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug .'" />'; |
|
| 2562 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
| 2561 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />'; |
|
| 2562 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />'; |
|
| 2563 | 2563 | } else { |
| 2564 | 2564 | $sortable_list_table_form_fields = ''; |
| 2565 | 2565 | } |
| 2566 | 2566 | |
| 2567 | 2567 | $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
| 2568 | - $hidden_form_fields = isset( $this->_template_args['list_table_hidden_fields'] ) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
| 2569 | - $nonce_ref = $this->_req_action . '_nonce'; |
|
| 2570 | - $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce( $nonce_ref ) . '">'; |
|
| 2568 | + $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
| 2569 | + $nonce_ref = $this->_req_action.'_nonce'; |
|
| 2570 | + $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">'; |
|
| 2571 | 2571 | $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
| 2572 | 2572 | |
| 2573 | 2573 | //display message about search results? |
| 2574 | 2574 | $this->_template_args['before_list_table'] .= apply_filters( |
| 2575 | 2575 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', |
| 2576 | - ! empty( $this->_req_data['s'] ) |
|
| 2577 | - ? '<p class="ee-search-results">' . sprintf( |
|
| 2578 | - __( 'Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso' ), |
|
| 2579 | - trim( $this->_req_data['s'], '%' ) |
|
| 2580 | - ) . '</p>' |
|
| 2576 | + ! empty($this->_req_data['s']) |
|
| 2577 | + ? '<p class="ee-search-results">'.sprintf( |
|
| 2578 | + __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), |
|
| 2579 | + trim($this->_req_data['s'], '%') |
|
| 2580 | + ).'</p>' |
|
| 2581 | 2581 | : '', |
| 2582 | 2582 | $this->page_slug, |
| 2583 | 2583 | $this->_req_data, |
@@ -2589,7 +2589,7 @@ discard block |
||
| 2589 | 2589 | true |
| 2590 | 2590 | ); |
| 2591 | 2591 | // the final template wrapper |
| 2592 | - if ( $sidebar ) |
|
| 2592 | + if ($sidebar) |
|
| 2593 | 2593 | $this->display_admin_page_with_sidebar(); |
| 2594 | 2594 | else |
| 2595 | 2595 | $this->display_admin_page_with_no_sidebar(); |
@@ -2612,9 +2612,9 @@ discard block |
||
| 2612 | 2612 | * @param array $items see above for format of array |
| 2613 | 2613 | * @return string html string of legend |
| 2614 | 2614 | */ |
| 2615 | - protected function _display_legend( $items ) { |
|
| 2616 | - $this->_template_args['items'] = apply_filters( 'FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this ); |
|
| 2617 | - $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
| 2615 | + protected function _display_legend($items) { |
|
| 2616 | + $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this); |
|
| 2617 | + $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php'; |
|
| 2618 | 2618 | return EEH_Template::display_template($legend_template, $this->_template_args, TRUE); |
| 2619 | 2619 | } |
| 2620 | 2620 | |
@@ -2639,33 +2639,33 @@ discard block |
||
| 2639 | 2639 | * |
| 2640 | 2640 | * @return void |
| 2641 | 2641 | */ |
| 2642 | - protected function _return_json( $sticky_notices = false ) { |
|
| 2642 | + protected function _return_json($sticky_notices = false) { |
|
| 2643 | 2643 | |
| 2644 | 2644 | //make sure any EE_Error notices have been handled. |
| 2645 | - $this->_process_notices( array(), true, $sticky_notices ); |
|
| 2645 | + $this->_process_notices(array(), true, $sticky_notices); |
|
| 2646 | 2646 | |
| 2647 | 2647 | |
| 2648 | - $data = isset( $this->_template_args['data'] ) ? $this->_template_args['data'] : array(); |
|
| 2648 | + $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array(); |
|
| 2649 | 2649 | unset($this->_template_args['data']); |
| 2650 | 2650 | $json = array( |
| 2651 | - 'error' => isset( $this->_template_args['error'] ) ? $this->_template_args['error'] : false, |
|
| 2652 | - 'success' => isset( $this->_template_args['success'] ) ? $this->_template_args['success'] : false, |
|
| 2653 | - 'errors' => isset( $this->_template_args['errors'] ) ? $this->_template_args['errors'] : false, |
|
| 2654 | - 'attention' => isset( $this->_template_args['attention'] ) ? $this->_template_args['attention'] : false, |
|
| 2651 | + 'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : false, |
|
| 2652 | + 'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : false, |
|
| 2653 | + 'errors' => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false, |
|
| 2654 | + 'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false, |
|
| 2655 | 2655 | 'notices' => EE_Error::get_notices(), |
| 2656 | - 'content' => isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : '', |
|
| 2657 | - 'data' => array_merge( $data, array('template_args' => $this->_template_args ) ), |
|
| 2656 | + 'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '', |
|
| 2657 | + 'data' => array_merge($data, array('template_args' => $this->_template_args)), |
|
| 2658 | 2658 | 'isEEajax' => TRUE //special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
| 2659 | 2659 | ); |
| 2660 | 2660 | |
| 2661 | 2661 | |
| 2662 | 2662 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
| 2663 | - if ( NULL === error_get_last() || ! headers_sent() ) |
|
| 2663 | + if (NULL === error_get_last() || ! headers_sent()) |
|
| 2664 | 2664 | header('Content-Type: application/json; charset=UTF-8'); |
| 2665 | - if( function_exists( 'wp_json_encode' ) ) { |
|
| 2666 | - echo wp_json_encode( $json ); |
|
| 2665 | + if (function_exists('wp_json_encode')) { |
|
| 2666 | + echo wp_json_encode($json); |
|
| 2667 | 2667 | } else { |
| 2668 | - echo json_encode( $json ); |
|
| 2668 | + echo json_encode($json); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | exit(); |
| 2671 | 2671 | } |
@@ -2679,11 +2679,11 @@ discard block |
||
| 2679 | 2679 | * @throws EE_Error |
| 2680 | 2680 | */ |
| 2681 | 2681 | public function return_json() { |
| 2682 | - if ( defined('DOING_AJAX') && DOING_AJAX ) |
|
| 2682 | + if (defined('DOING_AJAX') && DOING_AJAX) |
|
| 2683 | 2683 | $this->_return_json(); |
| 2684 | 2684 | |
| 2685 | 2685 | else { |
| 2686 | - throw new EE_Error( sprintf( __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__ ) ); |
|
| 2686 | + throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__)); |
|
| 2687 | 2687 | } |
| 2688 | 2688 | } |
| 2689 | 2689 | |
@@ -2696,7 +2696,7 @@ discard block |
||
| 2696 | 2696 | * |
| 2697 | 2697 | * @access public |
| 2698 | 2698 | */ |
| 2699 | - public function set_hook_object( EE_Admin_Hooks $hook_obj ) { |
|
| 2699 | + public function set_hook_object(EE_Admin_Hooks $hook_obj) { |
|
| 2700 | 2700 | $this->_hook_obj = $hook_obj; |
| 2701 | 2701 | } |
| 2702 | 2702 | |
@@ -2712,33 +2712,33 @@ discard block |
||
| 2712 | 2712 | */ |
| 2713 | 2713 | public function admin_page_wrapper($about = FALSE) { |
| 2714 | 2714 | |
| 2715 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 2715 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2716 | 2716 | |
| 2717 | 2717 | $this->_nav_tabs = $this->_get_main_nav_tabs(); |
| 2718 | 2718 | |
| 2719 | 2719 | $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
| 2720 | 2720 | $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
| 2721 | 2721 | |
| 2722 | - $this->_template_args['before_admin_page_content'] = apply_filters( 'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['before_admin_page_content'] ) ? $this->_template_args['before_admin_page_content'] : ''); |
|
| 2723 | - $this->_template_args['after_admin_page_content'] = apply_filters( 'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['after_admin_page_content'] ) ? $this->_template_args['after_admin_page_content'] : ''); |
|
| 2722 | + $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
|
| 2723 | + $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
|
| 2724 | 2724 | |
| 2725 | 2725 | $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
| 2726 | 2726 | |
| 2727 | 2727 | |
| 2728 | 2728 | |
| 2729 | 2729 | // load settings page wrapper template |
| 2730 | - $template_path = !defined( 'DOING_AJAX' ) ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
| 2730 | + $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php'; |
|
| 2731 | 2731 | |
| 2732 | 2732 | //about page? |
| 2733 | - $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
| 2733 | + $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path; |
|
| 2734 | 2734 | |
| 2735 | 2735 | |
| 2736 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 2737 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 2736 | + if (defined('DOING_AJAX')) { |
|
| 2737 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 2738 | 2738 | |
| 2739 | 2739 | $this->_return_json(); |
| 2740 | 2740 | } else { |
| 2741 | - EEH_Template::display_template( $template_path, $this->_template_args ); |
|
| 2741 | + EEH_Template::display_template($template_path, $this->_template_args); |
|
| 2742 | 2742 | } |
| 2743 | 2743 | |
| 2744 | 2744 | } |
@@ -2764,7 +2764,7 @@ discard block |
||
| 2764 | 2764 | * @param $b |
| 2765 | 2765 | * @return int |
| 2766 | 2766 | */ |
| 2767 | - private function _sort_nav_tabs( $a, $b ) { |
|
| 2767 | + private function _sort_nav_tabs($a, $b) { |
|
| 2768 | 2768 | if ($a['order'] == $b['order']) { |
| 2769 | 2769 | return 0; |
| 2770 | 2770 | } |
@@ -2784,7 +2784,7 @@ discard block |
||
| 2784 | 2784 | * @uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php) |
| 2785 | 2785 | * @uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php) |
| 2786 | 2786 | */ |
| 2787 | - protected function _generate_admin_form_fields( $input_vars = array(), $generator = 'string', $id = FALSE ) { |
|
| 2787 | + protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = FALSE) { |
|
| 2788 | 2788 | $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars); |
| 2789 | 2789 | return $content; |
| 2790 | 2790 | } |
@@ -2806,25 +2806,25 @@ discard block |
||
| 2806 | 2806 | * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button). We can also use this to just dump default actions by submitting some other value. |
| 2807 | 2807 | * @param bool|string|null $referrer if false then we just do the default action on save and close. Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling). |
| 2808 | 2808 | */ |
| 2809 | - protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL ) { |
|
| 2809 | + protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL) { |
|
| 2810 | 2810 | //make sure $text and $actions are in an array |
| 2811 | 2811 | $text = (array) $text; |
| 2812 | 2812 | $actions = (array) $actions; |
| 2813 | 2813 | $referrer_url = empty($referrer) ? '' : $referrer; |
| 2814 | - $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] .'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer .'" />'; |
|
| 2814 | + $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />'; |
|
| 2815 | 2815 | |
| 2816 | - $button_text = !empty($text) ? $text : array( __('Save', 'event_espresso'), __('Save and Close', 'event_espresso') ); |
|
| 2817 | - $default_names = array( 'save', 'save_and_close' ); |
|
| 2816 | + $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
|
| 2817 | + $default_names = array('save', 'save_and_close'); |
|
| 2818 | 2818 | |
| 2819 | 2819 | //add in a hidden index for the current page (so save and close redirects properly) |
| 2820 | 2820 | $this->_template_args['save_buttons'] = $referrer_url; |
| 2821 | 2821 | |
| 2822 | - foreach ( $button_text as $key => $button ) { |
|
| 2822 | + foreach ($button_text as $key => $button) { |
|
| 2823 | 2823 | $ref = $default_names[$key]; |
| 2824 | - $id = $this->_current_view . '_' . $ref; |
|
| 2825 | - $name = !empty($actions) ? $actions[$key] : $ref; |
|
| 2826 | - $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
| 2827 | - if ( !$both ) break; |
|
| 2824 | + $id = $this->_current_view.'_'.$ref; |
|
| 2825 | + $name = ! empty($actions) ? $actions[$key] : $ref; |
|
| 2826 | + $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />'; |
|
| 2827 | + if ( ! $both) break; |
|
| 2828 | 2828 | } |
| 2829 | 2829 | |
| 2830 | 2830 | } |
@@ -2839,8 +2839,8 @@ discard block |
||
| 2839 | 2839 | * @param string $route |
| 2840 | 2840 | * @param array $additional_hidden_fields |
| 2841 | 2841 | */ |
| 2842 | - public function set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) { |
|
| 2843 | - $this->_set_add_edit_form_tags( $route, $additional_hidden_fields ); |
|
| 2842 | + public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) { |
|
| 2843 | + $this->_set_add_edit_form_tags($route, $additional_hidden_fields); |
|
| 2844 | 2844 | } |
| 2845 | 2845 | |
| 2846 | 2846 | |
@@ -2853,30 +2853,30 @@ discard block |
||
| 2853 | 2853 | * @param array $additional_hidden_fields any additional hidden fields required in the form header |
| 2854 | 2854 | * @return void |
| 2855 | 2855 | */ |
| 2856 | - protected function _set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) { |
|
| 2856 | + protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) { |
|
| 2857 | 2857 | |
| 2858 | - if ( empty( $route )) { |
|
| 2858 | + if (empty($route)) { |
|
| 2859 | 2859 | $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
| 2860 | - $dev_msg = $user_msg . "\n" . sprintf( __('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__ ); |
|
| 2861 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2860 | + $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
| 2861 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2862 | 2862 | } |
| 2863 | 2863 | // open form |
| 2864 | - $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
| 2864 | + $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >'; |
|
| 2865 | 2865 | // add nonce |
| 2866 | - $nonce = wp_nonce_field( $route . '_nonce', $route . '_nonce', FALSE, FALSE ); |
|
| 2866 | + $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', FALSE, FALSE); |
|
| 2867 | 2867 | // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
| 2868 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
| 2868 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce; |
|
| 2869 | 2869 | // add REQUIRED form action |
| 2870 | 2870 | $hidden_fields = array( |
| 2871 | - 'action' => array( 'type' => 'hidden', 'value' => $route ), |
|
| 2871 | + 'action' => array('type' => 'hidden', 'value' => $route), |
|
| 2872 | 2872 | ); |
| 2873 | 2873 | // merge arrays |
| 2874 | - $hidden_fields = is_array( $additional_hidden_fields) ? array_merge( $hidden_fields, $additional_hidden_fields ) : $hidden_fields; |
|
| 2874 | + $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields; |
|
| 2875 | 2875 | // generate form fields |
| 2876 | - $form_fields = $this->_generate_admin_form_fields( $hidden_fields, 'array' ); |
|
| 2876 | + $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
|
| 2877 | 2877 | // add fields to form |
| 2878 | - foreach ( (array)$form_fields as $field_name => $form_field ) { |
|
| 2879 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
| 2878 | + foreach ((array) $form_fields as $field_name => $form_field) { |
|
| 2879 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field']; |
|
| 2880 | 2880 | } |
| 2881 | 2881 | |
| 2882 | 2882 | // close form |
@@ -2893,8 +2893,8 @@ discard block |
||
| 2893 | 2893 | * @see EE_Admin_Page::_redirect_after_action() for params. |
| 2894 | 2894 | * @since 4.5.0 |
| 2895 | 2895 | */ |
| 2896 | - public function redirect_after_action( $success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) { |
|
| 2897 | - $this->_redirect_after_action( $success, $what, $action_desc, $query_args, $override_overwrite ); |
|
| 2896 | + public function redirect_after_action($success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) { |
|
| 2897 | + $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite); |
|
| 2898 | 2898 | } |
| 2899 | 2899 | |
| 2900 | 2900 | |
@@ -2910,38 +2910,38 @@ discard block |
||
| 2910 | 2910 | * @access protected |
| 2911 | 2911 | * @return void |
| 2912 | 2912 | */ |
| 2913 | - protected function _redirect_after_action( $success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) { |
|
| 2913 | + protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) { |
|
| 2914 | 2914 | |
| 2915 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 2915 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2916 | 2916 | |
| 2917 | 2917 | //class name for actions/filters. |
| 2918 | 2918 | $classname = get_class($this); |
| 2919 | 2919 | |
| 2920 | 2920 | //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url |
| 2921 | - $redirect_url = isset( $query_args['page'] ) ? admin_url('admin.php') : $this->_admin_base_url; |
|
| 2922 | - $notices = EE_Error::get_notices( FALSE ); |
|
| 2921 | + $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url; |
|
| 2922 | + $notices = EE_Error::get_notices(FALSE); |
|
| 2923 | 2923 | |
| 2924 | 2924 | // overwrite default success messages //BUT ONLY if overwrite not overridden |
| 2925 | - if ( ! $override_overwrite || ! empty( $notices['errors'] )) { |
|
| 2925 | + if ( ! $override_overwrite || ! empty($notices['errors'])) { |
|
| 2926 | 2926 | EE_Error::overwrite_success(); |
| 2927 | 2927 | } |
| 2928 | - if ( ! empty( $what ) && ! empty( $action_desc ) ) { |
|
| 2928 | + if ( ! empty($what) && ! empty($action_desc)) { |
|
| 2929 | 2929 | // how many records affected ? more than one record ? or just one ? |
| 2930 | - if ( $success > 1 && empty( $notices[ 'errors' ] ) ) { |
|
| 2930 | + if ($success > 1 && empty($notices['errors'])) { |
|
| 2931 | 2931 | // set plural msg |
| 2932 | 2932 | EE_Error::add_success( |
| 2933 | 2933 | sprintf( |
| 2934 | - __( 'The "%s" have been successfully %s.', 'event_espresso' ), |
|
| 2934 | + __('The "%s" have been successfully %s.', 'event_espresso'), |
|
| 2935 | 2935 | $what, |
| 2936 | 2936 | $action_desc |
| 2937 | 2937 | ), |
| 2938 | 2938 | __FILE__, __FUNCTION__, __LINE__ |
| 2939 | 2939 | ); |
| 2940 | - } else if ( $success == 1 && empty( $notices[ 'errors' ] ) ) { |
|
| 2940 | + } else if ($success == 1 && empty($notices['errors'])) { |
|
| 2941 | 2941 | // set singular msg |
| 2942 | 2942 | EE_Error::add_success( |
| 2943 | 2943 | sprintf( |
| 2944 | - __( 'The "%s" has been successfully %s.', 'event_espresso' ), |
|
| 2944 | + __('The "%s" has been successfully %s.', 'event_espresso'), |
|
| 2945 | 2945 | $what, |
| 2946 | 2946 | $action_desc |
| 2947 | 2947 | ), |
@@ -2950,7 +2950,7 @@ discard block |
||
| 2950 | 2950 | } |
| 2951 | 2951 | } |
| 2952 | 2952 | // check that $query_args isn't something crazy |
| 2953 | - if ( ! is_array( $query_args )) { |
|
| 2953 | + if ( ! is_array($query_args)) { |
|
| 2954 | 2954 | $query_args = array(); |
| 2955 | 2955 | } |
| 2956 | 2956 | |
@@ -2963,36 +2963,36 @@ discard block |
||
| 2963 | 2963 | * @param array $query_args The original query_args array coming into the |
| 2964 | 2964 | * method. |
| 2965 | 2965 | */ |
| 2966 | - do_action( 'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args ); |
|
| 2966 | + do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args); |
|
| 2967 | 2967 | |
| 2968 | 2968 | //calculate where we're going (if we have a "save and close" button pushed) |
| 2969 | - if ( isset($this->_req_data['save_and_close'] ) && isset($this->_req_data['save_and_close_referrer'] ) ) { |
|
| 2969 | + if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
|
| 2970 | 2970 | // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
| 2971 | - $parsed_url = parse_url( $this->_req_data['save_and_close_referrer'] ); |
|
| 2971 | + $parsed_url = parse_url($this->_req_data['save_and_close_referrer']); |
|
| 2972 | 2972 | // regenerate query args array from referrer URL |
| 2973 | - parse_str( $parsed_url['query'], $query_args ); |
|
| 2973 | + parse_str($parsed_url['query'], $query_args); |
|
| 2974 | 2974 | // correct page and action will be in the query args now |
| 2975 | - $redirect_url = admin_url( 'admin.php' ); |
|
| 2975 | + $redirect_url = admin_url('admin.php'); |
|
| 2976 | 2976 | } |
| 2977 | 2977 | |
| 2978 | 2978 | //merge any default query_args set in _default_route_query_args property |
| 2979 | - if ( ! empty( $this->_default_route_query_args ) && ! $this->_is_UI_request ) { |
|
| 2979 | + if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) { |
|
| 2980 | 2980 | $args_to_merge = array(); |
| 2981 | - foreach ( $this->_default_route_query_args as $query_param => $query_value ) { |
|
| 2981 | + foreach ($this->_default_route_query_args as $query_param => $query_value) { |
|
| 2982 | 2982 | //is there a wp_referer array in our _default_route_query_args property? |
| 2983 | - if ( $query_param == 'wp_referer' ) { |
|
| 2983 | + if ($query_param == 'wp_referer') { |
|
| 2984 | 2984 | $query_value = (array) $query_value; |
| 2985 | - foreach ( $query_value as $reference => $value ) { |
|
| 2986 | - if ( strpos( $reference, 'nonce' ) !== false ) { |
|
| 2985 | + foreach ($query_value as $reference => $value) { |
|
| 2986 | + if (strpos($reference, 'nonce') !== false) { |
|
| 2987 | 2987 | continue; |
| 2988 | 2988 | } |
| 2989 | 2989 | |
| 2990 | 2990 | //finally we will override any arguments in the referer with |
| 2991 | 2991 | //what might be set on the _default_route_query_args array. |
| 2992 | - if ( isset( $this->_default_route_query_args[$reference] ) ) { |
|
| 2993 | - $args_to_merge[$reference] = urlencode( $this->_default_route_query_args[$reference] ); |
|
| 2992 | + if (isset($this->_default_route_query_args[$reference])) { |
|
| 2993 | + $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]); |
|
| 2994 | 2994 | } else { |
| 2995 | - $args_to_merge[$reference] = urlencode( $value ); |
|
| 2995 | + $args_to_merge[$reference] = urlencode($value); |
|
| 2996 | 2996 | } |
| 2997 | 2997 | } |
| 2998 | 2998 | continue; |
@@ -3003,7 +3003,7 @@ discard block |
||
| 3003 | 3003 | |
| 3004 | 3004 | //now let's merge these arguments but override with what was specifically sent in to the |
| 3005 | 3005 | //redirect. |
| 3006 | - $query_args = array_merge( $args_to_merge, $query_args ); |
|
| 3006 | + $query_args = array_merge($args_to_merge, $query_args); |
|
| 3007 | 3007 | } |
| 3008 | 3008 | |
| 3009 | 3009 | $this->_process_notices($query_args); |
@@ -3012,19 +3012,19 @@ discard block |
||
| 3012 | 3012 | // generate redirect url |
| 3013 | 3013 | |
| 3014 | 3014 | // if redirecting to anything other than the main page, add a nonce |
| 3015 | - if ( isset( $query_args['action'] )) { |
|
| 3015 | + if (isset($query_args['action'])) { |
|
| 3016 | 3016 | // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
| 3017 | - $query_args['_wpnonce'] = wp_create_nonce( $query_args['action'] . '_nonce' ); |
|
| 3017 | + $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
| 3018 | 3018 | } |
| 3019 | 3019 | |
| 3020 | 3020 | //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
| 3021 | - do_action( 'AHEE_redirect_' . $classname . $this->_req_action, $query_args ); |
|
| 3021 | + do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args); |
|
| 3022 | 3022 | |
| 3023 | - $redirect_url = apply_filters( 'FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce( $query_args, $redirect_url ), $query_args ); |
|
| 3023 | + $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
| 3024 | 3024 | |
| 3025 | 3025 | |
| 3026 | 3026 | // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
| 3027 | - if ( defined('DOING_AJAX' ) ) { |
|
| 3027 | + if (defined('DOING_AJAX')) { |
|
| 3028 | 3028 | $default_data = array( |
| 3029 | 3029 | 'close' => TRUE, |
| 3030 | 3030 | 'redirect_url' => $redirect_url, |
@@ -3033,11 +3033,11 @@ discard block |
||
| 3033 | 3033 | ); |
| 3034 | 3034 | |
| 3035 | 3035 | $this->_template_args['success'] = $success; |
| 3036 | - $this->_template_args['data'] = !empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data'] ): $default_data; |
|
| 3036 | + $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data; |
|
| 3037 | 3037 | $this->_return_json(); |
| 3038 | 3038 | } |
| 3039 | 3039 | |
| 3040 | - wp_safe_redirect( $redirect_url ); |
|
| 3040 | + wp_safe_redirect($redirect_url); |
|
| 3041 | 3041 | exit(); |
| 3042 | 3042 | } |
| 3043 | 3043 | |
@@ -3053,30 +3053,30 @@ discard block |
||
| 3053 | 3053 | * @param bool $sticky_notices This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice. |
| 3054 | 3054 | * @return void |
| 3055 | 3055 | */ |
| 3056 | - protected function _process_notices( $query_args = array(), $skip_route_verify = FALSE , $sticky_notices = TRUE ) { |
|
| 3056 | + protected function _process_notices($query_args = array(), $skip_route_verify = FALSE, $sticky_notices = TRUE) { |
|
| 3057 | 3057 | |
| 3058 | 3058 | //first let's set individual error properties if doing_ajax and the properties aren't already set. |
| 3059 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 3060 | - $notices = EE_Error::get_notices( false ); |
|
| 3061 | - if ( empty( $this->_template_args['success'] ) ) { |
|
| 3062 | - $this->_template_args['success'] = isset( $notices['success'] ) ? $notices['success'] : false; |
|
| 3059 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 3060 | + $notices = EE_Error::get_notices(false); |
|
| 3061 | + if (empty($this->_template_args['success'])) { |
|
| 3062 | + $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false; |
|
| 3063 | 3063 | } |
| 3064 | 3064 | |
| 3065 | - if ( empty( $this->_template_args['errors'] ) ) { |
|
| 3066 | - $this->_template_args['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : false; |
|
| 3065 | + if (empty($this->_template_args['errors'])) { |
|
| 3066 | + $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false; |
|
| 3067 | 3067 | } |
| 3068 | 3068 | |
| 3069 | - if ( empty( $this->_template_args['attention'] ) ) { |
|
| 3070 | - $this->_template_args['attention'] = isset( $notices['attention'] ) ? $notices['attention'] : false; |
|
| 3069 | + if (empty($this->_template_args['attention'])) { |
|
| 3070 | + $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false; |
|
| 3071 | 3071 | } |
| 3072 | 3072 | } |
| 3073 | 3073 | |
| 3074 | 3074 | $this->_template_args['notices'] = EE_Error::get_notices(); |
| 3075 | 3075 | |
| 3076 | 3076 | //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true) |
| 3077 | - if ( ! defined( 'DOING_AJAX' ) || $sticky_notices ) { |
|
| 3078 | - $route = isset( $query_args['action'] ) ? $query_args['action'] : 'default'; |
|
| 3079 | - $this->_add_transient( $route, $this->_template_args['notices'], TRUE, $skip_route_verify ); |
|
| 3077 | + if ( ! defined('DOING_AJAX') || $sticky_notices) { |
|
| 3078 | + $route = isset($query_args['action']) ? $query_args['action'] : 'default'; |
|
| 3079 | + $this->_add_transient($route, $this->_template_args['notices'], TRUE, $skip_route_verify); |
|
| 3080 | 3080 | } |
| 3081 | 3081 | } |
| 3082 | 3082 | |
@@ -3106,7 +3106,7 @@ discard block |
||
| 3106 | 3106 | $exclude_nonce = false |
| 3107 | 3107 | ) { |
| 3108 | 3108 | //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along) |
| 3109 | - if ( empty( $base_url ) && ! isset( $this->_page_routes[ $action ] ) ) { |
|
| 3109 | + if (empty($base_url) && ! isset($this->_page_routes[$action])) { |
|
| 3110 | 3110 | throw new EE_Error( |
| 3111 | 3111 | sprintf( |
| 3112 | 3112 | __( |
@@ -3117,7 +3117,7 @@ discard block |
||
| 3117 | 3117 | ) |
| 3118 | 3118 | ); |
| 3119 | 3119 | } |
| 3120 | - if ( ! isset( $this->_labels['buttons'][ $type ] ) ) { |
|
| 3120 | + if ( ! isset($this->_labels['buttons'][$type])) { |
|
| 3121 | 3121 | throw new EE_Error( |
| 3122 | 3122 | sprintf( |
| 3123 | 3123 | __( |
@@ -3129,8 +3129,8 @@ discard block |
||
| 3129 | 3129 | ); |
| 3130 | 3130 | } |
| 3131 | 3131 | //finally check user access for this button. |
| 3132 | - $has_access = $this->check_user_access( $action, true ); |
|
| 3133 | - if ( ! $has_access ) { |
|
| 3132 | + $has_access = $this->check_user_access($action, true); |
|
| 3133 | + if ( ! $has_access) { |
|
| 3134 | 3134 | return ''; |
| 3135 | 3135 | } |
| 3136 | 3136 | $_base_url = ! $base_url ? $this->_admin_base_url : $base_url; |
@@ -3138,11 +3138,11 @@ discard block |
||
| 3138 | 3138 | 'action' => $action |
| 3139 | 3139 | ); |
| 3140 | 3140 | //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten. |
| 3141 | - if ( ! empty( $extra_request ) ) { |
|
| 3142 | - $query_args = array_merge( $extra_request, $query_args ); |
|
| 3141 | + if ( ! empty($extra_request)) { |
|
| 3142 | + $query_args = array_merge($extra_request, $query_args); |
|
| 3143 | 3143 | } |
| 3144 | - $url = self::add_query_args_and_nonce( $query_args, $_base_url, false, $exclude_nonce ); |
|
| 3145 | - return EEH_Template::get_button_or_link( $url, $this->_labels['buttons'][ $type ], $class ); |
|
| 3144 | + $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce); |
|
| 3145 | + return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class); |
|
| 3146 | 3146 | } |
| 3147 | 3147 | |
| 3148 | 3148 | |
@@ -3157,11 +3157,11 @@ discard block |
||
| 3157 | 3157 | $args = array( |
| 3158 | 3158 | 'label' => $this->_admin_page_title, |
| 3159 | 3159 | 'default' => 10, |
| 3160 | - 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page' |
|
| 3160 | + 'option' => $this->_current_page.'_'.$this->_current_view.'_per_page' |
|
| 3161 | 3161 | ); |
| 3162 | 3162 | //ONLY add the screen option if the user has access to it. |
| 3163 | - if ( $this->check_user_access( $this->_current_view, true ) ) { |
|
| 3164 | - add_screen_option( $option, $args ); |
|
| 3163 | + if ($this->check_user_access($this->_current_view, true)) { |
|
| 3164 | + add_screen_option($option, $args); |
|
| 3165 | 3165 | } |
| 3166 | 3166 | } |
| 3167 | 3167 | |
@@ -3177,36 +3177,36 @@ discard block |
||
| 3177 | 3177 | * @return void |
| 3178 | 3178 | */ |
| 3179 | 3179 | private function _set_per_page_screen_options() { |
| 3180 | - if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
|
| 3181 | - check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
|
| 3180 | + if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
| 3181 | + check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
| 3182 | 3182 | |
| 3183 | - if ( !$user = wp_get_current_user() ) |
|
| 3183 | + if ( ! $user = wp_get_current_user()) |
|
| 3184 | 3184 | return; |
| 3185 | 3185 | $option = $_POST['wp_screen_options']['option']; |
| 3186 | 3186 | $value = $_POST['wp_screen_options']['value']; |
| 3187 | 3187 | |
| 3188 | - if ( $option != sanitize_key( $option ) ) |
|
| 3188 | + if ($option != sanitize_key($option)) |
|
| 3189 | 3189 | return; |
| 3190 | 3190 | |
| 3191 | 3191 | $map_option = $option; |
| 3192 | 3192 | |
| 3193 | 3193 | $option = str_replace('-', '_', $option); |
| 3194 | 3194 | |
| 3195 | - switch ( $map_option ) { |
|
| 3196 | - case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
| 3195 | + switch ($map_option) { |
|
| 3196 | + case $this->_current_page.'_'.$this->_current_view.'_per_page': |
|
| 3197 | 3197 | $value = (int) $value; |
| 3198 | - if ( $value < 1 || $value > 999 ) |
|
| 3198 | + if ($value < 1 || $value > 999) |
|
| 3199 | 3199 | return; |
| 3200 | 3200 | break; |
| 3201 | 3201 | default: |
| 3202 | - $value = apply_filters( 'FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value ); |
|
| 3203 | - if ( false === $value ) |
|
| 3202 | + $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value); |
|
| 3203 | + if (false === $value) |
|
| 3204 | 3204 | return; |
| 3205 | 3205 | break; |
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | 3208 | update_user_meta($user->ID, $option, $value); |
| 3209 | - wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) ); |
|
| 3209 | + wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
| 3210 | 3210 | exit; |
| 3211 | 3211 | } |
| 3212 | 3212 | } |
@@ -3217,8 +3217,8 @@ discard block |
||
| 3217 | 3217 | * This just allows for setting the $_template_args property if it needs to be set outside the object |
| 3218 | 3218 | * @param array $data array that will be assigned to template args. |
| 3219 | 3219 | */ |
| 3220 | - public function set_template_args( $data ) { |
|
| 3221 | - $this->_template_args = array_merge( $this->_template_args, (array) $data ); |
|
| 3220 | + public function set_template_args($data) { |
|
| 3221 | + $this->_template_args = array_merge($this->_template_args, (array) $data); |
|
| 3222 | 3222 | } |
| 3223 | 3223 | |
| 3224 | 3224 | |
@@ -3234,26 +3234,26 @@ discard block |
||
| 3234 | 3234 | * @param bool $skip_route_verify Used to indicate we want to skip route verification. This is usually ONLY used when we are adding a transient before page_routes have been defined. |
| 3235 | 3235 | * @return void |
| 3236 | 3236 | */ |
| 3237 | - protected function _add_transient( $route, $data, $notices = FALSE, $skip_route_verify = FALSE ) { |
|
| 3237 | + protected function _add_transient($route, $data, $notices = FALSE, $skip_route_verify = FALSE) { |
|
| 3238 | 3238 | $user_id = get_current_user_id(); |
| 3239 | 3239 | |
| 3240 | - if ( !$skip_route_verify ) |
|
| 3240 | + if ( ! $skip_route_verify) |
|
| 3241 | 3241 | $this->_verify_route($route); |
| 3242 | 3242 | |
| 3243 | 3243 | |
| 3244 | 3244 | //now let's set the string for what kind of transient we're setting |
| 3245 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3246 | - $data = $notices ? array( 'notices' => $data ) : $data; |
|
| 3245 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
| 3246 | + $data = $notices ? array('notices' => $data) : $data; |
|
| 3247 | 3247 | //is there already a transient for this route? If there is then let's ADD to that transient |
| 3248 | - $existing = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient ); |
|
| 3249 | - if ( $existing ) { |
|
| 3250 | - $data = array_merge( (array) $data, (array) $existing ); |
|
| 3248 | + $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
| 3249 | + if ($existing) { |
|
| 3250 | + $data = array_merge((array) $data, (array) $existing); |
|
| 3251 | 3251 | } |
| 3252 | 3252 | |
| 3253 | - if ( is_multisite() && is_network_admin() ) { |
|
| 3254 | - set_site_transient( $transient, $data, 8 ); |
|
| 3253 | + if (is_multisite() && is_network_admin()) { |
|
| 3254 | + set_site_transient($transient, $data, 8); |
|
| 3255 | 3255 | } else { |
| 3256 | - set_transient( $transient, $data, 8 ); |
|
| 3256 | + set_transient($transient, $data, 8); |
|
| 3257 | 3257 | } |
| 3258 | 3258 | } |
| 3259 | 3259 | |
@@ -3265,18 +3265,18 @@ discard block |
||
| 3265 | 3265 | * @param bool $notices true we get notices transient. False we just return normal route transient |
| 3266 | 3266 | * @return mixed data |
| 3267 | 3267 | */ |
| 3268 | - protected function _get_transient( $notices = FALSE, $route = FALSE ) { |
|
| 3268 | + protected function _get_transient($notices = FALSE, $route = FALSE) { |
|
| 3269 | 3269 | $user_id = get_current_user_id(); |
| 3270 | - $route = !$route ? $this->_req_action : $route; |
|
| 3271 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3272 | - $data = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient ); |
|
| 3270 | + $route = ! $route ? $this->_req_action : $route; |
|
| 3271 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
| 3272 | + $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
| 3273 | 3273 | //delete transient after retrieval (just in case it hasn't expired); |
| 3274 | - if ( is_multisite() && is_network_admin() ) { |
|
| 3275 | - delete_site_transient( $transient ); |
|
| 3274 | + if (is_multisite() && is_network_admin()) { |
|
| 3275 | + delete_site_transient($transient); |
|
| 3276 | 3276 | } else { |
| 3277 | - delete_transient( $transient ); |
|
| 3277 | + delete_transient($transient); |
|
| 3278 | 3278 | } |
| 3279 | - return $notices && isset( $data['notices'] ) ? $data['notices'] : $data; |
|
| 3279 | + return $notices && isset($data['notices']) ? $data['notices'] : $data; |
|
| 3280 | 3280 | } |
| 3281 | 3281 | |
| 3282 | 3282 | |
@@ -3293,12 +3293,12 @@ discard block |
||
| 3293 | 3293 | |
| 3294 | 3294 | //retrieve all existing transients |
| 3295 | 3295 | $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'"; |
| 3296 | - if ( $results = $wpdb->get_results( $query ) ) { |
|
| 3297 | - foreach ( $results as $result ) { |
|
| 3298 | - $transient = str_replace( '_transient_', '', $result->option_name ); |
|
| 3299 | - get_transient( $transient ); |
|
| 3300 | - if ( is_multisite() && is_network_admin() ) { |
|
| 3301 | - get_site_transient( $transient ); |
|
| 3296 | + if ($results = $wpdb->get_results($query)) { |
|
| 3297 | + foreach ($results as $result) { |
|
| 3298 | + $transient = str_replace('_transient_', '', $result->option_name); |
|
| 3299 | + get_transient($transient); |
|
| 3300 | + if (is_multisite() && is_network_admin()) { |
|
| 3301 | + get_site_transient($transient); |
|
| 3302 | 3302 | } |
| 3303 | 3303 | } |
| 3304 | 3304 | } |
@@ -3448,23 +3448,23 @@ discard block |
||
| 3448 | 3448 | * @param string $line line no where error occurred |
| 3449 | 3449 | * @return boolean |
| 3450 | 3450 | */ |
| 3451 | - protected function _update_espresso_configuration( $tab, $config, $file = '', $func = '', $line = '' ) { |
|
| 3451 | + protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') { |
|
| 3452 | 3452 | |
| 3453 | 3453 | //remove any options that are NOT going to be saved with the config settings. |
| 3454 | - if ( isset( $config->core->ee_ueip_optin ) ) { |
|
| 3454 | + if (isset($config->core->ee_ueip_optin)) { |
|
| 3455 | 3455 | $config->core->ee_ueip_has_notified = TRUE; |
| 3456 | 3456 | // TODO: remove the following two lines and make sure values are migrated from 3.1 |
| 3457 | - update_option( 'ee_ueip_optin', $config->core->ee_ueip_optin); |
|
| 3458 | - update_option( 'ee_ueip_has_notified', TRUE ); |
|
| 3457 | + update_option('ee_ueip_optin', $config->core->ee_ueip_optin); |
|
| 3458 | + update_option('ee_ueip_has_notified', TRUE); |
|
| 3459 | 3459 | } |
| 3460 | 3460 | // and save it (note we're also doing the network save here) |
| 3461 | - $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config( FALSE, FALSE ) : TRUE; |
|
| 3462 | - $config_saved = EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
| 3463 | - if ( $config_saved && $net_saved ) { |
|
| 3464 | - EE_Error::add_success( sprintf( __('"%s" have been successfully updated.', 'event_espresso'), $tab )); |
|
| 3461 | + $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(FALSE, FALSE) : TRUE; |
|
| 3462 | + $config_saved = EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
| 3463 | + if ($config_saved && $net_saved) { |
|
| 3464 | + EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab)); |
|
| 3465 | 3465 | return TRUE; |
| 3466 | 3466 | } else { |
| 3467 | - EE_Error::add_error( sprintf( __('The "%s" were not updated.', 'event_espresso'), $tab ), $file, $func, $line ); |
|
| 3467 | + EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line); |
|
| 3468 | 3468 | return FALSE; |
| 3469 | 3469 | } |
| 3470 | 3470 | } |
@@ -3477,7 +3477,7 @@ discard block |
||
| 3477 | 3477 | * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument. |
| 3478 | 3478 | * @return array |
| 3479 | 3479 | */ |
| 3480 | - public function get_yes_no_values(){ |
|
| 3480 | + public function get_yes_no_values() { |
|
| 3481 | 3481 | return $this->_yes_no_values; |
| 3482 | 3482 | } |
| 3483 | 3483 | |
@@ -3499,8 +3499,8 @@ discard block |
||
| 3499 | 3499 | * |
| 3500 | 3500 | * @return string |
| 3501 | 3501 | */ |
| 3502 | - protected function _next_link( $url, $class = 'dashicons dashicons-arrow-right' ) { |
|
| 3503 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3502 | + protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') { |
|
| 3503 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
| 3504 | 3504 | } |
| 3505 | 3505 | |
| 3506 | 3506 | |
@@ -3514,8 +3514,8 @@ discard block |
||
| 3514 | 3514 | * |
| 3515 | 3515 | * @return string |
| 3516 | 3516 | */ |
| 3517 | - protected function _previous_link( $url, $class = 'dashicons dashicons-arrow-left' ) { |
|
| 3518 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3517 | + protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') { |
|
| 3518 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
| 3519 | 3519 | } |
| 3520 | 3520 | |
| 3521 | 3521 | |
@@ -3534,8 +3534,8 @@ discard block |
||
| 3534 | 3534 | * @return bool success/fail |
| 3535 | 3535 | */ |
| 3536 | 3536 | protected function _process_resend_registration() { |
| 3537 | - $this->_template_args['success'] = EED_Messages::process_resend( $this->_req_data ); |
|
| 3538 | - do_action( 'AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data ); |
|
| 3537 | + $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data); |
|
| 3538 | + do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data); |
|
| 3539 | 3539 | return $this->_template_args['success']; |
| 3540 | 3540 | } |
| 3541 | 3541 | |
@@ -3548,11 +3548,11 @@ discard block |
||
| 3548 | 3548 | * @param \EE_Payment $payment |
| 3549 | 3549 | * @return bool success/fail |
| 3550 | 3550 | */ |
| 3551 | - protected function _process_payment_notification( EE_Payment $payment ) { |
|
| 3552 | - add_filter( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true' ); |
|
| 3553 | - do_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', $payment ); |
|
| 3554 | - $this->_template_args['success'] = apply_filters( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment ); |
|
| 3555 | - return $this->_template_args[ 'success' ]; |
|
| 3551 | + protected function _process_payment_notification(EE_Payment $payment) { |
|
| 3552 | + add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true'); |
|
| 3553 | + do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment); |
|
| 3554 | + $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment); |
|
| 3555 | + return $this->_template_args['success']; |
|
| 3556 | 3556 | } |
| 3557 | 3557 | |
| 3558 | 3558 | |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * grab url requests and route them |
| 166 | - * @access private |
|
| 167 | - * @return void |
|
| 168 | - */ |
|
| 166 | + * @access private |
|
| 167 | + * @return void |
|
| 168 | + */ |
|
| 169 | 169 | public function _set_page_routes() { |
| 170 | 170 | |
| 171 | 171 | $this->_get_registration_status_array(); |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | 'title' => __('Registrations Other', 'event_espresso'), |
| 438 | 438 | 'filename' => 'registrations_overview_other' |
| 439 | 439 | ) |
| 440 | - ), |
|
| 440 | + ), |
|
| 441 | 441 | 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
| 442 | 442 | 'qtips' => array('Registration_List_Table_Tips'), |
| 443 | 443 | 'list_table' => 'EE_Registrations_List_Table', |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | : $this->_admin_base_url, |
| 457 | 457 | 'persistent' => FALSE |
| 458 | 458 | ), |
| 459 | - 'help_tabs' => array( |
|
| 459 | + 'help_tabs' => array( |
|
| 460 | 460 | 'registrations_details_help_tab' => array( |
| 461 | 461 | 'title' => __('Registration Details', 'event_espresso'), |
| 462 | 462 | 'filename' => 'registrations_details' |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | 'order' => 20 |
| 521 | 521 | ), |
| 522 | 522 | 'list_table' => 'EE_Attendee_Contact_List_Table', |
| 523 | - 'help_tabs' => array( |
|
| 523 | + 'help_tabs' => array( |
|
| 524 | 524 | 'registrations_contact_list_help_tab' => array( |
| 525 | 525 | 'title' => __('Registrations Contact List', 'event_espresso'), |
| 526 | 526 | 'filename' => 'registrations_contact_list' |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | 'title' => __('Contact List Other', 'event_espresso'), |
| 538 | 538 | 'filename' => 'registrations_contact_list_other' |
| 539 | 539 | ) |
| 540 | - ), |
|
| 540 | + ), |
|
| 541 | 541 | 'help_tour' => array( 'Contact_List_Help_Tour' ), |
| 542 | 542 | 'metaboxes' => array(), |
| 543 | 543 | 'require_nonce' => FALSE |
@@ -571,9 +571,9 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | /** |
| 573 | 573 | * get list of registration statuses |
| 574 | - * @access private |
|
| 575 | - * @return void |
|
| 576 | - */ |
|
| 574 | + * @access private |
|
| 575 | + * @return void |
|
| 576 | + */ |
|
| 577 | 577 | private function _get_registration_status_array() { |
| 578 | 578 | self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
| 579 | 579 | } |
@@ -865,8 +865,8 @@ discard block |
||
| 865 | 865 | |
| 866 | 866 | |
| 867 | 867 | /** |
| 868 | - * @throws \EE_Error |
|
| 869 | - */ |
|
| 868 | + * @throws \EE_Error |
|
| 869 | + */ |
|
| 870 | 870 | protected function _registrations_overview_list_table() { |
| 871 | 871 | $this->_template_args['admin_page_header'] = ''; |
| 872 | 872 | $EVT_ID = ! empty( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : 0; |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | return TRUE; |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | - $REG = EEM_Registration::instance(); |
|
| 929 | + $REG = EEM_Registration::instance(); |
|
| 930 | 930 | |
| 931 | 931 | $REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
| 932 | 932 | |
@@ -1150,9 +1150,9 @@ discard block |
||
| 1150 | 1150 | |
| 1151 | 1151 | /** |
| 1152 | 1152 | * generates HTML for the View Registration Details Admin page |
| 1153 | - * @access protected |
|
| 1154 | - * @return void |
|
| 1155 | - */ |
|
| 1153 | + * @access protected |
|
| 1154 | + * @return void |
|
| 1155 | + */ |
|
| 1156 | 1156 | protected function _registration_details() { |
| 1157 | 1157 | |
| 1158 | 1158 | $this->_template_args = array(); |
@@ -1325,16 +1325,16 @@ discard block |
||
| 1325 | 1325 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
| 1326 | 1326 | //); |
| 1327 | 1327 | //Approved |
| 1328 | - //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant . |
|
| 1328 | + //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant . |
|
| 1329 | 1329 | //Cancelled |
| 1330 | 1330 | // A { |
| 1331 | 1331 | // cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved . |
| 1332 | 1332 | //Declined |
| 1333 | - //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved . |
|
| 1333 | + //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved . |
|
| 1334 | 1334 | //Not Approved |
| 1335 | - //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved . |
|
| 1335 | + //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved . |
|
| 1336 | 1336 | //Pending Payment |
| 1337 | - //A pending registration allows payments . The status will be automatically toggled to approved if the { |
|
| 1337 | + //A pending registration allows payments . The status will be automatically toggled to approved if the { |
|
| 1338 | 1338 | // payment} is made in full by registrant . |
| 1339 | 1339 | |
| 1340 | 1340 | } |
@@ -1441,8 +1441,8 @@ discard block |
||
| 1441 | 1441 | */ |
| 1442 | 1442 | protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
| 1443 | 1443 | $result = ! empty( $STS_ID ) |
| 1444 | - ? $this->_set_registration_status_from_request( $STS_ID, $notify ) |
|
| 1445 | - : array( 'success' => false ); |
|
| 1444 | + ? $this->_set_registration_status_from_request( $STS_ID, $notify ) |
|
| 1445 | + : array( 'success' => false ); |
|
| 1446 | 1446 | $success = isset( $result['success'] ) && $result['success']; |
| 1447 | 1447 | //setup success message |
| 1448 | 1448 | if ( $success ) { |
@@ -1624,9 +1624,9 @@ discard block |
||
| 1624 | 1624 | |
| 1625 | 1625 | /** |
| 1626 | 1626 | * generates HTML for the Registration main meta box |
| 1627 | - * @access public |
|
| 1628 | - * @return void |
|
| 1629 | - */ |
|
| 1627 | + * @access public |
|
| 1628 | + * @return void |
|
| 1629 | + */ |
|
| 1630 | 1630 | public function _reg_details_meta_box() { |
| 1631 | 1631 | EEH_Autoloader::register_line_item_display_autoloaders(); |
| 1632 | 1632 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
@@ -1760,7 +1760,7 @@ discard block |
||
| 1760 | 1760 | * |
| 1761 | 1761 | * @access public |
| 1762 | 1762 | * @return void |
| 1763 | - */ |
|
| 1763 | + */ |
|
| 1764 | 1764 | public function _reg_questions_meta_box() { |
| 1765 | 1765 | //allow someone to override this method entirely |
| 1766 | 1766 | if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
@@ -1962,12 +1962,12 @@ discard block |
||
| 1962 | 1962 | |
| 1963 | 1963 | /** |
| 1964 | 1964 | * generates HTML for the Registration main meta box |
| 1965 | - * @access public |
|
| 1966 | - * @return void |
|
| 1967 | - */ |
|
| 1965 | + * @access public |
|
| 1966 | + * @return void |
|
| 1967 | + */ |
|
| 1968 | 1968 | public function _reg_attendees_meta_box() { |
| 1969 | 1969 | |
| 1970 | - $REG = EEM_Registration::instance(); |
|
| 1970 | + $REG = EEM_Registration::instance(); |
|
| 1971 | 1971 | //get all other registrations on this transaction, and cache |
| 1972 | 1972 | //the attendees for them so we don't have to run another query using force_join |
| 1973 | 1973 | $registrations = $REG->get_all(array( |
@@ -2019,9 +2019,9 @@ discard block |
||
| 2019 | 2019 | |
| 2020 | 2020 | /** |
| 2021 | 2021 | * generates HTML for the Edit Registration side meta box |
| 2022 | - * @access public |
|
| 2023 | - * @return void |
|
| 2024 | - */ |
|
| 2022 | + * @access public |
|
| 2023 | + * @return void |
|
| 2024 | + */ |
|
| 2025 | 2025 | public function _reg_registrant_side_meta_box() { |
| 2026 | 2026 | |
| 2027 | 2027 | /*@var $attendee EE_Attendee */ |
@@ -2402,9 +2402,9 @@ discard block |
||
| 2402 | 2402 | |
| 2403 | 2403 | /** |
| 2404 | 2404 | * set_reg_event |
| 2405 | - * @access private |
|
| 2406 | - * @return boolean |
|
| 2407 | - */ |
|
| 2405 | + * @access private |
|
| 2406 | + * @return boolean |
|
| 2407 | + */ |
|
| 2408 | 2408 | private function _set_reg_event() { |
| 2409 | 2409 | if ( is_object( $this->_reg_event )) { |
| 2410 | 2410 | return TRUE; |
@@ -2544,9 +2544,9 @@ discard block |
||
| 2544 | 2544 | |
| 2545 | 2545 | /** |
| 2546 | 2546 | * generates HTML for the Attendee Contact List |
| 2547 | - * @access protected |
|
| 2548 | - * @return void |
|
| 2549 | - */ |
|
| 2547 | + * @access protected |
|
| 2548 | + * @return void |
|
| 2549 | + */ |
|
| 2550 | 2550 | protected function _attendee_contact_list_table() { |
| 2551 | 2551 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
| 2552 | 2552 | $this->_search_btn_label = __('Contacts', 'event_espresso'); |
@@ -2560,9 +2560,9 @@ discard block |
||
| 2560 | 2560 | /** |
| 2561 | 2561 | * get_attendees |
| 2562 | 2562 | * @param bool $count whether to return count or data. |
| 2563 | - * @access public |
|
| 2564 | - * @return array |
|
| 2565 | - */ |
|
| 2563 | + * @access public |
|
| 2564 | + * @return array |
|
| 2565 | + */ |
|
| 2566 | 2566 | public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
| 2567 | 2567 | |
| 2568 | 2568 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -2894,9 +2894,9 @@ discard block |
||
| 2894 | 2894 | |
| 2895 | 2895 | /** |
| 2896 | 2896 | * _attendee_details |
| 2897 | - * @access protected |
|
| 2898 | - * @return void |
|
| 2899 | - */ |
|
| 2897 | + * @access protected |
|
| 2898 | + * @return void |
|
| 2899 | + */ |
|
| 2900 | 2900 | public function attendee_registrations_meta_box( $post ) { |
| 2901 | 2901 | |
| 2902 | 2902 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
@@ -2929,10 +2929,10 @@ discard block |
||
| 2929 | 2929 | |
| 2930 | 2930 | /** |
| 2931 | 2931 | * _trash_or_restore_attendee |
| 2932 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2933 | - * @access protected |
|
| 2934 | - * @return void |
|
| 2935 | - */ |
|
| 2932 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2933 | + * @access protected |
|
| 2934 | + * @return void |
|
| 2935 | + */ |
|
| 2936 | 2936 | protected function _trash_or_restore_attendees( $trash = TRUE ) { |
| 2937 | 2937 | |
| 2938 | 2938 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -56,26 +56,26 @@ discard block |
||
| 56 | 56 | * @param bool $routing |
| 57 | 57 | * @return Registrations_Admin_Page |
| 58 | 58 | */ |
| 59 | - public function __construct( $routing = TRUE ) { |
|
| 60 | - parent::__construct( $routing ); |
|
| 61 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' )); |
|
| 59 | + public function __construct($routing = TRUE) { |
|
| 60 | + parent::__construct($routing); |
|
| 61 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | public function wp_loaded() { |
| 67 | 67 | // when adding a new registration... |
| 68 | - if ( isset( $this->_req_data[ 'action' ] ) && $this->_req_data[ 'action' ] == 'new_registration' ) { |
|
| 68 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] == 'new_registration') { |
|
| 69 | 69 | EE_System::do_not_cache(); |
| 70 | 70 | if ( |
| 71 | - ! isset( $this->_req_data[ 'processing_registration' ] ) |
|
| 72 | - || absint( $this->_req_data[ 'processing_registration' ] ) !== 1 |
|
| 71 | + ! isset($this->_req_data['processing_registration']) |
|
| 72 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
| 73 | 73 | ) { |
| 74 | 74 | // and it's NOT the attendee information reg step |
| 75 | 75 | // force cookie expiration by setting time to last week |
| 76 | - setcookie( 'ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/' ); |
|
| 76 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 77 | 77 | // and update the global |
| 78 | - $_COOKIE[ 'ee_registration_added' ] = 0; |
|
| 78 | + $_COOKIE['ee_registration_added'] = 0; |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -109,16 +109,16 @@ discard block |
||
| 109 | 109 | 'trash' => 'post.php' |
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 ); |
|
| 112 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 113 | 113 | //add filters so that the comment urls don't take users to a confusing 404 page |
| 114 | - add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 ); |
|
| 114 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
| 118 | - public function clear_comment_link( $link, $comment, $args ) { |
|
| 118 | + public function clear_comment_link($link, $comment, $args) { |
|
| 119 | 119 | //gotta make sure this only happens on this route |
| 120 | - $post_type = get_post_type( $comment->comment_post_ID); |
|
| 121 | - if ( $post_type == 'espresso_attendees' ) |
|
| 120 | + $post_type = get_post_type($comment->comment_post_ID); |
|
| 121 | + if ($post_type == 'espresso_attendees') |
|
| 122 | 122 | return '#commentsdiv'; |
| 123 | 123 | return $link; |
| 124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | protected function _ajax_hooks() { |
| 128 | 128 | //todo: all hooks for registrations ajax goes in here |
| 129 | - add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' )); |
|
| 129 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | 'add-attendee' => __('Add Contact', 'event_espresso'), |
| 142 | 142 | 'edit' => __('Edit Contact', 'event_espresso'), |
| 143 | 143 | 'report'=> __("Event Registrations CSV Report", "event_espresso"), |
| 144 | - 'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ), |
|
| 145 | - 'contact_list_report' => __( 'Contact List Report', 'event_espresso' ), |
|
| 144 | + 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
| 145 | + 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
| 146 | 146 | 'contact_list_export'=> __("Export Data", "event_espresso"), |
| 147 | 147 | ), |
| 148 | 148 | 'publishbox' => array( |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | $this->_get_registration_status_array(); |
| 172 | 172 | |
| 173 | - $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
|
| 174 | - $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0; |
|
| 175 | - $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
|
| 173 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0; |
|
| 174 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0; |
|
| 175 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id; |
|
| 176 | 176 | |
| 177 | 177 | $this->_page_routes = array( |
| 178 | 178 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | 'restore_registrations' => array( |
| 207 | 207 | 'func' => '_trash_or_restore_registrations', |
| 208 | - 'args' => array( 'trash' => FALSE ), |
|
| 208 | + 'args' => array('trash' => FALSE), |
|
| 209 | 209 | 'noheader' => TRUE, |
| 210 | 210 | 'capability' => 'ee_delete_registrations' |
| 211 | 211 | ), |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | 'filename' => 'registrations_overview_other' |
| 439 | 439 | ) |
| 440 | 440 | ), |
| 441 | - 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
|
| 441 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 442 | 442 | 'qtips' => array('Registration_List_Table_Tips'), |
| 443 | 443 | 'list_table' => 'EE_Registrations_List_Table', |
| 444 | 444 | 'require_nonce' => FALSE |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | 'order' => 15, |
| 451 | 451 | 'url' => isset($this->_req_data['_REG_ID']) |
| 452 | 452 | ? add_query_arg( |
| 453 | - array('_REG_ID' => $this->_req_data['_REG_ID'] ), |
|
| 453 | + array('_REG_ID' => $this->_req_data['_REG_ID']), |
|
| 454 | 454 | $this->_current_page_view_url |
| 455 | 455 | ) |
| 456 | 456 | : $this->_admin_base_url, |
@@ -474,8 +474,8 @@ discard block |
||
| 474 | 474 | 'filename' => 'registrations_details_registrant_details' |
| 475 | 475 | ) |
| 476 | 476 | ), |
| 477 | - 'help_tour' => array( 'Registration_Details_Help_Tour' ), |
|
| 478 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ), |
|
| 477 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 478 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')), |
|
| 479 | 479 | 'require_nonce' => FALSE |
| 480 | 480 | ), |
| 481 | 481 | |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | 'order' => 15, |
| 500 | 500 | 'persistent' => FALSE |
| 501 | 501 | ), |
| 502 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ), |
|
| 502 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
| 503 | 503 | 'require_nonce' => FALSE |
| 504 | 504 | ), |
| 505 | 505 | |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | 'label' => __('Edit Contact', 'event_espresso'), |
| 509 | 509 | 'order' => 15, |
| 510 | 510 | 'persistent' => FALSE, |
| 511 | - 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
| 511 | + 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
| 512 | 512 | ), |
| 513 | 513 | 'metaboxes' => array('attendee_editor_metaboxes'), |
| 514 | 514 | 'require_nonce' => FALSE |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | 'filename' => 'registrations_contact_list_other' |
| 539 | 539 | ) |
| 540 | 540 | ), |
| 541 | - 'help_tour' => array( 'Contact_List_Help_Tour' ), |
|
| 541 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 542 | 542 | 'metaboxes' => array(), |
| 543 | 543 | 'require_nonce' => FALSE |
| 544 | 544 | ), |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | protected function _add_screen_options() {} |
| 558 | 558 | protected function _add_feature_pointers() {} |
| 559 | 559 | public function admin_init() { |
| 560 | - EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' ); |
|
| 560 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso'); |
|
| 561 | 561 | } |
| 562 | 562 | public function admin_notices() {} |
| 563 | 563 | public function admin_footer_scripts() {} |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @return void |
| 576 | 576 | */ |
| 577 | 577 | private function _get_registration_status_array() { |
| 578 | - self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
|
| 578 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | |
@@ -598,11 +598,11 @@ discard block |
||
| 598 | 598 | public function load_scripts_styles() { |
| 599 | 599 | //style |
| 600 | 600 | //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
| 601 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
| 601 | + wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
| 602 | 602 | wp_enqueue_style('espresso_reg'); |
| 603 | 603 | |
| 604 | 604 | //script |
| 605 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 605 | + wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 606 | 606 | wp_enqueue_script('espresso_reg'); |
| 607 | 607 | } |
| 608 | 608 | |
@@ -611,9 +611,9 @@ discard block |
||
| 611 | 611 | public function load_scripts_styles_edit_attendee() { |
| 612 | 612 | //stuff to only show up on our attendee edit details page. |
| 613 | 613 | $attendee_details_translations = array( |
| 614 | - 'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') ) |
|
| 614 | + 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created')) |
|
| 615 | 615 | ); |
| 616 | - wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations ); |
|
| 616 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 617 | 617 | wp_enqueue_script('jquery-validate'); |
| 618 | 618 | } |
| 619 | 619 | |
@@ -622,8 +622,8 @@ discard block |
||
| 622 | 622 | //styles |
| 623 | 623 | wp_enqueue_style('espresso-ui-theme'); |
| 624 | 624 | //scripts |
| 625 | - $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
| 626 | - $this->_reg_custom_questions_form->wp_enqueue_scripts( true ); |
|
| 625 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 626 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | public function load_scripts_styles_contact_list() { |
| 635 | 635 | wp_deregister_style('espresso_reg'); |
| 636 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
| 636 | + wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
| 637 | 637 | wp_enqueue_style('espresso_att'); |
| 638 | 638 | } |
| 639 | 639 | |
@@ -642,9 +642,9 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | |
| 644 | 644 | public function load_scripts_styles_new_registration() { |
| 645 | - wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 645 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 646 | 646 | wp_enqueue_script('ee-spco-for-admin'); |
| 647 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
| 647 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 648 | 648 | EE_Form_Section_Proper::wp_enqueue_scripts(); |
| 649 | 649 | EED_Ticket_Selector::load_tckt_slctr_assets(); |
| 650 | 650 | EE_Datepicker_Input::enqueue_styles_and_scripts(); |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | //for notification related bulk actions we need to make sure only active messengers have an option. |
| 672 | 672 | EED_Messages::set_autoloaders(); |
| 673 | 673 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
| 674 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 674 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 675 | 675 | $active_mts = $message_resource_manager->list_of_active_message_types(); |
| 676 | 676 | //key= bulk_action_slug, value= message type. |
| 677 | 677 | $match_array = array( |
@@ -684,23 +684,23 @@ discard block |
||
| 684 | 684 | |
| 685 | 685 | /** setup reg status bulk actions **/ |
| 686 | 686 | $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
| 687 | - if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
| 687 | + if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
| 688 | 688 | $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso'); |
| 689 | 689 | } |
| 690 | 690 | $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
| 691 | - if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
| 691 | + if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
| 692 | 692 | $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso'); |
| 693 | 693 | } |
| 694 | 694 | $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
| 695 | - if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
| 695 | + if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
| 696 | 696 | $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso'); |
| 697 | 697 | } |
| 698 | 698 | $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
| 699 | - if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
| 699 | + if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
| 700 | 700 | $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso'); |
| 701 | 701 | } |
| 702 | 702 | $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
| 703 | - if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
| 703 | + if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
| 704 | 704 | $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso'); |
| 705 | 705 | } |
| 706 | 706 | |
@@ -709,29 +709,29 @@ discard block |
||
| 709 | 709 | 'slug' => 'all', |
| 710 | 710 | 'label' => __('View All Registrations', 'event_espresso'), |
| 711 | 711 | 'count' => 0, |
| 712 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
| 712 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 713 | 713 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
| 714 | - ) ) |
|
| 714 | + )) |
|
| 715 | 715 | ), |
| 716 | 716 | 'month' => array( |
| 717 | 717 | 'slug' => 'month', |
| 718 | 718 | 'label' => __('This Month', 'event_espresso'), |
| 719 | 719 | 'count' => 0, |
| 720 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
| 720 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 721 | 721 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
| 722 | 722 | )) |
| 723 | 723 | ), |
| 724 | 724 | 'today' => array( |
| 725 | 725 | 'slug' => 'today', |
| 726 | - 'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ), |
|
| 726 | + 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
| 727 | 727 | 'count' => 0, |
| 728 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
| 728 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 729 | 729 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
| 730 | 730 | )) |
| 731 | 731 | ) |
| 732 | 732 | ); |
| 733 | 733 | |
| 734 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) { |
|
| 734 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) { |
|
| 735 | 735 | $this->_views['incomplete'] = array( |
| 736 | 736 | 'slug' => 'incomplete', |
| 737 | 737 | 'label' => __('Incomplete', 'event_espresso'), |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | ) |
| 768 | 768 | ); |
| 769 | 769 | |
| 770 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) { |
|
| 770 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) { |
|
| 771 | 771 | $this->_views['trash'] = array( |
| 772 | 772 | 'slug' => 'trash', |
| 773 | 773 | 'label' => __('Trash', 'event_espresso'), |
@@ -806,18 +806,18 @@ discard block |
||
| 806 | 806 | 'desc' => __('View Transaction Invoice', 'event_espresso') |
| 807 | 807 | ), |
| 808 | 808 | ); |
| 809 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) { |
|
| 809 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) { |
|
| 810 | 810 | $fc_items['resend_registration'] = array( |
| 811 | 811 | 'class' => 'dashicons dashicons-email-alt', |
| 812 | 812 | 'desc' => __('Resend Registration Details', 'event_espresso') |
| 813 | 813 | ); |
| 814 | 814 | } else { |
| 815 | - $fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' ); |
|
| 815 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
| 819 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
| 820 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
| 818 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 819 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 820 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 821 | 821 | $fc_items['view_related_messages'] = array( |
| 822 | 822 | 'class' => $related_for_icon['css_class'], |
| 823 | 823 | 'desc' => $related_for_icon['label'], |
@@ -827,35 +827,35 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | $sc_items = array( |
| 829 | 829 | 'approved_status' => array( |
| 830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 831 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) |
|
| 830 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 831 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') |
|
| 832 | 832 | ), |
| 833 | 833 | 'pending_status' => array( |
| 834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 835 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) |
|
| 834 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 835 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence') |
|
| 836 | 836 | ), |
| 837 | 837 | 'wait_list' => array( |
| 838 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 839 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) |
|
| 838 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 839 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') |
|
| 840 | 840 | ), |
| 841 | 841 | 'incomplete_status' => array( |
| 842 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 843 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' ) |
|
| 842 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
| 843 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence') |
|
| 844 | 844 | ), |
| 845 | 845 | 'not_approved' => array( |
| 846 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 847 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) |
|
| 846 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 847 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence') |
|
| 848 | 848 | ), |
| 849 | 849 | 'declined_status' => array( |
| 850 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 851 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) |
|
| 850 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 851 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence') |
|
| 852 | 852 | ), |
| 853 | 853 | 'cancelled_status' => array( |
| 854 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 855 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) |
|
| 854 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 855 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence') |
|
| 856 | 856 | ) |
| 857 | 857 | ); |
| 858 | - return array_merge( $fc_items, $sc_items ); |
|
| 858 | + return array_merge($fc_items, $sc_items); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | |
@@ -869,45 +869,45 @@ discard block |
||
| 869 | 869 | */ |
| 870 | 870 | protected function _registrations_overview_list_table() { |
| 871 | 871 | $this->_template_args['admin_page_header'] = ''; |
| 872 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : 0; |
|
| 873 | - if ( $EVT_ID ) { |
|
| 874 | - if ( EE_Registry::instance()->CAP->current_user_can( |
|
| 872 | + $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
| 873 | + if ($EVT_ID) { |
|
| 874 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 875 | 875 | 'ee_edit_registrations', |
| 876 | 876 | 'espresso_registrations_new_registration', |
| 877 | 877 | $EVT_ID |
| 878 | 878 | ) |
| 879 | 879 | ) { |
| 880 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 880 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 881 | 881 | 'new_registration', |
| 882 | 882 | 'add-registrant', |
| 883 | - array( 'event_id' => $EVT_ID ), |
|
| 883 | + array('event_id' => $EVT_ID), |
|
| 884 | 884 | 'add-new-h2' |
| 885 | 885 | ); |
| 886 | 886 | } |
| 887 | - $event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
| 888 | - if ( $event instanceof EE_Event ) { |
|
| 887 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 888 | + if ($event instanceof EE_Event) { |
|
| 889 | 889 | $this->_template_args['admin_page_header'] = sprintf( |
| 890 | - __( '%s Viewing registrations for the event: %s%s', 'event_espresso' ), |
|
| 890 | + __('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
| 891 | 891 | '<h3 style="line-height:1.5em;">', |
| 892 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 893 | - array( 'action' => 'edit', 'post' => $event->ID() ), |
|
| 892 | + '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
| 893 | + array('action' => 'edit', 'post' => $event->ID()), |
|
| 894 | 894 | EVENTS_ADMIN_URL |
| 895 | - ) . '"> ' . $event->get( 'EVT_name' ) . ' </a> ', |
|
| 895 | + ).'"> '.$event->get('EVT_name').' </a> ', |
|
| 896 | 896 | '</h3>' |
| 897 | 897 | ); |
| 898 | 898 | } |
| 899 | - $DTT_ID = ! empty( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : 0; |
|
| 900 | - $datetime = EEM_Datetime::instance()->get_one_by_ID( $DTT_ID ); |
|
| 901 | - if ( $datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '' ) { |
|
| 902 | - $this->_template_args['admin_page_header'] = substr( $this->_template_args['admin_page_header'], 0, -5 ); |
|
| 899 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 900 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 901 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 902 | + $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
| 903 | 903 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
| 904 | 904 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 905 | 905 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
| 906 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 906 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
| 907 | 907 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
| 908 | 908 | } |
| 909 | 909 | } |
| 910 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() ); |
|
| 910 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 911 | 911 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 912 | 912 | } |
| 913 | 913 | |
@@ -922,19 +922,19 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | private function _set_registration_object() { |
| 924 | 924 | //get out if we've already set the object |
| 925 | - if ( is_object( $this->_registration )) { |
|
| 925 | + if (is_object($this->_registration)) { |
|
| 926 | 926 | return TRUE; |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | $REG = EEM_Registration::instance(); |
| 930 | 930 | |
| 931 | - $REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
| 931 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
| 932 | 932 | |
| 933 | - if ( $this->_registration = $REG->get_one_by_ID( $REG_ID )) |
|
| 933 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) |
|
| 934 | 934 | return TRUE; |
| 935 | 935 | else { |
| 936 | - $error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID ); |
|
| 937 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 936 | + $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID); |
|
| 937 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 938 | 938 | $this->_registration = NULL; |
| 939 | 939 | return FALSE; |
| 940 | 940 | } |
@@ -952,25 +952,25 @@ discard block |
||
| 952 | 952 | * @throws \EE_Error |
| 953 | 953 | * @return mixed (int|array) int = count || array of registration objects |
| 954 | 954 | */ |
| 955 | - public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) { |
|
| 956 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
| 957 | - $CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE; |
|
| 958 | - $DTT_ID = isset( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : null; |
|
| 959 | - $reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE; |
|
| 960 | - $month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april |
|
| 961 | - $today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
| 962 | - $this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
| 955 | + public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) { |
|
| 956 | + $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE; |
|
| 957 | + $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE; |
|
| 958 | + $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null; |
|
| 959 | + $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE; |
|
| 960 | + $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april |
|
| 961 | + $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
| 962 | + $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
| 963 | 963 | $start_date = FALSE; |
| 964 | 964 | $end_date = FALSE; |
| 965 | 965 | $_where = array(); |
| 966 | - $trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
| 967 | - $incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
| 966 | + $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
| 967 | + $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
| 968 | 968 | |
| 969 | 969 | //set orderby |
| 970 | 970 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
| 971 | 971 | |
| 972 | 972 | |
| 973 | - switch ( $this->_req_data['orderby'] ) { |
|
| 973 | + switch ($this->_req_data['orderby']) { |
|
| 974 | 974 | case '_REG_ID': |
| 975 | 975 | $orderby = 'REG_ID'; |
| 976 | 976 | break; |
@@ -990,30 +990,30 @@ discard block |
||
| 990 | 990 | $orderby = 'REG_date'; |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
| 994 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
| 995 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
| 993 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
| 994 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 995 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 996 | 996 | |
| 997 | 997 | |
| 998 | - $offset = ($current_page-1)*$per_page; |
|
| 999 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
| 998 | + $offset = ($current_page - 1) * $per_page; |
|
| 999 | + $limit = $count ? NULL : array($offset, $per_page); |
|
| 1000 | 1000 | |
| 1001 | - if($EVT_ID){ |
|
| 1002 | - $_where['EVT_ID']=$EVT_ID; |
|
| 1001 | + if ($EVT_ID) { |
|
| 1002 | + $_where['EVT_ID'] = $EVT_ID; |
|
| 1003 | 1003 | } |
| 1004 | - if($CAT_ID){ |
|
| 1004 | + if ($CAT_ID) { |
|
| 1005 | 1005 | $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
| 1006 | 1006 | } |
| 1007 | 1007 | //if DTT is included we filter by that datetime. |
| 1008 | - if ( $DTT_ID ) { |
|
| 1008 | + if ($DTT_ID) { |
|
| 1009 | 1009 | $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
| 1010 | 1010 | } |
| 1011 | - if ( $incomplete ) { |
|
| 1011 | + if ($incomplete) { |
|
| 1012 | 1012 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
| 1013 | 1013 | } else if ( ! $trash) { |
| 1014 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
| 1014 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1015 | 1015 | } |
| 1016 | - if($reg_status){ |
|
| 1016 | + if ($reg_status) { |
|
| 1017 | 1017 | $_where['STS_ID'] = $reg_status; |
| 1018 | 1018 | } |
| 1019 | 1019 | |
@@ -1025,103 +1025,103 @@ discard block |
||
| 1025 | 1025 | $time_start = ' 00:00:00'; |
| 1026 | 1026 | $time_end = ' 23:59:59'; |
| 1027 | 1027 | |
| 1028 | - if($today_a || $today ){ |
|
| 1028 | + if ($today_a || $today) { |
|
| 1029 | 1029 | $curdate = date('Y-m-d', current_time('timestamp')); |
| 1030 | - $_where['REG_date']= array('BETWEEN', |
|
| 1030 | + $_where['REG_date'] = array('BETWEEN', |
|
| 1031 | 1031 | array( |
| 1032 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ), |
|
| 1033 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ), |
|
| 1032 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'), |
|
| 1033 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'), |
|
| 1034 | 1034 | )); |
| 1035 | - }elseif($this_month_a || $this_month){ |
|
| 1035 | + }elseif ($this_month_a || $this_month) { |
|
| 1036 | 1036 | $this_month_r = date('m', current_time('timestamp')); |
| 1037 | - $days_this_month = date( 't', current_time('timestamp') ); |
|
| 1038 | - $_where['REG_date']= array('BETWEEN', |
|
| 1037 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 1038 | + $_where['REG_date'] = array('BETWEEN', |
|
| 1039 | 1039 | array( |
| 1040 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ), |
|
| 1041 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ) |
|
| 1040 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'), |
|
| 1041 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s') |
|
| 1042 | 1042 | )); |
| 1043 | - }elseif($month_range){ |
|
| 1043 | + }elseif ($month_range) { |
|
| 1044 | 1044 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
| 1045 | - $month_r = !empty($pieces[0]) ? date('m', strtotime( $month_range ) ) : ''; |
|
| 1046 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1047 | - $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01') ); |
|
| 1048 | - $_where['REG_date']= array('BETWEEN', |
|
| 1049 | - array( EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s' ) ) ); |
|
| 1050 | - }elseif($start_date && $end_date){ |
|
| 1045 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : ''; |
|
| 1046 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1047 | + $days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01')); |
|
| 1048 | + $_where['REG_date'] = array('BETWEEN', |
|
| 1049 | + array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s'))); |
|
| 1050 | + }elseif ($start_date && $end_date) { |
|
| 1051 | 1051 | throw new EE_Error("not yet supported"); |
| 1052 | - }elseif($start_date){ |
|
| 1052 | + }elseif ($start_date) { |
|
| 1053 | 1053 | throw new EE_Error("not yet supported"); |
| 1054 | - }elseif($end_date){ |
|
| 1054 | + }elseif ($end_date) { |
|
| 1055 | 1055 | throw new EE_Error("not yet supported"); |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
| 1059 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 1058 | + if ( ! empty($this->_req_data['s'])) { |
|
| 1059 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 1060 | 1060 | $_where['OR'] = array( |
| 1061 | - 'Event.EVT_name' => array( 'LIKE', $sstr), |
|
| 1062 | - 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
| 1063 | - 'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
| 1064 | - 'Attendee.ATT_full_name' => array( 'LIKE', $sstr ), |
|
| 1065 | - 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
|
| 1066 | - 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
|
| 1067 | - 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
|
| 1068 | - 'Attendee.ATT_email' => array('LIKE', $sstr ), |
|
| 1069 | - 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
|
| 1070 | - 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
|
| 1071 | - 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
|
| 1072 | - 'REG_final_price' => array( 'LIKE', $sstr ), |
|
| 1073 | - 'REG_code' => array( 'LIKE', $sstr ), |
|
| 1074 | - 'REG_count' => array( 'LIKE' , $sstr ), |
|
| 1075 | - 'REG_group_size' => array( 'LIKE' , $sstr ), |
|
| 1076 | - 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
|
| 1077 | - 'Ticket.TKT_description' => array( 'LIKE', $sstr ), |
|
| 1078 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr ) |
|
| 1061 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
| 1062 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
| 1063 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 1064 | + 'Attendee.ATT_full_name' => array('LIKE', $sstr), |
|
| 1065 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
| 1066 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
| 1067 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
| 1068 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
| 1069 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
| 1070 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
| 1071 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
| 1072 | + 'REG_final_price' => array('LIKE', $sstr), |
|
| 1073 | + 'REG_code' => array('LIKE', $sstr), |
|
| 1074 | + 'REG_count' => array('LIKE', $sstr), |
|
| 1075 | + 'REG_group_size' => array('LIKE', $sstr), |
|
| 1076 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
| 1077 | + 'Ticket.TKT_description' => array('LIKE', $sstr), |
|
| 1078 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr) |
|
| 1079 | 1079 | ); |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | 1082 | //capability checks |
| 1083 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) { |
|
| 1083 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) { |
|
| 1084 | 1084 | $_where['AND'] = array( |
| 1085 | 1085 | 'Event.EVT_wp_user' => get_current_user_id() |
| 1086 | 1086 | ); |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | - if( $count ){ |
|
| 1090 | - if ( $trash ) { |
|
| 1091 | - return EEM_Registration::instance()->count_deleted( array( $_where )); |
|
| 1092 | - } else if ( $incomplete ) { |
|
| 1093 | - return EEM_Registration::instance()->count( array( $_where )); |
|
| 1089 | + if ($count) { |
|
| 1090 | + if ($trash) { |
|
| 1091 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
| 1092 | + } else if ($incomplete) { |
|
| 1093 | + return EEM_Registration::instance()->count(array($_where)); |
|
| 1094 | 1094 | } else { |
| 1095 | - return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' )); |
|
| 1095 | + return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only')); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | } else { |
| 1098 | 1098 | //make sure we remove default where conditions cause all registrations matching query are returned |
| 1099 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' ); |
|
| 1100 | - if ( $per_page !== -1 ) { |
|
| 1099 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only'); |
|
| 1100 | + if ($per_page !== -1) { |
|
| 1101 | 1101 | $query_params['limit'] = $limit; |
| 1102 | 1102 | } |
| 1103 | - $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
| 1103 | + $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
| 1104 | 1104 | |
| 1105 | - if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
| 1105 | + if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
| 1106 | 1106 | $first_registration = $registrations[0]; |
| 1107 | 1107 | //EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 1108 | 1108 | $event_name = $first_registration->event_obj()->name(); |
| 1109 | - $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
| 1109 | + $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
| 1110 | 1110 | // edit event link |
| 1111 | - if ( $event_name != '' ) { |
|
| 1112 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
|
| 1113 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
| 1114 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
| 1111 | + if ($event_name != '') { |
|
| 1112 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL); |
|
| 1113 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
| 1114 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - $back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
|
| 1118 | - $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
|
| 1117 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL); |
|
| 1118 | + $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">« '.__('Back to All Registrations', 'event_espresso').'</a>'; |
|
| 1119 | 1119 | |
| 1120 | 1120 | $this->_template_args['before_admin_page_content'] = ' |
| 1121 | 1121 | <div id="admin-page-header"> |
| 1122 | - <h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
|
| 1123 | - <h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
|
| 1124 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
| 1122 | + <h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
| 1123 | + <h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
| 1124 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
| 1125 | 1125 | </div> |
| 1126 | 1126 | '; |
| 1127 | 1127 | |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | |
| 1160 | 1160 | $this->_set_registration_object(); |
| 1161 | 1161 | |
| 1162 | - if ( is_object( $this->_registration )) { |
|
| 1162 | + if (is_object($this->_registration)) { |
|
| 1163 | 1163 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
| 1164 | 1164 | $this->_session = $transaction->session_data(); |
| 1165 | 1165 | |
@@ -1167,10 +1167,10 @@ discard block |
||
| 1167 | 1167 | |
| 1168 | 1168 | |
| 1169 | 1169 | $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
| 1170 | - $this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' ); |
|
| 1170 | + $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
| 1171 | 1171 | |
| 1172 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime( 'REG_date' ); |
|
| 1173 | - $this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' ); |
|
| 1172 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1173 | + $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
| 1174 | 1174 | |
| 1175 | 1175 | $this->_template_args['grand_total'] = $transaction->total(); |
| 1176 | 1176 | |
@@ -1178,20 +1178,20 @@ discard block |
||
| 1178 | 1178 | // link back to overview |
| 1179 | 1179 | $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
| 1180 | 1180 | $this->_template_args['registration'] = $this->_registration; |
| 1181 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL ); |
|
| 1182 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) ); |
|
| 1183 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) ); |
|
| 1181 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL); |
|
| 1182 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php')); |
|
| 1183 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php')); |
|
| 1184 | 1184 | |
| 1185 | 1185 | //next and previous links |
| 1186 | - $next_reg = $this->_registration->next(null, array(), 'REG_ID' ); |
|
| 1187 | - $this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : ''; |
|
| 1188 | - $previous_reg = $this->_registration->previous( null, array(), 'REG_ID' ); |
|
| 1189 | - $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : ''; |
|
| 1186 | + $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
| 1187 | + $this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
| 1188 | + $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
| 1189 | + $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
| 1190 | 1190 | |
| 1191 | 1191 | // grab header |
| 1192 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1192 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
| 1193 | 1193 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1194 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 1194 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 1195 | 1195 | |
| 1196 | 1196 | } else { |
| 1197 | 1197 | |
@@ -1210,17 +1210,17 @@ discard block |
||
| 1210 | 1210 | |
| 1211 | 1211 | |
| 1212 | 1212 | protected function _registration_details_metaboxes() { |
| 1213 | - do_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this ); |
|
| 1213 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1214 | 1214 | $this->_set_registration_object(); |
| 1215 | 1215 | $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
| 1216 | - add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' ); |
|
| 1217 | - add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
| 1218 | - if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) { |
|
| 1219 | - add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
| 1216 | + add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1217 | + add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1218 | + if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) { |
|
| 1219 | + add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1220 | 1220 | } |
| 1221 | - add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' ); |
|
| 1222 | - if ( $this->_registration->group_size() > 1 ) { |
|
| 1223 | - add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
| 1221 | + add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
| 1222 | + if ($this->_registration->group_size() > 1) { |
|
| 1223 | + add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | } |
| 1226 | 1226 | |
@@ -1262,25 +1262,25 @@ discard block |
||
| 1262 | 1262 | 'html_id' => 'reg-status-change-form', |
| 1263 | 1263 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
| 1264 | 1264 | 'subsections' => array( |
| 1265 | - 'return' => new EE_Hidden_Input( array( |
|
| 1265 | + 'return' => new EE_Hidden_Input(array( |
|
| 1266 | 1266 | 'name' => 'return', |
| 1267 | 1267 | 'default' => 'view_registration' |
| 1268 | - ) ), |
|
| 1269 | - 'REG_ID' => new EE_Hidden_Input( array( |
|
| 1268 | + )), |
|
| 1269 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1270 | 1270 | 'name' => 'REG_ID', |
| 1271 | 1271 | 'default' => $this->_registration->ID() |
| 1272 | - ) ), |
|
| 1272 | + )), |
|
| 1273 | 1273 | 'current_status' => new EE_Form_Section_HTML( |
| 1274 | 1274 | EEH_HTML::tr( |
| 1275 | 1275 | EEH_HTML::th( |
| 1276 | 1276 | EEH_HTML::label( |
| 1277 | - EEH_HTML::strong( __( 'Current Registration Status', 'event_espresso' ) ) |
|
| 1277 | + EEH_HTML::strong(__('Current Registration Status', 'event_espresso')) |
|
| 1278 | 1278 | ) |
| 1279 | - ) . |
|
| 1279 | + ). |
|
| 1280 | 1280 | EEH_HTML::td( |
| 1281 | 1281 | EEH_HTML::strong( |
| 1282 | 1282 | $this->_registration->pretty_status(), |
| 1283 | - '', 'status-' . $this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1283 | + '', 'status-'.$this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1284 | 1284 | ) |
| 1285 | 1285 | ) |
| 1286 | 1286 | ) |
@@ -1288,22 +1288,22 @@ discard block |
||
| 1288 | 1288 | 'reg_status' => new EE_Select_Input( |
| 1289 | 1289 | $this->_get_reg_statuses(), |
| 1290 | 1290 | array( |
| 1291 | - 'html_label_text' => __( 'Change Registration Status to', 'event_espresso' ), |
|
| 1291 | + 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
| 1292 | 1292 | 'default' => $this->_registration->status_ID(), |
| 1293 | 1293 | ) |
| 1294 | 1294 | ), |
| 1295 | 1295 | 'send_notifications' => new EE_Yes_No_Input( |
| 1296 | 1296 | array( |
| 1297 | - 'html_label_text' => __( 'Send Related Messages', 'event_espresso' ), |
|
| 1297 | + 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
| 1298 | 1298 | 'default' => false, |
| 1299 | - 'html_help_text' => __( 'If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso' ), |
|
| 1299 | + 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso'), |
|
| 1300 | 1300 | ) |
| 1301 | 1301 | ), |
| 1302 | - 'submit' => new EE_Submit_Input( array( |
|
| 1302 | + 'submit' => new EE_Submit_Input(array( |
|
| 1303 | 1303 | 'html_class' => 'button-primary', |
| 1304 | 1304 | 'html_label_text' => ' ', |
| 1305 | - 'default' => __( 'Update Registration Status', 'event_espresso' ) |
|
| 1306 | - ) ), |
|
| 1305 | + 'default' => __('Update Registration Status', 'event_espresso') |
|
| 1306 | + )), |
|
| 1307 | 1307 | ), |
| 1308 | 1308 | ) |
| 1309 | 1309 | ); |
@@ -1316,7 +1316,7 @@ discard block |
||
| 1316 | 1316 | * Returns an array of all the buttons for the various statuses and switch status actions |
| 1317 | 1317 | * @return string |
| 1318 | 1318 | */ |
| 1319 | - protected function _get_current_reg_status_help_text( $STS_ID = '' ) { |
|
| 1319 | + protected function _get_current_reg_status_help_text($STS_ID = '') { |
|
| 1320 | 1320 | //$reg_status_help_text = array( |
| 1321 | 1321 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
| 1322 | 1322 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
@@ -1349,14 +1349,14 @@ discard block |
||
| 1349 | 1349 | */ |
| 1350 | 1350 | protected function _get_reg_statuses() { |
| 1351 | 1351 | $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
| 1352 | - unset ( $reg_status_array[ EEM_Registration::status_id_incomplete ] ); |
|
| 1352 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1353 | 1353 | // get current reg status |
| 1354 | 1354 | $current_status = $this->_registration->status_ID(); |
| 1355 | 1355 | // is registration for free event? This will determine whether to display the pending payment option |
| 1356 | - if ( $current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free() ) { |
|
| 1357 | - unset( $reg_status_array[ EEM_Registration::status_id_pending_payment ] ); |
|
| 1356 | + if ($current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free()) { |
|
| 1357 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1358 | 1358 | } |
| 1359 | - return EEM_Status::instance()->localized_status( $reg_status_array, false, 'sentence' ); |
|
| 1359 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | |
@@ -1369,15 +1369,15 @@ discard block |
||
| 1369 | 1369 | * |
| 1370 | 1370 | * @return array (array with reg_id(s) updated and whether update was successful. |
| 1371 | 1371 | */ |
| 1372 | - protected function _set_registration_status_from_request( $status = false, $notify = false ) { |
|
| 1373 | - if ( isset( $this->_req_data[ 'reg_status_change_form' ] ) ) { |
|
| 1374 | - $REG_IDs = isset( $this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ] ) |
|
| 1375 | - ? (array)$this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ] |
|
| 1372 | + protected function _set_registration_status_from_request($status = false, $notify = false) { |
|
| 1373 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1374 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1375 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] |
|
| 1376 | 1376 | : array(); |
| 1377 | 1377 | } else { |
| 1378 | - $REG_IDs = isset( $this->_req_data[ '_REG_ID' ] ) ? (array)$this->_req_data[ '_REG_ID' ] : array(); |
|
| 1378 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
| 1379 | 1379 | } |
| 1380 | - $success = $this->_set_registration_status( $REG_IDs, $status ); |
|
| 1380 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1381 | 1381 | //notify? |
| 1382 | 1382 | if ( |
| 1383 | 1383 | $success |
@@ -1404,21 +1404,21 @@ discard block |
||
| 1404 | 1404 | * @param bool $status |
| 1405 | 1405 | * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations). |
| 1406 | 1406 | */ |
| 1407 | - protected function _set_registration_status( $REG_IDs = array(), $status = false ) { |
|
| 1407 | + protected function _set_registration_status($REG_IDs = array(), $status = false) { |
|
| 1408 | 1408 | $success = false; |
| 1409 | 1409 | // typecast $REG_IDs |
| 1410 | - $REG_IDs = (array)$REG_IDs; |
|
| 1411 | - if ( ! empty( $REG_IDs ) ) { |
|
| 1410 | + $REG_IDs = (array) $REG_IDs; |
|
| 1411 | + if ( ! empty($REG_IDs)) { |
|
| 1412 | 1412 | $success = true; |
| 1413 | 1413 | // set default status if none is passed |
| 1414 | 1414 | $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
| 1415 | 1415 | // sanitize $REG_IDs |
| 1416 | - $REG_IDs = array_filter( $REG_IDs, 'absint' ); |
|
| 1416 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1417 | 1417 | //loop through REG_ID's and change status |
| 1418 | - foreach ( $REG_IDs as $REG_ID ) { |
|
| 1419 | - $registration = EEM_Registration::instance()->get_one_by_ID( $REG_ID ); |
|
| 1420 | - if ( $registration instanceof EE_Registration ) { |
|
| 1421 | - $registration->set_status( $status ); |
|
| 1418 | + foreach ($REG_IDs as $REG_ID) { |
|
| 1419 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1420 | + if ($registration instanceof EE_Registration) { |
|
| 1421 | + $registration->set_status($status); |
|
| 1422 | 1422 | $result = $registration->save(); |
| 1423 | 1423 | // verifying explicit fails because update *may* just return 0 for 0 rows affected |
| 1424 | 1424 | $success = $result !== false ? $success : false; |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | //reset _req_data['_REG_ID'] for any potential future messages notifications |
| 1429 | 1429 | $this->_req_data['_REG_ID'] = $REG_IDs; |
| 1430 | 1430 | //return $success and processed registrations |
| 1431 | - return array( 'REG_ID' => $REG_IDs, 'success' => $success ); |
|
| 1431 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | 1434 | |
@@ -1440,49 +1440,49 @@ discard block |
||
| 1440 | 1440 | * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
| 1441 | 1441 | * @return void |
| 1442 | 1442 | */ |
| 1443 | - protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
|
| 1444 | - $result = ! empty( $STS_ID ) |
|
| 1445 | - ? $this->_set_registration_status_from_request( $STS_ID, $notify ) |
|
| 1446 | - : array( 'success' => false ); |
|
| 1447 | - $success = isset( $result['success'] ) && $result['success']; |
|
| 1443 | + protected function _reg_status_change_return($STS_ID, $notify = false) { |
|
| 1444 | + $result = ! empty($STS_ID) |
|
| 1445 | + ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1446 | + : array('success' => false); |
|
| 1447 | + $success = isset($result['success']) && $result['success']; |
|
| 1448 | 1448 | //setup success message |
| 1449 | - if ( $success ) { |
|
| 1450 | - if ( is_array( $result[ 'REG_ID' ] ) && count( $result[ 'REG_ID' ] ) === 1 ) { |
|
| 1449 | + if ($success) { |
|
| 1450 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1451 | 1451 | $msg = sprintf( |
| 1452 | - __( 'Registration status has been set to %s', 'event_espresso' ), |
|
| 1453 | - EEH_Template::pretty_status( $STS_ID, false, 'lower' ) |
|
| 1452 | + __('Registration status has been set to %s', 'event_espresso'), |
|
| 1453 | + EEH_Template::pretty_status($STS_ID, false, 'lower') |
|
| 1454 | 1454 | ); |
| 1455 | 1455 | } else { |
| 1456 | 1456 | $msg = sprintf( |
| 1457 | - __( 'Registrations have been set to %s.', 'event_espresso' ), |
|
| 1458 | - EEH_Template::pretty_status( $STS_ID, false, 'lower' ) |
|
| 1457 | + __('Registrations have been set to %s.', 'event_espresso'), |
|
| 1458 | + EEH_Template::pretty_status($STS_ID, false, 'lower') |
|
| 1459 | 1459 | ); |
| 1460 | 1460 | } |
| 1461 | - EE_Error::add_success( $msg ); |
|
| 1461 | + EE_Error::add_success($msg); |
|
| 1462 | 1462 | } else { |
| 1463 | 1463 | EE_Error::add_error( |
| 1464 | - __( 'Something went wrong, and the status was not changed', 'event_espresso' ), |
|
| 1464 | + __('Something went wrong, and the status was not changed', 'event_espresso'), |
|
| 1465 | 1465 | __FILE__, __LINE__, __FUNCTION__ |
| 1466 | 1466 | ); |
| 1467 | 1467 | } |
| 1468 | - if ( isset( $this->_req_data[ 'return' ] ) && $this->_req_data[ 'return' ] == 'view_registration' ) { |
|
| 1469 | - $route = array( 'action' => 'view_registration', '_REG_ID' => reset( $result[ 'REG_ID' ] ) ); |
|
| 1468 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1469 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1470 | 1470 | } else { |
| 1471 | - $route = array( 'action' => 'default' ); |
|
| 1471 | + $route = array('action' => 'default'); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | //unset nonces |
| 1474 | - foreach ( $this->_req_data as $ref => $value ) { |
|
| 1475 | - if ( strpos( $ref, 'nonce' ) !== false ) { |
|
| 1476 | - unset( $this->_req_data[$ref] ); |
|
| 1474 | + foreach ($this->_req_data as $ref => $value) { |
|
| 1475 | + if (strpos($ref, 'nonce') !== false) { |
|
| 1476 | + unset($this->_req_data[$ref]); |
|
| 1477 | 1477 | continue; |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | - $value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value ); |
|
| 1480 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1481 | 1481 | $this->_req_data[$ref] = $value; |
| 1482 | 1482 | } |
| 1483 | 1483 | //merge request vars so that the reloaded list table contains any existing filter query params |
| 1484 | - $route = array_merge( $this->_req_data, $route ); |
|
| 1485 | - $this->_redirect_after_action( $success, '', '', $route, true ); |
|
| 1484 | + $route = array_merge($this->_req_data, $route); |
|
| 1485 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | |
@@ -1493,51 +1493,51 @@ discard block |
||
| 1493 | 1493 | protected function _change_reg_status() { |
| 1494 | 1494 | $this->_req_data['return'] = 'view_registration'; |
| 1495 | 1495 | //set notify based on whether the send notifications toggle is set or not |
| 1496 | - $notify = ! empty( $this->_req_data['reg_status_change_form']['send_notifications'] ); |
|
| 1496 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1497 | 1497 | //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
| 1498 | - $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] = isset( |
|
| 1499 | - $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] |
|
| 1498 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset( |
|
| 1499 | + $this->_req_data['reg_status_change_form']['reg_status'] |
|
| 1500 | 1500 | ) |
| 1501 | - ? $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] |
|
| 1501 | + ? $this->_req_data['reg_status_change_form']['reg_status'] |
|
| 1502 | 1502 | : ''; |
| 1503 | 1503 | |
| 1504 | - switch ( $this->_req_data[ 'reg_status_change_form' ]['reg_status'] ) { |
|
| 1504 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1505 | 1505 | |
| 1506 | 1506 | case EEM_Registration::status_id_approved : |
| 1507 | - case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) : |
|
| 1508 | - $this->approve_registration( $notify ); |
|
| 1507 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1508 | + $this->approve_registration($notify); |
|
| 1509 | 1509 | break; |
| 1510 | 1510 | |
| 1511 | 1511 | case EEM_Registration::status_id_pending_payment : |
| 1512 | - case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) : |
|
| 1513 | - $this->pending_registration( $notify ); |
|
| 1512 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1513 | + $this->pending_registration($notify); |
|
| 1514 | 1514 | break; |
| 1515 | 1515 | |
| 1516 | 1516 | case EEM_Registration::status_id_not_approved : |
| 1517 | - case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) : |
|
| 1518 | - $this->not_approve_registration( $notify ); |
|
| 1517 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1518 | + $this->not_approve_registration($notify); |
|
| 1519 | 1519 | break; |
| 1520 | 1520 | |
| 1521 | 1521 | case EEM_Registration::status_id_declined : |
| 1522 | - case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) : |
|
| 1523 | - $this->decline_registration( $notify ); |
|
| 1522 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1523 | + $this->decline_registration($notify); |
|
| 1524 | 1524 | break; |
| 1525 | 1525 | |
| 1526 | 1526 | case EEM_Registration::status_id_cancelled : |
| 1527 | - case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) : |
|
| 1528 | - $this->cancel_registration( $notify ); |
|
| 1527 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1528 | + $this->cancel_registration($notify); |
|
| 1529 | 1529 | break; |
| 1530 | 1530 | |
| 1531 | 1531 | case EEM_Registration::status_id_wait_list : |
| 1532 | - case EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) : |
|
| 1533 | - $this->waitlist_registration( $notify ); |
|
| 1532 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1533 | + $this->waitlist_registration($notify); |
|
| 1534 | 1534 | break; |
| 1535 | 1535 | |
| 1536 | 1536 | case EEM_Registration::status_id_incomplete : |
| 1537 | 1537 | default : |
| 1538 | 1538 | $result['success'] = false; |
| 1539 | - unset( $this->_req_data['return'] ); |
|
| 1540 | - $this->_reg_status_change_return( '', false ); |
|
| 1539 | + unset($this->_req_data['return']); |
|
| 1540 | + $this->_reg_status_change_return('', false); |
|
| 1541 | 1541 | break; |
| 1542 | 1542 | } |
| 1543 | 1543 | } |
@@ -1551,8 +1551,8 @@ discard block |
||
| 1551 | 1551 | * @param bool $notify whether or not to notify the registrant about their approval. |
| 1552 | 1552 | * @return void |
| 1553 | 1553 | */ |
| 1554 | - protected function approve_registration( $notify = false ) { |
|
| 1555 | - $this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify ); |
|
| 1554 | + protected function approve_registration($notify = false) { |
|
| 1555 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1556 | 1556 | } |
| 1557 | 1557 | |
| 1558 | 1558 | |
@@ -1564,8 +1564,8 @@ discard block |
||
| 1564 | 1564 | * @param bool $notify whether or not to notify the registrant about their status change. |
| 1565 | 1565 | * @return void |
| 1566 | 1566 | */ |
| 1567 | - protected function decline_registration( $notify = false ) { |
|
| 1568 | - $this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify ); |
|
| 1567 | + protected function decline_registration($notify = false) { |
|
| 1568 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | |
@@ -1577,8 +1577,8 @@ discard block |
||
| 1577 | 1577 | * @param bool $notify whether or not to notify the registrant about their status change. |
| 1578 | 1578 | * @return void |
| 1579 | 1579 | */ |
| 1580 | - protected function cancel_registration( $notify = false ) { |
|
| 1581 | - $this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify ); |
|
| 1580 | + protected function cancel_registration($notify = false) { |
|
| 1581 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1582 | 1582 | } |
| 1583 | 1583 | |
| 1584 | 1584 | |
@@ -1590,8 +1590,8 @@ discard block |
||
| 1590 | 1590 | * @param bool $notify whether or not to notify the registrant about their status change. |
| 1591 | 1591 | * @return void |
| 1592 | 1592 | */ |
| 1593 | - protected function not_approve_registration( $notify = false ) { |
|
| 1594 | - $this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify ); |
|
| 1593 | + protected function not_approve_registration($notify = false) { |
|
| 1594 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | |
@@ -1603,8 +1603,8 @@ discard block |
||
| 1603 | 1603 | * @param bool $notify whether or not to notify the registrant about their status change. |
| 1604 | 1604 | * @return void |
| 1605 | 1605 | */ |
| 1606 | - protected function pending_registration( $notify = false ) { |
|
| 1607 | - $this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify ); |
|
| 1606 | + protected function pending_registration($notify = false) { |
|
| 1607 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | |
@@ -1616,8 +1616,8 @@ discard block |
||
| 1616 | 1616 | * @param bool $notify whether or not to notify the registrant about their status change. |
| 1617 | 1617 | * @return void |
| 1618 | 1618 | */ |
| 1619 | - protected function waitlist_registration( $notify = false ) { |
|
| 1620 | - $this->_reg_status_change_return( EEM_Registration::status_id_wait_list, $notify ); |
|
| 1619 | + protected function waitlist_registration($notify = false) { |
|
| 1620 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | |
@@ -1631,14 +1631,14 @@ discard block |
||
| 1631 | 1631 | public function _reg_details_meta_box() { |
| 1632 | 1632 | EEH_Autoloader::register_line_item_display_autoloaders(); |
| 1633 | 1633 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
| 1634 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
| 1634 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
| 1635 | 1635 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
| 1636 | 1636 | $this->_session = $transaction->session_data(); |
| 1637 | 1637 | |
| 1638 | 1638 | $filters = new EE_Line_Item_Filter_Collection(); |
| 1639 | 1639 | //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
| 1640 | - $filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) ); |
|
| 1641 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() ); |
|
| 1640 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 1641 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item()); |
|
| 1642 | 1642 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
| 1643 | 1643 | $line_item_display = new EE_Line_Item_Display( |
| 1644 | 1644 | 'reg_admin_table', |
@@ -1646,7 +1646,7 @@ discard block |
||
| 1646 | 1646 | ); |
| 1647 | 1647 | $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
| 1648 | 1648 | $filtered_line_item_tree, |
| 1649 | - array( 'EE_Registration' => $this->_registration ) |
|
| 1649 | + array('EE_Registration' => $this->_registration) |
|
| 1650 | 1650 | ); |
| 1651 | 1651 | $attendee = $this->_registration->attendee(); |
| 1652 | 1652 | |
@@ -1656,7 +1656,7 @@ discard block |
||
| 1656 | 1656 | 'espresso_transactions_view_transaction' |
| 1657 | 1657 | ) |
| 1658 | 1658 | ) { |
| 1659 | - $this->_template_args[ 'view_transaction_button' ] = EEH_Template::get_button_or_link( |
|
| 1659 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
| 1660 | 1660 | EE_Admin_Page::add_query_args_and_nonce( |
| 1661 | 1661 | array( |
| 1662 | 1662 | 'action' => 'view_transaction', |
@@ -1664,12 +1664,12 @@ discard block |
||
| 1664 | 1664 | ), |
| 1665 | 1665 | TXN_ADMIN_URL |
| 1666 | 1666 | ), |
| 1667 | - esc_html__( ' View Transaction' ), |
|
| 1667 | + esc_html__(' View Transaction'), |
|
| 1668 | 1668 | 'button secondary-button right', |
| 1669 | 1669 | 'dashicons dashicons-cart' |
| 1670 | 1670 | ); |
| 1671 | 1671 | } else { |
| 1672 | - $this->_template_args[ 'view_transaction_button' ] = ''; |
|
| 1672 | + $this->_template_args['view_transaction_button'] = ''; |
|
| 1673 | 1673 | } |
| 1674 | 1674 | |
| 1675 | 1675 | if ( |
@@ -1679,7 +1679,7 @@ discard block |
||
| 1679 | 1679 | 'espresso_registrations_resend_registration' |
| 1680 | 1680 | ) |
| 1681 | 1681 | ) { |
| 1682 | - $this->_template_args[ 'resend_registration_button' ] = EEH_Template::get_button_or_link( |
|
| 1682 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
| 1683 | 1683 | EE_Admin_Page::add_query_args_and_nonce( |
| 1684 | 1684 | array( |
| 1685 | 1685 | 'action' => 'resend_registration', |
@@ -1688,55 +1688,55 @@ discard block |
||
| 1688 | 1688 | ), |
| 1689 | 1689 | REG_ADMIN_URL |
| 1690 | 1690 | ), |
| 1691 | - esc_html__( ' Resend Registration' ), |
|
| 1691 | + esc_html__(' Resend Registration'), |
|
| 1692 | 1692 | 'button secondary-button right', |
| 1693 | 1693 | 'dashicons dashicons-email-alt' |
| 1694 | 1694 | ); |
| 1695 | 1695 | } else { |
| 1696 | - $this->_template_args[ 'resend_registration_button' ] = ''; |
|
| 1696 | + $this->_template_args['resend_registration_button'] = ''; |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | 1699 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
| 1700 | - $payment = $transaction->get_first_related( 'Payment' ); |
|
| 1700 | + $payment = $transaction->get_first_related('Payment'); |
|
| 1701 | 1701 | $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
| 1702 | - $payment_method = $payment->get_first_related( 'Payment_Method' ); |
|
| 1702 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 1703 | 1703 | $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method; |
| 1704 | 1704 | |
| 1705 | 1705 | $reg_details = array( |
| 1706 | 1706 | 'payment_method' => $payment_method->name(), |
| 1707 | 1707 | 'response_msg' => $payment->gateway_response(), |
| 1708 | - 'registration_id' => $this->_registration->get( 'REG_code' ), |
|
| 1708 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
| 1709 | 1709 | 'registration_session' => $this->_registration->session_ID(), |
| 1710 | - 'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '', |
|
| 1711 | - 'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '', |
|
| 1710 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 1711 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 1712 | 1712 | ); |
| 1713 | 1713 | |
| 1714 | 1714 | |
| 1715 | - if ( isset( $reg_details['registration_id'] )) { |
|
| 1715 | + if (isset($reg_details['registration_id'])) { |
|
| 1716 | 1716 | $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
| 1717 | - $this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' ); |
|
| 1717 | + $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
| 1718 | 1718 | $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
| 1719 | 1719 | } |
| 1720 | 1720 | |
| 1721 | - if ( isset( $reg_details['payment_method'] ) ) { |
|
| 1721 | + if (isset($reg_details['payment_method'])) { |
|
| 1722 | 1722 | $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
| 1723 | - $this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' ); |
|
| 1723 | + $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso'); |
|
| 1724 | 1724 | $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
| 1725 | 1725 | $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
| 1726 | - $this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' ); |
|
| 1726 | + $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso'); |
|
| 1727 | 1727 | $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
| 1728 | 1728 | } |
| 1729 | 1729 | |
| 1730 | 1730 | $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
| 1731 | - $this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' ); |
|
| 1731 | + $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso'); |
|
| 1732 | 1732 | $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
| 1733 | 1733 | |
| 1734 | 1734 | $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
| 1735 | - $this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' ); |
|
| 1735 | + $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso'); |
|
| 1736 | 1736 | $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
| 1737 | 1737 | |
| 1738 | 1738 | $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
| 1739 | - $this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' ); |
|
| 1739 | + $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso'); |
|
| 1740 | 1740 | $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
| 1741 | 1741 | |
| 1742 | 1742 | $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
@@ -1749,8 +1749,8 @@ discard block |
||
| 1749 | 1749 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1750 | 1750 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
| 1751 | 1751 | |
| 1752 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1753 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 1752 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1753 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 1754 | 1754 | |
| 1755 | 1755 | } |
| 1756 | 1756 | |
@@ -1764,14 +1764,14 @@ discard block |
||
| 1764 | 1764 | */ |
| 1765 | 1765 | public function _reg_questions_meta_box() { |
| 1766 | 1766 | //allow someone to override this method entirely |
| 1767 | - if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
|
| 1768 | - $form = $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
| 1769 | - $this->_template_args[ 'att_questions' ] = count( $form->subforms() ) > 0 ? $form->get_html_and_js() : ''; |
|
| 1767 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration)) { |
|
| 1768 | + $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 1769 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
| 1770 | 1770 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
| 1771 | 1771 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1772 | 1772 | |
| 1773 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1774 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 1773 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1774 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 1775 | 1775 | } |
| 1776 | 1776 | } |
| 1777 | 1777 | |
@@ -1785,12 +1785,12 @@ discard block |
||
| 1785 | 1785 | * @param string $output |
| 1786 | 1786 | * @return string |
| 1787 | 1787 | */ |
| 1788 | - public function form_before_question_group( $output ) { |
|
| 1788 | + public function form_before_question_group($output) { |
|
| 1789 | 1789 | EE_Error::doing_it_wrong( |
| 1790 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 1791 | - __( 'This method would have been protected but was used on a filter callback' |
|
| 1790 | + __CLASS__.'::'.__FUNCTION__, |
|
| 1791 | + __('This method would have been protected but was used on a filter callback' |
|
| 1792 | 1792 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
| 1793 | - 'event_espresso' ), |
|
| 1793 | + 'event_espresso'), |
|
| 1794 | 1794 | '4.8.32.rc.000' |
| 1795 | 1795 | ); |
| 1796 | 1796 | return ' |
@@ -1809,20 +1809,20 @@ discard block |
||
| 1809 | 1809 | * @param string $output |
| 1810 | 1810 | * @return string |
| 1811 | 1811 | */ |
| 1812 | - public function form_after_question_group( $output ) { |
|
| 1812 | + public function form_after_question_group($output) { |
|
| 1813 | 1813 | EE_Error::doing_it_wrong( |
| 1814 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 1815 | - __( 'This method would have been protected but was used on a filter callback' |
|
| 1814 | + __CLASS__.'::'.__FUNCTION__, |
|
| 1815 | + __('This method would have been protected but was used on a filter callback' |
|
| 1816 | 1816 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
| 1817 | - 'event_espresso' ), |
|
| 1817 | + 'event_espresso'), |
|
| 1818 | 1818 | '4.8.32.rc.000' |
| 1819 | 1819 | ); |
| 1820 | 1820 | return ' |
| 1821 | 1821 | <tr class="hide-if-no-js"> |
| 1822 | 1822 | <th> </th> |
| 1823 | 1823 | <td class="reg-admin-edit-attendee-question-td"> |
| 1824 | - <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '"> |
|
| 1825 | - <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span> |
|
| 1824 | + <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'"> |
|
| 1825 | + <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span> |
|
| 1826 | 1826 | <div class="dashicons dashicons-edit"></div> |
| 1827 | 1827 | </a> |
| 1828 | 1828 | </td> |
@@ -1842,18 +1842,18 @@ discard block |
||
| 1842 | 1842 | * @param string $label |
| 1843 | 1843 | * @return string |
| 1844 | 1844 | */ |
| 1845 | - public function form_form_field_label_wrap( $label ) { |
|
| 1845 | + public function form_form_field_label_wrap($label) { |
|
| 1846 | 1846 | EE_Error::doing_it_wrong( |
| 1847 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 1848 | - __( 'This method would have been protected but was used on a filter callback' |
|
| 1847 | + __CLASS__.'::'.__FUNCTION__, |
|
| 1848 | + __('This method would have been protected but was used on a filter callback' |
|
| 1849 | 1849 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
| 1850 | - 'event_espresso' ), |
|
| 1850 | + 'event_espresso'), |
|
| 1851 | 1851 | '4.8.32.rc.000' |
| 1852 | 1852 | ); |
| 1853 | 1853 | return ' |
| 1854 | 1854 | <tr> |
| 1855 | 1855 | <th> |
| 1856 | - ' . $label . ' |
|
| 1856 | + ' . $label.' |
|
| 1857 | 1857 | </th>'; |
| 1858 | 1858 | } |
| 1859 | 1859 | |
@@ -1867,17 +1867,17 @@ discard block |
||
| 1867 | 1867 | * @param string $input |
| 1868 | 1868 | * @return string |
| 1869 | 1869 | */ |
| 1870 | - public function form_form_field_input__wrap( $input ) { |
|
| 1870 | + public function form_form_field_input__wrap($input) { |
|
| 1871 | 1871 | EE_Error::doing_it_wrong( |
| 1872 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 1873 | - __( 'This method would have been protected but was used on a filter callback' |
|
| 1872 | + __CLASS__.'::'.__FUNCTION__, |
|
| 1873 | + __('This method would have been protected but was used on a filter callback' |
|
| 1874 | 1874 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
| 1875 | - 'event_espresso' ), |
|
| 1875 | + 'event_espresso'), |
|
| 1876 | 1876 | '4.8.32.rc.000' |
| 1877 | 1877 | ); |
| 1878 | 1878 | return ' |
| 1879 | 1879 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 1880 | - ' . $input . ' |
|
| 1880 | + ' . $input.' |
|
| 1881 | 1881 | </td> |
| 1882 | 1882 | </tr>'; |
| 1883 | 1883 | } |
@@ -1891,14 +1891,14 @@ discard block |
||
| 1891 | 1891 | * @return void |
| 1892 | 1892 | */ |
| 1893 | 1893 | protected function _update_attendee_registration_form() { |
| 1894 | - do_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this ); |
|
| 1895 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
| 1896 | - $REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
| 1897 | - $success = $this->_save_reg_custom_questions_form( $REG_ID ); |
|
| 1898 | - if( $success ) { |
|
| 1894 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 1895 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 1896 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
| 1897 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 1898 | + if ($success) { |
|
| 1899 | 1899 | $what = __('Registration Form', 'event_espresso'); |
| 1900 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
| 1901 | - $this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
| 1900 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
| 1901 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 1902 | 1902 | } |
| 1903 | 1903 | } |
| 1904 | 1904 | } |
@@ -1909,11 +1909,11 @@ discard block |
||
| 1909 | 1909 | * @param int $REG_ID |
| 1910 | 1910 | * @return EE_Registration_Custom_Questions_Form |
| 1911 | 1911 | */ |
| 1912 | - protected function _get_reg_custom_questions_form( $REG_ID ) { |
|
| 1913 | - if( ! $this->_reg_custom_questions_form ) { |
|
| 1914 | - require_once( REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php' ); |
|
| 1915 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( EEM_Registration::instance()->get_one_by_ID( $REG_ID ) ); |
|
| 1916 | - $this->_reg_custom_questions_form->_construct_finalize( null, null ); |
|
| 1912 | + protected function _get_reg_custom_questions_form($REG_ID) { |
|
| 1913 | + if ( ! $this->_reg_custom_questions_form) { |
|
| 1914 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1915 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()->get_one_by_ID($REG_ID)); |
|
| 1916 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 1917 | 1917 | } |
| 1918 | 1918 | return $this->_reg_custom_questions_form; |
| 1919 | 1919 | } |
@@ -1926,17 +1926,17 @@ discard block |
||
| 1926 | 1926 | * @param bool $REG_ID |
| 1927 | 1927 | * @return bool |
| 1928 | 1928 | */ |
| 1929 | - private function _save_reg_custom_questions_form( $REG_ID = FALSE ) { |
|
| 1929 | + private function _save_reg_custom_questions_form($REG_ID = FALSE) { |
|
| 1930 | 1930 | |
| 1931 | 1931 | if ( ! $REG_ID) { |
| 1932 | - EE_Error::add_error( __('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1932 | + EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1933 | 1933 | } |
| 1934 | - $form = $this->_get_reg_custom_questions_form( $REG_ID ); |
|
| 1935 | - $form->receive_form_submission( $this->_req_data ); |
|
| 1934 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 1935 | + $form->receive_form_submission($this->_req_data); |
|
| 1936 | 1936 | $success = false; |
| 1937 | - if( $form->is_valid() ) { |
|
| 1938 | - foreach( $form->subforms() as $question_group_id => $question_group_form ) { |
|
| 1939 | - foreach( $question_group_form->inputs() as $question_id => $input ) { |
|
| 1937 | + if ($form->is_valid()) { |
|
| 1938 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 1939 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 1940 | 1940 | $where_conditions = array( |
| 1941 | 1941 | 'QST_ID' => $question_id, |
| 1942 | 1942 | 'REG_ID' => $REG_ID |
@@ -1944,19 +1944,19 @@ discard block |
||
| 1944 | 1944 | $possibly_new_values = array( |
| 1945 | 1945 | 'ANS_value' => $input->normalized_value() |
| 1946 | 1946 | ); |
| 1947 | - $answer = EEM_Answer::instance()->get_one( array( $where_conditions ) ); |
|
| 1948 | - if( $answer instanceof EE_Answer ) { |
|
| 1949 | - $success = $answer->save( $possibly_new_values ); |
|
| 1947 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 1948 | + if ($answer instanceof EE_Answer) { |
|
| 1949 | + $success = $answer->save($possibly_new_values); |
|
| 1950 | 1950 | } else { |
| 1951 | 1951 | //insert it then |
| 1952 | - $cols_n_vals = array_merge( $where_conditions, $possibly_new_values ); |
|
| 1953 | - $answer = EE_Answer::new_instance( $cols_n_vals ); |
|
| 1952 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 1953 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 1954 | 1954 | $success = $answer->save(); |
| 1955 | 1955 | } |
| 1956 | 1956 | } |
| 1957 | 1957 | } |
| 1958 | 1958 | } else { |
| 1959 | - EE_Error::add_error( $form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1959 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1960 | 1960 | } |
| 1961 | 1961 | return $success; |
| 1962 | 1962 | } |
@@ -1974,31 +1974,31 @@ discard block |
||
| 1974 | 1974 | $registrations = $REG->get_all(array( |
| 1975 | 1975 | array( |
| 1976 | 1976 | 'TXN_ID'=>$this->_registration->transaction_ID(), |
| 1977 | - 'REG_ID'=>array('!=',$this->_registration->ID()) |
|
| 1977 | + 'REG_ID'=>array('!=', $this->_registration->ID()) |
|
| 1978 | 1978 | ), |
| 1979 | 1979 | 'force_join'=>array('Attendee'))); |
| 1980 | 1980 | |
| 1981 | 1981 | $this->_template_args['attendees'] = array(); |
| 1982 | 1982 | $this->_template_args['attendee_notice'] = ''; |
| 1983 | - if ( empty( $registrations) || ( is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations) ) ) { |
|
| 1984 | - EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1983 | + if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) { |
|
| 1984 | + EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1985 | 1985 | $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
| 1986 | 1986 | } else { |
| 1987 | 1987 | |
| 1988 | 1988 | $att_nmbr = 1; |
| 1989 | - foreach ( $registrations as $registration ) { |
|
| 1989 | + foreach ($registrations as $registration) { |
|
| 1990 | 1990 | /* @var $registration EE_Registration */ |
| 1991 | 1991 | $attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object(); |
| 1992 | - $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID(); |
|
| 1993 | - $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 1994 | - $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 1995 | - $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 1996 | - $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 1992 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 1993 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 1994 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 1995 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 1996 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 1997 | 1997 | |
| 1998 | - $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() ); |
|
| 1998 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array()); |
|
| 1999 | 1999 | |
| 2000 | - $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
| 2001 | - $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name(); |
|
| 2000 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
| 2001 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2002 | 2002 | |
| 2003 | 2003 | $att_nmbr++; |
| 2004 | 2004 | } |
@@ -2008,8 +2008,8 @@ discard block |
||
| 2008 | 2008 | |
| 2009 | 2009 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
| 2010 | 2010 | } |
| 2011 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2012 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 2011 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2012 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 2013 | 2013 | |
| 2014 | 2014 | } |
| 2015 | 2015 | |
@@ -2030,14 +2030,14 @@ discard block |
||
| 2030 | 2030 | $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
| 2031 | 2031 | |
| 2032 | 2032 | //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
| 2033 | - if ( ! $this->_registration->is_primary_registrant() ) { |
|
| 2033 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2034 | 2034 | |
| 2035 | 2035 | $primary_registration = $this->_registration->get_primary_registration(); |
| 2036 | 2036 | $primary_attendee = $primary_registration instanceof EE_Registration |
| 2037 | 2037 | ? $primary_registration->attendee() |
| 2038 | 2038 | : null; |
| 2039 | 2039 | |
| 2040 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) { |
|
| 2040 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2041 | 2041 | //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
| 2042 | 2042 | $primary_registration = NULL; |
| 2043 | 2043 | } |
@@ -2046,27 +2046,27 @@ discard block |
||
| 2046 | 2046 | } |
| 2047 | 2047 | |
| 2048 | 2048 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
| 2049 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
| 2050 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
| 2051 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
| 2049 | + $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname; |
|
| 2050 | + $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname; |
|
| 2051 | + $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email; |
|
| 2052 | 2052 | $this->_template_args['phone'] = $attendee->phone(); |
| 2053 | 2053 | |
| 2054 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee ); |
|
| 2054 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2055 | 2055 | |
| 2056 | 2056 | |
| 2057 | 2057 | //edit link |
| 2058 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
| 2058 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
| 2059 | 2059 | $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
| 2060 | 2060 | |
| 2061 | 2061 | //create link |
| 2062 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): ''; |
|
| 2062 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : ''; |
|
| 2063 | 2063 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
| 2064 | 2064 | |
| 2065 | 2065 | $this->_template_args['att_check'] = $att_check; |
| 2066 | 2066 | |
| 2067 | 2067 | |
| 2068 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2069 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 2068 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2069 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | |
@@ -2079,7 +2079,7 @@ discard block |
||
| 2079 | 2079 | * @access protected |
| 2080 | 2080 | * @return void |
| 2081 | 2081 | */ |
| 2082 | - protected function _trash_or_restore_registrations( $trash = TRUE ) { |
|
| 2082 | + protected function _trash_or_restore_registrations($trash = TRUE) { |
|
| 2083 | 2083 | $REGM = EEM_Registration::instance(); |
| 2084 | 2084 | |
| 2085 | 2085 | $success = 1; |
@@ -2089,26 +2089,26 @@ discard block |
||
| 2089 | 2089 | $dtts = array(); |
| 2090 | 2090 | |
| 2091 | 2091 | //if empty _REG_ID then get out because there's nothing to do |
| 2092 | - if ( empty( $this->_req_data['_REG_ID'] ) ) { |
|
| 2092 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2093 | 2093 | $msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso'); |
| 2094 | - EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ ); |
|
| 2095 | - $this->_redirect_after_action(FALSE, '', '', array(), TRUE ); |
|
| 2094 | + EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
| 2095 | + $this->_redirect_after_action(FALSE, '', '', array(), TRUE); |
|
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | 2098 | //Checkboxes |
| 2099 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2099 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2100 | 2100 | // if array has more than one element than success message should be plural |
| 2101 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
| 2101 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2102 | 2102 | // cycle thru checkboxes |
| 2103 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
| 2103 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2104 | 2104 | /** @var EE_Registration $REG */ |
| 2105 | - $REG = $REGM->get_one_by_ID( $REG_ID); |
|
| 2105 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
| 2106 | 2106 | $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
| 2107 | - if ( $payment_count > 0 ) { |
|
| 2108 | - $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ); |
|
| 2107 | + if ($payment_count > 0) { |
|
| 2108 | + $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso'); |
|
| 2109 | 2109 | $error = 1; |
| 2110 | 2110 | $success = 0; |
| 2111 | - EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2111 | + EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
| 2112 | 2112 | continue; //can't trash this registration because it has payments. |
| 2113 | 2113 | } |
| 2114 | 2114 | $ticket = $REG->get_first_related('Ticket'); |
@@ -2117,7 +2117,7 @@ discard block |
||
| 2117 | 2117 | $dtts = array_merge($dtts, $dtt); |
| 2118 | 2118 | |
| 2119 | 2119 | $updated = $trash ? $REG->delete() : $REG->restore(); |
| 2120 | - if ( !$updated ) { |
|
| 2120 | + if ( ! $updated) { |
|
| 2121 | 2121 | $success = 0; |
| 2122 | 2122 | } else { |
| 2123 | 2123 | $success = 2; |
@@ -2132,7 +2132,7 @@ discard block |
||
| 2132 | 2132 | $tickets[$ticket->ID()] = $ticket; |
| 2133 | 2133 | $dtts = $ticket->get_many_related('Datetime'); |
| 2134 | 2134 | $updated = $trash ? $REG->delete() : $REG->restore(); |
| 2135 | - if ( ! $updated ) { |
|
| 2135 | + if ( ! $updated) { |
|
| 2136 | 2136 | $success = 0; |
| 2137 | 2137 | } |
| 2138 | 2138 | |
@@ -2142,10 +2142,10 @@ discard block |
||
| 2142 | 2142 | EEM_Ticket::instance()->update_tickets_sold($tickets); |
| 2143 | 2143 | EEM_Datetime::instance()->update_sold($dtts); |
| 2144 | 2144 | |
| 2145 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
| 2146 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
| 2145 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2146 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 2147 | 2147 | $overwrite_msgs = $error ? TRUE : FALSE; |
| 2148 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs ); |
|
| 2148 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
| 2149 | 2149 | } |
| 2150 | 2150 | |
| 2151 | 2151 | |
@@ -2169,16 +2169,16 @@ discard block |
||
| 2169 | 2169 | $success = 1; |
| 2170 | 2170 | |
| 2171 | 2171 | //Checkboxes |
| 2172 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2172 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2173 | 2173 | // if array has more than one element than success message should be plural |
| 2174 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
| 2174 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2175 | 2175 | // cycle thru checkboxes |
| 2176 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
| 2176 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2177 | 2177 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
| 2178 | - if ( ! $REG instanceof EE_Registration ) |
|
| 2178 | + if ( ! $REG instanceof EE_Registration) |
|
| 2179 | 2179 | continue; |
| 2180 | 2180 | $deleted = $this->_delete_registration($REG); |
| 2181 | - if ( !$deleted ) { |
|
| 2181 | + if ( ! $deleted) { |
|
| 2182 | 2182 | $success = 0; |
| 2183 | 2183 | } |
| 2184 | 2184 | } |
@@ -2188,15 +2188,15 @@ discard block |
||
| 2188 | 2188 | $REG_ID = $this->_req_data['_REG_ID']; |
| 2189 | 2189 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
| 2190 | 2190 | $deleted = $this->_delete_registration($REG); |
| 2191 | - if ( ! $deleted ) { |
|
| 2191 | + if ( ! $deleted) { |
|
| 2192 | 2192 | $success = 0; |
| 2193 | 2193 | } |
| 2194 | 2194 | |
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
| 2198 | - $action_desc = __( 'permanently deleted.', 'event_espresso' ); |
|
| 2199 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE ); |
|
| 2197 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2198 | + $action_desc = __('permanently deleted.', 'event_espresso'); |
|
| 2199 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE); |
|
| 2200 | 2200 | } |
| 2201 | 2201 | |
| 2202 | 2202 | |
@@ -2208,31 +2208,31 @@ discard block |
||
| 2208 | 2208 | * @param EE_Registration $REG registration to be deleted permenantly |
| 2209 | 2209 | * @return boolean true = successful deletion, false = fail. |
| 2210 | 2210 | */ |
| 2211 | - protected function _delete_registration( EE_Registration $REG ) { |
|
| 2211 | + protected function _delete_registration(EE_Registration $REG) { |
|
| 2212 | 2212 | //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
| 2213 | 2213 | $TXN = $REG->get_first_related('Transaction'); |
| 2214 | 2214 | $REGS = $TXN->get_many_related('Registration'); |
| 2215 | 2215 | |
| 2216 | 2216 | $all_trashed = TRUE; |
| 2217 | - foreach ( $REGS as $registration ) { |
|
| 2218 | - if ( ! $registration->get('REG_deleted') ) |
|
| 2217 | + foreach ($REGS as $registration) { |
|
| 2218 | + if ( ! $registration->get('REG_deleted')) |
|
| 2219 | 2219 | $all_trashed = FALSE; |
| 2220 | 2220 | } |
| 2221 | 2221 | |
| 2222 | - if ( ! $all_trashed ) { |
|
| 2223 | - EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2222 | + if ( ! $all_trashed) { |
|
| 2223 | + EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2224 | 2224 | return false; |
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | 2227 | //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
| 2228 | - foreach ( $REGS as $registration ) { |
|
| 2228 | + foreach ($REGS as $registration) { |
|
| 2229 | 2229 | |
| 2230 | 2230 | //delete related answers |
| 2231 | 2231 | $registration->delete_related_permanently('Answer'); |
| 2232 | 2232 | |
| 2233 | 2233 | //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
| 2234 | 2234 | $attendee = $registration->get_first_related('Attendee'); |
| 2235 | - if ( $attendee instanceof EE_Attendee ) { |
|
| 2235 | + if ($attendee instanceof EE_Attendee) { |
|
| 2236 | 2236 | $registration->_remove_relation_to($attendee, 'Attendee'); |
| 2237 | 2237 | } |
| 2238 | 2238 | |
@@ -2242,7 +2242,7 @@ discard block |
||
| 2242 | 2242 | //now delete permanently the checkins related to this registration. |
| 2243 | 2243 | $registration->delete_related_permanently('Checkin'); |
| 2244 | 2244 | |
| 2245 | - if ( $registration->ID() === $REG->ID() ) |
|
| 2245 | + if ($registration->ID() === $REG->ID()) |
|
| 2246 | 2246 | continue; //we don't want to delete permanently the existing registration just yet. |
| 2247 | 2247 | |
| 2248 | 2248 | //remove relation to transaction for these registrations if NOT the existing registrations |
@@ -2279,35 +2279,35 @@ discard block |
||
| 2279 | 2279 | * @return void |
| 2280 | 2280 | */ |
| 2281 | 2281 | public function new_registration() { |
| 2282 | - if ( ! $this->_set_reg_event() ) { |
|
| 2283 | - throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') ); |
|
| 2282 | + if ( ! $this->_set_reg_event()) { |
|
| 2283 | + throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso')); |
|
| 2284 | 2284 | } |
| 2285 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
| 2285 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
| 2286 | 2286 | // gotta start with a clean slate if we're not coming here via ajax |
| 2287 | 2287 | if ( |
| 2288 | - ! defined('DOING_AJAX' ) |
|
| 2289 | - && ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ) ) |
|
| 2288 | + ! defined('DOING_AJAX') |
|
| 2289 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2290 | 2290 | ) { |
| 2291 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 2291 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2292 | 2292 | } |
| 2293 | 2293 | |
| 2294 | - $this->_template_args['event_name'] = '' ; |
|
| 2294 | + $this->_template_args['event_name'] = ''; |
|
| 2295 | 2295 | // event name |
| 2296 | - if ( $this->_reg_event ) { |
|
| 2296 | + if ($this->_reg_event) { |
|
| 2297 | 2297 | $this->_template_args['event_name'] = $this->_reg_event->name(); |
| 2298 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL ); |
|
| 2299 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
| 2300 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
| 2298 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL); |
|
| 2299 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
| 2300 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
| 2301 | 2301 | } |
| 2302 | 2302 | |
| 2303 | 2303 | $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
| 2304 | 2304 | |
| 2305 | - if ( defined('DOING_AJAX' ) ) { |
|
| 2305 | + if (defined('DOING_AJAX')) { |
|
| 2306 | 2306 | $this->_return_json(); |
| 2307 | 2307 | } |
| 2308 | 2308 | // grab header |
| 2309 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2310 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 2309 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
| 2310 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 2311 | 2311 | |
| 2312 | 2312 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
| 2313 | 2313 | // the details template wrapper |
@@ -2324,7 +2324,7 @@ discard block |
||
| 2324 | 2324 | * @return string html |
| 2325 | 2325 | */ |
| 2326 | 2326 | protected function _get_registration_step_content() { |
| 2327 | - if ( isset( $_COOKIE[ 'ee_registration_added' ] ) && $_COOKIE[ 'ee_registration_added' ] ) { |
|
| 2327 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2328 | 2328 | $warning_msg = sprintf( |
| 2329 | 2329 | __( |
| 2330 | 2330 | '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
@@ -2340,7 +2340,7 @@ discard block |
||
| 2340 | 2340 | '</b>' |
| 2341 | 2341 | ); |
| 2342 | 2342 | return ' |
| 2343 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
| 2343 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
| 2344 | 2344 | <script > |
| 2345 | 2345 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
| 2346 | 2346 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2375,16 +2375,16 @@ discard block |
||
| 2375 | 2375 | $cart = EE_Registry::instance()->SSN->cart(); |
| 2376 | 2376 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
| 2377 | 2377 | |
| 2378 | - switch ( $step ) { |
|
| 2378 | + switch ($step) { |
|
| 2379 | 2379 | case 'ticket' : |
| 2380 | 2380 | $hidden_fields['processing_registration']['value'] = 1; |
| 2381 | 2381 | $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso'); |
| 2382 | - $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event ); |
|
| 2382 | + $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2383 | 2383 | $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso'); |
| 2384 | 2384 | $template_args['show_notification_toggle'] = FALSE; |
| 2385 | 2385 | break; |
| 2386 | 2386 | case 'questions' : |
| 2387 | - $hidden_fields[ 'processing_registration' ][ 'value' ] = 2; |
|
| 2387 | + $hidden_fields['processing_registration']['value'] = 2; |
|
| 2388 | 2388 | $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', 'event_espresso'); |
| 2389 | 2389 | //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
| 2390 | 2390 | $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
@@ -2393,10 +2393,10 @@ discard block |
||
| 2393 | 2393 | break; |
| 2394 | 2394 | } |
| 2395 | 2395 | |
| 2396 | - $this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route. |
|
| 2396 | + $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route. |
|
| 2397 | 2397 | |
| 2398 | 2398 | return EEH_Template::display_template( |
| 2399 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
| 2399 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
| 2400 | 2400 | ); |
| 2401 | 2401 | } |
| 2402 | 2402 | |
@@ -2411,11 +2411,11 @@ discard block |
||
| 2411 | 2411 | * @return boolean |
| 2412 | 2412 | */ |
| 2413 | 2413 | private function _set_reg_event() { |
| 2414 | - if ( is_object( $this->_reg_event )) { |
|
| 2414 | + if (is_object($this->_reg_event)) { |
|
| 2415 | 2415 | return TRUE; |
| 2416 | 2416 | } |
| 2417 | - $EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
| 2418 | - if ( ! $EVT_ID ) { |
|
| 2417 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE; |
|
| 2418 | + if ( ! $EVT_ID) { |
|
| 2419 | 2419 | return FALSE; |
| 2420 | 2420 | } |
| 2421 | 2421 | |
@@ -2436,80 +2436,80 @@ discard block |
||
| 2436 | 2436 | public function process_reg_step() { |
| 2437 | 2437 | EE_System::do_not_cache(); |
| 2438 | 2438 | $this->_set_reg_event(); |
| 2439 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
| 2439 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
| 2440 | 2440 | |
| 2441 | 2441 | //what step are we on? |
| 2442 | 2442 | $cart = EE_Registry::instance()->SSN->cart(); |
| 2443 | 2443 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
| 2444 | 2444 | |
| 2445 | 2445 | //if doing ajax then we need to verify the nonce |
| 2446 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 2447 | - $nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : ''; |
|
| 2448 | - $this->_verify_nonce( $nonce, $this->_req_nonce ); |
|
| 2446 | + if (defined('DOING_AJAX')) { |
|
| 2447 | + $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2448 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | - switch ( $step ) { |
|
| 2451 | + switch ($step) { |
|
| 2452 | 2452 | |
| 2453 | 2453 | case 'ticket' : |
| 2454 | 2454 | //process ticket selection |
| 2455 | 2455 | $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
| 2456 | - if ( $success ) { |
|
| 2457 | - EE_Error::add_success( esc_html__( 'Tickets Selected. Now complete the registration.', 'event_espresso' ) ); |
|
| 2456 | + if ($success) { |
|
| 2457 | + EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', 'event_espresso')); |
|
| 2458 | 2458 | } else { |
| 2459 | 2459 | $query_args['step_error'] = $this->_req_data['step_error'] = TRUE; |
| 2460 | 2460 | } |
| 2461 | - if ( defined('DOING_AJAX') ) { |
|
| 2461 | + if (defined('DOING_AJAX')) { |
|
| 2462 | 2462 | $this->new_registration(); //display next step |
| 2463 | 2463 | } else { |
| 2464 | 2464 | $query_args['action'] = 'new_registration'; |
| 2465 | 2465 | $query_args['processing_registration'] = 1; |
| 2466 | 2466 | $query_args['event_id'] = $this->_reg_event->ID(); |
| 2467 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
| 2467 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
| 2468 | 2468 | } |
| 2469 | 2469 | break; |
| 2470 | 2470 | |
| 2471 | 2471 | case 'questions' : |
| 2472 | - if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) { |
|
| 2473 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 ); |
|
| 2472 | + if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
| 2473 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2474 | 2474 | } |
| 2475 | 2475 | //process registration |
| 2476 | 2476 | $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
| 2477 | - if ( $cart instanceof EE_Cart ) { |
|
| 2477 | + if ($cart instanceof EE_Cart) { |
|
| 2478 | 2478 | $grand_total = $cart->get_cart_grand_total(); |
| 2479 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
| 2479 | + if ($grand_total instanceof EE_Line_Item) { |
|
| 2480 | 2480 | $grand_total->save_this_and_descendants_to_txn(); |
| 2481 | 2481 | } |
| 2482 | 2482 | } |
| 2483 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
| 2483 | + if ( ! $transaction instanceof EE_Transaction) { |
|
| 2484 | 2484 | $query_args = array( |
| 2485 | 2485 | 'action' => 'new_registration', |
| 2486 | 2486 | 'processing_registration' => 2, |
| 2487 | 2487 | 'event_id' => $this->_reg_event->ID() |
| 2488 | 2488 | ); |
| 2489 | 2489 | |
| 2490 | - if ( defined('DOING_AJAX' )) { |
|
| 2490 | + if (defined('DOING_AJAX')) { |
|
| 2491 | 2491 | //display registration form again because there are errors (maybe validation?) |
| 2492 | 2492 | $this->new_registration(); |
| 2493 | 2493 | return; |
| 2494 | 2494 | } else { |
| 2495 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
| 2495 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
| 2496 | 2496 | return; |
| 2497 | 2497 | } |
| 2498 | 2498 | } |
| 2499 | 2499 | // maybe update status, and make sure to save transaction if not done already |
| 2500 | - if ( ! $transaction->update_status_based_on_total_paid() ) { |
|
| 2500 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2501 | 2501 | $transaction->save(); |
| 2502 | 2502 | } |
| 2503 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 2503 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2504 | 2504 | $this->_req_data = array(); |
| 2505 | 2505 | $query_args = array( |
| 2506 | 2506 | 'action' => 'redirect_to_txn', |
| 2507 | 2507 | 'TXN_ID' => $transaction->ID(), |
| 2508 | 2508 | 'EVT_ID' => $this->_reg_event->ID(), |
| 2509 | - 'event_name' => urlencode( $this->_reg_event->name() ), |
|
| 2509 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2510 | 2510 | 'redirect_from' => 'new_registration' |
| 2511 | 2511 | ); |
| 2512 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
| 2512 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2513 | 2513 | break; |
| 2514 | 2514 | } |
| 2515 | 2515 | |
@@ -2526,21 +2526,21 @@ discard block |
||
| 2526 | 2526 | */ |
| 2527 | 2527 | public function redirect_to_txn() { |
| 2528 | 2528 | EE_System::do_not_cache(); |
| 2529 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 2529 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2530 | 2530 | $query_args = array( |
| 2531 | 2531 | 'action' => 'view_transaction', |
| 2532 | - 'TXN_ID' => isset( $this->_req_data['TXN_ID'] ) ? absint( $this->_req_data[ 'TXN_ID' ] ) : 0, |
|
| 2532 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 2533 | 2533 | 'page' => 'espresso_transactions' |
| 2534 | 2534 | ); |
| 2535 | - if ( isset( $this->_req_data[ 'EVT_ID' ], $this->_req_data[ 'redirect_from' ] ) ) { |
|
| 2536 | - $query_args['EVT_ID'] = $this->_req_data[ 'EVT_ID' ]; |
|
| 2537 | - $query_args['event_name'] = urlencode( $this->_req_data[ 'event_name' ] ); |
|
| 2538 | - $query_args['redirect_from'] = $this->_req_data[ 'redirect_from' ]; |
|
| 2535 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 2536 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 2537 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 2538 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 2539 | 2539 | } |
| 2540 | 2540 | EE_Error::add_success( |
| 2541 | - __( 'Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso' ) |
|
| 2541 | + __('Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso') |
|
| 2542 | 2542 | ); |
| 2543 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
| 2543 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | 2546 | |
@@ -2551,7 +2551,7 @@ discard block |
||
| 2551 | 2551 | * @return void |
| 2552 | 2552 | */ |
| 2553 | 2553 | protected function _attendee_contact_list_table() { |
| 2554 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 2554 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2555 | 2555 | $this->_search_btn_label = __('Contacts', 'event_espresso'); |
| 2556 | 2556 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 2557 | 2557 | } |
@@ -2566,10 +2566,10 @@ discard block |
||
| 2566 | 2566 | * @access public |
| 2567 | 2567 | * @return array |
| 2568 | 2568 | */ |
| 2569 | - public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
|
| 2569 | + public function get_attendees($per_page, $count = FALSE, $trash = FALSE) { |
|
| 2570 | 2570 | |
| 2571 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 2572 | - require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' ); |
|
| 2571 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2572 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2573 | 2573 | $ATT_MDL = EEM_Attendee::instance(); |
| 2574 | 2574 | |
| 2575 | 2575 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
@@ -2597,47 +2597,47 @@ discard block |
||
| 2597 | 2597 | $orderby = 'ATT_lname'; |
| 2598 | 2598 | } |
| 2599 | 2599 | |
| 2600 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
| 2600 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
| 2601 | 2601 | |
| 2602 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
| 2603 | - $per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
|
| 2604 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
| 2602 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 2603 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 2604 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 2605 | 2605 | |
| 2606 | 2606 | $_where = array(); |
| 2607 | 2607 | |
| 2608 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
| 2609 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2608 | + if ( ! empty($this->_req_data['s'])) { |
|
| 2609 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 2610 | 2610 | $_where['OR'] = array( |
| 2611 | - 'Registration.Event.EVT_name' => array( 'LIKE', $sstr), |
|
| 2612 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
| 2613 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
| 2614 | - 'ATT_fname' => array( 'LIKE', $sstr ), |
|
| 2615 | - 'ATT_lname' => array( 'LIKE', $sstr ), |
|
| 2616 | - 'ATT_short_bio' => array( 'LIKE', $sstr ), |
|
| 2617 | - 'ATT_email' => array('LIKE', $sstr ), |
|
| 2618 | - 'ATT_address' => array( 'LIKE', $sstr ), |
|
| 2619 | - 'ATT_address2' => array( 'LIKE', $sstr ), |
|
| 2620 | - 'ATT_city' => array( 'LIKE', $sstr ), |
|
| 2621 | - 'Country.CNT_name' => array( 'LIKE', $sstr ), |
|
| 2622 | - 'State.STA_name' => array('LIKE', $sstr ), |
|
| 2623 | - 'ATT_phone' => array( 'LIKE', $sstr ), |
|
| 2624 | - 'Registration.REG_final_price' => array( 'LIKE', $sstr ), |
|
| 2625 | - 'Registration.REG_code' => array( 'LIKE', $sstr ), |
|
| 2626 | - 'Registration.REG_count' => array( 'LIKE' , $sstr ), |
|
| 2627 | - 'Registration.REG_group_size' => array( 'LIKE' , $sstr ) |
|
| 2611 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 2612 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 2613 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 2614 | + 'ATT_fname' => array('LIKE', $sstr), |
|
| 2615 | + 'ATT_lname' => array('LIKE', $sstr), |
|
| 2616 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 2617 | + 'ATT_email' => array('LIKE', $sstr), |
|
| 2618 | + 'ATT_address' => array('LIKE', $sstr), |
|
| 2619 | + 'ATT_address2' => array('LIKE', $sstr), |
|
| 2620 | + 'ATT_city' => array('LIKE', $sstr), |
|
| 2621 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 2622 | + 'State.STA_name' => array('LIKE', $sstr), |
|
| 2623 | + 'ATT_phone' => array('LIKE', $sstr), |
|
| 2624 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 2625 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 2626 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 2627 | + 'Registration.REG_group_size' => array('LIKE', $sstr) |
|
| 2628 | 2628 | ); |
| 2629 | 2629 | } |
| 2630 | 2630 | |
| 2631 | 2631 | |
| 2632 | - $offset = ($current_page-1)*$per_page; |
|
| 2633 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
| 2632 | + $offset = ($current_page - 1) * $per_page; |
|
| 2633 | + $limit = $count ? NULL : array($offset, $per_page); |
|
| 2634 | 2634 | |
| 2635 | - if ( $trash ) { |
|
| 2636 | - $_where['status'] = array( '!=', 'publish' ); |
|
| 2637 | - $all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true ): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
| 2635 | + if ($trash) { |
|
| 2636 | + $_where['status'] = array('!=', 'publish'); |
|
| 2637 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
| 2638 | 2638 | } else { |
| 2639 | - $_where['status'] = array( 'IN', array( 'publish' ) ); |
|
| 2640 | - $all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit ), 'ATT_ID' , true ) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) ); |
|
| 2639 | + $_where['status'] = array('IN', array('publish')); |
|
| 2640 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
| 2641 | 2641 | } |
| 2642 | 2642 | |
| 2643 | 2643 | return $all_attendees; |
@@ -2654,10 +2654,10 @@ discard block |
||
| 2654 | 2654 | */ |
| 2655 | 2655 | protected function _resend_registration() { |
| 2656 | 2656 | $this->_process_resend_registration(); |
| 2657 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array( |
|
| 2657 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array( |
|
| 2658 | 2658 | 'action' => 'default' |
| 2659 | 2659 | ); |
| 2660 | - $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE ); |
|
| 2660 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
| 2661 | 2661 | } |
| 2662 | 2662 | |
| 2663 | 2663 | |
@@ -2665,26 +2665,26 @@ discard block |
||
| 2665 | 2665 | |
| 2666 | 2666 | |
| 2667 | 2667 | |
| 2668 | - public function _registrations_report(){ |
|
| 2669 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
| 2670 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
| 2668 | + public function _registrations_report() { |
|
| 2669 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2670 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 2671 | 2671 | array( |
| 2672 | 2672 | 'page' => 'espresso_batch', |
| 2673 | 2673 | 'batch' => 'file', |
| 2674 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
| 2675 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ), |
|
| 2676 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
| 2677 | - )) ); |
|
| 2674 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
| 2675 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 2676 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2677 | + ))); |
|
| 2678 | 2678 | } else { |
| 2679 | 2679 | $new_request_args = array( |
| 2680 | 2680 | 'export' => 'report', |
| 2681 | 2681 | 'action' => 'registrations_report_for_event', |
| 2682 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
| 2682 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
| 2683 | 2683 | ); |
| 2684 | 2684 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
| 2685 | 2685 | |
| 2686 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2687 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2686 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2687 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2688 | 2688 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2689 | 2689 | $EE_Export->export(); |
| 2690 | 2690 | } |
@@ -2693,26 +2693,26 @@ discard block |
||
| 2693 | 2693 | |
| 2694 | 2694 | |
| 2695 | 2695 | |
| 2696 | - public function _contact_list_export(){ |
|
| 2697 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2698 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2696 | + public function _contact_list_export() { |
|
| 2697 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2698 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2699 | 2699 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2700 | 2700 | $EE_Export->export_attendees(); |
| 2701 | 2701 | } |
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | - public function _contact_list_report(){ |
|
| 2705 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
| 2706 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
| 2704 | + public function _contact_list_report() { |
|
| 2705 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2706 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 2707 | 2707 | array( |
| 2708 | 2708 | 'page' => 'espresso_batch', |
| 2709 | 2709 | 'batch' => 'file', |
| 2710 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ), |
|
| 2711 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
| 2712 | - )) ); |
|
| 2710 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 2711 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2712 | + ))); |
|
| 2713 | 2713 | } else { |
| 2714 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2715 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2714 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2715 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2716 | 2716 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2717 | 2717 | $EE_Export->report_attendees(); |
| 2718 | 2718 | } |
@@ -2731,73 +2731,73 @@ discard block |
||
| 2731 | 2731 | * @return void |
| 2732 | 2732 | */ |
| 2733 | 2733 | protected function _duplicate_attendee() { |
| 2734 | - $action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default'; |
|
| 2734 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 2735 | 2735 | //verify we have necessary info |
| 2736 | - if ( empty($this->_req_data['_REG_ID'] ) ) { |
|
| 2737 | - EE_Error::add_error( __('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__ ); |
|
| 2738 | - $query_args = array( 'action' => $action ); |
|
| 2736 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2737 | + EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
| 2738 | + $query_args = array('action' => $action); |
|
| 2739 | 2739 | $this->_redirect_after_action('', '', '', $query_args, TRUE); |
| 2740 | 2740 | } |
| 2741 | 2741 | |
| 2742 | 2742 | //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
| 2743 | - $registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] ); |
|
| 2743 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 2744 | 2744 | $attendee = $registration->attendee(); |
| 2745 | 2745 | |
| 2746 | 2746 | //remove relation of existing attendee on registration |
| 2747 | - $registration->_remove_relation_to($attendee, 'Attendee' ); |
|
| 2747 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2748 | 2748 | //new attendee |
| 2749 | 2749 | $new_attendee = clone $attendee; |
| 2750 | - $new_attendee->set( 'ATT_ID', 0 ); |
|
| 2750 | + $new_attendee->set('ATT_ID', 0); |
|
| 2751 | 2751 | $new_attendee->save(); |
| 2752 | 2752 | |
| 2753 | 2753 | //add new attendee to reg |
| 2754 | - $registration->_add_relation_to( $new_attendee, 'Attendee'); |
|
| 2754 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 2755 | 2755 | |
| 2756 | - EE_Error::add_success( __('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso') ); |
|
| 2756 | + EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso')); |
|
| 2757 | 2757 | |
| 2758 | 2758 | //redirect to edit page for attendee |
| 2759 | - $query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' ); |
|
| 2759 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 2760 | 2760 | |
| 2761 | - $this->_redirect_after_action( '', '', '', $query_args, TRUE ); |
|
| 2761 | + $this->_redirect_after_action('', '', '', $query_args, TRUE); |
|
| 2762 | 2762 | } |
| 2763 | 2763 | |
| 2764 | 2764 | |
| 2765 | 2765 | //related to cpt routes |
| 2766 | 2766 | protected function _insert_update_cpt_item($post_id, $post) { |
| 2767 | 2767 | $success = true; |
| 2768 | - $attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id ); |
|
| 2768 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 2769 | 2769 | //for attendee updates |
| 2770 | - if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) { |
|
| 2770 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 2771 | 2771 | //note we should only be UPDATING attendees at this point. |
| 2772 | 2772 | $updated_fields = array( |
| 2773 | 2773 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
| 2774 | 2774 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
| 2775 | - 'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 2775 | + 'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
| 2776 | 2776 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
| 2777 | 2777 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
| 2778 | - 'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '', |
|
| 2779 | - 'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '', |
|
| 2780 | - 'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '', |
|
| 2781 | - 'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '', |
|
| 2782 | - 'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '', |
|
| 2783 | - 'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : '' |
|
| 2778 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 2779 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 2780 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 2781 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 2782 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 2783 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '' |
|
| 2784 | 2784 | ); |
| 2785 | - foreach ( $updated_fields as $field => $value ) { |
|
| 2785 | + foreach ($updated_fields as $field => $value) { |
|
| 2786 | 2786 | $attendee->set($field, $value); |
| 2787 | 2787 | } |
| 2788 | 2788 | |
| 2789 | 2789 | $success = $attendee->save(); |
| 2790 | 2790 | |
| 2791 | - $attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() ); |
|
| 2792 | - foreach ( $attendee_update_callbacks as $a_callback ) { |
|
| 2793 | - if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) { |
|
| 2794 | - throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback ) ); |
|
| 2791 | + $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array()); |
|
| 2792 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
| 2793 | + if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 2794 | + throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback)); |
|
| 2795 | 2795 | } |
| 2796 | 2796 | } |
| 2797 | 2797 | } |
| 2798 | 2798 | |
| 2799 | - if ( $success === FALSE ) |
|
| 2800 | - EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2799 | + if ($success === FALSE) |
|
| 2800 | + EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2801 | 2801 | |
| 2802 | 2802 | } |
| 2803 | 2803 | |
@@ -2817,17 +2817,17 @@ discard block |
||
| 2817 | 2817 | remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
| 2818 | 2818 | remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
| 2819 | 2819 | |
| 2820 | - if ( post_type_supports( 'espresso_attendees', 'excerpt') ) { |
|
| 2821 | - add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' ); |
|
| 2820 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 2821 | + add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal'); |
|
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | - if ( post_type_supports( 'espresso_attendees', 'comments') ) { |
|
| 2824 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 2825 | 2825 | add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
| 2826 | 2826 | } |
| 2827 | 2827 | |
| 2828 | - add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
| 2829 | - add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' ); |
|
| 2830 | - add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
| 2828 | + add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
| 2829 | + add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2830 | + add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
| 2831 | 2831 | } |
| 2832 | 2832 | |
| 2833 | 2833 | |
@@ -2836,10 +2836,10 @@ discard block |
||
| 2836 | 2836 | * @param WP_Post $post wp post object |
| 2837 | 2837 | * @return string attendee contact info ( and form ) |
| 2838 | 2838 | */ |
| 2839 | - public function attendee_contact_info( $post ) { |
|
| 2839 | + public function attendee_contact_info($post) { |
|
| 2840 | 2840 | //get attendee object ( should already have it ) |
| 2841 | 2841 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 2842 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 2842 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
| 2843 | 2843 | EEH_Template::display_template($template, $this->_template_args); |
| 2844 | 2844 | } |
| 2845 | 2845 | |
@@ -2855,12 +2855,12 @@ discard block |
||
| 2855 | 2855 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 2856 | 2856 | $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
| 2857 | 2857 | new EE_Question_Form_Input( |
| 2858 | - EE_Question::new_instance( array( |
|
| 2858 | + EE_Question::new_instance(array( |
|
| 2859 | 2859 | 'QST_ID' => 0, |
| 2860 | 2860 | 'QST_display_text' => __('State/Province', 'event_espresso'), |
| 2861 | 2861 | 'QST_system' => 'admin-state' |
| 2862 | 2862 | )), |
| 2863 | - EE_Answer::new_instance( array( |
|
| 2863 | + EE_Answer::new_instance(array( |
|
| 2864 | 2864 | 'ANS_ID' => 0, |
| 2865 | 2865 | 'ANS_value' => $this->_cpt_model_obj->state_ID() |
| 2866 | 2866 | )), |
@@ -2873,12 +2873,12 @@ discard block |
||
| 2873 | 2873 | )); |
| 2874 | 2874 | $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
| 2875 | 2875 | new EE_Question_Form_Input( |
| 2876 | - EE_Question::new_instance( array( |
|
| 2876 | + EE_Question::new_instance(array( |
|
| 2877 | 2877 | 'QST_ID' => 0, |
| 2878 | 2878 | 'QST_display_text' => __('Country', 'event_espresso'), |
| 2879 | 2879 | 'QST_system' => 'admin-country' |
| 2880 | 2880 | )), |
| 2881 | - EE_Answer::new_instance( array( |
|
| 2881 | + EE_Answer::new_instance(array( |
|
| 2882 | 2882 | 'ANS_ID' => 0, |
| 2883 | 2883 | 'ANS_value' => $this->_cpt_model_obj->country_ID() |
| 2884 | 2884 | )), |
@@ -2889,8 +2889,8 @@ discard block |
||
| 2889 | 2889 | 'append_qstn_id' => FALSE |
| 2890 | 2890 | ) |
| 2891 | 2891 | )); |
| 2892 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 2893 | - EEH_Template::display_template($template, $this->_template_args ); |
|
| 2892 | + $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
| 2893 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 2894 | 2894 | |
| 2895 | 2895 | } |
| 2896 | 2896 | |
@@ -2900,11 +2900,11 @@ discard block |
||
| 2900 | 2900 | * @access protected |
| 2901 | 2901 | * @return void |
| 2902 | 2902 | */ |
| 2903 | - public function attendee_registrations_meta_box( $post ) { |
|
| 2903 | + public function attendee_registrations_meta_box($post) { |
|
| 2904 | 2904 | |
| 2905 | 2905 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 2906 | 2906 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
| 2907 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 2907 | + $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
| 2908 | 2908 | EEH_Template::display_template($template, $this->_template_args); |
| 2909 | 2909 | |
| 2910 | 2910 | } |
@@ -2918,8 +2918,8 @@ discard block |
||
| 2918 | 2918 | * @return string html for new form. |
| 2919 | 2919 | */ |
| 2920 | 2920 | public function after_title_form_fields($post) { |
| 2921 | - if ( $post->post_type == 'espresso_attendees' ) { |
|
| 2922 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 2921 | + if ($post->post_type == 'espresso_attendees') { |
|
| 2922 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
| 2923 | 2923 | $template_args['attendee'] = $this->_cpt_model_obj; |
| 2924 | 2924 | EEH_Template::display_template($template, $template_args); |
| 2925 | 2925 | } |
@@ -2936,21 +2936,21 @@ discard block |
||
| 2936 | 2936 | * @access protected |
| 2937 | 2937 | * @return void |
| 2938 | 2938 | */ |
| 2939 | - protected function _trash_or_restore_attendees( $trash = TRUE ) { |
|
| 2939 | + protected function _trash_or_restore_attendees($trash = TRUE) { |
|
| 2940 | 2940 | |
| 2941 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 2941 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2942 | 2942 | |
| 2943 | 2943 | $ATT_MDL = EEM_Attendee::instance(); |
| 2944 | 2944 | |
| 2945 | 2945 | $success = 1; |
| 2946 | 2946 | //Checkboxes |
| 2947 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 2947 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 2948 | 2948 | // if array has more than one element than success message should be plural |
| 2949 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
| 2949 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 2950 | 2950 | // cycle thru checkboxes |
| 2951 | - while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
| 2952 | - $updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID); |
|
| 2953 | - if ( !$updated ) { |
|
| 2951 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 2952 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 2953 | + if ( ! $updated) { |
|
| 2954 | 2954 | $success = 0; |
| 2955 | 2955 | } |
| 2956 | 2956 | } |
@@ -2959,18 +2959,18 @@ discard block |
||
| 2959 | 2959 | // grab single id and delete |
| 2960 | 2960 | $ATT_ID = absint($this->_req_data['ATT_ID']); |
| 2961 | 2961 | //get attendee |
| 2962 | - $att = $ATT_MDL->get_one_by_ID( $ATT_ID ); |
|
| 2962 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 2963 | 2963 | $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
| 2964 | 2964 | $updated = $att->save(); |
| 2965 | - if ( ! $updated ) { |
|
| 2965 | + if ( ! $updated) { |
|
| 2966 | 2966 | $success = 0; |
| 2967 | 2967 | } |
| 2968 | 2968 | |
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | - $what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' ); |
|
| 2972 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
| 2973 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) ); |
|
| 2971 | + $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
| 2972 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 2973 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 2974 | 2974 | |
| 2975 | 2975 | } |
| 2976 | 2976 | |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is |
| 503 | 503 | * allowed) |
| 504 | 504 | * @param string $datetime_string mysql timestamp in UTC |
| 505 | - * @return mixed null | DateTime |
|
| 505 | + * @return null|DateTime null | DateTime |
|
| 506 | 506 | */ |
| 507 | 507 | public function prepare_for_set_from_db( $datetime_string ) { |
| 508 | 508 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * |
| 620 | 620 | * @param \DateTimeZone $DateTimeZone |
| 621 | 621 | * @param null $time |
| 622 | - * @return mixed |
|
| 622 | + * @return string |
|
| 623 | 623 | */ |
| 624 | 624 | public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
| 625 | 625 | $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
@@ -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_Datetime_Field |
@@ -118,15 +118,15 @@ discard block |
||
| 118 | 118 | * @param string $pretty_date_format |
| 119 | 119 | * @param string $pretty_time_format |
| 120 | 120 | */ |
| 121 | - public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){ |
|
| 121 | + public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') { |
|
| 122 | 122 | |
| 123 | - $this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format'); |
|
| 124 | - $this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format'); |
|
| 125 | - $this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format'); |
|
| 126 | - $this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format'); |
|
| 123 | + $this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 124 | + $this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 125 | + $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format'); |
|
| 126 | + $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format'); |
|
| 127 | 127 | |
| 128 | - parent::__construct( $table_column, $nice_name, $nullable, $default_value ); |
|
| 129 | - $this->set_timezone( $timezone_string ); |
|
| 128 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
| 129 | + $this->set_timezone($timezone_string); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @return DateTimeZone |
| 146 | 146 | */ |
| 147 | 147 | public function get_UTC_DateTimeZone() { |
| 148 | - return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' ); |
|
| 148 | + return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @return DateTimeZone |
| 155 | 155 | */ |
| 156 | 156 | public function get_blog_DateTimeZone() { |
| 157 | - return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' ); |
|
| 157 | + return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string(''); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | * @param string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp |
| 165 | 165 | * @return DateTime |
| 166 | 166 | */ |
| 167 | - public function prepare_for_set( $value_inputted_for_field_on_model_object ) { |
|
| 168 | - return $this->_get_date_object( $value_inputted_for_field_on_model_object ); |
|
| 167 | + public function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
| 168 | + return $this->_get_date_object($value_inputted_for_field_on_model_object); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | * @param bool $pretty If we're returning the pretty formats or standard format string. |
| 182 | 182 | * @return string The final assembled format string. |
| 183 | 183 | */ |
| 184 | - protected function _get_date_time_output( $pretty = FALSE ) { |
|
| 184 | + protected function _get_date_time_output($pretty = FALSE) { |
|
| 185 | 185 | |
| 186 | - switch ( $this->_date_time_output ) { |
|
| 186 | + switch ($this->_date_time_output) { |
|
| 187 | 187 | case 'time' : |
| 188 | 188 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
| 189 | 189 | break; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | break; |
| 194 | 194 | |
| 195 | 195 | default : |
| 196 | - return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format; |
|
| 196 | + return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format; |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @param string $what acceptable values are 'time' or 'date'. Any other value will be set but will always result in both 'date' and 'time' being returned. |
| 208 | 208 | * @return void |
| 209 | 209 | */ |
| 210 | - public function set_date_time_output( $what = NULL ) { |
|
| 210 | + public function set_date_time_output($what = NULL) { |
|
| 211 | 211 | $this->_date_time_output = $what; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -223,15 +223,15 @@ discard block |
||
| 223 | 223 | * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
| 224 | 224 | * @return void |
| 225 | 225 | */ |
| 226 | - public function set_timezone( $timezone_string ) { |
|
| 227 | - if( empty( $timezone_string ) && $this->_timezone_string != NULL ){ |
|
| 226 | + public function set_timezone($timezone_string) { |
|
| 227 | + if (empty($timezone_string) && $this->_timezone_string != NULL) { |
|
| 228 | 228 | // leave the timezone AS-IS if we already have one and |
| 229 | 229 | // the function arg didn't provide one |
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
| 233 | - $this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC'; |
|
| 234 | - $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string ); |
|
| 232 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
| 233 | + $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC'; |
|
| 234 | + $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | * @param string $timezone_string |
| 244 | 244 | * @return \DateTimeZone |
| 245 | 245 | */ |
| 246 | - protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) { |
|
| 247 | - return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) ); |
|
| 246 | + protected function _create_timezone_object_from_timezone_string($timezone_string = '') { |
|
| 247 | + return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string)); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | * @param bool $pretty Whether to set pretty format or not. |
| 270 | 270 | * @return void |
| 271 | 271 | */ |
| 272 | - public function set_date_format( $format, $pretty = false ) { |
|
| 273 | - if ( $pretty ) { |
|
| 272 | + public function set_date_format($format, $pretty = false) { |
|
| 273 | + if ($pretty) { |
|
| 274 | 274 | $this->_pretty_date_format = $format; |
| 275 | 275 | } else { |
| 276 | 276 | $this->_date_format = $format; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param bool $pretty Whether to get pretty format or not. |
| 286 | 286 | * @return string |
| 287 | 287 | */ |
| 288 | - public function get_date_format( $pretty = false ) { |
|
| 288 | + public function get_date_format($pretty = false) { |
|
| 289 | 289 | return $pretty ? $this->_pretty_date_format : $this->_date_format; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | * @param bool $pretty Whether to set pretty format or not. |
| 301 | 301 | * @return void |
| 302 | 302 | */ |
| 303 | - public function set_time_format( $format, $pretty = false ) { |
|
| 304 | - if ( $pretty ) { |
|
| 303 | + public function set_time_format($format, $pretty = false) { |
|
| 304 | + if ($pretty) { |
|
| 305 | 305 | $this->_pretty_time_format = $format; |
| 306 | 306 | } else { |
| 307 | 307 | $this->_time_format = $format; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param bool $pretty Whether to get pretty format or not. |
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | - public function get_time_format( $pretty = false ) { |
|
| 319 | + public function get_time_format($pretty = false) { |
|
| 320 | 320 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
| 321 | 321 | } |
| 322 | 322 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function) |
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | - public function set_pretty_date_format( $format ) { |
|
| 334 | + public function set_pretty_date_format($format) { |
|
| 335 | 335 | $this->_pretty_date_format = $format; |
| 336 | 336 | } |
| 337 | 337 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function) |
| 349 | 349 | * @return void |
| 350 | 350 | */ |
| 351 | - public function set_pretty_time_format( $format ) { |
|
| 351 | + public function set_pretty_time_format($format) { |
|
| 352 | 352 | $this->_pretty_time_format = $format; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | * @param DateTime $current current DateTime object for the datetime field |
| 361 | 361 | * @return DateTime |
| 362 | 362 | */ |
| 363 | - public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){ |
|
| 363 | + public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) { |
|
| 364 | 364 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
| 365 | - if ( $time_to_set_string instanceof DateTime ) { |
|
| 365 | + if ($time_to_set_string instanceof DateTime) { |
|
| 366 | 366 | $parsed = array( |
| 367 | 367 | 'hour' => $time_to_set_string->format('H'), |
| 368 | 368 | 'minute' => $time_to_set_string->format('i'), |
@@ -370,12 +370,12 @@ discard block |
||
| 370 | 370 | ); |
| 371 | 371 | } else { |
| 372 | 372 | //parse incoming string |
| 373 | - $parsed = date_parse_from_format( $this->_time_format, $time_to_set_string ); |
|
| 373 | + $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | //make sure $current is in the correct timezone. |
| 377 | - $current->setTimezone( $this->_DateTimeZone ); |
|
| 378 | - return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] ); |
|
| 377 | + $current->setTimezone($this->_DateTimeZone); |
|
| 378 | + return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
@@ -386,9 +386,9 @@ discard block |
||
| 386 | 386 | * @param DateTime $current current DateTime object for the datetime field |
| 387 | 387 | * @return DateTime |
| 388 | 388 | */ |
| 389 | - public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){ |
|
| 389 | + public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) { |
|
| 390 | 390 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
| 391 | - if ( $date_to_set_string instanceof DateTime ) { |
|
| 391 | + if ($date_to_set_string instanceof DateTime) { |
|
| 392 | 392 | $parsed = array( |
| 393 | 393 | 'year' => $date_to_set_string->format('Y'), |
| 394 | 394 | 'month' => $date_to_set_string->format('m'), |
@@ -396,12 +396,12 @@ discard block |
||
| 396 | 396 | ); |
| 397 | 397 | } else { |
| 398 | 398 | //parse incoming string |
| 399 | - $parsed = date_parse_from_format( $this->_date_format, $date_to_set_string ); |
|
| 399 | + $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | //make sure $current is in the correct timezone |
| 403 | - $current->setTimezone( $this->_DateTimeZone ); |
|
| 404 | - return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] ); |
|
| 403 | + $current->setTimezone($this->_DateTimeZone); |
|
| 404 | + return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | * @param DateTime $DateTime |
| 414 | 414 | * @return string formatted date time for given timezone |
| 415 | 415 | */ |
| 416 | - public function prepare_for_get( $DateTime ) { |
|
| 417 | - return $this->_prepare_for_display( $DateTime ); |
|
| 416 | + public function prepare_for_get($DateTime) { |
|
| 417 | + return $this->_prepare_for_display($DateTime); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | |
@@ -429,8 +429,8 @@ discard block |
||
| 429 | 429 | * @param null $schema |
| 430 | 430 | * @return string |
| 431 | 431 | */ |
| 432 | - public function prepare_for_pretty_echoing( $DateTime, $schema = null ) { |
|
| 433 | - return $this->_prepare_for_display( $DateTime, $schema ? $schema : true ); |
|
| 432 | + public function prepare_for_pretty_echoing($DateTime, $schema = null) { |
|
| 433 | + return $this->_prepare_for_display($DateTime, $schema ? $schema : true); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
@@ -444,36 +444,36 @@ discard block |
||
| 444 | 444 | * @return string |
| 445 | 445 | * @throws \EE_Error |
| 446 | 446 | */ |
| 447 | - protected function _prepare_for_display( $DateTime, $schema = false ) { |
|
| 448 | - if ( ! $DateTime instanceof DateTime ) { |
|
| 449 | - if ( $this->_nullable ) { |
|
| 447 | + protected function _prepare_for_display($DateTime, $schema = false) { |
|
| 448 | + if ( ! $DateTime instanceof DateTime) { |
|
| 449 | + if ($this->_nullable) { |
|
| 450 | 450 | return ''; |
| 451 | 451 | } else { |
| 452 | - if ( WP_DEBUG ) { |
|
| 453 | - throw new EE_Error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso' ), $this->_nicename ) ); |
|
| 452 | + if (WP_DEBUG) { |
|
| 453 | + throw new EE_Error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso'), $this->_nicename)); |
|
| 454 | 454 | } else { |
| 455 | - $DateTime = new DateTime( "now" ); |
|
| 456 | - EE_Error::add_error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso' ), $this->_nicename ) ); |
|
| 455 | + $DateTime = new DateTime("now"); |
|
| 456 | + EE_Error::add_error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso'), $this->_nicename)); |
|
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | - $format_string = $this->_get_date_time_output( $schema ); |
|
| 460 | + $format_string = $this->_get_date_time_output($schema); |
|
| 461 | 461 | //make sure datetime_value is in the correct timezone (in case that's been updated). |
| 462 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
| 463 | - if ( $schema ) { |
|
| 464 | - if( $this->_display_timezone() ) { |
|
| 462 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
| 463 | + if ($schema) { |
|
| 464 | + if ($this->_display_timezone()) { |
|
| 465 | 465 | //must be explicit because schema could equal true. |
| 466 | - if( $schema === 'no_html' ){ |
|
| 467 | - $timezone_string = ' (' . $DateTime->format( 'T' ) . ')'; |
|
| 468 | - }else{ |
|
| 469 | - $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>'; |
|
| 466 | + if ($schema === 'no_html') { |
|
| 467 | + $timezone_string = ' ('.$DateTime->format('T').')'; |
|
| 468 | + } else { |
|
| 469 | + $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>'; |
|
| 470 | 470 | } |
| 471 | 471 | } else { |
| 472 | 472 | $timezone_string = ''; |
| 473 | 473 | } |
| 474 | - return $DateTime->format( $format_string ) . $timezone_string; |
|
| 474 | + return $DateTime->format($format_string).$timezone_string; |
|
| 475 | 475 | } else { |
| 476 | - return $DateTime->format( $format_string ); |
|
| 476 | + return $DateTime->format($format_string); |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
@@ -487,18 +487,18 @@ discard block |
||
| 487 | 487 | * @return string mysql timestamp in UTC |
| 488 | 488 | * @throws \EE_Error |
| 489 | 489 | */ |
| 490 | - public function prepare_for_use_in_db( $datetime_value ) { |
|
| 490 | + public function prepare_for_use_in_db($datetime_value) { |
|
| 491 | 491 | //we allow an empty value or DateTime object, but nothing else. |
| 492 | - if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) { |
|
| 493 | - throw new EE_Error( __('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso' ) ); |
|
| 492 | + if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
| 493 | + throw new EE_Error(__('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso')); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - if ( $datetime_value instanceof DateTime ) { |
|
| 497 | - return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format ); |
|
| 496 | + if ($datetime_value instanceof DateTime) { |
|
| 497 | + return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true |
| 501 | - return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null; |
|
| 501 | + return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null; |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | |
@@ -511,20 +511,20 @@ discard block |
||
| 511 | 511 | * @param string $datetime_string mysql timestamp in UTC |
| 512 | 512 | * @return mixed null | DateTime |
| 513 | 513 | */ |
| 514 | - public function prepare_for_set_from_db( $datetime_string ) { |
|
| 514 | + public function prepare_for_set_from_db($datetime_string) { |
|
| 515 | 515 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
| 516 | - if ( empty( $datetime_string) && $this->_nullable ) { |
|
| 516 | + if (empty($datetime_string) && $this->_nullable) { |
|
| 517 | 517 | return null; |
| 518 | 518 | } |
| 519 | 519 | // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating |
| 520 | - $DateTime = empty( $datetime_string ) ? new DateTime( 'now', $this->get_UTC_DateTimeZone() ) : DateTime::createFromFormat( EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone() ); |
|
| 520 | + $DateTime = empty($datetime_string) ? new DateTime('now', $this->get_UTC_DateTimeZone()) : DateTime::createFromFormat(EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone()); |
|
| 521 | 521 | |
| 522 | - if ( ! $DateTime instanceof DateTime ) { |
|
| 522 | + if ( ! $DateTime instanceof DateTime) { |
|
| 523 | 523 | //if still no datetime object, then let's just use now |
| 524 | - $DateTime = new DateTime( 'now', $this->get_UTC_DateTimeZone() ); |
|
| 524 | + $DateTime = new DateTime('now', $this->get_UTC_DateTimeZone()); |
|
| 525 | 525 | } |
| 526 | 526 | // THEN apply the field's set DateTimeZone |
| 527 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
| 527 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
| 528 | 528 | return $DateTime; |
| 529 | 529 | } |
| 530 | 530 | |
@@ -541,15 +541,15 @@ discard block |
||
| 541 | 541 | protected function _display_timezone() { |
| 542 | 542 | |
| 543 | 543 | // first let's do a comparison of timezone strings. If they match then we can get out without any further calculations |
| 544 | - $blog_string = get_option( 'timezone_string' ); |
|
| 545 | - if ( $blog_string == $this->_timezone_string ) { |
|
| 544 | + $blog_string = get_option('timezone_string'); |
|
| 545 | + if ($blog_string == $this->_timezone_string) { |
|
| 546 | 546 | return FALSE; |
| 547 | 547 | } |
| 548 | 548 | // now we need to calc the offset for the timezone string so we can compare with the blog offset. |
| 549 | - $this_offset = $this->get_timezone_offset( $this->_DateTimeZone ); |
|
| 550 | - $blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() ); |
|
| 549 | + $this_offset = $this->get_timezone_offset($this->_DateTimeZone); |
|
| 550 | + $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone()); |
|
| 551 | 551 | // now compare |
| 552 | - if ( $blog_offset === $this_offset ) { |
|
| 552 | + if ($blog_offset === $this_offset) { |
|
| 553 | 553 | return FALSE; |
| 554 | 554 | } |
| 555 | 555 | return TRUE; |
@@ -567,24 +567,24 @@ discard block |
||
| 567 | 567 | * |
| 568 | 568 | * @return DateTime |
| 569 | 569 | */ |
| 570 | - protected function _get_date_object( $date_string ) { |
|
| 570 | + protected function _get_date_object($date_string) { |
|
| 571 | 571 | //first if this is an empty date_string and nullable is allowed, just return null. |
| 572 | - if ( $this->_nullable && empty( $date_string ) ) { |
|
| 572 | + if ($this->_nullable && empty($date_string)) { |
|
| 573 | 573 | return null; |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | // if incoming date |
| 577 | - if ( $date_string instanceof DateTime ) { |
|
| 578 | - $date_string->setTimezone( $this->_DateTimeZone ); |
|
| 577 | + if ($date_string instanceof DateTime) { |
|
| 578 | + $date_string->setTimezone($this->_DateTimeZone); |
|
| 579 | 579 | return $date_string; |
| 580 | 580 | } |
| 581 | 581 | // if empty date_string and made it here. |
| 582 | 582 | // Return a datetime object for now in the given timezone. |
| 583 | - if ( empty( $date_string ) ) { |
|
| 584 | - return new DateTime( "now", $this->_DateTimeZone ); |
|
| 583 | + if (empty($date_string)) { |
|
| 584 | + return new DateTime("now", $this->_DateTimeZone); |
|
| 585 | 585 | } |
| 586 | 586 | // if $date_string is matches something that looks like a Unix timestamp let's just use it. |
| 587 | - if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) { |
|
| 587 | + if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) { |
|
| 588 | 588 | try { |
| 589 | 589 | /** |
| 590 | 590 | * This is operating under the assumption that the incoming Unix timestamp is |
@@ -592,29 +592,29 @@ discard block |
||
| 592 | 592 | * current_time('timestamp'); |
| 593 | 593 | * |
| 594 | 594 | */ |
| 595 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
| 596 | - return $DateTime->setTimestamp( $date_string ); |
|
| 597 | - } catch ( Exception $e ) { |
|
| 595 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
| 596 | + return $DateTime->setTimestamp($date_string); |
|
| 597 | + } catch (Exception $e) { |
|
| 598 | 598 | // should be rare, but if things got fooled then let's just continue |
| 599 | 599 | } |
| 600 | 600 | } |
| 601 | 601 | //not a unix timestamp. So we will use the set format on this object and set timezone to |
| 602 | 602 | //create the DateTime object. |
| 603 | - $format = $this->_date_format . ' ' . $this->_time_format; |
|
| 603 | + $format = $this->_date_format.' '.$this->_time_format; |
|
| 604 | 604 | try { |
| 605 | - $DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone ); |
|
| 606 | - if ( ! $DateTime instanceof DateTime ) { |
|
| 605 | + $DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
|
| 606 | + if ( ! $DateTime instanceof DateTime) { |
|
| 607 | 607 | throw new EE_Error( |
| 608 | 608 | sprintf( |
| 609 | - __( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ), |
|
| 609 | + __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |
|
| 610 | 610 | $date_string, |
| 611 | 611 | $format |
| 612 | 612 | ) |
| 613 | 613 | ); |
| 614 | 614 | } |
| 615 | - } catch ( Exception $e ) { |
|
| 615 | + } catch (Exception $e) { |
|
| 616 | 616 | // if we made it here then likely then something went really wrong. Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone. |
| 617 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
| 617 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
| 618 | 618 | } |
| 619 | 619 | return $DateTime; |
| 620 | 620 | } |
@@ -628,9 +628,9 @@ discard block |
||
| 628 | 628 | * @param null $time |
| 629 | 629 | * @return mixed |
| 630 | 630 | */ |
| 631 | - public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
|
| 632 | - $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
|
| 633 | - $transitions = $DateTimeZone->getTransitions( $time ); |
|
| 631 | + public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) { |
|
| 632 | + $time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time(); |
|
| 633 | + $transitions = $DateTimeZone->getTransitions($time); |
|
| 634 | 634 | return $transitions[0]['offset']; |
| 635 | 635 | } |
| 636 | 636 | |
@@ -642,10 +642,10 @@ discard block |
||
| 642 | 642 | * @param string $timezone_string |
| 643 | 643 | * @return string abbreviation |
| 644 | 644 | */ |
| 645 | - public function get_timezone_abbrev( $timezone_string ) { |
|
| 646 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
| 647 | - $dateTime = new DateTime( 'now', new DateTimeZone( $timezone_string ) ); |
|
| 648 | - return $dateTime->format( 'T' ); |
|
| 645 | + public function get_timezone_abbrev($timezone_string) { |
|
| 646 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
| 647 | + $dateTime = new DateTime('now', new DateTimeZone($timezone_string)); |
|
| 648 | + return $dateTime->format('T'); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | /** |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | * @return |
| 654 | 654 | */ |
| 655 | 655 | public function get_default_value() { |
| 656 | - if( $this->_default_value === EE_Datetime_Field::now ) { |
|
| 656 | + if ($this->_default_value === EE_Datetime_Field::now) { |
|
| 657 | 657 | return time(); |
| 658 | 658 | } else { |
| 659 | 659 | return parent::get_default_value(); |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | * Returns the name of the field's name that points to the WP_User table |
| 803 | 803 | * on this model (or follows the _model_chain_to_wp_user and uses that model's |
| 804 | 804 | * foreign key to the WP_User table) |
| 805 | - * @return string|boolean string on success, boolean false when there is no |
|
| 805 | + * @return string|false string on success, boolean false when there is no |
|
| 806 | 806 | * foreign key to the WP_User table |
| 807 | 807 | */ |
| 808 | 808 | public function wp_user_field_name() { |
@@ -897,6 +897,7 @@ discard block |
||
| 897 | 897 | * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array. |
| 898 | 898 | * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection |
| 899 | 899 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
| 900 | + * @param string $columns_to_select |
|
| 900 | 901 | * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
| 901 | 902 | * @throws \EE_Error |
| 902 | 903 | */ |
@@ -1242,7 +1243,7 @@ discard block |
||
| 1242 | 1243 | * @param bool $pretty Whether to return the pretty formats (true) or not (false). |
| 1243 | 1244 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
| 1244 | 1245 | * |
| 1245 | - * @return array formats in an array with the date format first, and the time format last. |
|
| 1246 | + * @return string[] formats in an array with the date format first, and the time format last. |
|
| 1246 | 1247 | */ |
| 1247 | 1248 | public function get_formats_for( $field_name, $pretty = false ) { |
| 1248 | 1249 | $field_settings = $this->field_settings_for( $field_name ); |
@@ -1277,7 +1278,7 @@ discard block |
||
| 1277 | 1278 | * |
| 1278 | 1279 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
| 1279 | 1280 | * |
| 1280 | - * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
| 1281 | + * @return string|null If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
| 1281 | 1282 | * exception is triggered. |
| 1282 | 1283 | */ |
| 1283 | 1284 | public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
@@ -1588,7 +1589,7 @@ discard block |
||
| 1588 | 1589 | * Wrapper for EEM_Base::delete_permanently() |
| 1589 | 1590 | * |
| 1590 | 1591 | * @param mixed $id |
| 1591 | - * @return boolean whether the row got deleted or not |
|
| 1592 | + * @return integer whether the row got deleted or not |
|
| 1592 | 1593 | * @throws \EE_Error |
| 1593 | 1594 | */ |
| 1594 | 1595 | public function delete_permanently_by_ID( $id ) { |
@@ -1607,7 +1608,7 @@ discard block |
||
| 1607 | 1608 | * Wrapper for EEM_Base::delete() |
| 1608 | 1609 | * |
| 1609 | 1610 | * @param mixed $id |
| 1610 | - * @return boolean whether the row got deleted or not |
|
| 1611 | + * @return integer whether the row got deleted or not |
|
| 1611 | 1612 | * @throws \EE_Error |
| 1612 | 1613 | */ |
| 1613 | 1614 | public function delete_by_ID( $id ){ |
@@ -2017,7 +2018,7 @@ discard block |
||
| 2017 | 2018 | /** |
| 2018 | 2019 | * Verifies the EE addons' database is up-to-date and records that we've done it on |
| 2019 | 2020 | * EEM_Base::$_db_verification_level |
| 2020 | - * @param $wpdb_method |
|
| 2021 | + * @param string $wpdb_method |
|
| 2021 | 2022 | * @param $arguments_to_provide |
| 2022 | 2023 | * @return string |
| 2023 | 2024 | */ |
@@ -2112,6 +2113,7 @@ discard block |
||
| 2112 | 2113 | * @return boolean of success |
| 2113 | 2114 | * @throws \EE_Error |
| 2114 | 2115 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
| 2116 | + * @param EE_Base_Class $id_or_obj |
|
| 2115 | 2117 | */ |
| 2116 | 2118 | public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query= array() ){ |
| 2117 | 2119 | $relation_obj = $this->related_settings_for($relationName); |
@@ -2121,7 +2123,7 @@ discard block |
||
| 2121 | 2123 | |
| 2122 | 2124 | |
| 2123 | 2125 | /** |
| 2124 | - * @param mixed $id_or_obj |
|
| 2126 | + * @param EE_Base_Class $id_or_obj |
|
| 2125 | 2127 | * @param string $relationName |
| 2126 | 2128 | * @param array $where_query_params |
| 2127 | 2129 | * @param EE_Base_Class[] objects to which relations were removed |
@@ -2160,7 +2162,7 @@ discard block |
||
| 2160 | 2162 | * However, if the model objects can't be deleted because of blocking related model objects, then |
| 2161 | 2163 | * they aren't deleted. (Unless the thing that would have been deleted can be soft-deleted, that still happens). |
| 2162 | 2164 | * |
| 2163 | - * @param EE_Base_Class|int|string $id_or_obj |
|
| 2165 | + * @param EE_Base_Class $id_or_obj |
|
| 2164 | 2166 | * @param string $model_name |
| 2165 | 2167 | * @param array $query_params |
| 2166 | 2168 | * @return int how many deleted |
@@ -2180,7 +2182,7 @@ discard block |
||
| 2180 | 2182 | * the model objects can't be hard deleted because of blocking related model objects, |
| 2181 | 2183 | * just does a soft-delete on them instead. |
| 2182 | 2184 | * |
| 2183 | - * @param EE_Base_Class|int|string $id_or_obj |
|
| 2185 | + * @param EE_Base_Class $id_or_obj |
|
| 2184 | 2186 | * @param string $model_name |
| 2185 | 2187 | * @param array $query_params |
| 2186 | 2188 | * @return int how many deleted |
@@ -2229,6 +2231,7 @@ discard block |
||
| 2229 | 2231 | * @param string $model_name like 'Event', or 'Registration' |
| 2230 | 2232 | * @param array $query_params like EEM_Base::get_all's |
| 2231 | 2233 | * @param string $field_to_sum name of field to count by. By default, uses primary key |
| 2234 | + * @param EE_Base_Class $id_or_obj |
|
| 2232 | 2235 | * @return float |
| 2233 | 2236 | * @throws \EE_Error |
| 2234 | 2237 | */ |
@@ -2638,7 +2641,7 @@ discard block |
||
| 2638 | 2641 | /** |
| 2639 | 2642 | * Finds all the fields that correspond to the given table |
| 2640 | 2643 | * @param string $table_alias, array key in EEM_Base::_tables |
| 2641 | - * @return EE_Model_Field_Base[] |
|
| 2644 | + * @return EE_Model_Field_Base |
|
| 2642 | 2645 | */ |
| 2643 | 2646 | public function _get_fields_for_table($table_alias){ |
| 2644 | 2647 | return $this->_fields[$table_alias]; |
@@ -3901,7 +3904,7 @@ discard block |
||
| 3901 | 3904 | /** |
| 3902 | 3905 | * gets the field object of type 'primary_key' from the fieldsSettings attribute. |
| 3903 | 3906 | * Eg, on EE_Answer that would be ANS_ID field object |
| 3904 | - * @param $field_obj |
|
| 3907 | + * @param EE_Model_Field_Base $field_obj |
|
| 3905 | 3908 | * @return boolean |
| 3906 | 3909 | */ |
| 3907 | 3910 | public function is_primary_key_field( $field_obj ){ |
@@ -3997,7 +4000,7 @@ discard block |
||
| 3997 | 4000 | * Gets the actual table for the table alias |
| 3998 | 4001 | * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe |
| 3999 | 4002 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
| 4000 | - * @return EE_Table_Base |
|
| 4003 | + * @return string |
|
| 4001 | 4004 | */ |
| 4002 | 4005 | public function get_table_for_alias($table_alias){ |
| 4003 | 4006 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
@@ -4543,7 +4546,7 @@ discard block |
||
| 4543 | 4546 | } |
| 4544 | 4547 | /** |
| 4545 | 4548 | * Read comments for assume_values_already_prepared_by_model_object() |
| 4546 | - * @return int |
|
| 4549 | + * @return boolean |
|
| 4547 | 4550 | */ |
| 4548 | 4551 | public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
| 4549 | 4552 | return $this->_values_already_prepared_by_model_object; |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | * Gets all the EE_Base_Class objects which match the $query_params, by querying the DB. |
| 654 | 654 | * |
| 655 | 655 | * @param array $query_params { |
| 656 | - * @var array $0 (where) array { |
|
| 656 | + * @var array $0 (where) array { |
|
| 657 | 657 | * eg: array('QST_display_text'=>'Are you bob?','QST_admin_text'=>'Determine if user is bob') |
| 658 | - * becomes |
|
| 658 | + * becomes |
|
| 659 | 659 | * SQL >> "...WHERE QST_display_text = 'Are you bob?' AND QST_admin_text = 'Determine if user is bob'...") |
| 660 | - * To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name |
|
| 660 | + * To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name |
|
| 661 | 661 | * onto the field name. Eg, EEM_Event::instance()->get_all(array(array('Venue.VNU_ID'=>12))); |
| 662 | 662 | * becomes |
| 663 | 663 | * SQL >> "SELECT * FROM wp_posts AS Event_CPT |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * SQL >> "...WHERE QST_display_text LIKE '%bob%' AND QST_ID < 34 AND QST_wp_user IN (1,2,7,23)...". |
| 678 | 678 | * Valid operators so far: =, !=, <, <=, >, >=, LIKE, NOT LIKE, IN (followed by numeric-indexed array), |
| 679 | 679 | * NOT IN (dido), BETWEEN (followed by an array with exactly 2 date strings), IS NULL, and IS NOT NULL |
| 680 | - * Values can be a string, int, or float. They can also be arrays IFF the operator is IN. |
|
| 680 | + * Values can be a string, int, or float. They can also be arrays IFF the operator is IN. |
|
| 681 | 681 | * Also, values can actually be field names. To indicate the value is a field, |
| 682 | 682 | * simply provide a third array item (true) to the operator-value array like so: |
| 683 | 683 | * eg: array( 'DTT_reg_limit' => array('>', 'DTT_sold', TRUE) ) |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | * Note: you can also use related model field names like you would any other field name. |
| 687 | 687 | * eg: array('Datetime.DTT_reg_limit'=>array('=','Datetime.DTT_sold',TRUE) |
| 688 | 688 | * could be used if you were querying EEM_Tickets (because Datetime is directly related to tickets) |
| 689 | - * Also, by default all the where conditions are AND'd together. |
|
| 689 | + * Also, by default all the where conditions are AND'd together. |
|
| 690 | 690 | * To override this, add an array key 'OR' (or 'AND') and the array to be OR'd together |
| 691 | 691 | * eg: array('OR'=>array('TXN_ID' => 23 , 'TXN_timestamp__>' => 345678912)) |
| 692 | 692 | * becomes |
@@ -701,17 +701,17 @@ discard block |
||
| 701 | 701 | * eg array('OR'=>array('NOT'=>array('TXN_total' => 50, 'TXN_paid'=>23)),AND=>array('TXN_ID'=>1,'STS_ID'=>'TIN') |
| 702 | 702 | * becomes |
| 703 | 703 | * SQL >> "...where ! (TXN_total =50 OR TXN_paid =23) AND TXN_ID=1 AND STS_ID='TIN'" |
| 704 | - * They can be nested indefinitely. |
|
| 704 | + * They can be nested indefinitely. |
|
| 705 | 705 | * eg: array('OR'=>array('TXN_total' => 23, 'NOT'=> array( 'TXN_timestamp'=> 345678912, 'AND'=>array('TXN_paid' => 53, 'STS_ID' => 'TIN')))) |
| 706 | 706 | * becomes |
| 707 | 707 | * SQL >> "...WHERE TXN_total = 23 OR ! (TXN_timestamp = 345678912 OR (TXN_paid = 53 AND STS_ID = 'TIN'))..." |
| 708 | - * GOTCHA: |
|
| 708 | + * GOTCHA: |
|
| 709 | 709 | * because this is an array, array keys must be unique, making it impossible to place two or more where conditions applying to the same field. |
| 710 | 710 | * eg: array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp'=>array('<',$end_date),'PAY_timestamp'=>array('!=',$special_date)), |
| 711 | 711 | * as PHP enforces that the array keys must be unique, thus removing the first two array entries with key 'PAY_timestamp'. |
| 712 | 712 | * becomes |
| 713 | 713 | * SQL >> "PAY_timestamp != 4234232", ignoring the first two PAY_timestamp conditions). |
| 714 | - * To overcome this, you can add a '*' character to the end of the field's name, followed by anything. |
|
| 714 | + * To overcome this, you can add a '*' character to the end of the field's name, followed by anything. |
|
| 715 | 715 | * These will be removed when generating the SQL string, but allow for the array keys to be unique. |
| 716 | 716 | * eg: you could rewrite the previous query as: |
| 717 | 717 | * array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp*1st'=>array('<',$end_date),'PAY_timestamp*2nd'=>array('!=',$special_date)) |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | * You will probably only want to do this in hopes of increasing efficiency, as related models which belongs to the current model |
| 745 | 745 | * (ie, the current model has a foreign key to them, like how Registration belongs to Attendee) can be cached in order |
| 746 | 746 | * to avoid future queries |
| 747 | - * @var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out |
|
| 747 | + * @var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out |
|
| 748 | 748 | * if you want to include them, set this query param to 'none'. If you want to ONLY disable THIS model's default where conditions |
| 749 | 749 | * set it to 'other_models_only'. If you only want this model's default where conditions added to the query, use 'this_model_only'. |
| 750 | 750 | * If you want to use all default where conditions (default), set to 'all'. |
@@ -1014,7 +1014,6 @@ discard block |
||
| 1014 | 1014 | /** |
| 1015 | 1015 | * Gets a single item for this model from the DB, given the $query_params. Only returns a single class, not an array. If no item is found, |
| 1016 | 1016 | * null is returned. |
| 1017 | - |
|
| 1018 | 1017 | * |
| 1019 | 1018 | *@param array $query_params like EEM_Base's $query_params variable. |
| 1020 | 1019 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class|NULL |
@@ -1117,7 +1116,7 @@ discard block |
||
| 1117 | 1116 | * can indicate just the columns you |
| 1118 | 1117 | * want and a single array indexed by |
| 1119 | 1118 | * the columns will be returned. |
| 1120 | - * @return EE_Base_Class|null|array() |
|
| 1119 | + * @return EE_Base_Class|null|array() |
|
| 1121 | 1120 | * @throws EE_Error |
| 1122 | 1121 | */ |
| 1123 | 1122 | public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
@@ -1765,7 +1764,7 @@ discard block |
||
| 1765 | 1764 | //make sure there's no related objects blocking its deletion (if we're checking) |
| 1766 | 1765 | if ( |
| 1767 | 1766 | $allow_blocking |
| 1768 | - && $this->delete_is_blocked_by_related_models( |
|
| 1767 | + && $this->delete_is_blocked_by_related_models( |
|
| 1769 | 1768 | $delete_object[ $primary_table->get_fully_qualified_pk_column() ] |
| 1770 | 1769 | ) |
| 1771 | 1770 | ) { |
@@ -1813,8 +1812,8 @@ discard block |
||
| 1813 | 1812 | foreach($fields as $cpk_field){ |
| 1814 | 1813 | if ( $cpk_field instanceof EE_Model_Field_Base ){ |
| 1815 | 1814 | $values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column() |
| 1816 | - . "=" |
|
| 1817 | - . $delete_object[ $cpk_field->get_qualified_column() ]; |
|
| 1815 | + . "=" |
|
| 1816 | + . $delete_object[ $cpk_field->get_qualified_column() ]; |
|
| 1818 | 1817 | } |
| 1819 | 1818 | } |
| 1820 | 1819 | $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
@@ -2930,8 +2929,8 @@ discard block |
||
| 2930 | 2929 | } |
| 2931 | 2930 | //if 'order_by' wasn't set, maybe they are just using 'order' on its own? |
| 2932 | 2931 | if ( ! array_key_exists( 'order_by', $query_params ) |
| 2933 | - && array_key_exists( 'order', $query_params ) |
|
| 2934 | - && ! empty( $query_params['order'] ) |
|
| 2932 | + && array_key_exists( 'order', $query_params ) |
|
| 2933 | + && ! empty( $query_params['order'] ) |
|
| 2935 | 2934 | ) { |
| 2936 | 2935 | $pk_field = $this->get_primary_key_field(); |
| 2937 | 2936 | $order = $this->_extract_order( $query_params['order'] ); |
@@ -4469,7 +4468,7 @@ discard block |
||
| 4469 | 4468 | $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
| 4470 | 4469 | } else if ( |
| 4471 | 4470 | $primary_key_field instanceof EE_Primary_Key_String_Field |
| 4472 | - && is_string( $base_class_obj_or_id ) |
|
| 4471 | + && is_string( $base_class_obj_or_id ) |
|
| 4473 | 4472 | ) { |
| 4474 | 4473 | // assume its a string representation of the object |
| 4475 | 4474 | $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | if( isset( $this->_cap_restriction_generators[ $context ] ) && |
| 555 | 555 | $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) { |
| 556 | 556 | return $this->_cap_restriction_generators[ $context ]->generate_restrictions(); |
| 557 | - }else{ |
|
| 557 | + } else{ |
|
| 558 | 558 | return array(); |
| 559 | 559 | } |
| 560 | 560 | } |
@@ -812,13 +812,13 @@ discard block |
||
| 812 | 812 | $last_model_name = end( $models_to_follow_to_wp_users ); |
| 813 | 813 | $model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name ); |
| 814 | 814 | $model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.'; |
| 815 | - }else{ |
|
| 815 | + } else{ |
|
| 816 | 816 | $model_with_fk_to_wp_users = $this; |
| 817 | 817 | $model_chain_to_wp_user = ''; |
| 818 | 818 | } |
| 819 | 819 | $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' ); |
| 820 | 820 | return $model_chain_to_wp_user . $wp_user_field->get_name(); |
| 821 | - }catch( EE_Error $e ) { |
|
| 821 | + } catch( EE_Error $e ) { |
|
| 822 | 822 | return false; |
| 823 | 823 | } |
| 824 | 824 | } |
@@ -846,11 +846,11 @@ discard block |
||
| 846 | 846 | public function is_owned() { |
| 847 | 847 | if( $this->model_chain_to_wp_user() ){ |
| 848 | 848 | return true; |
| 849 | - }else{ |
|
| 849 | + } else{ |
|
| 850 | 850 | try{ |
| 851 | 851 | $this->get_foreign_key_to( 'WP_User' ); |
| 852 | 852 | return true; |
| 853 | - }catch( EE_Error $e ){ |
|
| 853 | + } catch( EE_Error $e ){ |
|
| 854 | 854 | return false; |
| 855 | 855 | } |
| 856 | 856 | } |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | $select_sql_array[] = "{$selection_and_datatype[0]} AS $alias"; |
| 947 | 947 | } |
| 948 | 948 | $columns_to_select_string = implode(", ",$select_sql_array); |
| 949 | - }else{ |
|
| 949 | + } else{ |
|
| 950 | 950 | $columns_to_select_string = $columns_to_select; |
| 951 | 951 | } |
| 952 | 952 | return $columns_to_select_string; |
@@ -1004,7 +1004,7 @@ discard block |
||
| 1004 | 1004 | $conditions_from_id = $this->parse_index_primary_key_string( $id ); |
| 1005 | 1005 | if( $conditions_from_id === null ) { |
| 1006 | 1006 | $query_params[ 0 ][ $this->primary_key_name() ] = $id ; |
| 1007 | - }else{ |
|
| 1007 | + } else{ |
|
| 1008 | 1008 | //no primary key, so the $id must be from the get_index_primary_key_string() |
| 1009 | 1009 | $query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) ); |
| 1010 | 1010 | } |
@@ -1031,7 +1031,7 @@ discard block |
||
| 1031 | 1031 | $items = $this->get_all($query_params); |
| 1032 | 1032 | if(empty($items)){ |
| 1033 | 1033 | return null; |
| 1034 | - }else{ |
|
| 1034 | + } else{ |
|
| 1035 | 1035 | return array_shift($items); |
| 1036 | 1036 | } |
| 1037 | 1037 | } |
@@ -1417,7 +1417,7 @@ discard block |
||
| 1417 | 1417 | //get the model object's PK, as we'll want this if we need to insert a row into secondary tables |
| 1418 | 1418 | if( $this->has_primary_key_field() ){ |
| 1419 | 1419 | $main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ]; |
| 1420 | - }else{ |
|
| 1420 | + } else{ |
|
| 1421 | 1421 | //if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work) |
| 1422 | 1422 | $main_table_pk_value = null; |
| 1423 | 1423 | } |
@@ -1456,7 +1456,7 @@ discard block |
||
| 1456 | 1456 | if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){ |
| 1457 | 1457 | if( $this->has_primary_key_field() ){ |
| 1458 | 1458 | $model_objs_affected_ids = $this->get_col( $query_params ); |
| 1459 | - }else{ |
|
| 1459 | + } else{ |
|
| 1460 | 1460 | //we need to select a bunch of columns and then combine them into the the "index primary key string"s |
| 1461 | 1461 | $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A ); |
| 1462 | 1462 | $model_objs_affected_ids = array(); |
@@ -1520,9 +1520,9 @@ discard block |
||
| 1520 | 1520 | |
| 1521 | 1521 | if( $field_to_select ){ |
| 1522 | 1522 | $field = $this->field_settings_for( $field_to_select ); |
| 1523 | - }elseif( $this->has_primary_key_field ( ) ){ |
|
| 1523 | + } elseif( $this->has_primary_key_field ( ) ){ |
|
| 1524 | 1524 | $field = $this->get_primary_key_field(); |
| 1525 | - }else{ |
|
| 1525 | + } else{ |
|
| 1526 | 1526 | //no primary key, just grab the first column |
| 1527 | 1527 | $field = reset( $this->field_settings()); |
| 1528 | 1528 | } |
@@ -1549,7 +1549,7 @@ discard block |
||
| 1549 | 1549 | $col = $this->get_col( $query_params, $field_to_select ); |
| 1550 | 1550 | if( ! empty( $col ) ) { |
| 1551 | 1551 | return reset( $col ); |
| 1552 | - }else{ |
|
| 1552 | + } else{ |
|
| 1553 | 1553 | return NULL; |
| 1554 | 1554 | } |
| 1555 | 1555 | } |
@@ -1676,7 +1676,7 @@ discard block |
||
| 1676 | 1676 | |
| 1677 | 1677 | // /echo "delete sql:$SQL"; |
| 1678 | 1678 | $rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) ); |
| 1679 | - }else{ |
|
| 1679 | + } else{ |
|
| 1680 | 1680 | $rows_deleted = 0; |
| 1681 | 1681 | } |
| 1682 | 1682 | |
@@ -1720,7 +1720,7 @@ discard block |
||
| 1720 | 1720 | //first, if $ignore_this_model_obj was supplied, get its model |
| 1721 | 1721 | if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){ |
| 1722 | 1722 | $ignored_model = $ignore_this_model_obj->get_model(); |
| 1723 | - }else{ |
|
| 1723 | + } else{ |
|
| 1724 | 1724 | $ignored_model = null; |
| 1725 | 1725 | } |
| 1726 | 1726 | //now check all the relations of $this_model_obj_or_id and see if there |
@@ -1733,7 +1733,7 @@ discard block |
||
| 1733 | 1733 | if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){ |
| 1734 | 1734 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array( |
| 1735 | 1735 | array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID())))); |
| 1736 | - }else{ |
|
| 1736 | + } else{ |
|
| 1737 | 1737 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id); |
| 1738 | 1738 | } |
| 1739 | 1739 | |
@@ -1806,7 +1806,7 @@ discard block |
||
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | return !empty($query) ? implode(' AND ', $query ) : ''; |
| 1809 | - }elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
| 1809 | + } elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
| 1810 | 1810 | $ways_to_identify_a_row = array(); |
| 1811 | 1811 | $fields = $this->get_combined_primary_key_fields(); |
| 1812 | 1812 | //note: because there' sno primary key, that means nothing else can be pointing to this model, right? |
@@ -1822,7 +1822,7 @@ discard block |
||
| 1822 | 1822 | $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
| 1823 | 1823 | } |
| 1824 | 1824 | return implode(" OR ",$ways_to_identify_a_row); |
| 1825 | - }else{ |
|
| 1825 | + } else{ |
|
| 1826 | 1826 | //so there's no primary key and no combined key... |
| 1827 | 1827 | //sorry, can't help you |
| 1828 | 1828 | throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this))); |
@@ -1846,10 +1846,10 @@ discard block |
||
| 1846 | 1846 | if($field_to_count){ |
| 1847 | 1847 | $field_obj = $this->field_settings_for($field_to_count); |
| 1848 | 1848 | $column_to_count = $field_obj->get_qualified_column(); |
| 1849 | - }elseif($this->has_primary_key_field ()){ |
|
| 1849 | + } elseif($this->has_primary_key_field ()){ |
|
| 1850 | 1850 | $pk_field_obj = $this->get_primary_key_field(); |
| 1851 | 1851 | $column_to_count = $pk_field_obj->get_qualified_column(); |
| 1852 | - }else{ |
|
| 1852 | + } else{ |
|
| 1853 | 1853 | //there's no primary key |
| 1854 | 1854 | //if we're counting distinct items, and there's no primary key, |
| 1855 | 1855 | //we need to list out the columns for distinction; |
@@ -1887,7 +1887,7 @@ discard block |
||
| 1887 | 1887 | if($field_to_sum){ |
| 1888 | 1888 | $field_obj = $this->field_settings_for($field_to_sum); |
| 1889 | 1889 | |
| 1890 | - }else{ |
|
| 1890 | + } else{ |
|
| 1891 | 1891 | $field_obj = $this->get_primary_key_field(); |
| 1892 | 1892 | } |
| 1893 | 1893 | $column_to_count = $field_obj->get_qualified_column(); |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | $data_type = $field_obj->get_wpdb_data_type(); |
| 1898 | 1898 | if( $data_type === '%d' || $data_type === '%s' ){ |
| 1899 | 1899 | return (float)$return_value; |
| 1900 | - }else{//must be %f |
|
| 1900 | + } else{//must be %f |
|
| 1901 | 1901 | return (float)$return_value; |
| 1902 | 1902 | } |
| 1903 | 1903 | } |
@@ -1935,10 +1935,10 @@ discard block |
||
| 1935 | 1935 | $wpdb->show_errors( $old_show_errors_value ); |
| 1936 | 1936 | if( ! empty( $wpdb->last_error ) ){ |
| 1937 | 1937 | throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) ); |
| 1938 | - }elseif( $result === false ){ |
|
| 1938 | + } elseif( $result === false ){ |
|
| 1939 | 1939 | throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) ); |
| 1940 | 1940 | } |
| 1941 | - }elseif( $result === false ) { |
|
| 1941 | + } elseif( $result === false ) { |
|
| 1942 | 1942 | EE_Error::add_error( |
| 1943 | 1943 | sprintf( |
| 1944 | 1944 | __( 'A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso' ), |
@@ -2280,7 +2280,7 @@ discard block |
||
| 2280 | 2280 | $results = $this->get_all_related($id_or_obj,$other_model_name,$query_params); |
| 2281 | 2281 | if( $results ){ |
| 2282 | 2282 | return array_shift($results); |
| 2283 | - }else{ |
|
| 2283 | + } else{ |
|
| 2284 | 2284 | return null; |
| 2285 | 2285 | } |
| 2286 | 2286 | |
@@ -2351,7 +2351,7 @@ discard block |
||
| 2351 | 2351 | */ |
| 2352 | 2352 | do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id ); |
| 2353 | 2353 | return $new_id; |
| 2354 | - }else{ |
|
| 2354 | + } else{ |
|
| 2355 | 2355 | return FALSE; |
| 2356 | 2356 | } |
| 2357 | 2357 | } |
@@ -2413,9 +2413,9 @@ discard block |
||
| 2413 | 2413 | public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){ |
| 2414 | 2414 | if($obj_or_fields_array instanceof EE_Base_Class){ |
| 2415 | 2415 | $fields_n_values = $obj_or_fields_array->model_field_array(); |
| 2416 | - }elseif( is_array($obj_or_fields_array)){ |
|
| 2416 | + } elseif( is_array($obj_or_fields_array)){ |
|
| 2417 | 2417 | $fields_n_values = $obj_or_fields_array; |
| 2418 | - }else{ |
|
| 2418 | + } else{ |
|
| 2419 | 2419 | throw new EE_Error( |
| 2420 | 2420 | sprintf( |
| 2421 | 2421 | __( |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | //if there is nothing to base this search on, then we shouldn't find anything |
| 2441 | 2441 | if( empty( $query_params ) ){ |
| 2442 | 2442 | return array(); |
| 2443 | - }else{ |
|
| 2443 | + } else{ |
|
| 2444 | 2444 | return $this->get_one($query_params); |
| 2445 | 2445 | } |
| 2446 | 2446 | } |
@@ -2521,12 +2521,12 @@ discard block |
||
| 2521 | 2521 | if($this->has_primary_key_field()){ |
| 2522 | 2522 | if($this->get_primary_key_field()->is_auto_increment()){ |
| 2523 | 2523 | return $wpdb->insert_id; |
| 2524 | - }else{ |
|
| 2524 | + } else{ |
|
| 2525 | 2525 | //it's not an auto-increment primary key, so |
| 2526 | 2526 | //it must have been supplied |
| 2527 | 2527 | return $fields_n_values[$this->get_primary_key_field()->get_name()]; |
| 2528 | 2528 | } |
| 2529 | - }else{ |
|
| 2529 | + } else{ |
|
| 2530 | 2530 | //we can't return a primary key because there is none. instead return |
| 2531 | 2531 | //a unique string indicating this model |
| 2532 | 2532 | return $this->get_index_primary_key_string($fields_n_values); |
@@ -2578,7 +2578,7 @@ discard block |
||
| 2578 | 2578 | //leave the value alone |
| 2579 | 2579 | } |
| 2580 | 2580 | return $value; |
| 2581 | - }else{ |
|
| 2581 | + } else{ |
|
| 2582 | 2582 | return $value; |
| 2583 | 2583 | } |
| 2584 | 2584 | } |
@@ -2747,10 +2747,10 @@ discard block |
||
| 2747 | 2747 | if (! is_array($possibly_array_of_params)){ |
| 2748 | 2748 | throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"), |
| 2749 | 2749 | $param,$possibly_array_of_params)); |
| 2750 | - }else{ |
|
| 2750 | + } else{ |
|
| 2751 | 2751 | $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type); |
| 2752 | 2752 | } |
| 2753 | - }elseif($query_param_type === 0 //ie WHERE |
|
| 2753 | + } elseif($query_param_type === 0 //ie WHERE |
|
| 2754 | 2754 | && is_array($possibly_array_of_params) |
| 2755 | 2755 | && isset($possibly_array_of_params[2]) |
| 2756 | 2756 | && $possibly_array_of_params[2] == true){ |
@@ -3028,7 +3028,7 @@ discard block |
||
| 3028 | 3028 | private function _extract_order($should_be_order_string){ |
| 3029 | 3029 | if(in_array($should_be_order_string, $this->_allowed_order_values)){ |
| 3030 | 3030 | return $should_be_order_string; |
| 3031 | - }else{ |
|
| 3031 | + } else{ |
|
| 3032 | 3032 | throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string)); |
| 3033 | 3033 | } |
| 3034 | 3034 | } |
@@ -3106,7 +3106,7 @@ discard block |
||
| 3106 | 3106 | foreach($default_where_conditions as $key => $val){ |
| 3107 | 3107 | if( isset($provided_where_conditions[$key])){ |
| 3108 | 3108 | $none_overridden = false; |
| 3109 | - }else{ |
|
| 3109 | + } else{ |
|
| 3110 | 3110 | $null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val; |
| 3111 | 3111 | } |
| 3112 | 3112 | } |
@@ -3232,7 +3232,7 @@ discard block |
||
| 3232 | 3232 | if(array_key_exists($query_param,$this_model_fields)){ |
| 3233 | 3233 | if($allow_fields){ |
| 3234 | 3234 | return; |
| 3235 | - }else{ |
|
| 3235 | + } else{ |
|
| 3236 | 3236 | throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"), |
| 3237 | 3237 | $query_param,get_class($this),$query_param_type,$original_query_param)); |
| 3238 | 3238 | } |
@@ -3241,7 +3241,7 @@ discard block |
||
| 3241 | 3241 | elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){ |
| 3242 | 3242 | if($allow_logic_query_params){ |
| 3243 | 3243 | return; |
| 3244 | - }else{ |
|
| 3244 | + } else{ |
|
| 3245 | 3245 | throw new EE_Error( |
| 3246 | 3246 | sprintf( |
| 3247 | 3247 | __( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ), |
@@ -3272,12 +3272,12 @@ discard block |
||
| 3272 | 3272 | //we should actually end in a field name, not a model like this! |
| 3273 | 3273 | throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"), |
| 3274 | 3274 | $query_param,$query_param_type,get_class($this),$valid_related_model_name)); |
| 3275 | - }else{ |
|
| 3275 | + } else{ |
|
| 3276 | 3276 | $related_model_obj = $this->get_related_model_obj($valid_related_model_name); |
| 3277 | 3277 | $related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param); |
| 3278 | 3278 | return; |
| 3279 | 3279 | } |
| 3280 | - }elseif($query_param === $valid_related_model_name){ |
|
| 3280 | + } elseif($query_param === $valid_related_model_name){ |
|
| 3281 | 3281 | $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
| 3282 | 3282 | return; |
| 3283 | 3283 | } |
@@ -3342,7 +3342,7 @@ discard block |
||
| 3342 | 3342 | $SQL = $this->_construct_condition_clause_recursive($where_params, ' AND '); |
| 3343 | 3343 | if($SQL){ |
| 3344 | 3344 | return " WHERE ". $SQL; |
| 3345 | - }else{ |
|
| 3345 | + } else{ |
|
| 3346 | 3346 | return ''; |
| 3347 | 3347 | } |
| 3348 | 3348 | } |
@@ -3361,7 +3361,7 @@ discard block |
||
| 3361 | 3361 | $SQL = $this->_construct_condition_clause_recursive($having_params, ' AND '); |
| 3362 | 3362 | if($SQL){ |
| 3363 | 3363 | return " HAVING ". $SQL; |
| 3364 | - }else{ |
|
| 3364 | + } else{ |
|
| 3365 | 3365 | return ''; |
| 3366 | 3366 | } |
| 3367 | 3367 | |
@@ -3383,7 +3383,7 @@ discard block |
||
| 3383 | 3383 | $model_instance=call_user_func($model_name."::instance"); |
| 3384 | 3384 | /* @var $model_instance EEM_Base */ |
| 3385 | 3385 | return $model_instance->field_settings_for($field_name); |
| 3386 | - }else{ |
|
| 3386 | + } else{ |
|
| 3387 | 3387 | throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath)); |
| 3388 | 3388 | } |
| 3389 | 3389 | } |
@@ -3416,14 +3416,14 @@ discard block |
||
| 3416 | 3416 | $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")"; |
| 3417 | 3417 | break; |
| 3418 | 3418 | } |
| 3419 | - }else{ |
|
| 3419 | + } else{ |
|
| 3420 | 3420 | $field_obj = $this->_deduce_field_from_query_param($query_param); |
| 3421 | 3421 | |
| 3422 | 3422 | //if it's not a normal field, maybe it's a custom selection? |
| 3423 | 3423 | if( ! $field_obj){ |
| 3424 | 3424 | if(isset( $this->_custom_selections[$query_param][1])){ |
| 3425 | 3425 | $field_obj = $this->_custom_selections[$query_param][1]; |
| 3426 | - }else{ |
|
| 3426 | + } else{ |
|
| 3427 | 3427 | throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param)); |
| 3428 | 3428 | } |
| 3429 | 3429 | } |
@@ -3448,11 +3448,11 @@ discard block |
||
| 3448 | 3448 | if( $field ){ |
| 3449 | 3449 | $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param ); |
| 3450 | 3450 | return $table_alias_prefix . $field->get_qualified_column(); |
| 3451 | - }elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
| 3451 | + } elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
| 3452 | 3452 | //maybe it's custom selection item? |
| 3453 | 3453 | //if so, just use it as the "column name" |
| 3454 | 3454 | return $query_param; |
| 3455 | - }else{ |
|
| 3455 | + } else{ |
|
| 3456 | 3456 | throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections))); |
| 3457 | 3457 | } |
| 3458 | 3458 | } |
@@ -3469,7 +3469,7 @@ discard block |
||
| 3469 | 3469 | $pos_of_star = strpos($condition_query_param_key, '*'); |
| 3470 | 3470 | if($pos_of_star === FALSE){ |
| 3471 | 3471 | return $condition_query_param_key; |
| 3472 | - }else{ |
|
| 3472 | + } else{ |
|
| 3473 | 3473 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
| 3474 | 3474 | return $condition_query_param_sans_star; |
| 3475 | 3475 | } |
@@ -3654,7 +3654,7 @@ discard block |
||
| 3654 | 3654 | global $wpdb; |
| 3655 | 3655 | if($field_obj instanceof EE_Model_Field_Base){ |
| 3656 | 3656 | return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj)); |
| 3657 | - }else{//$field_obj should really just be a data type |
|
| 3657 | + } else{//$field_obj should really just be a data type |
|
| 3658 | 3658 | if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){ |
| 3659 | 3659 | throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types))); |
| 3660 | 3660 | } |
@@ -3683,14 +3683,14 @@ discard block |
||
| 3683 | 3683 | if($number_of_parts === 1){ |
| 3684 | 3684 | $field_name = $last_query_param_part; |
| 3685 | 3685 | $model_obj = $this; |
| 3686 | - }else{// $number_of_parts >= 2 |
|
| 3686 | + } else{// $number_of_parts >= 2 |
|
| 3687 | 3687 | //the last part is the column name, and there are only 2parts. therefore... |
| 3688 | 3688 | $field_name = $last_query_param_part; |
| 3689 | 3689 | $model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]); |
| 3690 | 3690 | } |
| 3691 | 3691 | try{ |
| 3692 | 3692 | return $model_obj->field_settings_for($field_name); |
| 3693 | - }catch(EE_Error $e){ |
|
| 3693 | + } catch(EE_Error $e){ |
|
| 3694 | 3694 | return null; |
| 3695 | 3695 | } |
| 3696 | 3696 | } |
@@ -3709,7 +3709,7 @@ discard block |
||
| 3709 | 3709 | $field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE; |
| 3710 | 3710 | if($field){ |
| 3711 | 3711 | return $field->get_qualified_column(); |
| 3712 | - }else{ |
|
| 3712 | + } else{ |
|
| 3713 | 3713 | throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this))); |
| 3714 | 3714 | } |
| 3715 | 3715 | } |
@@ -3780,7 +3780,7 @@ discard block |
||
| 3780 | 3780 | //the FROM statement, BUT the primary table isn't. So we want |
| 3781 | 3781 | //to add the inverse join sql |
| 3782 | 3782 | $SQL .= $table_obj->get_inverse_join_sql($alias_prefixed); |
| 3783 | - }else{ |
|
| 3783 | + } else{ |
|
| 3784 | 3784 | //just add a regular JOIN to this table from the primary table |
| 3785 | 3785 | $SQL .= $table_obj->get_join_sql($alias_prefixed); |
| 3786 | 3786 | } |
@@ -3893,7 +3893,7 @@ discard block |
||
| 3893 | 3893 | $fieldSettings = $this->field_settings(true); |
| 3894 | 3894 | if( isset($fieldSettings[$fieldName])){ |
| 3895 | 3895 | return true; |
| 3896 | - }else{ |
|
| 3896 | + } else{ |
|
| 3897 | 3897 | return false; |
| 3898 | 3898 | } |
| 3899 | 3899 | } |
@@ -3907,7 +3907,7 @@ discard block |
||
| 3907 | 3907 | $relations = $this->relation_settings(); |
| 3908 | 3908 | if(isset($relations[$relation_name])){ |
| 3909 | 3909 | return true; |
| 3910 | - }else{ |
|
| 3910 | + } else{ |
|
| 3911 | 3911 | return false; |
| 3912 | 3912 | } |
| 3913 | 3913 | } |
@@ -3958,7 +3958,7 @@ discard block |
||
| 3958 | 3958 | try{ |
| 3959 | 3959 | $this->get_primary_key_field(); |
| 3960 | 3960 | $this->_has_primary_key_field = true; |
| 3961 | - }catch(EE_Error $e){ |
|
| 3961 | + } catch(EE_Error $e){ |
|
| 3962 | 3962 | $this->_has_primary_key_field = false; |
| 3963 | 3963 | } |
| 3964 | 3964 | } |
@@ -4038,7 +4038,7 @@ discard block |
||
| 4038 | 4038 | } |
| 4039 | 4039 | } |
| 4040 | 4040 | return $this->_cached_fields; |
| 4041 | - }else{ |
|
| 4041 | + } else{ |
|
| 4042 | 4042 | if( $this->_cached_fields_non_db_only === NULL ){ |
| 4043 | 4043 | $this->_cached_fields_non_db_only = array(); |
| 4044 | 4044 | foreach($this->_fields as $fields_corresponding_to_table){ |
@@ -4174,7 +4174,7 @@ discard block |
||
| 4174 | 4174 | if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){ |
| 4175 | 4175 | return NULL; |
| 4176 | 4176 | } |
| 4177 | - }else if($this->unique_indexes()){ |
|
| 4177 | + } else if($this->unique_indexes()){ |
|
| 4178 | 4178 | $first_column = reset($this_model_fields_n_values); |
| 4179 | 4179 | if(empty($first_column)){ |
| 4180 | 4180 | return NULL; |
@@ -4189,7 +4189,7 @@ discard block |
||
| 4189 | 4189 | // add this new object to the entity map |
| 4190 | 4190 | $classInstance = $this->add_to_entity_map( $classInstance ); |
| 4191 | 4191 | } |
| 4192 | - }else{ |
|
| 4192 | + } else{ |
|
| 4193 | 4193 | $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
| 4194 | 4194 | } |
| 4195 | 4195 | |
@@ -4302,7 +4302,7 @@ discard block |
||
| 4302 | 4302 | $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value ); |
| 4303 | 4303 | } |
| 4304 | 4304 | } |
| 4305 | - }else{ |
|
| 4305 | + } else{ |
|
| 4306 | 4306 | //the table's rows existed. Use their values |
| 4307 | 4307 | foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
| 4308 | 4308 | if( ! $field_obj->is_db_only_field() ){ |
@@ -4332,7 +4332,7 @@ discard block |
||
| 4332 | 4332 | //or is it a db-only field? (not relating to the model) |
| 4333 | 4333 | if( isset( $cols_n_values[ $qualified_column ] ) ){ |
| 4334 | 4334 | $value = $cols_n_values[ $qualified_column ]; |
| 4335 | - }elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
| 4335 | + } elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
| 4336 | 4336 | $value = $cols_n_values[ $regular_column ]; |
| 4337 | 4337 | } |
| 4338 | 4338 | return $value; |
@@ -4366,7 +4366,7 @@ discard block |
||
| 4366 | 4366 | } |
| 4367 | 4367 | } |
| 4368 | 4368 | return $obj_in_map; |
| 4369 | - }else{ |
|
| 4369 | + } else{ |
|
| 4370 | 4370 | return $this->get_one_by_ID( $id ); |
| 4371 | 4371 | } |
| 4372 | 4372 | } |
@@ -4401,7 +4401,7 @@ discard block |
||
| 4401 | 4401 | } |
| 4402 | 4402 | } |
| 4403 | 4403 | return $obj_in_map; |
| 4404 | - }else{ |
|
| 4404 | + } else{ |
|
| 4405 | 4405 | $this->add_to_entity_map( $replacing_model_obj ); |
| 4406 | 4406 | return $replacing_model_obj; |
| 4407 | 4407 | } |
@@ -4546,13 +4546,13 @@ discard block |
||
| 4546 | 4546 | if( $base_class_obj_or_id instanceof $className ){ |
| 4547 | 4547 | /** @var $base_class_obj_or_id EE_Base_Class */ |
| 4548 | 4548 | $id = $base_class_obj_or_id->ID(); |
| 4549 | - }elseif(is_int($base_class_obj_or_id)){ |
|
| 4549 | + } elseif(is_int($base_class_obj_or_id)){ |
|
| 4550 | 4550 | //assume it's an ID |
| 4551 | 4551 | $id = $base_class_obj_or_id; |
| 4552 | - }elseif(is_string($base_class_obj_or_id)){ |
|
| 4552 | + } elseif(is_string($base_class_obj_or_id)){ |
|
| 4553 | 4553 | //assume its a string representation of the object |
| 4554 | 4554 | $id = $base_class_obj_or_id; |
| 4555 | - }else{ |
|
| 4555 | + } else{ |
|
| 4556 | 4556 | throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
| 4557 | 4557 | } |
| 4558 | 4558 | return $id; |
@@ -4700,9 +4700,9 @@ discard block |
||
| 4700 | 4700 | |
| 4701 | 4701 | if($model_object_or_attributes_array instanceof EE_Base_Class){ |
| 4702 | 4702 | $attributes_array = $model_object_or_attributes_array->model_field_array(); |
| 4703 | - }elseif(is_array($model_object_or_attributes_array)){ |
|
| 4703 | + } elseif(is_array($model_object_or_attributes_array)){ |
|
| 4704 | 4704 | $attributes_array = $model_object_or_attributes_array; |
| 4705 | - }else{ |
|
| 4705 | + } else{ |
|
| 4706 | 4706 | throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array)); |
| 4707 | 4707 | } |
| 4708 | 4708 | //even copies obviously won't have the same ID, so remove the primary key |
@@ -4712,7 +4712,7 @@ discard block |
||
| 4712 | 4712 | } |
| 4713 | 4713 | if(isset($query_params[0])){ |
| 4714 | 4714 | $query_params[0] = array_merge($attributes_array,$query_params); |
| 4715 | - }else{ |
|
| 4715 | + } else{ |
|
| 4716 | 4716 | $query_params[0] = $attributes_array; |
| 4717 | 4717 | } |
| 4718 | 4718 | return $this->get_all($query_params); |
@@ -4737,7 +4737,7 @@ discard block |
||
| 4737 | 4737 | $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
| 4738 | 4738 | if(is_array($copies)){ |
| 4739 | 4739 | return array_shift($copies); |
| 4740 | - }else{ |
|
| 4740 | + } else{ |
|
| 4741 | 4741 | return null; |
| 4742 | 4742 | } |
| 4743 | 4743 | } |
@@ -4771,7 +4771,7 @@ discard block |
||
| 4771 | 4771 | $sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null; |
| 4772 | 4772 | if($sql_operator){ |
| 4773 | 4773 | return $sql_operator; |
| 4774 | - }else{ |
|
| 4774 | + } else{ |
|
| 4775 | 4775 | throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators)))); |
| 4776 | 4776 | } |
| 4777 | 4777 | } |
@@ -4976,7 +4976,7 @@ discard block |
||
| 4976 | 4976 | $valid_cap_contexts = EEM_Base::valid_cap_contexts(); |
| 4977 | 4977 | if( in_array( $context, $valid_cap_contexts ) ) { |
| 4978 | 4978 | return true; |
| 4979 | - }else{ |
|
| 4979 | + } else{ |
|
| 4980 | 4980 | throw new EE_Error( |
| 4981 | 4981 | sprintf( |
| 4982 | 4982 | __( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ), |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @since EE4 |
| 24 | 24 | * |
| 25 | 25 | */ |
| 26 | -abstract class EEM_Base extends EE_Base{ |
|
| 26 | +abstract class EEM_Base extends EE_Base { |
|
| 27 | 27 | |
| 28 | 28 | //admin posty |
| 29 | 29 | //basic -> grants access to mine -> if they don't have it, select none |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * Flag indicating whether this model has a primary key or not |
| 244 | 244 | * @var boolean |
| 245 | 245 | */ |
| 246 | - protected $_has_primary_key_field=null; |
|
| 246 | + protected $_has_primary_key_field = null; |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * Whether or not this model is based off a table in WP core only (CPTs should set |
@@ -305,19 +305,19 @@ discard block |
||
| 305 | 305 | * operators that work like 'BETWEEN'. Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'" |
| 306 | 306 | * @var array |
| 307 | 307 | */ |
| 308 | - protected $_between_style_operators = array( 'BETWEEN' ); |
|
| 308 | + protected $_between_style_operators = array('BETWEEN'); |
|
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | 311 | * operators that are used for handling NUll and !NULL queries. Typically used for when checking if a row exists on a join table. |
| 312 | 312 | * @var array |
| 313 | 313 | */ |
| 314 | - protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL'); |
|
| 314 | + protected $_null_style_operators = array('IS NOT NULL', 'IS NULL'); |
|
| 315 | 315 | |
| 316 | 316 | /** |
| 317 | 317 | * Allowed values for $query_params['order'] for ordering in queries |
| 318 | 318 | * @var array |
| 319 | 319 | */ |
| 320 | - protected $_allowed_order_values = array('asc','desc','ASC','DESC'); |
|
| 320 | + protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC'); |
|
| 321 | 321 | |
| 322 | 322 | /** |
| 323 | 323 | * When these are keys in a WHERE or HAVING clause, they are handled much differently |
@@ -331,13 +331,13 @@ discard block |
||
| 331 | 331 | * 'where', but 'where' clauses are so common that we thought we'd omit it |
| 332 | 332 | * @var array |
| 333 | 333 | */ |
| 334 | - private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps'); |
|
| 334 | + private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps'); |
|
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * All the data types that can be used in $wpdb->prepare statements. |
| 338 | 338 | * @var array |
| 339 | 339 | */ |
| 340 | - private $_valid_wpdb_data_types = array('%d','%s','%f'); |
|
| 340 | + private $_valid_wpdb_data_types = array('%d', '%s', '%f'); |
|
| 341 | 341 | |
| 342 | 342 | /** |
| 343 | 343 | * EE_Registry Object |
@@ -370,17 +370,17 @@ discard block |
||
| 370 | 370 | /** |
| 371 | 371 | * constant used to show EEM_Base has not yet verified the db on this http request |
| 372 | 372 | */ |
| 373 | - const db_verified_none = 0; |
|
| 373 | + const db_verified_none = 0; |
|
| 374 | 374 | /** |
| 375 | 375 | * constant used to show EEM_Base has verified the EE core db on this http request, |
| 376 | 376 | * but not the addons' dbs |
| 377 | 377 | */ |
| 378 | - const db_verified_core = 1; |
|
| 378 | + const db_verified_core = 1; |
|
| 379 | 379 | /** |
| 380 | 380 | * constant used to show EEM_Base has verified the addons' dbs (and implicitly |
| 381 | 381 | * the EE core db too) |
| 382 | 382 | */ |
| 383 | - const db_verified_addons = 2; |
|
| 383 | + const db_verified_addons = 2; |
|
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | 386 | * indicates whether an EEM_Base child has already re-verified the DB |
@@ -411,13 +411,13 @@ discard block |
||
| 411 | 411 | * @param null $timezone |
| 412 | 412 | * @throws \EE_Error |
| 413 | 413 | */ |
| 414 | - protected function __construct( $timezone = NULL ){ |
|
| 414 | + protected function __construct($timezone = NULL) { |
|
| 415 | 415 | // check that the model has not been loaded too soon |
| 416 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) { |
|
| 417 | - throw new EE_Error ( |
|
| 416 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons')) { |
|
| 417 | + throw new EE_Error( |
|
| 418 | 418 | sprintf( |
| 419 | - __( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ), |
|
| 420 | - get_class( $this ) |
|
| 419 | + __('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'), |
|
| 420 | + get_class($this) |
|
| 421 | 421 | ) |
| 422 | 422 | ); |
| 423 | 423 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | /** |
| 426 | 426 | * Set blogid for models to current blog. However we ONLY do this if $_model_query_blog_id is not already set. |
| 427 | 427 | */ |
| 428 | - if ( empty( EEM_Base::$_model_query_blog_id ) ) { |
|
| 428 | + if (empty(EEM_Base::$_model_query_blog_id)) { |
|
| 429 | 429 | EEM_Base::set_model_query_blog_id(); |
| 430 | 430 | } |
| 431 | 431 | |
@@ -434,11 +434,11 @@ discard block |
||
| 434 | 434 | * just use EE_Register_Model_Extension |
| 435 | 435 | * @var EE_Table_Base[] $_tables |
| 436 | 436 | */ |
| 437 | - $this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables ); |
|
| 438 | - foreach($this->_tables as $table_alias => $table_obj){ |
|
| 437 | + $this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables); |
|
| 438 | + foreach ($this->_tables as $table_alias => $table_obj) { |
|
| 439 | 439 | /** @var $table_obj EE_Table_Base */ |
| 440 | 440 | $table_obj->_construct_finalize_with_alias($table_alias); |
| 441 | - if( $table_obj instanceof EE_Secondary_Table ){ |
|
| 441 | + if ($table_obj instanceof EE_Secondary_Table) { |
|
| 442 | 442 | /** @var $table_obj EE_Secondary_Table */ |
| 443 | 443 | $table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table()); |
| 444 | 444 | } |
@@ -448,54 +448,54 @@ discard block |
||
| 448 | 448 | * EE_Register_Model_Extension |
| 449 | 449 | * @param EE_Model_Field_Base[] $_fields |
| 450 | 450 | */ |
| 451 | - $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields); |
|
| 451 | + $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields); |
|
| 452 | 452 | $this->_invalidate_field_caches(); |
| 453 | - foreach($this->_fields as $table_alias => $fields_for_table){ |
|
| 454 | - if ( ! array_key_exists( $table_alias, $this->_tables )){ |
|
| 455 | - throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields))); |
|
| 453 | + foreach ($this->_fields as $table_alias => $fields_for_table) { |
|
| 454 | + if ( ! array_key_exists($table_alias, $this->_tables)) { |
|
| 455 | + throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields))); |
|
| 456 | 456 | } |
| 457 | - foreach($fields_for_table as $field_name => $field_obj){ |
|
| 457 | + foreach ($fields_for_table as $field_name => $field_obj) { |
|
| 458 | 458 | /** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */ |
| 459 | 459 | //primary key field base has a slightly different _construct_finalize |
| 460 | 460 | /** @var $field_obj EE_Model_Field_Base */ |
| 461 | - $field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() ); |
|
| 461 | + $field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name()); |
|
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // everything is related to Extra_Meta |
| 466 | - if( get_class($this) !== 'EEM_Extra_Meta'){ |
|
| 466 | + if (get_class($this) !== 'EEM_Extra_Meta') { |
|
| 467 | 467 | //make extra meta related to everything, but don't block deleting things just |
| 468 | 468 | //because they have related extra meta info. For now just orphan those extra meta |
| 469 | 469 | //in the future we should automatically delete them |
| 470 | - $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE ); |
|
| 470 | + $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE); |
|
| 471 | 471 | } |
| 472 | 472 | //and change logs |
| 473 | - if( get_class( $this) !== 'EEM_Change_Log' ) { |
|
| 474 | - $this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE ); |
|
| 473 | + if (get_class($this) !== 'EEM_Change_Log') { |
|
| 474 | + $this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE); |
|
| 475 | 475 | } |
| 476 | 476 | /** |
| 477 | 477 | * Filters the list of relations on a model. It is best to NOT use this directly and instead just use |
| 478 | 478 | * EE_Register_Model_Extension |
| 479 | 479 | * @param EE_Model_Relation_Base[] $_model_relations |
| 480 | 480 | */ |
| 481 | - $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations); |
|
| 482 | - foreach($this->_model_relations as $model_name => $relation_obj){ |
|
| 481 | + $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations); |
|
| 482 | + foreach ($this->_model_relations as $model_name => $relation_obj) { |
|
| 483 | 483 | /** @var $relation_obj EE_Model_Relation_Base */ |
| 484 | 484 | $relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name); |
| 485 | 485 | } |
| 486 | - foreach($this->_indexes as $index_name => $index_obj){ |
|
| 486 | + foreach ($this->_indexes as $index_name => $index_obj) { |
|
| 487 | 487 | /** @var $index_obj EE_Index */ |
| 488 | 488 | $index_obj->_construct_finalize($index_name, $this->get_this_model_name()); |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | $this->set_timezone($timezone); |
| 492 | 492 | //finalize default where condition strategy, or set default |
| 493 | - if( ! $this->_default_where_conditions_strategy){ |
|
| 493 | + if ( ! $this->_default_where_conditions_strategy) { |
|
| 494 | 494 | //nothing was set during child constructor, so set default |
| 495 | 495 | $this->_default_where_conditions_strategy = new EE_Default_Where_Conditions(); |
| 496 | 496 | } |
| 497 | 497 | $this->_default_where_conditions_strategy->_finalize_construct($this); |
| 498 | - if( ! $this->_minimum_where_conditions_strategy){ |
|
| 498 | + if ( ! $this->_minimum_where_conditions_strategy) { |
|
| 499 | 499 | //nothing was set during child constructor, so set default |
| 500 | 500 | $this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions(); |
| 501 | 501 | } |
@@ -503,14 +503,14 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | //if the cap slug hasn't been set, and we haven't set it to false on purpose |
| 505 | 505 | //to indicate to NOT set it, set it to the logical default |
| 506 | - if( $this->_caps_slug === null ) { |
|
| 507 | - $this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() ); |
|
| 506 | + if ($this->_caps_slug === null) { |
|
| 507 | + $this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name()); |
|
| 508 | 508 | } |
| 509 | 509 | //initialize the standard cap restriction generators if none were specified by the child constructor |
| 510 | - if( $this->_cap_restriction_generators !== false ){ |
|
| 511 | - foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){ |
|
| 512 | - if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) { |
|
| 513 | - $this->_cap_restriction_generators[ $cap_context ] = apply_filters( |
|
| 510 | + if ($this->_cap_restriction_generators !== false) { |
|
| 511 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
| 512 | + if ( ! isset($this->_cap_restriction_generators[$cap_context])) { |
|
| 513 | + $this->_cap_restriction_generators[$cap_context] = apply_filters( |
|
| 514 | 514 | 'FHEE__EEM_Base___construct__standard_cap_restriction_generator', |
| 515 | 515 | new EE_Restriction_Generator_Protected(), |
| 516 | 516 | $cap_context, |
@@ -520,23 +520,23 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | //if there are cap restriction generators, use them to make the default cap restrictions |
| 523 | - if( $this->_cap_restriction_generators !== false ){ |
|
| 524 | - foreach( $this->_cap_restriction_generators as $context => $generator_object ) { |
|
| 525 | - if( ! $generator_object ){ |
|
| 523 | + if ($this->_cap_restriction_generators !== false) { |
|
| 524 | + foreach ($this->_cap_restriction_generators as $context => $generator_object) { |
|
| 525 | + if ( ! $generator_object) { |
|
| 526 | 526 | continue; |
| 527 | 527 | } |
| 528 | - if( ! $generator_object instanceof EE_Restriction_Generator_Base ){ |
|
| 528 | + if ( ! $generator_object instanceof EE_Restriction_Generator_Base) { |
|
| 529 | 529 | throw new EE_Error( |
| 530 | 530 | sprintf( |
| 531 | - __( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ), |
|
| 531 | + __('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'), |
|
| 532 | 532 | $context, |
| 533 | 533 | $this->get_this_model_name() |
| 534 | 534 | ) |
| 535 | 535 | ); |
| 536 | 536 | } |
| 537 | - $action = $this->cap_action_for_context( $context ); |
|
| 538 | - if( ! $generator_object->construction_finalized() ){ |
|
| 539 | - $generator_object->_construct_finalize( $this, $action ); |
|
| 537 | + $action = $this->cap_action_for_context($context); |
|
| 538 | + if ( ! $generator_object->construction_finalized()) { |
|
| 539 | + $generator_object->_construct_finalize($this, $action); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | } |
@@ -550,11 +550,11 @@ discard block |
||
| 550 | 550 | * @param string $context one of EEM_Base::valid_cap_contexts() |
| 551 | 551 | * @return EE_Default_Where_Conditions[] |
| 552 | 552 | */ |
| 553 | - protected function _generate_cap_restrictions( $context ){ |
|
| 554 | - if( isset( $this->_cap_restriction_generators[ $context ] ) && |
|
| 555 | - $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) { |
|
| 556 | - return $this->_cap_restriction_generators[ $context ]->generate_restrictions(); |
|
| 557 | - }else{ |
|
| 553 | + protected function _generate_cap_restrictions($context) { |
|
| 554 | + if (isset($this->_cap_restriction_generators[$context]) && |
|
| 555 | + $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) { |
|
| 556 | + return $this->_cap_restriction_generators[$context]->generate_restrictions(); |
|
| 557 | + } else { |
|
| 558 | 558 | return array(); |
| 559 | 559 | } |
| 560 | 560 | } |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * @param int $blog_id If provided then will set the blog_id for the models to this id. If not provided then the |
| 567 | 567 | * value for get_current_blog_id() will be used. |
| 568 | 568 | */ |
| 569 | - public static function set_model_query_blog_id( $blog_id = 0 ) { |
|
| 569 | + public static function set_model_query_blog_id($blog_id = 0) { |
|
| 570 | 570 | EEM_Base::$_model_query_blog_id = $blog_id > 0 ? (int) $blog_id : get_current_blog_id(); |
| 571 | 571 | } |
| 572 | 572 | |
@@ -591,16 +591,16 @@ discard block |
||
| 591 | 591 | * @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) |
| 592 | 592 | * @return static (as in the concrete child class) |
| 593 | 593 | */ |
| 594 | - public static function instance( $timezone = NULL ){ |
|
| 594 | + public static function instance($timezone = NULL) { |
|
| 595 | 595 | |
| 596 | 596 | // check if instance of Espresso_model already exists |
| 597 | 597 | if ( ! static::$_instance instanceof static) { |
| 598 | 598 | // instantiate Espresso_model |
| 599 | - static::$_instance = new static( $timezone ); |
|
| 599 | + static::$_instance = new static($timezone); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | //we might have a timezone set, let set_timezone decide what to do with it |
| 603 | - static::$_instance->set_timezone( $timezone ); |
|
| 603 | + static::$_instance->set_timezone($timezone); |
|
| 604 | 604 | |
| 605 | 605 | // Espresso_model object |
| 606 | 606 | return static::$_instance; |
@@ -614,24 +614,24 @@ discard block |
||
| 614 | 614 | * @return EEM_Base|null (if the model was already instantiated, returns it, with |
| 615 | 615 | * all its properties reset; if it wasn't instantiated, returns null) |
| 616 | 616 | */ |
| 617 | - public static function reset( $timezone = NULL ){ |
|
| 618 | - if ( static::$_instance instanceof EEM_Base ) { |
|
| 617 | + public static function reset($timezone = NULL) { |
|
| 618 | + if (static::$_instance instanceof EEM_Base) { |
|
| 619 | 619 | //let's try to NOT swap out the current instance for a new one |
| 620 | 620 | //because if someone has a reference to it, we can't remove their reference |
| 621 | 621 | //so it's best to keep using the same reference, but change the original object |
| 622 | 622 | //reset all its properties to their original values as defined in the class |
| 623 | - $r = new ReflectionClass( get_class( static::$_instance ) ); |
|
| 623 | + $r = new ReflectionClass(get_class(static::$_instance)); |
|
| 624 | 624 | $static_properties = $r->getStaticProperties(); |
| 625 | - foreach( $r->getDefaultProperties() as $property => $value ) { |
|
| 625 | + foreach ($r->getDefaultProperties() as $property => $value) { |
|
| 626 | 626 | //don't set instance to null like it was originally, |
| 627 | 627 | //but it's static anyways, and we're ignoring static properties (for now at least) |
| 628 | - if( ! isset( $static_properties[ $property ] ) ) { |
|
| 628 | + if ( ! isset($static_properties[$property])) { |
|
| 629 | 629 | static::$_instance->{$property} = $value; |
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | //and then directly call its constructor again, like we would if we |
| 633 | 633 | //were creating a new one |
| 634 | - static::$_instance->__construct( $timezone ); |
|
| 634 | + static::$_instance->__construct($timezone); |
|
| 635 | 635 | return self::instance(); |
| 636 | 636 | } |
| 637 | 637 | return null; |
@@ -646,19 +646,19 @@ discard block |
||
| 646 | 646 | * @return array |
| 647 | 647 | * @throws \EE_Error |
| 648 | 648 | */ |
| 649 | - public function status_array( $translated = FALSE ) { |
|
| 650 | - if ( ! array_key_exists( 'Status', $this->_model_relations ) ) { |
|
| 649 | + public function status_array($translated = FALSE) { |
|
| 650 | + if ( ! array_key_exists('Status', $this->_model_relations)) { |
|
| 651 | 651 | return array(); |
| 652 | 652 | } |
| 653 | 653 | $model_name = $this->get_this_model_name(); |
| 654 | - $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) ); |
|
| 655 | - $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) ); |
|
| 654 | + $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name))); |
|
| 655 | + $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type))); |
|
| 656 | 656 | $status_array = array(); |
| 657 | - foreach ( $stati as $status ) { |
|
| 658 | - $status_array[ $status->ID() ] = $status->get( 'STS_code' ); |
|
| 657 | + foreach ($stati as $status) { |
|
| 658 | + $status_array[$status->ID()] = $status->get('STS_code'); |
|
| 659 | 659 | } |
| 660 | 660 | return $translated |
| 661 | - ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' ) |
|
| 661 | + ? EEM_Status::instance()->localized_status($status_array, false, 'sentence') |
|
| 662 | 662 | : $status_array; |
| 663 | 663 | } |
| 664 | 664 | |
@@ -791,10 +791,10 @@ discard block |
||
| 791 | 791 | * )); |
| 792 | 792 | * @throws \EE_Error |
| 793 | 793 | */ |
| 794 | - public function get_all($query_params = array()){ |
|
| 795 | - if( isset( $query_params[ 'limit' ] ) |
|
| 796 | - && ! isset( $query_params[ 'group_by' ] ) ) { |
|
| 797 | - $query_params[ 'group_by' ] = array_keys( $this->get_combined_primary_key_fields() ); |
|
| 794 | + public function get_all($query_params = array()) { |
|
| 795 | + if (isset($query_params['limit']) |
|
| 796 | + && ! isset($query_params['group_by'])) { |
|
| 797 | + $query_params['group_by'] = array_keys($this->get_combined_primary_key_fields()); |
|
| 798 | 798 | } |
| 799 | 799 | return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL)); |
| 800 | 800 | } |
@@ -805,10 +805,10 @@ discard block |
||
| 805 | 805 | * @param array $query_params @see EEM_Base::get_all() |
| 806 | 806 | * @return array like EEM_Base::get_all |
| 807 | 807 | */ |
| 808 | - public function alter_query_params_to_only_include_mine( $query_params = array() ) { |
|
| 808 | + public function alter_query_params_to_only_include_mine($query_params = array()) { |
|
| 809 | 809 | $wp_user_field_name = $this->wp_user_field_name(); |
| 810 | - if( $wp_user_field_name ){ |
|
| 811 | - $query_params[0][ $wp_user_field_name ] = get_current_user_id(); |
|
| 810 | + if ($wp_user_field_name) { |
|
| 811 | + $query_params[0][$wp_user_field_name] = get_current_user_id(); |
|
| 812 | 812 | } |
| 813 | 813 | return $query_params; |
| 814 | 814 | } |
@@ -821,19 +821,19 @@ discard block |
||
| 821 | 821 | * foreign key to the WP_User table |
| 822 | 822 | */ |
| 823 | 823 | public function wp_user_field_name() { |
| 824 | - try{ |
|
| 825 | - if( ! empty( $this->_model_chain_to_wp_user ) ) { |
|
| 826 | - $models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user ); |
|
| 827 | - $last_model_name = end( $models_to_follow_to_wp_users ); |
|
| 828 | - $model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name ); |
|
| 829 | - $model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.'; |
|
| 830 | - }else{ |
|
| 824 | + try { |
|
| 825 | + if ( ! empty($this->_model_chain_to_wp_user)) { |
|
| 826 | + $models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user); |
|
| 827 | + $last_model_name = end($models_to_follow_to_wp_users); |
|
| 828 | + $model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name); |
|
| 829 | + $model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.'; |
|
| 830 | + } else { |
|
| 831 | 831 | $model_with_fk_to_wp_users = $this; |
| 832 | 832 | $model_chain_to_wp_user = ''; |
| 833 | 833 | } |
| 834 | - $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' ); |
|
| 835 | - return $model_chain_to_wp_user . $wp_user_field->get_name(); |
|
| 836 | - }catch( EE_Error $e ) { |
|
| 834 | + $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User'); |
|
| 835 | + return $model_chain_to_wp_user.$wp_user_field->get_name(); |
|
| 836 | + } catch (EE_Error $e) { |
|
| 837 | 837 | return false; |
| 838 | 838 | } |
| 839 | 839 | } |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | * (or transiently-related model) |
| 848 | 848 | * @return string |
| 849 | 849 | */ |
| 850 | - public function model_chain_to_wp_user(){ |
|
| 850 | + public function model_chain_to_wp_user() { |
|
| 851 | 851 | return $this->_model_chain_to_wp_user; |
| 852 | 852 | } |
| 853 | 853 | |
@@ -859,13 +859,13 @@ discard block |
||
| 859 | 859 | * @return boolean |
| 860 | 860 | */ |
| 861 | 861 | public function is_owned() { |
| 862 | - if( $this->model_chain_to_wp_user() ){ |
|
| 862 | + if ($this->model_chain_to_wp_user()) { |
|
| 863 | 863 | return true; |
| 864 | - }else{ |
|
| 865 | - try{ |
|
| 866 | - $this->get_foreign_key_to( 'WP_User' ); |
|
| 864 | + } else { |
|
| 865 | + try { |
|
| 866 | + $this->get_foreign_key_to('WP_User'); |
|
| 867 | 867 | return true; |
| 868 | - }catch( EE_Error $e ){ |
|
| 868 | + } catch (EE_Error $e) { |
|
| 869 | 869 | return false; |
| 870 | 870 | } |
| 871 | 871 | } |
@@ -887,17 +887,17 @@ discard block |
||
| 887 | 887 | * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
| 888 | 888 | * @throws \EE_Error |
| 889 | 889 | */ |
| 890 | - protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
| 890 | + protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
| 891 | 891 | // remember the custom selections, if any, and type cast as array |
| 892 | 892 | // (unless $columns_to_select is an object, then just set as an empty array) |
| 893 | 893 | // Note: (array) 'some string' === array( 'some string' ) |
| 894 | - $this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array(); |
|
| 895 | - $model_query_info = $this->_create_model_query_info_carrier( $query_params ); |
|
| 894 | + $this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array(); |
|
| 895 | + $model_query_info = $this->_create_model_query_info_carrier($query_params); |
|
| 896 | 896 | $select_expressions = $columns_to_select !== null |
| 897 | - ? $this->_construct_select_from_input( $columns_to_select ) |
|
| 898 | - : $this->_construct_default_select_sql( $model_query_info ); |
|
| 899 | - $SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info ); |
|
| 900 | - return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) ); |
|
| 897 | + ? $this->_construct_select_from_input($columns_to_select) |
|
| 898 | + : $this->_construct_default_select_sql($model_query_info); |
|
| 899 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
| 900 | + return $this->_do_wpdb_query('get_results', array($SQL, $output)); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
| 916 | 916 | * @throws \EE_Error |
| 917 | 917 | */ |
| 918 | - public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
| 918 | + public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
| 919 | 919 | return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select); |
| 920 | 920 | } |
| 921 | 921 | |
@@ -927,12 +927,12 @@ discard block |
||
| 927 | 927 | * @throws EE_Error |
| 928 | 928 | * @return string |
| 929 | 929 | */ |
| 930 | - private function _construct_select_from_input($columns_to_select){ |
|
| 931 | - if(is_array($columns_to_select)){ |
|
| 930 | + private function _construct_select_from_input($columns_to_select) { |
|
| 931 | + if (is_array($columns_to_select)) { |
|
| 932 | 932 | $select_sql_array = array(); |
| 933 | 933 | |
| 934 | - foreach($columns_to_select as $alias => $selection_and_datatype){ |
|
| 935 | - if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){ |
|
| 934 | + foreach ($columns_to_select as $alias => $selection_and_datatype) { |
|
| 935 | + if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) { |
|
| 936 | 936 | throw new EE_Error( |
| 937 | 937 | sprintf( |
| 938 | 938 | __( |
@@ -944,24 +944,24 @@ discard block |
||
| 944 | 944 | ) |
| 945 | 945 | ); |
| 946 | 946 | } |
| 947 | - if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){ |
|
| 947 | + if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) { |
|
| 948 | 948 | throw new EE_Error( |
| 949 | 949 | sprintf( |
| 950 | 950 | __( |
| 951 | 951 | "Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", |
| 952 | 952 | "event_espresso" |
| 953 | 953 | ), |
| 954 | - $selection_and_datatype[ 1 ], |
|
| 955 | - $selection_and_datatype[ 0 ], |
|
| 954 | + $selection_and_datatype[1], |
|
| 955 | + $selection_and_datatype[0], |
|
| 956 | 956 | $alias, |
| 957 | - implode( ",", $this->_valid_wpdb_data_types ) |
|
| 957 | + implode(",", $this->_valid_wpdb_data_types) |
|
| 958 | 958 | ) |
| 959 | 959 | ); |
| 960 | 960 | } |
| 961 | 961 | $select_sql_array[] = "{$selection_and_datatype[0]} AS $alias"; |
| 962 | 962 | } |
| 963 | - $columns_to_select_string = implode(", ",$select_sql_array); |
|
| 964 | - }else{ |
|
| 963 | + $columns_to_select_string = implode(", ", $select_sql_array); |
|
| 964 | + } else { |
|
| 965 | 965 | $columns_to_select_string = $columns_to_select; |
| 966 | 966 | } |
| 967 | 967 | return $columns_to_select_string; |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | * @return string |
| 977 | 977 | * @throws \EE_Error |
| 978 | 978 | */ |
| 979 | - public function primary_key_name(){ |
|
| 979 | + public function primary_key_name() { |
|
| 980 | 980 | return $this->get_primary_key_field()->get_name(); |
| 981 | 981 | } |
| 982 | 982 | |
@@ -988,14 +988,14 @@ discard block |
||
| 988 | 988 | * @param mixed $id int or string, depending on the type of the model's primary key |
| 989 | 989 | * @return EE_Base_Class |
| 990 | 990 | */ |
| 991 | - public function get_one_by_ID($id){ |
|
| 992 | - if( $this->get_from_entity_map( $id ) ){ |
|
| 993 | - return $this->get_from_entity_map( $id ); |
|
| 991 | + public function get_one_by_ID($id) { |
|
| 992 | + if ($this->get_from_entity_map($id)) { |
|
| 993 | + return $this->get_from_entity_map($id); |
|
| 994 | 994 | } |
| 995 | 995 | return $this->get_one( |
| 996 | 996 | $this->alter_query_params_to_restrict_by_ID( |
| 997 | 997 | $id, |
| 998 | - array( 'default_where_conditions' => 'minimum' ) |
|
| 998 | + array('default_where_conditions' => 'minimum') |
|
| 999 | 999 | ) |
| 1000 | 1000 | ); |
| 1001 | 1001 | } |
@@ -1012,16 +1012,16 @@ discard block |
||
| 1012 | 1012 | * @return array of normal query params, @see EEM_Base::get_all |
| 1013 | 1013 | * @throws \EE_Error |
| 1014 | 1014 | */ |
| 1015 | - public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) { |
|
| 1016 | - if( ! isset( $query_params[ 0 ] ) ) { |
|
| 1017 | - $query_params[ 0 ] = array(); |
|
| 1015 | + public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) { |
|
| 1016 | + if ( ! isset($query_params[0])) { |
|
| 1017 | + $query_params[0] = array(); |
|
| 1018 | 1018 | } |
| 1019 | - $conditions_from_id = $this->parse_index_primary_key_string( $id ); |
|
| 1020 | - if( $conditions_from_id === null ) { |
|
| 1021 | - $query_params[ 0 ][ $this->primary_key_name() ] = $id ; |
|
| 1022 | - }else{ |
|
| 1019 | + $conditions_from_id = $this->parse_index_primary_key_string($id); |
|
| 1020 | + if ($conditions_from_id === null) { |
|
| 1021 | + $query_params[0][$this->primary_key_name()] = $id; |
|
| 1022 | + } else { |
|
| 1023 | 1023 | //no primary key, so the $id must be from the get_index_primary_key_string() |
| 1024 | - $query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) ); |
|
| 1024 | + $query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id)); |
|
| 1025 | 1025 | } |
| 1026 | 1026 | return $query_params; |
| 1027 | 1027 | } |
@@ -1037,16 +1037,16 @@ discard block |
||
| 1037 | 1037 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class|NULL |
| 1038 | 1038 | * @throws \EE_Error |
| 1039 | 1039 | */ |
| 1040 | - public function get_one($query_params = array()){ |
|
| 1041 | - if( ! is_array( $query_params ) ){ |
|
| 1042 | - EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
| 1040 | + public function get_one($query_params = array()) { |
|
| 1041 | + if ( ! is_array($query_params)) { |
|
| 1042 | + EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
| 1043 | 1043 | $query_params = array(); |
| 1044 | 1044 | } |
| 1045 | 1045 | $query_params['limit'] = 1; |
| 1046 | 1046 | $items = $this->get_all($query_params); |
| 1047 | - if(empty($items)){ |
|
| 1047 | + if (empty($items)) { |
|
| 1048 | 1048 | return null; |
| 1049 | - }else{ |
|
| 1049 | + } else { |
|
| 1050 | 1050 | return array_shift($items); |
| 1051 | 1051 | } |
| 1052 | 1052 | } |
@@ -1069,8 +1069,8 @@ discard block |
||
| 1069 | 1069 | * @return EE_Base_Class[]|array |
| 1070 | 1070 | * @throws \EE_Error |
| 1071 | 1071 | */ |
| 1072 | - public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
| 1073 | - return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
| 1072 | + public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
| 1073 | + return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | |
@@ -1091,8 +1091,8 @@ discard block |
||
| 1091 | 1091 | * @return EE_Base_Class[]|array |
| 1092 | 1092 | * @throws \EE_Error |
| 1093 | 1093 | */ |
| 1094 | - public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
| 1095 | - return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
| 1094 | + public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
| 1095 | + return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | 1098 | |
@@ -1113,9 +1113,9 @@ discard block |
||
| 1113 | 1113 | * @return EE_Base_Class|null|array() |
| 1114 | 1114 | * @throws \EE_Error |
| 1115 | 1115 | */ |
| 1116 | - public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
| 1117 | - $results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
| 1118 | - return empty( $results ) ? null : reset( $results ); |
|
| 1116 | + public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
| 1117 | + $results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
| 1118 | + return empty($results) ? null : reset($results); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | |
@@ -1137,9 +1137,9 @@ discard block |
||
| 1137 | 1137 | * @return EE_Base_Class|null|array() |
| 1138 | 1138 | * @throws EE_Error |
| 1139 | 1139 | */ |
| 1140 | - public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
| 1141 | - $results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
| 1142 | - return empty( $results ) ? null : reset( $results ); |
|
| 1140 | + public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
| 1141 | + $results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
| 1142 | + return empty($results) ? null : reset($results); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | |
@@ -1160,42 +1160,42 @@ discard block |
||
| 1160 | 1160 | * @return EE_Base_Class[]|array |
| 1161 | 1161 | * @throws EE_Error |
| 1162 | 1162 | */ |
| 1163 | - protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
| 1163 | + protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
| 1164 | 1164 | //if $field_to_order_by is empty then let's assume we're ordering by the primary key. |
| 1165 | - if ( empty( $field_to_order_by ) ) { |
|
| 1166 | - if ( $this->has_primary_key_field() ) { |
|
| 1165 | + if (empty($field_to_order_by)) { |
|
| 1166 | + if ($this->has_primary_key_field()) { |
|
| 1167 | 1167 | $field_to_order_by = $this->get_primary_key_field()->get_name(); |
| 1168 | 1168 | } else { |
| 1169 | 1169 | |
| 1170 | - if ( WP_DEBUG ) { |
|
| 1171 | - throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) ); |
|
| 1170 | + if (WP_DEBUG) { |
|
| 1171 | + throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso')); |
|
| 1172 | 1172 | } |
| 1173 | - EE_Error::add_error( __('There was an error with the query.', 'event_espresso') ); |
|
| 1173 | + EE_Error::add_error(__('There was an error with the query.', 'event_espresso')); |
|
| 1174 | 1174 | return array(); |
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - if( ! is_array( $query_params ) ){ |
|
| 1179 | - EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
| 1178 | + if ( ! is_array($query_params)) { |
|
| 1179 | + EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
| 1180 | 1180 | $query_params = array(); |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | //let's add the where query param for consecutive look up. |
| 1184 | - $query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value ); |
|
| 1184 | + $query_params[0][$field_to_order_by] = array($operand, $current_field_value); |
|
| 1185 | 1185 | $query_params['limit'] = $limit; |
| 1186 | 1186 | |
| 1187 | 1187 | //set direction |
| 1188 | - $incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array(); |
|
| 1188 | + $incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array(); |
|
| 1189 | 1189 | $query_params['order_by'] = $operand === '>' |
| 1190 | - ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby |
|
| 1191 | - : array( $field_to_order_by => 'DESC') + $incoming_orderby; |
|
| 1190 | + ? array($field_to_order_by => 'ASC') + $incoming_orderby |
|
| 1191 | + : array($field_to_order_by => 'DESC') + $incoming_orderby; |
|
| 1192 | 1192 | |
| 1193 | 1193 | //if $columns_to_select is empty then that means we're returning EE_Base_Class objects |
| 1194 | - if ( empty( $columns_to_select ) ) { |
|
| 1195 | - return $this->get_all( $query_params ); |
|
| 1194 | + if (empty($columns_to_select)) { |
|
| 1195 | + return $this->get_all($query_params); |
|
| 1196 | 1196 | } else { |
| 1197 | 1197 | //getting just the fields |
| 1198 | - return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select ); |
|
| 1198 | + return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | } |
| 1201 | 1201 | |
@@ -1206,18 +1206,18 @@ discard block |
||
| 1206 | 1206 | * This sets the _timezone property after model object has been instantiated. |
| 1207 | 1207 | * @param null | string $timezone valid PHP DateTimeZone timezone string |
| 1208 | 1208 | */ |
| 1209 | - public function set_timezone( $timezone ) { |
|
| 1210 | - if ( $timezone !== null ) { |
|
| 1209 | + public function set_timezone($timezone) { |
|
| 1210 | + if ($timezone !== null) { |
|
| 1211 | 1211 | $this->_timezone = $timezone; |
| 1212 | 1212 | } |
| 1213 | 1213 | //note we need to loop through relations and set the timezone on those objects as well. |
| 1214 | - foreach ( $this->_model_relations as $relation ) { |
|
| 1215 | - $relation->set_timezone( $timezone ); |
|
| 1214 | + foreach ($this->_model_relations as $relation) { |
|
| 1215 | + $relation->set_timezone($timezone); |
|
| 1216 | 1216 | } |
| 1217 | 1217 | //and finally we do the same for any datetime fields |
| 1218 | - foreach ( $this->_fields as $field ) { |
|
| 1219 | - if ( $field instanceof EE_Datetime_Field ) { |
|
| 1220 | - $field->set_timezone( $timezone ); |
|
| 1218 | + foreach ($this->_fields as $field) { |
|
| 1219 | + if ($field instanceof EE_Datetime_Field) { |
|
| 1220 | + $field->set_timezone($timezone); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | } |
| 1223 | 1223 | } |
@@ -1232,9 +1232,9 @@ discard block |
||
| 1232 | 1232 | */ |
| 1233 | 1233 | public function get_timezone() { |
| 1234 | 1234 | //first validate if timezone is set. If not, then let's set it be whatever is set on the model fields. |
| 1235 | - if ( empty( $this->_timezone ) ) { |
|
| 1236 | - foreach( $this->_fields as $field ) { |
|
| 1237 | - if ( $field instanceof EE_Datetime_Field ) { |
|
| 1235 | + if (empty($this->_timezone)) { |
|
| 1236 | + foreach ($this->_fields as $field) { |
|
| 1237 | + if ($field instanceof EE_Datetime_Field) { |
|
| 1238 | 1238 | $this->set_timezone($field->get_timezone()); |
| 1239 | 1239 | break; |
| 1240 | 1240 | } |
@@ -1242,8 +1242,8 @@ discard block |
||
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | //if timezone STILL empty then return the default timezone for the site. |
| 1245 | - if ( empty( $this->_timezone ) ) { |
|
| 1246 | - $this->set_timezone( EEH_DTT_Helper::get_timezone() ); |
|
| 1245 | + if (empty($this->_timezone)) { |
|
| 1246 | + $this->set_timezone(EEH_DTT_Helper::get_timezone()); |
|
| 1247 | 1247 | } |
| 1248 | 1248 | return $this->_timezone; |
| 1249 | 1249 | } |
@@ -1261,19 +1261,19 @@ discard block |
||
| 1261 | 1261 | * |
| 1262 | 1262 | * @return array formats in an array with the date format first, and the time format last. |
| 1263 | 1263 | */ |
| 1264 | - public function get_formats_for( $field_name, $pretty = false ) { |
|
| 1265 | - $field_settings = $this->field_settings_for( $field_name ); |
|
| 1264 | + public function get_formats_for($field_name, $pretty = false) { |
|
| 1265 | + $field_settings = $this->field_settings_for($field_name); |
|
| 1266 | 1266 | |
| 1267 | 1267 | //if not a valid EE_Datetime_Field then throw error |
| 1268 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
| 1269 | - throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) ); |
|
| 1268 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
| 1269 | + throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name)); |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | //while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on |
| 1273 | 1273 | //the field. |
| 1274 | 1274 | $this->_timezone = $field_settings->get_timezone(); |
| 1275 | 1275 | |
| 1276 | - return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) ); |
|
| 1276 | + return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty)); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | 1279 | |
@@ -1297,25 +1297,25 @@ discard block |
||
| 1297 | 1297 | * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
| 1298 | 1298 | * exception is triggered. |
| 1299 | 1299 | */ |
| 1300 | - public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
|
| 1301 | - $formats = $this->get_formats_for( $field_name ); |
|
| 1300 | + public function current_time_for_query($field_name, $timestamp = false, $what = 'both') { |
|
| 1301 | + $formats = $this->get_formats_for($field_name); |
|
| 1302 | 1302 | |
| 1303 | - $DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) ); |
|
| 1303 | + $DateTime = new DateTime("now", new DateTimeZone($this->_timezone)); |
|
| 1304 | 1304 | |
| 1305 | - if ( $timestamp ) { |
|
| 1306 | - return $DateTime->format( 'U' ); |
|
| 1305 | + if ($timestamp) { |
|
| 1306 | + return $DateTime->format('U'); |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | //not returning timestamp, so return formatted string in timezone. |
| 1310 | - switch( $what ) { |
|
| 1310 | + switch ($what) { |
|
| 1311 | 1311 | case 'time' : |
| 1312 | - return $DateTime->format( $formats[1] ); |
|
| 1312 | + return $DateTime->format($formats[1]); |
|
| 1313 | 1313 | break; |
| 1314 | 1314 | case 'date' : |
| 1315 | - return $DateTime->format( $formats[0] ); |
|
| 1315 | + return $DateTime->format($formats[0]); |
|
| 1316 | 1316 | break; |
| 1317 | 1317 | default : |
| 1318 | - return $DateTime->format( implode( ' ', $formats ) ); |
|
| 1318 | + return $DateTime->format(implode(' ', $formats)); |
|
| 1319 | 1319 | break; |
| 1320 | 1320 | } |
| 1321 | 1321 | } |
@@ -1337,17 +1337,17 @@ discard block |
||
| 1337 | 1337 | * @return DateTime |
| 1338 | 1338 | * @throws \EE_Error |
| 1339 | 1339 | */ |
| 1340 | - public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) { |
|
| 1340 | + public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') { |
|
| 1341 | 1341 | |
| 1342 | 1342 | //just using this to ensure the timezone is set correctly internally |
| 1343 | - $this->get_formats_for( $field_name ); |
|
| 1343 | + $this->get_formats_for($field_name); |
|
| 1344 | 1344 | |
| 1345 | 1345 | //load EEH_DTT_Helper |
| 1346 | - $set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
| 1346 | + $set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
| 1347 | 1347 | |
| 1348 | - $incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) ); |
|
| 1348 | + $incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone)); |
|
| 1349 | 1349 | |
| 1350 | - return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
| 1350 | + return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone)); |
|
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | 1353 | |
@@ -1357,7 +1357,7 @@ discard block |
||
| 1357 | 1357 | * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects |
| 1358 | 1358 | * @return EE_Table_Base[] |
| 1359 | 1359 | */ |
| 1360 | - public function get_tables(){ |
|
| 1360 | + public function get_tables() { |
|
| 1361 | 1361 | return $this->_tables; |
| 1362 | 1362 | } |
| 1363 | 1363 | |
@@ -1393,9 +1393,9 @@ discard block |
||
| 1393 | 1393 | * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad) |
| 1394 | 1394 | * @throws \EE_Error |
| 1395 | 1395 | */ |
| 1396 | - public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){ |
|
| 1397 | - if( ! is_array( $query_params ) ){ |
|
| 1398 | - EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
| 1396 | + public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
| 1397 | + if ( ! is_array($query_params)) { |
|
| 1398 | + EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
| 1399 | 1399 | $query_params = array(); |
| 1400 | 1400 | } |
| 1401 | 1401 | /** |
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | * @param array $fields_n_values the updated fields and their new values |
| 1406 | 1406 | * @param array $query_params @see EEM_Base::get_all() |
| 1407 | 1407 | */ |
| 1408 | - do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params ); |
|
| 1408 | + do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params); |
|
| 1409 | 1409 | /** |
| 1410 | 1410 | * Filters the fields about to be updated given the query parameters. You can provide the |
| 1411 | 1411 | * $query_params to $this->get_all() to find exactly which records will be updated |
@@ -1413,10 +1413,10 @@ discard block |
||
| 1413 | 1413 | * @param EEM_Base $model the model being queried |
| 1414 | 1414 | * @param array $query_params see EEM_Base::get_all() |
| 1415 | 1415 | */ |
| 1416 | - $fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params ); |
|
| 1416 | + $fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params); |
|
| 1417 | 1417 | //need to verify that, for any entry we want to update, there are entries in each secondary table. |
| 1418 | 1418 | //to do that, for each table, verify that it's PK isn't null. |
| 1419 | - $tables= $this->get_tables(); |
|
| 1419 | + $tables = $this->get_tables(); |
|
| 1420 | 1420 | |
| 1421 | 1421 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
| 1422 | 1422 | //NOTE: we should make this code more efficient by NOT querying twice |
@@ -1426,29 +1426,29 @@ discard block |
||
| 1426 | 1426 | //we want to make sure the default_where strategy is ignored |
| 1427 | 1427 | $this->_ignore_where_strategy = TRUE; |
| 1428 | 1428 | $wpdb_select_results = $this->_get_all_wpdb_results($query_params); |
| 1429 | - foreach( $wpdb_select_results as $wpdb_result ){ |
|
| 1429 | + foreach ($wpdb_select_results as $wpdb_result) { |
|
| 1430 | 1430 | // type cast stdClass as array |
| 1431 | - $wpdb_result = (array)$wpdb_result; |
|
| 1431 | + $wpdb_result = (array) $wpdb_result; |
|
| 1432 | 1432 | //get the model object's PK, as we'll want this if we need to insert a row into secondary tables |
| 1433 | - if( $this->has_primary_key_field() ){ |
|
| 1434 | - $main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
| 1435 | - }else{ |
|
| 1433 | + if ($this->has_primary_key_field()) { |
|
| 1434 | + $main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()]; |
|
| 1435 | + } else { |
|
| 1436 | 1436 | //if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work) |
| 1437 | 1437 | $main_table_pk_value = null; |
| 1438 | 1438 | } |
| 1439 | 1439 | //if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables |
| 1440 | 1440 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
| 1441 | - if(count($tables) > 1){ |
|
| 1441 | + if (count($tables) > 1) { |
|
| 1442 | 1442 | //foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry |
| 1443 | 1443 | //in that table, and so we'll want to insert one |
| 1444 | - foreach($tables as $table_obj){ |
|
| 1444 | + foreach ($tables as $table_obj) { |
|
| 1445 | 1445 | $this_table_pk_column = $table_obj->get_fully_qualified_pk_column(); |
| 1446 | 1446 | //if there is no private key for this table on the results, it means there's no entry |
| 1447 | 1447 | //in this table, right? so insert a row in the current table, using any fields available |
| 1448 | - if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){ |
|
| 1448 | + if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) { |
|
| 1449 | 1449 | $success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value); |
| 1450 | 1450 | //if we died here, report the error |
| 1451 | - if( ! $success ) { |
|
| 1451 | + if ( ! $success) { |
|
| 1452 | 1452 | return false; |
| 1453 | 1453 | } |
| 1454 | 1454 | } |
@@ -1468,44 +1468,44 @@ discard block |
||
| 1468 | 1468 | //if this wasn't called from a model object (to update itself) |
| 1469 | 1469 | //then we want to make sure we keep all the existing |
| 1470 | 1470 | //model objects in sync with the db |
| 1471 | - if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){ |
|
| 1472 | - if( $this->has_primary_key_field() ){ |
|
| 1473 | - $model_objs_affected_ids = $this->get_col( $query_params ); |
|
| 1474 | - }else{ |
|
| 1471 | + if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) { |
|
| 1472 | + if ($this->has_primary_key_field()) { |
|
| 1473 | + $model_objs_affected_ids = $this->get_col($query_params); |
|
| 1474 | + } else { |
|
| 1475 | 1475 | //we need to select a bunch of columns and then combine them into the the "index primary key string"s |
| 1476 | - $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A ); |
|
| 1476 | + $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A); |
|
| 1477 | 1477 | $model_objs_affected_ids = array(); |
| 1478 | - foreach( $models_affected_key_columns as $row ){ |
|
| 1479 | - $combined_index_key = $this->get_index_primary_key_string( $row ); |
|
| 1480 | - $model_objs_affected_ids[ $combined_index_key ] = $combined_index_key; |
|
| 1478 | + foreach ($models_affected_key_columns as $row) { |
|
| 1479 | + $combined_index_key = $this->get_index_primary_key_string($row); |
|
| 1480 | + $model_objs_affected_ids[$combined_index_key] = $combined_index_key; |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | - if( ! $model_objs_affected_ids ){ |
|
| 1485 | + if ( ! $model_objs_affected_ids) { |
|
| 1486 | 1486 | //wait wait wait- if nothing was affected let's stop here |
| 1487 | 1487 | return 0; |
| 1488 | 1488 | } |
| 1489 | - foreach( $model_objs_affected_ids as $id ){ |
|
| 1490 | - $model_obj_in_entity_map = $this->get_from_entity_map( $id ); |
|
| 1491 | - if( $model_obj_in_entity_map ){ |
|
| 1492 | - foreach( $fields_n_values as $field => $new_value ){ |
|
| 1493 | - $model_obj_in_entity_map->set( $field, $new_value ); |
|
| 1489 | + foreach ($model_objs_affected_ids as $id) { |
|
| 1490 | + $model_obj_in_entity_map = $this->get_from_entity_map($id); |
|
| 1491 | + if ($model_obj_in_entity_map) { |
|
| 1492 | + foreach ($fields_n_values as $field => $new_value) { |
|
| 1493 | + $model_obj_in_entity_map->set($field, $new_value); |
|
| 1494 | 1494 | } |
| 1495 | 1495 | } |
| 1496 | 1496 | } |
| 1497 | 1497 | //if there is a primary key on this model, we can now do a slight optimization |
| 1498 | - if( $this->has_primary_key_field() ){ |
|
| 1498 | + if ($this->has_primary_key_field()) { |
|
| 1499 | 1499 | //we already know what we want to update. So let's make the query simpler so it's a little more efficient |
| 1500 | 1500 | $query_params = array( |
| 1501 | - array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ), |
|
| 1502 | - 'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' ); |
|
| 1501 | + array($this->primary_key_name() => array('IN', $model_objs_affected_ids)), |
|
| 1502 | + 'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' ); |
|
| 1503 | 1503 | } |
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | - $model_query_info = $this->_create_model_query_info_carrier( $query_params ); |
|
| 1507 | - $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
| 1508 | - $rows_affected = $this->_do_wpdb_query('query', array( $SQL ) ); |
|
| 1506 | + $model_query_info = $this->_create_model_query_info_carrier($query_params); |
|
| 1507 | + $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
| 1508 | + $rows_affected = $this->_do_wpdb_query('query', array($SQL)); |
|
| 1509 | 1509 | /** |
| 1510 | 1510 | * Action called after a model update call has been made. |
| 1511 | 1511 | * |
@@ -1514,8 +1514,8 @@ discard block |
||
| 1514 | 1514 | * @param array $query_params @see EEM_Base::get_all() |
| 1515 | 1515 | * @param int $rows_affected |
| 1516 | 1516 | */ |
| 1517 | - do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected ); |
|
| 1518 | - return $rows_affected;//how many supposedly got updated |
|
| 1517 | + do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected); |
|
| 1518 | + return $rows_affected; //how many supposedly got updated |
|
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | |
@@ -1531,22 +1531,22 @@ discard block |
||
| 1531 | 1531 | * @return array just like $wpdb->get_col() |
| 1532 | 1532 | * @throws \EE_Error |
| 1533 | 1533 | */ |
| 1534 | - public function get_col( $query_params = array(), $field_to_select = NULL ){ |
|
| 1534 | + public function get_col($query_params = array(), $field_to_select = NULL) { |
|
| 1535 | 1535 | |
| 1536 | - if( $field_to_select ){ |
|
| 1537 | - $field = $this->field_settings_for( $field_to_select ); |
|
| 1538 | - }elseif( $this->has_primary_key_field ( ) ){ |
|
| 1536 | + if ($field_to_select) { |
|
| 1537 | + $field = $this->field_settings_for($field_to_select); |
|
| 1538 | + }elseif ($this->has_primary_key_field( )) { |
|
| 1539 | 1539 | $field = $this->get_primary_key_field(); |
| 1540 | - }else{ |
|
| 1540 | + } else { |
|
| 1541 | 1541 | //no primary key, just grab the first column |
| 1542 | - $field = reset( $this->field_settings()); |
|
| 1542 | + $field = reset($this->field_settings()); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | 1545 | |
| 1546 | 1546 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
| 1547 | 1547 | $select_expressions = $field->get_qualified_column(); |
| 1548 | - $SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
| 1549 | - return $this->_do_wpdb_query('get_col', array( $SQL ) ); |
|
| 1548 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
| 1549 | + return $this->_do_wpdb_query('get_col', array($SQL)); |
|
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | |
@@ -1559,12 +1559,12 @@ discard block |
||
| 1559 | 1559 | * @return string |
| 1560 | 1560 | * @throws \EE_Error |
| 1561 | 1561 | */ |
| 1562 | - public function get_var( $query_params = array(), $field_to_select = NULL ) { |
|
| 1563 | - $query_params[ 'limit' ] = 1; |
|
| 1564 | - $col = $this->get_col( $query_params, $field_to_select ); |
|
| 1565 | - if( ! empty( $col ) ) { |
|
| 1566 | - return reset( $col ); |
|
| 1567 | - }else{ |
|
| 1562 | + public function get_var($query_params = array(), $field_to_select = NULL) { |
|
| 1563 | + $query_params['limit'] = 1; |
|
| 1564 | + $col = $this->get_col($query_params, $field_to_select); |
|
| 1565 | + if ( ! empty($col)) { |
|
| 1566 | + return reset($col); |
|
| 1567 | + } else { |
|
| 1568 | 1568 | return NULL; |
| 1569 | 1569 | } |
| 1570 | 1570 | } |
@@ -1580,19 +1580,19 @@ discard block |
||
| 1580 | 1580 | * @return string of SQL |
| 1581 | 1581 | * @throws \EE_Error |
| 1582 | 1582 | */ |
| 1583 | - public function _construct_update_sql($fields_n_values){ |
|
| 1583 | + public function _construct_update_sql($fields_n_values) { |
|
| 1584 | 1584 | /** @type WPDB $wpdb */ |
| 1585 | 1585 | global $wpdb; |
| 1586 | 1586 | $cols_n_values = array(); |
| 1587 | - foreach($fields_n_values as $field_name => $value){ |
|
| 1587 | + foreach ($fields_n_values as $field_name => $value) { |
|
| 1588 | 1588 | $field_obj = $this->field_settings_for($field_name); |
| 1589 | 1589 | //if the value is NULL, we want to assign the value to that. |
| 1590 | 1590 | //wpdb->prepare doesn't really handle that properly |
| 1591 | - $prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values ); |
|
| 1592 | - $value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value ); |
|
| 1591 | + $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
|
| 1592 | + $value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value); |
|
| 1593 | 1593 | $cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql; |
| 1594 | 1594 | } |
| 1595 | - return implode(",",$cols_n_values); |
|
| 1595 | + return implode(",", $cols_n_values); |
|
| 1596 | 1596 | |
| 1597 | 1597 | } |
| 1598 | 1598 | |
@@ -1608,10 +1608,10 @@ discard block |
||
| 1608 | 1608 | * @return boolean whether the row got deleted or not |
| 1609 | 1609 | * @throws \EE_Error |
| 1610 | 1610 | */ |
| 1611 | - public function delete_permanently_by_ID( $id ) { |
|
| 1611 | + public function delete_permanently_by_ID($id) { |
|
| 1612 | 1612 | return $this->delete_permanently( |
| 1613 | 1613 | array( |
| 1614 | - array( $this->get_primary_key_field()->get_name() => $id ), |
|
| 1614 | + array($this->get_primary_key_field()->get_name() => $id), |
|
| 1615 | 1615 | 'limit' => 1 |
| 1616 | 1616 | ) |
| 1617 | 1617 | ); |
@@ -1627,10 +1627,10 @@ discard block |
||
| 1627 | 1627 | * @return boolean whether the row got deleted or not |
| 1628 | 1628 | * @throws \EE_Error |
| 1629 | 1629 | */ |
| 1630 | - public function delete_by_ID( $id ){ |
|
| 1630 | + public function delete_by_ID($id) { |
|
| 1631 | 1631 | return $this->delete( |
| 1632 | 1632 | array( |
| 1633 | - array( $this->get_primary_key_field()->get_name() => $id ), |
|
| 1633 | + array($this->get_primary_key_field()->get_name() => $id), |
|
| 1634 | 1634 | 'limit' => 1 |
| 1635 | 1635 | ) |
| 1636 | 1636 | ); |
@@ -1649,7 +1649,7 @@ discard block |
||
| 1649 | 1649 | * @return int how many rows got deleted |
| 1650 | 1650 | * @throws \EE_Error |
| 1651 | 1651 | */ |
| 1652 | - public function delete($query_params,$allow_blocking = true){ |
|
| 1652 | + public function delete($query_params, $allow_blocking = true) { |
|
| 1653 | 1653 | return $this->delete_permanently($query_params, $allow_blocking); |
| 1654 | 1654 | } |
| 1655 | 1655 | |
@@ -1667,7 +1667,7 @@ discard block |
||
| 1667 | 1667 | * @return int how many rows got deleted |
| 1668 | 1668 | * @throws \EE_Error |
| 1669 | 1669 | */ |
| 1670 | - public function delete_permanently($query_params,$allow_blocking = true){ |
|
| 1670 | + public function delete_permanently($query_params, $allow_blocking = true) { |
|
| 1671 | 1671 | /** |
| 1672 | 1672 | * Action called just before performing a real deletion query. You can use the |
| 1673 | 1673 | * model and its $query_params to find exactly which items will be deleted |
@@ -1676,31 +1676,31 @@ discard block |
||
| 1676 | 1676 | * @param boolean $allow_blocking whether or not to allow related model objects |
| 1677 | 1677 | * to block (prevent) this deletion |
| 1678 | 1678 | */ |
| 1679 | - do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking ); |
|
| 1679 | + do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking); |
|
| 1680 | 1680 | //some MySQL databases may be running safe mode, which may restrict |
| 1681 | 1681 | //deletion if there is no KEY column used in the WHERE statement of a deletion. |
| 1682 | 1682 | //to get around this, we first do a SELECT, get all the IDs, and then run another query |
| 1683 | 1683 | //to delete them |
| 1684 | 1684 | $items_for_deletion = $this->_get_all_wpdb_results($query_params); |
| 1685 | - $deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking); |
|
| 1686 | - if($deletion_where){ |
|
| 1685 | + $deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking); |
|
| 1686 | + if ($deletion_where) { |
|
| 1687 | 1687 | //echo "objects for deletion:";var_dump($objects_for_deletion); |
| 1688 | 1688 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
| 1689 | - $table_aliases = array_keys( $this->_tables ); |
|
| 1690 | - $SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
| 1689 | + $table_aliases = array_keys($this->_tables); |
|
| 1690 | + $SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
| 1691 | 1691 | |
| 1692 | 1692 | // /echo "delete sql:$SQL"; |
| 1693 | - $rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) ); |
|
| 1694 | - }else{ |
|
| 1693 | + $rows_deleted = $this->_do_wpdb_query('query', array($SQL)); |
|
| 1694 | + } else { |
|
| 1695 | 1695 | $rows_deleted = 0; |
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | 1698 | //and lastly make sure those items are removed from the entity map; if they could be put into it at all |
| 1699 | - if( $this->has_primary_key_field() ){ |
|
| 1700 | - foreach($items_for_deletion as $item_for_deletion_row ){ |
|
| 1701 | - $pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
| 1702 | - if( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ) ){ |
|
| 1703 | - unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ); |
|
| 1699 | + if ($this->has_primary_key_field()) { |
|
| 1700 | + foreach ($items_for_deletion as $item_for_deletion_row) { |
|
| 1701 | + $pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()]; |
|
| 1702 | + if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value])) { |
|
| 1703 | + unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value]); |
|
| 1704 | 1704 | } |
| 1705 | 1705 | } |
| 1706 | 1706 | } |
@@ -1712,8 +1712,8 @@ discard block |
||
| 1712 | 1712 | * @param array $query_params @see EEM_Base::get_all() |
| 1713 | 1713 | * @param int $rows_deleted |
| 1714 | 1714 | */ |
| 1715 | - do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted ); |
|
| 1716 | - return $rows_deleted;//how many supposedly got deleted |
|
| 1715 | + do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted); |
|
| 1716 | + return $rows_deleted; //how many supposedly got deleted |
|
| 1717 | 1717 | } |
| 1718 | 1718 | |
| 1719 | 1719 | |
@@ -1731,28 +1731,28 @@ discard block |
||
| 1731 | 1731 | * @return boolean |
| 1732 | 1732 | * @throws \EE_Error |
| 1733 | 1733 | */ |
| 1734 | - public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){ |
|
| 1734 | + public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) { |
|
| 1735 | 1735 | //first, if $ignore_this_model_obj was supplied, get its model |
| 1736 | - if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){ |
|
| 1736 | + if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) { |
|
| 1737 | 1737 | $ignored_model = $ignore_this_model_obj->get_model(); |
| 1738 | - }else{ |
|
| 1738 | + } else { |
|
| 1739 | 1739 | $ignored_model = null; |
| 1740 | 1740 | } |
| 1741 | 1741 | //now check all the relations of $this_model_obj_or_id and see if there |
| 1742 | 1742 | //are any related model objects blocking it? |
| 1743 | 1743 | $is_blocked = false; |
| 1744 | - foreach($this->_model_relations as $relation_name => $relation_obj){ |
|
| 1745 | - if( $relation_obj->block_delete_if_related_models_exist()){ |
|
| 1744 | + foreach ($this->_model_relations as $relation_name => $relation_obj) { |
|
| 1745 | + if ($relation_obj->block_delete_if_related_models_exist()) { |
|
| 1746 | 1746 | //if $ignore_this_model_obj was supplied, then for the query |
| 1747 | 1747 | //on that model needs to be told to ignore $ignore_this_model_obj |
| 1748 | - if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){ |
|
| 1749 | - $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array( |
|
| 1750 | - array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID())))); |
|
| 1751 | - }else{ |
|
| 1748 | + if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) { |
|
| 1749 | + $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array( |
|
| 1750 | + array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID())))); |
|
| 1751 | + } else { |
|
| 1752 | 1752 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id); |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | - if($related_model_objects){ |
|
| 1755 | + if ($related_model_objects) { |
|
| 1756 | 1756 | EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__); |
| 1757 | 1757 | $is_blocked = true; |
| 1758 | 1758 | } |
@@ -1772,75 +1772,75 @@ discard block |
||
| 1772 | 1772 | * @throws EE_Error |
| 1773 | 1773 | * @return string everything that comes after the WHERE statement. |
| 1774 | 1774 | */ |
| 1775 | - protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) { |
|
| 1776 | - if($this->has_primary_key_field()){ |
|
| 1775 | + protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) { |
|
| 1776 | + if ($this->has_primary_key_field()) { |
|
| 1777 | 1777 | $primary_table = $this->_get_main_table(); |
| 1778 | 1778 | $other_tables = $this->_get_other_tables(); |
| 1779 | 1779 | $deletes = $query = array(); |
| 1780 | - foreach ( $objects_for_deletion as $delete_object ) { |
|
| 1780 | + foreach ($objects_for_deletion as $delete_object) { |
|
| 1781 | 1781 | //before we mark this object for deletion, |
| 1782 | 1782 | //make sure there's no related objects blocking its deletion (if we're checking) |
| 1783 | 1783 | if ( |
| 1784 | 1784 | $allow_blocking |
| 1785 | 1785 | && $this->delete_is_blocked_by_related_models( |
| 1786 | - $delete_object[ $primary_table->get_fully_qualified_pk_column() ] |
|
| 1786 | + $delete_object[$primary_table->get_fully_qualified_pk_column()] |
|
| 1787 | 1787 | ) |
| 1788 | 1788 | ) { |
| 1789 | 1789 | continue; |
| 1790 | 1790 | } |
| 1791 | 1791 | //primary table deletes |
| 1792 | - if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) { |
|
| 1793 | - $deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ]; |
|
| 1792 | + if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) { |
|
| 1793 | + $deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()]; |
|
| 1794 | 1794 | } |
| 1795 | 1795 | //other tables |
| 1796 | - if ( ! empty( $other_tables ) ) { |
|
| 1797 | - foreach ( $other_tables as $ot ) { |
|
| 1796 | + if ( ! empty($other_tables)) { |
|
| 1797 | + foreach ($other_tables as $ot) { |
|
| 1798 | 1798 | //first check if we've got the foreign key column here. |
| 1799 | - if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) { |
|
| 1800 | - $deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ]; |
|
| 1799 | + if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) { |
|
| 1800 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()]; |
|
| 1801 | 1801 | } |
| 1802 | 1802 | // wait! it's entirely possible that we'll have a the primary key |
| 1803 | 1803 | // for this table in here, if it's a foreign key for one of the other secondary tables |
| 1804 | - if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) { |
|
| 1805 | - $deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ]; |
|
| 1804 | + if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) { |
|
| 1805 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
| 1806 | 1806 | } |
| 1807 | 1807 | // finally, it is possible that the fk for this table is found |
| 1808 | 1808 | // in the fully qualified pk column for the fk table, so let's see if that's there! |
| 1809 | - if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) { |
|
| 1810 | - $deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ]; |
|
| 1809 | + if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) { |
|
| 1810 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
| 1811 | 1811 | } |
| 1812 | 1812 | } |
| 1813 | 1813 | } |
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | 1816 | //we should have deletes now, so let's just go through and setup the where statement |
| 1817 | - foreach ( $deletes as $column => $values ) { |
|
| 1817 | + foreach ($deletes as $column => $values) { |
|
| 1818 | 1818 | //make sure we have unique $values; |
| 1819 | 1819 | $values = array_unique($values); |
| 1820 | - $query[] = $column . ' IN(' . implode(",",$values) . ')'; |
|
| 1820 | + $query[] = $column.' IN('.implode(",", $values).')'; |
|
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | - return !empty($query) ? implode(' AND ', $query ) : ''; |
|
| 1824 | - }elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
| 1823 | + return ! empty($query) ? implode(' AND ', $query) : ''; |
|
| 1824 | + }elseif (count($this->get_combined_primary_key_fields()) > 1) { |
|
| 1825 | 1825 | $ways_to_identify_a_row = array(); |
| 1826 | 1826 | $fields = $this->get_combined_primary_key_fields(); |
| 1827 | 1827 | //note: because there' sno primary key, that means nothing else can be pointing to this model, right? |
| 1828 | - foreach($objects_for_deletion as $delete_object){ |
|
| 1828 | + foreach ($objects_for_deletion as $delete_object) { |
|
| 1829 | 1829 | $values_for_each_cpk_for_a_row = array(); |
| 1830 | - foreach($fields as $cpk_field){ |
|
| 1831 | - if ( $cpk_field instanceof EE_Model_Field_Base ){ |
|
| 1830 | + foreach ($fields as $cpk_field) { |
|
| 1831 | + if ($cpk_field instanceof EE_Model_Field_Base) { |
|
| 1832 | 1832 | $values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column() |
| 1833 | 1833 | . "=" |
| 1834 | - . $delete_object[ $cpk_field->get_qualified_column() ]; |
|
| 1834 | + . $delete_object[$cpk_field->get_qualified_column()]; |
|
| 1835 | 1835 | } |
| 1836 | 1836 | } |
| 1837 | - $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
|
| 1837 | + $ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")"; |
|
| 1838 | 1838 | } |
| 1839 | - return implode(" OR ",$ways_to_identify_a_row); |
|
| 1840 | - }else{ |
|
| 1839 | + return implode(" OR ", $ways_to_identify_a_row); |
|
| 1840 | + } else { |
|
| 1841 | 1841 | //so there's no primary key and no combined key... |
| 1842 | 1842 | //sorry, can't help you |
| 1843 | - throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this))); |
|
| 1843 | + throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this))); |
|
| 1844 | 1844 | } |
| 1845 | 1845 | } |
| 1846 | 1846 | |
@@ -1856,34 +1856,34 @@ discard block |
||
| 1856 | 1856 | * @return int |
| 1857 | 1857 | * @throws \EE_Error |
| 1858 | 1858 | */ |
| 1859 | - public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
| 1859 | + public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
| 1860 | 1860 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
| 1861 | - if($field_to_count){ |
|
| 1861 | + if ($field_to_count) { |
|
| 1862 | 1862 | $field_obj = $this->field_settings_for($field_to_count); |
| 1863 | 1863 | $column_to_count = $field_obj->get_qualified_column(); |
| 1864 | - }elseif($this->has_primary_key_field ()){ |
|
| 1864 | + }elseif ($this->has_primary_key_field()) { |
|
| 1865 | 1865 | $pk_field_obj = $this->get_primary_key_field(); |
| 1866 | 1866 | $column_to_count = $pk_field_obj->get_qualified_column(); |
| 1867 | - }else{ |
|
| 1867 | + } else { |
|
| 1868 | 1868 | //there's no primary key |
| 1869 | 1869 | //if we're counting distinct items, and there's no primary key, |
| 1870 | 1870 | //we need to list out the columns for distinction; |
| 1871 | 1871 | //otherwise we can just use star |
| 1872 | - if( $distinct ) { |
|
| 1872 | + if ($distinct) { |
|
| 1873 | 1873 | $columns_to_use = array(); |
| 1874 | - foreach( $this->get_combined_primary_key_fields() as $field_obj ) { |
|
| 1874 | + foreach ($this->get_combined_primary_key_fields() as $field_obj) { |
|
| 1875 | 1875 | $columns_to_use[] = $field_obj->get_qualified_column(); |
| 1876 | 1876 | } |
| 1877 | - $column_to_count = implode(',', $columns_to_use ); |
|
| 1877 | + $column_to_count = implode(',', $columns_to_use); |
|
| 1878 | 1878 | } else { |
| 1879 | 1879 | $column_to_count = '*'; |
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | - $column_to_count = $distinct ? "DISTINCT " . $column_to_count : $column_to_count; |
|
| 1885 | - $SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
| 1886 | - return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) ); |
|
| 1884 | + $column_to_count = $distinct ? "DISTINCT ".$column_to_count : $column_to_count; |
|
| 1885 | + $SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
| 1886 | + return (int) $this->_do_wpdb_query('get_var', array($SQL)); |
|
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | 1889 | |
@@ -1896,24 +1896,24 @@ discard block |
||
| 1896 | 1896 | * @return float |
| 1897 | 1897 | * @throws \EE_Error |
| 1898 | 1898 | */ |
| 1899 | - public function sum($query_params, $field_to_sum = NULL){ |
|
| 1899 | + public function sum($query_params, $field_to_sum = NULL) { |
|
| 1900 | 1900 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
| 1901 | 1901 | |
| 1902 | - if($field_to_sum){ |
|
| 1902 | + if ($field_to_sum) { |
|
| 1903 | 1903 | $field_obj = $this->field_settings_for($field_to_sum); |
| 1904 | 1904 | |
| 1905 | - }else{ |
|
| 1905 | + } else { |
|
| 1906 | 1906 | $field_obj = $this->get_primary_key_field(); |
| 1907 | 1907 | } |
| 1908 | 1908 | $column_to_count = $field_obj->get_qualified_column(); |
| 1909 | 1909 | |
| 1910 | - $SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
| 1911 | - $return_value = $this->_do_wpdb_query('get_var',array( $SQL ) ); |
|
| 1910 | + $SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
| 1911 | + $return_value = $this->_do_wpdb_query('get_var', array($SQL)); |
|
| 1912 | 1912 | $data_type = $field_obj->get_wpdb_data_type(); |
| 1913 | - if( $data_type === '%d' || $data_type === '%s' ){ |
|
| 1914 | - return (float)$return_value; |
|
| 1915 | - }else{//must be %f |
|
| 1916 | - return (float)$return_value; |
|
| 1913 | + if ($data_type === '%d' || $data_type === '%s') { |
|
| 1914 | + return (float) $return_value; |
|
| 1915 | + } else {//must be %f |
|
| 1916 | + return (float) $return_value; |
|
| 1917 | 1917 | } |
| 1918 | 1918 | } |
| 1919 | 1919 | |
@@ -1928,37 +1928,37 @@ discard block |
||
| 1928 | 1928 | * @global wpdb $wpdb |
| 1929 | 1929 | * @return mixed |
| 1930 | 1930 | */ |
| 1931 | - protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){ |
|
| 1931 | + protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
| 1932 | 1932 | //if we're in maintenance mode level 2, DON'T run any queries |
| 1933 | 1933 | //because level 2 indicates the database needs updating and |
| 1934 | 1934 | //is probably out of sync with the code |
| 1935 | - if( ! EE_Maintenance_Mode::instance()->models_can_query()){ |
|
| 1935 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 1936 | 1936 | throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso"))); |
| 1937 | 1937 | } |
| 1938 | 1938 | /** @type WPDB $wpdb */ |
| 1939 | 1939 | global $wpdb; |
| 1940 | - if( ! method_exists( $wpdb, $wpdb_method ) ){ |
|
| 1941 | - throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) ); |
|
| 1940 | + if ( ! method_exists($wpdb, $wpdb_method)) { |
|
| 1941 | + throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method)); |
|
| 1942 | 1942 | } |
| 1943 | - if( WP_DEBUG ){ |
|
| 1943 | + if (WP_DEBUG) { |
|
| 1944 | 1944 | $old_show_errors_value = $wpdb->show_errors; |
| 1945 | - $wpdb->show_errors( FALSE ); |
|
| 1946 | - } |
|
| 1947 | - $result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
| 1948 | - $this->show_db_query_if_previously_requested( $wpdb->last_query ); |
|
| 1949 | - if( WP_DEBUG ){ |
|
| 1950 | - $wpdb->show_errors( $old_show_errors_value ); |
|
| 1951 | - if( ! empty( $wpdb->last_error ) ){ |
|
| 1952 | - throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) ); |
|
| 1953 | - }elseif( $result === false ){ |
|
| 1954 | - throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) ); |
|
| 1945 | + $wpdb->show_errors(FALSE); |
|
| 1946 | + } |
|
| 1947 | + $result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
| 1948 | + $this->show_db_query_if_previously_requested($wpdb->last_query); |
|
| 1949 | + if (WP_DEBUG) { |
|
| 1950 | + $wpdb->show_errors($old_show_errors_value); |
|
| 1951 | + if ( ! empty($wpdb->last_error)) { |
|
| 1952 | + throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error)); |
|
| 1953 | + }elseif ($result === false) { |
|
| 1954 | + throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true))); |
|
| 1955 | 1955 | } |
| 1956 | - }elseif( $result === false ) { |
|
| 1956 | + }elseif ($result === false) { |
|
| 1957 | 1957 | EE_Error::add_error( |
| 1958 | 1958 | sprintf( |
| 1959 | - __( 'A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso' ), |
|
| 1959 | + __('A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso'), |
|
| 1960 | 1960 | $wpdb_method, |
| 1961 | - var_export( $arguments_to_provide, true ), |
|
| 1961 | + var_export($arguments_to_provide, true), |
|
| 1962 | 1962 | $wpdb->last_error |
| 1963 | 1963 | ), |
| 1964 | 1964 | __FILE__, |
@@ -1980,26 +1980,26 @@ discard block |
||
| 1980 | 1980 | * @param array $arguments_to_provide |
| 1981 | 1981 | * @return mixed |
| 1982 | 1982 | */ |
| 1983 | - private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) { |
|
| 1983 | + private function _process_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
| 1984 | 1984 | /** @type WPDB $wpdb */ |
| 1985 | 1985 | global $wpdb; |
| 1986 | 1986 | $wpdb->last_error = null; |
| 1987 | - $result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide ); |
|
| 1987 | + $result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide); |
|
| 1988 | 1988 | // was there an error running the query? but we don't care on new activations |
| 1989 | 1989 | // (we're going to setup the DB anyway on new activations) |
| 1990 | - if ( ( $result === false || ! empty( $wpdb->last_error ) ) |
|
| 1990 | + if (($result === false || ! empty($wpdb->last_error)) |
|
| 1991 | 1991 | && EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation |
| 1992 | 1992 | ) { |
| 1993 | - switch ( EEM_Base::$_db_verification_level ) { |
|
| 1993 | + switch (EEM_Base::$_db_verification_level) { |
|
| 1994 | 1994 | |
| 1995 | 1995 | case EEM_Base::db_verified_none : |
| 1996 | 1996 | // let's double-check core's DB |
| 1997 | - $error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide ); |
|
| 1997 | + $error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide); |
|
| 1998 | 1998 | break; |
| 1999 | 1999 | |
| 2000 | 2000 | case EEM_Base::db_verified_core : |
| 2001 | 2001 | // STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed |
| 2002 | - $error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide ); |
|
| 2002 | + $error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide); |
|
| 2003 | 2003 | break; |
| 2004 | 2004 | |
| 2005 | 2005 | case EEM_Base::db_verified_addons : |
@@ -2007,11 +2007,11 @@ discard block |
||
| 2007 | 2007 | return $result; |
| 2008 | 2008 | break; |
| 2009 | 2009 | } |
| 2010 | - if ( ! empty( $error_message ) ) { |
|
| 2011 | - EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' ); |
|
| 2012 | - trigger_error( $error_message ); |
|
| 2010 | + if ( ! empty($error_message)) { |
|
| 2011 | + EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error'); |
|
| 2012 | + trigger_error($error_message); |
|
| 2013 | 2013 | } |
| 2014 | - return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
| 2014 | + return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
| 2015 | 2015 | |
| 2016 | 2016 | } |
| 2017 | 2017 | |
@@ -2027,18 +2027,18 @@ discard block |
||
| 2027 | 2027 | * @param array $arguments_to_provide |
| 2028 | 2028 | * @return string |
| 2029 | 2029 | */ |
| 2030 | - private function _verify_core_db( $wpdb_method, $arguments_to_provide ){ |
|
| 2030 | + private function _verify_core_db($wpdb_method, $arguments_to_provide) { |
|
| 2031 | 2031 | /** @type WPDB $wpdb */ |
| 2032 | 2032 | global $wpdb; |
| 2033 | 2033 | //ok remember that we've already attempted fixing the core db, in case the problem persists |
| 2034 | 2034 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_core; |
| 2035 | 2035 | $error_message = sprintf( |
| 2036 | - __( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ), |
|
| 2036 | + __('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'), |
|
| 2037 | 2037 | $wpdb->last_error, |
| 2038 | 2038 | $wpdb_method, |
| 2039 | - json_encode( $arguments_to_provide ) |
|
| 2039 | + json_encode($arguments_to_provide) |
|
| 2040 | 2040 | ); |
| 2041 | - EE_System::instance()->initialize_db_if_no_migrations_required( false, true ); |
|
| 2041 | + EE_System::instance()->initialize_db_if_no_migrations_required(false, true); |
|
| 2042 | 2042 | return $error_message; |
| 2043 | 2043 | } |
| 2044 | 2044 | |
@@ -2051,16 +2051,16 @@ discard block |
||
| 2051 | 2051 | * @param $arguments_to_provide |
| 2052 | 2052 | * @return string |
| 2053 | 2053 | */ |
| 2054 | - private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) { |
|
| 2054 | + private function _verify_addons_db($wpdb_method, $arguments_to_provide) { |
|
| 2055 | 2055 | /** @type WPDB $wpdb */ |
| 2056 | 2056 | global $wpdb; |
| 2057 | 2057 | //ok remember that we've already attempted fixing the addons dbs, in case the problem persists |
| 2058 | 2058 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons; |
| 2059 | 2059 | $error_message = sprintf( |
| 2060 | - __( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ), |
|
| 2060 | + __('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'), |
|
| 2061 | 2061 | $wpdb->last_error, |
| 2062 | 2062 | $wpdb_method, |
| 2063 | - json_encode( $arguments_to_provide ) |
|
| 2063 | + json_encode($arguments_to_provide) |
|
| 2064 | 2064 | ); |
| 2065 | 2065 | EE_System::instance()->initialize_addons(); |
| 2066 | 2066 | return $error_message; |
@@ -2075,7 +2075,7 @@ discard block |
||
| 2075 | 2075 | * @param EE_Model_Query_Info_Carrier $model_query_info |
| 2076 | 2076 | * @return string |
| 2077 | 2077 | */ |
| 2078 | - private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){ |
|
| 2078 | + private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) { |
|
| 2079 | 2079 | return " FROM ".$model_query_info->get_full_join_sql(). |
| 2080 | 2080 | $model_query_info->get_where_sql(). |
| 2081 | 2081 | $model_query_info->get_group_by_sql(). |
@@ -2088,7 +2088,7 @@ discard block |
||
| 2088 | 2088 | * Set to easily debug the next X queries ran from this model. |
| 2089 | 2089 | * @param int $count |
| 2090 | 2090 | */ |
| 2091 | - public function show_next_x_db_queries($count = 1){ |
|
| 2091 | + public function show_next_x_db_queries($count = 1) { |
|
| 2092 | 2092 | $this->_show_next_x_db_queries = $count; |
| 2093 | 2093 | } |
| 2094 | 2094 | |
@@ -2097,8 +2097,8 @@ discard block |
||
| 2097 | 2097 | /** |
| 2098 | 2098 | * @param $sql_query |
| 2099 | 2099 | */ |
| 2100 | - public function show_db_query_if_previously_requested($sql_query){ |
|
| 2101 | - if($this->_show_next_x_db_queries > 0){ |
|
| 2100 | + public function show_db_query_if_previously_requested($sql_query) { |
|
| 2101 | + if ($this->_show_next_x_db_queries > 0) { |
|
| 2102 | 2102 | echo $sql_query; |
| 2103 | 2103 | $this->_show_next_x_db_queries--; |
| 2104 | 2104 | } |
@@ -2122,9 +2122,9 @@ discard block |
||
| 2122 | 2122 | * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj |
| 2123 | 2123 | * @throws \EE_Error |
| 2124 | 2124 | */ |
| 2125 | - public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){ |
|
| 2125 | + public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) { |
|
| 2126 | 2126 | $relation_obj = $this->related_settings_for($relationName); |
| 2127 | - return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values); |
|
| 2127 | + return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values); |
|
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | 2130 | |
@@ -2143,9 +2143,9 @@ discard block |
||
| 2143 | 2143 | * @throws \EE_Error |
| 2144 | 2144 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
| 2145 | 2145 | */ |
| 2146 | - public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query= array() ){ |
|
| 2146 | + public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) { |
|
| 2147 | 2147 | $relation_obj = $this->related_settings_for($relationName); |
| 2148 | - return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query ); |
|
| 2148 | + return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query); |
|
| 2149 | 2149 | } |
| 2150 | 2150 | |
| 2151 | 2151 | |
@@ -2158,9 +2158,9 @@ discard block |
||
| 2158 | 2158 | * @return \EE_Base_Class[] |
| 2159 | 2159 | * @throws \EE_Error |
| 2160 | 2160 | */ |
| 2161 | - public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){ |
|
| 2161 | + public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) { |
|
| 2162 | 2162 | $relation_obj = $this->related_settings_for($relationName); |
| 2163 | - return $relation_obj->remove_relations($id_or_obj, $where_query_params ); |
|
| 2163 | + return $relation_obj->remove_relations($id_or_obj, $where_query_params); |
|
| 2164 | 2164 | } |
| 2165 | 2165 | |
| 2166 | 2166 | |
@@ -2176,10 +2176,10 @@ discard block |
||
| 2176 | 2176 | * @return EE_Base_Class[] |
| 2177 | 2177 | * @throws \EE_Error |
| 2178 | 2178 | */ |
| 2179 | - public function get_all_related($id_or_obj, $model_name, $query_params = null){ |
|
| 2179 | + public function get_all_related($id_or_obj, $model_name, $query_params = null) { |
|
| 2180 | 2180 | $model_obj = $this->ensure_is_obj($id_or_obj); |
| 2181 | 2181 | $relation_settings = $this->related_settings_for($model_name); |
| 2182 | - return $relation_settings->get_all_related($model_obj,$query_params); |
|
| 2182 | + return $relation_settings->get_all_related($model_obj, $query_params); |
|
| 2183 | 2183 | } |
| 2184 | 2184 | |
| 2185 | 2185 | |
@@ -2196,10 +2196,10 @@ discard block |
||
| 2196 | 2196 | * @return int how many deleted |
| 2197 | 2197 | * @throws \EE_Error |
| 2198 | 2198 | */ |
| 2199 | - public function delete_related($id_or_obj,$model_name, $query_params = array()){ |
|
| 2199 | + public function delete_related($id_or_obj, $model_name, $query_params = array()) { |
|
| 2200 | 2200 | $model_obj = $this->ensure_is_obj($id_or_obj); |
| 2201 | 2201 | $relation_settings = $this->related_settings_for($model_name); |
| 2202 | - return $relation_settings->delete_all_related($model_obj,$query_params); |
|
| 2202 | + return $relation_settings->delete_all_related($model_obj, $query_params); |
|
| 2203 | 2203 | } |
| 2204 | 2204 | |
| 2205 | 2205 | |
@@ -2216,10 +2216,10 @@ discard block |
||
| 2216 | 2216 | * @return int how many deleted |
| 2217 | 2217 | * @throws \EE_Error |
| 2218 | 2218 | */ |
| 2219 | - public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){ |
|
| 2219 | + public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) { |
|
| 2220 | 2220 | $model_obj = $this->ensure_is_obj($id_or_obj); |
| 2221 | 2221 | $relation_settings = $this->related_settings_for($model_name); |
| 2222 | - return $relation_settings->delete_related_permanently($model_obj,$query_params); |
|
| 2222 | + return $relation_settings->delete_related_permanently($model_obj, $query_params); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | 2225 | |
@@ -2236,17 +2236,17 @@ discard block |
||
| 2236 | 2236 | * @return int |
| 2237 | 2237 | * @throws \EE_Error |
| 2238 | 2238 | */ |
| 2239 | - public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){ |
|
| 2239 | + public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) { |
|
| 2240 | 2240 | $related_model = $this->get_related_model_obj($model_name); |
| 2241 | 2241 | //we're just going to use the query params on the related model's normal get_all query, |
| 2242 | 2242 | //except add a condition to say to match the current mod |
| 2243 | - if( ! isset($query_params['default_where_conditions'])){ |
|
| 2244 | - $query_params['default_where_conditions']='none'; |
|
| 2243 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
| 2244 | + $query_params['default_where_conditions'] = 'none'; |
|
| 2245 | 2245 | } |
| 2246 | 2246 | $this_model_name = $this->get_this_model_name(); |
| 2247 | 2247 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
| 2248 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
| 2249 | - return $related_model->count($query_params,$field_to_count,$distinct); |
|
| 2248 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
| 2249 | + return $related_model->count($query_params, $field_to_count, $distinct); |
|
| 2250 | 2250 | } |
| 2251 | 2251 | |
| 2252 | 2252 | |
@@ -2262,21 +2262,21 @@ discard block |
||
| 2262 | 2262 | * @return float |
| 2263 | 2263 | * @throws \EE_Error |
| 2264 | 2264 | */ |
| 2265 | - public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){ |
|
| 2265 | + public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) { |
|
| 2266 | 2266 | $related_model = $this->get_related_model_obj($model_name); |
| 2267 | - if( ! is_array( $query_params ) ){ |
|
| 2268 | - EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
| 2267 | + if ( ! is_array($query_params)) { |
|
| 2268 | + EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
| 2269 | 2269 | $query_params = array(); |
| 2270 | 2270 | } |
| 2271 | 2271 | //we're just going to use the query params on the related model's normal get_all query, |
| 2272 | 2272 | //except add a condition to say to match the current mod |
| 2273 | - if( ! isset($query_params['default_where_conditions'])){ |
|
| 2274 | - $query_params['default_where_conditions']='none'; |
|
| 2273 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
| 2274 | + $query_params['default_where_conditions'] = 'none'; |
|
| 2275 | 2275 | } |
| 2276 | 2276 | $this_model_name = $this->get_this_model_name(); |
| 2277 | 2277 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
| 2278 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
| 2279 | - return $related_model->sum($query_params,$field_to_sum); |
|
| 2278 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
| 2279 | + return $related_model->sum($query_params, $field_to_sum); |
|
| 2280 | 2280 | } |
| 2281 | 2281 | |
| 2282 | 2282 | |
@@ -2290,12 +2290,12 @@ discard block |
||
| 2290 | 2290 | * @return EE_Base_Class |
| 2291 | 2291 | * @throws \EE_Error |
| 2292 | 2292 | */ |
| 2293 | - public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){ |
|
| 2294 | - $query_params['limit']=1; |
|
| 2295 | - $results = $this->get_all_related($id_or_obj,$other_model_name,$query_params); |
|
| 2296 | - if( $results ){ |
|
| 2293 | + public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) { |
|
| 2294 | + $query_params['limit'] = 1; |
|
| 2295 | + $results = $this->get_all_related($id_or_obj, $other_model_name, $query_params); |
|
| 2296 | + if ($results) { |
|
| 2297 | 2297 | return array_shift($results); |
| 2298 | - }else{ |
|
| 2298 | + } else { |
|
| 2299 | 2299 | return null; |
| 2300 | 2300 | } |
| 2301 | 2301 | |
@@ -2305,8 +2305,8 @@ discard block |
||
| 2305 | 2305 | * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event |
| 2306 | 2306 | * @return string |
| 2307 | 2307 | */ |
| 2308 | - public function get_this_model_name(){ |
|
| 2309 | - return str_replace("EEM_","",get_class($this)); |
|
| 2308 | + public function get_this_model_name() { |
|
| 2309 | + return str_replace("EEM_", "", get_class($this)); |
|
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | 2312 | /** |
@@ -2314,14 +2314,14 @@ discard block |
||
| 2314 | 2314 | * @return EE_Any_Foreign_Model_Name_Field |
| 2315 | 2315 | * @throws EE_Error |
| 2316 | 2316 | */ |
| 2317 | - public function get_field_containing_related_model_name(){ |
|
| 2318 | - foreach($this->field_settings(true) as $field){ |
|
| 2319 | - if($field instanceof EE_Any_Foreign_Model_Name_Field){ |
|
| 2317 | + public function get_field_containing_related_model_name() { |
|
| 2318 | + foreach ($this->field_settings(true) as $field) { |
|
| 2319 | + if ($field instanceof EE_Any_Foreign_Model_Name_Field) { |
|
| 2320 | 2320 | $field_with_model_name = $field; |
| 2321 | 2321 | } |
| 2322 | 2322 | } |
| 2323 | - if( !isset($field_with_model_name) || !$field_with_model_name ){ |
|
| 2324 | - throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() )); |
|
| 2323 | + if ( ! isset($field_with_model_name) || ! $field_with_model_name) { |
|
| 2324 | + throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name())); |
|
| 2325 | 2325 | } |
| 2326 | 2326 | return $field_with_model_name; |
| 2327 | 2327 | } |
@@ -2342,19 +2342,19 @@ discard block |
||
| 2342 | 2342 | * @return int new primary key on main table that got inserted |
| 2343 | 2343 | * @throws EE_Error |
| 2344 | 2344 | */ |
| 2345 | - public function insert($field_n_values){ |
|
| 2345 | + public function insert($field_n_values) { |
|
| 2346 | 2346 | /** |
| 2347 | 2347 | * Filters the fields and their values before inserting an item using the models |
| 2348 | 2348 | * @param array $fields_n_values keys are the fields and values are their new values |
| 2349 | 2349 | * @param EEM_Base $model the model used |
| 2350 | 2350 | */ |
| 2351 | - $field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this ); |
|
| 2352 | - if($this->_satisfies_unique_indexes($field_n_values)){ |
|
| 2351 | + $field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this); |
|
| 2352 | + if ($this->_satisfies_unique_indexes($field_n_values)) { |
|
| 2353 | 2353 | $main_table = $this->_get_main_table(); |
| 2354 | 2354 | $new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false); |
| 2355 | - if( $new_id !== false ) { |
|
| 2356 | - foreach($this->_get_other_tables() as $other_table){ |
|
| 2357 | - $this->_insert_into_specific_table($other_table, $field_n_values,$new_id); |
|
| 2355 | + if ($new_id !== false) { |
|
| 2356 | + foreach ($this->_get_other_tables() as $other_table) { |
|
| 2357 | + $this->_insert_into_specific_table($other_table, $field_n_values, $new_id); |
|
| 2358 | 2358 | } |
| 2359 | 2359 | } |
| 2360 | 2360 | /** |
@@ -2364,9 +2364,9 @@ discard block |
||
| 2364 | 2364 | * @param array $fields_n_values fields and their values |
| 2365 | 2365 | * @param int|string the ID of the newly-inserted model object |
| 2366 | 2366 | */ |
| 2367 | - do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id ); |
|
| 2367 | + do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id); |
|
| 2368 | 2368 | return $new_id; |
| 2369 | - }else{ |
|
| 2369 | + } else { |
|
| 2370 | 2370 | return FALSE; |
| 2371 | 2371 | } |
| 2372 | 2372 | } |
@@ -2381,10 +2381,10 @@ discard block |
||
| 2381 | 2381 | * @return boolean |
| 2382 | 2382 | * @throws \EE_Error |
| 2383 | 2383 | */ |
| 2384 | - protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){ |
|
| 2385 | - foreach($this->unique_indexes() as $index_name => $index){ |
|
| 2384 | + protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') { |
|
| 2385 | + foreach ($this->unique_indexes() as $index_name => $index) { |
|
| 2386 | 2386 | $uniqueness_where_params = array_intersect_key($field_n_values, $index->fields()); |
| 2387 | - if($this->exists(array($uniqueness_where_params))){ |
|
| 2387 | + if ($this->exists(array($uniqueness_where_params))) { |
|
| 2388 | 2388 | EE_Error::add_error( |
| 2389 | 2389 | sprintf( |
| 2390 | 2390 | __( |
@@ -2394,8 +2394,8 @@ discard block |
||
| 2394 | 2394 | $action, |
| 2395 | 2395 | $this->_get_class_name(), |
| 2396 | 2396 | $index_name, |
| 2397 | - implode( ",", $index->field_names() ), |
|
| 2398 | - http_build_query( $uniqueness_where_params ) |
|
| 2397 | + implode(",", $index->field_names()), |
|
| 2398 | + http_build_query($uniqueness_where_params) |
|
| 2399 | 2399 | ), |
| 2400 | 2400 | __FILE__, |
| 2401 | 2401 | __FUNCTION__, |
@@ -2425,37 +2425,37 @@ discard block |
||
| 2425 | 2425 | * @throws EE_Error |
| 2426 | 2426 | * @return EE_Base_Class|array |
| 2427 | 2427 | */ |
| 2428 | - public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){ |
|
| 2429 | - if($obj_or_fields_array instanceof EE_Base_Class){ |
|
| 2428 | + public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) { |
|
| 2429 | + if ($obj_or_fields_array instanceof EE_Base_Class) { |
|
| 2430 | 2430 | $fields_n_values = $obj_or_fields_array->model_field_array(); |
| 2431 | - }elseif( is_array($obj_or_fields_array)){ |
|
| 2431 | + }elseif (is_array($obj_or_fields_array)) { |
|
| 2432 | 2432 | $fields_n_values = $obj_or_fields_array; |
| 2433 | - }else{ |
|
| 2433 | + } else { |
|
| 2434 | 2434 | throw new EE_Error( |
| 2435 | 2435 | sprintf( |
| 2436 | 2436 | __( |
| 2437 | 2437 | "%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", |
| 2438 | 2438 | "event_espresso" |
| 2439 | 2439 | ), |
| 2440 | - get_class( $this ), |
|
| 2440 | + get_class($this), |
|
| 2441 | 2441 | $obj_or_fields_array |
| 2442 | 2442 | ) |
| 2443 | 2443 | ); |
| 2444 | 2444 | } |
| 2445 | 2445 | $query_params = array(); |
| 2446 | - if( $this->has_primary_key_field() && |
|
| 2447 | - ( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
| 2448 | - isset($fields_n_values[$this->primary_key_name()])){ |
|
| 2446 | + if ($this->has_primary_key_field() && |
|
| 2447 | + ($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
| 2448 | + isset($fields_n_values[$this->primary_key_name()])) { |
|
| 2449 | 2449 | $query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()]; |
| 2450 | 2450 | } |
| 2451 | - foreach($this->unique_indexes() as $unique_index_name=>$unique_index){ |
|
| 2451 | + foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) { |
|
| 2452 | 2452 | $uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields()); |
| 2453 | 2453 | $query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params; |
| 2454 | 2454 | } |
| 2455 | 2455 | //if there is nothing to base this search on, then we shouldn't find anything |
| 2456 | - if( empty( $query_params ) ){ |
|
| 2456 | + if (empty($query_params)) { |
|
| 2457 | 2457 | return array(); |
| 2458 | - }else{ |
|
| 2458 | + } else { |
|
| 2459 | 2459 | return $this->get_one($query_params); |
| 2460 | 2460 | } |
| 2461 | 2461 | } |
@@ -2469,7 +2469,7 @@ discard block |
||
| 2469 | 2469 | * @return boolean |
| 2470 | 2470 | * @throws \EE_Error |
| 2471 | 2471 | */ |
| 2472 | - public function exists($query_params){ |
|
| 2472 | + public function exists($query_params) { |
|
| 2473 | 2473 | $query_params['limit'] = 1; |
| 2474 | 2474 | return $this->count($query_params) > 0; |
| 2475 | 2475 | } |
@@ -2483,7 +2483,7 @@ discard block |
||
| 2483 | 2483 | * @return boolean |
| 2484 | 2484 | * @throws \EE_Error |
| 2485 | 2485 | */ |
| 2486 | - public function exists_by_ID($id){ |
|
| 2486 | + public function exists_by_ID($id) { |
|
| 2487 | 2487 | return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id))); |
| 2488 | 2488 | } |
| 2489 | 2489 | |
@@ -2503,45 +2503,45 @@ discard block |
||
| 2503 | 2503 | * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert |
| 2504 | 2504 | * @return int ID of new row inserted, or FALSE on failure |
| 2505 | 2505 | */ |
| 2506 | - protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){ |
|
| 2506 | + protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) { |
|
| 2507 | 2507 | global $wpdb; |
| 2508 | 2508 | $insertion_col_n_values = array(); |
| 2509 | 2509 | $format_for_insertion = array(); |
| 2510 | 2510 | $fields_on_table = $this->_get_fields_for_table($table->get_table_alias()); |
| 2511 | - foreach($fields_on_table as $field_name => $field_obj){ |
|
| 2511 | + foreach ($fields_on_table as $field_name => $field_obj) { |
|
| 2512 | 2512 | //check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing |
| 2513 | - if($field_obj->is_auto_increment()){ |
|
| 2513 | + if ($field_obj->is_auto_increment()) { |
|
| 2514 | 2514 | continue; |
| 2515 | 2515 | } |
| 2516 | 2516 | $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
| 2517 | 2517 | //if the value we want to assign it to is NULL, just don't mention it for the insertion |
| 2518 | - if( $prepared_value !== NULL ){ |
|
| 2519 | - $insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value; |
|
| 2518 | + if ($prepared_value !== NULL) { |
|
| 2519 | + $insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value; |
|
| 2520 | 2520 | $format_for_insertion[] = $field_obj->get_wpdb_data_type(); |
| 2521 | 2521 | } |
| 2522 | 2522 | } |
| 2523 | 2523 | |
| 2524 | - if($table instanceof EE_Secondary_Table && $new_id){ |
|
| 2524 | + if ($table instanceof EE_Secondary_Table && $new_id) { |
|
| 2525 | 2525 | //its not the main table, so we should have already saved the main table's PK which we just inserted |
| 2526 | 2526 | //so add the fk to the main table as a column |
| 2527 | 2527 | $insertion_col_n_values[$table->get_fk_on_table()] = $new_id; |
| 2528 | - $format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs |
|
| 2528 | + $format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs |
|
| 2529 | 2529 | } |
| 2530 | 2530 | //insert the new entry |
| 2531 | - $result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) ); |
|
| 2532 | - if( $result === false ) { |
|
| 2531 | + $result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion)); |
|
| 2532 | + if ($result === false) { |
|
| 2533 | 2533 | return false; |
| 2534 | 2534 | } |
| 2535 | 2535 | //ok, now what do we return for the ID of the newly-inserted thing? |
| 2536 | - if($this->has_primary_key_field()){ |
|
| 2537 | - if($this->get_primary_key_field()->is_auto_increment()){ |
|
| 2536 | + if ($this->has_primary_key_field()) { |
|
| 2537 | + if ($this->get_primary_key_field()->is_auto_increment()) { |
|
| 2538 | 2538 | return $wpdb->insert_id; |
| 2539 | - }else{ |
|
| 2539 | + } else { |
|
| 2540 | 2540 | //it's not an auto-increment primary key, so |
| 2541 | 2541 | //it must have been supplied |
| 2542 | 2542 | return $fields_n_values[$this->get_primary_key_field()->get_name()]; |
| 2543 | 2543 | } |
| 2544 | - }else{ |
|
| 2544 | + } else { |
|
| 2545 | 2545 | //we can't return a primary key because there is none. instead return |
| 2546 | 2546 | //a unique string indicating this model |
| 2547 | 2547 | return $this->get_index_primary_key_string($fields_n_values); |
@@ -2560,15 +2560,15 @@ discard block |
||
| 2560 | 2560 | * @return mixed string|int|float depending on what the table column will be expecting |
| 2561 | 2561 | * @throws \EE_Error |
| 2562 | 2562 | */ |
| 2563 | - protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){ |
|
| 2563 | + protected function _prepare_value_or_use_default($field_obj, $fields_n_values) { |
|
| 2564 | 2564 | //if this field doesn't allow nullable, don't allow it |
| 2565 | - if( ! $field_obj->is_nullable() && ( |
|
| 2566 | - ! isset( $fields_n_values[ $field_obj->get_name() ] ) || |
|
| 2567 | - $fields_n_values[ $field_obj->get_name() ] === NULL ) ){ |
|
| 2568 | - $fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value(); |
|
| 2565 | + if ( ! $field_obj->is_nullable() && ( |
|
| 2566 | + ! isset($fields_n_values[$field_obj->get_name()]) || |
|
| 2567 | + $fields_n_values[$field_obj->get_name()] === NULL )) { |
|
| 2568 | + $fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value(); |
|
| 2569 | 2569 | } |
| 2570 | - $unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL; |
|
| 2571 | - return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj); |
|
| 2570 | + $unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL; |
|
| 2571 | + return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj); |
|
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | 2574 | |
@@ -2580,9 +2580,9 @@ discard block |
||
| 2580 | 2580 | * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection |
| 2581 | 2581 | * @return mixed a value ready for use in the database for insertions, updating, or in a where clause |
| 2582 | 2582 | */ |
| 2583 | - private function _prepare_value_for_use_in_db($value, $field){ |
|
| 2584 | - if($field && $field instanceof EE_Model_Field_Base){ |
|
| 2585 | - switch( $this->_values_already_prepared_by_model_object ){ |
|
| 2583 | + private function _prepare_value_for_use_in_db($value, $field) { |
|
| 2584 | + if ($field && $field instanceof EE_Model_Field_Base) { |
|
| 2585 | + switch ($this->_values_already_prepared_by_model_object) { |
|
| 2586 | 2586 | /** @noinspection PhpMissingBreakStatementInspection */ |
| 2587 | 2587 | case self::not_prepared_by_model_object: |
| 2588 | 2588 | $value = $field->prepare_for_set($value); |
@@ -2593,7 +2593,7 @@ discard block |
||
| 2593 | 2593 | //leave the value alone |
| 2594 | 2594 | } |
| 2595 | 2595 | return $value; |
| 2596 | - }else{ |
|
| 2596 | + } else { |
|
| 2597 | 2597 | return $value; |
| 2598 | 2598 | } |
| 2599 | 2599 | } |
@@ -2603,13 +2603,13 @@ discard block |
||
| 2603 | 2603 | * @return EE_Primary_Table |
| 2604 | 2604 | * @throws EE_Error |
| 2605 | 2605 | */ |
| 2606 | - protected function _get_main_table(){ |
|
| 2607 | - foreach($this->_tables as $table){ |
|
| 2608 | - if($table instanceof EE_Primary_Table){ |
|
| 2606 | + protected function _get_main_table() { |
|
| 2607 | + foreach ($this->_tables as $table) { |
|
| 2608 | + if ($table instanceof EE_Primary_Table) { |
|
| 2609 | 2609 | return $table; |
| 2610 | 2610 | } |
| 2611 | 2611 | } |
| 2612 | - throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this))); |
|
| 2612 | + throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this))); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | |
| 2615 | 2615 | |
@@ -2632,7 +2632,7 @@ discard block |
||
| 2632 | 2632 | */ |
| 2633 | 2633 | public function second_table() { |
| 2634 | 2634 | // grab second table from tables array |
| 2635 | - $second_table = end( $this->_tables ); |
|
| 2635 | + $second_table = end($this->_tables); |
|
| 2636 | 2636 | return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL; |
| 2637 | 2637 | } |
| 2638 | 2638 | |
@@ -2645,8 +2645,8 @@ discard block |
||
| 2645 | 2645 | * @param string $table_alias |
| 2646 | 2646 | * @return EE_Primary_Table | EE_Secondary_Table |
| 2647 | 2647 | */ |
| 2648 | - public function get_table_obj_by_alias( $table_alias = '' ) { |
|
| 2649 | - return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL; |
|
| 2648 | + public function get_table_obj_by_alias($table_alias = '') { |
|
| 2649 | + return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL; |
|
| 2650 | 2650 | } |
| 2651 | 2651 | |
| 2652 | 2652 | |
@@ -2655,10 +2655,10 @@ discard block |
||
| 2655 | 2655 | * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables |
| 2656 | 2656 | * @return EE_Secondary_Table[] |
| 2657 | 2657 | */ |
| 2658 | - protected function _get_other_tables(){ |
|
| 2659 | - $other_tables =array(); |
|
| 2660 | - foreach($this->_tables as $table_alias => $table){ |
|
| 2661 | - if($table instanceof EE_Secondary_Table){ |
|
| 2658 | + protected function _get_other_tables() { |
|
| 2659 | + $other_tables = array(); |
|
| 2660 | + foreach ($this->_tables as $table_alias => $table) { |
|
| 2661 | + if ($table instanceof EE_Secondary_Table) { |
|
| 2662 | 2662 | $other_tables[$table_alias] = $table; |
| 2663 | 2663 | } |
| 2664 | 2664 | } |
@@ -2670,7 +2670,7 @@ discard block |
||
| 2670 | 2670 | * @param string $table_alias, array key in EEM_Base::_tables |
| 2671 | 2671 | * @return EE_Model_Field_Base[] |
| 2672 | 2672 | */ |
| 2673 | - public function _get_fields_for_table($table_alias){ |
|
| 2673 | + public function _get_fields_for_table($table_alias) { |
|
| 2674 | 2674 | return $this->_fields[$table_alias]; |
| 2675 | 2675 | } |
| 2676 | 2676 | |
@@ -2686,19 +2686,19 @@ discard block |
||
| 2686 | 2686 | * @return EE_Model_Query_Info_Carrier |
| 2687 | 2687 | * @throws \EE_Error |
| 2688 | 2688 | */ |
| 2689 | - public function _extract_related_models_from_query($query_params){ |
|
| 2689 | + public function _extract_related_models_from_query($query_params) { |
|
| 2690 | 2690 | $query_info_carrier = new EE_Model_Query_Info_Carrier(); |
| 2691 | - if ( array_key_exists( 0, $query_params ) ) { |
|
| 2692 | - $this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 ); |
|
| 2691 | + if (array_key_exists(0, $query_params)) { |
|
| 2692 | + $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0); |
|
| 2693 | 2693 | } |
| 2694 | - if ( array_key_exists( 'group_by', $query_params ) ) { |
|
| 2695 | - if ( is_array( $query_params['group_by'] ) ) { |
|
| 2694 | + if (array_key_exists('group_by', $query_params)) { |
|
| 2695 | + if (is_array($query_params['group_by'])) { |
|
| 2696 | 2696 | $this->_extract_related_models_from_sub_params_array_values( |
| 2697 | 2697 | $query_params['group_by'], |
| 2698 | 2698 | $query_info_carrier, |
| 2699 | 2699 | 'group_by' |
| 2700 | 2700 | ); |
| 2701 | - } elseif ( ! empty ( $query_params['group_by'] ) ) { |
|
| 2701 | + } elseif ( ! empty ($query_params['group_by'])) { |
|
| 2702 | 2702 | $this->_extract_related_model_info_from_query_param( |
| 2703 | 2703 | $query_params['group_by'], |
| 2704 | 2704 | $query_info_carrier, |
@@ -2706,21 +2706,21 @@ discard block |
||
| 2706 | 2706 | ); |
| 2707 | 2707 | } |
| 2708 | 2708 | } |
| 2709 | - if ( array_key_exists( 'having', $query_params ) ) { |
|
| 2709 | + if (array_key_exists('having', $query_params)) { |
|
| 2710 | 2710 | $this->_extract_related_models_from_sub_params_array_keys( |
| 2711 | 2711 | $query_params[0], |
| 2712 | 2712 | $query_info_carrier, |
| 2713 | 2713 | 'having' |
| 2714 | 2714 | ); |
| 2715 | 2715 | } |
| 2716 | - if ( array_key_exists( 'order_by', $query_params ) ) { |
|
| 2717 | - if ( is_array( $query_params['order_by'] ) ) { |
|
| 2716 | + if (array_key_exists('order_by', $query_params)) { |
|
| 2717 | + if (is_array($query_params['order_by'])) { |
|
| 2718 | 2718 | $this->_extract_related_models_from_sub_params_array_keys( |
| 2719 | 2719 | $query_params['order_by'], |
| 2720 | 2720 | $query_info_carrier, |
| 2721 | 2721 | 'order_by' |
| 2722 | 2722 | ); |
| 2723 | - } elseif ( ! empty( $query_params['order_by'] ) ) { |
|
| 2723 | + } elseif ( ! empty($query_params['order_by'])) { |
|
| 2724 | 2724 | $this->_extract_related_model_info_from_query_param( |
| 2725 | 2725 | $query_params['order_by'], |
| 2726 | 2726 | $query_info_carrier, |
@@ -2728,7 +2728,7 @@ discard block |
||
| 2728 | 2728 | ); |
| 2729 | 2729 | } |
| 2730 | 2730 | } |
| 2731 | - if ( array_key_exists( 'force_join', $query_params ) ) { |
|
| 2731 | + if (array_key_exists('force_join', $query_params)) { |
|
| 2732 | 2732 | $this->_extract_related_models_from_sub_params_array_values( |
| 2733 | 2733 | $query_params['force_join'], |
| 2734 | 2734 | $query_info_carrier, |
@@ -2746,34 +2746,34 @@ discard block |
||
| 2746 | 2746 | * @throws EE_Error |
| 2747 | 2747 | * @return \EE_Model_Query_Info_Carrier |
| 2748 | 2748 | */ |
| 2749 | - private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
| 2750 | - if (!empty($sub_query_params)){ |
|
| 2749 | + private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
| 2750 | + if ( ! empty($sub_query_params)) { |
|
| 2751 | 2751 | $sub_query_params = (array) $sub_query_params; |
| 2752 | - foreach($sub_query_params as $param => $possibly_array_of_params){ |
|
| 2752 | + foreach ($sub_query_params as $param => $possibly_array_of_params) { |
|
| 2753 | 2753 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
| 2754 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type); |
|
| 2754 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
| 2755 | 2755 | |
| 2756 | 2756 | //if $possibly_array_of_params is an array, try recursing into it, searching for keys which |
| 2757 | 2757 | //indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried |
| 2758 | 2758 | //extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value |
| 2759 | 2759 | //of array('Registration.TXN_ID'=>23) |
| 2760 | 2760 | $query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param); |
| 2761 | - if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){ |
|
| 2762 | - if (! is_array($possibly_array_of_params)){ |
|
| 2761 | + if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) { |
|
| 2762 | + if ( ! is_array($possibly_array_of_params)) { |
|
| 2763 | 2763 | throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"), |
| 2764 | - $param,$possibly_array_of_params)); |
|
| 2765 | - }else{ |
|
| 2766 | - $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type); |
|
| 2764 | + $param, $possibly_array_of_params)); |
|
| 2765 | + } else { |
|
| 2766 | + $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type); |
|
| 2767 | 2767 | } |
| 2768 | - }elseif($query_param_type === 0 //ie WHERE |
|
| 2768 | + }elseif ($query_param_type === 0 //ie WHERE |
|
| 2769 | 2769 | && is_array($possibly_array_of_params) |
| 2770 | 2770 | && isset($possibly_array_of_params[2]) |
| 2771 | - && $possibly_array_of_params[2] == true){ |
|
| 2771 | + && $possibly_array_of_params[2] == true) { |
|
| 2772 | 2772 | //then $possible_array_of_params looks something like array('<','DTT_sold',true) |
| 2773 | 2773 | //indicating that $possible_array_of_params[1] is actually a field name, |
| 2774 | 2774 | //from which we should extract query parameters! |
| 2775 | - if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) { |
|
| 2776 | - throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params))); |
|
| 2775 | + if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) { |
|
| 2776 | + throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params))); |
|
| 2777 | 2777 | } |
| 2778 | 2778 | $this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type); |
| 2779 | 2779 | } |
@@ -2792,14 +2792,14 @@ discard block |
||
| 2792 | 2792 | * @throws EE_Error |
| 2793 | 2793 | * @return \EE_Model_Query_Info_Carrier |
| 2794 | 2794 | */ |
| 2795 | - private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
| 2796 | - if (!empty($sub_query_params)){ |
|
| 2797 | - if(!is_array($sub_query_params)){ |
|
| 2798 | - throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params)); |
|
| 2795 | + private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
| 2796 | + if ( ! empty($sub_query_params)) { |
|
| 2797 | + if ( ! is_array($sub_query_params)) { |
|
| 2798 | + throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params)); |
|
| 2799 | 2799 | } |
| 2800 | - foreach($sub_query_params as $param){ |
|
| 2800 | + foreach ($sub_query_params as $param) { |
|
| 2801 | 2801 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
| 2802 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type); |
|
| 2802 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
| 2803 | 2803 | } |
| 2804 | 2804 | } |
| 2805 | 2805 | return $model_query_info_carrier; |
@@ -2818,8 +2818,8 @@ discard block |
||
| 2818 | 2818 | * @throws EE_Error |
| 2819 | 2819 | * @return EE_Model_Query_Info_Carrier |
| 2820 | 2820 | */ |
| 2821 | - public function _create_model_query_info_carrier($query_params){ |
|
| 2822 | - if ( ! is_array( $query_params ) ) { |
|
| 2821 | + public function _create_model_query_info_carrier($query_params) { |
|
| 2822 | + if ( ! is_array($query_params)) { |
|
| 2823 | 2823 | EE_Error::doing_it_wrong( |
| 2824 | 2824 | 'EEM_Base::_create_model_query_info_carrier', |
| 2825 | 2825 | sprintf( |
@@ -2827,16 +2827,16 @@ discard block |
||
| 2827 | 2827 | '$query_params should be an array, you passed a variable of type %s', |
| 2828 | 2828 | 'event_espresso' |
| 2829 | 2829 | ), |
| 2830 | - gettype( $query_params ) |
|
| 2830 | + gettype($query_params) |
|
| 2831 | 2831 | ), |
| 2832 | 2832 | '4.6.0' |
| 2833 | 2833 | ); |
| 2834 | 2834 | $query_params = array(); |
| 2835 | 2835 | } |
| 2836 | - $where_query_params = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
| 2836 | + $where_query_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 2837 | 2837 | //first check if we should alter the query to account for caps or not |
| 2838 | 2838 | //because the caps might require us to do extra joins |
| 2839 | - if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) { |
|
| 2839 | + if (isset($query_params['caps']) && $query_params['caps'] !== 'none') { |
|
| 2840 | 2840 | $query_params[0] = $where_query_params = array_replace_recursive( |
| 2841 | 2841 | $where_query_params, |
| 2842 | 2842 | $this->caps_where_conditions( |
@@ -2844,10 +2844,10 @@ discard block |
||
| 2844 | 2844 | ) |
| 2845 | 2845 | ); |
| 2846 | 2846 | } |
| 2847 | - $query_object = $this->_extract_related_models_from_query( $query_params ); |
|
| 2847 | + $query_object = $this->_extract_related_models_from_query($query_params); |
|
| 2848 | 2848 | //verify where_query_params has NO numeric indexes.... that's simply not how you use it! |
| 2849 | - foreach ( $where_query_params as $key => $value ) { |
|
| 2850 | - if ( is_int( $key ) ) { |
|
| 2849 | + foreach ($where_query_params as $key => $value) { |
|
| 2850 | + if (is_int($key)) { |
|
| 2851 | 2851 | throw new EE_Error( |
| 2852 | 2852 | sprintf( |
| 2853 | 2853 | __( |
@@ -2855,16 +2855,16 @@ discard block |
||
| 2855 | 2855 | "event_espresso" |
| 2856 | 2856 | ), |
| 2857 | 2857 | $key, |
| 2858 | - var_export( $value, true ), |
|
| 2859 | - var_export( $query_params, true ), |
|
| 2860 | - get_class( $this ) |
|
| 2858 | + var_export($value, true), |
|
| 2859 | + var_export($query_params, true), |
|
| 2860 | + get_class($this) |
|
| 2861 | 2861 | ) |
| 2862 | 2862 | ); |
| 2863 | 2863 | } |
| 2864 | 2864 | } |
| 2865 | 2865 | if ( |
| 2866 | - array_key_exists( 'default_where_conditions', $query_params ) |
|
| 2867 | - && ! empty( $query_params['default_where_conditions'] ) |
|
| 2866 | + array_key_exists('default_where_conditions', $query_params) |
|
| 2867 | + && ! empty($query_params['default_where_conditions']) |
|
| 2868 | 2868 | ) { |
| 2869 | 2869 | $use_default_where_conditions = $query_params['default_where_conditions']; |
| 2870 | 2870 | } else { |
@@ -2878,13 +2878,13 @@ discard block |
||
| 2878 | 2878 | ), |
| 2879 | 2879 | $where_query_params |
| 2880 | 2880 | ); |
| 2881 | - $query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) ); |
|
| 2881 | + $query_object->set_where_sql($this->_construct_where_clause($where_query_params)); |
|
| 2882 | 2882 | // if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join. |
| 2883 | 2883 | // So we need to setup a subquery and use that for the main join. |
| 2884 | 2884 | // Note for now this only works on the primary table for the model. |
| 2885 | 2885 | // So for instance, you could set the limit array like this: |
| 2886 | 2886 | // array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) ) |
| 2887 | - if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) { |
|
| 2887 | + if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) { |
|
| 2888 | 2888 | $query_object->set_main_model_join_sql( |
| 2889 | 2889 | $this->_construct_limit_join_select( |
| 2890 | 2890 | $query_params['on_join_limit'][0], |
@@ -2893,40 +2893,40 @@ discard block |
||
| 2893 | 2893 | ); |
| 2894 | 2894 | } |
| 2895 | 2895 | //set limit |
| 2896 | - if ( array_key_exists( 'limit', $query_params ) ) { |
|
| 2897 | - if ( is_array( $query_params['limit'] ) ) { |
|
| 2898 | - if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) { |
|
| 2896 | + if (array_key_exists('limit', $query_params)) { |
|
| 2897 | + if (is_array($query_params['limit'])) { |
|
| 2898 | + if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) { |
|
| 2899 | 2899 | $e = sprintf( |
| 2900 | 2900 | __( |
| 2901 | 2901 | "Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", |
| 2902 | 2902 | "event_espresso" |
| 2903 | 2903 | ), |
| 2904 | - http_build_query( $query_params['limit'] ) |
|
| 2904 | + http_build_query($query_params['limit']) |
|
| 2905 | 2905 | ); |
| 2906 | - throw new EE_Error( $e . "|" . $e ); |
|
| 2906 | + throw new EE_Error($e."|".$e); |
|
| 2907 | 2907 | } |
| 2908 | 2908 | //they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25 |
| 2909 | - $query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] ); |
|
| 2910 | - } elseif ( ! empty ( $query_params['limit'] ) ) { |
|
| 2911 | - $query_object->set_limit_sql( " LIMIT " . $query_params['limit'] ); |
|
| 2909 | + $query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]); |
|
| 2910 | + } elseif ( ! empty ($query_params['limit'])) { |
|
| 2911 | + $query_object->set_limit_sql(" LIMIT ".$query_params['limit']); |
|
| 2912 | 2912 | } |
| 2913 | 2913 | } |
| 2914 | 2914 | //set order by |
| 2915 | - if ( array_key_exists( 'order_by', $query_params ) ) { |
|
| 2916 | - if ( is_array( $query_params['order_by'] ) ) { |
|
| 2915 | + if (array_key_exists('order_by', $query_params)) { |
|
| 2916 | + if (is_array($query_params['order_by'])) { |
|
| 2917 | 2917 | //if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must |
| 2918 | 2918 | //specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So |
| 2919 | 2919 | //including 'order' wouldn't make any sense if 'order_by' has already specified which way to order! |
| 2920 | - if ( array_key_exists( 'order', $query_params ) ) { |
|
| 2920 | + if (array_key_exists('order', $query_params)) { |
|
| 2921 | 2921 | throw new EE_Error( |
| 2922 | 2922 | sprintf( |
| 2923 | 2923 | __( |
| 2924 | 2924 | "In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", |
| 2925 | 2925 | "event_espresso" |
| 2926 | 2926 | ), |
| 2927 | - get_class( $this ), |
|
| 2928 | - implode( ", ", array_keys( $query_params['order_by'] ) ), |
|
| 2929 | - implode( ", ", $query_params['order_by'] ), |
|
| 2927 | + get_class($this), |
|
| 2928 | + implode(", ", array_keys($query_params['order_by'])), |
|
| 2929 | + implode(", ", $query_params['order_by']), |
|
| 2930 | 2930 | $query_params['order'] |
| 2931 | 2931 | ) |
| 2932 | 2932 | ); |
@@ -2938,57 +2938,57 @@ discard block |
||
| 2938 | 2938 | ); |
| 2939 | 2939 | //assume it's an array of fields to order by |
| 2940 | 2940 | $order_array = array(); |
| 2941 | - foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) { |
|
| 2942 | - $order = $this->_extract_order( $order ); |
|
| 2943 | - $order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order; |
|
| 2941 | + foreach ($query_params['order_by'] as $field_name_to_order_by => $order) { |
|
| 2942 | + $order = $this->_extract_order($order); |
|
| 2943 | + $order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order; |
|
| 2944 | 2944 | } |
| 2945 | - $query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) ); |
|
| 2946 | - } elseif ( ! empty ( $query_params['order_by'] ) ) { |
|
| 2945 | + $query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array)); |
|
| 2946 | + } elseif ( ! empty ($query_params['order_by'])) { |
|
| 2947 | 2947 | $this->_extract_related_model_info_from_query_param( |
| 2948 | 2948 | $query_params['order_by'], |
| 2949 | 2949 | $query_object, |
| 2950 | 2950 | 'order', |
| 2951 | 2951 | $query_params['order_by'] |
| 2952 | 2952 | ); |
| 2953 | - $order = isset( $query_params['order'] ) |
|
| 2954 | - ? $this->_extract_order( $query_params['order'] ) |
|
| 2953 | + $order = isset($query_params['order']) |
|
| 2954 | + ? $this->_extract_order($query_params['order']) |
|
| 2955 | 2955 | : 'DESC'; |
| 2956 | 2956 | $query_object->set_order_by_sql( |
| 2957 | - " ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order |
|
| 2957 | + " ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order |
|
| 2958 | 2958 | ); |
| 2959 | 2959 | } |
| 2960 | 2960 | } |
| 2961 | 2961 | //if 'order_by' wasn't set, maybe they are just using 'order' on its own? |
| 2962 | - if ( ! array_key_exists( 'order_by', $query_params ) |
|
| 2963 | - && array_key_exists( 'order', $query_params ) |
|
| 2964 | - && ! empty( $query_params['order'] ) |
|
| 2962 | + if ( ! array_key_exists('order_by', $query_params) |
|
| 2963 | + && array_key_exists('order', $query_params) |
|
| 2964 | + && ! empty($query_params['order']) |
|
| 2965 | 2965 | ) { |
| 2966 | 2966 | $pk_field = $this->get_primary_key_field(); |
| 2967 | - $order = $this->_extract_order( $query_params['order'] ); |
|
| 2968 | - $query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order ); |
|
| 2967 | + $order = $this->_extract_order($query_params['order']); |
|
| 2968 | + $query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order); |
|
| 2969 | 2969 | } |
| 2970 | 2970 | //set group by |
| 2971 | - if ( array_key_exists( 'group_by', $query_params ) ) { |
|
| 2972 | - if ( is_array( $query_params['group_by'] ) ) { |
|
| 2971 | + if (array_key_exists('group_by', $query_params)) { |
|
| 2972 | + if (is_array($query_params['group_by'])) { |
|
| 2973 | 2973 | //it's an array, so assume we'll be grouping by a bunch of stuff |
| 2974 | 2974 | $group_by_array = array(); |
| 2975 | - foreach ( $query_params['group_by'] as $field_name_to_group_by ) { |
|
| 2976 | - $group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by ); |
|
| 2975 | + foreach ($query_params['group_by'] as $field_name_to_group_by) { |
|
| 2976 | + $group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by); |
|
| 2977 | 2977 | } |
| 2978 | - $query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) ); |
|
| 2979 | - } elseif ( ! empty ( $query_params['group_by'] ) ) { |
|
| 2978 | + $query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array)); |
|
| 2979 | + } elseif ( ! empty ($query_params['group_by'])) { |
|
| 2980 | 2980 | $query_object->set_group_by_sql( |
| 2981 | - " GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] ) |
|
| 2981 | + " GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']) |
|
| 2982 | 2982 | ); |
| 2983 | 2983 | } |
| 2984 | 2984 | } |
| 2985 | 2985 | //set having |
| 2986 | - if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) { |
|
| 2987 | - $query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) ); |
|
| 2986 | + if (array_key_exists('having', $query_params) && $query_params['having']) { |
|
| 2987 | + $query_object->set_having_sql($this->_construct_having_clause($query_params['having'])); |
|
| 2988 | 2988 | } |
| 2989 | 2989 | //now, just verify they didn't pass anything wack |
| 2990 | - foreach ( $query_params as $query_key => $query_value ) { |
|
| 2991 | - if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) { |
|
| 2990 | + foreach ($query_params as $query_key => $query_value) { |
|
| 2991 | + if ( ! in_array($query_key, $this->_allowed_query_params, true)) { |
|
| 2992 | 2992 | throw new EE_Error( |
| 2993 | 2993 | sprintf( |
| 2994 | 2994 | __( |
@@ -2996,16 +2996,16 @@ discard block |
||
| 2996 | 2996 | 'event_espresso' |
| 2997 | 2997 | ), |
| 2998 | 2998 | $query_key, |
| 2999 | - get_class( $this ), |
|
| 2999 | + get_class($this), |
|
| 3000 | 3000 | // print_r( $this->_allowed_query_params, TRUE ) |
| 3001 | - implode( ',', $this->_allowed_query_params ) |
|
| 3001 | + implode(',', $this->_allowed_query_params) |
|
| 3002 | 3002 | ) |
| 3003 | 3003 | ); |
| 3004 | 3004 | } |
| 3005 | 3005 | } |
| 3006 | 3006 | $main_model_join_sql = $query_object->get_main_model_join_sql(); |
| 3007 | - if ( empty( $main_model_join_sql ) ) { |
|
| 3008 | - $query_object->set_main_model_join_sql( $this->_construct_internal_join() ); |
|
| 3007 | + if (empty($main_model_join_sql)) { |
|
| 3008 | + $query_object->set_main_model_join_sql($this->_construct_internal_join()); |
|
| 3009 | 3009 | } |
| 3010 | 3010 | return $query_object; |
| 3011 | 3011 | } |
@@ -3020,17 +3020,17 @@ discard block |
||
| 3020 | 3020 | * @return array like EEM_Base::get_all() 's $query_params[0] |
| 3021 | 3021 | * @throws \EE_Error |
| 3022 | 3022 | */ |
| 3023 | - public function caps_where_conditions( $context = self::caps_read ) { |
|
| 3024 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
| 3023 | + public function caps_where_conditions($context = self::caps_read) { |
|
| 3024 | + EEM_Base::verify_is_valid_cap_context($context); |
|
| 3025 | 3025 | $cap_where_conditions = array(); |
| 3026 | - $cap_restrictions = $this->caps_missing( $context ); |
|
| 3026 | + $cap_restrictions = $this->caps_missing($context); |
|
| 3027 | 3027 | /** |
| 3028 | 3028 | * @var $cap_restrictions EE_Default_Where_Conditions[] |
| 3029 | 3029 | */ |
| 3030 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
| 3031 | - $cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() ); |
|
| 3030 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
| 3031 | + $cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions()); |
|
| 3032 | 3032 | } |
| 3033 | - return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions ); |
|
| 3033 | + return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions); |
|
| 3034 | 3034 | } |
| 3035 | 3035 | |
| 3036 | 3036 | /** |
@@ -3040,11 +3040,11 @@ discard block |
||
| 3040 | 3040 | * @return string either ASC, asc, DESC or desc |
| 3041 | 3041 | * @throws EE_Error |
| 3042 | 3042 | */ |
| 3043 | - private function _extract_order($should_be_order_string){ |
|
| 3044 | - if(in_array($should_be_order_string, $this->_allowed_order_values)){ |
|
| 3043 | + private function _extract_order($should_be_order_string) { |
|
| 3044 | + if (in_array($should_be_order_string, $this->_allowed_order_values)) { |
|
| 3045 | 3045 | return $should_be_order_string; |
| 3046 | - }else{ |
|
| 3047 | - throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string)); |
|
| 3046 | + } else { |
|
| 3047 | + throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string)); |
|
| 3048 | 3048 | } |
| 3049 | 3049 | } |
| 3050 | 3050 | |
@@ -3062,7 +3062,7 @@ discard block |
||
| 3062 | 3062 | * @throws EE_Error |
| 3063 | 3063 | * @return array like $query_params[0], see EEM_Base::get_all for documentation |
| 3064 | 3064 | */ |
| 3065 | - private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){ |
|
| 3065 | + private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) { |
|
| 3066 | 3066 | $allowed_used_default_where_conditions_values = array( |
| 3067 | 3067 | 'all', |
| 3068 | 3068 | 'this_model_only', |
@@ -3070,17 +3070,17 @@ discard block |
||
| 3070 | 3070 | 'minimum', |
| 3071 | 3071 | 'none' |
| 3072 | 3072 | ); |
| 3073 | - if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){ |
|
| 3074 | - throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values))); |
|
| 3073 | + if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) { |
|
| 3074 | + throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values))); |
|
| 3075 | 3075 | } |
| 3076 | 3076 | $universal_query_params = array(); |
| 3077 | - if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){ |
|
| 3077 | + if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') { |
|
| 3078 | 3078 | $universal_query_params = $this->_get_default_where_conditions(); |
| 3079 | - } else if( $use_default_where_conditions === 'minimum' ) { |
|
| 3079 | + } else if ($use_default_where_conditions === 'minimum') { |
|
| 3080 | 3080 | $universal_query_params = $this->_get_minimum_where_conditions(); |
| 3081 | 3081 | } |
| 3082 | - if(in_array($use_default_where_conditions,array('all','other_models_only'))){ |
|
| 3083 | - foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){ |
|
| 3082 | + if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) { |
|
| 3083 | + foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) { |
|
| 3084 | 3084 | $related_model = $this->get_related_model_obj($model_name); |
| 3085 | 3085 | $related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path); |
| 3086 | 3086 | $overrides = $this->_override_defaults_or_make_null_friendly( |
@@ -3113,20 +3113,20 @@ discard block |
||
| 3113 | 3113 | * @return array like EEM_Base::get_all's $query_params[0] |
| 3114 | 3114 | * @throws \EE_Error |
| 3115 | 3115 | */ |
| 3116 | - private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){ |
|
| 3116 | + private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) { |
|
| 3117 | 3117 | $null_friendly_where_conditions = array(); |
| 3118 | 3118 | $none_overridden = true; |
| 3119 | 3119 | $or_condition_key_for_defaults = 'OR*'.get_class($model); |
| 3120 | 3120 | |
| 3121 | - foreach($default_where_conditions as $key => $val){ |
|
| 3122 | - if( isset($provided_where_conditions[$key])){ |
|
| 3121 | + foreach ($default_where_conditions as $key => $val) { |
|
| 3122 | + if (isset($provided_where_conditions[$key])) { |
|
| 3123 | 3123 | $none_overridden = false; |
| 3124 | - }else{ |
|
| 3124 | + } else { |
|
| 3125 | 3125 | $null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val; |
| 3126 | 3126 | } |
| 3127 | 3127 | } |
| 3128 | - if( $none_overridden && $default_where_conditions){ |
|
| 3129 | - if($model->has_primary_key_field()){ |
|
| 3128 | + if ($none_overridden && $default_where_conditions) { |
|
| 3129 | + if ($model->has_primary_key_field()) { |
|
| 3130 | 3130 | $null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL'); |
| 3131 | 3131 | }/*else{ |
| 3132 | 3132 | //@todo NO PK, use other defaults |
@@ -3143,8 +3143,8 @@ discard block |
||
| 3143 | 3143 | * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment." |
| 3144 | 3144 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
| 3145 | 3145 | */ |
| 3146 | - private function _get_default_where_conditions($model_relation_path = null){ |
|
| 3147 | - if ( $this->_ignore_where_strategy ){ |
|
| 3146 | + private function _get_default_where_conditions($model_relation_path = null) { |
|
| 3147 | + if ($this->_ignore_where_strategy) { |
|
| 3148 | 3148 | return array(); |
| 3149 | 3149 | } |
| 3150 | 3150 | return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
@@ -3158,8 +3158,8 @@ discard block |
||
| 3158 | 3158 | * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment." |
| 3159 | 3159 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
| 3160 | 3160 | */ |
| 3161 | - protected function _get_minimum_where_conditions($model_relation_path = null){ |
|
| 3162 | - if ( $this->_ignore_where_strategy ){ |
|
| 3161 | + protected function _get_minimum_where_conditions($model_relation_path = null) { |
|
| 3162 | + if ($this->_ignore_where_strategy) { |
|
| 3163 | 3163 | return array(); |
| 3164 | 3164 | } |
| 3165 | 3165 | return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
@@ -3175,16 +3175,16 @@ discard block |
||
| 3175 | 3175 | * @return string |
| 3176 | 3176 | * @throws \EE_Error |
| 3177 | 3177 | */ |
| 3178 | - private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){ |
|
| 3178 | + private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) { |
|
| 3179 | 3179 | $selects = $this->_get_columns_to_select_for_this_model(); |
| 3180 | - foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){ |
|
| 3180 | + foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) { |
|
| 3181 | 3181 | $other_model_included = $this->get_related_model_obj($name_of_other_model_included); |
| 3182 | - $other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain ); |
|
| 3183 | - foreach ( $other_model_selects as $key => $value ) { |
|
| 3182 | + $other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain); |
|
| 3183 | + foreach ($other_model_selects as $key => $value) { |
|
| 3184 | 3184 | $selects[] = $value; |
| 3185 | 3185 | } |
| 3186 | 3186 | } |
| 3187 | - return implode(", ",$selects); |
|
| 3187 | + return implode(", ", $selects); |
|
| 3188 | 3188 | } |
| 3189 | 3189 | |
| 3190 | 3190 | /** |
@@ -3193,19 +3193,19 @@ discard block |
||
| 3193 | 3193 | * @param string $model_relation_chain like 'Question.Question_Group.Event' |
| 3194 | 3194 | * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'" |
| 3195 | 3195 | */ |
| 3196 | - public function _get_columns_to_select_for_this_model($model_relation_chain = ''){ |
|
| 3196 | + public function _get_columns_to_select_for_this_model($model_relation_chain = '') { |
|
| 3197 | 3197 | $fields = $this->field_settings(); |
| 3198 | 3198 | $selects = array(); |
| 3199 | 3199 | $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name()); |
| 3200 | - foreach($fields as $field_obj){ |
|
| 3201 | - $selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
| 3200 | + foreach ($fields as $field_obj) { |
|
| 3201 | + $selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
| 3202 | 3202 | } |
| 3203 | 3203 | //make sure we are also getting the PKs of each table |
| 3204 | 3204 | $tables = $this->get_tables(); |
| 3205 | - if(count($tables) > 1){ |
|
| 3206 | - foreach($tables as $table_obj){ |
|
| 3207 | - $qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column(); |
|
| 3208 | - if( ! in_array($qualified_pk_column,$selects)){ |
|
| 3205 | + if (count($tables) > 1) { |
|
| 3206 | + foreach ($tables as $table_obj) { |
|
| 3207 | + $qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column(); |
|
| 3208 | + if ( ! in_array($qualified_pk_column, $selects)) { |
|
| 3209 | 3209 | $selects[] = "$qualified_pk_column AS '$qualified_pk_column'"; |
| 3210 | 3210 | } |
| 3211 | 3211 | } |
@@ -3235,65 +3235,65 @@ discard block |
||
| 3235 | 3235 | $query_param_type, |
| 3236 | 3236 | $original_query_param = null |
| 3237 | 3237 | ) { |
| 3238 | - if( $original_query_param === null ){ |
|
| 3238 | + if ($original_query_param === null) { |
|
| 3239 | 3239 | $original_query_param = $query_param; |
| 3240 | 3240 | } |
| 3241 | 3241 | $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); |
| 3242 | 3242 | /** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */ |
| 3243 | - $allow_logic_query_params = in_array($query_param_type,array('where','having')); |
|
| 3244 | - $allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order')); |
|
| 3243 | + $allow_logic_query_params = in_array($query_param_type, array('where', 'having')); |
|
| 3244 | + $allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order')); |
|
| 3245 | 3245 | //check to see if we have a field on this model |
| 3246 | 3246 | $this_model_fields = $this->field_settings(true); |
| 3247 | - if(array_key_exists($query_param,$this_model_fields)){ |
|
| 3248 | - if($allow_fields){ |
|
| 3247 | + if (array_key_exists($query_param, $this_model_fields)) { |
|
| 3248 | + if ($allow_fields) { |
|
| 3249 | 3249 | return; |
| 3250 | - }else{ |
|
| 3250 | + } else { |
|
| 3251 | 3251 | throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"), |
| 3252 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
| 3252 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
| 3253 | 3253 | } |
| 3254 | 3254 | } |
| 3255 | 3255 | //check if this is a special logic query param |
| 3256 | - elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){ |
|
| 3257 | - if($allow_logic_query_params){ |
|
| 3256 | + elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) { |
|
| 3257 | + if ($allow_logic_query_params) { |
|
| 3258 | 3258 | return; |
| 3259 | - }else{ |
|
| 3259 | + } else { |
|
| 3260 | 3260 | throw new EE_Error( |
| 3261 | 3261 | sprintf( |
| 3262 | - __( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ), |
|
| 3263 | - implode( '", "', $this->_logic_query_param_keys ), |
|
| 3264 | - $query_param , |
|
| 3265 | - get_class( $this ), |
|
| 3262 | + __('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'), |
|
| 3263 | + implode('", "', $this->_logic_query_param_keys), |
|
| 3264 | + $query_param, |
|
| 3265 | + get_class($this), |
|
| 3266 | 3266 | '<br />', |
| 3267 | - "\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param |
|
| 3267 | + "\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param |
|
| 3268 | 3268 | ) |
| 3269 | 3269 | ); |
| 3270 | 3270 | } |
| 3271 | 3271 | } |
| 3272 | 3272 | |
| 3273 | 3273 | //check if it's a custom selection |
| 3274 | - elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
| 3274 | + elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
| 3275 | 3275 | return; |
| 3276 | 3276 | } |
| 3277 | 3277 | |
| 3278 | 3278 | //check if has a model name at the beginning |
| 3279 | 3279 | //and |
| 3280 | 3280 | //check if it's a field on a related model |
| 3281 | - foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){ |
|
| 3282 | - if(strpos($query_param, $valid_related_model_name.".") === 0){ |
|
| 3283 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
| 3281 | + foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) { |
|
| 3282 | + if (strpos($query_param, $valid_related_model_name.".") === 0) { |
|
| 3283 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
| 3284 | 3284 | $query_param = substr($query_param, strlen($valid_related_model_name.".")); |
| 3285 | - if($query_param === ''){ |
|
| 3285 | + if ($query_param === '') { |
|
| 3286 | 3286 | //nothing left to $query_param |
| 3287 | 3287 | //we should actually end in a field name, not a model like this! |
| 3288 | 3288 | throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"), |
| 3289 | - $query_param,$query_param_type,get_class($this),$valid_related_model_name)); |
|
| 3290 | - }else{ |
|
| 3289 | + $query_param, $query_param_type, get_class($this), $valid_related_model_name)); |
|
| 3290 | + } else { |
|
| 3291 | 3291 | $related_model_obj = $this->get_related_model_obj($valid_related_model_name); |
| 3292 | 3292 | $related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param); |
| 3293 | 3293 | return; |
| 3294 | 3294 | } |
| 3295 | - }elseif($query_param === $valid_related_model_name){ |
|
| 3296 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
| 3295 | + }elseif ($query_param === $valid_related_model_name) { |
|
| 3296 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
| 3297 | 3297 | return; |
| 3298 | 3298 | } |
| 3299 | 3299 | } |
@@ -3303,7 +3303,7 @@ discard block |
||
| 3303 | 3303 | //and we previously confirmed it wasn't a logic query param or field on the current model |
| 3304 | 3304 | //it's wack, that's what it is |
| 3305 | 3305 | throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"), |
| 3306 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
| 3306 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
| 3307 | 3307 | |
| 3308 | 3308 | } |
| 3309 | 3309 | |
@@ -3322,26 +3322,26 @@ discard block |
||
| 3322 | 3322 | * @return void |
| 3323 | 3323 | * @throws \EE_Error |
| 3324 | 3324 | */ |
| 3325 | - private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){ |
|
| 3325 | + private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) { |
|
| 3326 | 3326 | $relation_obj = $this->related_settings_for($model_name); |
| 3327 | 3327 | |
| 3328 | 3328 | $model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param); |
| 3329 | 3329 | //check if the relation is HABTM, because then we're essentially doing two joins |
| 3330 | 3330 | //If so, join first to the JOIN table, and add its data types, and then continue as normal |
| 3331 | - if($relation_obj instanceof EE_HABTM_Relation){ |
|
| 3331 | + if ($relation_obj instanceof EE_HABTM_Relation) { |
|
| 3332 | 3332 | $join_model_obj = $relation_obj->get_join_model(); |
| 3333 | 3333 | //replace the model specified with the join model for this relation chain, whi |
| 3334 | 3334 | $relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain); |
| 3335 | 3335 | $new_query_info = new EE_Model_Query_Info_Carrier( |
| 3336 | 3336 | array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()), |
| 3337 | 3337 | $relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model)); |
| 3338 | - $passed_in_query_info->merge( $new_query_info ); |
|
| 3338 | + $passed_in_query_info->merge($new_query_info); |
|
| 3339 | 3339 | } |
| 3340 | 3340 | //now just join to the other table pointed to by the relation object, and add its data types |
| 3341 | 3341 | $new_query_info = new EE_Model_Query_Info_Carrier( |
| 3342 | 3342 | array($model_relation_chain=>$model_name), |
| 3343 | 3343 | $relation_obj->get_join_statement($model_relation_chain)); |
| 3344 | - $passed_in_query_info->merge( $new_query_info ); |
|
| 3344 | + $passed_in_query_info->merge($new_query_info); |
|
| 3345 | 3345 | } |
| 3346 | 3346 | |
| 3347 | 3347 | |
@@ -3353,11 +3353,11 @@ discard block |
||
| 3353 | 3353 | * @return string of SQL |
| 3354 | 3354 | * @throws \EE_Error |
| 3355 | 3355 | */ |
| 3356 | - private function _construct_where_clause($where_params){ |
|
| 3356 | + private function _construct_where_clause($where_params) { |
|
| 3357 | 3357 | $SQL = $this->_construct_condition_clause_recursive($where_params, ' AND '); |
| 3358 | - if($SQL){ |
|
| 3359 | - return " WHERE ". $SQL; |
|
| 3360 | - }else{ |
|
| 3358 | + if ($SQL) { |
|
| 3359 | + return " WHERE ".$SQL; |
|
| 3360 | + } else { |
|
| 3361 | 3361 | return ''; |
| 3362 | 3362 | } |
| 3363 | 3363 | } |
@@ -3372,11 +3372,11 @@ discard block |
||
| 3372 | 3372 | * @return string |
| 3373 | 3373 | * @throws \EE_Error |
| 3374 | 3374 | */ |
| 3375 | - private function _construct_having_clause($having_params){ |
|
| 3375 | + private function _construct_having_clause($having_params) { |
|
| 3376 | 3376 | $SQL = $this->_construct_condition_clause_recursive($having_params, ' AND '); |
| 3377 | - if($SQL){ |
|
| 3378 | - return " HAVING ". $SQL; |
|
| 3379 | - }else{ |
|
| 3377 | + if ($SQL) { |
|
| 3378 | + return " HAVING ".$SQL; |
|
| 3379 | + } else { |
|
| 3380 | 3380 | return ''; |
| 3381 | 3381 | } |
| 3382 | 3382 | |
@@ -3390,16 +3390,16 @@ discard block |
||
| 3390 | 3390 | * @return EE_Model_Field_Base |
| 3391 | 3391 | * @throws EE_Error |
| 3392 | 3392 | */ |
| 3393 | - protected function _get_field_on_model($field_name,$model_name){ |
|
| 3393 | + protected function _get_field_on_model($field_name, $model_name) { |
|
| 3394 | 3394 | $model_class = 'EEM_'.$model_name; |
| 3395 | 3395 | $model_filepath = $model_class.".model.php"; |
| 3396 | - if ( is_readable($model_filepath)){ |
|
| 3396 | + if (is_readable($model_filepath)) { |
|
| 3397 | 3397 | require_once($model_filepath); |
| 3398 | - $model_instance=call_user_func($model_name."::instance"); |
|
| 3398 | + $model_instance = call_user_func($model_name."::instance"); |
|
| 3399 | 3399 | /* @var $model_instance EEM_Base */ |
| 3400 | 3400 | return $model_instance->field_settings_for($field_name); |
| 3401 | - }else{ |
|
| 3402 | - throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath)); |
|
| 3401 | + } else { |
|
| 3402 | + throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath)); |
|
| 3403 | 3403 | } |
| 3404 | 3404 | } |
| 3405 | 3405 | |
@@ -3412,41 +3412,41 @@ discard block |
||
| 3412 | 3412 | * @throws EE_Error |
| 3413 | 3413 | * @return string of SQL |
| 3414 | 3414 | */ |
| 3415 | - private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){ |
|
| 3416 | - $where_clauses=array(); |
|
| 3417 | - foreach($where_params as $query_param => $op_and_value_or_sub_condition){ |
|
| 3418 | - $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param); |
|
| 3419 | - if(in_array($query_param,$this->_logic_query_param_keys)){ |
|
| 3420 | - switch($query_param){ |
|
| 3415 | + private function _construct_condition_clause_recursive($where_params, $glue = ' AND') { |
|
| 3416 | + $where_clauses = array(); |
|
| 3417 | + foreach ($where_params as $query_param => $op_and_value_or_sub_condition) { |
|
| 3418 | + $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param); |
|
| 3419 | + if (in_array($query_param, $this->_logic_query_param_keys)) { |
|
| 3420 | + switch ($query_param) { |
|
| 3421 | 3421 | case 'not': |
| 3422 | 3422 | case 'NOT': |
| 3423 | - $where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
| 3423 | + $where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
| 3424 | 3424 | break; |
| 3425 | 3425 | case 'and': |
| 3426 | 3426 | case 'AND': |
| 3427 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")"; |
|
| 3427 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")"; |
|
| 3428 | 3428 | break; |
| 3429 | 3429 | case 'or': |
| 3430 | 3430 | case 'OR': |
| 3431 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")"; |
|
| 3431 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")"; |
|
| 3432 | 3432 | break; |
| 3433 | 3433 | } |
| 3434 | - }else{ |
|
| 3434 | + } else { |
|
| 3435 | 3435 | $field_obj = $this->_deduce_field_from_query_param($query_param); |
| 3436 | 3436 | |
| 3437 | 3437 | //if it's not a normal field, maybe it's a custom selection? |
| 3438 | - if( ! $field_obj){ |
|
| 3439 | - if(isset( $this->_custom_selections[$query_param][1])){ |
|
| 3438 | + if ( ! $field_obj) { |
|
| 3439 | + if (isset($this->_custom_selections[$query_param][1])) { |
|
| 3440 | 3440 | $field_obj = $this->_custom_selections[$query_param][1]; |
| 3441 | - }else{ |
|
| 3442 | - throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param)); |
|
| 3441 | + } else { |
|
| 3442 | + throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param)); |
|
| 3443 | 3443 | } |
| 3444 | 3444 | } |
| 3445 | 3445 | $op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj); |
| 3446 | - $where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
| 3446 | + $where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
| 3447 | 3447 | } |
| 3448 | 3448 | } |
| 3449 | - return $where_clauses ? implode( $glue, $where_clauses ) : ''; |
|
| 3449 | + return $where_clauses ? implode($glue, $where_clauses) : ''; |
|
| 3450 | 3450 | } |
| 3451 | 3451 | |
| 3452 | 3452 | |
@@ -3457,18 +3457,18 @@ discard block |
||
| 3457 | 3457 | * @throws EE_Error |
| 3458 | 3458 | * @return string table alias and column name for SQL, eg "Transaction.TXN_ID" |
| 3459 | 3459 | */ |
| 3460 | - private function _deduce_column_name_from_query_param($query_param){ |
|
| 3460 | + private function _deduce_column_name_from_query_param($query_param) { |
|
| 3461 | 3461 | $field = $this->_deduce_field_from_query_param($query_param); |
| 3462 | 3462 | |
| 3463 | - if( $field ){ |
|
| 3464 | - $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param ); |
|
| 3465 | - return $table_alias_prefix . $field->get_qualified_column(); |
|
| 3466 | - }elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
| 3463 | + if ($field) { |
|
| 3464 | + $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param); |
|
| 3465 | + return $table_alias_prefix.$field->get_qualified_column(); |
|
| 3466 | + }elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
| 3467 | 3467 | //maybe it's custom selection item? |
| 3468 | 3468 | //if so, just use it as the "column name" |
| 3469 | 3469 | return $query_param; |
| 3470 | - }else{ |
|
| 3471 | - throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections))); |
|
| 3470 | + } else { |
|
| 3471 | + throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections))); |
|
| 3472 | 3472 | } |
| 3473 | 3473 | } |
| 3474 | 3474 | |
@@ -3480,11 +3480,11 @@ discard block |
||
| 3480 | 3480 | * @param string $condition_query_param_key |
| 3481 | 3481 | * @return string |
| 3482 | 3482 | */ |
| 3483 | - private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){ |
|
| 3483 | + private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
| 3484 | 3484 | $pos_of_star = strpos($condition_query_param_key, '*'); |
| 3485 | - if($pos_of_star === FALSE){ |
|
| 3485 | + if ($pos_of_star === FALSE) { |
|
| 3486 | 3486 | return $condition_query_param_key; |
| 3487 | - }else{ |
|
| 3487 | + } else { |
|
| 3488 | 3488 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
| 3489 | 3489 | return $condition_query_param_sans_star; |
| 3490 | 3490 | } |
@@ -3499,12 +3499,12 @@ discard block |
||
| 3499 | 3499 | * @throws EE_Error |
| 3500 | 3500 | * @return string |
| 3501 | 3501 | */ |
| 3502 | - private function _construct_op_and_value($op_and_value, $field_obj){ |
|
| 3503 | - if ( is_array( $op_and_value ) ) { |
|
| 3504 | - $operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null; |
|
| 3505 | - if ( ! $operator ) { |
|
| 3502 | + private function _construct_op_and_value($op_and_value, $field_obj) { |
|
| 3503 | + if (is_array($op_and_value)) { |
|
| 3504 | + $operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null; |
|
| 3505 | + if ( ! $operator) { |
|
| 3506 | 3506 | $php_array_like_string = array(); |
| 3507 | - foreach ( $op_and_value as $key => $value ) { |
|
| 3507 | + foreach ($op_and_value as $key => $value) { |
|
| 3508 | 3508 | $php_array_like_string[] = "$key=>$value"; |
| 3509 | 3509 | } |
| 3510 | 3510 | throw new EE_Error( |
@@ -3513,27 +3513,27 @@ discard block |
||
| 3513 | 3513 | "You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", |
| 3514 | 3514 | "event_espresso" |
| 3515 | 3515 | ), |
| 3516 | - implode( ",", $php_array_like_string ) |
|
| 3516 | + implode(",", $php_array_like_string) |
|
| 3517 | 3517 | ) |
| 3518 | 3518 | ); |
| 3519 | 3519 | } |
| 3520 | - $value = isset( $op_and_value[1] ) ? $op_and_value[1] : null; |
|
| 3520 | + $value = isset($op_and_value[1]) ? $op_and_value[1] : null; |
|
| 3521 | 3521 | } else { |
| 3522 | 3522 | $operator = '='; |
| 3523 | 3523 | $value = $op_and_value; |
| 3524 | 3524 | } |
| 3525 | 3525 | //check to see if the value is actually another field |
| 3526 | - if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) { |
|
| 3527 | - return $operator . SP . $this->_deduce_column_name_from_query_param( $value ); |
|
| 3528 | - } elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) { |
|
| 3526 | + if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) { |
|
| 3527 | + return $operator.SP.$this->_deduce_column_name_from_query_param($value); |
|
| 3528 | + } elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
| 3529 | 3529 | //in this case, the value should be an array, or at least a comma-separated list |
| 3530 | 3530 | //it will need to handle a little differently |
| 3531 | - $cleaned_value = $this->_construct_in_value( $value, $field_obj ); |
|
| 3531 | + $cleaned_value = $this->_construct_in_value($value, $field_obj); |
|
| 3532 | 3532 | //note: $cleaned_value has already been run through $wpdb->prepare() |
| 3533 | - return $operator . SP . $cleaned_value; |
|
| 3534 | - } elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) { |
|
| 3533 | + return $operator.SP.$cleaned_value; |
|
| 3534 | + } elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) { |
|
| 3535 | 3535 | //the value should be an array with count of two. |
| 3536 | - if ( count( $value ) !== 2 ) { |
|
| 3536 | + if (count($value) !== 2) { |
|
| 3537 | 3537 | throw new EE_Error( |
| 3538 | 3538 | sprintf( |
| 3539 | 3539 | __( |
@@ -3544,10 +3544,10 @@ discard block |
||
| 3544 | 3544 | ) |
| 3545 | 3545 | ); |
| 3546 | 3546 | } |
| 3547 | - $cleaned_value = $this->_construct_between_value( $value, $field_obj ); |
|
| 3548 | - return $operator . SP . $cleaned_value; |
|
| 3549 | - } elseif ( in_array( $operator, $this->_null_style_operators ) ) { |
|
| 3550 | - if ( $value !== null ) { |
|
| 3547 | + $cleaned_value = $this->_construct_between_value($value, $field_obj); |
|
| 3548 | + return $operator.SP.$cleaned_value; |
|
| 3549 | + } elseif (in_array($operator, $this->_null_style_operators)) { |
|
| 3550 | + if ($value !== null) { |
|
| 3551 | 3551 | throw new EE_Error( |
| 3552 | 3552 | sprintf( |
| 3553 | 3553 | __( |
@@ -3560,13 +3560,13 @@ discard block |
||
| 3560 | 3560 | ); |
| 3561 | 3561 | } |
| 3562 | 3562 | return $operator; |
| 3563 | - } elseif ( $operator === 'LIKE' && ! is_array( $value ) ) { |
|
| 3563 | + } elseif ($operator === 'LIKE' && ! is_array($value)) { |
|
| 3564 | 3564 | //if the operator is 'LIKE', we want to allow percent signs (%) and not |
| 3565 | 3565 | //remove other junk. So just treat it as a string. |
| 3566 | - return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' ); |
|
| 3567 | - } elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) { |
|
| 3568 | - return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj ); |
|
| 3569 | - } elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) { |
|
| 3566 | + return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s'); |
|
| 3567 | + } elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
| 3568 | + return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj); |
|
| 3569 | + } elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
| 3570 | 3570 | throw new EE_Error( |
| 3571 | 3571 | sprintf( |
| 3572 | 3572 | __( |
@@ -3577,7 +3577,7 @@ discard block |
||
| 3577 | 3577 | $operator |
| 3578 | 3578 | ) |
| 3579 | 3579 | ); |
| 3580 | - } elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) { |
|
| 3580 | + } elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
| 3581 | 3581 | throw new EE_Error( |
| 3582 | 3582 | sprintf( |
| 3583 | 3583 | __( |
@@ -3595,7 +3595,7 @@ discard block |
||
| 3595 | 3595 | "It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", |
| 3596 | 3596 | "event_espresso" |
| 3597 | 3597 | ), |
| 3598 | - http_build_query( $op_and_value ) |
|
| 3598 | + http_build_query($op_and_value) |
|
| 3599 | 3599 | ) |
| 3600 | 3600 | ); |
| 3601 | 3601 | } |
@@ -3611,12 +3611,12 @@ discard block |
||
| 3611 | 3611 | * @return string |
| 3612 | 3612 | * @throws \EE_Error |
| 3613 | 3613 | */ |
| 3614 | - public function _construct_between_value( $values, $field_obj ) { |
|
| 3614 | + public function _construct_between_value($values, $field_obj) { |
|
| 3615 | 3615 | $cleaned_values = array(); |
| 3616 | - foreach ( $values as $value ) { |
|
| 3617 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
| 3616 | + foreach ($values as $value) { |
|
| 3617 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
| 3618 | 3618 | } |
| 3619 | - return $cleaned_values[0] . " AND " . $cleaned_values[1]; |
|
| 3619 | + return $cleaned_values[0]." AND ".$cleaned_values[1]; |
|
| 3620 | 3620 | } |
| 3621 | 3621 | |
| 3622 | 3622 | |
@@ -3633,26 +3633,26 @@ discard block |
||
| 3633 | 3633 | * @return string of SQL to follow an 'IN' or 'NOT IN' operator |
| 3634 | 3634 | * @throws \EE_Error |
| 3635 | 3635 | */ |
| 3636 | - public function _construct_in_value($values, $field_obj){ |
|
| 3636 | + public function _construct_in_value($values, $field_obj) { |
|
| 3637 | 3637 | //check if the value is a CSV list |
| 3638 | - if(is_string($values)){ |
|
| 3638 | + if (is_string($values)) { |
|
| 3639 | 3639 | //in which case, turn it into an array |
| 3640 | - $values = explode(",",$values); |
|
| 3640 | + $values = explode(",", $values); |
|
| 3641 | 3641 | } |
| 3642 | 3642 | $cleaned_values = array(); |
| 3643 | - foreach($values as $value){ |
|
| 3644 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
| 3643 | + foreach ($values as $value) { |
|
| 3644 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
| 3645 | 3645 | } |
| 3646 | 3646 | //we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()", |
| 3647 | 3647 | //but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set |
| 3648 | 3648 | //which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns |
| 3649 | - if(empty($cleaned_values)){ |
|
| 3649 | + if (empty($cleaned_values)) { |
|
| 3650 | 3650 | $all_fields = $this->field_settings(); |
| 3651 | 3651 | $a_field = array_shift($all_fields); |
| 3652 | 3652 | $main_table = $this->_get_main_table(); |
| 3653 | 3653 | $cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE"; |
| 3654 | 3654 | } |
| 3655 | - return "(".implode(",",$cleaned_values).")"; |
|
| 3655 | + return "(".implode(",", $cleaned_values).")"; |
|
| 3656 | 3656 | } |
| 3657 | 3657 | |
| 3658 | 3658 | |
@@ -3664,16 +3664,16 @@ discard block |
||
| 3664 | 3664 | * @throws EE_Error |
| 3665 | 3665 | * @return false|null|string |
| 3666 | 3666 | */ |
| 3667 | - private function _wpdb_prepare_using_field($value,$field_obj){ |
|
| 3667 | + private function _wpdb_prepare_using_field($value, $field_obj) { |
|
| 3668 | 3668 | /** @type WPDB $wpdb */ |
| 3669 | 3669 | global $wpdb; |
| 3670 | - if($field_obj instanceof EE_Model_Field_Base){ |
|
| 3671 | - return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
| 3672 | - }else{//$field_obj should really just be a data type |
|
| 3673 | - if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){ |
|
| 3674 | - throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types))); |
|
| 3670 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
| 3671 | + return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
| 3672 | + } else {//$field_obj should really just be a data type |
|
| 3673 | + if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) { |
|
| 3674 | + throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types))); |
|
| 3675 | 3675 | } |
| 3676 | - return $wpdb->prepare($field_obj,$value); |
|
| 3676 | + return $wpdb->prepare($field_obj, $value); |
|
| 3677 | 3677 | } |
| 3678 | 3678 | } |
| 3679 | 3679 | |
@@ -3685,27 +3685,27 @@ discard block |
||
| 3685 | 3685 | * @throws EE_Error |
| 3686 | 3686 | * @return EE_Model_Field_Base |
| 3687 | 3687 | */ |
| 3688 | - protected function _deduce_field_from_query_param($query_param_name){ |
|
| 3688 | + protected function _deduce_field_from_query_param($query_param_name) { |
|
| 3689 | 3689 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
| 3690 | 3690 | //which will help us find the database table and column |
| 3691 | 3691 | |
| 3692 | - $query_param_parts = explode(".",$query_param_name); |
|
| 3693 | - if(empty($query_param_parts)){ |
|
| 3694 | - throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
| 3692 | + $query_param_parts = explode(".", $query_param_name); |
|
| 3693 | + if (empty($query_param_parts)) { |
|
| 3694 | + throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
| 3695 | 3695 | } |
| 3696 | 3696 | $number_of_parts = count($query_param_parts); |
| 3697 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
| 3698 | - if($number_of_parts === 1){ |
|
| 3697 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
| 3698 | + if ($number_of_parts === 1) { |
|
| 3699 | 3699 | $field_name = $last_query_param_part; |
| 3700 | 3700 | $model_obj = $this; |
| 3701 | - }else{// $number_of_parts >= 2 |
|
| 3701 | + } else {// $number_of_parts >= 2 |
|
| 3702 | 3702 | //the last part is the column name, and there are only 2parts. therefore... |
| 3703 | 3703 | $field_name = $last_query_param_part; |
| 3704 | - $model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]); |
|
| 3704 | + $model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]); |
|
| 3705 | 3705 | } |
| 3706 | - try{ |
|
| 3706 | + try { |
|
| 3707 | 3707 | return $model_obj->field_settings_for($field_name); |
| 3708 | - }catch(EE_Error $e){ |
|
| 3708 | + } catch (EE_Error $e) { |
|
| 3709 | 3709 | return null; |
| 3710 | 3710 | } |
| 3711 | 3711 | } |
@@ -3719,13 +3719,13 @@ discard block |
||
| 3719 | 3719 | * @throws EE_Error |
| 3720 | 3720 | * @return string |
| 3721 | 3721 | */ |
| 3722 | - public function _get_qualified_column_for_field($field_name){ |
|
| 3722 | + public function _get_qualified_column_for_field($field_name) { |
|
| 3723 | 3723 | $all_fields = $this->field_settings(); |
| 3724 | 3724 | $field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE; |
| 3725 | - if($field){ |
|
| 3725 | + if ($field) { |
|
| 3726 | 3726 | return $field->get_qualified_column(); |
| 3727 | - }else{ |
|
| 3728 | - throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this))); |
|
| 3727 | + } else { |
|
| 3728 | + throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this))); |
|
| 3729 | 3729 | } |
| 3730 | 3730 | } |
| 3731 | 3731 | |
@@ -3739,17 +3739,17 @@ discard block |
||
| 3739 | 3739 | * @param mixed|string $limit The limit for this select |
| 3740 | 3740 | * @return string The final select join element for the query. |
| 3741 | 3741 | */ |
| 3742 | - public function _construct_limit_join_select( $table_alias, $limit ) { |
|
| 3742 | + public function _construct_limit_join_select($table_alias, $limit) { |
|
| 3743 | 3743 | $SQL = ''; |
| 3744 | - foreach ( $this->_tables as $table_obj ) { |
|
| 3745 | - if ( $table_obj instanceof EE_Primary_Table ) { |
|
| 3744 | + foreach ($this->_tables as $table_obj) { |
|
| 3745 | + if ($table_obj instanceof EE_Primary_Table) { |
|
| 3746 | 3746 | $SQL .= $table_alias === $table_obj->get_table_alias() |
| 3747 | - ? $table_obj->get_select_join_limit( $limit ) |
|
| 3748 | - : SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP; |
|
| 3749 | - } elseif ( $table_obj instanceof EE_Secondary_Table ) { |
|
| 3747 | + ? $table_obj->get_select_join_limit($limit) |
|
| 3748 | + : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP; |
|
| 3749 | + } elseif ($table_obj instanceof EE_Secondary_Table) { |
|
| 3750 | 3750 | $SQL .= $table_alias === $table_obj->get_table_alias() |
| 3751 | - ? $table_obj->get_select_join_limit_join( $limit ) |
|
| 3752 | - : SP . $table_obj->get_join_sql( $table_alias ) . SP; |
|
| 3751 | + ? $table_obj->get_select_join_limit_join($limit) |
|
| 3752 | + : SP.$table_obj->get_join_sql($table_alias).SP; |
|
| 3753 | 3753 | } |
| 3754 | 3754 | } |
| 3755 | 3755 | return $SQL; |
@@ -3764,7 +3764,7 @@ discard block |
||
| 3764 | 3764 | * @return string SQL |
| 3765 | 3765 | * @throws \EE_Error |
| 3766 | 3766 | */ |
| 3767 | - public function _construct_internal_join(){ |
|
| 3767 | + public function _construct_internal_join() { |
|
| 3768 | 3768 | $SQL = $this->_get_main_table()->get_table_sql(); |
| 3769 | 3769 | $SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias()); |
| 3770 | 3770 | return $SQL; |
@@ -3785,17 +3785,17 @@ discard block |
||
| 3785 | 3785 | * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause) |
| 3786 | 3786 | * @return string |
| 3787 | 3787 | */ |
| 3788 | - public function _construct_internal_join_to_table_with_alias($alias_prefixed){ |
|
| 3788 | + public function _construct_internal_join_to_table_with_alias($alias_prefixed) { |
|
| 3789 | 3789 | $SQL = ''; |
| 3790 | 3790 | $alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed); |
| 3791 | - foreach($this->_tables as $table_obj){ |
|
| 3792 | - if($table_obj instanceof EE_Secondary_Table){//table is secondary table |
|
| 3793 | - if($alias_sans_prefix === $table_obj->get_table_alias()){ |
|
| 3791 | + foreach ($this->_tables as $table_obj) { |
|
| 3792 | + if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table |
|
| 3793 | + if ($alias_sans_prefix === $table_obj->get_table_alias()) { |
|
| 3794 | 3794 | //so we're joining to this table, meaning the table is already in |
| 3795 | 3795 | //the FROM statement, BUT the primary table isn't. So we want |
| 3796 | 3796 | //to add the inverse join sql |
| 3797 | 3797 | $SQL .= $table_obj->get_inverse_join_sql($alias_prefixed); |
| 3798 | - }else{ |
|
| 3798 | + } else { |
|
| 3799 | 3799 | //just add a regular JOIN to this table from the primary table |
| 3800 | 3800 | $SQL .= $table_obj->get_join_sql($alias_prefixed); |
| 3801 | 3801 | } |
@@ -3809,9 +3809,9 @@ discard block |
||
| 3809 | 3809 | * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc) |
| 3810 | 3810 | * @return array |
| 3811 | 3811 | */ |
| 3812 | - public function _get_data_types(){ |
|
| 3812 | + public function _get_data_types() { |
|
| 3813 | 3813 | $data_types = array(); |
| 3814 | - foreach( $this->field_settings() as $field_obj){ |
|
| 3814 | + foreach ($this->field_settings() as $field_obj) { |
|
| 3815 | 3815 | //$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type(); |
| 3816 | 3816 | /** @var $field_obj EE_Model_Field_Base */ |
| 3817 | 3817 | $data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type(); |
@@ -3827,10 +3827,10 @@ discard block |
||
| 3827 | 3827 | * @throws EE_Error |
| 3828 | 3828 | * @return EEM_Base |
| 3829 | 3829 | */ |
| 3830 | - public function get_related_model_obj($model_name){ |
|
| 3830 | + public function get_related_model_obj($model_name) { |
|
| 3831 | 3831 | $model_classname = "EEM_".$model_name; |
| 3832 | - if(!class_exists($model_classname)){ |
|
| 3833 | - throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname)); |
|
| 3832 | + if ( ! class_exists($model_classname)) { |
|
| 3833 | + throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname)); |
|
| 3834 | 3834 | } |
| 3835 | 3835 | return call_user_func($model_classname."::instance"); |
| 3836 | 3836 | } |
@@ -3840,7 +3840,7 @@ discard block |
||
| 3840 | 3840 | * Returns the array of EE_ModelRelations for this model. |
| 3841 | 3841 | * @return EE_Model_Relation_Base[] |
| 3842 | 3842 | */ |
| 3843 | - public function relation_settings(){ |
|
| 3843 | + public function relation_settings() { |
|
| 3844 | 3844 | return $this->_model_relations; |
| 3845 | 3845 | } |
| 3846 | 3846 | |
@@ -3850,10 +3850,10 @@ discard block |
||
| 3850 | 3850 | * (Eg, without an event, datetimes have little purpose.) |
| 3851 | 3851 | * @return EE_Belongs_To_Relation[] |
| 3852 | 3852 | */ |
| 3853 | - public function belongs_to_relations(){ |
|
| 3853 | + public function belongs_to_relations() { |
|
| 3854 | 3854 | $belongs_to_relations = array(); |
| 3855 | - foreach($this->relation_settings() as $model_name => $relation_obj){ |
|
| 3856 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
| 3855 | + foreach ($this->relation_settings() as $model_name => $relation_obj) { |
|
| 3856 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
| 3857 | 3857 | $belongs_to_relations[$model_name] = $relation_obj; |
| 3858 | 3858 | } |
| 3859 | 3859 | } |
@@ -3868,15 +3868,15 @@ discard block |
||
| 3868 | 3868 | * @throws EE_Error |
| 3869 | 3869 | * @return EE_Model_Relation_Base |
| 3870 | 3870 | */ |
| 3871 | - public function related_settings_for($relation_name){ |
|
| 3872 | - $relatedModels=$this->relation_settings(); |
|
| 3873 | - if(!array_key_exists($relation_name,$relatedModels)){ |
|
| 3871 | + public function related_settings_for($relation_name) { |
|
| 3872 | + $relatedModels = $this->relation_settings(); |
|
| 3873 | + if ( ! array_key_exists($relation_name, $relatedModels)) { |
|
| 3874 | 3874 | throw new EE_Error( |
| 3875 | 3875 | sprintf( |
| 3876 | - __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'), |
|
| 3876 | + __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'), |
|
| 3877 | 3877 | $relation_name, |
| 3878 | 3878 | $this->_get_class_name(), |
| 3879 | - implode( ', ', array_keys( $relatedModels )) |
|
| 3879 | + implode(', ', array_keys($relatedModels)) |
|
| 3880 | 3880 | ) |
| 3881 | 3881 | ); |
| 3882 | 3882 | } |
@@ -3891,10 +3891,10 @@ discard block |
||
| 3891 | 3891 | * @throws EE_Error |
| 3892 | 3892 | * @return EE_Model_Field_Base |
| 3893 | 3893 | */ |
| 3894 | - public function field_settings_for($fieldName){ |
|
| 3895 | - $fieldSettings=$this->field_settings(true); |
|
| 3896 | - if( ! array_key_exists($fieldName,$fieldSettings)){ |
|
| 3897 | - throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this))); |
|
| 3894 | + public function field_settings_for($fieldName) { |
|
| 3895 | + $fieldSettings = $this->field_settings(true); |
|
| 3896 | + if ( ! array_key_exists($fieldName, $fieldSettings)) { |
|
| 3897 | + throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this))); |
|
| 3898 | 3898 | } |
| 3899 | 3899 | return $fieldSettings[$fieldName]; |
| 3900 | 3900 | } |
@@ -3904,11 +3904,11 @@ discard block |
||
| 3904 | 3904 | * @param string $fieldName a key in the model's _field_settings array |
| 3905 | 3905 | * @return boolean |
| 3906 | 3906 | */ |
| 3907 | - public function has_field($fieldName){ |
|
| 3907 | + public function has_field($fieldName) { |
|
| 3908 | 3908 | $fieldSettings = $this->field_settings(true); |
| 3909 | - if( isset($fieldSettings[$fieldName])){ |
|
| 3909 | + if (isset($fieldSettings[$fieldName])) { |
|
| 3910 | 3910 | return true; |
| 3911 | - }else{ |
|
| 3911 | + } else { |
|
| 3912 | 3912 | return false; |
| 3913 | 3913 | } |
| 3914 | 3914 | } |
@@ -3918,11 +3918,11 @@ discard block |
||
| 3918 | 3918 | * @param string $relation_name possibly one of the keys in the relation_settings array |
| 3919 | 3919 | * @return boolean |
| 3920 | 3920 | */ |
| 3921 | - public function has_relation($relation_name){ |
|
| 3921 | + public function has_relation($relation_name) { |
|
| 3922 | 3922 | $relations = $this->relation_settings(); |
| 3923 | - if(isset($relations[$relation_name])){ |
|
| 3923 | + if (isset($relations[$relation_name])) { |
|
| 3924 | 3924 | return true; |
| 3925 | - }else{ |
|
| 3925 | + } else { |
|
| 3926 | 3926 | return false; |
| 3927 | 3927 | } |
| 3928 | 3928 | } |
@@ -3934,7 +3934,7 @@ discard block |
||
| 3934 | 3934 | * @param $field_obj |
| 3935 | 3935 | * @return boolean |
| 3936 | 3936 | */ |
| 3937 | - public function is_primary_key_field( $field_obj ){ |
|
| 3937 | + public function is_primary_key_field($field_obj) { |
|
| 3938 | 3938 | return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE; |
| 3939 | 3939 | } |
| 3940 | 3940 | |
@@ -3946,16 +3946,16 @@ discard block |
||
| 3946 | 3946 | * @return EE_Model_Field_Base |
| 3947 | 3947 | * @throws EE_Error |
| 3948 | 3948 | */ |
| 3949 | - public function get_primary_key_field(){ |
|
| 3950 | - if( $this->_primary_key_field === NULL ){ |
|
| 3951 | - foreach( $this->field_settings( TRUE ) as $field_obj ){ |
|
| 3952 | - if( $this->is_primary_key_field( $field_obj )){ |
|
| 3949 | + public function get_primary_key_field() { |
|
| 3950 | + if ($this->_primary_key_field === NULL) { |
|
| 3951 | + foreach ($this->field_settings(TRUE) as $field_obj) { |
|
| 3952 | + if ($this->is_primary_key_field($field_obj)) { |
|
| 3953 | 3953 | $this->_primary_key_field = $field_obj; |
| 3954 | 3954 | break; |
| 3955 | 3955 | } |
| 3956 | 3956 | } |
| 3957 | - if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){ |
|
| 3958 | - throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this))); |
|
| 3957 | + if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) { |
|
| 3958 | + throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this))); |
|
| 3959 | 3959 | } |
| 3960 | 3960 | } |
| 3961 | 3961 | return $this->_primary_key_field; |
@@ -3968,12 +3968,12 @@ discard block |
||
| 3968 | 3968 | * Internally does some caching. |
| 3969 | 3969 | * @return boolean |
| 3970 | 3970 | */ |
| 3971 | - public function has_primary_key_field(){ |
|
| 3972 | - if($this->_has_primary_key_field === null){ |
|
| 3973 | - try{ |
|
| 3971 | + public function has_primary_key_field() { |
|
| 3972 | + if ($this->_has_primary_key_field === null) { |
|
| 3973 | + try { |
|
| 3974 | 3974 | $this->get_primary_key_field(); |
| 3975 | 3975 | $this->_has_primary_key_field = true; |
| 3976 | - }catch(EE_Error $e){ |
|
| 3976 | + } catch (EE_Error $e) { |
|
| 3977 | 3977 | $this->_has_primary_key_field = false; |
| 3978 | 3978 | } |
| 3979 | 3979 | } |
@@ -3987,9 +3987,9 @@ discard block |
||
| 3987 | 3987 | * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc |
| 3988 | 3988 | * @return EE_Model_Field_Base or null if none is found |
| 3989 | 3989 | */ |
| 3990 | - public function get_a_field_of_type($field_class_name){ |
|
| 3991 | - foreach($this->field_settings() as $field){ |
|
| 3992 | - if( $field instanceof $field_class_name ){ |
|
| 3990 | + public function get_a_field_of_type($field_class_name) { |
|
| 3991 | + foreach ($this->field_settings() as $field) { |
|
| 3992 | + if ($field instanceof $field_class_name) { |
|
| 3993 | 3993 | return $field; |
| 3994 | 3994 | } |
| 3995 | 3995 | } |
@@ -4003,22 +4003,22 @@ discard block |
||
| 4003 | 4003 | * @return EE_Foreign_Key_Field_Base |
| 4004 | 4004 | * @throws EE_Error |
| 4005 | 4005 | */ |
| 4006 | - public function get_foreign_key_to($model_name){ |
|
| 4007 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
| 4008 | - foreach($this->field_settings() as $field){ |
|
| 4009 | - if( |
|
| 4006 | + public function get_foreign_key_to($model_name) { |
|
| 4007 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
| 4008 | + foreach ($this->field_settings() as $field) { |
|
| 4009 | + if ( |
|
| 4010 | 4010 | $field instanceof EE_Foreign_Key_Field_Base |
| 4011 | - && in_array($model_name,$field->get_model_names_pointed_to() ) |
|
| 4011 | + && in_array($model_name, $field->get_model_names_pointed_to()) |
|
| 4012 | 4012 | ) { |
| 4013 | - $this->_cache_foreign_key_to_fields[ $model_name ] = $field; |
|
| 4013 | + $this->_cache_foreign_key_to_fields[$model_name] = $field; |
|
| 4014 | 4014 | break; |
| 4015 | 4015 | } |
| 4016 | 4016 | } |
| 4017 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
| 4018 | - throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this))); |
|
| 4017 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
| 4018 | + throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this))); |
|
| 4019 | 4019 | } |
| 4020 | 4020 | } |
| 4021 | - return $this->_cache_foreign_key_to_fields[ $model_name ]; |
|
| 4021 | + return $this->_cache_foreign_key_to_fields[$model_name]; |
|
| 4022 | 4022 | } |
| 4023 | 4023 | |
| 4024 | 4024 | |
@@ -4029,7 +4029,7 @@ discard block |
||
| 4029 | 4029 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
| 4030 | 4030 | * @return EE_Table_Base |
| 4031 | 4031 | */ |
| 4032 | - public function get_table_for_alias($table_alias){ |
|
| 4032 | + public function get_table_for_alias($table_alias) { |
|
| 4033 | 4033 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
| 4034 | 4034 | return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name(); |
| 4035 | 4035 | } |
@@ -4042,25 +4042,25 @@ discard block |
||
| 4042 | 4042 | * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields |
| 4043 | 4043 | * @return EE_Model_Field_Base[] where the keys are the field's name |
| 4044 | 4044 | */ |
| 4045 | - public function field_settings($include_db_only_fields = false){ |
|
| 4046 | - if( $include_db_only_fields ){ |
|
| 4047 | - if( $this->_cached_fields === NULL ){ |
|
| 4045 | + public function field_settings($include_db_only_fields = false) { |
|
| 4046 | + if ($include_db_only_fields) { |
|
| 4047 | + if ($this->_cached_fields === NULL) { |
|
| 4048 | 4048 | $this->_cached_fields = array(); |
| 4049 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
| 4050 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
| 4051 | - $this->_cached_fields[$field_name]=$field_obj; |
|
| 4049 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
| 4050 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
| 4051 | + $this->_cached_fields[$field_name] = $field_obj; |
|
| 4052 | 4052 | } |
| 4053 | 4053 | } |
| 4054 | 4054 | } |
| 4055 | 4055 | return $this->_cached_fields; |
| 4056 | - }else{ |
|
| 4057 | - if( $this->_cached_fields_non_db_only === NULL ){ |
|
| 4056 | + } else { |
|
| 4057 | + if ($this->_cached_fields_non_db_only === NULL) { |
|
| 4058 | 4058 | $this->_cached_fields_non_db_only = array(); |
| 4059 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
| 4060 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
| 4059 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
| 4060 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
| 4061 | 4061 | /** @var $field_obj EE_Model_Field_Base */ |
| 4062 | - if( ! $field_obj->is_db_only_field() ){ |
|
| 4063 | - $this->_cached_fields_non_db_only[$field_name]=$field_obj; |
|
| 4062 | + if ( ! $field_obj->is_db_only_field()) { |
|
| 4063 | + $this->_cached_fields_non_db_only[$field_name] = $field_obj; |
|
| 4064 | 4064 | } |
| 4065 | 4065 | } |
| 4066 | 4066 | } |
@@ -4079,60 +4079,60 @@ discard block |
||
| 4079 | 4079 | * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed) |
| 4080 | 4080 | * @throws \EE_Error |
| 4081 | 4081 | */ |
| 4082 | - protected function _create_objects( $rows = array() ) { |
|
| 4083 | - $array_of_objects=array(); |
|
| 4084 | - if(empty($rows)){ |
|
| 4082 | + protected function _create_objects($rows = array()) { |
|
| 4083 | + $array_of_objects = array(); |
|
| 4084 | + if (empty($rows)) { |
|
| 4085 | 4085 | return array(); |
| 4086 | 4086 | } |
| 4087 | 4087 | $count_if_model_has_no_primary_key = 0; |
| 4088 | 4088 | $has_primary_key = $this->has_primary_key_field(); |
| 4089 | 4089 | $primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null; |
| 4090 | - foreach ( (array)$rows as $row ) { |
|
| 4091 | - if(empty($row)){ |
|
| 4090 | + foreach ((array) $rows as $row) { |
|
| 4091 | + if (empty($row)) { |
|
| 4092 | 4092 | //wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful... |
| 4093 | 4093 | return array(); |
| 4094 | 4094 | } |
| 4095 | 4095 | //check if we've already set this object in the results array, |
| 4096 | 4096 | //in which case there's no need to process it further (again) |
| 4097 | - if( $has_primary_key ) { |
|
| 4097 | + if ($has_primary_key) { |
|
| 4098 | 4098 | $table_pk_value = $this->_get_column_value_with_table_alias_or_not( |
| 4099 | 4099 | $row, |
| 4100 | 4100 | $primary_key_field->get_qualified_column(), |
| 4101 | 4101 | $primary_key_field->get_table_column() |
| 4102 | 4102 | ); |
| 4103 | - if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) { |
|
| 4103 | + if ($table_pk_value && isset($array_of_objects[$table_pk_value])) { |
|
| 4104 | 4104 | continue; |
| 4105 | 4105 | } |
| 4106 | 4106 | } |
| 4107 | 4107 | $classInstance = $this->instantiate_class_from_array_or_object($row); |
| 4108 | - if( ! $classInstance ) { |
|
| 4108 | + if ( ! $classInstance) { |
|
| 4109 | 4109 | throw new EE_Error( |
| 4110 | 4110 | sprintf( |
| 4111 | - __( 'Could not create instance of class %s from row %s', 'event_espresso' ), |
|
| 4111 | + __('Could not create instance of class %s from row %s', 'event_espresso'), |
|
| 4112 | 4112 | $this->get_this_model_name(), |
| 4113 | - http_build_query( $row ) |
|
| 4113 | + http_build_query($row) |
|
| 4114 | 4114 | ) |
| 4115 | 4115 | ); |
| 4116 | 4116 | } |
| 4117 | 4117 | //set the timezone on the instantiated objects |
| 4118 | - $classInstance->set_timezone( $this->_timezone ); |
|
| 4118 | + $classInstance->set_timezone($this->_timezone); |
|
| 4119 | 4119 | //make sure if there is any timezone setting present that we set the timezone for the object |
| 4120 | 4120 | $key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++; |
| 4121 | - $array_of_objects[ $key ] = $classInstance; |
|
| 4121 | + $array_of_objects[$key] = $classInstance; |
|
| 4122 | 4122 | //also, for all the relations of type BelongsTo, see if we can cache |
| 4123 | 4123 | //those related models |
| 4124 | 4124 | //(we could do this for other relations too, but if there are conditions |
| 4125 | 4125 | //that filtered out some fo the results, then we'd be caching an incomplete set |
| 4126 | 4126 | //so it requires a little more thought than just caching them immediately...) |
| 4127 | - foreach($this->_model_relations as $modelName => $relation_obj){ |
|
| 4128 | - if( $relation_obj instanceof EE_Belongs_To_Relation){ |
|
| 4127 | + foreach ($this->_model_relations as $modelName => $relation_obj) { |
|
| 4128 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
| 4129 | 4129 | //check if this model's INFO is present. If so, cache it on the model |
| 4130 | 4130 | $other_model = $relation_obj->get_other_model(); |
| 4131 | 4131 | $other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row); |
| 4132 | 4132 | //if we managed to make a model object from the results, cache it on the main model object |
| 4133 | - if( $other_model_obj_maybe ){ |
|
| 4133 | + if ($other_model_obj_maybe) { |
|
| 4134 | 4134 | //set timezone on these other model objects if they are present |
| 4135 | - $other_model_obj_maybe->set_timezone( $this->_timezone ); |
|
| 4135 | + $other_model_obj_maybe->set_timezone($this->_timezone); |
|
| 4136 | 4136 | $classInstance->cache($modelName, $other_model_obj_maybe); |
| 4137 | 4137 | } |
| 4138 | 4138 | } |
@@ -4153,12 +4153,12 @@ discard block |
||
| 4153 | 4153 | |
| 4154 | 4154 | $this_model_fields_and_values = array(); |
| 4155 | 4155 | //setup the row using default values; |
| 4156 | - foreach ( $this->field_settings() as $field_name => $field_obj ) { |
|
| 4156 | + foreach ($this->field_settings() as $field_name => $field_obj) { |
|
| 4157 | 4157 | $this_model_fields_and_values[$field_name] = $field_obj->get_default_value(); |
| 4158 | 4158 | } |
| 4159 | 4159 | |
| 4160 | 4160 | $className = $this->_get_class_name(); |
| 4161 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE ); |
|
| 4161 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE); |
|
| 4162 | 4162 | |
| 4163 | 4163 | return $classInstance; |
| 4164 | 4164 | } |
@@ -4171,45 +4171,45 @@ discard block |
||
| 4171 | 4171 | * @return EE_Base_Class |
| 4172 | 4172 | * @throws \EE_Error |
| 4173 | 4173 | */ |
| 4174 | - public function instantiate_class_from_array_or_object($cols_n_values){ |
|
| 4175 | - if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) { |
|
| 4176 | - $cols_n_values = get_object_vars( $cols_n_values ); |
|
| 4174 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
| 4175 | + if ( ! is_array($cols_n_values) && is_object($cols_n_values)) { |
|
| 4176 | + $cols_n_values = get_object_vars($cols_n_values); |
|
| 4177 | 4177 | } |
| 4178 | 4178 | $primary_key = NULL; |
| 4179 | 4179 | //make sure the array only has keys that are fields/columns on this model |
| 4180 | - $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
| 4181 | - if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){ |
|
| 4182 | - $primary_key = $this_model_fields_n_values[ $this->primary_key_name() ]; |
|
| 4180 | + $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
| 4181 | + if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) { |
|
| 4182 | + $primary_key = $this_model_fields_n_values[$this->primary_key_name()]; |
|
| 4183 | 4183 | } |
| 4184 | - $className=$this->_get_class_name(); |
|
| 4184 | + $className = $this->_get_class_name(); |
|
| 4185 | 4185 | |
| 4186 | 4186 | //check we actually found results that we can use to build our model object |
| 4187 | 4187 | //if not, return null |
| 4188 | - if( $this->has_primary_key_field()){ |
|
| 4189 | - if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){ |
|
| 4188 | + if ($this->has_primary_key_field()) { |
|
| 4189 | + if (empty($this_model_fields_n_values[$this->primary_key_name()])) { |
|
| 4190 | 4190 | return NULL; |
| 4191 | 4191 | } |
| 4192 | - }else if($this->unique_indexes()){ |
|
| 4192 | + } else if ($this->unique_indexes()) { |
|
| 4193 | 4193 | $first_column = reset($this_model_fields_n_values); |
| 4194 | - if(empty($first_column)){ |
|
| 4194 | + if (empty($first_column)) { |
|
| 4195 | 4195 | return NULL; |
| 4196 | 4196 | } |
| 4197 | 4197 | } |
| 4198 | 4198 | |
| 4199 | 4199 | // if there is no primary key or the object doesn't already exist in the entity map, then create a new instance |
| 4200 | - if ( $primary_key){ |
|
| 4201 | - $classInstance = $this->get_from_entity_map( $primary_key ); |
|
| 4202 | - if( ! $classInstance) { |
|
| 4203 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
| 4200 | + if ($primary_key) { |
|
| 4201 | + $classInstance = $this->get_from_entity_map($primary_key); |
|
| 4202 | + if ( ! $classInstance) { |
|
| 4203 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
| 4204 | 4204 | // add this new object to the entity map |
| 4205 | - $classInstance = $this->add_to_entity_map( $classInstance ); |
|
| 4205 | + $classInstance = $this->add_to_entity_map($classInstance); |
|
| 4206 | 4206 | } |
| 4207 | - }else{ |
|
| 4208 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
| 4207 | + } else { |
|
| 4208 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
| 4209 | 4209 | } |
| 4210 | 4210 | |
| 4211 | 4211 | //it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example). In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property. |
| 4212 | - $this->set_timezone( $classInstance->get_timezone() ); |
|
| 4212 | + $this->set_timezone($classInstance->get_timezone()); |
|
| 4213 | 4213 | return $classInstance; |
| 4214 | 4214 | } |
| 4215 | 4215 | /** |
@@ -4217,8 +4217,8 @@ discard block |
||
| 4217 | 4217 | * @param int|string $id the ID of the model object |
| 4218 | 4218 | * @return EE_Base_Class |
| 4219 | 4219 | */ |
| 4220 | - public function get_from_entity_map( $id ){ |
|
| 4221 | - return isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ? $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] : NULL; |
|
| 4220 | + public function get_from_entity_map($id) { |
|
| 4221 | + return isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]) ? $this->_entity_map[EEM_Base::$_model_query_blog_id][$id] : NULL; |
|
| 4222 | 4222 | } |
| 4223 | 4223 | |
| 4224 | 4224 | |
@@ -4240,21 +4240,21 @@ discard block |
||
| 4240 | 4240 | * @throws EE_Error |
| 4241 | 4241 | * @return \EE_Base_Class |
| 4242 | 4242 | */ |
| 4243 | - public function add_to_entity_map( EE_Base_Class $object) { |
|
| 4243 | + public function add_to_entity_map(EE_Base_Class $object) { |
|
| 4244 | 4244 | $className = $this->_get_class_name(); |
| 4245 | - if( ! $object instanceof $className ){ |
|
| 4246 | - throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) ); |
|
| 4245 | + if ( ! $object instanceof $className) { |
|
| 4246 | + throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className)); |
|
| 4247 | 4247 | } |
| 4248 | 4248 | /** @var $object EE_Base_Class */ |
| 4249 | - if ( ! $object->ID() ){ |
|
| 4250 | - throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this))); |
|
| 4249 | + if ( ! $object->ID()) { |
|
| 4250 | + throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this))); |
|
| 4251 | 4251 | } |
| 4252 | 4252 | // double check it's not already there |
| 4253 | - $classInstance = $this->get_from_entity_map( $object->ID() ); |
|
| 4254 | - if ( $classInstance ) { |
|
| 4253 | + $classInstance = $this->get_from_entity_map($object->ID()); |
|
| 4254 | + if ($classInstance) { |
|
| 4255 | 4255 | return $classInstance; |
| 4256 | 4256 | } else { |
| 4257 | - $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $object->ID() ] = $object; |
|
| 4257 | + $this->_entity_map[EEM_Base::$_model_query_blog_id][$object->ID()] = $object; |
|
| 4258 | 4258 | return $object; |
| 4259 | 4259 | } |
| 4260 | 4260 | } |
@@ -4268,13 +4268,13 @@ discard block |
||
| 4268 | 4268 | * @param int|string $id the ID of the model object |
| 4269 | 4269 | * @return boolean |
| 4270 | 4270 | */ |
| 4271 | - public function clear_entity_map( $id = null ) { |
|
| 4272 | - if ( empty( $id ) ) { |
|
| 4273 | - $this->_entity_map[ EEM_Base::$_model_query_blog_id ] = array(); |
|
| 4271 | + public function clear_entity_map($id = null) { |
|
| 4272 | + if (empty($id)) { |
|
| 4273 | + $this->_entity_map[EEM_Base::$_model_query_blog_id] = array(); |
|
| 4274 | 4274 | return true; |
| 4275 | 4275 | } |
| 4276 | - if ( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ) { |
|
| 4277 | - unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ); |
|
| 4276 | + if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id])) { |
|
| 4277 | + unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]); |
|
| 4278 | 4278 | return true; |
| 4279 | 4279 | } |
| 4280 | 4280 | return false; |
@@ -4290,8 +4290,8 @@ discard block |
||
| 4290 | 4290 | * @param array $cols_n_values |
| 4291 | 4291 | * @return array |
| 4292 | 4292 | */ |
| 4293 | - public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) { |
|
| 4294 | - return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
| 4293 | + public function deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
| 4294 | + return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
| 4295 | 4295 | } |
| 4296 | 4296 | |
| 4297 | 4297 | |
@@ -4304,23 +4304,23 @@ discard block |
||
| 4304 | 4304 | * @param string $cols_n_values |
| 4305 | 4305 | * @return array |
| 4306 | 4306 | */ |
| 4307 | - protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){ |
|
| 4307 | + protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
| 4308 | 4308 | $this_model_fields_n_values = array(); |
| 4309 | - foreach( $this->get_tables() as $table_alias => $table_obj ) { |
|
| 4310 | - $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() ); |
|
| 4309 | + foreach ($this->get_tables() as $table_alias => $table_obj) { |
|
| 4310 | + $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column()); |
|
| 4311 | 4311 | //there is a primary key on this table and its not set. Use defaults for all its columns |
| 4312 | - if( $table_pk_value === null && $table_obj->get_pk_column() ){ |
|
| 4313 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
| 4314 | - if( ! $field_obj->is_db_only_field() ){ |
|
| 4312 | + if ($table_pk_value === null && $table_obj->get_pk_column()) { |
|
| 4313 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
| 4314 | + if ( ! $field_obj->is_db_only_field()) { |
|
| 4315 | 4315 | //prepare field as if its coming from db |
| 4316 | - $prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() ); |
|
| 4317 | - $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value ); |
|
| 4316 | + $prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value()); |
|
| 4317 | + $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value); |
|
| 4318 | 4318 | } |
| 4319 | 4319 | } |
| 4320 | - }else{ |
|
| 4320 | + } else { |
|
| 4321 | 4321 | //the table's rows existed. Use their values |
| 4322 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
| 4323 | - if( ! $field_obj->is_db_only_field() ){ |
|
| 4322 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
| 4323 | + if ( ! $field_obj->is_db_only_field()) { |
|
| 4324 | 4324 | $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not( |
| 4325 | 4325 | $cols_n_values, $field_obj->get_qualified_column(), |
| 4326 | 4326 | $field_obj->get_table_column() |
@@ -4340,15 +4340,15 @@ discard block |
||
| 4340 | 4340 | * @param $regular_column |
| 4341 | 4341 | * @return null |
| 4342 | 4342 | */ |
| 4343 | - protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){ |
|
| 4343 | + protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) { |
|
| 4344 | 4344 | $value = null; |
| 4345 | 4345 | //ask the field what it think it's table_name.column_name should be, and call it the "qualified column" |
| 4346 | 4346 | //does the field on the model relate to this column retrieved from the db? |
| 4347 | 4347 | //or is it a db-only field? (not relating to the model) |
| 4348 | - if( isset( $cols_n_values[ $qualified_column ] ) ){ |
|
| 4349 | - $value = $cols_n_values[ $qualified_column ]; |
|
| 4350 | - }elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
| 4351 | - $value = $cols_n_values[ $regular_column ]; |
|
| 4348 | + if (isset($cols_n_values[$qualified_column])) { |
|
| 4349 | + $value = $cols_n_values[$qualified_column]; |
|
| 4350 | + }elseif (isset($cols_n_values[$regular_column])) { |
|
| 4351 | + $value = $cols_n_values[$regular_column]; |
|
| 4352 | 4352 | } |
| 4353 | 4353 | return $value; |
| 4354 | 4354 | } |
@@ -4364,25 +4364,25 @@ discard block |
||
| 4364 | 4364 | * @return EE_Base_Class |
| 4365 | 4365 | * @throws \EE_Error |
| 4366 | 4366 | */ |
| 4367 | - public function refresh_entity_map_from_db( $id ){ |
|
| 4368 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
| 4369 | - if( $obj_in_map ){ |
|
| 4367 | + public function refresh_entity_map_from_db($id) { |
|
| 4368 | + $obj_in_map = $this->get_from_entity_map($id); |
|
| 4369 | + if ($obj_in_map) { |
|
| 4370 | 4370 | $wpdb_results = $this->_get_all_wpdb_results( |
| 4371 | - array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) |
|
| 4371 | + array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1) |
|
| 4372 | 4372 | ); |
| 4373 | - if( $wpdb_results && is_array( $wpdb_results ) ){ |
|
| 4374 | - $one_row = reset( $wpdb_results ); |
|
| 4375 | - foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) { |
|
| 4376 | - $obj_in_map->set_from_db( $field_name, $db_value ); |
|
| 4373 | + if ($wpdb_results && is_array($wpdb_results)) { |
|
| 4374 | + $one_row = reset($wpdb_results); |
|
| 4375 | + foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) { |
|
| 4376 | + $obj_in_map->set_from_db($field_name, $db_value); |
|
| 4377 | 4377 | } |
| 4378 | 4378 | //clear the cache of related model objects |
| 4379 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
| 4380 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
| 4379 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
| 4380 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
| 4381 | 4381 | } |
| 4382 | 4382 | } |
| 4383 | 4383 | return $obj_in_map; |
| 4384 | - }else{ |
|
| 4385 | - return $this->get_one_by_ID( $id ); |
|
| 4384 | + } else { |
|
| 4385 | + return $this->get_one_by_ID($id); |
|
| 4386 | 4386 | } |
| 4387 | 4387 | } |
| 4388 | 4388 | |
@@ -4400,24 +4400,24 @@ discard block |
||
| 4400 | 4400 | * @return \EE_Base_Class |
| 4401 | 4401 | * @throws \EE_Error |
| 4402 | 4402 | */ |
| 4403 | - public function refresh_entity_map_with( $id, $replacing_model_obj ) { |
|
| 4404 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
| 4405 | - if( $obj_in_map ){ |
|
| 4406 | - if( $replacing_model_obj instanceof EE_Base_Class ){ |
|
| 4407 | - foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) { |
|
| 4408 | - $obj_in_map->set( $field_name, $value ); |
|
| 4403 | + public function refresh_entity_map_with($id, $replacing_model_obj) { |
|
| 4404 | + $obj_in_map = $this->get_from_entity_map($id); |
|
| 4405 | + if ($obj_in_map) { |
|
| 4406 | + if ($replacing_model_obj instanceof EE_Base_Class) { |
|
| 4407 | + foreach ($replacing_model_obj->model_field_array() as $field_name => $value) { |
|
| 4408 | + $obj_in_map->set($field_name, $value); |
|
| 4409 | 4409 | } |
| 4410 | 4410 | //make the model object in the entity map's cache match the $replacing_model_obj |
| 4411 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
| 4412 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
| 4413 | - foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) { |
|
| 4414 | - $obj_in_map->cache( $relation_name, $cached_obj, $cache_id ); |
|
| 4411 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
| 4412 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
| 4413 | + foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) { |
|
| 4414 | + $obj_in_map->cache($relation_name, $cached_obj, $cache_id); |
|
| 4415 | 4415 | } |
| 4416 | 4416 | } |
| 4417 | 4417 | } |
| 4418 | 4418 | return $obj_in_map; |
| 4419 | - }else{ |
|
| 4420 | - $this->add_to_entity_map( $replacing_model_obj ); |
|
| 4419 | + } else { |
|
| 4420 | + $this->add_to_entity_map($replacing_model_obj); |
|
| 4421 | 4421 | return $replacing_model_obj; |
| 4422 | 4422 | } |
| 4423 | 4423 | } |
@@ -4430,7 +4430,7 @@ discard block |
||
| 4430 | 4430 | * require_once($this->_getClassName().".class.php"); |
| 4431 | 4431 | * @return string |
| 4432 | 4432 | */ |
| 4433 | - private function _get_class_name(){ |
|
| 4433 | + private function _get_class_name() { |
|
| 4434 | 4434 | return "EE_".$this->get_this_model_name(); |
| 4435 | 4435 | } |
| 4436 | 4436 | |
@@ -4443,8 +4443,8 @@ discard block |
||
| 4443 | 4443 | * @param int $quantity |
| 4444 | 4444 | * @return string |
| 4445 | 4445 | */ |
| 4446 | - public function item_name($quantity = 1){ |
|
| 4447 | - return (int)$quantity === 1 ? $this->singular_item : $this->plural_item; |
|
| 4446 | + public function item_name($quantity = 1) { |
|
| 4447 | + return (int) $quantity === 1 ? $this->singular_item : $this->plural_item; |
|
| 4448 | 4448 | } |
| 4449 | 4449 | |
| 4450 | 4450 | |
@@ -4471,13 +4471,13 @@ discard block |
||
| 4471 | 4471 | * @throws EE_Error |
| 4472 | 4472 | * @return mixed whatever the plugin which calls add_filter decides |
| 4473 | 4473 | */ |
| 4474 | - public function __call($methodName,$args){ |
|
| 4475 | - $className=get_class($this); |
|
| 4476 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
| 4477 | - if(!has_filter($tagName)){ |
|
| 4474 | + public function __call($methodName, $args) { |
|
| 4475 | + $className = get_class($this); |
|
| 4476 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
| 4477 | + if ( ! has_filter($tagName)) { |
|
| 4478 | 4478 | throw new EE_Error( |
| 4479 | 4479 | sprintf( |
| 4480 | - __( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ), |
|
| 4480 | + __('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'), |
|
| 4481 | 4481 | $methodName, |
| 4482 | 4482 | $className, |
| 4483 | 4483 | $tagName, |
@@ -4486,7 +4486,7 @@ discard block |
||
| 4486 | 4486 | ); |
| 4487 | 4487 | } |
| 4488 | 4488 | |
| 4489 | - return apply_filters($tagName,null,$this,$args); |
|
| 4489 | + return apply_filters($tagName, null, $this, $args); |
|
| 4490 | 4490 | } |
| 4491 | 4491 | |
| 4492 | 4492 | |
@@ -4504,28 +4504,28 @@ discard block |
||
| 4504 | 4504 | * @throws EE_Error |
| 4505 | 4505 | * @return EE_Base_Class |
| 4506 | 4506 | */ |
| 4507 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){ |
|
| 4507 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
| 4508 | 4508 | $className = $this->_get_class_name(); |
| 4509 | - if ( $base_class_obj_or_id instanceof $className ) { |
|
| 4509 | + if ($base_class_obj_or_id instanceof $className) { |
|
| 4510 | 4510 | $model_object = $base_class_obj_or_id; |
| 4511 | 4511 | } else { |
| 4512 | 4512 | $primary_key_field = $this->get_primary_key_field(); |
| 4513 | 4513 | if ( |
| 4514 | 4514 | $primary_key_field instanceof EE_Primary_Key_Int_Field |
| 4515 | 4515 | && ( |
| 4516 | - is_int( $base_class_obj_or_id ) |
|
| 4517 | - || is_string( $base_class_obj_or_id ) |
|
| 4516 | + is_int($base_class_obj_or_id) |
|
| 4517 | + || is_string($base_class_obj_or_id) |
|
| 4518 | 4518 | ) |
| 4519 | 4519 | ) { |
| 4520 | 4520 | // assume it's an ID. |
| 4521 | 4521 | // either a proper integer or a string representing an integer (eg "101" instead of 101) |
| 4522 | - $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
|
| 4522 | + $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
|
| 4523 | 4523 | } else if ( |
| 4524 | 4524 | $primary_key_field instanceof EE_Primary_Key_String_Field |
| 4525 | - && is_string( $base_class_obj_or_id ) |
|
| 4525 | + && is_string($base_class_obj_or_id) |
|
| 4526 | 4526 | ) { |
| 4527 | 4527 | // assume its a string representation of the object |
| 4528 | - $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
|
| 4528 | + $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
|
| 4529 | 4529 | } else { |
| 4530 | 4530 | throw new EE_Error( |
| 4531 | 4531 | sprintf( |
@@ -4535,12 +4535,12 @@ discard block |
||
| 4535 | 4535 | ), |
| 4536 | 4536 | $base_class_obj_or_id, |
| 4537 | 4537 | $this->_get_class_name(), |
| 4538 | - print_r( $base_class_obj_or_id, true ) |
|
| 4538 | + print_r($base_class_obj_or_id, true) |
|
| 4539 | 4539 | ) |
| 4540 | 4540 | ); |
| 4541 | 4541 | } |
| 4542 | 4542 | } |
| 4543 | - if ( $ensure_is_in_db && $model_object->ID() !== null ) { |
|
| 4543 | + if ($ensure_is_in_db && $model_object->ID() !== null) { |
|
| 4544 | 4544 | $model_object->save(); |
| 4545 | 4545 | } |
| 4546 | 4546 | return $model_object; |
@@ -4556,19 +4556,19 @@ discard block |
||
| 4556 | 4556 | * @return int|string depending on the type of this model object's ID |
| 4557 | 4557 | * @throws EE_Error |
| 4558 | 4558 | */ |
| 4559 | - public function ensure_is_ID($base_class_obj_or_id){ |
|
| 4559 | + public function ensure_is_ID($base_class_obj_or_id) { |
|
| 4560 | 4560 | $className = $this->_get_class_name(); |
| 4561 | - if( $base_class_obj_or_id instanceof $className ){ |
|
| 4561 | + if ($base_class_obj_or_id instanceof $className) { |
|
| 4562 | 4562 | /** @var $base_class_obj_or_id EE_Base_Class */ |
| 4563 | 4563 | $id = $base_class_obj_or_id->ID(); |
| 4564 | - }elseif(is_int($base_class_obj_or_id)){ |
|
| 4564 | + }elseif (is_int($base_class_obj_or_id)) { |
|
| 4565 | 4565 | //assume it's an ID |
| 4566 | 4566 | $id = $base_class_obj_or_id; |
| 4567 | - }elseif(is_string($base_class_obj_or_id)){ |
|
| 4567 | + }elseif (is_string($base_class_obj_or_id)) { |
|
| 4568 | 4568 | //assume its a string representation of the object |
| 4569 | 4569 | $id = $base_class_obj_or_id; |
| 4570 | - }else{ |
|
| 4571 | - throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
|
| 4570 | + } else { |
|
| 4571 | + throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true))); |
|
| 4572 | 4572 | } |
| 4573 | 4573 | return $id; |
| 4574 | 4574 | } |
@@ -4591,14 +4591,14 @@ discard block |
||
| 4591 | 4591 | * @param int $values_already_prepared like one of the constants on EEM_Base |
| 4592 | 4592 | * @return void |
| 4593 | 4593 | */ |
| 4594 | - public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){ |
|
| 4594 | + public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) { |
|
| 4595 | 4595 | $this->_values_already_prepared_by_model_object = $values_already_prepared; |
| 4596 | 4596 | } |
| 4597 | 4597 | /** |
| 4598 | 4598 | * Read comments for assume_values_already_prepared_by_model_object() |
| 4599 | 4599 | * @return int |
| 4600 | 4600 | */ |
| 4601 | - public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
|
| 4601 | + public function get_assumption_concerning_values_already_prepared_by_model_object() { |
|
| 4602 | 4602 | return $this->_values_already_prepared_by_model_object; |
| 4603 | 4603 | } |
| 4604 | 4604 | |
@@ -4606,17 +4606,17 @@ discard block |
||
| 4606 | 4606 | * Gets all the indexes on this model |
| 4607 | 4607 | * @return EE_Index[] |
| 4608 | 4608 | */ |
| 4609 | - public function indexes(){ |
|
| 4609 | + public function indexes() { |
|
| 4610 | 4610 | return $this->_indexes; |
| 4611 | 4611 | } |
| 4612 | 4612 | /** |
| 4613 | 4613 | * Gets all the Unique Indexes on this model |
| 4614 | 4614 | * @return EE_Unique_Index[] |
| 4615 | 4615 | */ |
| 4616 | - public function unique_indexes(){ |
|
| 4616 | + public function unique_indexes() { |
|
| 4617 | 4617 | $unique_indexes = array(); |
| 4618 | - foreach($this->_indexes as $name => $index){ |
|
| 4619 | - if($index instanceof EE_Unique_Index){ |
|
| 4618 | + foreach ($this->_indexes as $name => $index) { |
|
| 4619 | + if ($index instanceof EE_Unique_Index) { |
|
| 4620 | 4620 | $unique_indexes [$name] = $index; |
| 4621 | 4621 | } |
| 4622 | 4622 | } |
@@ -4634,13 +4634,13 @@ discard block |
||
| 4634 | 4634 | * @return EE_Model_Field_Base[] indexed by the field's name |
| 4635 | 4635 | * @throws \EE_Error |
| 4636 | 4636 | */ |
| 4637 | - public function get_combined_primary_key_fields(){ |
|
| 4638 | - foreach($this->indexes() as $index){ |
|
| 4639 | - if($index instanceof EE_Primary_Key_Index){ |
|
| 4637 | + public function get_combined_primary_key_fields() { |
|
| 4638 | + foreach ($this->indexes() as $index) { |
|
| 4639 | + if ($index instanceof EE_Primary_Key_Index) { |
|
| 4640 | 4640 | return $index->fields(); |
| 4641 | 4641 | } |
| 4642 | 4642 | } |
| 4643 | - return array( $this->primary_key_name() => $this->get_primary_key_field()); |
|
| 4643 | + return array($this->primary_key_name() => $this->get_primary_key_field()); |
|
| 4644 | 4644 | } |
| 4645 | 4645 | |
| 4646 | 4646 | |
@@ -4654,7 +4654,7 @@ discard block |
||
| 4654 | 4654 | * @return string |
| 4655 | 4655 | * @throws \EE_Error |
| 4656 | 4656 | */ |
| 4657 | - public function get_index_primary_key_string($cols_n_values){ |
|
| 4657 | + public function get_index_primary_key_string($cols_n_values) { |
|
| 4658 | 4658 | $cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields()); |
| 4659 | 4659 | return http_build_query($cols_n_values_for_primary_key_index); |
| 4660 | 4660 | } |
@@ -4669,13 +4669,13 @@ discard block |
||
| 4669 | 4669 | * @return null|array |
| 4670 | 4670 | * @throws \EE_Error |
| 4671 | 4671 | */ |
| 4672 | - public function parse_index_primary_key_string( $index_primary_key_string) { |
|
| 4672 | + public function parse_index_primary_key_string($index_primary_key_string) { |
|
| 4673 | 4673 | $key_fields = $this->get_combined_primary_key_fields(); |
| 4674 | 4674 | //check all of them are in the $id |
| 4675 | 4675 | $key_vals_in_combined_pk = array(); |
| 4676 | - parse_str( $index_primary_key_string, $key_vals_in_combined_pk ); |
|
| 4677 | - foreach( $key_fields as $key_field_name => $field_obj ) { |
|
| 4678 | - if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){ |
|
| 4676 | + parse_str($index_primary_key_string, $key_vals_in_combined_pk); |
|
| 4677 | + foreach ($key_fields as $key_field_name => $field_obj) { |
|
| 4678 | + if ( ! isset($key_vals_in_combined_pk[$key_field_name])) { |
|
| 4679 | 4679 | return NULL; |
| 4680 | 4680 | } |
| 4681 | 4681 | } |
@@ -4692,10 +4692,10 @@ discard block |
||
| 4692 | 4692 | * @return boolean |
| 4693 | 4693 | * @throws \EE_Error |
| 4694 | 4694 | */ |
| 4695 | - public function has_all_combined_primary_key_fields( $key_vals ) { |
|
| 4696 | - $keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() ); |
|
| 4697 | - foreach( $keys_it_should_have as $key ){ |
|
| 4698 | - if( ! isset( $key_vals[ $key ] ) ){ |
|
| 4695 | + public function has_all_combined_primary_key_fields($key_vals) { |
|
| 4696 | + $keys_it_should_have = array_keys($this->get_combined_primary_key_fields()); |
|
| 4697 | + foreach ($keys_it_should_have as $key) { |
|
| 4698 | + if ( ! isset($key_vals[$key])) { |
|
| 4699 | 4699 | return false; |
| 4700 | 4700 | } |
| 4701 | 4701 | } |
@@ -4711,23 +4711,23 @@ discard block |
||
| 4711 | 4711 | * @throws EE_Error |
| 4712 | 4712 | * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed) |
| 4713 | 4713 | */ |
| 4714 | - public function get_all_copies($model_object_or_attributes_array, $query_params = array()){ |
|
| 4714 | + public function get_all_copies($model_object_or_attributes_array, $query_params = array()) { |
|
| 4715 | 4715 | |
| 4716 | - if($model_object_or_attributes_array instanceof EE_Base_Class){ |
|
| 4716 | + if ($model_object_or_attributes_array instanceof EE_Base_Class) { |
|
| 4717 | 4717 | $attributes_array = $model_object_or_attributes_array->model_field_array(); |
| 4718 | - }elseif(is_array($model_object_or_attributes_array)){ |
|
| 4718 | + }elseif (is_array($model_object_or_attributes_array)) { |
|
| 4719 | 4719 | $attributes_array = $model_object_or_attributes_array; |
| 4720 | - }else{ |
|
| 4721 | - throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array)); |
|
| 4720 | + } else { |
|
| 4721 | + throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array)); |
|
| 4722 | 4722 | } |
| 4723 | 4723 | //even copies obviously won't have the same ID, so remove the primary key |
| 4724 | 4724 | //from the WHERE conditions for finding copies (if there is a primary key, of course) |
| 4725 | - if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){ |
|
| 4725 | + if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) { |
|
| 4726 | 4726 | unset($attributes_array[$this->primary_key_name()]); |
| 4727 | 4727 | } |
| 4728 | - if(isset($query_params[0])){ |
|
| 4729 | - $query_params[0] = array_merge($attributes_array,$query_params); |
|
| 4730 | - }else{ |
|
| 4728 | + if (isset($query_params[0])) { |
|
| 4729 | + $query_params[0] = array_merge($attributes_array, $query_params); |
|
| 4730 | + } else { |
|
| 4731 | 4731 | $query_params[0] = $attributes_array; |
| 4732 | 4732 | } |
| 4733 | 4733 | return $this->get_all($query_params); |
@@ -4743,16 +4743,16 @@ discard block |
||
| 4743 | 4743 | * @return EE_Base_Class |
| 4744 | 4744 | * @throws \EE_Error |
| 4745 | 4745 | */ |
| 4746 | - public function get_one_copy($model_object_or_attributes_array,$query_params = array()){ |
|
| 4747 | - if( ! is_array( $query_params ) ){ |
|
| 4748 | - EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
| 4746 | + public function get_one_copy($model_object_or_attributes_array, $query_params = array()) { |
|
| 4747 | + if ( ! is_array($query_params)) { |
|
| 4748 | + EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
| 4749 | 4749 | $query_params = array(); |
| 4750 | 4750 | } |
| 4751 | 4751 | $query_params['limit'] = 1; |
| 4752 | - $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
|
| 4753 | - if(is_array($copies)){ |
|
| 4752 | + $copies = $this->get_all_copies($model_object_or_attributes_array, $query_params); |
|
| 4753 | + if (is_array($copies)) { |
|
| 4754 | 4754 | return array_shift($copies); |
| 4755 | - }else{ |
|
| 4755 | + } else { |
|
| 4756 | 4756 | return null; |
| 4757 | 4757 | } |
| 4758 | 4758 | } |
@@ -4768,10 +4768,10 @@ discard block |
||
| 4768 | 4768 | * @return int number of rows updated |
| 4769 | 4769 | * @throws \EE_Error |
| 4770 | 4770 | */ |
| 4771 | - public function update_by_ID($fields_n_values,$id){ |
|
| 4771 | + public function update_by_ID($fields_n_values, $id) { |
|
| 4772 | 4772 | $query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id), |
| 4773 | 4773 | 'default_where_conditions'=>'other_models_only',); |
| 4774 | - return $this->update($fields_n_values,$query_params); |
|
| 4774 | + return $this->update($fields_n_values, $query_params); |
|
| 4775 | 4775 | } |
| 4776 | 4776 | |
| 4777 | 4777 | |
@@ -4782,12 +4782,12 @@ discard block |
||
| 4782 | 4782 | * @return string an operator which can be used in SQL |
| 4783 | 4783 | * @throws EE_Error |
| 4784 | 4784 | */ |
| 4785 | - private function _prepare_operator_for_sql($operator_supplied){ |
|
| 4785 | + private function _prepare_operator_for_sql($operator_supplied) { |
|
| 4786 | 4786 | $sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null; |
| 4787 | - if($sql_operator){ |
|
| 4787 | + if ($sql_operator) { |
|
| 4788 | 4788 | return $sql_operator; |
| 4789 | - }else{ |
|
| 4790 | - throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators)))); |
|
| 4789 | + } else { |
|
| 4790 | + throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators)))); |
|
| 4791 | 4791 | } |
| 4792 | 4792 | } |
| 4793 | 4793 | |
@@ -4801,10 +4801,10 @@ discard block |
||
| 4801 | 4801 | * @return string[] |
| 4802 | 4802 | * @throws \EE_Error |
| 4803 | 4803 | */ |
| 4804 | - public function get_all_names($query_params = array()){ |
|
| 4804 | + public function get_all_names($query_params = array()) { |
|
| 4805 | 4805 | $objs = $this->get_all($query_params); |
| 4806 | 4806 | $names = array(); |
| 4807 | - foreach($objs as $obj){ |
|
| 4807 | + foreach ($objs as $obj) { |
|
| 4808 | 4808 | $names[$obj->ID()] = $obj->name(); |
| 4809 | 4809 | } |
| 4810 | 4810 | return $names; |
@@ -4823,11 +4823,11 @@ discard block |
||
| 4823 | 4823 | * @return array |
| 4824 | 4824 | * @throws \EE_Error |
| 4825 | 4825 | */ |
| 4826 | - public function get_IDs( $model_objects, $filter_out_empty_ids = false) { |
|
| 4827 | - if( ! $this->has_primary_key_field() ) { |
|
| 4828 | - if( WP_DEBUG ) { |
|
| 4826 | + public function get_IDs($model_objects, $filter_out_empty_ids = false) { |
|
| 4827 | + if ( ! $this->has_primary_key_field()) { |
|
| 4828 | + if (WP_DEBUG) { |
|
| 4829 | 4829 | EE_Error::add_error( |
| 4830 | - __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), |
|
| 4830 | + __('Trying to get IDs from a model than has no primary key', 'event_espresso'), |
|
| 4831 | 4831 | __FILE__, |
| 4832 | 4832 | __FUNCTION__, |
| 4833 | 4833 | __LINE__ |
@@ -4835,13 +4835,13 @@ discard block |
||
| 4835 | 4835 | } |
| 4836 | 4836 | } |
| 4837 | 4837 | $IDs = array(); |
| 4838 | - foreach( $model_objects as $model_object ) { |
|
| 4838 | + foreach ($model_objects as $model_object) { |
|
| 4839 | 4839 | $id = $model_object->ID(); |
| 4840 | - if( ! $id ) { |
|
| 4841 | - if( $filter_out_empty_ids ) { |
|
| 4840 | + if ( ! $id) { |
|
| 4841 | + if ($filter_out_empty_ids) { |
|
| 4842 | 4842 | continue; |
| 4843 | 4843 | } |
| 4844 | - if ( WP_DEBUG ) { |
|
| 4844 | + if (WP_DEBUG) { |
|
| 4845 | 4845 | EE_Error::add_error( |
| 4846 | 4846 | __( |
| 4847 | 4847 | 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', |
@@ -4863,8 +4863,8 @@ discard block |
||
| 4863 | 4863 | * are no capabilities that relate to this model returns false |
| 4864 | 4864 | * @return string|false |
| 4865 | 4865 | */ |
| 4866 | - public function cap_slug(){ |
|
| 4867 | - return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
| 4866 | + public function cap_slug() { |
|
| 4867 | + return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
| 4868 | 4868 | } |
| 4869 | 4869 | |
| 4870 | 4870 | |
@@ -4879,34 +4879,34 @@ discard block |
||
| 4879 | 4879 | * @return EE_Default_Where_Conditions[] indexed by associated capability |
| 4880 | 4880 | * @throws \EE_Error |
| 4881 | 4881 | */ |
| 4882 | - public function cap_restrictions( $context = EEM_Base::caps_read ) { |
|
| 4883 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
| 4882 | + public function cap_restrictions($context = EEM_Base::caps_read) { |
|
| 4883 | + EEM_Base::verify_is_valid_cap_context($context); |
|
| 4884 | 4884 | //check if we ought to run the restriction generator first |
| 4885 | - if( |
|
| 4886 | - isset( $this->_cap_restriction_generators[ $context ] ) |
|
| 4887 | - && $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base |
|
| 4888 | - && ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() |
|
| 4885 | + if ( |
|
| 4886 | + isset($this->_cap_restriction_generators[$context]) |
|
| 4887 | + && $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base |
|
| 4888 | + && ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions() |
|
| 4889 | 4889 | ) { |
| 4890 | - $this->_cap_restrictions[ $context ] = array_merge( |
|
| 4891 | - $this->_cap_restrictions[ $context ], |
|
| 4892 | - $this->_cap_restriction_generators[ $context ]->generate_restrictions() |
|
| 4890 | + $this->_cap_restrictions[$context] = array_merge( |
|
| 4891 | + $this->_cap_restrictions[$context], |
|
| 4892 | + $this->_cap_restriction_generators[$context]->generate_restrictions() |
|
| 4893 | 4893 | ); |
| 4894 | 4894 | } |
| 4895 | 4895 | //and make sure we've finalized the construction of each restriction |
| 4896 | - foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) { |
|
| 4897 | - if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) { |
|
| 4898 | - $where_conditions_obj->_finalize_construct( $this ); |
|
| 4896 | + foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) { |
|
| 4897 | + if ($where_conditions_obj instanceof EE_Default_Where_Conditions) { |
|
| 4898 | + $where_conditions_obj->_finalize_construct($this); |
|
| 4899 | 4899 | } |
| 4900 | 4900 | } |
| 4901 | 4901 | |
| 4902 | - return $this->_cap_restrictions[ $context ]; |
|
| 4902 | + return $this->_cap_restrictions[$context]; |
|
| 4903 | 4903 | } |
| 4904 | 4904 | |
| 4905 | 4905 | /** |
| 4906 | 4906 | * Indicating whether or not this model thinks its a wp core model |
| 4907 | 4907 | * @return boolean |
| 4908 | 4908 | */ |
| 4909 | - public function is_wp_core_model(){ |
|
| 4909 | + public function is_wp_core_model() { |
|
| 4910 | 4910 | return $this->_wp_core_model; |
| 4911 | 4911 | } |
| 4912 | 4912 | |
@@ -4920,12 +4920,12 @@ discard block |
||
| 4920 | 4920 | * @return EE_Default_Where_Conditions[] indexed by capability name |
| 4921 | 4921 | * @throws \EE_Error |
| 4922 | 4922 | */ |
| 4923 | - public function caps_missing( $context = EEM_Base::caps_read ) { |
|
| 4923 | + public function caps_missing($context = EEM_Base::caps_read) { |
|
| 4924 | 4924 | $missing_caps = array(); |
| 4925 | - $cap_restrictions = $this->cap_restrictions( $context ); |
|
| 4926 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
| 4927 | - if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) { |
|
| 4928 | - $missing_caps[ $cap ] = $restriction_if_no_cap; |
|
| 4925 | + $cap_restrictions = $this->cap_restrictions($context); |
|
| 4926 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
| 4927 | + if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) { |
|
| 4928 | + $missing_caps[$cap] = $restriction_if_no_cap; |
|
| 4929 | 4929 | } |
| 4930 | 4930 | } |
| 4931 | 4931 | return $missing_caps; |
@@ -4937,7 +4937,7 @@ discard block |
||
| 4937 | 4937 | * one of 'read', 'edit', or 'delete' |
| 4938 | 4938 | */ |
| 4939 | 4939 | public function cap_contexts_to_cap_action_map() { |
| 4940 | - return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this ); |
|
| 4940 | + return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this); |
|
| 4941 | 4941 | } |
| 4942 | 4942 | |
| 4943 | 4943 | |
@@ -4948,19 +4948,19 @@ discard block |
||
| 4948 | 4948 | * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values |
| 4949 | 4949 | * @throws \EE_Error |
| 4950 | 4950 | */ |
| 4951 | - public function cap_action_for_context( $context ) { |
|
| 4951 | + public function cap_action_for_context($context) { |
|
| 4952 | 4952 | $mapping = $this->cap_contexts_to_cap_action_map(); |
| 4953 | - if( isset( $mapping[ $context ] ) ) { |
|
| 4954 | - return $mapping[ $context ]; |
|
| 4953 | + if (isset($mapping[$context])) { |
|
| 4954 | + return $mapping[$context]; |
|
| 4955 | 4955 | } |
| 4956 | - if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) { |
|
| 4956 | + if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) { |
|
| 4957 | 4957 | return $action; |
| 4958 | 4958 | } |
| 4959 | 4959 | throw new EE_Error( |
| 4960 | 4960 | sprintf( |
| 4961 | - __( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ), |
|
| 4961 | + __('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'), |
|
| 4962 | 4962 | $context, |
| 4963 | - implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) ) |
|
| 4963 | + implode(',', array_keys($this->cap_contexts_to_cap_action_map())) |
|
| 4964 | 4964 | ) |
| 4965 | 4965 | ); |
| 4966 | 4966 | |
@@ -4971,7 +4971,7 @@ discard block |
||
| 4971 | 4971 | * @return array |
| 4972 | 4972 | */ |
| 4973 | 4973 | static public function valid_cap_contexts() { |
| 4974 | - return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array( |
|
| 4974 | + return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array( |
|
| 4975 | 4975 | self::caps_read, |
| 4976 | 4976 | self::caps_read_admin, |
| 4977 | 4977 | self::caps_edit, |
@@ -4987,17 +4987,17 @@ discard block |
||
| 4987 | 4987 | * @return bool |
| 4988 | 4988 | * @throws \EE_Error |
| 4989 | 4989 | */ |
| 4990 | - static public function verify_is_valid_cap_context( $context ) { |
|
| 4990 | + static public function verify_is_valid_cap_context($context) { |
|
| 4991 | 4991 | $valid_cap_contexts = EEM_Base::valid_cap_contexts(); |
| 4992 | - if( in_array( $context, $valid_cap_contexts ) ) { |
|
| 4992 | + if (in_array($context, $valid_cap_contexts)) { |
|
| 4993 | 4993 | return true; |
| 4994 | - }else{ |
|
| 4994 | + } else { |
|
| 4995 | 4995 | throw new EE_Error( |
| 4996 | 4996 | sprintf( |
| 4997 | - __( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ), |
|
| 4997 | + __('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'), |
|
| 4998 | 4998 | $context, |
| 4999 | - 'EEM_Base' , |
|
| 5000 | - implode(',', $valid_cap_contexts ) |
|
| 4999 | + 'EEM_Base', |
|
| 5000 | + implode(',', $valid_cap_contexts) |
|
| 5001 | 5001 | ) |
| 5002 | 5002 | ); |
| 5003 | 5003 | } |
@@ -328,7 +328,7 @@ |
||
| 328 | 328 | * @param int $TXN_ID |
| 329 | 329 | * @param int $ATT_ID |
| 330 | 330 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
| 331 | - * @return mixed array on success, FALSE on fail |
|
| 331 | + * @return null|EE_Base_Class array on success, FALSE on fail |
|
| 332 | 332 | */ |
| 333 | 333 | public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
| 334 | 334 | return $this->get_one(array( |
@@ -106,32 +106,32 @@ discard block |
||
| 106 | 106 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). |
| 107 | 107 | * 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) |
| 108 | 108 | */ |
| 109 | - protected function __construct( $timezone = null ) { |
|
| 110 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
| 111 | - $this->singular_item = __('Registration','event_espresso'); |
|
| 112 | - $this->plural_item = __('Registrations','event_espresso'); |
|
| 109 | + protected function __construct($timezone = null) { |
|
| 110 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 111 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
| 112 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
| 113 | 113 | |
| 114 | 114 | $this->_tables = array( |
| 115 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
| 115 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
| 116 | 116 | ); |
| 117 | 117 | $this->_fields = array( |
| 118 | 118 | 'Registration'=>array( |
| 119 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
| 120 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
| 121 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
| 122 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
| 123 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
| 124 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
| 125 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
| 126 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
| 127 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
| 128 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
| 129 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
| 130 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
| 131 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
| 132 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
| 133 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
| 134 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
| 119 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
| 120 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
| 121 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
| 122 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
| 123 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
| 124 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
| 125 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
| 126 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
| 127 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
| 128 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
| 129 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
| 130 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
| 131 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
| 132 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
| 133 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
| 134 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
| 135 | 135 | ) |
| 136 | 136 | ); |
| 137 | 137 | $this->_model_relations = array( |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | 'Answer'=>new EE_Has_Many_Relation(), |
| 144 | 144 | 'Checkin'=>new EE_Has_Many_Relation(), |
| 145 | 145 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
| 146 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
| 147 | - 'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletes even if there are messages in the queue related |
|
| 146 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
| 147 | + 'Message' => new EE_Has_Many_Any_Relation(false) //allow deletes even if there are messages in the queue related |
|
| 148 | 148 | ); |
| 149 | 149 | $this->_model_chain_to_wp_user = 'Event'; |
| 150 | 150 | |
| 151 | - parent::__construct( $timezone ); |
|
| 151 | + parent::__construct($timezone); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | * @param bool $translated If true will return the values as singular localized strings |
| 244 | 244 | * @return array |
| 245 | 245 | */ |
| 246 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
| 247 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
| 248 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
| 246 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
| 247 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
| 248 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | |
@@ -256,18 +256,18 @@ discard block |
||
| 256 | 256 | * @param array $exclude |
| 257 | 257 | * @return array |
| 258 | 258 | */ |
| 259 | - private function _get_registration_status_array( $exclude = array() ) { |
|
| 259 | + private function _get_registration_status_array($exclude = array()) { |
|
| 260 | 260 | //in the very rare circumstance that we are deleting a model's table's data |
| 261 | 261 | //and the table hasn't actually been created, this could have an error |
| 262 | 262 | /** @type WPDB $wpdb */ |
| 263 | 263 | global $wpdb; |
| 264 | - if( $this->_get_table_analysis()->tableExists( $wpdb->prefix . 'esp_status' ) ){ |
|
| 265 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
| 266 | - $results = $wpdb->get_results( $SQL ); |
|
| 264 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) { |
|
| 265 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
| 266 | + $results = $wpdb->get_results($SQL); |
|
| 267 | 267 | self::$_reg_status = array(); |
| 268 | - foreach ( $results as $status ) { |
|
| 269 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
| 270 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
| 268 | + foreach ($results as $status) { |
|
| 269 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
| 270 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -280,13 +280,13 @@ discard block |
||
| 280 | 280 | * @throws \EE_Error |
| 281 | 281 | */ |
| 282 | 282 | protected function _get_table_analysis() { |
| 283 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
| 283 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
| 284 | 284 | return $this->_table_analysis; |
| 285 | 285 | } else { |
| 286 | 286 | throw new \EE_Error( |
| 287 | 287 | sprintf( |
| 288 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
| 289 | - get_class( $this ) |
|
| 288 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
| 289 | + get_class($this) |
|
| 290 | 290 | ) |
| 291 | 291 | ); |
| 292 | 292 | } |
@@ -301,15 +301,15 @@ discard block |
||
| 301 | 301 | * @return array |
| 302 | 302 | * @throws \EE_Error |
| 303 | 303 | */ |
| 304 | - public function get_reg_months_and_years( $where_params ) { |
|
| 304 | + public function get_reg_months_and_years($where_params) { |
|
| 305 | 305 | $query_params[0] = $where_params; |
| 306 | 306 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
| 307 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
| 307 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
| 308 | 308 | $columns_to_select = array( |
| 309 | 309 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
| 310 | 310 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
| 311 | 311 | ); |
| 312 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
| 312 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
@@ -321,11 +321,11 @@ discard block |
||
| 321 | 321 | * @param int $ATT_ID |
| 322 | 322 | * @return EE_Registration[] |
| 323 | 323 | */ |
| 324 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
| 325 | - if ( ! $ATT_ID ) { |
|
| 324 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
| 325 | + if ( ! $ATT_ID) { |
|
| 326 | 326 | return FALSE; |
| 327 | 327 | } |
| 328 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
| 328 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | * @param string $REG_url_link |
| 337 | 337 | * @return EE_Registration |
| 338 | 338 | */ |
| 339 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
| 340 | - if(!$REG_url_link){ |
|
| 339 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
| 340 | + if ( ! $REG_url_link) { |
|
| 341 | 341 | return false; |
| 342 | 342 | } |
| 343 | 343 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -355,13 +355,13 @@ discard block |
||
| 355 | 355 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
| 356 | 356 | * @return mixed array on success, FALSE on fail |
| 357 | 357 | */ |
| 358 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
| 358 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
| 359 | 359 | return $this->get_one(array( |
| 360 | 360 | array( |
| 361 | 361 | 'TXN_ID'=>$TXN_ID, |
| 362 | 362 | 'ATT_ID'=>$ATT_ID |
| 363 | 363 | ), |
| 364 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
| 364 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
| 365 | 365 | )); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
| 374 | 374 | * @return stdClass[] with properties regDate and total |
| 375 | 375 | */ |
| 376 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
| 376 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
| 377 | 377 | |
| 378 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
| 379 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
| 378 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
| 379 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
| 380 | 380 | |
| 381 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
| 381 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
| 382 | 382 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' ); |
|
| 385 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
| 386 | 386 | |
| 387 | 387 | $results = $this->_get_all_wpdb_results( |
| 388 | 388 | array( |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | ), |
| 393 | 393 | OBJECT, |
| 394 | 394 | array( |
| 395 | - 'regDate'=>array( 'DATE(' . $query_interval . ')','%s'), |
|
| 396 | - 'total'=>array('count(REG_ID)','%d') |
|
| 395 | + 'regDate'=>array('DATE('.$query_interval.')', '%s'), |
|
| 396 | + 'total'=>array('count(REG_ID)', '%d') |
|
| 397 | 397 | )); |
| 398 | 398 | return $results; |
| 399 | 399 | } |
@@ -408,22 +408,22 @@ discard block |
||
| 408 | 408 | * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
| 409 | 409 | * (i.e. RAP) |
| 410 | 410 | */ |
| 411 | - public function get_registrations_per_day_and_per_status_report( $period = '-1 month' ) { |
|
| 411 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') { |
|
| 412 | 412 | global $wpdb; |
| 413 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 413 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
| 414 | 414 | $event_table = $wpdb->posts; |
| 415 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
| 415 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
| 416 | 416 | |
| 417 | 417 | //prepare the query interval for displaying offset |
| 418 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'dates.REG_date' ); |
|
| 418 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
| 419 | 419 | |
| 420 | 420 | //inner date query |
| 421 | 421 | $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
| 422 | 422 | $inner_where = " WHERE"; |
| 423 | 423 | //exclude events not authored by user if permissions in effect |
| 424 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
| 424 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 425 | 425 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
| 426 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
| 426 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
| 427 | 427 | } |
| 428 | 428 | $inner_where .= " REG_date >= '$sql_date'"; |
| 429 | 429 | $inner_date_query .= $inner_where; |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | $select_parts = array(); |
| 436 | 436 | |
| 437 | 437 | //loop through registration stati to do parts for each status. |
| 438 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
| 439 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
| 438 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
| 439 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
| 440 | 440 | continue; |
| 441 | 441 | } |
| 442 | 442 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -444,14 +444,14 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | //setup the selects |
| 447 | - $select .= implode(', ', $select_parts ); |
|
| 447 | + $select .= implode(', ', $select_parts); |
|
| 448 | 448 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
| 449 | 449 | |
| 450 | 450 | //setup the joins |
| 451 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
| 451 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
| 452 | 452 | |
| 453 | 453 | //now let's put it all together |
| 454 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
| 454 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
| 455 | 455 | |
| 456 | 456 | //and execute it |
| 457 | 457 | $results = $wpdb->get_results( |
@@ -472,23 +472,23 @@ discard block |
||
| 472 | 472 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
| 473 | 473 | * @return stdClass[] each with properties event_name, reg_limit, and total |
| 474 | 474 | */ |
| 475 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
| 475 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
| 476 | 476 | |
| 477 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
| 478 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
| 477 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
| 478 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
| 479 | 479 | |
| 480 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
| 480 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 481 | 481 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
| 482 | 482 | } |
| 483 | 483 | $results = $this->_get_all_wpdb_results(array( |
| 484 | 484 | $where, |
| 485 | 485 | 'group_by'=>'Event.EVT_name', |
| 486 | 486 | 'order_by'=>'Event.EVT_name', |
| 487 | - 'limit'=>array(0,24)), |
|
| 487 | + 'limit'=>array(0, 24)), |
|
| 488 | 488 | OBJECT, |
| 489 | 489 | array( |
| 490 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
| 491 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
| 490 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
| 491 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
| 492 | 492 | ) |
| 493 | 493 | ); |
| 494 | 494 | |
@@ -506,19 +506,19 @@ discard block |
||
| 506 | 506 | * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
| 507 | 507 | * (i.e. RAP) |
| 508 | 508 | */ |
| 509 | - public function get_registrations_per_event_and_per_status_report( $period = '-1 month' ) { |
|
| 509 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') { |
|
| 510 | 510 | global $wpdb; |
| 511 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 511 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
| 512 | 512 | $event_table = $wpdb->posts; |
| 513 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
| 513 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
| 514 | 514 | |
| 515 | 515 | //inner date query |
| 516 | 516 | $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
| 517 | 517 | $inner_where = " WHERE"; |
| 518 | 518 | //exclude events not authored by user if permissions in effect |
| 519 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
| 519 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 520 | 520 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
| 521 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
| 521 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
| 522 | 522 | } |
| 523 | 523 | $inner_where .= " REG_date >= '$sql_date'"; |
| 524 | 524 | $inner_date_query .= $inner_where; |
@@ -530,8 +530,8 @@ discard block |
||
| 530 | 530 | $select_parts = array(); |
| 531 | 531 | |
| 532 | 532 | //loop through registration stati to do parts for each status. |
| 533 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
| 534 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
| 533 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
| 534 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
| 535 | 535 | continue; |
| 536 | 536 | } |
| 537 | 537 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -539,14 +539,14 @@ discard block |
||
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | //setup the selects |
| 542 | - $select .= implode( ', ', $select_parts ); |
|
| 542 | + $select .= implode(', ', $select_parts); |
|
| 543 | 543 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
| 544 | 544 | |
| 545 | 545 | //setup remaining joins |
| 546 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
| 546 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
| 547 | 547 | |
| 548 | 548 | //now put it all together |
| 549 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
| 549 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
| 550 | 550 | |
| 551 | 551 | //and execute |
| 552 | 552 | $results = $wpdb->get_results( |
@@ -562,11 +562,11 @@ discard block |
||
| 562 | 562 | * @param int $TXN_ID |
| 563 | 563 | * @return EE_Registration |
| 564 | 564 | */ |
| 565 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
| 566 | - if( ! $TXN_ID ){ |
|
| 565 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
| 566 | + if ( ! $TXN_ID) { |
|
| 567 | 567 | return false; |
| 568 | 568 | } |
| 569 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
| 569 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | |
@@ -578,11 +578,11 @@ discard block |
||
| 578 | 578 | * @param boolean $for_incomplete_payments |
| 579 | 579 | * @return int |
| 580 | 580 | */ |
| 581 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
| 581 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
| 582 | 582 | // we only count approved registrations towards registration limits |
| 583 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
| 584 | - if( $for_incomplete_payments ){ |
|
| 585 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
| 583 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
| 584 | + if ($for_incomplete_payments) { |
|
| 585 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | return $this->count($query_params); |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | /** @type WPDB $wpdb */ |
| 599 | 599 | global $wpdb; |
| 600 | 600 | return $wpdb->query( |
| 601 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
| 601 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
@@ -608,17 +608,17 @@ discard block |
||
| 608 | 608 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
| 609 | 609 | * @return int |
| 610 | 610 | */ |
| 611 | - public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) { |
|
| 611 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) { |
|
| 612 | 612 | global $wpdb; |
| 613 | 613 | //subquery to get latest checkin |
| 614 | 614 | $query = $wpdb->prepare( |
| 615 | 615 | 'SELECT ' |
| 616 | 616 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
| 617 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
| 617 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
| 618 | 618 | . '( SELECT ' |
| 619 | 619 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
| 620 | 620 | . 'REG_ID AS REG_ID ' |
| 621 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
| 621 | + . 'FROM '.EEM_Checkin::instance()->table().' ' |
|
| 622 | 622 | . 'WHERE DTT_ID=%d ' |
| 623 | 623 | . 'GROUP BY REG_ID' |
| 624 | 624 | . ') AS most_recent_checkin_per_reg ' |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | $DTT_ID, |
| 630 | 630 | $checked_in |
| 631 | 631 | ); |
| 632 | - return (int)$wpdb->get_var( $query ); |
|
| 632 | + return (int) $wpdb->get_var($query); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -639,18 +639,18 @@ discard block |
||
| 639 | 639 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
| 640 | 640 | * @return int |
| 641 | 641 | */ |
| 642 | - public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) { |
|
| 642 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) { |
|
| 643 | 643 | global $wpdb; |
| 644 | 644 | //subquery to get latest checkin |
| 645 | 645 | $query = $wpdb->prepare( |
| 646 | 646 | 'SELECT ' |
| 647 | 647 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
| 648 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
| 648 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
| 649 | 649 | . '( SELECT ' |
| 650 | 650 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
| 651 | 651 | . 'REG_ID AS REG_ID ' |
| 652 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
| 653 | - . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
| 652 | + . 'FROM '.EEM_Checkin::instance()->table().' AS c ' |
|
| 653 | + . 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d ' |
|
| 654 | 654 | . 'ON c.DTT_ID=d.DTT_ID ' |
| 655 | 655 | . 'WHERE d.EVT_ID=%d ' |
| 656 | 656 | . 'GROUP BY REG_ID' |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | $EVT_ID, |
| 663 | 663 | $checked_in |
| 664 | 664 | ); |
| 665 | - return (int)$wpdb->get_var( $query ); |
|
| 665 | + return (int) $wpdb->get_var($query); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | |
@@ -677,15 +677,15 @@ discard block |
||
| 677 | 677 | * @param array $attendee_ids |
| 678 | 678 | * @return EE_Registration[] |
| 679 | 679 | */ |
| 680 | - public function get_latest_registration_for_each_of_given_contacts( $attendee_ids = array() ) { |
|
| 680 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) { |
|
| 681 | 681 | //first do a native wp_query to get the latest REG_ID's matching these attendees. |
| 682 | 682 | global $wpdb; |
| 683 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 683 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
| 684 | 684 | $attendee_table = $wpdb->posts; |
| 685 | - $attendee_ids = is_array( $attendee_ids ) |
|
| 686 | - ? array_map( 'absint', $attendee_ids ) |
|
| 687 | - : array( (int) $attendee_ids ); |
|
| 688 | - $attendee_ids = implode( ',', $attendee_ids ); |
|
| 685 | + $attendee_ids = is_array($attendee_ids) |
|
| 686 | + ? array_map('absint', $attendee_ids) |
|
| 687 | + : array((int) $attendee_ids); |
|
| 688 | + $attendee_ids = implode(',', $attendee_ids); |
|
| 689 | 689 | |
| 690 | 690 | |
| 691 | 691 | //first we do a query to get the registration ids |
@@ -710,24 +710,24 @@ discard block |
||
| 710 | 710 | ARRAY_A |
| 711 | 711 | ); |
| 712 | 712 | |
| 713 | - if ( empty( $registration_ids ) ) { |
|
| 713 | + if (empty($registration_ids)) { |
|
| 714 | 714 | return array(); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | $ids_for_model_query = array(); |
| 718 | 718 | //let's flatten the ids so they can be used in the model query. |
| 719 | - foreach ( $registration_ids as $registration_id ) { |
|
| 720 | - if ( isset( $registration_id['registration_id'] ) ) { |
|
| 719 | + foreach ($registration_ids as $registration_id) { |
|
| 720 | + if (isset($registration_id['registration_id'])) { |
|
| 721 | 721 | $ids_for_model_query[] = $registration_id['registration_id']; |
| 722 | 722 | } |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | //construct query |
| 726 | 726 | $_where = array( |
| 727 | - 'REG_ID' => array( 'IN', $ids_for_model_query ) |
|
| 727 | + 'REG_ID' => array('IN', $ids_for_model_query) |
|
| 728 | 728 | ); |
| 729 | 729 | |
| 730 | - return $this->get_all( array( $_where ) ); |
|
| 730 | + return $this->get_all(array($_where)); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * Sum all the deleted items. |
| 147 | 147 | * @param array $query_params like EEM_Base::get_all |
| 148 | 148 | * @param string $field_to_sum |
| 149 | - * @return int |
|
| 149 | + * @return double |
|
| 150 | 150 | */ |
| 151 | 151 | public function sum_deleted($query_params = null, $field_to_sum = null){ |
| 152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
| 196 | 196 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
| 197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
| 198 | - * @return boolean success |
|
| 198 | + * @return integer success |
|
| 199 | 199 | */ |
| 200 | 200 | public function delete_permanently($query_params = array(), $allow_blocking = true){ |
| 201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
| 2 | -require_once( EE_MODELS . 'EEM_Base.model.php'); |
|
| 2 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
| 3 | 3 | /** |
| 4 | 4 | * EEM_Soft_Delete_Base |
| 5 | 5 | * |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | * @subpackage includes/models/ |
| 26 | 26 | * @author Michael Nelson |
| 27 | 27 | */ |
| 28 | -abstract class EEM_Soft_Delete_Base extends EEM_Base{ |
|
| 28 | +abstract class EEM_Soft_Delete_Base extends EEM_Base { |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @param null $timezone |
| 32 | 32 | */ |
| 33 | 33 | protected function __construct($timezone = NULL) { |
| 34 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
| 34 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
| 35 | 35 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
| 36 | 36 | } |
| 37 | 37 | parent::__construct($timezone); |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | * @return string |
| 43 | 43 | * @throws EE_Error |
| 44 | 44 | */ |
| 45 | - public function deleted_field_name(){ |
|
| 45 | + public function deleted_field_name() { |
|
| 46 | 46 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
| 47 | - if($field){ |
|
| 47 | + if ($field) { |
|
| 48 | 48 | return $field->get_name(); |
| 49 | - }else{ |
|
| 50 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
| 49 | + } else { |
|
| 50 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param array $query_params like EEM_Base::get_all's $query_params |
| 58 | 58 | * @return EE_Soft_Delete_Base_Class |
| 59 | 59 | */ |
| 60 | - public function get_one_deleted($query_params = array()){ |
|
| 60 | + public function get_one_deleted($query_params = array()) { |
|
| 61 | 61 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
| 62 | 62 | return parent::get_one($query_params); |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param array $query_params like EEM_base::get_all's $query_params |
| 68 | 68 | * @return EE_Soft_Delete_Base_Class |
| 69 | 69 | */ |
| 70 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
| 70 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
| 71 | 71 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 72 | 72 | return parent::get_one($query_params); |
| 73 | 73 | } |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | * @param int|string $id |
| 78 | 78 | * @return EE_Soft_Delete_Base_Class |
| 79 | 79 | */ |
| 80 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
| 80 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
| 81 | 81 | return $this->get_one( |
| 82 | 82 | $this->alter_query_params_to_restrict_by_ID( |
| 83 | 83 | $id, |
| 84 | - array( 'default_where_conditions' => 'default' ) |
|
| 84 | + array('default_where_conditions' => 'default') |
|
| 85 | 85 | ) |
| 86 | 86 | ); |
| 87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
| 94 | 94 | * @return int |
| 95 | 95 | */ |
| 96 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
| 96 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
| 97 | 97 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
| 98 | 98 | return parent::count($query_params, $field_to_count, $distinct); |
| 99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | * @param array $query_params like EEM_Base::get_all's $query_params |
| 104 | 104 | * @return array like EEM_Base::get_all's $query_params |
| 105 | 105 | */ |
| 106 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
| 107 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
| 108 | - $query_params[0][$deletedFlagFieldName]=true; |
|
| 106 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
| 107 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
| 108 | + $query_params[0][$deletedFlagFieldName] = true; |
|
| 109 | 109 | return $query_params; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param array $query_params |
| 115 | 115 | * @return array |
| 116 | 116 | */ |
| 117 | - public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){ |
|
| 117 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) { |
|
| 118 | 118 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | * @param array $query_params |
| 124 | 124 | * @return array |
| 125 | 125 | */ |
| 126 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
| 127 | - if( ! isset( $query_params[ 'default_where_conditions' ] ) ) { |
|
| 126 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
| 127 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
| 128 | 128 | $query_params['default_where_conditions'] = 'minimum'; |
| 129 | 129 | } |
| 130 | 130 | return $query_params; |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
| 138 | 138 | * @return int |
| 139 | 139 | */ |
| 140 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
| 140 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
| 141 | 141 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 142 | - return parent::count($query_params,$field_to_count, $distinct); |
|
| 142 | + return parent::count($query_params, $field_to_count, $distinct); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param string $field_to_sum |
| 149 | 149 | * @return int |
| 150 | 150 | */ |
| 151 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
| 151 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
| 152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
| 153 | 153 | return parent::sum($query_params, $field_to_sum); |
| 154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param string $field_to_sum |
| 160 | 160 | * @return int |
| 161 | 161 | */ |
| 162 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
| 162 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
| 163 | 163 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 164 | 164 | parent::sum($query_params, $field_to_sum); |
| 165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param array $query_params like EEM_Base::get_all |
| 170 | 170 | * @return EE_Soft_Delete_Base_Class[] |
| 171 | 171 | */ |
| 172 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
| 172 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
| 173 | 173 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 174 | 174 | return parent::get_all($query_params); |
| 175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param array $query_params like EEM_Base::get_all |
| 180 | 180 | * @return EE_Soft_Delete_Base_Class[] |
| 181 | 181 | */ |
| 182 | - public function get_all_deleted($query_params = array()){ |
|
| 182 | + public function get_all_deleted($query_params = array()) { |
|
| 183 | 183 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
| 184 | 184 | return parent::get_all($query_params); |
| 185 | 185 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
| 198 | 198 | * @return boolean success |
| 199 | 199 | */ |
| 200 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
| 200 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
| 201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 202 | 202 | return parent::delete_permanently($query_params, $allow_blocking); |
| 203 | 203 | } |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | * @param mixed $ID int if primary key is an int, string otherwise |
| 209 | 209 | * @return boolean success |
| 210 | 210 | */ |
| 211 | - public function restore_by_ID($ID=FALSE){ |
|
| 212 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
| 211 | + public function restore_by_ID($ID = FALSE) { |
|
| 212 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
| 213 | 213 | } |
| 214 | 214 | /** |
| 215 | 215 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | * @param mixed $ID int if primary key is an int, string otherwise |
| 219 | 219 | * @return boolean |
| 220 | 220 | */ |
| 221 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
| 222 | - if ( ! $ID ) { |
|
| 221 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
| 222 | + if ( ! $ID) { |
|
| 223 | 223 | return FALSE; |
| 224 | 224 | } |
| 225 | 225 | if ( |
| 226 | 226 | $this->delete_or_restore( |
| 227 | 227 | $delete, |
| 228 | - $this->alter_query_params_to_restrict_by_ID( $ID ) |
|
| 228 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
| 229 | 229 | ) |
| 230 | 230 | ) { |
| 231 | 231 | return TRUE; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @param bool $block_deletes |
| 246 | 246 | * @return boolean |
| 247 | 247 | */ |
| 248 | - public function delete($query_params = array(), $block_deletes = false){ |
|
| 248 | + public function delete($query_params = array(), $block_deletes = false) { |
|
| 249 | 249 | //no matter what, we WON'T block soft deletes. |
| 250 | 250 | return $this->delete_or_restore(true, $query_params); |
| 251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @param array $query_params like EEM_Base::get_all |
| 257 | 257 | * @return boolean |
| 258 | 258 | */ |
| 259 | - public function restore($query_params = array()){ |
|
| 259 | + public function restore($query_params = array()) { |
|
| 260 | 260 | return $this->delete_or_restore(false, $query_params); |
| 261 | 261 | } |
| 262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | * @param array $query_params like EEM_Base::get_all |
| 266 | 266 | * @return boolean |
| 267 | 267 | */ |
| 268 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
| 269 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
| 268 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
| 269 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
| 270 | 270 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 271 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
| 271 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
| 272 | 272 | return TRUE; |
| 273 | 273 | } else { |
| 274 | 274 | return FALSE; |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | * be aware that model objects being used could get out-of-sync with the database |
| 287 | 287 | * @return int number of items updated |
| 288 | 288 | */ |
| 289 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
| 289 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
| 290 | 290 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
| 291 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
| 291 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
| 292 | 292 | } |
| 293 | 293 | } |