@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
141 | - * @return null |
|
141 | + * @return EE_Line_Item_Display |
|
142 | 142 | */ |
143 | 143 | public function line_item_display() { |
144 | 144 | return $this->line_item_display; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | |
149 | 149 | /** |
150 | - * @param null $line_item_display |
|
150 | + * @param EE_Line_Item_Display $line_item_display |
|
151 | 151 | */ |
152 | 152 | public function set_line_item_display( $line_item_display ) { |
153 | 153 | $this->line_item_display = $line_item_display; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | |
230 | 230 | /** |
231 | - * @return bool |
|
231 | + * @return EE_Form_Section_Proper |
|
232 | 232 | * @throws \EE_Error |
233 | 233 | */ |
234 | 234 | public function generate_reg_form() { |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * _apply_registration_payments_to_amount_owing |
625 | 625 | * |
626 | 626 | * @access protected |
627 | - * @param array $registrations |
|
627 | + * @param EE_Base_Class[] $registrations |
|
628 | 628 | */ |
629 | 629 | protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
630 | 630 | $payments = array(); |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * get_billing_form_html_for_payment_method |
898 | 898 | * |
899 | 899 | * @access public |
900 | - * @return string |
|
900 | + * @return boolean |
|
901 | 901 | * @throws \EE_Error |
902 | 902 | */ |
903 | 903 | public function get_billing_form_html_for_payment_method() { |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | * switch_payment_method |
1066 | 1066 | * |
1067 | 1067 | * @access public |
1068 | - * @return string |
|
1068 | + * @return boolean |
|
1069 | 1069 | * @throws \EE_Error |
1070 | 1070 | */ |
1071 | 1071 | public function switch_payment_method() { |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | /** |
1272 | 1272 | * process_reg_step |
1273 | 1273 | * |
1274 | - * @return boolean |
|
1274 | + * @return null|boolean |
|
1275 | 1275 | * @throws \EE_Error |
1276 | 1276 | */ |
1277 | 1277 | public function process_reg_step() { |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | * update_reg_step |
1367 | 1367 | * this is the final step after a user revisits the site to retry a payment |
1368 | 1368 | * |
1369 | - * @return boolean |
|
1369 | + * @return null|boolean |
|
1370 | 1370 | * @throws \EE_Error |
1371 | 1371 | */ |
1372 | 1372 | public function update_reg_step() { |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | * |
1731 | 1731 | * @access private |
1732 | 1732 | * @type EE_Payment_Method $payment_method |
1733 | - * @return mixed EE_Payment | boolean |
|
1733 | + * @return EE_Payment|null EE_Payment | boolean |
|
1734 | 1734 | * @throws \EE_Error |
1735 | 1735 | */ |
1736 | 1736 | private function _attempt_payment( EE_Payment_Method $payment_method ) { |
@@ -1940,6 +1940,7 @@ discard block |
||
1940 | 1940 | * @access private |
1941 | 1941 | * @type EE_Payment $payment |
1942 | 1942 | * @param string $payment_occurs |
1943 | + * @param EE_Payment|null $payment |
|
1943 | 1944 | * @return bool |
1944 | 1945 | * @throws \EE_Error |
1945 | 1946 | */ |
@@ -2050,7 +2051,7 @@ discard block |
||
2050 | 2051 | * or present the payment options again |
2051 | 2052 | * |
2052 | 2053 | * @access private |
2053 | - * @return EE_Payment | FALSE |
|
2054 | + * @return boolean | FALSE |
|
2054 | 2055 | * @throws \EE_Error |
2055 | 2056 | */ |
2056 | 2057 | public function process_gateway_response() { |
@@ -2112,7 +2113,7 @@ discard block |
||
2112 | 2113 | * _validate_return |
2113 | 2114 | * |
2114 | 2115 | * @access private |
2115 | - * @return bool |
|
2116 | + * @return boolean|null |
|
2116 | 2117 | * @throws \EE_Error |
2117 | 2118 | */ |
2118 | 2119 | private function _validate_offsite_return() { |
@@ -2183,8 +2184,8 @@ discard block |
||
2183 | 2184 | * _redirect_wayward_request |
2184 | 2185 | * |
2185 | 2186 | * @access private |
2186 | - * @param \EE_Registration|null $primary_registrant |
|
2187 | - * @return bool |
|
2187 | + * @param EE_Registration $primary_registrant |
|
2188 | + * @return false|null |
|
2188 | 2189 | * @throws \EE_Error |
2189 | 2190 | */ |
2190 | 2191 | private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | 'layout_strategy' => new EE_Template_Layout( |
412 | 412 | array( |
413 | 413 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
414 | - . $this->_slug |
|
415 | - . DS |
|
416 | - . 'sold_out_events.template.php', |
|
414 | + . $this->_slug |
|
415 | + . DS |
|
416 | + . 'sold_out_events.template.php', |
|
417 | 417 | 'template_args' => apply_filters( |
418 | 418 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
419 | 419 | array( |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | 'layout_strategy' => new EE_Template_Layout( |
466 | 466 | array( |
467 | 467 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
468 | - . $this->_slug |
|
469 | - . DS |
|
470 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
468 | + . $this->_slug |
|
469 | + . DS |
|
470 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
471 | 471 | 'template_args' => apply_filters( |
472 | 472 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
473 | 473 | array( |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | 'layout_strategy' => new EE_Template_Layout( |
510 | 510 | array( |
511 | 511 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
512 | - . $this->_slug |
|
513 | - . DS |
|
514 | - . 'no_payment_required.template.php', // layout_template |
|
512 | + . $this->_slug |
|
513 | + . DS |
|
514 | + . 'no_payment_required.template.php', // layout_template |
|
515 | 515 | 'template_args' => apply_filters( |
516 | 516 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
517 | 517 | array( |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
742 | 742 | } |
743 | 743 | $payment_methods_billing_info[ $payment_method->slug() |
744 | - . '-info' ] = $this->_payment_method_billing_info( |
|
744 | + . '-info' ] = $this->_payment_method_billing_info( |
|
745 | 745 | $payment_method |
746 | 746 | ); |
747 | 747 | } |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | // fill form with attendee info if applicable |
930 | 930 | if ( |
931 | 931 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
932 | - && $this->checkout->transaction_has_primary_registrant() |
|
932 | + && $this->checkout->transaction_has_primary_registrant() |
|
933 | 933 | ) { |
934 | 934 | $payment_method_billing_form->populate_from_attendee( |
935 | 935 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | // and debug content |
939 | 939 | if ( |
940 | 940 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
941 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
941 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
942 | 942 | ) { |
943 | 943 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
944 | 944 | $payment_method_billing_form |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | } |
1098 | 1098 | // fill form with attendee info if applicable |
1099 | 1099 | if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
1100 | - && $this->checkout->transaction_has_primary_registrant() |
|
1100 | + && $this->checkout->transaction_has_primary_registrant() |
|
1101 | 1101 | ) { |
1102 | 1102 | $this->checkout->billing_form->populate_from_attendee( |
1103 | 1103 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | } |
1106 | 1106 | // and debug content |
1107 | 1107 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
1108 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1108 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1109 | 1109 | ) { |
1110 | 1110 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1111 | 1111 | $this->checkout->billing_form |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | } |
1239 | 1239 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1240 | 1240 | if ( ! empty( $attendee_data['ATT_fname'] ) |
1241 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1242 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1241 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
1242 | + && ! empty( $attendee_data['ATT_email'] ) |
|
1243 | 1243 | ) { |
1244 | 1244 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1245 | 1245 | array( |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | $payment_status = $payment->status(); |
1451 | 1451 | if ( |
1452 | 1452 | $payment_status === EEM_Payment::status_id_approved |
1453 | - || $payment_status === EEM_Payment::status_id_pending |
|
1453 | + || $payment_status === EEM_Payment::status_id_pending |
|
1454 | 1454 | ) { |
1455 | 1455 | return true; |
1456 | 1456 | } else { |
@@ -1638,8 +1638,8 @@ discard block |
||
1638 | 1638 | return false; |
1639 | 1639 | } |
1640 | 1640 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
1641 | - instanceof |
|
1642 | - EE_Attendee |
|
1641 | + instanceof |
|
1642 | + EE_Attendee |
|
1643 | 1643 | ) { |
1644 | 1644 | EE_Error::add_error( |
1645 | 1645 | sprintf( |
@@ -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 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | * @return \EE_SPCO_Reg_Step_Payment_Options |
129 | 129 | */ |
130 | - public function __construct( EE_Checkout $checkout ) { |
|
130 | + public function __construct(EE_Checkout $checkout) { |
|
131 | 131 | $this->_slug = 'payment_options'; |
132 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
133 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
132 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
133 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
134 | 134 | $this->checkout = $checkout; |
135 | 135 | $this->_reset_success_message(); |
136 | 136 | $this->set_instructions( |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @param null $line_item_display |
157 | 157 | */ |
158 | - public function set_line_item_display( $line_item_display ) { |
|
158 | + public function set_line_item_display($line_item_display) { |
|
159 | 159 | $this->line_item_display = $line_item_display; |
160 | 160 | } |
161 | 161 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * @param boolean $handle_IPN_in_this_request |
175 | 175 | */ |
176 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
177 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
176 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
177 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | public function enqueue_styles_and_scripts() { |
210 | 210 | $transaction = $this->checkout->transaction; |
211 | 211 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
212 | - if( ! $transaction instanceof EE_Transaction |
|
213 | - || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
212 | + if ( ! $transaction instanceof EE_Transaction |
|
213 | + || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
216 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
217 | 217 | $type_obj = $payment_method->type_obj(); |
218 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
219 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
220 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
218 | + if ($type_obj instanceof EE_PMT_Base) { |
|
219 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
220 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
221 | 221 | $billing_form->enqueue_js(); |
222 | 222 | } |
223 | 223 | } |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | // $ 0.00 transactions (no payment required) |
243 | 243 | ! $this->checkout->payment_required() |
244 | 244 | // but do NOT remove if current action being called belongs to this reg step |
245 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
245 | + && ! is_callable(array($this, $this->checkout->action)) |
|
246 | 246 | && ! $this->completed() |
247 | 247 | ) { |
248 | 248 | // and if so, then we no longer need the Payment Options step |
249 | - if ( $this->is_current_step() ) { |
|
249 | + if ($this->is_current_step()) { |
|
250 | 250 | $this->checkout->generate_reg_form = false; |
251 | 251 | } |
252 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
252 | + $this->checkout->remove_reg_step($this->_slug); |
|
253 | 253 | // DEBUG LOG |
254 | 254 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | // load EEM_Payment_Method |
258 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
258 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
259 | 259 | // get all active payment methods |
260 | 260 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
261 | 261 | $this->checkout->transaction, |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | $sold_out_events = array(); |
282 | 282 | $reg_count = 0; |
283 | 283 | // loop thru registrations to gather info |
284 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
285 | - foreach ( $registrations as $registration ) { |
|
284 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
285 | + foreach ($registrations as $registration) { |
|
286 | 286 | /** @var $registration EE_Registration */ |
287 | 287 | $reg_count++; |
288 | 288 | // if returning registrant is Approved then do NOT do this |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | && $registration->status_ID() === EEM_Registration::status_id_approved |
293 | 293 | ) |
294 | 294 | ) { |
295 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) { |
|
295 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
296 | 296 | // add event to list of events that are sold out |
297 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
297 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
298 | 298 | do_action( |
299 | 299 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
300 | 300 | $registration->event(), |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | ); |
303 | 303 | } |
304 | 304 | // event requires admin approval |
305 | - if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) { |
|
305 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
306 | 306 | // add event to list of events with pre-approval reg status |
307 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
307 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
308 | 308 | do_action( |
309 | 309 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
310 | 310 | $registration->event(), |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | } |
314 | 314 | } |
315 | 315 | // are they allowed to pay now and is there monies owing? |
316 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
317 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
316 | + if ($registration->owes_monies_and_can_pay()) { |
|
317 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
318 | 318 | do_action( |
319 | 319 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
320 | 320 | $registration->event(), |
@@ -325,23 +325,23 @@ discard block |
||
325 | 325 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
326 | 326 | && $registration->ticket()->is_free() |
327 | 327 | ) { |
328 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
328 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | $subsections = array(); |
332 | 332 | // now decide which template to load |
333 | - if ( ! empty( $sold_out_events ) ) { |
|
334 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
333 | + if ( ! empty($sold_out_events)) { |
|
334 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
335 | 335 | } |
336 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
336 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
337 | 337 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
338 | 338 | $registrations_requiring_pre_approval |
339 | 339 | ); |
340 | 340 | } |
341 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
342 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
341 | + if ( ! empty($registrations_for_free_events)) { |
|
342 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
343 | 343 | } |
344 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
344 | + if ( ! empty($registrations_requiring_payment)) { |
|
345 | 345 | // autoload Line_Item_Display classes |
346 | 346 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
347 | 347 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -353,17 +353,17 @@ discard block |
||
353 | 353 | ); |
354 | 354 | /** @var EE_Line_Item $filtered_line_item_tree */ |
355 | 355 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
356 | - if ( $this->checkout->amount_owing > 0 ) { |
|
356 | + if ($this->checkout->amount_owing > 0) { |
|
357 | 357 | EEH_Autoloader::register_line_item_display_autoloaders(); |
358 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
358 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
359 | 359 | $subsections['payment_options'] = $this->_display_payment_options( |
360 | 360 | $this->line_item_display->display_line_item( |
361 | 361 | $filtered_line_item_tree, |
362 | - array( 'registrations' => $registrations ) |
|
362 | + array('registrations' => $registrations) |
|
363 | 363 | ) |
364 | 364 | ); |
365 | 365 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
366 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
366 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
367 | 367 | } |
368 | 368 | } else { |
369 | 369 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
394 | 394 | * @return \EE_Line_Item_Filter_Collection |
395 | 395 | */ |
396 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
396 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
397 | 397 | $line_item_filter_collection->add( |
398 | 398 | new EE_Billable_Line_Item_Filter( |
399 | 399 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | ) |
402 | 402 | ) |
403 | 403 | ); |
404 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
404 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
405 | 405 | return $line_item_filter_collection; |
406 | 406 | } |
407 | 407 | |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @return void |
416 | 416 | */ |
417 | 417 | protected function _hide_reg_step_submit_button_if_revisit() { |
418 | - if ( $this->checkout->revisit ) { |
|
419 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
418 | + if ($this->checkout->revisit) { |
|
419 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
@@ -429,13 +429,13 @@ discard block |
||
429 | 429 | * @return \EE_Form_Section_Proper |
430 | 430 | * @throws \EE_Error |
431 | 431 | */ |
432 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
432 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
433 | 433 | // set some defaults |
434 | 434 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
435 | 435 | $sold_out_events = ''; |
436 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
436 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
437 | 437 | $sold_out_events .= EEH_HTML::li( |
438 | - EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
438 | + EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
439 | 439 | ); |
440 | 440 | } |
441 | 441 | return new EE_Form_Section_Proper( |
@@ -480,17 +480,17 @@ discard block |
||
480 | 480 | * @return \EE_Form_Section_Proper |
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
483 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
484 | 484 | $events_requiring_pre_approval = ''; |
485 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
486 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
487 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
485 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
486 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
487 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
488 | 488 | EEH_HTML::span( |
489 | 489 | '', |
490 | 490 | '', |
491 | 491 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
492 | 492 | ) |
493 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
493 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
494 | 494 | ); |
495 | 495 | } |
496 | 496 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | 'template_args' => apply_filters( |
510 | 510 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
511 | 511 | array( |
512 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
512 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
513 | 513 | 'events_requiring_pre_approval_msg' => apply_filters( |
514 | 514 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
515 | 515 | __( |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @return \EE_Form_Section_Proper |
535 | 535 | * @throws \EE_Error |
536 | 536 | */ |
537 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
537 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
538 | 538 | // set some defaults |
539 | 539 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
540 | 540 | // generate no_payment_required form |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | 'ticket_count' => array(), |
559 | 559 | 'registrations_for_free_events' => $registrations_for_free_events, |
560 | 560 | 'no_payment_required_msg' => EEH_HTML::p( |
561 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
561 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
562 | 562 | ) |
563 | 563 | ) |
564 | 564 | ), |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @return \EE_Form_Section_Proper |
578 | 578 | * @throws \EE_Error |
579 | 579 | */ |
580 | - private function _display_payment_options( $transaction_details = '' ) { |
|
580 | + private function _display_payment_options($transaction_details = '') { |
|
581 | 581 | // has method_of_payment been set by no-js user? |
582 | 582 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
583 | 583 | // build payment options form |
@@ -589,18 +589,18 @@ discard block |
||
589 | 589 | 'before_payment_options' => apply_filters( |
590 | 590 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
591 | 591 | new EE_Form_Section_Proper( |
592 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
592 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
593 | 593 | ) |
594 | 594 | ), |
595 | 595 | 'payment_options' => $this->_setup_payment_options(), |
596 | 596 | 'after_payment_options' => apply_filters( |
597 | 597 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
598 | 598 | new EE_Form_Section_Proper( |
599 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
599 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
600 | 600 | ) |
601 | 601 | ), |
602 | 602 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
603 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( false ) |
|
603 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(false) |
|
604 | 604 | ), |
605 | 605 | 'layout_strategy' => new EE_Template_Layout( |
606 | 606 | array( |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @return \EE_Form_Section_Proper |
630 | 630 | * @throws \EE_Error |
631 | 631 | */ |
632 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
632 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
633 | 633 | return new EE_Form_Section_Proper( |
634 | 634 | array( |
635 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
635 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
636 | 636 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
637 | 637 | 'subsections' => array( |
638 | 638 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -664,16 +664,16 @@ discard block |
||
664 | 664 | * @access protected |
665 | 665 | * @param array $registrations |
666 | 666 | */ |
667 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
667 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
668 | 668 | $payments = array(); |
669 | - foreach ( $registrations as $registration ) { |
|
670 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
669 | + foreach ($registrations as $registration) { |
|
670 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
671 | 671 | $payments += $registration->registration_payments(); |
672 | 672 | } |
673 | 673 | } |
674 | - if ( ! empty( $payments ) ) { |
|
675 | - foreach ( $payments as $payment ) { |
|
676 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
674 | + if ( ! empty($payments)) { |
|
675 | + foreach ($payments as $payment) { |
|
676 | + if ($payment instanceof EE_Registration_Payment) { |
|
677 | 677 | $this->checkout->amount_owing -= $payment->amount(); |
678 | 678 | } |
679 | 679 | } |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | * @param bool $force_reset |
690 | 690 | * @return void |
691 | 691 | */ |
692 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
692 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
693 | 693 | $reset_payment_method = $force_reset |
694 | 694 | ? true |
695 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
696 | - if ( $reset_payment_method ) { |
|
695 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
696 | + if ($reset_payment_method) { |
|
697 | 697 | $this->checkout->selected_method_of_payment = null; |
698 | 698 | $this->checkout->payment_method = null; |
699 | 699 | $this->checkout->billing_form = null; |
@@ -712,12 +712,12 @@ discard block |
||
712 | 712 | * @param string $selected_method_of_payment |
713 | 713 | * @return EE_Billing_Info_Form |
714 | 714 | */ |
715 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
716 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
715 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
716 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
717 | 717 | ? $selected_method_of_payment |
718 | 718 | : $this->checkout->selected_method_of_payment; |
719 | 719 | EE_Registry::instance()->SSN->set_session_data( |
720 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
720 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
721 | 721 | ); |
722 | 722 | } |
723 | 723 | |
@@ -733,19 +733,19 @@ discard block |
||
733 | 733 | // load payment method classes |
734 | 734 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
735 | 735 | // switch up header depending on number of available payment methods |
736 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
736 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
737 | 737 | ? apply_filters( |
738 | 738 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
739 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
739 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
740 | 740 | ) |
741 | 741 | : apply_filters( |
742 | 742 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
743 | - __( 'Method of Payment', 'event_espresso' ) |
|
743 | + __('Method of Payment', 'event_espresso') |
|
744 | 744 | ); |
745 | 745 | $available_payment_methods = array( |
746 | 746 | // display the "Payment Method" header |
747 | 747 | 'payment_method_header' => new EE_Form_Section_HTML( |
748 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
748 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
749 | 749 | ) |
750 | 750 | ); |
751 | 751 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -754,32 +754,32 @@ discard block |
||
754 | 754 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
755 | 755 | $payment_methods_billing_info = array( |
756 | 756 | new EE_Form_Section_HTML( |
757 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
757 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
758 | 758 | ) |
759 | 759 | ); |
760 | 760 | // loop through payment methods |
761 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
762 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
761 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
762 | + if ($payment_method instanceof EE_Payment_Method) { |
|
763 | 763 | $payment_method_button = EEH_HTML::img( |
764 | 764 | $payment_method->button_url(), |
765 | 765 | $payment_method->name(), |
766 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
766 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
767 | 767 | 'spco-payment-method-btn-img' |
768 | 768 | ); |
769 | 769 | // check if any payment methods are set as default |
770 | 770 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
771 | 771 | if ( |
772 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
773 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
772 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
773 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
774 | 774 | ) { |
775 | 775 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
776 | 776 | $this->_save_selected_method_of_payment(); |
777 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
777 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
778 | 778 | } else { |
779 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
779 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
780 | 780 | } |
781 | - $payment_methods_billing_info[ $payment_method->slug() |
|
782 | - . '-info' ] = $this->_payment_method_billing_info( |
|
781 | + $payment_methods_billing_info[$payment_method->slug() |
|
782 | + . '-info'] = $this->_payment_method_billing_info( |
|
783 | 783 | $payment_method |
784 | 784 | ); |
785 | 785 | } |
@@ -809,12 +809,12 @@ discard block |
||
809 | 809 | * @return EE_Payment_Method[] |
810 | 810 | */ |
811 | 811 | protected function _get_available_payment_methods() { |
812 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
812 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
813 | 813 | return $this->checkout->available_payment_methods; |
814 | 814 | } |
815 | 815 | $available_payment_methods = array(); |
816 | 816 | // load EEM_Payment_Method |
817 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
817 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
818 | 818 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
819 | 819 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
820 | 820 | // get all active payment methods |
@@ -822,9 +822,9 @@ discard block |
||
822 | 822 | $this->checkout->transaction, |
823 | 823 | EEM_Payment_Method::scope_cart |
824 | 824 | ); |
825 | - foreach ( $payment_methods as $payment_method ) { |
|
826 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
827 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
825 | + foreach ($payment_methods as $payment_method) { |
|
826 | + if ($payment_method instanceof EE_Payment_Method) { |
|
827 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 | return $available_payment_methods; |
@@ -839,14 +839,14 @@ discard block |
||
839 | 839 | * @param array $available_payment_method_options |
840 | 840 | * @return \EE_Form_Section_Proper |
841 | 841 | */ |
842 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
842 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
843 | 843 | // generate inputs |
844 | 844 | return new EE_Form_Section_Proper( |
845 | 845 | array( |
846 | 846 | 'html_id' => 'ee-available-payment-method-inputs', |
847 | 847 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
848 | 848 | 'subsections' => array( |
849 | - '' => new EE_Radio_Button_Input ( |
|
849 | + '' => new EE_Radio_Button_Input( |
|
850 | 850 | $available_payment_method_options, |
851 | 851 | array( |
852 | 852 | 'html_name' => 'selected_method_of_payment', |
@@ -871,28 +871,28 @@ discard block |
||
871 | 871 | * @return \EE_Form_Section_Proper |
872 | 872 | * @throws \EE_Error |
873 | 873 | */ |
874 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
874 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
875 | 875 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
876 | 876 | ? true |
877 | 877 | : false; |
878 | 878 | // generate the billing form for payment method |
879 | 879 | $billing_form = $currently_selected |
880 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
880 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
881 | 881 | : new EE_Form_Section_HTML(); |
882 | 882 | $this->checkout->billing_form = $currently_selected |
883 | 883 | ? $billing_form |
884 | 884 | : $this->checkout->billing_form; |
885 | 885 | // it's all in the details |
886 | 886 | $info_html = EEH_HTML::h3( |
887 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
887 | + __('Important information regarding your payment', 'event_espresso'), |
|
888 | 888 | '', |
889 | 889 | 'spco-payment-method-hdr' |
890 | 890 | ); |
891 | 891 | // add some info regarding the step, either from what's saved in the admin, |
892 | 892 | // or a default string depending on whether the PM has a billing form or not |
893 | - if ( $payment_method->description() ) { |
|
893 | + if ($payment_method->description()) { |
|
894 | 894 | $payment_method_info = $payment_method->description(); |
895 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
895 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
896 | 896 | $payment_method_info = sprintf( |
897 | 897 | __( |
898 | 898 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | ); |
903 | 903 | } else { |
904 | 904 | $payment_method_info = sprintf( |
905 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
905 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
906 | 906 | $this->submit_button_text() |
907 | 907 | ); |
908 | 908 | } |
@@ -916,13 +916,13 @@ discard block |
||
916 | 916 | ); |
917 | 917 | return new EE_Form_Section_Proper( |
918 | 918 | array( |
919 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
919 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
920 | 920 | 'html_class' => 'spco-payment-method-info-dv', |
921 | 921 | // only display the selected or default PM |
922 | 922 | 'html_style' => $currently_selected ? '' : 'display:none;', |
923 | 923 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
924 | 924 | 'subsections' => array( |
925 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
925 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
926 | 926 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
927 | 927 | ) |
928 | 928 | ) |
@@ -940,15 +940,15 @@ discard block |
||
940 | 940 | */ |
941 | 941 | public function get_billing_form_html_for_payment_method() { |
942 | 942 | // how have they chosen to pay? |
943 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
943 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
944 | 944 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
945 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
945 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
946 | 946 | return false; |
947 | 947 | } |
948 | - if ( apply_filters( |
|
948 | + if (apply_filters( |
|
949 | 949 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
950 | 950 | false |
951 | - ) ) { |
|
951 | + )) { |
|
952 | 952 | EE_Error::add_success( |
953 | 953 | apply_filters( |
954 | 954 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | ); |
964 | 964 | } |
965 | 965 | // now generate billing form for selected method of payment |
966 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
966 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
967 | 967 | // fill form with attendee info if applicable |
968 | 968 | if ( |
969 | 969 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -985,10 +985,10 @@ discard block |
||
985 | 985 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
986 | 986 | ? $payment_method_billing_form->get_html() |
987 | 987 | : ''; |
988 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
988 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
989 | 989 | // localize validation rules for main form |
990 | 990 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
991 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
991 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
992 | 992 | return true; |
993 | 993 | } |
994 | 994 | |
@@ -1002,18 +1002,18 @@ discard block |
||
1002 | 1002 | * @return \EE_Billing_Info_Form |
1003 | 1003 | * @throws \EE_Error |
1004 | 1004 | */ |
1005 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
1005 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
1006 | 1006 | $billing_form = $payment_method->type_obj()->billing_form( |
1007 | 1007 | $this->checkout->transaction, |
1008 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
1008 | + array('amount_owing' => $this->checkout->amount_owing) |
|
1009 | 1009 | ); |
1010 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1010 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
1011 | 1011 | if ( |
1012 | 1012 | apply_filters( |
1013 | 1013 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1014 | 1014 | false |
1015 | 1015 | ) |
1016 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1016 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1017 | 1017 | ) { |
1018 | 1018 | EE_Error::add_success( |
1019 | 1019 | apply_filters( |
@@ -1055,15 +1055,15 @@ discard block |
||
1055 | 1055 | $request_param = 'selected_method_of_payment' |
1056 | 1056 | ) { |
1057 | 1057 | // is selected_method_of_payment set in the request ? |
1058 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1059 | - if ( $selected_method_of_payment ) { |
|
1058 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1059 | + if ($selected_method_of_payment) { |
|
1060 | 1060 | // sanitize it |
1061 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1062 | - ? array_shift( $selected_method_of_payment ) |
|
1061 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1062 | + ? array_shift($selected_method_of_payment) |
|
1063 | 1063 | : $selected_method_of_payment; |
1064 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1064 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1065 | 1065 | // store it in the session so that it's available for all subsequent requests including AJAX |
1066 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1066 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1067 | 1067 | } else { |
1068 | 1068 | // or is is set in the session ? |
1069 | 1069 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | ); |
1072 | 1072 | } |
1073 | 1073 | // do ya really really gotta have it? |
1074 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1074 | + if (empty($selected_method_of_payment) && $required) { |
|
1075 | 1075 | EE_Error::add_error( |
1076 | 1076 | sprintf( |
1077 | 1077 | __( |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | ), |
1081 | 1081 | '<br/>', |
1082 | 1082 | '<br/>', |
1083 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1083 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1084 | 1084 | ), |
1085 | 1085 | __FILE__, |
1086 | 1086 | __FUNCTION__, |
@@ -1107,13 +1107,13 @@ discard block |
||
1107 | 1107 | * @throws \EE_Error |
1108 | 1108 | */ |
1109 | 1109 | public function switch_payment_method() { |
1110 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1110 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1111 | 1111 | return false; |
1112 | 1112 | } |
1113 | - if ( apply_filters( |
|
1113 | + if (apply_filters( |
|
1114 | 1114 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1115 | 1115 | false |
1116 | - ) ) { |
|
1116 | + )) { |
|
1117 | 1117 | EE_Error::add_success( |
1118 | 1118 | apply_filters( |
1119 | 1119 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1128,13 +1128,13 @@ discard block |
||
1128 | 1128 | ); |
1129 | 1129 | } |
1130 | 1130 | // generate billing form for selected method of payment if it hasn't been done already |
1131 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1131 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1132 | 1132 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1133 | 1133 | $this->checkout->payment_method |
1134 | 1134 | ); |
1135 | 1135 | } |
1136 | 1136 | // fill form with attendee info if applicable |
1137 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1137 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1138 | 1138 | && $this->checkout->transaction_has_primary_registrant() |
1139 | 1139 | ) { |
1140 | 1140 | $this->checkout->billing_form->populate_from_attendee( |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | ); |
1143 | 1143 | } |
1144 | 1144 | // and debug content |
1145 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1145 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1146 | 1146 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1147 | 1147 | ) { |
1148 | 1148 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1150,15 +1150,15 @@ discard block |
||
1150 | 1150 | ); |
1151 | 1151 | } |
1152 | 1152 | // get html and validation rules for form |
1153 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1153 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1154 | 1154 | $this->checkout->json_response->set_return_data( |
1155 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1155 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1156 | 1156 | ); |
1157 | 1157 | // localize validation rules for main form |
1158 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1159 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1158 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1159 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1160 | 1160 | } else { |
1161 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1161 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1162 | 1162 | } |
1163 | 1163 | //prevents advancement to next step |
1164 | 1164 | $this->checkout->continue_reg = false; |
@@ -1175,12 +1175,12 @@ discard block |
||
1175 | 1175 | */ |
1176 | 1176 | protected function _verify_payment_method_is_set() { |
1177 | 1177 | // generate billing form for selected method of payment if it hasn't been done already |
1178 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1178 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1179 | 1179 | // how have they chosen to pay? |
1180 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1180 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1181 | 1181 | } |
1182 | 1182 | // verify payment method |
1183 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1183 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1184 | 1184 | // get payment method for selected method of payment |
1185 | 1185 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1186 | 1186 | } |
@@ -1199,25 +1199,25 @@ discard block |
||
1199 | 1199 | * @throws \EE_Error |
1200 | 1200 | */ |
1201 | 1201 | public function save_payer_details_via_ajax() { |
1202 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1202 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1203 | 1203 | return; |
1204 | 1204 | } |
1205 | 1205 | // generate billing form for selected method of payment if it hasn't been done already |
1206 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1206 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1207 | 1207 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1208 | 1208 | $this->checkout->payment_method |
1209 | 1209 | ); |
1210 | 1210 | } |
1211 | 1211 | // generate primary attendee from payer info if applicable |
1212 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1212 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1213 | 1213 | $attendee = $this->_create_attendee_from_request_data(); |
1214 | - if ( $attendee instanceof EE_Attendee ) { |
|
1215 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1216 | - if ( $registration->is_primary_registrant() ) { |
|
1214 | + if ($attendee instanceof EE_Attendee) { |
|
1215 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1216 | + if ($registration->is_primary_registrant()) { |
|
1217 | 1217 | $this->checkout->primary_attendee_obj = $attendee; |
1218 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1219 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1220 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1218 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1219 | + $registration->set_attendee_id($attendee->ID()); |
|
1220 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1221 | 1221 | } |
1222 | 1222 | } |
1223 | 1223 | } |
@@ -1234,50 +1234,50 @@ discard block |
||
1234 | 1234 | */ |
1235 | 1235 | protected function _create_attendee_from_request_data() { |
1236 | 1236 | // get State ID |
1237 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1238 | - if ( ! empty( $STA_ID ) ) { |
|
1237 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1238 | + if ( ! empty($STA_ID)) { |
|
1239 | 1239 | // can we get state object from name ? |
1240 | - EE_Registry::instance()->load_model( 'State' ); |
|
1241 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1242 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1240 | + EE_Registry::instance()->load_model('State'); |
|
1241 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1242 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1243 | 1243 | } |
1244 | 1244 | // get Country ISO |
1245 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1246 | - if ( ! empty( $CNT_ISO ) ) { |
|
1245 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1246 | + if ( ! empty($CNT_ISO)) { |
|
1247 | 1247 | // can we get country object from name ? |
1248 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1248 | + EE_Registry::instance()->load_model('Country'); |
|
1249 | 1249 | $country = EEM_Country::instance()->get_col( |
1250 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1250 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1251 | 1251 | 'CNT_ISO' |
1252 | 1252 | ); |
1253 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1253 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1254 | 1254 | } |
1255 | 1255 | // grab attendee data |
1256 | 1256 | $attendee_data = array( |
1257 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1258 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1259 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1260 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1261 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1262 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1257 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1258 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1259 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1260 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1261 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1262 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1263 | 1263 | 'STA_ID' => $STA_ID, |
1264 | 1264 | 'CNT_ISO' => $CNT_ISO, |
1265 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1266 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1265 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1266 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1267 | 1267 | ); |
1268 | 1268 | // validate the email address since it is the most important piece of info |
1269 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1269 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1270 | 1270 | EE_Error::add_error( |
1271 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1271 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1272 | 1272 | __FILE__, |
1273 | 1273 | __FUNCTION__, |
1274 | 1274 | __LINE__ |
1275 | 1275 | ); |
1276 | 1276 | } |
1277 | 1277 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1278 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1279 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1280 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1278 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1279 | + && ! empty($attendee_data['ATT_lname']) |
|
1280 | + && ! empty($attendee_data['ATT_email']) |
|
1281 | 1281 | ) { |
1282 | 1282 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1283 | 1283 | array( |
@@ -1286,19 +1286,19 @@ discard block |
||
1286 | 1286 | 'ATT_email' => $attendee_data['ATT_email'] |
1287 | 1287 | ) |
1288 | 1288 | ); |
1289 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1289 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1290 | 1290 | return $existing_attendee; |
1291 | 1291 | } |
1292 | 1292 | } |
1293 | 1293 | // no existing attendee? kk let's create a new one |
1294 | 1294 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1295 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1295 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1296 | 1296 | ? $attendee_data['ATT_fname'] |
1297 | 1297 | : $attendee_data['ATT_email']; |
1298 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1298 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1299 | 1299 | ? $attendee_data['ATT_lname'] |
1300 | 1300 | : $attendee_data['ATT_email']; |
1301 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1301 | + return EE_Attendee::new_instance($attendee_data); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | |
@@ -1316,26 +1316,26 @@ discard block |
||
1316 | 1316 | // how have they chosen to pay? |
1317 | 1317 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1318 | 1318 | ? 'no_payment_required' |
1319 | - : $this->_get_selected_method_of_payment( true ); |
|
1319 | + : $this->_get_selected_method_of_payment(true); |
|
1320 | 1320 | // choose your own adventure based on method_of_payment |
1321 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1321 | + switch ($this->checkout->selected_method_of_payment) { |
|
1322 | 1322 | |
1323 | 1323 | case 'events_sold_out' : |
1324 | 1324 | $this->checkout->redirect = true; |
1325 | 1325 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1326 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1326 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1327 | 1327 | // mark this reg step as completed |
1328 | 1328 | $this->set_completed(); |
1329 | 1329 | return false; |
1330 | 1330 | break; |
1331 | 1331 | |
1332 | 1332 | case 'payments_closed' : |
1333 | - if ( apply_filters( |
|
1333 | + if (apply_filters( |
|
1334 | 1334 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1335 | 1335 | false |
1336 | - ) ) { |
|
1336 | + )) { |
|
1337 | 1337 | EE_Error::add_success( |
1338 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1338 | + __('no payment required at this time.', 'event_espresso'), |
|
1339 | 1339 | __FILE__, |
1340 | 1340 | __FUNCTION__, |
1341 | 1341 | __LINE__ |
@@ -1347,12 +1347,12 @@ discard block |
||
1347 | 1347 | break; |
1348 | 1348 | |
1349 | 1349 | case 'no_payment_required' : |
1350 | - if ( apply_filters( |
|
1350 | + if (apply_filters( |
|
1351 | 1351 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1352 | 1352 | false |
1353 | - ) ) { |
|
1353 | + )) { |
|
1354 | 1354 | EE_Error::add_success( |
1355 | - __( 'no payment required.', 'event_espresso' ), |
|
1355 | + __('no payment required.', 'event_espresso'), |
|
1356 | 1356 | __FILE__, |
1357 | 1357 | __FUNCTION__, |
1358 | 1358 | __LINE__ |
@@ -1365,9 +1365,9 @@ discard block |
||
1365 | 1365 | |
1366 | 1366 | default: |
1367 | 1367 | $payment_successful = $this->_process_payment(); |
1368 | - if ( $payment_successful ) { |
|
1368 | + if ($payment_successful) { |
|
1369 | 1369 | $this->checkout->continue_reg = true; |
1370 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1370 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1371 | 1371 | } else { |
1372 | 1372 | $this->checkout->continue_reg = false; |
1373 | 1373 | } |
@@ -1386,8 +1386,8 @@ discard block |
||
1386 | 1386 | * @return void |
1387 | 1387 | * @throws \EE_Error |
1388 | 1388 | */ |
1389 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1390 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1389 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1390 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1391 | 1391 | case EE_PMT_Base::offsite : |
1392 | 1392 | break; |
1393 | 1393 | case EE_PMT_Base::onsite : |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | public function update_reg_step() { |
1411 | 1411 | $success = true; |
1412 | 1412 | // if payment required |
1413 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1413 | + if ($this->checkout->transaction->total() > 0) { |
|
1414 | 1414 | do_action( |
1415 | 1415 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1416 | 1416 | $this->checkout->transaction |
@@ -1418,13 +1418,13 @@ discard block |
||
1418 | 1418 | // attempt payment via payment method |
1419 | 1419 | $success = $this->process_reg_step(); |
1420 | 1420 | } |
1421 | - if ( $success && ! $this->checkout->redirect ) { |
|
1421 | + if ($success && ! $this->checkout->redirect) { |
|
1422 | 1422 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1423 | 1423 | $this->checkout->transaction->ID() |
1424 | 1424 | ); |
1425 | 1425 | // set return URL |
1426 | 1426 | $this->checkout->redirect_url = add_query_arg( |
1427 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1427 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1428 | 1428 | $this->checkout->thank_you_page_url |
1429 | 1429 | ); |
1430 | 1430 | } |
@@ -1444,28 +1444,28 @@ discard block |
||
1444 | 1444 | // clear any previous errors related to not selecting a payment method |
1445 | 1445 | // EE_Error::overwrite_errors(); |
1446 | 1446 | // ya gotta make a choice man |
1447 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1447 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1448 | 1448 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1449 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1449 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1450 | 1450 | ); |
1451 | 1451 | return false; |
1452 | 1452 | } |
1453 | 1453 | // get EE_Payment_Method object |
1454 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1454 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1455 | 1455 | return false; |
1456 | 1456 | } |
1457 | 1457 | // setup billing form |
1458 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1458 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1459 | 1459 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1460 | 1460 | $this->checkout->payment_method |
1461 | 1461 | ); |
1462 | 1462 | // bad billing form ? |
1463 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1463 | + if ( ! $this->_billing_form_is_valid()) { |
|
1464 | 1464 | return false; |
1465 | 1465 | } |
1466 | 1466 | } |
1467 | 1467 | // ensure primary registrant has been fully processed |
1468 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1468 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1469 | 1469 | return false; |
1470 | 1470 | } |
1471 | 1471 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1473,18 +1473,18 @@ discard block |
||
1473 | 1473 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1474 | 1474 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1475 | 1475 | // attempt payment |
1476 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1476 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1477 | 1477 | // process results |
1478 | - $payment = $this->_validate_payment( $payment ); |
|
1479 | - $payment = $this->_post_payment_processing( $payment ); |
|
1478 | + $payment = $this->_validate_payment($payment); |
|
1479 | + $payment = $this->_post_payment_processing($payment); |
|
1480 | 1480 | // verify payment |
1481 | - if ( $payment instanceof EE_Payment ) { |
|
1481 | + if ($payment instanceof EE_Payment) { |
|
1482 | 1482 | // store that for later |
1483 | 1483 | $this->checkout->payment = $payment; |
1484 | 1484 | /** @type EE_Transaction_Processor $transaction_processor */ |
1485 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1485 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1486 | 1486 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1487 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1487 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1488 | 1488 | $payment_status = $payment->status(); |
1489 | 1489 | if ( |
1490 | 1490 | $payment_status === EEM_Payment::status_id_approved |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | } else { |
1495 | 1495 | return false; |
1496 | 1496 | } |
1497 | - } else if ( $payment === true ) { |
|
1497 | + } else if ($payment === true) { |
|
1498 | 1498 | // please note that offline payment methods will NOT make a payment, |
1499 | 1499 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1500 | 1500 | $this->checkout->payment = $payment; |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | ); |
1520 | 1520 | $html = $payment_method_billing_info->get_html_and_js(); |
1521 | 1521 | $html .= $this->checkout->redirect_form; |
1522 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1522 | + EE_Registry::instance()->REQ->add_output($html); |
|
1523 | 1523 | return true; |
1524 | 1524 | } |
1525 | 1525 | |
@@ -1533,28 +1533,28 @@ discard block |
||
1533 | 1533 | * @throws \EE_Error |
1534 | 1534 | */ |
1535 | 1535 | private function _billing_form_is_valid() { |
1536 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1536 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1537 | 1537 | return true; |
1538 | 1538 | } |
1539 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1540 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1539 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1540 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1541 | 1541 | $this->checkout->billing_form->receive_form_submission(); |
1542 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1542 | + if ($this->checkout->billing_form->is_valid()) { |
|
1543 | 1543 | return true; |
1544 | 1544 | } |
1545 | 1545 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1546 | 1546 | $error_strings = array(); |
1547 | - foreach ( $validation_errors as $validation_error ) { |
|
1548 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1547 | + foreach ($validation_errors as $validation_error) { |
|
1548 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1549 | 1549 | $form_section = $validation_error->get_form_section(); |
1550 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1550 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1551 | 1551 | $label = $form_section->html_label_text(); |
1552 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1552 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1553 | 1553 | $label = $form_section->name(); |
1554 | 1554 | } else { |
1555 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1555 | + $label = __('Validation Error', 'event_espresso'); |
|
1556 | 1556 | } |
1557 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1557 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1558 | 1558 | } |
1559 | 1559 | } |
1560 | 1560 | EE_Error::add_error( |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | 'event_espresso' |
1565 | 1565 | ), |
1566 | 1566 | '<br/>', |
1567 | - implode( '<br/>', $error_strings ) |
|
1567 | + implode('<br/>', $error_strings) |
|
1568 | 1568 | ), |
1569 | 1569 | __FILE__, |
1570 | 1570 | __FUNCTION__, |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | } |
1584 | 1584 | } else { |
1585 | 1585 | EE_Error::add_error( |
1586 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1586 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1587 | 1587 | __FILE__, |
1588 | 1588 | __FUNCTION__, |
1589 | 1589 | __LINE__ |
@@ -1618,13 +1618,13 @@ discard block |
||
1618 | 1618 | // grab the primary_registration object |
1619 | 1619 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1620 | 1620 | /** @type EE_Transaction_Processor $transaction_processor */ |
1621 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1621 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1622 | 1622 | // at this point we'll consider a TXN to not have been failed |
1623 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1623 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1624 | 1624 | // save the TXN ( which clears cached copy of primary_registration) |
1625 | 1625 | $this->checkout->transaction->save(); |
1626 | 1626 | // grab TXN ID and save it to the primary_registration |
1627 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1627 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1628 | 1628 | // save what we have so far |
1629 | 1629 | $primary_registration->save(); |
1630 | 1630 | return true; |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | private function _capture_primary_registration_data_from_billing_form() { |
1643 | 1643 | // convert billing form data into an attendee |
1644 | 1644 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1645 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1645 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1646 | 1646 | EE_Error::add_error( |
1647 | 1647 | sprintf( |
1648 | 1648 | __( |
@@ -1650,7 +1650,7 @@ discard block |
||
1650 | 1650 | 'event_espresso' |
1651 | 1651 | ), |
1652 | 1652 | '<br/>', |
1653 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1653 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1654 | 1654 | ), |
1655 | 1655 | __FILE__, |
1656 | 1656 | __FUNCTION__, |
@@ -1659,7 +1659,7 @@ discard block |
||
1659 | 1659 | return false; |
1660 | 1660 | } |
1661 | 1661 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1662 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1662 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1663 | 1663 | EE_Error::add_error( |
1664 | 1664 | sprintf( |
1665 | 1665 | __( |
@@ -1667,7 +1667,7 @@ discard block |
||
1667 | 1667 | 'event_espresso' |
1668 | 1668 | ), |
1669 | 1669 | '<br/>', |
1670 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1670 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1671 | 1671 | ), |
1672 | 1672 | __FILE__, |
1673 | 1673 | __FUNCTION__, |
@@ -1675,7 +1675,7 @@ discard block |
||
1675 | 1675 | ); |
1676 | 1676 | return false; |
1677 | 1677 | } |
1678 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1678 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1679 | 1679 | instanceof |
1680 | 1680 | EE_Attendee |
1681 | 1681 | ) { |
@@ -1686,7 +1686,7 @@ discard block |
||
1686 | 1686 | 'event_espresso' |
1687 | 1687 | ), |
1688 | 1688 | '<br/>', |
1689 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1689 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1690 | 1690 | ), |
1691 | 1691 | __FILE__, |
1692 | 1692 | __FUNCTION__, |
@@ -1695,9 +1695,9 @@ discard block |
||
1695 | 1695 | return false; |
1696 | 1696 | } |
1697 | 1697 | /** @type EE_Registration_Processor $registration_processor */ |
1698 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1698 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1699 | 1699 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1700 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1700 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1701 | 1701 | return true; |
1702 | 1702 | } |
1703 | 1703 | |
@@ -1713,17 +1713,17 @@ discard block |
||
1713 | 1713 | */ |
1714 | 1714 | private function _get_payment_method_for_selected_method_of_payment() { |
1715 | 1715 | // get EE_Payment_Method object |
1716 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
1717 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1716 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1717 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1718 | 1718 | } else { |
1719 | 1719 | // load EEM_Payment_Method |
1720 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1720 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1721 | 1721 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1722 | 1722 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1723 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1723 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1724 | 1724 | } |
1725 | 1725 | // verify $payment_method |
1726 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1726 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1727 | 1727 | // not a payment |
1728 | 1728 | EE_Error::add_error( |
1729 | 1729 | sprintf( |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | 'event_espresso' |
1733 | 1733 | ), |
1734 | 1734 | '<br/>', |
1735 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1735 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1736 | 1736 | ), |
1737 | 1737 | __FILE__, |
1738 | 1738 | __FUNCTION__, |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | return null; |
1742 | 1742 | } |
1743 | 1743 | // and verify it has a valid Payment_Method Type object |
1744 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1744 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1745 | 1745 | // not a payment |
1746 | 1746 | EE_Error::add_error( |
1747 | 1747 | sprintf( |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | 'event_espresso' |
1751 | 1751 | ), |
1752 | 1752 | '<br/>', |
1753 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1753 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1754 | 1754 | ), |
1755 | 1755 | __FILE__, |
1756 | 1756 | __FUNCTION__, |
@@ -1771,29 +1771,29 @@ discard block |
||
1771 | 1771 | * @return mixed EE_Payment | boolean |
1772 | 1772 | * @throws \EE_Error |
1773 | 1773 | */ |
1774 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1774 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1775 | 1775 | $payment = null; |
1776 | 1776 | $this->checkout->transaction->save(); |
1777 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1778 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1777 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1778 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1779 | 1779 | return false; |
1780 | 1780 | } |
1781 | 1781 | try { |
1782 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1782 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1783 | 1783 | // generate payment object |
1784 | 1784 | $payment = $payment_processor->process_payment( |
1785 | 1785 | $payment_method, |
1786 | 1786 | $this->checkout->transaction, |
1787 | 1787 | $this->checkout->amount_owing, |
1788 | 1788 | $this->checkout->billing_form, |
1789 | - $this->_get_return_url( $payment_method ), |
|
1789 | + $this->_get_return_url($payment_method), |
|
1790 | 1790 | 'CART', |
1791 | 1791 | $this->checkout->admin_request, |
1792 | 1792 | true, |
1793 | 1793 | $this->reg_step_url() |
1794 | 1794 | ); |
1795 | - } catch ( Exception $e ) { |
|
1796 | - $this->_handle_payment_processor_exception( $e ); |
|
1795 | + } catch (Exception $e) { |
|
1796 | + $this->_handle_payment_processor_exception($e); |
|
1797 | 1797 | } |
1798 | 1798 | return $payment; |
1799 | 1799 | } |
@@ -1808,7 +1808,7 @@ discard block |
||
1808 | 1808 | * @return void |
1809 | 1809 | * @throws \EE_Error |
1810 | 1810 | */ |
1811 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1811 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1812 | 1812 | EE_Error::add_error( |
1813 | 1813 | sprintf( |
1814 | 1814 | __( |
@@ -1816,7 +1816,7 @@ discard block |
||
1816 | 1816 | 'event_espresso' |
1817 | 1817 | ), |
1818 | 1818 | '<br/>', |
1819 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1819 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1820 | 1820 | $e->getMessage(), |
1821 | 1821 | $e->getFile(), |
1822 | 1822 | $e->getLine() |
@@ -1837,9 +1837,9 @@ discard block |
||
1837 | 1837 | * @return string |
1838 | 1838 | * @throws \EE_Error |
1839 | 1839 | */ |
1840 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1840 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1841 | 1841 | $return_url = ''; |
1842 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1842 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1843 | 1843 | case EE_PMT_Base::offsite : |
1844 | 1844 | $return_url = add_query_arg( |
1845 | 1845 | array( |
@@ -1868,12 +1868,12 @@ discard block |
||
1868 | 1868 | * @return EE_Payment | FALSE |
1869 | 1869 | * @throws \EE_Error |
1870 | 1870 | */ |
1871 | - private function _validate_payment( $payment = null ) { |
|
1872 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1871 | + private function _validate_payment($payment = null) { |
|
1872 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1873 | 1873 | return true; |
1874 | 1874 | } |
1875 | 1875 | // verify payment object |
1876 | - if ( ! $payment instanceof EE_Payment ) { |
|
1876 | + if ( ! $payment instanceof EE_Payment) { |
|
1877 | 1877 | // not a payment |
1878 | 1878 | EE_Error::add_error( |
1879 | 1879 | sprintf( |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | 'event_espresso' |
1883 | 1883 | ), |
1884 | 1884 | '<br/>', |
1885 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1885 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1886 | 1886 | ), |
1887 | 1887 | __FILE__, |
1888 | 1888 | __FUNCTION__, |
@@ -1903,27 +1903,27 @@ discard block |
||
1903 | 1903 | * @return bool |
1904 | 1904 | * @throws \EE_Error |
1905 | 1905 | */ |
1906 | - private function _post_payment_processing( $payment = null ) { |
|
1906 | + private function _post_payment_processing($payment = null) { |
|
1907 | 1907 | // Off-Line payment? |
1908 | - if ( $payment === true ) { |
|
1908 | + if ($payment === true) { |
|
1909 | 1909 | //$this->_setup_redirect_for_next_step(); |
1910 | 1910 | return true; |
1911 | 1911 | // On-Site payment? |
1912 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
1913 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
1912 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
1913 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1914 | 1914 | //$this->_setup_redirect_for_next_step(); |
1915 | 1915 | $this->checkout->continue_reg = false; |
1916 | 1916 | } |
1917 | 1917 | // Off-Site payment? |
1918 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1918 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1919 | 1919 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1920 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
1921 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1920 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1921 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1922 | 1922 | $this->checkout->redirect = true; |
1923 | 1923 | $this->checkout->redirect_form = $payment->redirect_form(); |
1924 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1924 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1925 | 1925 | // set JSON response |
1926 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1926 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1927 | 1927 | // set cron job for finalizing the TXN |
1928 | 1928 | // in case the user does not return from the off-site gateway |
1929 | 1929 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1931,7 +1931,7 @@ discard block |
||
1931 | 1931 | $this->checkout->transaction->ID() |
1932 | 1932 | ); |
1933 | 1933 | // and lastly, let's bump the payment status to pending |
1934 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1934 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1935 | 1935 | $payment->save(); |
1936 | 1936 | } else { |
1937 | 1937 | // not a payment |
@@ -1943,7 +1943,7 @@ discard block |
||
1943 | 1943 | 'event_espresso' |
1944 | 1944 | ), |
1945 | 1945 | '<br/>', |
1946 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1946 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1947 | 1947 | ), |
1948 | 1948 | __FILE__, |
1949 | 1949 | __FUNCTION__, |
@@ -1981,21 +1981,21 @@ discard block |
||
1981 | 1981 | * @return bool |
1982 | 1982 | * @throws \EE_Error |
1983 | 1983 | */ |
1984 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1984 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1985 | 1985 | // off-line payment? carry on |
1986 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
1986 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
1987 | 1987 | return true; |
1988 | 1988 | } |
1989 | 1989 | // verify payment validity |
1990 | - if ( $payment instanceof EE_Payment ) { |
|
1991 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1990 | + if ($payment instanceof EE_Payment) { |
|
1991 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1992 | 1992 | $msg = $payment->gateway_response(); |
1993 | 1993 | // check results |
1994 | - switch ( $payment->status() ) { |
|
1994 | + switch ($payment->status()) { |
|
1995 | 1995 | // good payment |
1996 | 1996 | case EEM_Payment::status_id_approved : |
1997 | 1997 | EE_Error::add_success( |
1998 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
1998 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
1999 | 1999 | __FILE__, |
2000 | 2000 | __FUNCTION__, |
2001 | 2001 | __LINE__ |
@@ -2004,45 +2004,45 @@ discard block |
||
2004 | 2004 | break; |
2005 | 2005 | // slow payment |
2006 | 2006 | case EEM_Payment::status_id_pending : |
2007 | - if ( empty( $msg ) ) { |
|
2007 | + if (empty($msg)) { |
|
2008 | 2008 | $msg = __( |
2009 | 2009 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
2010 | 2010 | 'event_espresso' |
2011 | 2011 | ); |
2012 | 2012 | } |
2013 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2013 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2014 | 2014 | return true; |
2015 | 2015 | break; |
2016 | 2016 | // don't wanna payment |
2017 | 2017 | case EEM_Payment::status_id_cancelled : |
2018 | - if ( empty( $msg ) ) { |
|
2018 | + if (empty($msg)) { |
|
2019 | 2019 | $msg = _n( |
2020 | 2020 | 'Payment cancelled. Please try again.', |
2021 | 2021 | 'Payment cancelled. Please try again or select another method of payment.', |
2022 | - count( $this->checkout->available_payment_methods ), |
|
2022 | + count($this->checkout->available_payment_methods), |
|
2023 | 2023 | 'event_espresso' |
2024 | 2024 | ); |
2025 | 2025 | } |
2026 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2026 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2027 | 2027 | return false; |
2028 | 2028 | break; |
2029 | 2029 | // not enough payment |
2030 | 2030 | case EEM_Payment::status_id_declined : |
2031 | - if ( empty( $msg ) ) { |
|
2031 | + if (empty($msg)) { |
|
2032 | 2032 | $msg = _n( |
2033 | 2033 | 'We\'re sorry but your payment was declined. Please try again.', |
2034 | 2034 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2035 | - count( $this->checkout->available_payment_methods ), |
|
2035 | + count($this->checkout->available_payment_methods), |
|
2036 | 2036 | 'event_espresso' |
2037 | 2037 | ); |
2038 | 2038 | } |
2039 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2039 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2040 | 2040 | return false; |
2041 | 2041 | break; |
2042 | 2042 | // bad payment |
2043 | 2043 | case EEM_Payment::status_id_failed : |
2044 | - if ( ! empty( $msg ) ) { |
|
2045 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2044 | + if ( ! empty($msg)) { |
|
2045 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2046 | 2046 | return false; |
2047 | 2047 | } |
2048 | 2048 | // default to error below |
@@ -2051,7 +2051,7 @@ discard block |
||
2051 | 2051 | } |
2052 | 2052 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2053 | 2053 | // the payment processing is just running slower than the registrant's request |
2054 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2054 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2055 | 2055 | return true; |
2056 | 2056 | } |
2057 | 2057 | EE_Error::add_error( |
@@ -2061,7 +2061,7 @@ discard block |
||
2061 | 2061 | 'event_espresso' |
2062 | 2062 | ), |
2063 | 2063 | '<br/>', |
2064 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2064 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2065 | 2065 | ), |
2066 | 2066 | __FILE__, |
2067 | 2067 | __FUNCTION__, |
@@ -2094,13 +2094,13 @@ discard block |
||
2094 | 2094 | public function process_gateway_response() { |
2095 | 2095 | $payment = null; |
2096 | 2096 | // how have they chosen to pay? |
2097 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2097 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2098 | 2098 | // get EE_Payment_Method object |
2099 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2099 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2100 | 2100 | $this->checkout->continue_reg = false; |
2101 | 2101 | return false; |
2102 | 2102 | } |
2103 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2103 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2104 | 2104 | return false; |
2105 | 2105 | } |
2106 | 2106 | $this->_validate_offsite_return(); |
@@ -2114,23 +2114,23 @@ discard block |
||
2114 | 2114 | // true |
2115 | 2115 | //); |
2116 | 2116 | // verify TXN |
2117 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2117 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2118 | 2118 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2119 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2119 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2120 | 2120 | $this->checkout->continue_reg = false; |
2121 | 2121 | return false; |
2122 | 2122 | } |
2123 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2124 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2125 | - $payment = $this->_validate_payment( $payment ); |
|
2123 | + $payment = $this->_process_off_site_payment($gateway); |
|
2124 | + $payment = $this->_process_cancelled_payments($payment); |
|
2125 | + $payment = $this->_validate_payment($payment); |
|
2126 | 2126 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2127 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2127 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2128 | 2128 | //$this->_setup_redirect_for_next_step(); |
2129 | 2129 | // store that for later |
2130 | 2130 | $this->checkout->payment = $payment; |
2131 | 2131 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2132 | 2132 | // because we will complete this step during the IPN processing then |
2133 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2133 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2134 | 2134 | $this->set_completed(); |
2135 | 2135 | } |
2136 | 2136 | return true; |
@@ -2154,21 +2154,21 @@ discard block |
||
2154 | 2154 | * @throws \EE_Error |
2155 | 2155 | */ |
2156 | 2156 | private function _validate_offsite_return() { |
2157 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2158 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2157 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2158 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2159 | 2159 | // Houston... we might have a problem |
2160 | 2160 | $invalid_TXN = false; |
2161 | 2161 | // first gather some info |
2162 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2162 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2163 | 2163 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2164 | 2164 | ? $valid_TXN->primary_registration() |
2165 | 2165 | : null; |
2166 | 2166 | // let's start by retrieving the cart for this TXN |
2167 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2168 | - if ( $cart instanceof EE_Cart ) { |
|
2167 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2168 | + if ($cart instanceof EE_Cart) { |
|
2169 | 2169 | // verify that the current cart has tickets |
2170 | 2170 | $tickets = $cart->get_tickets(); |
2171 | - if ( empty( $tickets ) ) { |
|
2171 | + if (empty($tickets)) { |
|
2172 | 2172 | $invalid_TXN = true; |
2173 | 2173 | } |
2174 | 2174 | } else { |
@@ -2178,39 +2178,39 @@ discard block |
||
2178 | 2178 | ? $primary_registrant->session_ID() |
2179 | 2179 | : null; |
2180 | 2180 | // validate current Session ID and compare against valid TXN session ID |
2181 | - if ( EE_Session::instance()->id() === null ) { |
|
2181 | + if (EE_Session::instance()->id() === null) { |
|
2182 | 2182 | $invalid_TXN = true; |
2183 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
2183 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
2184 | 2184 | // WARNING !!! |
2185 | 2185 | // this could be PayPal sending back duplicate requests (ya they do that) |
2186 | 2186 | // or it **could** mean someone is simply registering AGAIN after having just done so |
2187 | 2187 | // so now we need to determine if this current TXN looks valid or not |
2188 | 2188 | /** @type EE_Transaction_Processor $transaction_processor */ |
2189 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
2189 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2190 | 2190 | // has this step even been started ? |
2191 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
2191 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
2192 | 2192 | ) { |
2193 | 2193 | // really? you're half way through this reg step, but you never started it ? |
2194 | 2194 | $invalid_TXN = true; |
2195 | 2195 | } |
2196 | 2196 | } |
2197 | - if ( $invalid_TXN ) { |
|
2197 | + if ($invalid_TXN) { |
|
2198 | 2198 | // is the valid TXN completed ? |
2199 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2199 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2200 | 2200 | /** @type EE_Transaction_Processor $transaction_processor */ |
2201 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
2201 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2202 | 2202 | // has this step even been started ? |
2203 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
2204 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2203 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
2204 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2205 | 2205 | // so it **looks** like this is a double request from PayPal |
2206 | 2206 | // so let's try to pick up where we left off |
2207 | 2207 | $this->checkout->transaction = $valid_TXN; |
2208 | - $this->checkout->refresh_all_entities( true ); |
|
2208 | + $this->checkout->refresh_all_entities(true); |
|
2209 | 2209 | return; |
2210 | 2210 | } |
2211 | 2211 | } |
2212 | 2212 | // you appear to be lost? |
2213 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2213 | + $this->_redirect_wayward_request($primary_registrant); |
|
2214 | 2214 | } |
2215 | 2215 | } |
2216 | 2216 | } |
@@ -2225,14 +2225,14 @@ discard block |
||
2225 | 2225 | * @return bool |
2226 | 2226 | * @throws \EE_Error |
2227 | 2227 | */ |
2228 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2229 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2228 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2229 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2230 | 2230 | // try redirecting based on the current TXN |
2231 | 2231 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2232 | 2232 | ? $this->checkout->transaction->primary_registration() |
2233 | 2233 | : null; |
2234 | 2234 | } |
2235 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2235 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2236 | 2236 | EE_Error::add_error( |
2237 | 2237 | sprintf( |
2238 | 2238 | __( |
@@ -2240,7 +2240,7 @@ discard block |
||
2240 | 2240 | 'event_espresso' |
2241 | 2241 | ), |
2242 | 2242 | '<br/>', |
2243 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2243 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2244 | 2244 | ), |
2245 | 2245 | __FILE__, |
2246 | 2246 | __FUNCTION__, |
@@ -2271,17 +2271,17 @@ discard block |
||
2271 | 2271 | * @return \EE_Payment |
2272 | 2272 | * @throws \EE_Error |
2273 | 2273 | */ |
2274 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2274 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2275 | 2275 | try { |
2276 | 2276 | $request_data = \EE_Registry::instance()->REQ->params(); |
2277 | 2277 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2278 | 2278 | $this->set_handle_IPN_in_this_request( |
2279 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2279 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2280 | 2280 | ); |
2281 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2281 | + if ($this->handle_IPN_in_this_request()) { |
|
2282 | 2282 | // get payment details and process results |
2283 | 2283 | /** @type EE_Payment_Processor $payment_processor */ |
2284 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2284 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2285 | 2285 | $payment = $payment_processor->process_ipn( |
2286 | 2286 | $request_data, |
2287 | 2287 | $this->checkout->transaction, |
@@ -2294,14 +2294,14 @@ discard block |
||
2294 | 2294 | $payment = $this->checkout->transaction->last_payment(); |
2295 | 2295 | //$payment_source = 'last_payment'; |
2296 | 2296 | } |
2297 | - } catch ( Exception $e ) { |
|
2297 | + } catch (Exception $e) { |
|
2298 | 2298 | // let's just eat the exception and try to move on using any previously set payment info |
2299 | 2299 | $payment = $this->checkout->transaction->last_payment(); |
2300 | 2300 | //$payment_source = 'last_payment after Exception'; |
2301 | 2301 | // but if we STILL don't have a payment object |
2302 | - if ( ! $payment instanceof EE_Payment ) { |
|
2302 | + if ( ! $payment instanceof EE_Payment) { |
|
2303 | 2303 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2304 | - $this->_handle_payment_processor_exception( $e ); |
|
2304 | + $this->_handle_payment_processor_exception($e); |
|
2305 | 2305 | } |
2306 | 2306 | } |
2307 | 2307 | // DEBUG LOG |
@@ -2326,13 +2326,13 @@ discard block |
||
2326 | 2326 | * @return EE_Payment | FALSE |
2327 | 2327 | * @throws \EE_Error |
2328 | 2328 | */ |
2329 | - private function _process_cancelled_payments( $payment = null ) { |
|
2329 | + private function _process_cancelled_payments($payment = null) { |
|
2330 | 2330 | if ( |
2331 | 2331 | $payment instanceof EE_Payment |
2332 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2332 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2333 | 2333 | && $payment->status() === EEM_Payment::status_id_failed |
2334 | 2334 | ) { |
2335 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2335 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2336 | 2336 | } |
2337 | 2337 | return $payment; |
2338 | 2338 | } |
@@ -2349,14 +2349,14 @@ discard block |
||
2349 | 2349 | public function get_transaction_details_for_gateways() { |
2350 | 2350 | $txn_details = array(); |
2351 | 2351 | // ya gotta make a choice man |
2352 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2352 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2353 | 2353 | $txn_details = array( |
2354 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2354 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2355 | 2355 | ); |
2356 | 2356 | } |
2357 | 2357 | // get EE_Payment_Method object |
2358 | 2358 | if ( |
2359 | - empty( $txn_details ) |
|
2359 | + empty($txn_details) |
|
2360 | 2360 | && |
2361 | 2361 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2362 | 2362 | ) { |
@@ -2368,8 +2368,8 @@ discard block |
||
2368 | 2368 | ) |
2369 | 2369 | ); |
2370 | 2370 | } |
2371 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2372 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2371 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2372 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2373 | 2373 | $txn_details = array( |
2374 | 2374 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2375 | 2375 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2380,7 +2380,7 @@ discard block |
||
2380 | 2380 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2381 | 2381 | 'payment_amount' => $this->checkout->amount_owing, |
2382 | 2382 | 'return_url' => $return_url, |
2383 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2383 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2384 | 2384 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2385 | 2385 | array( |
2386 | 2386 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2389,7 +2389,7 @@ discard block |
||
2389 | 2389 | ) |
2390 | 2390 | ); |
2391 | 2391 | } |
2392 | - echo json_encode( $txn_details ); |
|
2392 | + echo json_encode($txn_details); |
|
2393 | 2393 | exit(); |
2394 | 2394 | } |
2395 | 2395 |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Checkout |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since 4.5.0 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Checkout |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since 4.5.0 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Checkout { |
15 | 15 | |
16 | 16 | /** |
@@ -792,10 +792,10 @@ discard block |
||
792 | 792 | */ |
793 | 793 | public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
794 | 794 | return ! $this->revisit |
795 | - || $this->primary_revisit |
|
796 | - || ( |
|
797 | - $this->revisit && $this->reg_url_link === $registration->reg_url_link() |
|
798 | - ) |
|
795 | + || $this->primary_revisit |
|
796 | + || ( |
|
797 | + $this->revisit && $this->reg_url_link === $registration->reg_url_link() |
|
798 | + ) |
|
799 | 799 | ? true |
800 | 800 | : false; |
801 | 801 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | /** |
253 | 253 | * returns true if ANY reg status was updated during checkout |
254 | - * @return array |
|
254 | + * @return boolean |
|
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | 257 | foreach ( $this->reg_status_updated as $reg_status ) { |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | /** |
278 | 278 | * @param $REG_ID |
279 | - * @param $reg_status |
|
279 | + * @param boolean $reg_status |
|
280 | 280 | */ |
281 | 281 | public function set_reg_status_updated( $REG_ID, $reg_status ) { |
282 | 282 | $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * reset_reg_steps |
634 | 634 | * |
635 | 635 | * @access public |
636 | - * @return bool |
|
636 | + * @return boolean|null |
|
637 | 637 | */ |
638 | 638 | public function reset_reg_steps() { |
639 | 639 | $this->sort_reg_steps(); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * stores whether any updates were made to the TXN or it's related registrations |
749 | 749 | * |
750 | 750 | * @access public |
751 | - * @return bool |
|
751 | + * @return boolean|null |
|
752 | 752 | * @throws \EE_Error |
753 | 753 | */ |
754 | 754 | public function track_transaction_and_registration_status_updates() { |
@@ -1110,6 +1110,7 @@ discard block |
||
1110 | 1110 | * |
1111 | 1111 | * @param string | int $reg_cache_ID |
1112 | 1112 | * @param EE_Registration $registration |
1113 | + * @param integer $reg_cache_ID |
|
1113 | 1114 | * @return void |
1114 | 1115 | * @throws \EE_Error |
1115 | 1116 | */ |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | $this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url(); |
243 | 243 | $this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url(); |
244 | 244 | $this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url(); |
245 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE ); |
|
245 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE); |
|
246 | 246 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax; |
247 | - $this->reg_cache_where_params = array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
247 | + $this->reg_cache_where_params = array('order_by' => array('REG_count' => 'ASC')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | * @return array |
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | - foreach ( $this->reg_status_updated as $reg_status ) { |
|
258 | - if ( $reg_status ) { |
|
257 | + foreach ($this->reg_status_updated as $reg_status) { |
|
258 | + if ($reg_status) { |
|
259 | 259 | return true; |
260 | 260 | } |
261 | 261 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param $REG_ID |
269 | 269 | * @return array |
270 | 270 | */ |
271 | - public function reg_status_updated( $REG_ID ) { |
|
272 | - return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false; |
|
271 | + public function reg_status_updated($REG_ID) { |
|
272 | + return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param $REG_ID |
279 | 279 | * @param $reg_status |
280 | 280 | */ |
281 | - public function set_reg_status_updated( $REG_ID, $reg_status ) { |
|
282 | - $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
|
281 | + public function set_reg_status_updated($REG_ID, $reg_status) { |
|
282 | + $this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * can ONLY be set by the Finalize_Registration reg step |
301 | 301 | */ |
302 | 302 | public function set_exit_spco() { |
303 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
303 | + if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
304 | 304 | $this->exit_spco = true; |
305 | 305 | } |
306 | 306 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function reset_for_current_request() { |
319 | 319 | $this->process_form_submission = FALSE; |
320 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true ); |
|
320 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true); |
|
321 | 321 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax; |
322 | 322 | $this->continue_reg = true; |
323 | 323 | $this->redirect = false; |
324 | 324 | // don't reset the cached redirect form if we're about to be asked to display it !!! |
325 | - if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) { |
|
325 | + if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') { |
|
326 | 326 | $this->redirect_form = ''; |
327 | 327 | } |
328 | 328 | $this->redirect_url = ''; |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_SPCO_Reg_Step $reg_step_obj |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) { |
|
343 | - $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj; |
|
342 | + public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) { |
|
343 | + $this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -356,22 +356,22 @@ discard block |
||
356 | 356 | * @return void |
357 | 357 | * @throws \EE_Error |
358 | 358 | */ |
359 | - public function skip_reg_step( $reg_step_slug = '' ) { |
|
360 | - $step_to_skip = $this->find_reg_step( $reg_step_slug ); |
|
361 | - if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) { |
|
362 | - $step_to_skip->set_is_current_step( false ); |
|
359 | + public function skip_reg_step($reg_step_slug = '') { |
|
360 | + $step_to_skip = $this->find_reg_step($reg_step_slug); |
|
361 | + if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) { |
|
362 | + $step_to_skip->set_is_current_step(false); |
|
363 | 363 | $step_to_skip->set_completed(); |
364 | 364 | // advance to the next step |
365 | - $this->set_current_step( $this->next_step->slug() ); |
|
365 | + $this->set_current_step($this->next_step->slug()); |
|
366 | 366 | // also reset the step param in the request in case any other code references that directly |
367 | - EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() ); |
|
367 | + EE_Registry::instance()->REQ->set('step', $this->current_step->slug()); |
|
368 | 368 | // since we are skipping a step and setting the current step to be what was previously the next step, |
369 | 369 | // we need to check that the next step is now correct, and not still set to the current step. |
370 | - if ( $this->current_step->slug() === $this->next_step->slug() ) { |
|
370 | + if ($this->current_step->slug() === $this->next_step->slug()) { |
|
371 | 371 | // correctly setup the next step |
372 | 372 | $this->set_next_step(); |
373 | 373 | } |
374 | - $this->set_reg_step_initiated( $this->current_step ); |
|
374 | + $this->set_reg_step_initiated($this->current_step); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @param bool $reset whether to reset reg steps after removal |
386 | 386 | * @throws EE_Error |
387 | 387 | */ |
388 | - public function remove_reg_step( $reg_step_slug = '', $reset = true ) { |
|
389 | - unset( $this->reg_steps[ $reg_step_slug ] ); |
|
390 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
388 | + public function remove_reg_step($reg_step_slug = '', $reset = true) { |
|
389 | + unset($this->reg_steps[$reg_step_slug]); |
|
390 | + if ($this->transaction instanceof EE_Transaction) { |
|
391 | 391 | /** @type EE_Transaction_Processor $transaction_processor */ |
392 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
392 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
393 | 393 | // now remove reg step from TXN and save |
394 | - $transaction_processor->remove_reg_step( $this->transaction, $reg_step_slug ); |
|
394 | + $transaction_processor->remove_reg_step($this->transaction, $reg_step_slug); |
|
395 | 395 | $this->transaction->save(); |
396 | 396 | } |
397 | - if ( $reset ) { |
|
397 | + if ($reset) { |
|
398 | 398 | $this->reset_reg_steps(); |
399 | 399 | } |
400 | 400 | } |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | * @param int $order |
410 | 410 | * @return void |
411 | 411 | */ |
412 | - public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) { |
|
413 | - if ( isset( $this->reg_steps[ $reg_step_slug ] )) { |
|
414 | - $this->reg_steps[ $reg_step_slug ]->set_order( $order ); |
|
412 | + public function set_reg_step_order($reg_step_slug = '', $order = 100) { |
|
413 | + if (isset($this->reg_steps[$reg_step_slug])) { |
|
414 | + $this->reg_steps[$reg_step_slug]->set_order($order); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
@@ -424,25 +424,25 @@ discard block |
||
424 | 424 | * @param string $current_step |
425 | 425 | * @return void |
426 | 426 | */ |
427 | - public function set_current_step( $current_step ) { |
|
427 | + public function set_current_step($current_step) { |
|
428 | 428 | // grab what step we're on |
429 | - $this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps ); |
|
429 | + $this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps); |
|
430 | 430 | // verify instance |
431 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step ) { |
|
431 | + if ($this->current_step instanceof EE_SPCO_Reg_Step) { |
|
432 | 432 | // we don't want to repeat completed steps if this is the first time through SPCO |
433 | - if ( $this->continue_reg && ! $this->revisit && $this->current_step->completed() ) { |
|
433 | + if ($this->continue_reg && ! $this->revisit && $this->current_step->completed()) { |
|
434 | 434 | // so advance to the next step |
435 | 435 | $this->set_next_step(); |
436 | - if ( $this->next_step instanceof EE_SPCO_Reg_Step ) { |
|
436 | + if ($this->next_step instanceof EE_SPCO_Reg_Step) { |
|
437 | 437 | // and attempt to set it as the current step |
438 | - $this->set_current_step( $this->next_step->slug() ); |
|
438 | + $this->set_current_step($this->next_step->slug()); |
|
439 | 439 | } |
440 | 440 | return; |
441 | 441 | } |
442 | - $this->current_step->set_is_current_step( TRUE ); |
|
442 | + $this->current_step->set_is_current_step(TRUE); |
|
443 | 443 | } else { |
444 | 444 | EE_Error::add_error( |
445 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
445 | + __('The current step could not be set.', 'event_espresso'), |
|
446 | 446 | __FILE__, __FUNCTION__, __LINE__ |
447 | 447 | ); |
448 | 448 | } |
@@ -459,20 +459,20 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function set_next_step() { |
461 | 461 | // set pointer to start of array |
462 | - reset( $this->reg_steps ); |
|
462 | + reset($this->reg_steps); |
|
463 | 463 | // if there is more than one step |
464 | - if ( count( $this->reg_steps ) > 1 ) { |
|
464 | + if (count($this->reg_steps) > 1) { |
|
465 | 465 | // advance to the current step and set pointer |
466 | - while ( key( $this->reg_steps ) !== $this->current_step->slug() && key( $this->reg_steps ) !== '' ) { |
|
467 | - next( $this->reg_steps ); |
|
466 | + while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') { |
|
467 | + next($this->reg_steps); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | // advance one more spot ( if it exists ) |
471 | - $this->next_step = next( $this->reg_steps ); |
|
471 | + $this->next_step = next($this->reg_steps); |
|
472 | 472 | // verify instance |
473 | - $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
473 | + $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
474 | 474 | // then back to current step to reset |
475 | - prev( $this->reg_steps ); |
|
475 | + prev($this->reg_steps); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | * @return EE_SPCO_Reg_Step | null |
487 | 487 | */ |
488 | 488 | public function get_next_reg_step() { |
489 | - $next = next( $this->reg_steps ); |
|
490 | - prev( $this->reg_steps ); |
|
489 | + $next = next($this->reg_steps); |
|
490 | + prev($this->reg_steps); |
|
491 | 491 | return $next instanceof EE_SPCO_Reg_Step ? $next : null; |
492 | 492 | } |
493 | 493 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * @return EE_SPCO_Reg_Step | null |
503 | 503 | */ |
504 | 504 | public function get_prev_reg_step() { |
505 | - $prev = prev( $this->reg_steps ); |
|
506 | - next( $this->reg_steps ); |
|
505 | + $prev = prev($this->reg_steps); |
|
506 | + next($this->reg_steps); |
|
507 | 507 | return $prev instanceof EE_SPCO_Reg_Step ? $prev : null; |
508 | 508 | } |
509 | 509 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | * @return void |
517 | 517 | */ |
518 | 518 | public function sort_reg_steps() { |
519 | - $reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' ); |
|
520 | - uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback )); |
|
519 | + $reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback'); |
|
520 | + uasort($this->reg_steps, array($this, $reg_step_sorting_callback)); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | * @param string $reg_step_slug |
531 | 531 | * @return EE_SPCO_Reg_Step|null |
532 | 532 | */ |
533 | - public function find_reg_step( $reg_step_slug = '' ) { |
|
534 | - if ( ! empty( $reg_step_slug ) ) { |
|
533 | + public function find_reg_step($reg_step_slug = '') { |
|
534 | + if ( ! empty($reg_step_slug)) { |
|
535 | 535 | // copy reg step array |
536 | 536 | $reg_steps = $this->reg_steps; |
537 | 537 | // set pointer to start of array |
538 | - reset( $reg_steps ); |
|
538 | + reset($reg_steps); |
|
539 | 539 | // if there is more than one step |
540 | - if ( count( $reg_steps ) > 1 ) { |
|
540 | + if (count($reg_steps) > 1) { |
|
541 | 541 | // advance to the current step and set pointer |
542 | - while ( key( $reg_steps ) !== $reg_step_slug && key( $reg_steps ) !== '' ) { |
|
543 | - next( $reg_steps ); |
|
542 | + while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') { |
|
543 | + next($reg_steps); |
|
544 | 544 | } |
545 | - return current( $reg_steps ); |
|
545 | + return current($reg_steps); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | return null; |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | * @param EE_SPCO_Reg_Step $reg_step_B |
559 | 559 | * @return array() |
560 | 560 | */ |
561 | - public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) { |
|
561 | + public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) { |
|
562 | 562 | // send finalize_registration step to the end of the array |
563 | - if ( $reg_step_A->slug() === 'finalize_registration' ) { |
|
563 | + if ($reg_step_A->slug() === 'finalize_registration') { |
|
564 | 564 | return 1; |
565 | - } else if ( $reg_step_B->slug() === 'finalize_registration' ) { |
|
565 | + } else if ($reg_step_B->slug() === 'finalize_registration') { |
|
566 | 566 | return -1; |
567 | 567 | } |
568 | - if ( $reg_step_A->order() === $reg_step_B->order() ) { |
|
568 | + if ($reg_step_A->order() === $reg_step_B->order()) { |
|
569 | 569 | return 0; |
570 | 570 | } |
571 | - return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1; |
|
571 | + return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @param EE_SPCO_Reg_Step $reg_step |
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | - public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) { |
|
583 | + public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) { |
|
584 | 584 | // call set_reg_step_initiated ??? |
585 | 585 | if ( |
586 | 586 | // first time visiting SPCO ? |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | ) |
594 | 594 | ) { |
595 | 595 | /** @type EE_Transaction_Processor $transaction_processor */ |
596 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
596 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
597 | 597 | // set the start time for this reg step |
598 | - if ( ! $transaction_processor->set_reg_step_initiated( $this->transaction, $reg_step->slug() ) ) { |
|
599 | - if ( WP_DEBUG ) { |
|
598 | + if ( ! $transaction_processor->set_reg_step_initiated($this->transaction, $reg_step->slug())) { |
|
599 | + if (WP_DEBUG) { |
|
600 | 600 | EE_Error::add_error( |
601 | 601 | sprintf( |
602 | - __( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ), |
|
602 | + __('The "%1$s" registration step was not initialized properly.', 'event_espresso'), |
|
603 | 603 | $reg_step->name() |
604 | 604 | ), |
605 | 605 | __FILE__, __FUNCTION__, __LINE__ |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | * @return void |
619 | 619 | */ |
620 | 620 | public function set_reg_step_JSON_info() { |
621 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array(); |
|
621 | + EE_Registry::$i18n_js_strings['reg_steps'] = array(); |
|
622 | 622 | // pass basic reg step data to JS |
623 | - foreach ( $this->reg_steps as $reg_step ) { |
|
624 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug(); |
|
623 | + foreach ($this->reg_steps as $reg_step) { |
|
624 | + EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug(); |
|
625 | 625 | } |
626 | 626 | // reset reg step html |
627 | 627 | // $this->json_response->set_reg_step_html( '' ); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | */ |
638 | 638 | public function reset_reg_steps() { |
639 | 639 | $this->sort_reg_steps(); |
640 | - $this->set_current_step( EE_Registry::instance()->REQ->get( 'step' )); |
|
640 | + $this->set_current_step(EE_Registry::instance()->REQ->get('step')); |
|
641 | 641 | $this->set_next_step(); |
642 | 642 | // the text that appears on the reg step form submit button |
643 | 643 | $this->current_step->set_submit_button_text(); |
@@ -654,9 +654,9 @@ discard block |
||
654 | 654 | */ |
655 | 655 | public function get_registration_time_limit() { |
656 | 656 | |
657 | - $registration_time_limit = (float)( EE_Registry::instance() ->SSN->expiration() - time() ); |
|
657 | + $registration_time_limit = (float) (EE_Registry::instance() ->SSN->expiration() - time()); |
|
658 | 658 | $time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s'; |
659 | - $registration_time_limit = gmdate( $time_limit_format, $registration_time_limit ); |
|
659 | + $registration_time_limit = gmdate($time_limit_format, $registration_time_limit); |
|
660 | 660 | return apply_filters( |
661 | 661 | 'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit', |
662 | 662 | $registration_time_limit |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | // overpaid TXN |
677 | 677 | // free TXN ( total = 0.00 ) |
678 | 678 | // then payment required is TRUE |
679 | - return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE; |
|
679 | + return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | * @param EE_Transaction $transaction |
689 | 689 | * @return EE_Cart |
690 | 690 | */ |
691 | - public function get_cart_for_transaction( $transaction ) { |
|
692 | - $session = EE_Registry::instance()->load_core( 'Session' ); |
|
693 | - $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction, $session ) : null; |
|
691 | + public function get_cart_for_transaction($transaction) { |
|
692 | + $session = EE_Registry::instance()->load_core('Session'); |
|
693 | + $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null; |
|
694 | 694 | // verify cart |
695 | - if ( ! $cart instanceof EE_Cart ) { |
|
696 | - $cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
695 | + if ( ! $cart instanceof EE_Cart) { |
|
696 | + $cart = EE_Registry::instance()->load_core('Cart'); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | return $cart; |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function initialize_txn_reg_steps_array() { |
711 | 711 | $txn_reg_steps_array = array(); |
712 | - foreach ( $this->reg_steps as $reg_step ) { |
|
713 | - $txn_reg_steps_array[ $reg_step->slug() ] = FALSE; |
|
712 | + foreach ($this->reg_steps as $reg_step) { |
|
713 | + $txn_reg_steps_array[$reg_step->slug()] = FALSE; |
|
714 | 714 | } |
715 | 715 | return $txn_reg_steps_array; |
716 | 716 | } |
@@ -727,15 +727,15 @@ discard block |
||
727 | 727 | public function update_txn_reg_steps_array() { |
728 | 728 | $updated = false; |
729 | 729 | /** @type EE_Transaction_Processor $transaction_processor */ |
730 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
731 | - foreach ( $this->reg_steps as $reg_step ) { |
|
732 | - if ( $reg_step->completed() ) { |
|
733 | - $updated = $transaction_processor->set_reg_step_completed( $this->transaction, $reg_step->slug() ) |
|
730 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
731 | + foreach ($this->reg_steps as $reg_step) { |
|
732 | + if ($reg_step->completed()) { |
|
733 | + $updated = $transaction_processor->set_reg_step_completed($this->transaction, $reg_step->slug()) |
|
734 | 734 | ? true |
735 | 735 | : $updated; |
736 | 736 | } |
737 | 737 | } |
738 | - if ( $updated ) { |
|
738 | + if ($updated) { |
|
739 | 739 | $this->transaction->save(); |
740 | 740 | } |
741 | 741 | return $updated; |
@@ -751,14 +751,14 @@ discard block |
||
751 | 751 | * @throws \EE_Error |
752 | 752 | */ |
753 | 753 | public function stash_transaction_and_checkout() { |
754 | - if ( ! $this->revisit ) { |
|
754 | + if ( ! $this->revisit) { |
|
755 | 755 | $this->update_txn_reg_steps_array(); |
756 | 756 | } |
757 | 757 | $this->track_transaction_and_registration_status_updates(); |
758 | 758 | // save all data to the db, but suppress errors |
759 | 759 | //$this->save_all_data( FALSE ); |
760 | 760 | // cache the checkout in the session |
761 | - EE_Registry::instance()->SSN->set_checkout( $this ); |
|
761 | + EE_Registry::instance()->SSN->set_checkout($this); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -773,21 +773,21 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public function track_transaction_and_registration_status_updates() { |
775 | 775 | // verify the transaction |
776 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
776 | + if ($this->transaction instanceof EE_Transaction) { |
|
777 | 777 | /** @type EE_Transaction_Payments $transaction_payments */ |
778 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
778 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
779 | 779 | /** @type EE_Transaction_Processor $transaction_processor */ |
780 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
780 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
781 | 781 | // has there been a TXN status change during this checkout? |
782 | - if ( $transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated() ) { |
|
782 | + if ($transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated()) { |
|
783 | 783 | $this->txn_status_updated = true; |
784 | 784 | } |
785 | 785 | /** @type EE_Registration_Processor $registration_processor */ |
786 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
786 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
787 | 787 | // grab the saved registrations from the transaction |
788 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
789 | - if ( $registration_processor->reg_status_updated( $registration->ID() ) ) { |
|
790 | - $this->set_reg_status_updated( $registration->ID(), true ); |
|
788 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
789 | + if ($registration_processor->reg_status_updated($registration->ID())) { |
|
790 | + $this->set_reg_status_updated($registration->ID(), true); |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 | } |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | * @return bool |
809 | 809 | * @throws \EE_Error |
810 | 810 | */ |
811 | - public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
|
811 | + public function visit_allows_processing_of_this_registration(EE_Registration $registration) { |
|
812 | 812 | return ! $this->revisit |
813 | 813 | || $this->primary_revisit |
814 | 814 | || ( |
@@ -841,18 +841,18 @@ discard block |
||
841 | 841 | * @return bool |
842 | 842 | * @throws \EE_Error |
843 | 843 | */ |
844 | - public function save_all_data( $show_errors = TRUE ) { |
|
844 | + public function save_all_data($show_errors = TRUE) { |
|
845 | 845 | // verify the transaction |
846 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
846 | + if ($this->transaction instanceof EE_Transaction) { |
|
847 | 847 | // save to ensure that TXN has ID |
848 | 848 | $this->transaction->save(); |
849 | 849 | // grab the saved registrations from the transaction |
850 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
851 | - $this->_save_registration( $registration, $show_errors ); |
|
850 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
851 | + $this->_save_registration($registration, $show_errors); |
|
852 | 852 | } |
853 | 853 | } else { |
854 | - if ( $show_errors ) { |
|
855 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
854 | + if ($show_errors) { |
|
855 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
856 | 856 | } |
857 | 857 | return FALSE; |
858 | 858 | } |
@@ -869,32 +869,32 @@ discard block |
||
869 | 869 | * @return void |
870 | 870 | * @throws \EE_Error |
871 | 871 | */ |
872 | - private function _save_registration( $registration, $show_errors = TRUE ) { |
|
872 | + private function _save_registration($registration, $show_errors = TRUE) { |
|
873 | 873 | // verify object |
874 | - if ( $registration instanceof EE_Registration ) { |
|
874 | + if ($registration instanceof EE_Registration) { |
|
875 | 875 | // should this registration be processed during this visit ? |
876 | - if ( $this->visit_allows_processing_of_this_registration( $registration ) ) { |
|
876 | + if ($this->visit_allows_processing_of_this_registration($registration)) { |
|
877 | 877 | //set TXN ID |
878 | - if ( ! $registration->transaction_ID() ) { |
|
879 | - $registration->set_transaction_id( $this->transaction->ID() ); |
|
878 | + if ( ! $registration->transaction_ID()) { |
|
879 | + $registration->set_transaction_id($this->transaction->ID()); |
|
880 | 880 | } |
881 | 881 | // verify and save the attendee |
882 | - $this->_save_registration_attendee( $registration, $show_errors ); |
|
882 | + $this->_save_registration_attendee($registration, $show_errors); |
|
883 | 883 | // save answers to reg form questions |
884 | - $this->_save_registration_answers( $registration, $show_errors ); |
|
884 | + $this->_save_registration_answers($registration, $show_errors); |
|
885 | 885 | // save changes |
886 | 886 | $registration->save(); |
887 | 887 | // update txn cache |
888 | - if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) { |
|
889 | - if ( $show_errors ) { |
|
890 | - EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
888 | + if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) { |
|
889 | + if ($show_errors) { |
|
890 | + EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | } |
894 | 894 | } else { |
895 | - if ( $show_errors ) { |
|
895 | + if ($show_errors) { |
|
896 | 896 | EE_Error::add_error( |
897 | - __( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
897 | + __('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
898 | 898 | __FILE__, __FUNCTION__, __LINE__ |
899 | 899 | ); |
900 | 900 | } |
@@ -911,25 +911,25 @@ discard block |
||
911 | 911 | * @return void |
912 | 912 | * @throws \EE_Error |
913 | 913 | */ |
914 | - private function _save_registration_attendee( $registration, $show_errors = TRUE ) { |
|
915 | - if ( $registration->attendee() instanceof EE_Attendee ) { |
|
914 | + private function _save_registration_attendee($registration, $show_errors = TRUE) { |
|
915 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
916 | 916 | // save so that ATT has ID |
917 | 917 | $registration->attendee()->save(); |
918 | - if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() ) ) { |
|
919 | - if ( $show_errors ) { |
|
918 | + if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) { |
|
919 | + if ($show_errors) { |
|
920 | 920 | EE_Error::add_error( |
921 | - __( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ), |
|
921 | + __('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'), |
|
922 | 922 | __FILE__, __FUNCTION__, __LINE__ |
923 | 923 | ); |
924 | 924 | } |
925 | 925 | } |
926 | 926 | } else { |
927 | - if ( $show_errors ) { |
|
927 | + if ($show_errors) { |
|
928 | 928 | EE_Error::add_error( |
929 | 929 | sprintf( |
930 | 930 | '%1$s||%1$s $attendee = %2$s', |
931 | - __( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
932 | - var_export( $registration->attendee(), true ) |
|
931 | + __('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
932 | + var_export($registration->attendee(), true) |
|
933 | 933 | ), |
934 | 934 | __FILE__, __FUNCTION__, __LINE__ |
935 | 935 | ); |
@@ -947,25 +947,25 @@ discard block |
||
947 | 947 | * @return void |
948 | 948 | * @throws \EE_Error |
949 | 949 | */ |
950 | - private function _save_registration_answers( $registration, $show_errors = TRUE ) { |
|
950 | + private function _save_registration_answers($registration, $show_errors = TRUE) { |
|
951 | 951 | // now save the answers |
952 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
952 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
953 | 953 | // verify object |
954 | - if ( $answer instanceof EE_Answer ) { |
|
955 | - $answer->set_registration( $registration->ID() ); |
|
954 | + if ($answer instanceof EE_Answer) { |
|
955 | + $answer->set_registration($registration->ID()); |
|
956 | 956 | $answer->save(); |
957 | - if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) { |
|
958 | - if ( $show_errors ) { |
|
957 | + if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) { |
|
958 | + if ($show_errors) { |
|
959 | 959 | EE_Error::add_error( |
960 | - __( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ), |
|
960 | + __('The newly saved Answer object could not be cached on the registration.', 'event_espresso'), |
|
961 | 961 | __FILE__, __FUNCTION__, __LINE__ |
962 | 962 | ); |
963 | 963 | } |
964 | 964 | } |
965 | 965 | } else { |
966 | - if ( $show_errors ) { |
|
966 | + if ($show_errors) { |
|
967 | 967 | EE_Error::add_error( |
968 | - __( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
968 | + __('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
969 | 969 | __FILE__, __FUNCTION__, __LINE__ |
970 | 970 | ); |
971 | 971 | } |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @return bool |
985 | 985 | * @throws \EE_Error |
986 | 986 | */ |
987 | - public function refresh_all_entities( $from_db = false ) { |
|
987 | + public function refresh_all_entities($from_db = false) { |
|
988 | 988 | $from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response' |
989 | 989 | ? true |
990 | 990 | : $from_db; |
@@ -1008,11 +1008,11 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | protected function refresh_from_db() { |
1010 | 1010 | // verify the transaction |
1011 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1011 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1012 | 1012 | // pull fresh TXN data from the db |
1013 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() ); |
|
1013 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID()); |
|
1014 | 1014 | // update EE_Checkout's cached primary_attendee object |
1015 | - $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction ); |
|
1015 | + $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction); |
|
1016 | 1016 | // update EE_Checkout's cached payment object |
1017 | 1017 | $payment = $this->transaction->last_payment(); |
1018 | 1018 | $this->payment = $payment instanceof EE_Payment ? $payment : $this->payment; |
@@ -1020,9 +1020,9 @@ discard block |
||
1020 | 1020 | $payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null; |
1021 | 1021 | $this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method; |
1022 | 1022 | //now refresh the cart, based on the TXN |
1023 | - $this->cart = $this->get_cart_for_transaction( $this->transaction ); |
|
1023 | + $this->cart = $this->get_cart_for_transaction($this->transaction); |
|
1024 | 1024 | } else { |
1025 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1025 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1026 | 1026 | return FALSE; |
1027 | 1027 | } |
1028 | 1028 | return TRUE; |
@@ -1037,21 +1037,21 @@ discard block |
||
1037 | 1037 | * @return EE_Attendee | null |
1038 | 1038 | * @throws \EE_Error |
1039 | 1039 | */ |
1040 | - protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) { |
|
1040 | + protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) { |
|
1041 | 1041 | |
1042 | 1042 | $primary_attendee_obj = null; |
1043 | 1043 | // grab the saved registrations from the transaction |
1044 | - foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) { |
|
1044 | + foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) { |
|
1045 | 1045 | // verify object |
1046 | - if ( $registration instanceof EE_Registration ) { |
|
1046 | + if ($registration instanceof EE_Registration) { |
|
1047 | 1047 | $attendee = $registration->attendee(); |
1048 | 1048 | // verify object && maybe cache primary_attendee_obj ? |
1049 | - if ( $attendee instanceof EE_Attendee&& $registration->is_primary_registrant() ) { |
|
1049 | + if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) { |
|
1050 | 1050 | $primary_attendee_obj = $attendee; |
1051 | 1051 | } |
1052 | 1052 | } else { |
1053 | 1053 | EE_Error::add_error( |
1054 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1054 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1055 | 1055 | __FILE__, __FUNCTION__, __LINE__ |
1056 | 1056 | ); |
1057 | 1057 | } |
@@ -1072,45 +1072,45 @@ discard block |
||
1072 | 1072 | */ |
1073 | 1073 | protected function refresh_entity_map() { |
1074 | 1074 | // verify the transaction |
1075 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1075 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1076 | 1076 | // never cache payment info |
1077 | - $this->transaction->clear_cache( 'Payment' ); |
|
1077 | + $this->transaction->clear_cache('Payment'); |
|
1078 | 1078 | /** @type EE_Transaction_Processor $transaction_processor */ |
1079 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1079 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1080 | 1080 | // is the Payment Options Reg Step completed ? |
1081 | - if ( $transaction_processor->reg_step_completed( $this->transaction, 'payment_options' ) ) { |
|
1081 | + if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) { |
|
1082 | 1082 | // then check for payments and update TXN accordingly |
1083 | 1083 | /** @type EE_Transaction_Payments $transaction_payments */ |
1084 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1085 | - $transaction_payments->calculate_total_payments_and_update_status( $this->transaction ); |
|
1084 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1085 | + $transaction_payments->calculate_total_payments_and_update_status($this->transaction); |
|
1086 | 1086 | } |
1087 | 1087 | // grab the saved registrations from the transaction |
1088 | 1088 | foreach ( |
1089 | - $this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration |
|
1089 | + $this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration |
|
1090 | 1090 | ) { |
1091 | - $this->_refresh_registration( $reg_cache_ID, $registration ); |
|
1091 | + $this->_refresh_registration($reg_cache_ID, $registration); |
|
1092 | 1092 | } |
1093 | 1093 | // make sure our cached TXN is added to the model entity mapper |
1094 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction ); |
|
1094 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction); |
|
1095 | 1095 | |
1096 | 1096 | } else { |
1097 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1097 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1098 | 1098 | return FALSE; |
1099 | 1099 | } |
1100 | 1100 | // verify and update the cart because inaccurate totals are not so much fun |
1101 | - if ( $this->cart instanceof EE_Cart ) { |
|
1101 | + if ($this->cart instanceof EE_Cart) { |
|
1102 | 1102 | $grand_total = $this->cart->get_grand_total(); |
1103 | - if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) { |
|
1103 | + if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) { |
|
1104 | 1104 | $grand_total->recalculate_total_including_taxes(); |
1105 | 1105 | $grand_total = $grand_total->get_model()->refresh_entity_map_with( |
1106 | 1106 | $this->cart->get_grand_total()->ID(), |
1107 | 1107 | $this->cart->get_grand_total() |
1108 | 1108 | ); |
1109 | 1109 | } |
1110 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
1111 | - $this->cart = EE_Cart::instance( $grand_total ); |
|
1110 | + if ($grand_total instanceof EE_Line_Item) { |
|
1111 | + $this->cart = EE_Cart::instance($grand_total); |
|
1112 | 1112 | } else { |
1113 | - EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1113 | + EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1114 | 1114 | return false; |
1115 | 1115 | } |
1116 | 1116 | } |
@@ -1127,19 +1127,19 @@ discard block |
||
1127 | 1127 | * @return void |
1128 | 1128 | * @throws \EE_Error |
1129 | 1129 | */ |
1130 | - protected function _refresh_registration( $reg_cache_ID, $registration ) { |
|
1130 | + protected function _refresh_registration($reg_cache_ID, $registration) { |
|
1131 | 1131 | |
1132 | 1132 | // verify object |
1133 | - if ( $registration instanceof EE_Registration ) { |
|
1133 | + if ($registration instanceof EE_Registration) { |
|
1134 | 1134 | // update the entity mapper attendee |
1135 | - $this->_refresh_registration_attendee( $registration ); |
|
1135 | + $this->_refresh_registration_attendee($registration); |
|
1136 | 1136 | // update the entity mapper answers for reg form questions |
1137 | - $this->_refresh_registration_answers( $registration ); |
|
1137 | + $this->_refresh_registration_answers($registration); |
|
1138 | 1138 | // make sure the cached registration is added to the model entity mapper |
1139 | - $registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration ); |
|
1139 | + $registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration); |
|
1140 | 1140 | } else { |
1141 | 1141 | EE_Error::add_error( |
1142 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1142 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1143 | 1143 | __FILE__, __FUNCTION__, __LINE__ |
1144 | 1144 | ); |
1145 | 1145 | } |
@@ -1154,15 +1154,15 @@ discard block |
||
1154 | 1154 | * @return void |
1155 | 1155 | * @throws \EE_Error |
1156 | 1156 | */ |
1157 | - protected function _refresh_registration_attendee( $registration ) { |
|
1157 | + protected function _refresh_registration_attendee($registration) { |
|
1158 | 1158 | |
1159 | 1159 | $attendee = $registration->attendee(); |
1160 | 1160 | // verify object |
1161 | - if ( $attendee instanceof EE_Attendee && $attendee->ID() ) { |
|
1161 | + if ($attendee instanceof EE_Attendee && $attendee->ID()) { |
|
1162 | 1162 | // make sure the cached attendee is added to the model entity mapper |
1163 | - $registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee ); |
|
1163 | + $registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee); |
|
1164 | 1164 | // maybe cache primary_attendee_obj ? |
1165 | - if ( $registration->is_primary_registrant() ) { |
|
1165 | + if ($registration->is_primary_registrant()) { |
|
1166 | 1166 | $this->primary_attendee_obj = $attendee; |
1167 | 1167 | } |
1168 | 1168 | } |
@@ -1177,19 +1177,19 @@ discard block |
||
1177 | 1177 | * @return void |
1178 | 1178 | * @throws \EE_Error |
1179 | 1179 | */ |
1180 | - protected function _refresh_registration_answers( $registration ) { |
|
1180 | + protected function _refresh_registration_answers($registration) { |
|
1181 | 1181 | |
1182 | 1182 | // now update the answers |
1183 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
1183 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
1184 | 1184 | // verify object |
1185 | - if ( $answer instanceof EE_Answer ) { |
|
1186 | - if ( $answer->ID() ) { |
|
1185 | + if ($answer instanceof EE_Answer) { |
|
1186 | + if ($answer->ID()) { |
|
1187 | 1187 | // make sure the cached answer is added to the model entity mapper |
1188 | - $answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer ); |
|
1188 | + $answer->get_model()->refresh_entity_map_with($answer->ID(), $answer); |
|
1189 | 1189 | } |
1190 | 1190 | } else { |
1191 | 1191 | EE_Error::add_error( |
1192 | - __( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1192 | + __('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1193 | 1193 | __FILE__, __FUNCTION__, __LINE__ |
1194 | 1194 | ); |
1195 | 1195 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object |
1205 | 1205 | */ |
1206 | 1206 | public function __wakeup() { |
1207 | - foreach ( $this->reg_steps as $reg_step ) { |
|
1207 | + foreach ($this->reg_steps as $reg_step) { |
|
1208 | 1208 | $reg_step->checkout = $this; |
1209 | 1209 | } |
1210 | 1210 | } |
@@ -1221,12 +1221,12 @@ discard block |
||
1221 | 1221 | * @param bool $display_request |
1222 | 1222 | * @throws \EE_Error |
1223 | 1223 | */ |
1224 | - public function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) { |
|
1224 | + public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) { |
|
1225 | 1225 | $disabled = true; |
1226 | - if ( WP_DEBUG && ! $disabled ) { |
|
1227 | - $debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() ); |
|
1226 | + if (WP_DEBUG && ! $disabled) { |
|
1227 | + $debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array()); |
|
1228 | 1228 | $default_data = array( |
1229 | - $class => $func . '() : ' . $line, |
|
1229 | + $class => $func.'() : '.$line, |
|
1230 | 1230 | 'request->step' => $this->step, |
1231 | 1231 | 'request->action' => $this->action, |
1232 | 1232 | 'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ? |
@@ -1238,24 +1238,24 @@ discard block |
||
1238 | 1238 | 'reg_url_link' => $this->reg_url_link, |
1239 | 1239 | 'REQ' => $display_request ? $_REQUEST : '', |
1240 | 1240 | ); |
1241 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
1242 | - $default_data[ 'TXN_status' ] = $this->transaction->status_ID(); |
|
1243 | - $default_data[ 'TXN_reg_steps' ] = $this->transaction->reg_steps(); |
|
1244 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) { |
|
1245 | - $default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID(); |
|
1241 | + if ($this->transaction instanceof EE_Transaction) { |
|
1242 | + $default_data['TXN_status'] = $this->transaction->status_ID(); |
|
1243 | + $default_data['TXN_reg_steps'] = $this->transaction->reg_steps(); |
|
1244 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) { |
|
1245 | + $default_data['registrations'][$REG_ID] = $registration->status_ID(); |
|
1246 | 1246 | } |
1247 | - if ( $this->transaction->ID() ) { |
|
1248 | - $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID(); |
|
1247 | + if ($this->transaction->ID()) { |
|
1248 | + $TXN_ID = 'EE_Transaction: '.$this->transaction->ID(); |
|
1249 | 1249 | // don't serialize objects |
1250 | - $info = $this->_strip_objects( $info ); |
|
1251 | - if ( ! isset( $debug_data[ $TXN_ID ] ) ) { |
|
1252 | - $debug_data[ $TXN_ID ] = array(); |
|
1250 | + $info = $this->_strip_objects($info); |
|
1251 | + if ( ! isset($debug_data[$TXN_ID])) { |
|
1252 | + $debug_data[$TXN_ID] = array(); |
|
1253 | 1253 | } |
1254 | - $debug_data[ $TXN_ID ][ microtime() ] = array_merge( |
|
1254 | + $debug_data[$TXN_ID][microtime()] = array_merge( |
|
1255 | 1255 | $default_data, |
1256 | 1256 | $info |
1257 | 1257 | ); |
1258 | - update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data ); |
|
1258 | + update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data); |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | } |
@@ -1268,23 +1268,23 @@ discard block |
||
1268 | 1268 | * @param array $info |
1269 | 1269 | * @return array |
1270 | 1270 | */ |
1271 | - public function _strip_objects( $info = array() ) { |
|
1272 | - foreach ( (array)$info as $key => $value ) { |
|
1273 | - if ( is_array( $value )) { |
|
1274 | - $info[ $key ] = $this->_strip_objects( $value ); |
|
1275 | - } else if ( is_object( $value ) ) { |
|
1276 | - $object_class = get_class( $value ); |
|
1277 | - $info[ $object_class ] = array(); |
|
1278 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0; |
|
1279 | - if ( method_exists( $value, 'status' ) ) { |
|
1280 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
1281 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
1282 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
1271 | + public function _strip_objects($info = array()) { |
|
1272 | + foreach ((array) $info as $key => $value) { |
|
1273 | + if (is_array($value)) { |
|
1274 | + $info[$key] = $this->_strip_objects($value); |
|
1275 | + } else if (is_object($value)) { |
|
1276 | + $object_class = get_class($value); |
|
1277 | + $info[$object_class] = array(); |
|
1278 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0; |
|
1279 | + if (method_exists($value, 'status')) { |
|
1280 | + $info[$object_class]['status'] = $value->status(); |
|
1281 | + } else if (method_exists($value, 'status_ID')) { |
|
1282 | + $info[$object_class]['status'] = $value->status_ID(); |
|
1283 | 1283 | } |
1284 | - unset( $info[ $key ] ); |
|
1284 | + unset($info[$key]); |
|
1285 | 1285 | } |
1286 | 1286 | } |
1287 | - return (array)$info; |
|
1287 | + return (array) $info; |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 |
@@ -817,12 +817,12 @@ |
||
817 | 817 | if ( $registration instanceof EE_Registration ) { |
818 | 818 | // we display all attendee info for the primary registrant |
819 | 819 | if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
820 | - && $registration->is_primary_registrant() |
|
820 | + && $registration->is_primary_registrant() |
|
821 | 821 | ) { |
822 | 822 | $this->checkout->primary_revisit = true; |
823 | 823 | break; |
824 | 824 | } else if ( $this->checkout->revisit |
825 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
825 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
826 | 826 | ) { |
827 | 827 | // but hide info if it doesn't belong to you |
828 | 828 | $transaction->clear_cache( 'Registration', $registration->ID() ); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Single Page Checkout (SPCO) |
4 | 4 | * |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @return EED_Single_Page_Checkout |
48 | 48 | */ |
49 | 49 | public static function instance() { |
50 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
51 | - return parent::get_instance( __CLASS__ ); |
|
50 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
51 | + return parent::get_instance(__CLASS__); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -93,22 +93,22 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public static function set_hooks_admin() { |
95 | 95 | EED_Single_Page_Checkout::set_definitions(); |
96 | - if ( defined( 'DOING_AJAX' )) { |
|
96 | + if (defined('DOING_AJAX')) { |
|
97 | 97 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
98 | 98 | ob_start(); |
99 | 99 | EED_Single_Page_Checkout::load_request_handler(); |
100 | 100 | EED_Single_Page_Checkout::load_reg_steps(); |
101 | 101 | } else { |
102 | 102 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
103 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
103 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
104 | 104 | } |
105 | 105 | // set ajax hooks |
106 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
107 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
108 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
109 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
110 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
111 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
106 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
107 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
108 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
109 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
110 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
111 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param string $ajax_action |
120 | 120 | * @throws \EE_Error |
121 | 121 | */ |
122 | - public static function process_ajax_request( $ajax_action ) { |
|
123 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
122 | + public static function process_ajax_request($ajax_action) { |
|
123 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
124 | 124 | EED_Single_Page_Checkout::instance()->_initialize(); |
125 | 125 | } |
126 | 126 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @throws \EE_Error |
133 | 133 | */ |
134 | 134 | public static function display_reg_step() { |
135 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
135 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @throws \EE_Error |
144 | 144 | */ |
145 | 145 | public static function process_reg_step() { |
146 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
146 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @throws \EE_Error |
155 | 155 | */ |
156 | 156 | public static function update_reg_step() { |
157 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
157 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @throws \EE_Error |
168 | 168 | */ |
169 | 169 | public static function update_checkout() { |
170 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
170 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public static function load_request_handler() { |
182 | 182 | // load core Request_Handler class |
183 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
184 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
183 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
184 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | * @throws \EE_Error |
196 | 196 | */ |
197 | 197 | public static function set_definitions() { |
198 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
199 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
200 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
201 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
202 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
203 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
204 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
205 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
198 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
199 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
200 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
201 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
202 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
203 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
204 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
205 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public static function load_reg_steps() { |
219 | 219 | static $reg_steps_loaded = FALSE; |
220 | - if ( $reg_steps_loaded ) { |
|
220 | + if ($reg_steps_loaded) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | 223 | // filter list of reg_steps |
@@ -226,24 +226,24 @@ discard block |
||
226 | 226 | EED_Single_Page_Checkout::get_reg_steps() |
227 | 227 | ); |
228 | 228 | // sort by key (order) |
229 | - ksort( $reg_steps_to_load ); |
|
229 | + ksort($reg_steps_to_load); |
|
230 | 230 | // loop through folders |
231 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
231 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
232 | 232 | // we need a |
233 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
233 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
234 | 234 | // copy over to the reg_steps_array |
235 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
235 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
236 | 236 | // register custom key route for each reg step |
237 | 237 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
238 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
238 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
239 | 239 | // add AJAX or other hooks |
240 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
240 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
241 | 241 | // setup autoloaders if necessary |
242 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
243 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
242 | + if ( ! class_exists($reg_step['class_name'])) { |
|
243 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
244 | 244 | } |
245 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
246 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
245 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
246 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
@@ -262,28 +262,28 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function get_reg_steps() { |
264 | 264 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
265 | - if ( empty( $reg_steps )) { |
|
265 | + if (empty($reg_steps)) { |
|
266 | 266 | $reg_steps = array( |
267 | 267 | 10 => array( |
268 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
268 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
269 | 269 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
270 | 270 | 'slug' => 'attendee_information', |
271 | 271 | 'has_hooks' => FALSE |
272 | 272 | ), |
273 | 273 | 20 => array( |
274 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
274 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
275 | 275 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
276 | 276 | 'slug' => 'registration_confirmation', |
277 | 277 | 'has_hooks' => FALSE |
278 | 278 | ), |
279 | 279 | 30 => array( |
280 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
280 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
281 | 281 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
282 | 282 | 'slug' => 'payment_options', |
283 | 283 | 'has_hooks' => TRUE |
284 | 284 | ), |
285 | 285 | 999 => array( |
286 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
286 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
287 | 287 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
288 | 288 | 'slug' => 'finalize_registration', |
289 | 289 | 'has_hooks' => FALSE |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public static function registration_checkout_for_admin() { |
306 | 306 | EED_Single_Page_Checkout::load_reg_steps(); |
307 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
308 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
309 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
307 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
308 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
309 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
310 | 310 | EED_Single_Page_Checkout::instance()->_initialize(); |
311 | 311 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
312 | 312 | return EE_Registry::instance()->REQ->get_output(); |
@@ -323,15 +323,15 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public static function process_registration_from_admin() { |
325 | 325 | EED_Single_Page_Checkout::load_reg_steps(); |
326 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
327 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
328 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
326 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
327 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
328 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
329 | 329 | EED_Single_Page_Checkout::instance()->_initialize(); |
330 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
331 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
332 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
333 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
334 | - if ( $final_reg_step->process_reg_step() ) { |
|
330 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
331 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
332 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
333 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
334 | + if ($final_reg_step->process_reg_step()) { |
|
335 | 335 | $final_reg_step->set_completed(); |
336 | 336 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
337 | 337 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | * @return void |
352 | 352 | * @throws \EE_Error |
353 | 353 | */ |
354 | - public function run( $WP_Query ) { |
|
354 | + public function run($WP_Query) { |
|
355 | 355 | if ( |
356 | 356 | $WP_Query instanceof WP_Query |
357 | 357 | && $WP_Query->is_main_query() |
358 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
358 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
359 | 359 | ) { |
360 | 360 | $this->_initialize(); |
361 | 361 | } |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @return void |
372 | 372 | * @throws \EE_Error |
373 | 373 | */ |
374 | - public static function init( $WP_Query ) { |
|
375 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
374 | + public static function init($WP_Query) { |
|
375 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -386,34 +386,34 @@ discard block |
||
386 | 386 | */ |
387 | 387 | private function _initialize() { |
388 | 388 | // ensure SPCO doesn't run twice |
389 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
389 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
390 | 390 | return; |
391 | 391 | } |
392 | 392 | try { |
393 | 393 | // setup the EE_Checkout object |
394 | 394 | $this->checkout = $this->_initialize_checkout(); |
395 | 395 | // filter checkout |
396 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
396 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
397 | 397 | // get the $_GET |
398 | 398 | $this->_get_request_vars(); |
399 | 399 | // filter continue_reg |
400 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
400 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
401 | 401 | // load the reg steps array |
402 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
402 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
403 | 403 | EED_Single_Page_Checkout::$_initialized = true; |
404 | 404 | return; |
405 | 405 | } |
406 | 406 | // set the current step |
407 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
407 | + $this->checkout->set_current_step($this->checkout->step); |
|
408 | 408 | // and the next step |
409 | 409 | $this->checkout->set_next_step(); |
410 | 410 | // was there already a valid transaction in the checkout from the session ? |
411 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
411 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
412 | 412 | // get transaction from db or session |
413 | 413 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
414 | 414 | ? $this->_get_transaction_and_cart_for_previous_visit() |
415 | 415 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
416 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
416 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
417 | 417 | // add some style and make it dance |
418 | 418 | $this->checkout->transaction = EE_Transaction::new_instance(); |
419 | 419 | $this->add_styles_and_scripts(); |
@@ -421,10 +421,10 @@ discard block |
||
421 | 421 | return; |
422 | 422 | } |
423 | 423 | // and the registrations for the transaction |
424 | - $this->_get_registrations( $this->checkout->transaction ); |
|
424 | + $this->_get_registrations($this->checkout->transaction); |
|
425 | 425 | } |
426 | 426 | // verify that everything has been setup correctly |
427 | - if ( ! $this->_final_verifications() ) { |
|
427 | + if ( ! $this->_final_verifications()) { |
|
428 | 428 | EED_Single_Page_Checkout::$_initialized = true; |
429 | 429 | return; |
430 | 430 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | // set no cache headers and constants |
450 | 450 | EE_System::do_not_cache(); |
451 | 451 | // add anchor |
452 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
453 | - } catch ( Exception $e ) { |
|
454 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
452 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
453 | + } catch (Exception $e) { |
|
454 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -469,20 +469,20 @@ discard block |
||
469 | 469 | // look in session for existing checkout |
470 | 470 | $checkout = EE_Registry::instance()->SSN->checkout(); |
471 | 471 | // verify |
472 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
472 | + if ( ! $checkout instanceof EE_Checkout) { |
|
473 | 473 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
474 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
474 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
475 | 475 | } else { |
476 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
476 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
477 | 477 | $this->unlock_transaction(); |
478 | - wp_safe_redirect( $checkout->redirect_url ); |
|
478 | + wp_safe_redirect($checkout->redirect_url); |
|
479 | 479 | exit(); |
480 | 480 | } |
481 | 481 | } |
482 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
482 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
483 | 483 | // verify again |
484 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
485 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
484 | + if ( ! $checkout instanceof EE_Checkout) { |
|
485 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
486 | 486 | } |
487 | 487 | // reset anything that needs a clean slate for each request |
488 | 488 | $checkout->reset_for_current_request(); |
@@ -502,24 +502,24 @@ discard block |
||
502 | 502 | // load classes |
503 | 503 | EED_Single_Page_Checkout::load_request_handler(); |
504 | 504 | //make sure this request is marked as belonging to EE |
505 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
505 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
506 | 506 | // which step is being requested ? |
507 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
507 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
508 | 508 | // which step is being edited ? |
509 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
509 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
510 | 510 | // and what we're doing on the current step |
511 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
511 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
512 | 512 | // returning to edit ? |
513 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
513 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
514 | 514 | // or some other kind of revisit ? |
515 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
515 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
516 | 516 | // and whether or not to generate a reg form for this request |
517 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
517 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
518 | 518 | // and whether or not to process a reg form submission for this request |
519 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
519 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
520 | 520 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
521 | 521 | ? $this->checkout->process_form_submission |
522 | - : FALSE; // TRUE FALSE |
|
522 | + : FALSE; // TRUE FALSE |
|
523 | 523 | // $this->_display_request_vars(); |
524 | 524 | } |
525 | 525 | |
@@ -532,17 +532,17 @@ discard block |
||
532 | 532 | * @return void |
533 | 533 | */ |
534 | 534 | protected function _display_request_vars() { |
535 | - if ( ! WP_DEBUG ) { |
|
535 | + if ( ! WP_DEBUG) { |
|
536 | 536 | return; |
537 | 537 | } |
538 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
539 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
540 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
541 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
542 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
543 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
544 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
545 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
538 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
539 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
540 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
541 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
542 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
543 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
544 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
545 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | * @return array |
557 | 557 | */ |
558 | 558 | private function _get_first_step() { |
559 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
560 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
559 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
560 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -573,27 +573,27 @@ discard block |
||
573 | 573 | private function _load_and_instantiate_reg_steps() { |
574 | 574 | // have reg_steps already been instantiated ? |
575 | 575 | if ( |
576 | - empty( $this->checkout->reg_steps ) || |
|
577 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
576 | + empty($this->checkout->reg_steps) || |
|
577 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
578 | 578 | ) { |
579 | 579 | // if not, then loop through raw reg steps array |
580 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
581 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
580 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
581 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
582 | 582 | return false; |
583 | 583 | } |
584 | 584 | } |
585 | 585 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
586 | 586 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
587 | 587 | // skip the registration_confirmation page ? |
588 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
588 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
589 | 589 | // just remove it from the reg steps array |
590 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
590 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
591 | 591 | } else if ( |
592 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
592 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
593 | 593 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
594 | 594 | ) { |
595 | 595 | // set the order to something big like 100 |
596 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
596 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
597 | 597 | } |
598 | 598 | // filter the array for good luck |
599 | 599 | $this->checkout->reg_steps = apply_filters( |
@@ -603,13 +603,13 @@ discard block |
||
603 | 603 | // finally re-sort based on the reg step class order properties |
604 | 604 | $this->checkout->sort_reg_steps(); |
605 | 605 | } else { |
606 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
606 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
607 | 607 | // set all current step stati to FALSE |
608 | - $reg_step->set_is_current_step( FALSE ); |
|
608 | + $reg_step->set_is_current_step(FALSE); |
|
609 | 609 | } |
610 | 610 | } |
611 | - if ( empty( $this->checkout->reg_steps )) { |
|
612 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
611 | + if (empty($this->checkout->reg_steps)) { |
|
612 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
613 | 613 | return false; |
614 | 614 | } |
615 | 615 | // make reg step details available to JS |
@@ -627,10 +627,10 @@ discard block |
||
627 | 627 | * @param int $order |
628 | 628 | * @return bool |
629 | 629 | */ |
630 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
630 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
631 | 631 | |
632 | 632 | // we need a file_path, class_name, and slug to add a reg step |
633 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
633 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
634 | 634 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
635 | 635 | if ( |
636 | 636 | $this->checkout->reg_url_link |
@@ -648,26 +648,26 @@ discard block |
||
648 | 648 | FALSE |
649 | 649 | ); |
650 | 650 | // did we gets the goods ? |
651 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
651 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
652 | 652 | // set reg step order based on config |
653 | - $reg_step_obj->set_order( $order ); |
|
653 | + $reg_step_obj->set_order($order); |
|
654 | 654 | // add instantiated reg step object to the master reg steps array |
655 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
655 | + $this->checkout->add_reg_step($reg_step_obj); |
|
656 | 656 | } else { |
657 | 657 | EE_Error::add_error( |
658 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
658 | + __('The current step could not be set.', 'event_espresso'), |
|
659 | 659 | __FILE__, __FUNCTION__, __LINE__ |
660 | 660 | ); |
661 | 661 | return false; |
662 | 662 | } |
663 | 663 | } else { |
664 | - if ( WP_DEBUG ) { |
|
664 | + if (WP_DEBUG) { |
|
665 | 665 | EE_Error::add_error( |
666 | 666 | sprintf( |
667 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
668 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
669 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
670 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
667 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
668 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
669 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
670 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
671 | 671 | '<ul>', |
672 | 672 | '<li>', |
673 | 673 | '</li>', |
@@ -691,16 +691,16 @@ discard block |
||
691 | 691 | */ |
692 | 692 | private function _get_transaction_and_cart_for_previous_visit() { |
693 | 693 | /** @var $TXN_model EEM_Transaction */ |
694 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
694 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
695 | 695 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
696 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
696 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
697 | 697 | // verify transaction |
698 | - if ( $transaction instanceof EE_Transaction ) { |
|
698 | + if ($transaction instanceof EE_Transaction) { |
|
699 | 699 | // and get the cart that was used for that transaction |
700 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
700 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
701 | 701 | return $transaction; |
702 | 702 | } else { |
703 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
703 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
704 | 704 | return NULL; |
705 | 705 | } |
706 | 706 | } |
@@ -714,8 +714,8 @@ discard block |
||
714 | 714 | * @param EE_Transaction $transaction |
715 | 715 | * @return EE_Cart |
716 | 716 | */ |
717 | - private function _get_cart_for_transaction( $transaction ) { |
|
718 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
717 | + private function _get_cart_for_transaction($transaction) { |
|
718 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | * @param EE_Transaction $transaction |
728 | 728 | * @return EE_Cart |
729 | 729 | */ |
730 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
731 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
730 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
731 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | |
@@ -744,17 +744,17 @@ discard block |
||
744 | 744 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
745 | 745 | // if there's no transaction, then this is the FIRST visit to SPCO |
746 | 746 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
747 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
747 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
748 | 748 | // and then create a new transaction |
749 | 749 | $transaction = $this->_initialize_transaction(); |
750 | 750 | // verify transaction |
751 | - if ( $transaction instanceof EE_Transaction ) { |
|
751 | + if ($transaction instanceof EE_Transaction) { |
|
752 | 752 | // save it so that we have an ID for other objects to use |
753 | 753 | $transaction->save(); |
754 | 754 | // and save TXN data to the cart |
755 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
755 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
756 | 756 | } else { |
757 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
757 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
758 | 758 | } |
759 | 759 | return $transaction; |
760 | 760 | } |
@@ -774,15 +774,15 @@ discard block |
||
774 | 774 | // grab the cart grand total |
775 | 775 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
776 | 776 | // create new TXN |
777 | - return EE_Transaction::new_instance( array( |
|
777 | + return EE_Transaction::new_instance(array( |
|
778 | 778 | 'TXN_timestamp' => time(), |
779 | 779 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
780 | 780 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
781 | 781 | 'TXN_paid' => 0, |
782 | 782 | 'STS_ID' => EEM_Transaction::failed_status_code, |
783 | 783 | )); |
784 | - } catch( Exception $e ) { |
|
785 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
784 | + } catch (Exception $e) { |
|
785 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
786 | 786 | } |
787 | 787 | return NULL; |
788 | 788 | } |
@@ -797,38 +797,38 @@ discard block |
||
797 | 797 | * @return EE_Cart |
798 | 798 | * @throws \EE_Error |
799 | 799 | */ |
800 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
800 | + private function _get_registrations(EE_Transaction $transaction) { |
|
801 | 801 | // first step: grab the registrants { : o |
802 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
802 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
803 | 803 | // verify registrations have been set |
804 | - if ( empty( $registrations )) { |
|
804 | + if (empty($registrations)) { |
|
805 | 805 | // if no cached registrations, then check the db |
806 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
806 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
807 | 807 | // still nothing ? well as long as this isn't a revisit |
808 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
808 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
809 | 809 | // generate new registrations from scratch |
810 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
810 | + $registrations = $this->_initialize_registrations($transaction); |
|
811 | 811 | } |
812 | 812 | } |
813 | 813 | // sort by their original registration order |
814 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
814 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
815 | 815 | // then loop thru the array |
816 | - foreach ( $registrations as $registration ) { |
|
816 | + foreach ($registrations as $registration) { |
|
817 | 817 | // verify each registration |
818 | - if ( $registration instanceof EE_Registration ) { |
|
818 | + if ($registration instanceof EE_Registration) { |
|
819 | 819 | // we display all attendee info for the primary registrant |
820 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
820 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
821 | 821 | && $registration->is_primary_registrant() |
822 | 822 | ) { |
823 | 823 | $this->checkout->primary_revisit = true; |
824 | 824 | break; |
825 | - } else if ( $this->checkout->revisit |
|
825 | + } else if ($this->checkout->revisit |
|
826 | 826 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
827 | 827 | ) { |
828 | 828 | // but hide info if it doesn't belong to you |
829 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
829 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
830 | 830 | } |
831 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
831 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | } |
@@ -843,17 +843,17 @@ discard block |
||
843 | 843 | * @return array |
844 | 844 | * @throws \EE_Error |
845 | 845 | */ |
846 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
846 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
847 | 847 | $att_nmbr = 0; |
848 | 848 | $registrations = array(); |
849 | - if ( $transaction instanceof EE_Transaction ) { |
|
849 | + if ($transaction instanceof EE_Transaction) { |
|
850 | 850 | /** @type EE_Registration_Processor $registration_processor */ |
851 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
851 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
852 | 852 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
853 | 853 | // now let's add the cart items to the $transaction |
854 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
854 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
855 | 855 | //do the following for each ticket of this type they selected |
856 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
856 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
857 | 857 | $att_nmbr++; |
858 | 858 | $registration = $registration_processor->generate_ONE_registration_from_line_item( |
859 | 859 | $line_item, |
@@ -861,12 +861,12 @@ discard block |
||
861 | 861 | $att_nmbr, |
862 | 862 | $this->checkout->total_ticket_count |
863 | 863 | ); |
864 | - if ( $registration instanceof EE_Registration ) { |
|
865 | - $registrations[ $registration->ID() ] = $registration; |
|
864 | + if ($registration instanceof EE_Registration) { |
|
865 | + $registrations[$registration->ID()] = $registration; |
|
866 | 866 | } |
867 | 867 | } |
868 | 868 | } |
869 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
869 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
870 | 870 | } |
871 | 871 | return $registrations; |
872 | 872 | } |
@@ -881,12 +881,12 @@ discard block |
||
881 | 881 | * @param EE_Registration $reg_B |
882 | 882 | * @return array() |
883 | 883 | */ |
884 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
884 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
885 | 885 | // this shouldn't ever happen within the same TXN, but oh well |
886 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
886 | + if ($reg_A->count() === $reg_B->count()) { |
|
887 | 887 | return 0; |
888 | 888 | } |
889 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
889 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
@@ -901,21 +901,21 @@ discard block |
||
901 | 901 | */ |
902 | 902 | private function _final_verifications() { |
903 | 903 | // filter checkout |
904 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
904 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
905 | 905 | //verify that current step is still set correctly |
906 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
907 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
906 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
907 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
908 | 908 | return false; |
909 | 909 | } |
910 | 910 | // if returning to SPCO, then verify that primary registrant is set |
911 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
911 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
912 | 912 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
913 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
914 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
913 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
914 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
915 | 915 | return false; |
916 | 916 | } |
917 | 917 | $valid_registrant = null; |
918 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
918 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
919 | 919 | if ( |
920 | 920 | $registration instanceof EE_Registration |
921 | 921 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -923,9 +923,9 @@ discard block |
||
923 | 923 | $valid_registrant = $registration; |
924 | 924 | } |
925 | 925 | } |
926 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
926 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
927 | 927 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
928 | - if ( EED_Single_Page_Checkout::$_checkout_verified ) { |
|
928 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
929 | 929 | // clear the session, mark the checkout as unverified, and try again |
930 | 930 | EE_Registry::instance()->SSN->clear_session(); |
931 | 931 | EED_Single_Page_Checkout::$_initialized = false; |
@@ -934,13 +934,13 @@ discard block |
||
934 | 934 | EE_Error::reset_notices(); |
935 | 935 | return false; |
936 | 936 | } |
937 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
937 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
938 | 938 | return false; |
939 | 939 | } |
940 | 940 | } |
941 | 941 | // now that things have been kinda sufficiently verified, |
942 | 942 | // let's add the checkout to the session so that's available other systems |
943 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
943 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
944 | 944 | return true; |
945 | 945 | } |
946 | 946 | |
@@ -955,28 +955,28 @@ discard block |
||
955 | 955 | * @param bool $reinitializing |
956 | 956 | * @throws \EE_Error |
957 | 957 | */ |
958 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
959 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
958 | + private function _initialize_reg_steps($reinitializing = false) { |
|
959 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
960 | 960 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
961 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
962 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
961 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
962 | + if ( ! $reg_step->initialize_reg_step()) { |
|
963 | 963 | // if not initialized then maybe this step is being removed... |
964 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
964 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
965 | 965 | // if it was the current step, then we need to start over here |
966 | - $this->_initialize_reg_steps( true ); |
|
966 | + $this->_initialize_reg_steps(true); |
|
967 | 967 | return; |
968 | 968 | } |
969 | 969 | continue; |
970 | 970 | } |
971 | 971 | // i18n |
972 | 972 | $reg_step->translate_js_strings(); |
973 | - if ( $reg_step->is_current_step() ) { |
|
973 | + if ($reg_step->is_current_step()) { |
|
974 | 974 | // the text that appears on the reg step form submit button |
975 | 975 | $reg_step->set_submit_button_text(); |
976 | 976 | } |
977 | 977 | } |
978 | 978 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
979 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
979 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | |
@@ -989,43 +989,43 @@ discard block |
||
989 | 989 | */ |
990 | 990 | private function _check_form_submission() { |
991 | 991 | //does this request require the reg form to be generated ? |
992 | - if ( $this->checkout->generate_reg_form ) { |
|
992 | + if ($this->checkout->generate_reg_form) { |
|
993 | 993 | // ever heard that song by Blue Rodeo ? |
994 | 994 | try { |
995 | 995 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
996 | 996 | // if not displaying a form, then check for form submission |
997 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
997 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
998 | 998 | // clear out any old data in case this step is being run again |
999 | - $this->checkout->current_step->set_valid_data( array() ); |
|
999 | + $this->checkout->current_step->set_valid_data(array()); |
|
1000 | 1000 | // capture submitted form data |
1001 | 1001 | $this->checkout->current_step->reg_form->receive_form_submission( |
1002 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
1002 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
1003 | 1003 | ); |
1004 | 1004 | // validate submitted form data |
1005 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
1005 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1006 | 1006 | // thou shall not pass !!! |
1007 | 1007 | $this->checkout->continue_reg = FALSE; |
1008 | 1008 | // any form validation errors? |
1009 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
1009 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1010 | 1010 | $submission_error_messages = array(); |
1011 | 1011 | // bad, bad, bad registrant |
1012 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
1013 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1012 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1013 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1014 | 1014 | $submission_error_messages[] = sprintf( |
1015 | - __( '%s : %s', 'event_espresso' ), |
|
1015 | + __('%s : %s', 'event_espresso'), |
|
1016 | 1016 | $validation_error->get_form_section()->html_label_text(), |
1017 | 1017 | $validation_error->getMessage() |
1018 | 1018 | ); |
1019 | 1019 | } |
1020 | 1020 | } |
1021 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1021 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1022 | 1022 | } |
1023 | 1023 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1024 | 1024 | $this->go_to_next_step(); |
1025 | 1025 | return; |
1026 | 1026 | } |
1027 | 1027 | } |
1028 | - } catch( EE_Error $e ) { |
|
1028 | + } catch (EE_Error $e) { |
|
1029 | 1029 | $e->get_error(); |
1030 | 1030 | } |
1031 | 1031 | } |
@@ -1042,22 +1042,22 @@ discard block |
||
1042 | 1042 | */ |
1043 | 1043 | private function _process_form_action() { |
1044 | 1044 | // what cha wanna do? |
1045 | - switch( $this->checkout->action ) { |
|
1045 | + switch ($this->checkout->action) { |
|
1046 | 1046 | // AJAX next step reg form |
1047 | 1047 | case 'display_spco_reg_step' : |
1048 | 1048 | $this->checkout->redirect = FALSE; |
1049 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1050 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1049 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1050 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1051 | 1051 | } |
1052 | 1052 | break; |
1053 | 1053 | |
1054 | 1054 | default : |
1055 | 1055 | // meh... do one of those other steps first |
1056 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1056 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1057 | 1057 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1058 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1058 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1059 | 1059 | // call action on current step |
1060 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1060 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1061 | 1061 | // good registrant, you get to proceed |
1062 | 1062 | if ( |
1063 | 1063 | $this->checkout->current_step->success_message() !== '' |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | ) { |
1069 | 1069 | EE_Error::add_success( |
1070 | 1070 | $this->checkout->current_step->success_message() |
1071 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1071 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1072 | 1072 | ); |
1073 | 1073 | |
1074 | 1074 | } |
@@ -1076,12 +1076,12 @@ discard block |
||
1076 | 1076 | $this->_setup_redirect(); |
1077 | 1077 | } |
1078 | 1078 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1079 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1079 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1080 | 1080 | |
1081 | 1081 | } else { |
1082 | 1082 | EE_Error::add_error( |
1083 | 1083 | sprintf( |
1084 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1084 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1085 | 1085 | $this->checkout->action, |
1086 | 1086 | $this->checkout->current_step->name() |
1087 | 1087 | ), |
@@ -1107,10 +1107,10 @@ discard block |
||
1107 | 1107 | public function add_styles_and_scripts() { |
1108 | 1108 | // i18n |
1109 | 1109 | $this->translate_js_strings(); |
1110 | - if ( $this->checkout->admin_request ) { |
|
1111 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1110 | + if ($this->checkout->admin_request) { |
|
1111 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1112 | 1112 | } else { |
1113 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1113 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1114 | 1114 | } |
1115 | 1115 | } |
1116 | 1116 | |
@@ -1126,42 +1126,42 @@ discard block |
||
1126 | 1126 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1127 | 1127 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1128 | 1128 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1129 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1130 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1131 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1129 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1130 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1131 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1132 | 1132 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1133 | 1133 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1134 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' ); |
|
1135 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1134 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>'); |
|
1135 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1136 | 1136 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1137 | 1137 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1138 | 1138 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1139 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1140 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1141 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1142 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1143 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1144 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1145 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1146 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1147 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1148 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1149 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1150 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1151 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1152 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1139 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1140 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1141 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1142 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1143 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1144 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1145 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1146 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1147 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1148 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1149 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1150 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1151 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1152 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1153 | 1153 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1154 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1154 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1155 | 1155 | '<h4 class="important-notice">', |
1156 | 1156 | '</h4>', |
1157 | 1157 | '<br />', |
1158 | 1158 | '<p>', |
1159 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1159 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1160 | 1160 | '">', |
1161 | 1161 | '</a>', |
1162 | 1162 | '</p>' |
1163 | 1163 | ); |
1164 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1164 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | |
@@ -1174,25 +1174,25 @@ discard block |
||
1174 | 1174 | */ |
1175 | 1175 | public function enqueue_styles_and_scripts() { |
1176 | 1176 | // load css |
1177 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1178 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1177 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1178 | + wp_enqueue_style('single_page_checkout'); |
|
1179 | 1179 | // load JS |
1180 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1181 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1182 | - wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1183 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1180 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1181 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1182 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1183 | + wp_enqueue_script('single_page_checkout'); |
|
1184 | 1184 | |
1185 | 1185 | /** |
1186 | 1186 | * global action hook for enqueueing styles and scripts with |
1187 | 1187 | * spco calls. |
1188 | 1188 | */ |
1189 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1189 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1190 | 1190 | |
1191 | 1191 | /** |
1192 | 1192 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1193 | 1193 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1194 | 1194 | */ |
1195 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1195 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1196 | 1196 | |
1197 | 1197 | // add css and JS for current step |
1198 | 1198 | $this->checkout->current_step->enqueue_styles_and_scripts(); |
@@ -1209,19 +1209,19 @@ discard block |
||
1209 | 1209 | */ |
1210 | 1210 | private function _display_spco_reg_form() { |
1211 | 1211 | // if registering via the admin, just display the reg form for the current step |
1212 | - if ( $this->checkout->admin_request ) { |
|
1213 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1212 | + if ($this->checkout->admin_request) { |
|
1213 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1214 | 1214 | } else { |
1215 | 1215 | // add powered by EE msg |
1216 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1216 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1217 | 1217 | |
1218 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1218 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1219 | 1219 | $cookies_not_set_msg = ''; |
1220 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1220 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1221 | 1221 | $cookies_not_set_msg = apply_filters( |
1222 | 1222 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1223 | 1223 | sprintf( |
1224 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1224 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1225 | 1225 | '<div class="ee-attention">', |
1226 | 1226 | '</div>', |
1227 | 1227 | '<h6 class="important-notice">', |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | 'layout_strategy' => |
1242 | 1242 | new EE_Template_Layout( |
1243 | 1243 | array( |
1244 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1244 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1245 | 1245 | 'template_args' => array( |
1246 | 1246 | 'empty_cart' => $empty_cart, |
1247 | 1247 | 'revisit' => $this->checkout->revisit, |
@@ -1250,8 +1250,8 @@ discard block |
||
1250 | 1250 | 'empty_msg' => apply_filters( |
1251 | 1251 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1252 | 1252 | sprintf( |
1253 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1254 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1253 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1254 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1255 | 1255 | '">', |
1256 | 1256 | '</a>' |
1257 | 1257 | ) |
@@ -1259,14 +1259,14 @@ discard block |
||
1259 | 1259 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
1260 | 1260 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
1261 | 1261 | 'session_expiration' => |
1262 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
1262 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
1263 | 1263 | ) |
1264 | 1264 | ) |
1265 | 1265 | ) |
1266 | 1266 | ) |
1267 | 1267 | ); |
1268 | 1268 | // load template and add to output sent that gets filtered into the_content() |
1269 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1269 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1270 | 1270 | } |
1271 | 1271 | } |
1272 | 1272 | |
@@ -1280,8 +1280,8 @@ discard block |
||
1280 | 1280 | * @internal param string $label |
1281 | 1281 | * @return string |
1282 | 1282 | */ |
1283 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1284 | - if ( $next_step === 'finalize_registration' ) { |
|
1283 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1284 | + if ($next_step === 'finalize_registration') { |
|
1285 | 1285 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1286 | 1286 | } |
1287 | 1287 | } |
@@ -1295,18 +1295,18 @@ discard block |
||
1295 | 1295 | * @return string |
1296 | 1296 | */ |
1297 | 1297 | public static function display_registration_footer() { |
1298 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1299 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1300 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
1301 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1298 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1299 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1300 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
1301 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1302 | 1302 | echo apply_filters( |
1303 | 1303 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1304 | 1304 | sprintf( |
1305 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1306 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1305 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1306 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1307 | 1307 | '" target="_blank">', |
1308 | 1308 | '</a>', |
1309 | - '<a href="' . $url . '" title="', |
|
1309 | + '<a href="'.$url.'" title="', |
|
1310 | 1310 | '" target="_blank">', |
1311 | 1311 | '</a></div>' |
1312 | 1312 | ) |
@@ -1337,12 +1337,12 @@ discard block |
||
1337 | 1337 | * @return array |
1338 | 1338 | */ |
1339 | 1339 | private function _setup_redirect() { |
1340 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1340 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1341 | 1341 | $this->checkout->redirect = TRUE; |
1342 | - if ( empty( $this->checkout->redirect_url )) { |
|
1342 | + if (empty($this->checkout->redirect_url)) { |
|
1343 | 1343 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1344 | 1344 | } |
1345 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1345 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1346 | 1346 | } |
1347 | 1347 | } |
1348 | 1348 | |
@@ -1356,9 +1356,9 @@ discard block |
||
1356 | 1356 | * @throws \EE_Error |
1357 | 1357 | */ |
1358 | 1358 | public function go_to_next_step() { |
1359 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1359 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1360 | 1360 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1361 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1361 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1362 | 1362 | } |
1363 | 1363 | $this->unlock_transaction(); |
1364 | 1364 | // just return for these conditions |
@@ -1387,7 +1387,7 @@ discard block |
||
1387 | 1387 | */ |
1388 | 1388 | protected function _handle_json_response() { |
1389 | 1389 | // if this is an ajax request |
1390 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1390 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1391 | 1391 | // DEBUG LOG |
1392 | 1392 | //$this->checkout->log( |
1393 | 1393 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | $this->checkout->json_response->set_registration_time_limit( |
1401 | 1401 | $this->checkout->get_registration_time_limit() |
1402 | 1402 | ); |
1403 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1403 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1404 | 1404 | // just send the ajax ( |
1405 | 1405 | $json_response = apply_filters( |
1406 | 1406 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1421,9 +1421,9 @@ discard block |
||
1421 | 1421 | */ |
1422 | 1422 | protected function _handle_html_redirects() { |
1423 | 1423 | // going somewhere ? |
1424 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1424 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1425 | 1425 | // store notices in a transient |
1426 | - EE_Error::get_notices( false, true, true ); |
|
1426 | + EE_Error::get_notices(false, true, true); |
|
1427 | 1427 | // DEBUG LOG |
1428 | 1428 | //$this->checkout->log( |
1429 | 1429 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | // 'headers_list' => headers_list(), |
1434 | 1434 | // ) |
1435 | 1435 | //); |
1436 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1436 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1437 | 1437 | exit(); |
1438 | 1438 | } |
1439 | 1439 | } |
@@ -112,7 +112,7 @@ |
||
112 | 112 | if ( |
113 | 113 | ! ( |
114 | 114 | $this->checkout->payment_method instanceof EE_Payment_Method |
115 | - && $this->checkout->payment_method->is_off_site() |
|
115 | + && $this->checkout->payment_method->is_off_site() |
|
116 | 116 | ) |
117 | 117 | ) { |
118 | 118 | // mark this reg step as completed |
@@ -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 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param EE_Checkout $checkout |
23 | 23 | * @return \EE_SPCO_Reg_Step_Finalize_Registration |
24 | 24 | */ |
25 | - public function __construct( EE_Checkout $checkout ) { |
|
25 | + public function __construct(EE_Checkout $checkout) { |
|
26 | 26 | $this->_slug = 'finalize_registration'; |
27 | - $this->_name = __( 'Finalize Registration', 'event_espresso' ); |
|
27 | + $this->_name = __('Finalize Registration', 'event_espresso'); |
|
28 | 28 | $this->_submit_button_text = $this->_name; |
29 | 29 | $this->_template = ''; |
30 | 30 | $this->checkout = $checkout; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function initialize_reg_step() { |
49 | 49 | // there's actually no reg form to process if this is the final step |
50 | - if ( $this->is_current_step() ) { |
|
50 | + if ($this->is_current_step()) { |
|
51 | 51 | $this->checkout->step = $_REQUEST['step'] = $this->slug(); |
52 | 52 | $this->checkout->action = $_REQUEST['action'] = 'process_reg_step'; |
53 | 53 | $this->checkout->generate_reg_form = false; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function process_reg_step() { |
75 | 75 | // ensure all data gets refreshed from the db |
76 | - $this->checkout->refresh_all_entities( true ); |
|
76 | + $this->checkout->refresh_all_entities(true); |
|
77 | 77 | // ensures that all details and statuses for transaction, registration, and payments are updated |
78 | 78 | $txn_update_params = $this->_finalize_transaction(); |
79 | 79 | // DEBUG LOG |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | $txn_update_params |
103 | 103 | ); |
104 | 104 | // check if transaction has a primary registrant and that it has a related Attendee object |
105 | - if ( ! $this->_validate_primary_registrant() ) { |
|
105 | + if ( ! $this->_validate_primary_registrant()) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | // you don't have to go home but you can't stay here ! |
109 | 109 | $this->checkout->redirect = true; |
110 | 110 | $this->checkout->continue_reg = true; |
111 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
111 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
112 | 112 | if ( |
113 | 113 | ! ( |
114 | 114 | $this->checkout->payment_method instanceof EE_Payment_Method |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function _finalize_transaction() { |
135 | 135 | /** @type EE_Transaction_Processor $transaction_processor */ |
136 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
136 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
137 | 137 | //set revisit flag in txn processor |
138 | - $transaction_processor->set_revisit( $this->checkout->revisit ); |
|
138 | + $transaction_processor->set_revisit($this->checkout->revisit); |
|
139 | 139 | // at this point we'll consider a TXN to not have been abandoned |
140 | - $transaction_processor->toggle_abandoned_transaction_status( $this->checkout->transaction ); |
|
141 | - if ( $this->checkout->cart instanceof EE_Cart ) { |
|
140 | + $transaction_processor->toggle_abandoned_transaction_status($this->checkout->transaction); |
|
141 | + if ($this->checkout->cart instanceof EE_Cart) { |
|
142 | 142 | // save TXN data to the cart |
143 | 143 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
144 | 144 | $this->checkout->transaction->ID() |
145 | 145 | ); |
146 | 146 | } |
147 | 147 | /** @type EE_Transaction_Payments $transaction_payments */ |
148 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
148 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
149 | 149 | // maybe update status, but don't save transaction just yet |
150 | - $transaction_payments->update_transaction_status_based_on_total_paid( $this->checkout->transaction, false ); |
|
150 | + $transaction_payments->update_transaction_status_based_on_total_paid($this->checkout->transaction, false); |
|
151 | 151 | // maybe send messages |
152 | 152 | $this->_trigger_notifications(); |
153 | 153 | // this will result in the base session properties getting saved to the TXN_Session_data field |
154 | 154 | $this->checkout->transaction->set_txn_session_data( |
155 | - EE_Registry::instance()->SSN->get_session_data( null, true ) |
|
155 | + EE_Registry::instance()->SSN->get_session_data(null, true) |
|
156 | 156 | ); |
157 | 157 | // update the TXN if payment conditions have changed |
158 | 158 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | 176 | protected function _trigger_notifications() { |
177 | - if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
178 | - $is_revisit = filter_var( $this->checkout->revisit, FILTER_VALIDATE_BOOLEAN ); |
|
179 | - if ( $this->checkout->payment_method->is_off_site() ) { |
|
180 | - $gateway= $this->checkout->payment_method->type_obj()->get_gateway(); |
|
177 | + if ($this->checkout->payment_method instanceof EE_Payment_Method) { |
|
178 | + $is_revisit = filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN); |
|
179 | + if ($this->checkout->payment_method->is_off_site()) { |
|
180 | + $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
181 | 181 | if ( |
182 | 182 | ! $is_revisit |
183 | 183 | && $gateway instanceof EE_Offsite_Gateway |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | ) |
188 | 188 | ) { |
189 | 189 | // first time through SPCO and we are processing the payment notification NOW |
190 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
190 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
191 | 191 | } else { |
192 | 192 | // do NOT trigger notifications because this is a revisit, OR it was already done during the IPN |
193 | - remove_all_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ); |
|
193 | + remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
194 | 194 | add_filter( |
195 | 195 | 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
196 | 196 | '__return_false', |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | } |
200 | 200 | } else if ( |
201 | 201 | // if SPCO revisit and TXN status has changed due to a payment |
202 | - $is_revisit && ( $this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated() ) |
|
202 | + $is_revisit && ($this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated()) |
|
203 | 203 | ) { |
204 | 204 | // send out notifications |
205 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
206 | - } else if ( ! $is_revisit ) { |
|
207 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
205 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
206 | + } else if ( ! $is_revisit) { |
|
207 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * @throws \EE_Error |
219 | 219 | */ |
220 | 220 | protected function _validate_primary_registrant() { |
221 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
221 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
222 | 222 | EE_Error::add_error( |
223 | - __( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ), |
|
223 | + __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'), |
|
224 | 224 | __FILE__, |
225 | 225 | __FUNCTION__, |
226 | 226 | __LINE__ |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | } |
232 | 232 | // setup URL for redirect |
233 | 233 | $this->checkout->redirect_url = add_query_arg( |
234 | - array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ), |
|
234 | + array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()), |
|
235 | 235 | $this->checkout->thank_you_page_url |
236 | 236 | ); |
237 | 237 | return true; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function update_reg_step() { |
246 | 246 | EE_Error::doing_it_wrong( |
247 | - __CLASS__ . '::' . __FILE__, |
|
247 | + __CLASS__.'::'.__FILE__, |
|
248 | 248 | __( |
249 | 249 | 'Can not call update_reg_step() on the Finalize Registration reg step.', |
250 | 250 | 'event_espresso' |
@@ -310,23 +310,23 @@ discard block |
||
310 | 310 | * @param float $amount |
311 | 311 | * @param string $name |
312 | 312 | * @param string $description |
313 | - * @param string $code |
|
314 | - * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | - * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | - * set the taxes to match $amount |
|
313 | + * @param string $code |
|
314 | + * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | + * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | + * set the taxes to match $amount |
|
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | 319 | public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
320 | 320 | |
321 | - /** |
|
322 | - * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | - * Does NOT save the line items |
|
324 | - * @param EE_Line_Item $line_item |
|
325 | - * @param boolean $taxable |
|
326 | - * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | - * it will be whitelisted (ie, except from becoming taxable) |
|
328 | - */ |
|
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
321 | + /** |
|
322 | + * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | + * Does NOT save the line items |
|
324 | + * @param EE_Line_Item $line_item |
|
325 | + * @param boolean $taxable |
|
326 | + * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | + * it will be whitelisted (ie, except from becoming taxable) |
|
328 | + */ |
|
329 | + public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | */ |
357 | 357 | interface EEHI_Money{ |
358 | 358 | /** |
359 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | - * This should be used to compare floats instead of normal '==' because floats |
|
361 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | - * but actually differ by 0.00000001. |
|
363 | - * @param float $float1 |
|
364 | - * @param float $float2 |
|
365 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | - * @return boolean whether the equation is true or false |
|
367 | - */ |
|
359 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | + * This should be used to compare floats instead of normal '==' because floats |
|
361 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | + * but actually differ by 0.00000001. |
|
363 | + * @param float $float1 |
|
364 | + * @param float $float2 |
|
365 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | + * @return boolean whether the equation is true or false |
|
367 | + */ |
|
368 | 368 | public function compare_floats( $float1, $float2, $operator='=' ); |
369 | 369 | } |
370 | 370 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Interface EEI_Base |
7 | 7 | */ |
8 | -interface EEI_Base{ |
|
8 | +interface EEI_Base { |
|
9 | 9 | /** |
10 | 10 | * gets the unique ID of the model object. If it hasn't been saved yet |
11 | 11 | * to the database, this should be 0 or NULL |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
33 | 33 | * NOTE: if the values haven't changed, returns 0 |
34 | 34 | */ |
35 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL); |
|
35 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param boolean $unique |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function add_extra_meta($meta_key,$meta_value,$unique = false); |
|
46 | + public function add_extra_meta($meta_key, $meta_value, $unique = false); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deletes all the extra meta rows for this record as specified by key. If $meta_value |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $meta_value |
53 | 53 | * @return int number of extra meta rows deleted |
54 | 54 | */ |
55 | - public function delete_extra_meta($meta_key,$meta_value = NULL); |
|
55 | + public function delete_extra_meta($meta_key, $meta_value = NULL); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $default if we don't find anything, what should we return? |
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
|
66 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param EE_Response $response |
91 | 91 | * @return EE_Response |
92 | 92 | */ |
93 | - public function handle_request( EE_Request $request, EE_Response $response ); |
|
93 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param EE_Request $request |
107 | 107 | * @param EE_Response $response |
108 | 108 | */ |
109 | - public function handle_response( EE_Request $request, EE_Response $response ); |
|
109 | + public function handle_response(EE_Request $request, EE_Response $response); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param string $country |
287 | 287 | * @param string $CNT_ISO |
288 | 288 | */ |
289 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
|
289 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | /** |
297 | 297 | * Interface EEHI_Line_Item |
298 | 298 | */ |
299 | -interface EEHI_Line_Item{ |
|
299 | +interface EEHI_Line_Item { |
|
300 | 300 | /** |
301 | 301 | * Adds an item to the purchase in the right spot |
302 | 302 | * @param EE_Line_Item $total_line_item |
303 | 303 | * @param EE_Line_Item $line_item |
304 | 304 | */ |
305 | - public function add_item( EE_Line_Item $total_line_item, EE_Line_Item $line_item ); |
|
305 | + public function add_item(EE_Line_Item $total_line_item, EE_Line_Item $line_item); |
|
306 | 306 | /** |
307 | 307 | * Overwrites the previous tax by clearing out the old taxes, and creates a new |
308 | 308 | * tax and updates the total line item accordingly |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * set the taxes to match $amount |
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | - public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
|
319 | + public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false); |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Makes all the line items which are children of $line_item taxable (or not). |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $code_substring_for_whitelist if this string is part of the line item's code |
327 | 327 | * it will be whitelisted (ie, except from becoming taxable) |
328 | 328 | */ |
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
329 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -340,21 +340,21 @@ discard block |
||
340 | 340 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
341 | 341 | * @return boolean success |
342 | 342 | */ |
343 | - public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null ); |
|
343 | + public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null); |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Gets the line item for the taxes subtotal |
347 | 347 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
348 | 348 | * @return \EE_Line_Item |
349 | 349 | */ |
350 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ); |
|
350 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Money-related helper |
356 | 356 | */ |
357 | -interface EEHI_Money{ |
|
357 | +interface EEHI_Money { |
|
358 | 358 | /** |
359 | 359 | * For comparing floats. Default operator is '=', but see the $operator below for all options. |
360 | 360 | * This should be used to compare floats instead of normal '==' because floats |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
366 | 366 | * @return boolean whether the equation is true or false |
367 | 367 | */ |
368 | - public function compare_floats( $float1, $float2, $operator='=' ); |
|
368 | + public function compare_floats($float1, $float2, $operator = '='); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Interface EEHI_Template |
373 | 373 | */ |
374 | -interface EEHI_Template{ |
|
374 | +interface EEHI_Template { |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * EEH_Template::format_currency |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param string $cur_code_span_class |
385 | 385 | * @return string the html output for the formatted money value |
386 | 386 | */ |
387 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ); |
|
387 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code'); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param array $options |
400 | 400 | * @return mixed |
401 | 401 | */ |
402 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
402 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws EE_Error |
417 | 417 | * @return bool |
418 | 418 | */ |
419 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ); |
|
419 | + public static function ensure_file_exists_and_is_writable($full_file_path = ''); |
|
420 | 420 | |
421 | 421 | /** |
422 | 422 | * ensure_folder_exists_and_is_writable |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @throws EE_Error |
426 | 426 | * @return bool |
427 | 427 | */ |
428 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ); |
|
428 | + public static function ensure_folder_exists_and_is_writable($folder = ''); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | // End of file EEI_Interfaces.php |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * the interaction of EE_Transaction and EE_Registration model objects |
8 | 8 | * Provides methods for manipulating and processing changes to an EE_Transaction |
9 | 9 | * and it's related EE_Registrations with regards to the checkout/registration process |
10 | - |
|
11 | -* |
|
10 | + * |
|
12 | 11 | *@package Event Espresso |
13 | 12 | * @subpackage core |
14 | 13 | * @author Brent Christensen |
@@ -704,7 +703,7 @@ discard block |
||
704 | 703 | foreach ( $available_payment_methods as $available_payment_method ) { |
705 | 704 | if ( |
706 | 705 | $available_payment_method instanceof EE_Payment_Method |
707 | - && $available_payment_method->open_by_default() |
|
706 | + && $available_payment_method->open_by_default() |
|
708 | 707 | ) { |
709 | 708 | $PMD_ID = $available_payment_method->ID(); |
710 | 709 | break; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class EE_Transaction_Processor |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * @param array $registration_query_params |
53 | 53 | *@return EE_Transaction_Processor instance |
54 | 54 | */ |
55 | - public static function instance( $registration_query_params = array() ) { |
|
55 | + public static function instance($registration_query_params = array()) { |
|
56 | 56 | // check if class object is instantiated |
57 | - if ( ! self::$_instance instanceof EE_Transaction_Processor ) { |
|
58 | - self::$_instance = new self( $registration_query_params ); |
|
57 | + if ( ! self::$_instance instanceof EE_Transaction_Processor) { |
|
58 | + self::$_instance = new self($registration_query_params); |
|
59 | 59 | } |
60 | 60 | return self::$_instance; |
61 | 61 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @param array $registration_query_params |
67 | 67 | * @return EE_Transaction_Processor |
68 | 68 | */ |
69 | - private function __construct( $registration_query_params = array() ) { |
|
69 | + private function __construct($registration_query_params = array()) { |
|
70 | 70 | // make sure some query params are set for retrieving registrations |
71 | - $this->_set_registration_query_params( $registration_query_params ); |
|
71 | + $this->_set_registration_query_params($registration_query_params); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @access private |
78 | 78 | * @param array $registration_query_params |
79 | 79 | */ |
80 | - private function _set_registration_query_params( $registration_query_params ) { |
|
81 | - $this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
80 | + private function _set_registration_query_params($registration_query_params) { |
|
81 | + $this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * @param string $old_txn_status |
97 | 97 | */ |
98 | - public function set_old_txn_status( $old_txn_status ) { |
|
98 | + public function set_old_txn_status($old_txn_status) { |
|
99 | 99 | // only set the first time |
100 | - if ( $this->_old_txn_status === null ) { |
|
100 | + if ($this->_old_txn_status === null) { |
|
101 | 101 | $this->_old_txn_status = $old_txn_status; |
102 | 102 | } |
103 | 103 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * @param string $new_txn_status |
118 | 118 | */ |
119 | - public function set_new_txn_status( $new_txn_status ) { |
|
119 | + public function set_new_txn_status($new_txn_status) { |
|
120 | 120 | $this->_new_txn_status = $new_txn_status; |
121 | 121 | } |
122 | 122 | |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * @param bool $check_all |
148 | 148 | * @return boolean | int |
149 | 149 | */ |
150 | - private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) { |
|
150 | + private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) { |
|
151 | 151 | $reg_steps = $transaction->reg_steps(); |
152 | - if ( ! is_array( $reg_steps ) || empty( $reg_steps )) { |
|
152 | + if ( ! is_array($reg_steps) || empty($reg_steps)) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | // loop thru reg steps array) |
156 | - foreach ( $reg_steps as $slug => $reg_step_completed ) { |
|
156 | + foreach ($reg_steps as $slug => $reg_step_completed) { |
|
157 | 157 | // if NOT checking ALL steps (only checking one step) |
158 | - if ( ! $check_all ) { |
|
158 | + if ( ! $check_all) { |
|
159 | 159 | // and this is the one |
160 | - if ( $slug === $reg_step_slug ) { |
|
160 | + if ($slug === $reg_step_slug) { |
|
161 | 161 | return $reg_step_completed; |
162 | 162 | } else { |
163 | 163 | // skip to next reg step in loop |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | // $check_all must be true, else we would never have gotten to this point |
168 | - if ( $slug === $reg_step_slug ) { |
|
168 | + if ($slug === $reg_step_slug) { |
|
169 | 169 | // if we reach this point, then we are testing either: |
170 | 170 | // all_reg_steps_completed_except() or |
171 | 171 | // all_reg_steps_completed_except_final_step(), |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | // ie: "is everything completed except the final step?" |
175 | 175 | // "that is correct... the final step is not completed, but all others are." |
176 | 176 | return $reg_step_completed !== true ? true : false; |
177 | - } else if ( $reg_step_completed !== true ) { |
|
177 | + } else if ($reg_step_completed !== true) { |
|
178 | 178 | // if any reg step is NOT completed, then ALL steps are not completed |
179 | 179 | return false; |
180 | 180 | } |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * @param EE_Transaction $transaction |
196 | 196 | * @return boolean |
197 | 197 | */ |
198 | - public function all_reg_steps_completed( EE_Transaction $transaction ) { |
|
199 | - return $this->_reg_steps_completed( $transaction ); |
|
198 | + public function all_reg_steps_completed(EE_Transaction $transaction) { |
|
199 | + return $this->_reg_steps_completed($transaction); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | * @param string $exception |
214 | 214 | * @return boolean |
215 | 215 | */ |
216 | - public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) { |
|
217 | - return $this->_reg_steps_completed( $transaction, $exception ); |
|
216 | + public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') { |
|
217 | + return $this->_reg_steps_completed($transaction, $exception); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param EE_Transaction $transaction |
231 | 231 | * @return boolean |
232 | 232 | */ |
233 | - public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) { |
|
234 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration' ); |
|
233 | + public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) { |
|
234 | + return $this->_reg_steps_completed($transaction, 'finalize_registration'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $reg_step_slug |
249 | 249 | * @return boolean | int |
250 | 250 | */ |
251 | - public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
252 | - return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE ); |
|
251 | + public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
252 | + return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * @param EE_Transaction $transaction |
266 | 266 | * @return boolean | int |
267 | 267 | */ |
268 | - public function final_reg_step_completed( EE_Transaction $transaction ) { |
|
269 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE ); |
|
268 | + public function final_reg_step_completed(EE_Transaction $transaction) { |
|
269 | + return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @return boolean |
282 | 282 | * @throws \EE_Error |
283 | 283 | */ |
284 | - public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) { |
|
285 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, time() ); |
|
284 | + public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) { |
|
285 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, time()); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * @return boolean |
298 | 298 | * @throws \EE_Error |
299 | 299 | */ |
300 | - public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
301 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, true ); |
|
300 | + public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
301 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, true); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * @return boolean |
314 | 314 | * @throws \EE_Error |
315 | 315 | */ |
316 | - public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
317 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, false ); |
|
316 | + public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
317 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, false); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | |
@@ -330,37 +330,37 @@ discard block |
||
330 | 330 | * @return boolean |
331 | 331 | * @throws \EE_Error |
332 | 332 | */ |
333 | - private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) { |
|
333 | + private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) { |
|
334 | 334 | // validate status |
335 | - $status = is_bool( $status ) || is_int( $status ) ? $status : false; |
|
335 | + $status = is_bool($status) || is_int($status) ? $status : false; |
|
336 | 336 | // get reg steps array |
337 | 337 | $txn_reg_steps = $transaction->reg_steps(); |
338 | 338 | // if reg step does NOT exist |
339 | - if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) { |
|
339 | + if ( ! isset($txn_reg_steps[$reg_step_slug])) { |
|
340 | 340 | return false; |
341 | 341 | } |
342 | 342 | // if we're trying to complete a step that is already completed |
343 | - if ( $txn_reg_steps[ $reg_step_slug ] === true ) { |
|
343 | + if ($txn_reg_steps[$reg_step_slug] === true) { |
|
344 | 344 | return true; |
345 | 345 | } |
346 | 346 | // if we're trying to complete a step that hasn't even started |
347 | - if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) { |
|
347 | + if ($status === true && $txn_reg_steps[$reg_step_slug] === false) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | 350 | // if current status value matches the incoming value (no change) |
351 | 351 | // type casting as int means values should collapse to either 0, 1, or a timestamp like 1234567890 |
352 | - if ( (int)$txn_reg_steps[ $reg_step_slug ] === (int)$status ) { |
|
352 | + if ((int) $txn_reg_steps[$reg_step_slug] === (int) $status) { |
|
353 | 353 | // this will happen in cases where multiple AJAX requests occur during the same step |
354 | 354 | return true; |
355 | 355 | } |
356 | 356 | // if we're trying to set a start time, but it has already been set... |
357 | - if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) { |
|
357 | + if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) { |
|
358 | 358 | // skip the update below, but don't return FALSE so that errors won't be displayed |
359 | 359 | return true; |
360 | 360 | } |
361 | 361 | // update completed status |
362 | - $txn_reg_steps[ $reg_step_slug ] = $status; |
|
363 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
362 | + $txn_reg_steps[$reg_step_slug] = $status; |
|
363 | + $transaction->set_reg_steps($txn_reg_steps); |
|
364 | 364 | $transaction->save(); |
365 | 365 | // DEBUG LOG |
366 | 366 | //$this->log( |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | * @param string $reg_step_slug |
387 | 387 | * @return void |
388 | 388 | */ |
389 | - public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) { |
|
389 | + public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) { |
|
390 | 390 | // get reg steps array |
391 | 391 | $txn_reg_steps = $transaction->reg_steps(); |
392 | - unset( $txn_reg_steps[ $reg_step_slug ] ); |
|
393 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
392 | + unset($txn_reg_steps[$reg_step_slug]); |
|
393 | + $transaction->set_reg_steps($txn_reg_steps); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -405,15 +405,15 @@ discard block |
||
405 | 405 | * @return boolean |
406 | 406 | * @throws \EE_Error |
407 | 407 | */ |
408 | - public function toggle_failed_transaction_status( EE_Transaction $transaction ) { |
|
408 | + public function toggle_failed_transaction_status(EE_Transaction $transaction) { |
|
409 | 409 | $existing_txn_status = $transaction->status_ID(); |
410 | 410 | // set incoming TXN_Status |
411 | - $this->set_old_txn_status( $existing_txn_status ); |
|
411 | + $this->set_old_txn_status($existing_txn_status); |
|
412 | 412 | // if TXN status is still set as "failed"... |
413 | - if ( $existing_txn_status === EEM_Transaction::failed_status_code ) { |
|
413 | + if ($existing_txn_status === EEM_Transaction::failed_status_code) { |
|
414 | 414 | // set incoming TXN_Status |
415 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
416 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
415 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
416 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
417 | 417 | $transaction->save(); |
418 | 418 | return TRUE; |
419 | 419 | } |
@@ -430,27 +430,27 @@ discard block |
||
430 | 430 | * @param EE_Transaction $transaction |
431 | 431 | * @return boolean |
432 | 432 | */ |
433 | - public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) { |
|
433 | + public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { |
|
434 | 434 | // set incoming TXN_Status |
435 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
435 | + $this->set_old_txn_status($transaction->status_ID()); |
|
436 | 436 | // if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"... |
437 | 437 | $txn_status = $transaction->status_ID(); |
438 | 438 | if ( |
439 | 439 | $txn_status === EEM_Transaction::failed_status_code |
440 | 440 | || $txn_status === EEM_Transaction::abandoned_status_code |
441 | 441 | ) { |
442 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
442 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
443 | 443 | // if a contact record for the primary registrant has been created |
444 | 444 | if ( |
445 | 445 | $transaction->primary_registration() instanceof EE_Registration |
446 | 446 | && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
447 | 447 | ) { |
448 | - $transaction->set_status( EEM_Transaction::incomplete_status_code ); |
|
449 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
448 | + $transaction->set_status(EEM_Transaction::incomplete_status_code); |
|
449 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
450 | 450 | } else { |
451 | 451 | // no contact record? yer abandoned! |
452 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
453 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
452 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
453 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
454 | 454 | } |
455 | 455 | return TRUE; |
456 | 456 | } |
@@ -483,10 +483,10 @@ discard block |
||
483 | 483 | ); |
484 | 484 | // send messages |
485 | 485 | /** @type EE_Registration_Processor $registration_processor */ |
486 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
486 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
487 | 487 | $registration_processor->trigger_registration_update_notifications( |
488 | 488 | $transaction->primary_registration(), |
489 | - array( 'manually_updated' => true ) |
|
489 | + array('manually_updated' => true) |
|
490 | 490 | ); |
491 | 491 | do_action( |
492 | 492 | 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
@@ -573,16 +573,16 @@ discard block |
||
573 | 573 | $registration_query_params = array() |
574 | 574 | ) { |
575 | 575 | // set incoming TXN_Status, and consider it new since old status should have been set |
576 | - $this->set_new_txn_status( $transaction->status_ID() ); |
|
577 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' ); |
|
576 | + $this->set_new_txn_status($transaction->status_ID()); |
|
577 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()'); |
|
578 | 578 | // make sure some query params are set for retrieving registrations |
579 | - $this->_set_registration_query_params( $registration_query_params ); |
|
579 | + $this->_set_registration_query_params($registration_query_params); |
|
580 | 580 | // get final reg step status |
581 | - $finalized = $this->final_reg_step_completed( $transaction ); |
|
581 | + $finalized = $this->final_reg_step_completed($transaction); |
|
582 | 582 | // if the 'finalize_registration' step has been initiated (has a timestamp) |
583 | 583 | // but has not yet been fully completed (TRUE) |
584 | - if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) { |
|
585 | - $this->set_reg_step_completed( $transaction, 'finalize_registration' ); |
|
584 | + if (is_int($finalized) && $finalized !== false && $finalized !== true) { |
|
585 | + $this->set_reg_step_completed($transaction, 'finalize_registration'); |
|
586 | 586 | $finalized = true; |
587 | 587 | } |
588 | 588 | $transaction->save(); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | |
606 | 606 | // send messages |
607 | 607 | /** @type EE_Registration_Processor $registration_processor */ |
608 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
608 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
609 | 609 | $registration_processor->trigger_registration_update_notifications( |
610 | 610 | $transaction->primary_registration(), |
611 | 611 | $update_params |
@@ -641,22 +641,22 @@ discard block |
||
641 | 641 | ) { |
642 | 642 | $response = false; |
643 | 643 | /** @type EE_Registration_Processor $registration_processor */ |
644 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
644 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
645 | 645 | // check that method exists |
646 | - if ( ! method_exists( $registration_processor, $method_name )) { |
|
647 | - throw new EE_Error( __( 'Method does not exist.', 'event_espresso' )); |
|
646 | + if ( ! method_exists($registration_processor, $method_name)) { |
|
647 | + throw new EE_Error(__('Method does not exist.', 'event_espresso')); |
|
648 | 648 | } |
649 | 649 | // make sure some query params are set for retrieving registrations |
650 | - $this->_set_registration_query_params( $registration_query_params ); |
|
650 | + $this->_set_registration_query_params($registration_query_params); |
|
651 | 651 | // loop through cached registrations |
652 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
653 | - if ( $registration instanceof EE_Registration ) { |
|
654 | - if ( $additional_param ) { |
|
655 | - $response = $registration_processor->{$method_name}( $registration, $additional_param ) |
|
652 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
653 | + if ($registration instanceof EE_Registration) { |
|
654 | + if ($additional_param) { |
|
655 | + $response = $registration_processor->{$method_name}($registration, $additional_param) |
|
656 | 656 | ? true |
657 | 657 | : $response; |
658 | 658 | } else { |
659 | - $response = $registration_processor->{$method_name}( $registration ) |
|
659 | + $response = $registration_processor->{$method_name}($registration) |
|
660 | 660 | ? true |
661 | 661 | : $response; |
662 | 662 | } |
@@ -683,28 +683,28 @@ discard block |
||
683 | 683 | public function set_transaction_payment_method_based_on_registration_statuses( |
684 | 684 | EE_Registration $edited_registration |
685 | 685 | ) { |
686 | - if ( $edited_registration instanceof EE_Registration ) { |
|
686 | + if ($edited_registration instanceof EE_Registration) { |
|
687 | 687 | $transaction = $edited_registration->transaction(); |
688 | - if ( $transaction instanceof EE_Transaction ) { |
|
688 | + if ($transaction instanceof EE_Transaction) { |
|
689 | 689 | $all_not_approved = true; |
690 | - foreach ( $transaction->registrations() as $registration ) { |
|
691 | - if ( $registration instanceof EE_Registration ) { |
|
690 | + foreach ($transaction->registrations() as $registration) { |
|
691 | + if ($registration instanceof EE_Registration) { |
|
692 | 692 | // if any REG != "Not Approved" then toggle to false |
693 | 693 | $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | // if ALL Registrations are "Not Approved" |
697 | - if ( $all_not_approved ) { |
|
698 | - $transaction->set_payment_method_ID( null ); |
|
697 | + if ($all_not_approved) { |
|
698 | + $transaction->set_payment_method_ID(null); |
|
699 | 699 | $transaction->save(); |
700 | 700 | } else { |
701 | 701 | $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
702 | 702 | $transaction, |
703 | 703 | EEM_Payment_Method::scope_cart |
704 | 704 | ); |
705 | - if ( ! empty( $available_payment_methods ) ) { |
|
705 | + if ( ! empty($available_payment_methods)) { |
|
706 | 706 | $PMD_ID = 0; |
707 | - foreach ( $available_payment_methods as $available_payment_method ) { |
|
707 | + foreach ($available_payment_methods as $available_payment_method) { |
|
708 | 708 | if ( |
709 | 709 | $available_payment_method instanceof EE_Payment_Method |
710 | 710 | && $available_payment_method->open_by_default() |
@@ -713,22 +713,22 @@ discard block |
||
713 | 713 | break; |
714 | 714 | } |
715 | 715 | } |
716 | - if ( ! $PMD_ID ) { |
|
717 | - $first_payment_method = reset( $available_payment_methods ); |
|
718 | - if ( $first_payment_method instanceof EE_Payment_Method ) { |
|
716 | + if ( ! $PMD_ID) { |
|
717 | + $first_payment_method = reset($available_payment_methods); |
|
718 | + if ($first_payment_method instanceof EE_Payment_Method) { |
|
719 | 719 | $PMD_ID = $first_payment_method->ID(); |
720 | 720 | } else { |
721 | 721 | EE_Error::add_error( |
722 | - __( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ), |
|
722 | + __('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), |
|
723 | 723 | __FILE__, __LINE__, __FUNCTION__ |
724 | 724 | ); |
725 | 725 | } |
726 | 726 | } |
727 | - $transaction->set_payment_method_ID( $PMD_ID ); |
|
727 | + $transaction->set_payment_method_ID($PMD_ID); |
|
728 | 728 | $transaction->save(); |
729 | 729 | } else { |
730 | 730 | EE_Error::add_error( |
731 | - __( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ), |
|
731 | + __('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), |
|
732 | 732 | __FILE__, __LINE__, __FUNCTION__ |
733 | 733 | ); |
734 | 734 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @subpackage core/libraries/payment_methods |
16 | 16 | * @author Mike Nelson |
17 | 17 | */ |
18 | -abstract class EE_Gateway{ |
|
18 | +abstract class EE_Gateway { |
|
19 | 19 | /** |
20 | 20 | * a constant used as a possible value for $_currencies_supported to indicate |
21 | 21 | * that ALL currencies are supported by this gateway |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @return EE_Gateway |
95 | 95 | */ |
96 | - public function __construct(){ |
|
96 | + public function __construct() { |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * beginning again) |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public function __sleep(){ |
|
108 | + public function __sleep() { |
|
109 | 109 | $properties = get_object_vars($this); |
110 | - unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] ); |
|
110 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
111 | 111 | return array_keys($properties); |
112 | 112 | } |
113 | 113 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * see $_supports_sending_refunds |
116 | 116 | * @return boolean |
117 | 117 | */ |
118 | - public function supports_sending_refunds(){ |
|
118 | + public function supports_sending_refunds() { |
|
119 | 119 | return $this->_supports_sending_refunds; |
120 | 120 | } |
121 | 121 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * see $_supports_receiving_refunds |
124 | 124 | * @return boolean |
125 | 125 | */ |
126 | - public function supports_receiving_refunds(){ |
|
126 | + public function supports_receiving_refunds() { |
|
127 | 127 | return $this->_supports_receiving_refunds; |
128 | 128 | } |
129 | 129 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return EE_Payment for the refund |
139 | 139 | * @throws EE_Error |
140 | 140 | */ |
141 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
141 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
142 | 142 | return NULL; |
143 | 143 | } |
144 | 144 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * etc |
150 | 150 | * @param array $settings_array |
151 | 151 | */ |
152 | - public function set_settings($settings_array){ |
|
153 | - foreach($settings_array as $name => $value){ |
|
152 | + public function set_settings($settings_array) { |
|
153 | + foreach ($settings_array as $name => $value) { |
|
154 | 154 | $property_name = "_".$name; |
155 | 155 | $this->{$property_name} = $value; |
156 | 156 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | * See this class description |
160 | 160 | * @param EEMI_Payment $payment_model |
161 | 161 | */ |
162 | - public function set_payment_model($payment_model){ |
|
162 | + public function set_payment_model($payment_model) { |
|
163 | 163 | $this->_pay_model = $payment_model; |
164 | 164 | } |
165 | 165 | /** |
166 | 166 | * See this class description |
167 | 167 | * @param EEMI_Payment_Log $payment_log_model |
168 | 168 | */ |
169 | - public function set_payment_log($payment_log_model){ |
|
169 | + public function set_payment_log($payment_log_model) { |
|
170 | 170 | $this->_pay_log = $payment_log_model; |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * See this class description |
175 | 175 | * @param EEHI_Template $template_helper |
176 | 176 | */ |
177 | - public function set_template_helper($template_helper){ |
|
177 | + public function set_template_helper($template_helper) { |
|
178 | 178 | $this->_template = $template_helper; |
179 | 179 | } |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * See this class description |
183 | 183 | * @param EEHI_Line_Item $line_item_helper |
184 | 184 | */ |
185 | - public function set_line_item_helper( $line_item_helper ){ |
|
185 | + public function set_line_item_helper($line_item_helper) { |
|
186 | 186 | $this->_line_item = $line_item_helper; |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * See this class description |
191 | 191 | * @param EEHI_Money $money_helper |
192 | 192 | */ |
193 | - public function set_money_helper( $money_helper ){ |
|
193 | + public function set_money_helper($money_helper) { |
|
194 | 194 | $this->_money = $money_helper; |
195 | 195 | } |
196 | 196 | |
@@ -199,23 +199,23 @@ discard block |
||
199 | 199 | * @param $message |
200 | 200 | * @param $payment |
201 | 201 | */ |
202 | - public function log($message,$payment){ |
|
203 | - if($payment instanceof EEI_Payment){ |
|
204 | - $type='Payment'; |
|
202 | + public function log($message, $payment) { |
|
203 | + if ($payment instanceof EEI_Payment) { |
|
204 | + $type = 'Payment'; |
|
205 | 205 | $id = $payment->ID(); |
206 | - }else{ |
|
206 | + } else { |
|
207 | 207 | $type = 'Payment_Method'; |
208 | 208 | $id = $this->_ID; |
209 | 209 | } |
210 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
210 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
211 | 211 | } |
212 | 212 | /** |
213 | 213 | * Formats the amount so it can generally be sent to gateways |
214 | 214 | * @param float $amount |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public function format_currency($amount){ |
|
218 | - return number_format( $amount, 2, '.', '' ); |
|
217 | + public function format_currency($amount) { |
|
218 | + return number_format($amount, 2, '.', ''); |
|
219 | 219 | // return $this->_template->format_currency($amount, true); |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
225 | 225 | * @return mixed array or string |
226 | 226 | */ |
227 | - public function currencies_supported(){ |
|
227 | + public function currencies_supported() { |
|
228 | 228 | return $this->_currencies_supported; |
229 | 229 | } |
230 | 230 | |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * @param EE_Transaction $transaction |
237 | 237 | * @return float |
238 | 238 | */ |
239 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
239 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
240 | 240 | $total_line_item = $transaction->total_line_item(); |
241 | 241 | $total = 0; |
242 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
243 | - $total += max( $item_line_item->total(), 0 ); |
|
242 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
243 | + $total += max($item_line_item->total(), 0); |
|
244 | 244 | } |
245 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
246 | - $total += max( $tax_line_item->total(), 0 ); |
|
245 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
246 | + $total += max($tax_line_item->total(), 0); |
|
247 | 247 | } |
248 | 248 | return $total; |
249 | 249 | } |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | * @param EEI_Payment $payment |
255 | 255 | * @return boolean |
256 | 256 | */ |
257 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
257 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
258 | 258 | return $this->_money->compare_floats( |
259 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
259 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
260 | 260 | $payment->transaction()->total() ) && |
261 | 261 | $this->_money->compare_floats( |
262 | 262 | $payment->amount(), |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param EE_Payment $payment |
275 | 275 | * @return void |
276 | 276 | */ |
277 | - public function update_txn_based_on_payment( $payment ){ |
|
277 | + public function update_txn_based_on_payment($payment) { |
|
278 | 278 | //maybe update the transaction or line items or registrations |
279 | 279 | //but most gateways don't need to do this, because they only update the payment |
280 | 280 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance; |
20 | 20 | |
21 | 21 | |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
52 | 52 | * Saves the payment that is generated |
53 | - |
|
54 | 53 | * |
55 | 54 | *@param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | |
131 | 130 | |
132 | 131 | /** |
133 | - |
|
134 | 132 | * @param EE_Base_Class|int $transaction |
135 | 133 | * @param EE_Payment_Method $payment_method |
136 | 134 | * @throws EE_Error |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | *@return EE_Payment_Processor |
43 | 43 | */ |
44 | 44 | private function __construct() { |
45 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $update_txn = true, |
82 | 82 | $cancel_url = '' |
83 | 83 | ) { |
84 | - if( (float)$amount < 0 ) { |
|
84 | + if ((float) $amount < 0) { |
|
85 | 85 | throw new EE_Error( |
86 | 86 | sprintf( |
87 | 87 | __( |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | // verify payment method |
97 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
97 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
98 | 98 | // verify transaction |
99 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
100 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
99 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
100 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
101 | 101 | // verify payment method type |
102 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
102 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
103 | 103 | $payment = $payment_method->type_obj()->process_payment( |
104 | 104 | $transaction, |
105 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
105 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
106 | 106 | $billing_form, |
107 | 107 | $return_url, |
108 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
108 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
109 | 109 | $method, |
110 | 110 | $by_admin |
111 | 111 | ); |
112 | 112 | // check if payment method uses an off-site gateway |
113 | - if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) { |
|
113 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
114 | 114 | // don't process payments for off-site gateways yet because no payment has occurred yet |
115 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
115 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
116 | 116 | } |
117 | 117 | return $payment; |
118 | 118 | } else { |
119 | 119 | EE_Error::add_error( |
120 | 120 | sprintf( |
121 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
121 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
122 | 122 | '<br/>', |
123 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
123 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
124 | 124 | ), __FILE__, __FUNCTION__, __LINE__ |
125 | 125 | ); |
126 | 126 | return NULL; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * @throws EE_Error |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
139 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
140 | 140 | /** @type \EE_Transaction $transaction */ |
141 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
141 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
142 | 142 | $primary_reg = $transaction->primary_registration(); |
143 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
143 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
144 | 144 | throw new EE_Error( |
145 | 145 | sprintf( |
146 | 146 | __( |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | } |
154 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
154 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
155 | 155 | $url = add_query_arg( |
156 | 156 | array( |
157 | 157 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -188,92 +188,92 @@ discard block |
||
188 | 188 | $update_txn = true, |
189 | 189 | $separate_IPN_request = true |
190 | 190 | ) { |
191 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
192 | - $_req_data = $this->_remove_unusable_characters_from_array( $_req_data ); |
|
193 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
191 | + EE_Registry::instance()->load_model('Change_Log'); |
|
192 | + $_req_data = $this->_remove_unusable_characters_from_array($_req_data); |
|
193 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
194 | 194 | $obj_for_log = null; |
195 | - if( $transaction instanceof EE_Transaction ){ |
|
195 | + if ($transaction instanceof EE_Transaction) { |
|
196 | 196 | $obj_for_log = $transaction; |
197 | - if( $payment_method instanceof EE_Payment_Method ) { |
|
197 | + if ($payment_method instanceof EE_Payment_Method) { |
|
198 | 198 | $obj_for_log = EEM_Payment::instance()->get_one( |
199 | 199 | array( |
200 | - array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), |
|
201 | - 'order_by' => array( 'PAY_timestamp' => 'desc' ) |
|
200 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
201 | + 'order_by' => array('PAY_timestamp' => 'desc') |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | - } else if( $payment_method instanceof EE_Payment ) { |
|
205 | + } else if ($payment_method instanceof EE_Payment) { |
|
206 | 206 | $obj_for_log = $payment_method; |
207 | 207 | } |
208 | 208 | $log = EEM_Change_Log::instance()->log( |
209 | 209 | EEM_Change_Log::type_gateway, |
210 | - array( 'IPN data received' => $_req_data ), |
|
210 | + array('IPN data received' => $_req_data), |
|
211 | 211 | $obj_for_log |
212 | 212 | ); |
213 | - try{ |
|
213 | + try { |
|
214 | 214 | /** |
215 | 215 | * @var EE_Payment $payment |
216 | 216 | */ |
217 | 217 | $payment = NULL; |
218 | - if($transaction && $payment_method){ |
|
218 | + if ($transaction && $payment_method) { |
|
219 | 219 | /** @type EE_Transaction $transaction */ |
220 | 220 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
221 | 221 | /** @type EE_Payment_Method $payment_method */ |
222 | 222 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
223 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
224 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
223 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
224 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
225 | 225 | $log->set_object($payment); |
226 | 226 | } else { |
227 | 227 | // not a payment |
228 | 228 | EE_Error::add_error( |
229 | 229 | sprintf( |
230 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
230 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
231 | 231 | '<br/>', |
232 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
232 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
233 | 233 | ), |
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else { |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
241 | 241 | $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
242 | - foreach( $active_payment_methods as $active_payment_method ){ |
|
243 | - try{ |
|
244 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
242 | + foreach ($active_payment_methods as $active_payment_method) { |
|
243 | + try { |
|
244 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
245 | 245 | $payment_method = $active_payment_method; |
246 | 246 | EEM_Change_Log::instance()->log( |
247 | 247 | EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment |
248 | 248 | ); |
249 | 249 | break; |
250 | - } catch( EE_Error $e ) { |
|
250 | + } catch (EE_Error $e) { |
|
251 | 251 | //that's fine- it apparently couldn't handle the IPN |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | } |
256 | 256 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
257 | - if( $payment instanceof EE_Payment){ |
|
257 | + if ($payment instanceof EE_Payment) { |
|
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
261 | - }else{ |
|
260 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
261 | + } else { |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | - if($payment_method){ |
|
263 | + if ($payment_method) { |
|
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + }elseif ($transaction) { |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | |
271 | - } catch( EE_Error $e ) { |
|
271 | + } catch (EE_Error $e) { |
|
272 | 272 | do_action( |
273 | 273 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
274 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
275 | - print_r( $transaction, TRUE ), |
|
276 | - print_r( $_req_data, TRUE ), |
|
274 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
275 | + print_r($transaction, TRUE), |
|
276 | + print_r($_req_data, TRUE), |
|
277 | 277 | $e->getMessage() |
278 | 278 | ) |
279 | 279 | ); |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param array $request_data |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - protected function _remove_unusable_characters_from_array( array $request_data ) { |
|
291 | + protected function _remove_unusable_characters_from_array(array $request_data) { |
|
292 | 292 | $return_data = array(); |
293 | - foreach( $request_data as $key => $value ) { |
|
294 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
293 | + foreach ($request_data as $key => $value) { |
|
294 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
295 | 295 | } |
296 | 296 | return $return_data; |
297 | 297 | } |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $request_data |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - protected function _remove_unusable_characters( $request_data ) { |
|
307 | - return preg_replace( '/[^[:print:]]/', '', $request_data ); |
|
306 | + protected function _remove_unusable_characters($request_data) { |
|
307 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
327 | 327 | * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
328 | 328 | */ |
329 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
329 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
330 | 330 | /** @var $transaction EE_Transaction */ |
331 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
331 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
332 | 332 | $last_payment_method = $transaction->payment_method(); |
333 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
334 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
335 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
333 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
334 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
335 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
336 | 336 | return $payment; |
337 | 337 | } else { |
338 | 338 | return NULL; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | EE_Payment $payment_to_refund, |
356 | 356 | $refund_info = array() |
357 | 357 | ) { |
358 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
359 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
360 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
358 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
359 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
360 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
361 | 361 | } |
362 | 362 | return $payment_to_refund; |
363 | 363 | } |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | * TXN is locked before updating |
399 | 399 | * @throws \EE_Error |
400 | 400 | */ |
401 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
401 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
402 | 402 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
403 | 403 | /** @type EE_Transaction $transaction */ |
404 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
404 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
405 | 405 | // can we freely update the TXN at this moment? |
406 | - if ( $IPN && $transaction->is_locked() ) { |
|
406 | + if ($IPN && $transaction->is_locked()) { |
|
407 | 407 | // don't update the transaction at this exact moment |
408 | 408 | // because the TXN is active in another request |
409 | 409 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -413,45 +413,45 @@ discard block |
||
413 | 413 | ); |
414 | 414 | } else { |
415 | 415 | // verify payment and that it has been saved |
416 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
417 | - if( |
|
416 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
417 | + if ( |
|
418 | 418 | $payment->payment_method() instanceof EE_Payment_Method |
419 | 419 | && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
420 | - ){ |
|
421 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
420 | + ) { |
|
421 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
422 | 422 | // update TXN registrations with payment info |
423 | - $this->process_registration_payments( $transaction, $payment ); |
|
423 | + $this->process_registration_payments($transaction, $payment); |
|
424 | 424 | } |
425 | 425 | $do_action = $payment->just_approved() |
426 | 426 | ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
427 | 427 | : $do_action; |
428 | 428 | } else { |
429 | 429 | // send out notifications |
430 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
430 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
431 | 431 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
432 | 432 | } |
433 | 433 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
434 | 434 | // so that we know whether the status has changed and notifications should be triggered |
435 | - if ( $IPN ) { |
|
435 | + if ($IPN) { |
|
436 | 436 | /** @type EE_Transaction_Processor $transaction_processor */ |
437 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
438 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
437 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
438 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
439 | 439 | } |
440 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
440 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
441 | 441 | /** @type EE_Transaction_Payments $transaction_payments */ |
442 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
442 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
443 | 443 | // set new value for total paid |
444 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
444 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
445 | 445 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
446 | - if ( $update_txn ) { |
|
447 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
446 | + if ($update_txn) { |
|
447 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | // granular hook for others to use. |
451 | - do_action( $do_action, $transaction, $payment ); |
|
452 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
451 | + do_action($do_action, $transaction, $payment); |
|
452 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
453 | 453 | //global hook for others to use. |
454 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
454 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -471,25 +471,25 @@ discard block |
||
471 | 471 | $registrations = array() |
472 | 472 | ) { |
473 | 473 | // only process if payment was successful |
474 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
474 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
475 | 475 | return; |
476 | 476 | } |
477 | 477 | //EEM_Registration::instance()->show_next_x_db_queries(); |
478 | - if ( empty( $registrations )) { |
|
478 | + if (empty($registrations)) { |
|
479 | 479 | // find registrations with monies owing that can receive a payment |
480 | 480 | $registrations = $transaction->registrations( |
481 | 481 | array( |
482 | 482 | array( |
483 | 483 | // only these reg statuses can receive payments |
484 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
485 | - 'REG_final_price' => array( '!=', 0 ), |
|
486 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
484 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
485 | + 'REG_final_price' => array('!=', 0), |
|
486 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
487 | 487 | ) |
488 | 488 | ) |
489 | 489 | ); |
490 | 490 | } |
491 | 491 | // still nothing ??!?? |
492 | - if ( empty( $registrations )) { |
|
492 | + if (empty($registrations)) { |
|
493 | 493 | return; |
494 | 494 | } |
495 | 495 | // todo: break out the following logic into a separate strategy class |
@@ -501,28 +501,28 @@ discard block |
||
501 | 501 | |
502 | 502 | $refund = $payment->is_a_refund(); |
503 | 503 | // how much is available to apply to registrations? |
504 | - $available_payment_amount = abs( $payment->amount() ); |
|
505 | - foreach ( $registrations as $registration ) { |
|
506 | - if ( $registration instanceof EE_Registration ) { |
|
504 | + $available_payment_amount = abs($payment->amount()); |
|
505 | + foreach ($registrations as $registration) { |
|
506 | + if ($registration instanceof EE_Registration) { |
|
507 | 507 | // nothing left? |
508 | - if ( $available_payment_amount <= 0 ) { |
|
508 | + if ($available_payment_amount <= 0) { |
|
509 | 509 | break; |
510 | 510 | } |
511 | - if ( $refund ) { |
|
512 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
511 | + if ($refund) { |
|
512 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
513 | 513 | } else { |
514 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
514 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | } |
518 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
518 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
519 | 519 | EE_Error::add_attention( |
520 | 520 | sprintf( |
521 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
522 | - EEH_Template::format_currency( $available_payment_amount ), |
|
523 | - implode( ', ', array_keys( $registrations ) ), |
|
521 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
522 | + EEH_Template::format_currency($available_payment_amount), |
|
523 | + implode(', ', array_keys($registrations)), |
|
524 | 524 | '<br/>', |
525 | - EEH_Template::format_currency( $payment->amount() ) |
|
525 | + EEH_Template::format_currency($payment->amount()) |
|
526 | 526 | ), |
527 | 527 | __FILE__, __FUNCTION__, __LINE__ |
528 | 528 | ); |
@@ -540,17 +540,17 @@ discard block |
||
540 | 540 | * @return float |
541 | 541 | * @throws \EE_Error |
542 | 542 | */ |
543 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
543 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
544 | 544 | $owing = $registration->final_price() - $registration->paid(); |
545 | - if ( $owing > 0 ) { |
|
545 | + if ($owing > 0) { |
|
546 | 546 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
547 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
547 | + $payment_amount = min($available_payment_amount, $owing); |
|
548 | 548 | // update $available_payment_amount |
549 | 549 | $available_payment_amount -= $payment_amount; |
550 | 550 | //calculate and set new REG_paid |
551 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
551 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
552 | 552 | // now save it |
553 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
553 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
554 | 554 | } |
555 | 555 | return $available_payment_amount; |
556 | 556 | } |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | * @return float |
567 | 567 | * @throws \EE_Error |
568 | 568 | */ |
569 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
569 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
570 | 570 | // find any existing reg payment records for this registration and payment |
571 | 571 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
572 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
572 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
573 | 573 | ); |
574 | 574 | // if existing registration payment exists |
575 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
575 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
576 | 576 | // then update that record |
577 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
577 | + $existing_reg_payment->set_amount($payment_amount); |
|
578 | 578 | $existing_reg_payment->save(); |
579 | 579 | } else { |
580 | 580 | // or add new relation between registration and payment and set amount |
581 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
581 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
582 | 582 | // make it stick |
583 | 583 | $registration->save(); |
584 | 584 | } |
@@ -595,21 +595,21 @@ discard block |
||
595 | 595 | * @return float |
596 | 596 | * @throws \EE_Error |
597 | 597 | */ |
598 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
598 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
599 | 599 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
600 | - if ( $registration->paid() > 0 ) { |
|
600 | + if ($registration->paid() > 0) { |
|
601 | 601 | // ensure $available_refund_amount is NOT negative |
602 | - $available_refund_amount = (float)abs( $available_refund_amount ); |
|
602 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
603 | 603 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
604 | - $refund_amount = min( $available_refund_amount, (float)$registration->paid() ); |
|
604 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
605 | 605 | // update $available_payment_amount |
606 | 606 | $available_refund_amount -= $refund_amount; |
607 | 607 | //calculate and set new REG_paid |
608 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
608 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
609 | 609 | // convert payment amount back to a negative value for storage in the db |
610 | - $refund_amount = (float)abs( $refund_amount ) * -1; |
|
610 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
611 | 611 | // now save it |
612 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
612 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
613 | 613 | } |
614 | 614 | return $available_refund_amount; |
615 | 615 | } |
@@ -628,21 +628,21 @@ discard block |
||
628 | 628 | * @param bool $IPN |
629 | 629 | * @throws \EE_Error |
630 | 630 | */ |
631 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
631 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
632 | 632 | |
633 | 633 | /** @type EE_Transaction_Processor $transaction_processor */ |
634 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
634 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
635 | 635 | // is the Payment Options Reg Step completed ? |
636 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
636 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
637 | 637 | // if the Payment Options Reg Step is completed... |
638 | 638 | $revisit = $payment_options_step_completed === true ? true : false; |
639 | 639 | // then this is kinda sorta a revisit with regards to payments at least |
640 | - $transaction_processor->set_revisit( $revisit ); |
|
640 | + $transaction_processor->set_revisit($revisit); |
|
641 | 641 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
642 | 642 | if ( |
643 | 643 | $IPN && |
644 | 644 | $payment_options_step_completed !== true && |
645 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
645 | + ($payment->is_approved() || $payment->is_pending()) |
|
646 | 646 | ) { |
647 | 647 | $payment_options_step_completed = $transaction_processor->set_reg_step_completed( |
648 | 648 | $transaction, |
@@ -650,34 +650,34 @@ discard block |
||
650 | 650 | ); |
651 | 651 | } |
652 | 652 | /** @type EE_Transaction_Payments $transaction_payments */ |
653 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
653 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
654 | 654 | // maybe update status, but don't save transaction just yet |
655 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
655 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
656 | 656 | // check if 'finalize_registration' step has been completed... |
657 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
657 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
658 | 658 | // if this is an IPN and the final step has not been initiated |
659 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
659 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
660 | 660 | // and if it hasn't already been set as being started... |
661 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
661 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
662 | 662 | } |
663 | 663 | $transaction->save(); |
664 | 664 | // because the above will return false if the final step was not fully completed, we need to check again... |
665 | - if ( $IPN && $finalized !== false ) { |
|
665 | + if ($IPN && $finalized !== false) { |
|
666 | 666 | // and if we are all good to go, then send out notifications |
667 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
667 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
668 | 668 | //ok, now process the transaction according to the payment |
669 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
669 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
670 | 670 | } |
671 | 671 | // DEBUG LOG |
672 | 672 | $payment_method = $payment->payment_method(); |
673 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
673 | + if ($payment_method instanceof EE_Payment_Method) { |
|
674 | 674 | $payment_method_type_obj = $payment_method->type_obj(); |
675 | - if ( $payment_method_type_obj instanceof EE_PMT_Base ) { |
|
675 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
676 | 676 | $gateway = $payment_method_type_obj->get_gateway(); |
677 | - if ( $gateway instanceof EE_Gateway ){ |
|
677 | + if ($gateway instanceof EE_Gateway) { |
|
678 | 678 | $gateway->log( |
679 | 679 | array( |
680 | - 'message' => __( 'Post Payment Transaction Details', 'event_espresso' ), |
|
680 | + 'message' => __('Post Payment Transaction Details', 'event_espresso'), |
|
681 | 681 | 'transaction' => $transaction->model_field_array(), |
682 | 682 | 'finalized' => $finalized, |
683 | 683 | 'IPN' => $IPN, |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else{ |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | 260 | $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | 263 | if($payment_method){ |
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + } elseif($transaction){ |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
50 | - * date format |
|
51 | - * |
|
52 | - * pattern or format for displaying dates |
|
53 | - * |
|
54 | - * @access protected |
|
55 | - * @var string |
|
56 | - */ |
|
50 | + * date format |
|
51 | + * |
|
52 | + * pattern or format for displaying dates |
|
53 | + * |
|
54 | + * @access protected |
|
55 | + * @var string |
|
56 | + */ |
|
57 | 57 | protected $_dt_frmt; |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * time format |
|
63 | - * |
|
64 | - * pattern or format for displaying time |
|
65 | - * |
|
66 | - * @access protected |
|
67 | - * @var string |
|
68 | - */ |
|
61 | + /** |
|
62 | + * time format |
|
63 | + * |
|
64 | + * pattern or format for displaying time |
|
65 | + * |
|
66 | + * @access protected |
|
67 | + * @var string |
|
68 | + */ |
|
69 | 69 | protected $_tm_frmt; |
70 | 70 | |
71 | 71 | |
@@ -1420,24 +1420,24 @@ discard block |
||
1420 | 1420 | * |
1421 | 1421 | * @throws \EE_Error |
1422 | 1422 | */ |
1423 | - public function refresh_cache_of_related_objects() { |
|
1424 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1425 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1426 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1427 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1428 | - //this relation only stores a single model object, not an array |
|
1429 | - //but let's make it consistent |
|
1430 | - $related_objects = array( $related_objects ); |
|
1431 | - } |
|
1432 | - foreach( $related_objects as $related_object ) { |
|
1433 | - //only refresh their cache if they're in memory |
|
1434 | - if( $related_object instanceof EE_Base_Class ) { |
|
1423 | + public function refresh_cache_of_related_objects() { |
|
1424 | + foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1425 | + if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1426 | + $related_objects = $this->_model_relations[ $relation_name ]; |
|
1427 | + if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1428 | + //this relation only stores a single model object, not an array |
|
1429 | + //but let's make it consistent |
|
1430 | + $related_objects = array( $related_objects ); |
|
1431 | + } |
|
1432 | + foreach( $related_objects as $related_object ) { |
|
1433 | + //only refresh their cache if they're in memory |
|
1434 | + if( $related_object instanceof EE_Base_Class ) { |
|
1435 | 1435 | $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
1436 | - } |
|
1437 | - } |
|
1438 | - } |
|
1439 | - } |
|
1440 | - } |
|
1436 | + } |
|
1437 | + } |
|
1438 | + } |
|
1439 | + } |
|
1440 | + } |
|
1441 | 1441 | |
1442 | 1442 | |
1443 | 1443 | |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | if ( self::_get_model( $classname )->has_primary_key_field() ) { |
1679 | 1679 | $primary_id_ref = self::_get_primary_key_name( $classname ); |
1680 | 1680 | if ( array_key_exists( $primary_id_ref, $props_n_values ) |
1681 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1681 | + && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1682 | 1682 | ) { |
1683 | 1683 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
1684 | 1684 | $props_n_values[ $primary_id_ref ] |
@@ -1830,9 +1830,9 @@ discard block |
||
1830 | 1830 | $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
1831 | 1831 | //clear cache so future get_many_related and get_first_related() return new results. |
1832 | 1832 | $this->clear_cache( $relationName, $otherObject, TRUE ); |
1833 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1834 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1835 | - } |
|
1833 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1834 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1835 | + } |
|
1836 | 1836 | } else { |
1837 | 1837 | //this thing doesn't exist in the DB, so just cache it |
1838 | 1838 | if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
@@ -1846,18 +1846,18 @@ discard block |
||
1846 | 1846 | } |
1847 | 1847 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
1848 | 1848 | } |
1849 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1850 | - //fix the reciprocal relation too |
|
1851 | - if( $otherObject->ID() ) { |
|
1852 | - //its saved so assumed relations exist in the DB, so we can just |
|
1853 | - //clear the cache so future queries use the updated info in the DB |
|
1854 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1855 | - } else { |
|
1856 | - |
|
1857 | - //it's not saved, so it caches relations like this |
|
1858 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1859 | - } |
|
1860 | - } |
|
1849 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1850 | + //fix the reciprocal relation too |
|
1851 | + if( $otherObject->ID() ) { |
|
1852 | + //its saved so assumed relations exist in the DB, so we can just |
|
1853 | + //clear the cache so future queries use the updated info in the DB |
|
1854 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1855 | + } else { |
|
1856 | + |
|
1857 | + //it's not saved, so it caches relations like this |
|
1858 | + $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1859 | + } |
|
1860 | + } |
|
1861 | 1861 | return $otherObject; |
1862 | 1862 | } |
1863 | 1863 | |
@@ -1888,9 +1888,9 @@ discard block |
||
1888 | 1888 | //this doesn't exist in the DB, just remove it from the cache |
1889 | 1889 | $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
1890 | 1890 | } |
1891 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1892 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | - } |
|
1891 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1892 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | + } |
|
1894 | 1894 | return $otherObject; |
1895 | 1895 | } |
1896 | 1896 | |
@@ -1913,11 +1913,11 @@ discard block |
||
1913 | 1913 | //this doesn't exist in the DB, just remove it from the cache |
1914 | 1914 | $otherObjects = $this->clear_cache( $relationName, null, true ); |
1915 | 1915 | } |
1916 | - if( is_array( $otherObjects ) ) { |
|
1917 | - foreach ( $otherObjects as $otherObject ) { |
|
1918 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1919 | - } |
|
1920 | - } |
|
1916 | + if( is_array( $otherObjects ) ) { |
|
1917 | + foreach ( $otherObjects as $otherObject ) { |
|
1918 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1919 | + } |
|
1920 | + } |
|
1921 | 1921 | return $otherObjects; |
1922 | 1922 | } |
1923 | 1923 |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
171 | 171 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
172 | 172 | $this->_model_relations[$relation_name] = NULL; |
173 | - }else{ |
|
173 | + } else{ |
|
174 | 174 | $this->_model_relations[$relation_name] = array(); |
175 | 175 | } |
176 | 176 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
217 | 217 | $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
218 | 218 | return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
219 | - }else{ |
|
219 | + } else{ |
|
220 | 220 | return NULL; |
221 | 221 | } |
222 | 222 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | : $this->set( $field_name, $this->_fields[$field_name] ); |
274 | 274 | } |
275 | 275 | |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $this->_fields[$field_name] = $holder_of_value; |
278 | 278 | } |
279 | 279 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | //let's unset any cache for this field_name from the $_cached_properties property. |
306 | 306 | $this->_clear_cached_property( $field_name ); |
307 | - }else{ |
|
307 | + } else{ |
|
308 | 308 | throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
309 | 309 | } |
310 | 310 | |
@@ -653,10 +653,10 @@ discard block |
||
653 | 653 | if($clear_all){ |
654 | 654 | $obj_removed = true; |
655 | 655 | $this->_model_relations[$relationName] = null; |
656 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
656 | + } elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
657 | 657 | $obj_removed = $this->_model_relations[$relationName]; |
658 | 658 | $this->_model_relations[$relationName] = null; |
659 | - }else{ |
|
659 | + } else{ |
|
660 | 660 | if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
661 | 661 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
662 | 662 | if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
@@ -676,20 +676,20 @@ discard block |
||
676 | 676 | } |
677 | 677 | if($index_found_at){ |
678 | 678 | $index_in_cache = $index_found_at; |
679 | - }else{ |
|
679 | + } else{ |
|
680 | 680 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
681 | 681 | //if it wasn't in it to begin with. So we're done |
682 | 682 | return $object_to_remove_or_index_into_array; |
683 | 683 | } |
684 | 684 | } |
685 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
685 | + } elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
686 | 686 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
687 | 687 | foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
688 | 688 | if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
689 | 689 | $index_in_cache = $index; |
690 | 690 | } |
691 | 691 | } |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $index_in_cache = $object_to_remove_or_index_into_array; |
694 | 694 | } |
695 | 695 | //supposedly we've found it. But it could just be that the client code |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
760 | 760 | if(is_array($cached_array_or_object)){ |
761 | 761 | return array_shift($cached_array_or_object); |
762 | - }else{ |
|
762 | + } else{ |
|
763 | 763 | return $cached_array_or_object; |
764 | 764 | } |
765 | 765 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | if( $model_object->ID() ){ |
791 | 791 | $model->add_to_entity_map( $model_object ); |
792 | 792 | } |
793 | - }else{ |
|
793 | + } else{ |
|
794 | 794 | throw new EE_Error( |
795 | 795 | sprintf( |
796 | 796 | __( |
@@ -925,10 +925,10 @@ discard block |
||
925 | 925 | if( $field_obj->is_nullable()){ |
926 | 926 | //if the field allows nulls, then let it be null |
927 | 927 | $field_value = NULL; |
928 | - }else{ |
|
928 | + } else{ |
|
929 | 929 | $field_value = $field_obj->get_default_value(); |
930 | 930 | } |
931 | - }else{ |
|
931 | + } else{ |
|
932 | 932 | $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
933 | 933 | } |
934 | 934 | $this->_fields[$field_name] = $field_value; |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | $this->_update_cached_related_model_objs_fks(); |
1514 | 1514 | } |
1515 | 1515 | } |
1516 | - }else{//PK is NOT auto-increment |
|
1516 | + } else{//PK is NOT auto-increment |
|
1517 | 1517 | //so check if one like it already exists in the db |
1518 | 1518 | if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
1519 | 1519 | if( WP_DEBUG && ! $this->in_entity_map() ){ |
@@ -1528,12 +1528,12 @@ discard block |
||
1528 | 1528 | ); |
1529 | 1529 | } |
1530 | 1530 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1531 | - }else{ |
|
1531 | + } else{ |
|
1532 | 1532 | $results = $this->get_model()->insert($save_cols_n_values); |
1533 | 1533 | $this->_update_cached_related_model_objs_fks(); |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | - }else{//there is NO primary key |
|
1536 | + } else{//there is NO primary key |
|
1537 | 1537 | $already_in_db = false; |
1538 | 1538 | foreach($this->get_model()->unique_indexes() as $index){ |
1539 | 1539 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | if( $already_in_db ){ |
1545 | 1545 | $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
1546 | 1546 | $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
1547 | - }else{ |
|
1547 | + } else{ |
|
1548 | 1548 | $results = $this->get_model()->insert( $save_cols_n_values ); |
1549 | 1549 | } |
1550 | 1550 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | //make sure this has been saved |
1607 | 1607 | if( ! $this->ID()){ |
1608 | 1608 | $id = $this->save(); |
1609 | - }else{ |
|
1609 | + } else{ |
|
1610 | 1610 | $id = $this->ID(); |
1611 | 1611 | } |
1612 | 1612 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
@@ -1625,7 +1625,7 @@ discard block |
||
1625 | 1625 | $this->_add_relation_to($related_model_obj, $relationName); |
1626 | 1626 | $related_model_obj->save_new_cached_related_model_objs(); |
1627 | 1627 | // } |
1628 | - }else{ |
|
1628 | + } else{ |
|
1629 | 1629 | foreach($this->_model_relations[$relationName] as $related_model_obj){ |
1630 | 1630 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1631 | 1631 | //but ONLY if it DOES NOT exist in the DB |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | private static function _get_model_classname( $model_name = null){ |
1775 | 1775 | if(strpos($model_name,"EE_")===0){ |
1776 | 1776 | $model_classname=str_replace("EE_","EEM_",$model_name); |
1777 | - }else{ |
|
1777 | + } else{ |
|
1778 | 1778 | $model_classname = "EEM_".$model_name; |
1779 | 1779 | } |
1780 | 1780 | return $model_classname; |
@@ -1815,7 +1815,7 @@ discard block |
||
1815 | 1815 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1816 | 1816 | if( $this->get_model()->has_primary_key_field() ) { |
1817 | 1817 | return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
1818 | - }else{ |
|
1818 | + } else{ |
|
1819 | 1819 | return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
1820 | 1820 | } |
1821 | 1821 | } |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | //if there are query parameters, forget about caching the related model objects. |
1952 | 1952 | if( $query_params ){ |
1953 | 1953 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1954 | - }else{ |
|
1954 | + } else{ |
|
1955 | 1955 | //did we already cache the result of this query? |
1956 | 1956 | $cached_results = $this->get_all_from_cache($relationName); |
1957 | 1957 | if ( ! $cached_results ){ |
@@ -1961,11 +1961,11 @@ discard block |
||
1961 | 1961 | foreach($related_model_objects as $related_model_object){ |
1962 | 1962 | $this->cache($relationName, $related_model_object); |
1963 | 1963 | } |
1964 | - }else{ |
|
1964 | + } else{ |
|
1965 | 1965 | $related_model_objects = $cached_results; |
1966 | 1966 | } |
1967 | 1967 | } |
1968 | - }else{ |
|
1968 | + } else{ |
|
1969 | 1969 | //this doesn't exist in the DB, so just get the related things from the cache |
1970 | 1970 | $related_model_objects = $this->get_all_from_cache($relationName); |
1971 | 1971 | } |
@@ -2020,18 +2020,18 @@ discard block |
||
2020 | 2020 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2021 | 2021 | if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
2022 | 2022 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2023 | - }else{ |
|
2023 | + } else{ |
|
2024 | 2024 | //first, check if we've already cached the result of this query |
2025 | 2025 | $cached_result = $this->get_one_from_cache($relationName); |
2026 | 2026 | if ( ! $cached_result ){ |
2027 | 2027 | |
2028 | 2028 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2029 | 2029 | $this->cache($relationName,$related_model_object); |
2030 | - }else{ |
|
2030 | + } else{ |
|
2031 | 2031 | $related_model_object = $cached_result; |
2032 | 2032 | } |
2033 | 2033 | } |
2034 | - }else{ |
|
2034 | + } else{ |
|
2035 | 2035 | $related_model_object = null; |
2036 | 2036 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2037 | 2037 | if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
@@ -2063,7 +2063,7 @@ discard block |
||
2063 | 2063 | public function delete_related($relationName,$query_params = array()){ |
2064 | 2064 | if($this->ID()){ |
2065 | 2065 | $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
2066 | - }else{ |
|
2066 | + } else{ |
|
2067 | 2067 | $count = count($this->get_all_from_cache($relationName)); |
2068 | 2068 | $this->clear_cache($relationName,NULL,TRUE); |
2069 | 2069 | } |
@@ -2087,7 +2087,7 @@ discard block |
||
2087 | 2087 | public function delete_related_permanently($relationName,$query_params = array()){ |
2088 | 2088 | if($this->ID()){ |
2089 | 2089 | $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
2090 | - }else{ |
|
2090 | + } else{ |
|
2091 | 2091 | $count = count($this->get_all_from_cache($relationName)); |
2092 | 2092 | } |
2093 | 2093 | $this->clear_cache($relationName,NULL,TRUE); |
@@ -2317,10 +2317,10 @@ discard block |
||
2317 | 2317 | $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2318 | 2318 | if ( $result instanceof EE_Extra_Meta ){ |
2319 | 2319 | return $result->value(); |
2320 | - }else{ |
|
2320 | + } else{ |
|
2321 | 2321 | return $default; |
2322 | 2322 | } |
2323 | - }else{ |
|
2323 | + } else{ |
|
2324 | 2324 | $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2325 | 2325 | if($results){ |
2326 | 2326 | $values = array(); |
@@ -2330,7 +2330,7 @@ discard block |
||
2330 | 2330 | } |
2331 | 2331 | } |
2332 | 2332 | return $values; |
2333 | - }else{ |
|
2333 | + } else{ |
|
2334 | 2334 | return $default; |
2335 | 2335 | } |
2336 | 2336 | } |
@@ -2361,7 +2361,7 @@ discard block |
||
2361 | 2361 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2362 | 2362 | } |
2363 | 2363 | } |
2364 | - }else{ |
|
2364 | + } else{ |
|
2365 | 2365 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2366 | 2366 | foreach($extra_meta_objs as $extra_meta_obj){ |
2367 | 2367 | if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
@@ -2388,7 +2388,7 @@ discard block |
||
2388 | 2388 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2389 | 2389 | if($field_we_can_use){ |
2390 | 2390 | return $this->get($field_we_can_use->get_name()); |
2391 | - }else{ |
|
2391 | + } else{ |
|
2392 | 2392 | $first_few_properties = $this->model_field_array(); |
2393 | 2393 | $first_few_properties = array_slice($first_few_properties,0,3); |
2394 | 2394 | $name_parts = array(); |
@@ -2412,7 +2412,7 @@ discard block |
||
2412 | 2412 | if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
2413 | 2413 | //well, if we looked, did we find it in the entity map? |
2414 | 2414 | return TRUE; |
2415 | - }else{ |
|
2415 | + } else{ |
|
2416 | 2416 | return FALSE; |
2417 | 2417 | } |
2418 | 2418 | } |
@@ -2426,7 +2426,7 @@ discard block |
||
2426 | 2426 | public function refresh_from_db(){ |
2427 | 2427 | if( $this->ID() && $this->in_entity_map() ){ |
2428 | 2428 | $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
2429 | - }else{ |
|
2429 | + } else{ |
|
2430 | 2430 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2431 | 2431 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2432 | 2432 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * ------------------------------------------------------------------------ |
25 | 25 | */ |
26 | 26 | |
27 | -abstract class EE_Base_Class{ |
|
27 | +abstract class EE_Base_Class { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * This is an array of the original properties and values provided during construction |
@@ -117,59 +117,59 @@ discard block |
||
117 | 117 | * @throws EE_Error |
118 | 118 | * @return \EE_Base_Class |
119 | 119 | */ |
120 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){ |
|
120 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) { |
|
121 | 121 | |
122 | - $className=get_class($this); |
|
122 | + $className = get_class($this); |
|
123 | 123 | |
124 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
125 | - $model=$this->get_model(); |
|
126 | - $model_fields = $model->field_settings( FALSE ); |
|
124 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
125 | + $model = $this->get_model(); |
|
126 | + $model_fields = $model->field_settings(FALSE); |
|
127 | 127 | // ensure $fieldValues is an array |
128 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
128 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
129 | 129 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
130 | 130 | // verify client code has not passed any invalid field names |
131 | - foreach($fieldValues as $field_name=> $field_value){ |
|
132 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
133 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
131 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
132 | + if ( ! isset($model_fields[$field_name])) { |
|
133 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
137 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
137 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
138 | 138 | |
139 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
139 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
140 | 140 | $this->_dt_frmt = $date_formats[0]; |
141 | 141 | $this->_tm_frmt = $date_formats[1]; |
142 | 142 | } else { |
143 | 143 | //set default formats for date and time |
144 | - $this->_dt_frmt = get_option( 'date_format' ); |
|
145 | - $this->_tm_frmt = get_option( 'time_format' ); |
|
144 | + $this->_dt_frmt = get_option('date_format'); |
|
145 | + $this->_tm_frmt = get_option('time_format'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | //if db model is instantiating |
149 | - if ( $bydb ){ |
|
149 | + if ($bydb) { |
|
150 | 150 | //client code has indicated these field values are from the database |
151 | - foreach( $model_fields as $fieldName => $field ){ |
|
152 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
151 | + foreach ($model_fields as $fieldName => $field) { |
|
152 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | 155 | //we're constructing a brand |
156 | 156 | //new instance of the model object. Generally, this means we'll need to do more field validation |
157 | - foreach( $model_fields as $fieldName => $field ){ |
|
158 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
157 | + foreach ($model_fields as $fieldName => $field) { |
|
158 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | 162 | //remember what values were passed to this constructor |
163 | 163 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
164 | 164 | //remember in entity mapper |
165 | - if( ! $bydb && $model->has_primary_key_field() && $this->ID() ){ |
|
165 | + if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) { |
|
166 | 166 | $model->add_to_entity_map($this); |
167 | 167 | } |
168 | 168 | //setup all the relations |
169 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
170 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
169 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
170 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
171 | 171 | $this->_model_relations[$relation_name] = NULL; |
172 | - }else{ |
|
172 | + } else { |
|
173 | 173 | $this->_model_relations[$relation_name] = array(); |
174 | 174 | } |
175 | 175 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * Action done at the end of each model object construction |
178 | 178 | * @param EE_Base_Class $this the model object just created |
179 | 179 | */ |
180 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
180 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param boolean $allow_persist |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - public function set_allow_persist( $allow_persist ) { |
|
200 | + public function set_allow_persist($allow_persist) { |
|
201 | 201 | return $this->_allow_persist = $allow_persist; |
202 | 202 | } |
203 | 203 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * @return mixed|null |
212 | 212 | * @throws \EE_Error |
213 | 213 | */ |
214 | - public function get_original( $field_name ){ |
|
215 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
216 | - $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
|
217 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
218 | - }else{ |
|
214 | + public function get_original($field_name) { |
|
215 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
216 | + $field_settings = $this->get_model()->field_settings_for($field_name)) { |
|
217 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
218 | + } else { |
|
219 | 219 | return NULL; |
220 | 220 | } |
221 | 221 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param EE_Base_Class $obj |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public function get_class($obj){ |
|
228 | + public function get_class($obj) { |
|
229 | 229 | return get_class($obj); |
230 | 230 | } |
231 | 231 | |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | * @param bool $use_default |
241 | 241 | * @throws \EE_Error |
242 | 242 | */ |
243 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
244 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
245 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
243 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
244 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
245 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
246 | 246 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
247 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
248 | - $field_obj->set_timezone( $this->_timezone ); |
|
249 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
250 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
247 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
248 | + $field_obj->set_timezone($this->_timezone); |
|
249 | + $field_obj->set_date_format($this->_dt_frmt); |
|
250 | + $field_obj->set_time_format($this->_tm_frmt); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
254 | 254 | //should the value be null? |
255 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
255 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
256 | 256 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
257 | 257 | |
258 | 258 | /** |
@@ -264,26 +264,26 @@ discard block |
||
264 | 264 | */ |
265 | 265 | if ( |
266 | 266 | $field_obj instanceof EE_Datetime_Field |
267 | - && $this->_fields[ $field_name ] !== null |
|
267 | + && $this->_fields[$field_name] !== null |
|
268 | 268 | && ! $this->_fields[$field_name] instanceof DateTime |
269 | 269 | ) { |
270 | - empty( $this->_fields[$field_name] ) |
|
271 | - ? $this->set( $field_name, time() ) |
|
272 | - : $this->set( $field_name, $this->_fields[$field_name] ); |
|
270 | + empty($this->_fields[$field_name]) |
|
271 | + ? $this->set($field_name, time()) |
|
272 | + : $this->set($field_name, $this->_fields[$field_name]); |
|
273 | 273 | } |
274 | 274 | |
275 | - }else{ |
|
275 | + } else { |
|
276 | 276 | $this->_fields[$field_name] = $holder_of_value; |
277 | 277 | } |
278 | 278 | |
279 | 279 | //if we're not in the constructor... |
280 | 280 | //now check if what we set was a primary key |
281 | - if( |
|
281 | + if ( |
|
282 | 282 | //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
283 | 283 | $this->_props_n_values_provided_in_constructor |
284 | 284 | && $field_value |
285 | - && $field_name === self::_get_primary_key_name( get_class( $this ) ) |
|
286 | - ){ |
|
285 | + && $field_name === self::_get_primary_key_name(get_class($this)) |
|
286 | + ) { |
|
287 | 287 | //if so, we want all this object's fields to be filled either with |
288 | 288 | //what we've explicitly set on this model |
289 | 289 | //or what we have in the db |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | $fields_on_model = self::_get_model(get_class($this))->field_settings(); |
292 | 292 | |
293 | 293 | $obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value); |
294 | - foreach($fields_on_model as $field_obj){ |
|
295 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
296 | - && $field_obj->get_name() !== $field_name ){ |
|
294 | + foreach ($fields_on_model as $field_obj) { |
|
295 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
296 | + && $field_obj->get_name() !== $field_name) { |
|
297 | 297 | |
298 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
298 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | //oh this model object has an ID? well make sure its in the entity mapper |
302 | 302 | $this->get_model()->add_to_entity_map($this); |
303 | 303 | } |
304 | 304 | //let's unset any cache for this field_name from the $_cached_properties property. |
305 | - $this->_clear_cached_property( $field_name ); |
|
306 | - }else{ |
|
307 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
305 | + $this->_clear_cached_property($field_name); |
|
306 | + } else { |
|
307 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | } |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
325 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
326 | - $this->set( $field_name, $field_value ); |
|
324 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
325 | + if ($this->get_model()->has_field($field_name)) { |
|
326 | + $this->set($field_name, $field_value); |
|
327 | 327 | return true; |
328 | 328 | } else { |
329 | 329 | //ensure this object is saved first so that extra meta can be properly related. |
330 | 330 | $this->save(); |
331 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
331 | + return $this->update_extra_meta($field_name, $field_value); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | * @return mixed|null value for the field if found. null if not found. |
350 | 350 | * @throws \EE_Error |
351 | 351 | */ |
352 | - public function get_field_or_extra_meta( $field_name ) { |
|
353 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
354 | - $column_value = $this->get( $field_name ); |
|
352 | + public function get_field_or_extra_meta($field_name) { |
|
353 | + if ($this->get_model()->has_field($field_name)) { |
|
354 | + $column_value = $this->get($field_name); |
|
355 | 355 | } else { |
356 | 356 | //This isn't a column in the main table, let's see if it is in the extra meta. |
357 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
357 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
358 | 358 | } |
359 | 359 | return $column_value; |
360 | 360 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * @return void |
371 | 371 | * @throws \EE_Error |
372 | 372 | */ |
373 | - public function set_timezone( $timezone = '' ) { |
|
374 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
373 | + public function set_timezone($timezone = '') { |
|
374 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
375 | 375 | //make sure we clear all cached properties because they won't be relevant now |
376 | 376 | $this->_clear_cached_properties(); |
377 | 377 | |
378 | 378 | //make sure we update field settings and the date for all EE_Datetime_Fields |
379 | - $model_fields = $this->get_model()->field_settings( false ); |
|
380 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
381 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
382 | - $field_obj->set_timezone( $this->_timezone ); |
|
383 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
384 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
379 | + $model_fields = $this->get_model()->field_settings(false); |
|
380 | + foreach ($model_fields as $field_name => $field_obj) { |
|
381 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
382 | + $field_obj->set_timezone($this->_timezone); |
|
383 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
384 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @param string $format should be a format recognizable by PHP date() functions. |
412 | 412 | */ |
413 | - public function set_date_format( $format ) { |
|
413 | + public function set_date_format($format) { |
|
414 | 414 | $this->_dt_frmt = $format; |
415 | 415 | //clear cached_properties because they won't be relevant now. |
416 | 416 | $this->_clear_cached_properties(); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @since 4.6 |
427 | 427 | * @param string $format should be a format recognizable by PHP date() functions. |
428 | 428 | */ |
429 | - public function set_time_format( $format ) { |
|
429 | + public function set_time_format($format) { |
|
430 | 430 | $this->_tm_frmt = $format; |
431 | 431 | //clear cached_properties because they won't be relevant now. |
432 | 432 | $this->_clear_cached_properties(); |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return mixed string|array |
445 | 445 | */ |
446 | - public function get_format( $full = true ) { |
|
447 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
446 | + public function get_format($full = true) { |
|
447 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -462,17 +462,17 @@ discard block |
||
462 | 462 | * @throws EE_Error |
463 | 463 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
464 | 464 | */ |
465 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
465 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
466 | 466 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
467 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
467 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
468 | 468 | return FALSE; |
469 | 469 | } |
470 | 470 | // also get "how" the object is related, or throw an error |
471 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
472 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
471 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
472 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
473 | 473 | } |
474 | 474 | // how many things are related ? |
475 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
475 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
476 | 476 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
477 | 477 | // so for these model objects just set it to be cached |
478 | 478 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -480,26 +480,26 @@ discard block |
||
480 | 480 | } else { |
481 | 481 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
482 | 482 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
483 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
483 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
484 | 484 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
485 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
485 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
486 | 486 | } |
487 | 487 | // first check for a cache_id which is normally empty |
488 | - if ( ! empty( $cache_id )) { |
|
488 | + if ( ! empty($cache_id)) { |
|
489 | 489 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
490 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
490 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
491 | 491 | $return = $cache_id; |
492 | - } elseif ( $object_to_cache->ID() ) { |
|
492 | + } elseif ($object_to_cache->ID()) { |
|
493 | 493 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
494 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
494 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
495 | 495 | $return = $object_to_cache->ID(); |
496 | 496 | } else { |
497 | 497 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
498 | 498 | $this->_model_relations[$relationName][] = $object_to_cache; |
499 | 499 | // move the internal pointer to the end of the array |
500 | - end( $this->_model_relations[$relationName] ); |
|
500 | + end($this->_model_relations[$relationName]); |
|
501 | 501 | // and grab the key so that we can return it |
502 | - $return = key( $this->_model_relations[$relationName] ); |
|
502 | + $return = key($this->_model_relations[$relationName]); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | } |
@@ -518,11 +518,11 @@ discard block |
||
518 | 518 | * @return void |
519 | 519 | * @throws \EE_Error |
520 | 520 | */ |
521 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
521 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
522 | 522 | //first make sure this property exists |
523 | 523 | $this->get_model()->field_settings_for($fieldname); |
524 | 524 | |
525 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
525 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
526 | 526 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
527 | 527 | } |
528 | 528 | |
@@ -543,36 +543,36 @@ discard block |
||
543 | 543 | * @return mixed whatever the value for the property is we're retrieving |
544 | 544 | * @throws \EE_Error |
545 | 545 | */ |
546 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
546 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
547 | 547 | //verify the field exists |
548 | 548 | $this->get_model()->field_settings_for($fieldname); |
549 | 549 | |
550 | 550 | $cache_type = $pretty ? 'pretty' : 'standard'; |
551 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
551 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
552 | 552 | |
553 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
553 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
554 | 554 | return $this->_cached_properties[$fieldname][$cache_type]; |
555 | 555 | } |
556 | 556 | |
557 | 557 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
558 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
558 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
559 | 559 | /** |
560 | 560 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
561 | 561 | * formats are correct. |
562 | 562 | */ |
563 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
564 | - $field_obj->set_timezone( $this->_timezone ); |
|
565 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
566 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
563 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
564 | + $field_obj->set_timezone($this->_timezone); |
|
565 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
566 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
567 | 567 | } |
568 | 568 | |
569 | - if( ! isset($this->_fields[$fieldname])){ |
|
569 | + if ( ! isset($this->_fields[$fieldname])) { |
|
570 | 570 | $this->_fields[$fieldname] = NULL; |
571 | 571 | } |
572 | 572 | $value = $pretty |
573 | 573 | ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) |
574 | - : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
575 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
574 | + : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
575 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
576 | 576 | return $value; |
577 | 577 | } |
578 | 578 | return null; |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
599 | 599 | * @return void |
600 | 600 | */ |
601 | - protected function _clear_cached_property( $property_name ) { |
|
602 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
603 | - unset( $this->_cached_properties[ $property_name ] ); |
|
601 | + protected function _clear_cached_property($property_name) { |
|
602 | + if (isset($this->_cached_properties[$property_name])) { |
|
603 | + unset($this->_cached_properties[$property_name]); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
@@ -614,12 +614,12 @@ discard block |
||
614 | 614 | * @return EE_Base_Class |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
617 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
618 | 618 | $other_model_instance = self::_get_model_instance_with_name( |
619 | - self::_get_model_classname( $model_name ), |
|
619 | + self::_get_model_classname($model_name), |
|
620 | 620 | $this->_timezone |
621 | 621 | ); |
622 | - return $other_model_instance->ensure_is_obj( $object_or_id ); |
|
622 | + return $other_model_instance->ensure_is_obj($object_or_id); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | |
@@ -636,32 +636,32 @@ discard block |
||
636 | 636 | * @throws EE_Error |
637 | 637 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
638 | 638 | */ |
639 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
639 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
640 | 640 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
641 | 641 | $index_in_cache = ''; |
642 | - if( ! $relationship_to_model){ |
|
642 | + if ( ! $relationship_to_model) { |
|
643 | 643 | throw new EE_Error( |
644 | 644 | sprintf( |
645 | - __( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ), |
|
645 | + __("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), |
|
646 | 646 | $relationName, |
647 | - get_class( $this ) |
|
647 | + get_class($this) |
|
648 | 648 | ) |
649 | 649 | ); |
650 | 650 | } |
651 | - if($clear_all){ |
|
651 | + if ($clear_all) { |
|
652 | 652 | $obj_removed = true; |
653 | 653 | $this->_model_relations[$relationName] = null; |
654 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
654 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
655 | 655 | $obj_removed = $this->_model_relations[$relationName]; |
656 | 656 | $this->_model_relations[$relationName] = null; |
657 | - }else{ |
|
658 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
657 | + } else { |
|
658 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
659 | 659 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
660 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
660 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
661 | 661 | $index_found_at = NULL; |
662 | 662 | //find this object in the array even though it has a different key |
663 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
664 | - if( |
|
663 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
664 | + if ( |
|
665 | 665 | $obj instanceof EE_Base_Class |
666 | 666 | && ( |
667 | 667 | $obj == $object_to_remove_or_index_into_array |
@@ -672,34 +672,34 @@ discard block |
||
672 | 672 | break; |
673 | 673 | } |
674 | 674 | } |
675 | - if($index_found_at){ |
|
675 | + if ($index_found_at) { |
|
676 | 676 | $index_in_cache = $index_found_at; |
677 | - }else{ |
|
677 | + } else { |
|
678 | 678 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
679 | 679 | //if it wasn't in it to begin with. So we're done |
680 | 680 | return $object_to_remove_or_index_into_array; |
681 | 681 | } |
682 | 682 | } |
683 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
683 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
684 | 684 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
685 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
686 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
685 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
686 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
687 | 687 | $index_in_cache = $index; |
688 | 688 | } |
689 | 689 | } |
690 | - }else{ |
|
690 | + } else { |
|
691 | 691 | $index_in_cache = $object_to_remove_or_index_into_array; |
692 | 692 | } |
693 | 693 | //supposedly we've found it. But it could just be that the client code |
694 | 694 | //provided a bad index/object |
695 | 695 | if ( |
696 | 696 | isset( |
697 | - $this->_model_relations[ $relationName ], |
|
698 | - $this->_model_relations[ $relationName ][ $index_in_cache ] |
|
697 | + $this->_model_relations[$relationName], |
|
698 | + $this->_model_relations[$relationName][$index_in_cache] |
|
699 | 699 | ) |
700 | 700 | ) { |
701 | - $obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ]; |
|
702 | - unset( $this->_model_relations[ $relationName ][ $index_in_cache ] ); |
|
701 | + $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
|
702 | + unset($this->_model_relations[$relationName][$index_in_cache]); |
|
703 | 703 | } else { |
704 | 704 | //that thing was never cached anyways. |
705 | 705 | $obj_removed = null; |
@@ -720,24 +720,24 @@ discard block |
||
720 | 720 | * @return boolean TRUE on success, FALSE on fail |
721 | 721 | * @throws \EE_Error |
722 | 722 | */ |
723 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
723 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
724 | 724 | // verify that incoming object is of the correct type |
725 | - $obj_class = 'EE_' . $relationName; |
|
726 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
725 | + $obj_class = 'EE_'.$relationName; |
|
726 | + if ($newly_saved_object instanceof $obj_class) { |
|
727 | 727 | /* @type EE_Base_Class $newly_saved_object*/ |
728 | 728 | // now get the type of relation |
729 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
729 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
730 | 730 | // if this is a 1:1 relationship |
731 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
731 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
732 | 732 | // then just replace the cached object with the newly saved object |
733 | 733 | $this->_model_relations[$relationName] = $newly_saved_object; |
734 | 734 | return TRUE; |
735 | 735 | // or if it's some kind of sordid feral polyamorous relationship... |
736 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
736 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
737 | 737 | // then remove the current cached item |
738 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
738 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
739 | 739 | // and cache the newly saved object using it's new ID |
740 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
740 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
741 | 741 | return TRUE; |
742 | 742 | } |
743 | 743 | } |
@@ -753,11 +753,11 @@ discard block |
||
753 | 753 | * @param string $relationName |
754 | 754 | * @return EE_Base_Class |
755 | 755 | */ |
756 | - public function get_one_from_cache($relationName){ |
|
757 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
758 | - if(is_array($cached_array_or_object)){ |
|
756 | + public function get_one_from_cache($relationName) { |
|
757 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
758 | + if (is_array($cached_array_or_object)) { |
|
759 | 759 | return array_shift($cached_array_or_object); |
760 | - }else{ |
|
760 | + } else { |
|
761 | 761 | return $cached_array_or_object; |
762 | 762 | } |
763 | 763 | } |
@@ -772,23 +772,23 @@ discard block |
||
772 | 772 | * @throws \EE_Error |
773 | 773 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
774 | 774 | */ |
775 | - public function get_all_from_cache($relationName){ |
|
776 | - $objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
775 | + public function get_all_from_cache($relationName) { |
|
776 | + $objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
777 | 777 | // if the result is not an array, but exists, make it an array |
778 | - $objects = is_array( $objects ) ? $objects : array( $objects ); |
|
778 | + $objects = is_array($objects) ? $objects : array($objects); |
|
779 | 779 | //bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143 |
780 | 780 | //basically, if this model object was stored in the session, and these cached model objects |
781 | 781 | //already have IDs, let's make sure they're in their model's entity mapper |
782 | 782 | //otherwise we will have duplicates next time we call |
783 | 783 | // EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
784 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
785 | - foreach( $objects as $model_object ){ |
|
786 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
784 | + $model = EE_Registry::instance()->load_model($relationName); |
|
785 | + foreach ($objects as $model_object) { |
|
786 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
787 | 787 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
788 | - if( $model_object->ID() ){ |
|
789 | - $model->add_to_entity_map( $model_object ); |
|
788 | + if ($model_object->ID()) { |
|
789 | + $model->add_to_entity_map($model_object); |
|
790 | 790 | } |
791 | - }else{ |
|
791 | + } else { |
|
792 | 792 | throw new EE_Error( |
793 | 793 | sprintf( |
794 | 794 | __( |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | 'event_espresso' |
797 | 797 | ), |
798 | 798 | $relationName, |
799 | - gettype( $model_object ) |
|
799 | + gettype($model_object) |
|
800 | 800 | ) |
801 | 801 | ); |
802 | 802 | } |
@@ -818,15 +818,15 @@ discard block |
||
818 | 818 | * @return array|EE_Base_Class[] |
819 | 819 | * @throws \EE_Error |
820 | 820 | */ |
821 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
822 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
821 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
822 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
823 | 823 | ? $this->get_model()->get_primary_key_field()->get_name() |
824 | 824 | : $field_to_order_by; |
825 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
826 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
825 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
826 | + if (empty($field) || empty($current_value)) { |
|
827 | 827 | return array(); |
828 | 828 | } |
829 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
829 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -843,15 +843,15 @@ discard block |
||
843 | 843 | * @return array|EE_Base_Class[] |
844 | 844 | * @throws \EE_Error |
845 | 845 | */ |
846 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
847 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
846 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
847 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
848 | 848 | ? $this->get_model()->get_primary_key_field()->get_name() |
849 | 849 | : $field_to_order_by; |
850 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
851 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
850 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
851 | + if (empty($field) || empty($current_value)) { |
|
852 | 852 | return array(); |
853 | 853 | } |
854 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
854 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | |
@@ -867,15 +867,15 @@ discard block |
||
867 | 867 | * @return array|EE_Base_Class |
868 | 868 | * @throws \EE_Error |
869 | 869 | */ |
870 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
871 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
870 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
871 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
872 | 872 | ? $this->get_model()->get_primary_key_field()->get_name() |
873 | 873 | : $field_to_order_by; |
874 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
875 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
874 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
875 | + if (empty($field) || empty($current_value)) { |
|
876 | 876 | return array(); |
877 | 877 | } |
878 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
878 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | |
@@ -891,15 +891,15 @@ discard block |
||
891 | 891 | * @return array|EE_Base_Class |
892 | 892 | * @throws \EE_Error |
893 | 893 | */ |
894 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
895 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
894 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
895 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
896 | 896 | ? $this->get_model()->get_primary_key_field()->get_name() |
897 | 897 | : $field_to_order_by; |
898 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
899 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
898 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
899 | + if (empty($field) || empty($current_value)) { |
|
900 | 900 | return array(); |
901 | 901 | } |
902 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
902 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | |
@@ -912,25 +912,25 @@ discard block |
||
912 | 912 | * @param mixed $field_value_from_db |
913 | 913 | * @throws \EE_Error |
914 | 914 | */ |
915 | - public function set_from_db($field_name,$field_value_from_db){ |
|
915 | + public function set_from_db($field_name, $field_value_from_db) { |
|
916 | 916 | $field_obj = $this->get_model()->field_settings_for($field_name); |
917 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
917 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
918 | 918 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
919 | 919 | //eg, a CPT model object could have an entry in the posts table, but no |
920 | 920 | //entry in the meta table. Meaning that all its columns in the meta table |
921 | 921 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
922 | - if($field_value_from_db === NULL ){ |
|
923 | - if( $field_obj->is_nullable()){ |
|
922 | + if ($field_value_from_db === NULL) { |
|
923 | + if ($field_obj->is_nullable()) { |
|
924 | 924 | //if the field allows nulls, then let it be null |
925 | 925 | $field_value = NULL; |
926 | - }else{ |
|
926 | + } else { |
|
927 | 927 | $field_value = $field_obj->get_default_value(); |
928 | 928 | } |
929 | - }else{ |
|
930 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
929 | + } else { |
|
930 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
931 | 931 | } |
932 | 932 | $this->_fields[$field_name] = $field_value; |
933 | - $this->_clear_cached_property( $field_name ); |
|
933 | + $this->_clear_cached_property($field_name); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | * @return mixed |
947 | 947 | * @throws \EE_Error |
948 | 948 | */ |
949 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
950 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
949 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
950 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | |
@@ -980,10 +980,10 @@ discard block |
||
980 | 980 | * just null is returned (because that indicates that likely |
981 | 981 | * this field is nullable). |
982 | 982 | */ |
983 | - public function get_DateTime_object( $field_name ) { |
|
984 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
983 | + public function get_DateTime_object($field_name) { |
|
984 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
985 | 985 | |
986 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
986 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
987 | 987 | EE_Error::add_error( |
988 | 988 | sprintf( |
989 | 989 | __( |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | * @return void |
1016 | 1016 | * @throws \EE_Error |
1017 | 1017 | */ |
1018 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
1018 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
1019 | 1019 | echo $this->get_pretty($field_name, $extra_cache_ref); |
1020 | 1020 | } |
1021 | 1021 | |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @return void |
1030 | 1030 | * @throws \EE_Error |
1031 | 1031 | */ |
1032 | - public function f($field_name){ |
|
1033 | - $this->e($field_name,'form_input'); |
|
1032 | + public function f($field_name) { |
|
1033 | + $this->e($field_name, 'form_input'); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | * @return mixed |
1044 | 1044 | * @throws \EE_Error |
1045 | 1045 | */ |
1046 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
1047 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
1046 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
1047 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | |
@@ -1062,36 +1062,36 @@ discard block |
||
1062 | 1062 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
1063 | 1063 | * @throws \EE_Error |
1064 | 1064 | */ |
1065 | - protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
|
1065 | + protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { |
|
1066 | 1066 | |
1067 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1067 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1068 | 1068 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1069 | 1069 | |
1070 | 1070 | //validate field for datetime and returns field settings if valid. |
1071 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1071 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1072 | 1072 | |
1073 | 1073 | //clear cached property if either formats are not null. |
1074 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1075 | - $this->_clear_cached_property( $field_name ); |
|
1074 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1075 | + $this->_clear_cached_property($field_name); |
|
1076 | 1076 | //reset format properties because they are used in get() |
1077 | 1077 | $this->_dt_frmt = $in_dt_frmt; |
1078 | 1078 | $this->_tm_frmt = $in_tm_frmt; |
1079 | 1079 | } |
1080 | - if ( $echo ) { |
|
1081 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1080 | + if ($echo) { |
|
1081 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1082 | 1082 | } else { |
1083 | - $field->set_date_format( $in_dt_frmt ); |
|
1083 | + $field->set_date_format($in_dt_frmt); |
|
1084 | 1084 | } |
1085 | - if ( $echo ) { |
|
1086 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1085 | + if ($echo) { |
|
1086 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1087 | 1087 | } else { |
1088 | - $field->set_time_format( $in_tm_frmt ); |
|
1088 | + $field->set_time_format($in_tm_frmt); |
|
1089 | 1089 | } |
1090 | 1090 | //set timezone in field object |
1091 | - $field->set_timezone( $this->_timezone ); |
|
1091 | + $field->set_timezone($this->_timezone); |
|
1092 | 1092 | |
1093 | 1093 | //set the output returned |
1094 | - switch ( $date_or_time ) { |
|
1094 | + switch ($date_or_time) { |
|
1095 | 1095 | |
1096 | 1096 | case 'D' : |
1097 | 1097 | $field->set_date_time_output('date'); |
@@ -1106,11 +1106,11 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
1109 | - if ( $echo ) { |
|
1110 | - $this->e( $field_name, $date_or_time ); |
|
1109 | + if ($echo) { |
|
1110 | + $this->e($field_name, $date_or_time); |
|
1111 | 1111 | return ''; |
1112 | 1112 | } |
1113 | - return $this->get( $field_name, $date_or_time ); |
|
1113 | + return $this->get($field_name, $date_or_time); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @return string datetime value formatted |
1124 | 1124 | * @throws \EE_Error |
1125 | 1125 | */ |
1126 | - public function get_date( $field_name, $format = NULL ) { |
|
1127 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1126 | + public function get_date($field_name, $format = NULL) { |
|
1127 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | |
@@ -1134,8 +1134,8 @@ discard block |
||
1134 | 1134 | * @param null $format |
1135 | 1135 | * @throws \EE_Error |
1136 | 1136 | */ |
1137 | - public function e_date( $field_name, $format = NULL ) { |
|
1138 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1137 | + public function e_date($field_name, $format = NULL) { |
|
1138 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | * @return string datetime value formatted |
1149 | 1149 | * @throws \EE_Error |
1150 | 1150 | */ |
1151 | - public function get_time( $field_name, $format = NULL ) { |
|
1152 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1151 | + public function get_time($field_name, $format = NULL) { |
|
1152 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | |
@@ -1159,8 +1159,8 @@ discard block |
||
1159 | 1159 | * @param null $format |
1160 | 1160 | * @throws \EE_Error |
1161 | 1161 | */ |
1162 | - public function e_time( $field_name, $format = NULL ) { |
|
1163 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1162 | + public function e_time($field_name, $format = NULL) { |
|
1163 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
@@ -1174,8 +1174,8 @@ discard block |
||
1174 | 1174 | * @return string datetime value formatted |
1175 | 1175 | * @throws \EE_Error |
1176 | 1176 | */ |
1177 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1178 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1177 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1178 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
@@ -1186,8 +1186,8 @@ discard block |
||
1186 | 1186 | * @param null $tm_frmt |
1187 | 1187 | * @throws \EE_Error |
1188 | 1188 | */ |
1189 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1190 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1189 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1190 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | |
@@ -1201,11 +1201,11 @@ discard block |
||
1201 | 1201 | * @throws \EE_Error |
1202 | 1202 | * field name. |
1203 | 1203 | */ |
1204 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1205 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1204 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1205 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1206 | 1206 | return date_i18n( |
1207 | 1207 | $format, |
1208 | - EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) |
|
1208 | + EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone) |
|
1209 | 1209 | ); |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1218,14 +1218,14 @@ discard block |
||
1218 | 1218 | * @throws EE_Error |
1219 | 1219 | * @return EE_Datetime_Field |
1220 | 1220 | */ |
1221 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1221 | + protected function _get_dtt_field_settings($field_name) { |
|
1222 | 1222 | $field = $this->get_model()->field_settings_for($field_name); |
1223 | 1223 | |
1224 | 1224 | //check if field is dtt |
1225 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1225 | + if ($field instanceof EE_Datetime_Field) { |
|
1226 | 1226 | return $field; |
1227 | 1227 | } else { |
1228 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1228 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1229 | 1229 | } |
1230 | 1230 | } |
1231 | 1231 | |
@@ -1246,8 +1246,8 @@ discard block |
||
1246 | 1246 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1247 | 1247 | * @throws \EE_Error |
1248 | 1248 | */ |
1249 | - protected function _set_time_for( $time, $fieldname ) { |
|
1250 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1249 | + protected function _set_time_for($time, $fieldname) { |
|
1250 | + $this->_set_date_time('T', $time, $fieldname); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | |
@@ -1260,8 +1260,8 @@ discard block |
||
1260 | 1260 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1261 | 1261 | * @throws \EE_Error |
1262 | 1262 | */ |
1263 | - protected function _set_date_for( $date, $fieldname ) { |
|
1264 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1263 | + protected function _set_date_for($date, $fieldname) { |
|
1264 | + $this->_set_date_time('D', $date, $fieldname); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | |
@@ -1275,26 +1275,26 @@ discard block |
||
1275 | 1275 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1276 | 1276 | * @throws \EE_Error |
1277 | 1277 | */ |
1278 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1279 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1280 | - $field->set_timezone( $this->_timezone ); |
|
1281 | - $field->set_date_format( $this->_dt_frmt ); |
|
1282 | - $field->set_time_format( $this->_tm_frmt ); |
|
1283 | - switch ( $what ) { |
|
1278 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1279 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1280 | + $field->set_timezone($this->_timezone); |
|
1281 | + $field->set_date_format($this->_dt_frmt); |
|
1282 | + $field->set_time_format($this->_tm_frmt); |
|
1283 | + switch ($what) { |
|
1284 | 1284 | case 'T' : |
1285 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time( |
|
1285 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( |
|
1286 | 1286 | $datetime_value, |
1287 | - $this->_fields[ $fieldname ] |
|
1287 | + $this->_fields[$fieldname] |
|
1288 | 1288 | ); |
1289 | 1289 | break; |
1290 | 1290 | case 'D' : |
1291 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date( |
|
1291 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( |
|
1292 | 1292 | $datetime_value, |
1293 | - $this->_fields[ $fieldname ] |
|
1293 | + $this->_fields[$fieldname] |
|
1294 | 1294 | ); |
1295 | 1295 | break; |
1296 | 1296 | case 'B' : |
1297 | - $this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value ); |
|
1297 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1298 | 1298 | break; |
1299 | 1299 | } |
1300 | 1300 | $this->_clear_cached_property($fieldname); |
@@ -1316,17 +1316,17 @@ discard block |
||
1316 | 1316 | * @throws EE_Error |
1317 | 1317 | * @return string timestamp |
1318 | 1318 | */ |
1319 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1319 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1320 | 1320 | $timezone = EEH_DTT_Helper::get_timezone(); |
1321 | - if ( $timezone === $this->_timezone ) { |
|
1321 | + if ($timezone === $this->_timezone) { |
|
1322 | 1322 | return ''; |
1323 | 1323 | } |
1324 | 1324 | $original_timezone = $this->_timezone; |
1325 | - $this->set_timezone( $timezone ); |
|
1325 | + $this->set_timezone($timezone); |
|
1326 | 1326 | |
1327 | 1327 | $fn = (array) $field_name; |
1328 | - $args = array_merge( $fn, (array) $args ); |
|
1329 | - if ( ! method_exists( $this, $callback ) ) { |
|
1328 | + $args = array_merge($fn, (array) $args); |
|
1329 | + if ( ! method_exists($this, $callback)) { |
|
1330 | 1330 | throw new EE_Error( |
1331 | 1331 | sprintf( |
1332 | 1332 | __( |
@@ -1338,9 +1338,9 @@ discard block |
||
1338 | 1338 | ); |
1339 | 1339 | } |
1340 | 1340 | $args = (array) $args; |
1341 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1341 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1342 | 1342 | |
1343 | - $this->set_timezone( $original_timezone ); |
|
1343 | + $this->set_timezone($original_timezone); |
|
1344 | 1344 | return $return; |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | * @return boolean | int |
1355 | 1355 | * @throws \EE_Error |
1356 | 1356 | */ |
1357 | - public function delete(){ |
|
1357 | + public function delete() { |
|
1358 | 1358 | /** |
1359 | 1359 | * Called just before the `EE_Base_Class::_delete` method call. |
1360 | 1360 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | * |
1364 | 1364 | * @param EE_Base_Class $model_object about to be 'deleted' |
1365 | 1365 | */ |
1366 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1366 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1367 | 1367 | $result = $this->_delete(); |
1368 | 1368 | /** |
1369 | 1369 | * Called just after the `EE_Base_Class::_delete` method call. |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | * @param EE_Base_Class $model_object that was just 'deleted' |
1374 | 1374 | * @param boolean $result |
1375 | 1375 | */ |
1376 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1376 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1377 | 1377 | return $result; |
1378 | 1378 | } |
1379 | 1379 | |
@@ -1399,22 +1399,22 @@ discard block |
||
1399 | 1399 | * @return bool | int |
1400 | 1400 | * @throws \EE_Error |
1401 | 1401 | */ |
1402 | - public function delete_permanently(){ |
|
1402 | + public function delete_permanently() { |
|
1403 | 1403 | /** |
1404 | 1404 | * Called just before HARD deleting a model object |
1405 | 1405 | * |
1406 | 1406 | * @param EE_Base_Class $model_object about to be 'deleted' |
1407 | 1407 | */ |
1408 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1409 | - $model=$this->get_model(); |
|
1410 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
1408 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1409 | + $model = $this->get_model(); |
|
1410 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
1411 | 1411 | $this->refresh_cache_of_related_objects(); |
1412 | 1412 | /** |
1413 | 1413 | * Called just after HARD deleting a model object |
1414 | 1414 | * @param EE_Base_Class $model_object that was just 'deleted' |
1415 | 1415 | * @param boolean $result |
1416 | 1416 | */ |
1417 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1417 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1418 | 1418 | return $result; |
1419 | 1419 | } |
1420 | 1420 | |
@@ -1427,18 +1427,18 @@ discard block |
||
1427 | 1427 | * @throws \EE_Error |
1428 | 1428 | */ |
1429 | 1429 | public function refresh_cache_of_related_objects() { |
1430 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1431 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1432 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1433 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1430 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1431 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1432 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1433 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1434 | 1434 | //this relation only stores a single model object, not an array |
1435 | 1435 | //but let's make it consistent |
1436 | - $related_objects = array( $related_objects ); |
|
1436 | + $related_objects = array($related_objects); |
|
1437 | 1437 | } |
1438 | - foreach( $related_objects as $related_object ) { |
|
1438 | + foreach ($related_objects as $related_object) { |
|
1439 | 1439 | //only refresh their cache if they're in memory |
1440 | - if( $related_object instanceof EE_Base_Class ) { |
|
1441 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1440 | + if ($related_object instanceof EE_Base_Class) { |
|
1441 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1442 | 1442 | } |
1443 | 1443 | } |
1444 | 1444 | } |
@@ -1458,17 +1458,17 @@ discard block |
||
1458 | 1458 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1459 | 1459 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1460 | 1460 | */ |
1461 | - public function save($set_cols_n_values=array()) { |
|
1461 | + public function save($set_cols_n_values = array()) { |
|
1462 | 1462 | /** |
1463 | 1463 | * Filters the fields we're about to save on the model object |
1464 | 1464 | * |
1465 | 1465 | * @param array $set_cols_n_values |
1466 | 1466 | * @param EE_Base_Class $model_object |
1467 | 1467 | */ |
1468 | - $set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1468 | + $set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1469 | 1469 | //set attributes as provided in $set_cols_n_values |
1470 | - foreach($set_cols_n_values as $column=>$value){ |
|
1471 | - $this->set($column,$value); |
|
1470 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1471 | + $this->set($column, $value); |
|
1472 | 1472 | } |
1473 | 1473 | /** |
1474 | 1474 | * Saving a model object. |
@@ -1476,8 +1476,8 @@ discard block |
||
1476 | 1476 | * Before we perform a save, this action is fired. |
1477 | 1477 | * @param EE_Base_Class $model_object the model object about to be saved. |
1478 | 1478 | */ |
1479 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1480 | - if( ! $this->allow_persist() ) { |
|
1479 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1480 | + if ( ! $this->allow_persist()) { |
|
1481 | 1481 | return 0; |
1482 | 1482 | } |
1483 | 1483 | //now get current attribute values |
@@ -1487,61 +1487,61 @@ discard block |
||
1487 | 1487 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1488 | 1488 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1489 | 1489 | //does this model have an autoincrement PK? |
1490 | - if($this->get_model()->has_primary_key_field()){ |
|
1491 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1490 | + if ($this->get_model()->has_primary_key_field()) { |
|
1491 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1492 | 1492 | //ok check if it's set, if so: update; if not, insert |
1493 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1494 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1493 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1494 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1495 | 1495 | } else { |
1496 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1497 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1498 | - if($results){ |
|
1496 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1497 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1498 | + if ($results) { |
|
1499 | 1499 | //if successful, set the primary key |
1500 | 1500 | //but don't use the normal SET method, because it will check if |
1501 | 1501 | //an item with the same ID exists in the mapper & db, then |
1502 | 1502 | //will find it in the db (because we just added it) and THAT object |
1503 | 1503 | //will get added to the mapper before we can add this one! |
1504 | 1504 | //but if we just avoid using the SET method, all that headache can be avoided |
1505 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1505 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1506 | 1506 | $this->_fields[$pk_field_name] = $results; |
1507 | 1507 | $this->_clear_cached_property($pk_field_name); |
1508 | - $this->get_model()->add_to_entity_map( $this ); |
|
1508 | + $this->get_model()->add_to_entity_map($this); |
|
1509 | 1509 | $this->_update_cached_related_model_objs_fks(); |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | - }else{//PK is NOT auto-increment |
|
1512 | + } else {//PK is NOT auto-increment |
|
1513 | 1513 | //so check if one like it already exists in the db |
1514 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1515 | - if( WP_DEBUG && ! $this->in_entity_map() ){ |
|
1514 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1515 | + if (WP_DEBUG && ! $this->in_entity_map()) { |
|
1516 | 1516 | throw new EE_Error( |
1517 | 1517 | sprintf( |
1518 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1518 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1519 | 1519 | get_class($this), |
1520 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1521 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1520 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1521 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1522 | 1522 | '<br />' |
1523 | 1523 | ) |
1524 | 1524 | ); |
1525 | 1525 | } |
1526 | 1526 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1527 | - }else{ |
|
1527 | + } else { |
|
1528 | 1528 | $results = $this->get_model()->insert($save_cols_n_values); |
1529 | 1529 | $this->_update_cached_related_model_objs_fks(); |
1530 | 1530 | } |
1531 | 1531 | } |
1532 | - }else{//there is NO primary key |
|
1532 | + } else {//there is NO primary key |
|
1533 | 1533 | $already_in_db = false; |
1534 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1534 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1535 | 1535 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1536 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1536 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1537 | 1537 | $already_in_db = true; |
1538 | 1538 | } |
1539 | 1539 | } |
1540 | - if( $already_in_db ){ |
|
1541 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1542 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
1543 | - }else{ |
|
1544 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1540 | + if ($already_in_db) { |
|
1541 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1542 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
1543 | + } else { |
|
1544 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1545 | 1545 | } |
1546 | 1546 | } |
1547 | 1547 | //restore the old assumption about values being prepared by the model object |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1555 | 1555 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1556 | 1556 | */ |
1557 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1557 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1558 | 1558 | return $results; |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1569,15 +1569,15 @@ discard block |
||
1569 | 1569 | * @return void |
1570 | 1570 | * @throws \EE_Error |
1571 | 1571 | */ |
1572 | - protected function _update_cached_related_model_objs_fks(){ |
|
1573 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1574 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1575 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1572 | + protected function _update_cached_related_model_objs_fks() { |
|
1573 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1574 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1575 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1576 | 1576 | $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( |
1577 | 1577 | $this->get_model()->get_this_model_name() |
1578 | 1578 | ); |
1579 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1580 | - if( $related_model_obj_in_cache->ID() ){ |
|
1579 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1580 | + if ($related_model_obj_in_cache->ID()) { |
|
1581 | 1581 | $related_model_obj_in_cache->save(); |
1582 | 1582 | } |
1583 | 1583 | } |
@@ -1598,21 +1598,21 @@ discard block |
||
1598 | 1598 | * @return int ID of new model object on save; 0 on failure+ |
1599 | 1599 | * @throws \EE_Error |
1600 | 1600 | */ |
1601 | - public function save_new_cached_related_model_objs(){ |
|
1601 | + public function save_new_cached_related_model_objs() { |
|
1602 | 1602 | //make sure this has been saved |
1603 | - if( ! $this->ID()){ |
|
1603 | + if ( ! $this->ID()) { |
|
1604 | 1604 | $id = $this->save(); |
1605 | - }else{ |
|
1605 | + } else { |
|
1606 | 1606 | $id = $this->ID(); |
1607 | 1607 | } |
1608 | 1608 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1609 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1609 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1610 | 1610 | |
1611 | 1611 | |
1612 | - if($this->_model_relations[$relationName]){ |
|
1612 | + if ($this->_model_relations[$relationName]) { |
|
1613 | 1613 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1614 | 1614 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1615 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1615 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1616 | 1616 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1617 | 1617 | //but ONLY if it DOES NOT exist in the DB |
1618 | 1618 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1621,8 +1621,8 @@ discard block |
||
1621 | 1621 | $this->_add_relation_to($related_model_obj, $relationName); |
1622 | 1622 | $related_model_obj->save_new_cached_related_model_objs(); |
1623 | 1623 | // } |
1624 | - }else{ |
|
1625 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1624 | + } else { |
|
1625 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1626 | 1626 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1627 | 1627 | //but ONLY if it DOES NOT exist in the DB |
1628 | 1628 | // if( ! $related_model_obj->ID()){ |
@@ -1643,8 +1643,8 @@ discard block |
||
1643 | 1643 | * @return \EEM_Base | \EEM_CPT_Base |
1644 | 1644 | */ |
1645 | 1645 | public function get_model() { |
1646 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1647 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1646 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1647 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | |
@@ -1655,10 +1655,10 @@ discard block |
||
1655 | 1655 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1656 | 1656 | * @throws \EE_Error |
1657 | 1657 | */ |
1658 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1658 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1659 | 1659 | //TODO: will not work for Term_Relationships because they have no PK! |
1660 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1661 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1660 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1661 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1662 | 1662 | $id = $props_n_values[$primary_id_ref]; |
1663 | 1663 | return self::_get_model($classname)->get_from_entity_map($id); |
1664 | 1664 | } |
@@ -1679,37 +1679,37 @@ discard block |
||
1679 | 1679 | * @return mixed (EE_Base_Class|bool) |
1680 | 1680 | * @throws \EE_Error |
1681 | 1681 | */ |
1682 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1682 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1683 | 1683 | $existing = null; |
1684 | - if ( self::_get_model( $classname )->has_primary_key_field() ) { |
|
1685 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1686 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) |
|
1687 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1684 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1685 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1686 | + if (array_key_exists($primary_id_ref, $props_n_values) |
|
1687 | + && ! empty($props_n_values[$primary_id_ref]) |
|
1688 | 1688 | ) { |
1689 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1690 | - $props_n_values[ $primary_id_ref ] |
|
1689 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1690 | + $props_n_values[$primary_id_ref] |
|
1691 | 1691 | ); |
1692 | 1692 | } |
1693 | - } elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) { |
|
1693 | + } elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1694 | 1694 | //no primary key on this model, but there's still a matching item in the DB |
1695 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1696 | - self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values ) |
|
1695 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1696 | + self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values) |
|
1697 | 1697 | ); |
1698 | 1698 | } |
1699 | - if ( $existing ) { |
|
1699 | + if ($existing) { |
|
1700 | 1700 | |
1701 | 1701 | //set date formats if present before setting values |
1702 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1703 | - $existing->set_date_format( $date_formats[0] ); |
|
1704 | - $existing->set_time_format( $date_formats[1] ); |
|
1702 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1703 | + $existing->set_date_format($date_formats[0]); |
|
1704 | + $existing->set_time_format($date_formats[1]); |
|
1705 | 1705 | } else { |
1706 | 1706 | //set default formats for date and time |
1707 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1708 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1707 | + $existing->set_date_format(get_option('date_format')); |
|
1708 | + $existing->set_time_format(get_option('time_format')); |
|
1709 | 1709 | } |
1710 | 1710 | |
1711 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1712 | - $existing->set( $property, $field_value ); |
|
1711 | + foreach ($props_n_values as $property => $field_value) { |
|
1712 | + $existing->set($property, $field_value); |
|
1713 | 1713 | } |
1714 | 1714 | return $existing; |
1715 | 1715 | } else { |
@@ -1727,9 +1727,9 @@ discard block |
||
1727 | 1727 | * @throws EE_Error |
1728 | 1728 | * @return EEM_Base |
1729 | 1729 | */ |
1730 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1730 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1731 | 1731 | //find model for this class |
1732 | - if( ! $classname ){ |
|
1732 | + if ( ! $classname) { |
|
1733 | 1733 | throw new EE_Error( |
1734 | 1734 | sprintf( |
1735 | 1735 | __( |
@@ -1740,8 +1740,8 @@ discard block |
||
1740 | 1740 | ) |
1741 | 1741 | ); |
1742 | 1742 | } |
1743 | - $modelName=self::_get_model_classname($classname); |
|
1744 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1743 | + $modelName = self::_get_model_classname($classname); |
|
1744 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | |
@@ -1752,10 +1752,10 @@ discard block |
||
1752 | 1752 | * @param null $timezone |
1753 | 1753 | * @return EEM_Base |
1754 | 1754 | */ |
1755 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1756 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1757 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1758 | - $model->set_timezone( $timezone ); |
|
1755 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1756 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1757 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1758 | + $model->set_timezone($timezone); |
|
1759 | 1759 | return $model; |
1760 | 1760 | } |
1761 | 1761 | |
@@ -1767,10 +1767,10 @@ discard block |
||
1767 | 1767 | * @param null $model_name |
1768 | 1768 | * @return string like EEM_Attendee |
1769 | 1769 | */ |
1770 | - private static function _get_model_classname( $model_name = null){ |
|
1771 | - if(strpos($model_name,"EE_")===0){ |
|
1772 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1773 | - }else{ |
|
1770 | + private static function _get_model_classname($model_name = null) { |
|
1771 | + if (strpos($model_name, "EE_") === 0) { |
|
1772 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1773 | + } else { |
|
1774 | 1774 | $model_classname = "EEM_".$model_name; |
1775 | 1775 | } |
1776 | 1776 | return $model_classname; |
@@ -1784,16 +1784,16 @@ discard block |
||
1784 | 1784 | * @throws EE_Error |
1785 | 1785 | * @return string |
1786 | 1786 | */ |
1787 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1788 | - if( ! $classname){ |
|
1787 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1788 | + if ( ! $classname) { |
|
1789 | 1789 | throw new EE_Error( |
1790 | 1790 | sprintf( |
1791 | - __( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ), |
|
1791 | + __("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), |
|
1792 | 1792 | $classname |
1793 | 1793 | ) |
1794 | 1794 | ); |
1795 | 1795 | } |
1796 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1796 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1797 | 1797 | } |
1798 | 1798 | |
1799 | 1799 | |
@@ -1807,12 +1807,12 @@ discard block |
||
1807 | 1807 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1808 | 1808 | * @throws \EE_Error |
1809 | 1809 | */ |
1810 | - public function ID(){ |
|
1810 | + public function ID() { |
|
1811 | 1811 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1812 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1813 | - return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
|
1814 | - }else{ |
|
1815 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1812 | + if ($this->get_model()->has_primary_key_field()) { |
|
1813 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1814 | + } else { |
|
1815 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1816 | 1816 | } |
1817 | 1817 | } |
1818 | 1818 | |
@@ -1830,38 +1830,38 @@ discard block |
||
1830 | 1830 | * @throws EE_Error |
1831 | 1831 | * @return EE_Base_Class the object the relation was added to |
1832 | 1832 | */ |
1833 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1833 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1834 | 1834 | //if this thing exists in the DB, save the relation to the DB |
1835 | - if( $this->ID() ){ |
|
1836 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1835 | + if ($this->ID()) { |
|
1836 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1837 | 1837 | //clear cache so future get_many_related and get_first_related() return new results. |
1838 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1839 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1840 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1838 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1839 | + if ($otherObject instanceof EE_Base_Class) { |
|
1840 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1841 | 1841 | } |
1842 | 1842 | } else { |
1843 | 1843 | //this thing doesn't exist in the DB, so just cache it |
1844 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1845 | - throw new EE_Error( sprintf( |
|
1846 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1844 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1845 | + throw new EE_Error(sprintf( |
|
1846 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1847 | 1847 | $otherObjectModelObjectOrID, |
1848 | - get_class( $this ) |
|
1848 | + get_class($this) |
|
1849 | 1849 | )); |
1850 | 1850 | } else { |
1851 | 1851 | $otherObject = $otherObjectModelObjectOrID; |
1852 | 1852 | } |
1853 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1853 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1854 | 1854 | } |
1855 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1855 | + if ($otherObject instanceof EE_Base_Class) { |
|
1856 | 1856 | //fix the reciprocal relation too |
1857 | - if( $otherObject->ID() ) { |
|
1857 | + if ($otherObject->ID()) { |
|
1858 | 1858 | //its saved so assumed relations exist in the DB, so we can just |
1859 | 1859 | //clear the cache so future queries use the updated info in the DB |
1860 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1860 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1861 | 1861 | } else { |
1862 | 1862 | |
1863 | 1863 | //it's not saved, so it caches relations like this |
1864 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1864 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1865 | 1865 | } |
1866 | 1866 | } |
1867 | 1867 | return $otherObject; |
@@ -1885,17 +1885,17 @@ discard block |
||
1885 | 1885 | * @return EE_Base_Class the relation was removed from |
1886 | 1886 | * @throws \EE_Error |
1887 | 1887 | */ |
1888 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1889 | - if ( $this->ID() ) { |
|
1888 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1889 | + if ($this->ID()) { |
|
1890 | 1890 | //if this exists in the DB, save the relation change to the DB too |
1891 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1892 | - $this->clear_cache( $relationName, $otherObject ); |
|
1891 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1892 | + $this->clear_cache($relationName, $otherObject); |
|
1893 | 1893 | } else { |
1894 | 1894 | //this doesn't exist in the DB, just remove it from the cache |
1895 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1895 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1896 | 1896 | } |
1897 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1898 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1897 | + if ($otherObject instanceof EE_Base_Class) { |
|
1898 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1899 | 1899 | } |
1900 | 1900 | return $otherObject; |
1901 | 1901 | } |
@@ -1910,18 +1910,18 @@ discard block |
||
1910 | 1910 | * @return EE_Base_Class |
1911 | 1911 | * @throws \EE_Error |
1912 | 1912 | */ |
1913 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1914 | - if ( $this->ID() ) { |
|
1913 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1914 | + if ($this->ID()) { |
|
1915 | 1915 | //if this exists in the DB, save the relation change to the DB too |
1916 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1917 | - $this->clear_cache( $relationName, null, true ); |
|
1916 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1917 | + $this->clear_cache($relationName, null, true); |
|
1918 | 1918 | } else { |
1919 | 1919 | //this doesn't exist in the DB, just remove it from the cache |
1920 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1920 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1921 | 1921 | } |
1922 | - if( is_array( $otherObjects ) ) { |
|
1923 | - foreach ( $otherObjects as $otherObject ) { |
|
1924 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1922 | + if (is_array($otherObjects)) { |
|
1923 | + foreach ($otherObjects as $otherObject) { |
|
1924 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | return $otherObjects; |
@@ -1941,27 +1941,27 @@ discard block |
||
1941 | 1941 | * @throws \EE_Error |
1942 | 1942 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1943 | 1943 | */ |
1944 | - public function get_many_related($relationName,$query_params = array()){ |
|
1945 | - if($this->ID()){ |
|
1944 | + public function get_many_related($relationName, $query_params = array()) { |
|
1945 | + if ($this->ID()) { |
|
1946 | 1946 | //this exists in the DB, so get the related things from either the cache or the DB |
1947 | 1947 | //if there are query parameters, forget about caching the related model objects. |
1948 | - if( $query_params ){ |
|
1948 | + if ($query_params) { |
|
1949 | 1949 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1950 | - }else{ |
|
1950 | + } else { |
|
1951 | 1951 | //did we already cache the result of this query? |
1952 | 1952 | $cached_results = $this->get_all_from_cache($relationName); |
1953 | - if ( ! $cached_results ){ |
|
1953 | + if ( ! $cached_results) { |
|
1954 | 1954 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1955 | 1955 | //if no query parameters were passed, then we got all the related model objects |
1956 | 1956 | //for that relation. We can cache them then. |
1957 | - foreach($related_model_objects as $related_model_object){ |
|
1957 | + foreach ($related_model_objects as $related_model_object) { |
|
1958 | 1958 | $this->cache($relationName, $related_model_object); |
1959 | 1959 | } |
1960 | - }else{ |
|
1960 | + } else { |
|
1961 | 1961 | $related_model_objects = $cached_results; |
1962 | 1962 | } |
1963 | 1963 | } |
1964 | - }else{ |
|
1964 | + } else { |
|
1965 | 1965 | //this doesn't exist in the DB, so just get the related things from the cache |
1966 | 1966 | $related_model_objects = $this->get_all_from_cache($relationName); |
1967 | 1967 | } |
@@ -1979,8 +1979,8 @@ discard block |
||
1979 | 1979 | * @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; |
1980 | 1980 | * @return int |
1981 | 1981 | */ |
1982 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1983 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
1982 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1983 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
1995 | 1995 | * @return int |
1996 | 1996 | */ |
1997 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
1997 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
1998 | 1998 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
1999 | 1999 | } |
2000 | 2000 | |
@@ -2008,33 +2008,33 @@ discard block |
||
2008 | 2008 | * @return EE_Base_Class (not an array, a single object) |
2009 | 2009 | * @throws \EE_Error |
2010 | 2010 | */ |
2011 | - public function get_first_related($relationName,$query_params = array()){ |
|
2012 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
2011 | + public function get_first_related($relationName, $query_params = array()) { |
|
2012 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
2013 | 2013 | |
2014 | 2014 | //if they've provided some query parameters, don't bother trying to cache the result |
2015 | 2015 | //also make sure we're not caching the result of get_first_related |
2016 | 2016 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2017 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2018 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2019 | - }else{ |
|
2017 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2018 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2019 | + } else { |
|
2020 | 2020 | //first, check if we've already cached the result of this query |
2021 | 2021 | $cached_result = $this->get_one_from_cache($relationName); |
2022 | - if ( ! $cached_result ){ |
|
2022 | + if ( ! $cached_result) { |
|
2023 | 2023 | |
2024 | 2024 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2025 | - $this->cache($relationName,$related_model_object); |
|
2026 | - }else{ |
|
2025 | + $this->cache($relationName, $related_model_object); |
|
2026 | + } else { |
|
2027 | 2027 | $related_model_object = $cached_result; |
2028 | 2028 | } |
2029 | 2029 | } |
2030 | - }else{ |
|
2030 | + } else { |
|
2031 | 2031 | $related_model_object = null; |
2032 | 2032 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2033 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2034 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2033 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2034 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2035 | 2035 | } |
2036 | 2036 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
2037 | - if( ! $related_model_object){ |
|
2037 | + if ( ! $related_model_object) { |
|
2038 | 2038 | $related_model_object = $this->get_one_from_cache($relationName); |
2039 | 2039 | } |
2040 | 2040 | |
@@ -2056,12 +2056,12 @@ discard block |
||
2056 | 2056 | * @return int how many deleted |
2057 | 2057 | * @throws \EE_Error |
2058 | 2058 | */ |
2059 | - public function delete_related($relationName,$query_params = array()){ |
|
2060 | - if($this->ID()){ |
|
2061 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2062 | - }else{ |
|
2059 | + public function delete_related($relationName, $query_params = array()) { |
|
2060 | + if ($this->ID()) { |
|
2061 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2062 | + } else { |
|
2063 | 2063 | $count = count($this->get_all_from_cache($relationName)); |
2064 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2064 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2065 | 2065 | } |
2066 | 2066 | return $count; |
2067 | 2067 | } |
@@ -2080,13 +2080,13 @@ discard block |
||
2080 | 2080 | * @return int how many deleted (including those soft deleted) |
2081 | 2081 | * @throws \EE_Error |
2082 | 2082 | */ |
2083 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
2084 | - if($this->ID()){ |
|
2085 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2086 | - }else{ |
|
2083 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
2084 | + if ($this->ID()) { |
|
2085 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2086 | + } else { |
|
2087 | 2087 | $count = count($this->get_all_from_cache($relationName)); |
2088 | 2088 | } |
2089 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2089 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2090 | 2090 | return $count; |
2091 | 2091 | } |
2092 | 2092 | |
@@ -2102,7 +2102,7 @@ discard block |
||
2102 | 2102 | * @param string $field_name property to check |
2103 | 2103 | * @return bool TRUE if existing,FALSE if not. |
2104 | 2104 | */ |
2105 | - public function is_set( $field_name ) { |
|
2105 | + public function is_set($field_name) { |
|
2106 | 2106 | return isset($this->_fields[$field_name]); |
2107 | 2107 | } |
2108 | 2108 | |
@@ -2114,11 +2114,11 @@ discard block |
||
2114 | 2114 | * @throws EE_Error |
2115 | 2115 | * @return bool TRUE if existing, throw EE_Error if not. |
2116 | 2116 | */ |
2117 | - protected function _property_exists( $properties ) { |
|
2117 | + protected function _property_exists($properties) { |
|
2118 | 2118 | |
2119 | - foreach ( (array) $properties as $property_name ) { |
|
2119 | + foreach ((array) $properties as $property_name) { |
|
2120 | 2120 | //first make sure this property exists |
2121 | - if ( ! $this->_fields[ $property_name ] ) { |
|
2121 | + if ( ! $this->_fields[$property_name]) { |
|
2122 | 2122 | throw new EE_Error( |
2123 | 2123 | sprintf( |
2124 | 2124 | __( |
@@ -2146,7 +2146,7 @@ discard block |
||
2146 | 2146 | $fields = $this->get_model()->field_settings(FALSE); |
2147 | 2147 | $properties = array(); |
2148 | 2148 | //remove prepended underscore |
2149 | - foreach ( $fields as $field_name => $settings ) { |
|
2149 | + foreach ($fields as $field_name => $settings) { |
|
2150 | 2150 | $properties[$field_name] = $this->get($field_name); |
2151 | 2151 | } |
2152 | 2152 | return $properties; |
@@ -2176,10 +2176,10 @@ discard block |
||
2176 | 2176 | * @throws EE_Error |
2177 | 2177 | * @return mixed whatever the plugin which calls add_filter decides |
2178 | 2178 | */ |
2179 | - public function __call($methodName,$args){ |
|
2180 | - $className=get_class($this); |
|
2181 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2182 | - if ( ! has_filter( $tagName ) ) { |
|
2179 | + public function __call($methodName, $args) { |
|
2180 | + $className = get_class($this); |
|
2181 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2182 | + if ( ! has_filter($tagName)) { |
|
2183 | 2183 | throw new EE_Error( |
2184 | 2184 | sprintf( |
2185 | 2185 | __( |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | ) |
2193 | 2193 | ); |
2194 | 2194 | } |
2195 | - return apply_filters($tagName,null,$this,$args); |
|
2195 | + return apply_filters($tagName, null, $this, $args); |
|
2196 | 2196 | } |
2197 | 2197 | |
2198 | 2198 | |
@@ -2208,7 +2208,7 @@ discard block |
||
2208 | 2208 | * @throws \EE_Error |
2209 | 2209 | * NOTE: if the values haven't changed, returns 0 |
2210 | 2210 | */ |
2211 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2211 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2212 | 2212 | $query_params = array( |
2213 | 2213 | array( |
2214 | 2214 | 'EXM_key' => $meta_key, |
@@ -2216,17 +2216,17 @@ discard block |
||
2216 | 2216 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2217 | 2217 | ) |
2218 | 2218 | ); |
2219 | - if ( $previous_value !== null ) { |
|
2219 | + if ($previous_value !== null) { |
|
2220 | 2220 | $query_params[0]['EXM_value'] = $meta_value; |
2221 | 2221 | } |
2222 | - $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params ); |
|
2223 | - if ( ! $existing_rows_like_that ) { |
|
2224 | - return $this->add_extra_meta( $meta_key, $meta_value ); |
|
2222 | + $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
|
2223 | + if ( ! $existing_rows_like_that) { |
|
2224 | + return $this->add_extra_meta($meta_key, $meta_value); |
|
2225 | 2225 | } else { |
2226 | - foreach ( $existing_rows_like_that as $existing_row ) { |
|
2227 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2226 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2227 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2228 | 2228 | } |
2229 | - return count( $existing_rows_like_that ); |
|
2229 | + return count($existing_rows_like_that); |
|
2230 | 2230 | } |
2231 | 2231 | } |
2232 | 2232 | |
@@ -2243,8 +2243,8 @@ discard block |
||
2243 | 2243 | * @return boolean |
2244 | 2244 | * @throws \EE_Error |
2245 | 2245 | */ |
2246 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2247 | - if ( $unique ) { |
|
2246 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2247 | + if ($unique) { |
|
2248 | 2248 | $existing_extra_meta = EEM_Extra_Meta::instance()->get_one( |
2249 | 2249 | array( |
2250 | 2250 | array( |
@@ -2254,7 +2254,7 @@ discard block |
||
2254 | 2254 | ) |
2255 | 2255 | ) |
2256 | 2256 | ); |
2257 | - if ( $existing_extra_meta ) { |
|
2257 | + if ($existing_extra_meta) { |
|
2258 | 2258 | return false; |
2259 | 2259 | } |
2260 | 2260 | } |
@@ -2281,7 +2281,7 @@ discard block |
||
2281 | 2281 | * @return int number of extra meta rows deleted |
2282 | 2282 | * @throws \EE_Error |
2283 | 2283 | */ |
2284 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2284 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2285 | 2285 | $query_params = array( |
2286 | 2286 | array( |
2287 | 2287 | 'EXM_key' => $meta_key, |
@@ -2289,10 +2289,10 @@ discard block |
||
2289 | 2289 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2290 | 2290 | ) |
2291 | 2291 | ); |
2292 | - if ( $meta_value !== null ) { |
|
2292 | + if ($meta_value !== null) { |
|
2293 | 2293 | $query_params[0]['EXM_value'] = $meta_value; |
2294 | 2294 | } |
2295 | - return EEM_Extra_Meta::instance()->delete( $query_params ); |
|
2295 | + return EEM_Extra_Meta::instance()->delete($query_params); |
|
2296 | 2296 | } |
2297 | 2297 | |
2298 | 2298 | |
@@ -2308,25 +2308,25 @@ discard block |
||
2308 | 2308 | * @return mixed single value if $single; array if ! $single |
2309 | 2309 | * @throws \EE_Error |
2310 | 2310 | */ |
2311 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2312 | - if($single){ |
|
2313 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2314 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2311 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2312 | + if ($single) { |
|
2313 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2314 | + if ($result instanceof EE_Extra_Meta) { |
|
2315 | 2315 | return $result->value(); |
2316 | - }else{ |
|
2316 | + } else { |
|
2317 | 2317 | return $default; |
2318 | 2318 | } |
2319 | - }else{ |
|
2320 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2321 | - if($results){ |
|
2319 | + } else { |
|
2320 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2321 | + if ($results) { |
|
2322 | 2322 | $values = array(); |
2323 | - foreach($results as $result){ |
|
2324 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2323 | + foreach ($results as $result) { |
|
2324 | + if ($result instanceof EE_Extra_Meta) { |
|
2325 | 2325 | $values[$result->ID()] = $result->value(); |
2326 | 2326 | } |
2327 | 2327 | } |
2328 | 2328 | return $values; |
2329 | - }else{ |
|
2329 | + } else { |
|
2330 | 2330 | return $default; |
2331 | 2331 | } |
2332 | 2332 | } |
@@ -2348,20 +2348,20 @@ discard block |
||
2348 | 2348 | * @return array |
2349 | 2349 | * @throws \EE_Error |
2350 | 2350 | */ |
2351 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2351 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2352 | 2352 | $return_array = array(); |
2353 | - if($one_of_each_key){ |
|
2353 | + if ($one_of_each_key) { |
|
2354 | 2354 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2355 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2356 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2355 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2356 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2357 | 2357 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2358 | 2358 | } |
2359 | 2359 | } |
2360 | - }else{ |
|
2360 | + } else { |
|
2361 | 2361 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2362 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2363 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2364 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2362 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2363 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2364 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2365 | 2365 | $return_array[$extra_meta_obj->key()] = array(); |
2366 | 2366 | } |
2367 | 2367 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2379,19 +2379,19 @@ discard block |
||
2379 | 2379 | * @return string |
2380 | 2380 | * @throws \EE_Error |
2381 | 2381 | */ |
2382 | - public function name(){ |
|
2382 | + public function name() { |
|
2383 | 2383 | //find a field that's not a text field |
2384 | 2384 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2385 | - if($field_we_can_use){ |
|
2385 | + if ($field_we_can_use) { |
|
2386 | 2386 | return $this->get($field_we_can_use->get_name()); |
2387 | - }else{ |
|
2387 | + } else { |
|
2388 | 2388 | $first_few_properties = $this->model_field_array(); |
2389 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2389 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2390 | 2390 | $name_parts = array(); |
2391 | - foreach( $first_few_properties as $name=> $value ){ |
|
2391 | + foreach ($first_few_properties as $name=> $value) { |
|
2392 | 2392 | $name_parts[] = "$name:$value"; |
2393 | 2393 | } |
2394 | - return implode(",",$name_parts); |
|
2394 | + return implode(",", $name_parts); |
|
2395 | 2395 | } |
2396 | 2396 | } |
2397 | 2397 | |
@@ -2404,11 +2404,11 @@ discard block |
||
2404 | 2404 | * @return boolean |
2405 | 2405 | * @throws \EE_Error |
2406 | 2406 | */ |
2407 | - public function in_entity_map(){ |
|
2408 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2407 | + public function in_entity_map() { |
|
2408 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2409 | 2409 | //well, if we looked, did we find it in the entity map? |
2410 | 2410 | return TRUE; |
2411 | - }else{ |
|
2411 | + } else { |
|
2412 | 2412 | return FALSE; |
2413 | 2413 | } |
2414 | 2414 | } |
@@ -2419,21 +2419,21 @@ discard block |
||
2419 | 2419 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2420 | 2420 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2421 | 2421 | */ |
2422 | - public function refresh_from_db(){ |
|
2423 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2424 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2425 | - }else{ |
|
2422 | + public function refresh_from_db() { |
|
2423 | + if ($this->ID() && $this->in_entity_map()) { |
|
2424 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2425 | + } else { |
|
2426 | 2426 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2427 | 2427 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2428 | 2428 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2429 | 2429 | //absolutely nothing in it for this ID |
2430 | - if( WP_DEBUG ) { |
|
2430 | + if (WP_DEBUG) { |
|
2431 | 2431 | throw new EE_Error( |
2432 | 2432 | sprintf( |
2433 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2433 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2434 | 2434 | $this->ID(), |
2435 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2436 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2435 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2436 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2437 | 2437 | ) |
2438 | 2438 | ); |
2439 | 2439 | } |
@@ -2447,11 +2447,11 @@ discard block |
||
2447 | 2447 | * (probably a bad assumption they have made, oh well) |
2448 | 2448 | * @return string |
2449 | 2449 | */ |
2450 | - public function __toString(){ |
|
2450 | + public function __toString() { |
|
2451 | 2451 | try { |
2452 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2453 | - } catch ( Exception $e ) { |
|
2454 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
2452 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2453 | + } catch (Exception $e) { |
|
2454 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
2455 | 2455 | return ''; |
2456 | 2456 | } |
2457 | 2457 | } |
@@ -2487,16 +2487,16 @@ discard block |
||
2487 | 2487 | * @throws \EE_Error |
2488 | 2488 | */ |
2489 | 2489 | public function __sleep() { |
2490 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2491 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2492 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2493 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2494 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2495 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2490 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2491 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2492 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2493 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2494 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2495 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2496 | 2496 | } |
2497 | 2497 | } |
2498 | 2498 | } |
2499 | - return array_keys( get_object_vars( $this ) ); |
|
2499 | + return array_keys(get_object_vars($this)); |
|
2500 | 2500 | } |
2501 | 2501 | |
2502 | 2502 |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * |
863 | 863 | * @param null $field_to_order_by What field is being used as the reference point. |
864 | 864 | * @param array $query_params Any additional conditions on the query. |
865 | - * @param null $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
865 | + * @param string $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
866 | 866 | * you can indicate just the columns you want returned |
867 | 867 | * @return array|EE_Base_Class |
868 | 868 | * @throws \EE_Error |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @param null $field_to_order_by What field is being used as the reference point. |
888 | 888 | * @param array $query_params Any additional conditions on the query. |
889 | - * @param null $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
889 | + * @param string $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
890 | 890 | * you can indicate just the column you want returned |
891 | 891 | * @return array|EE_Base_Class |
892 | 892 | * @throws \EE_Error |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * This method simply returns the RAW unprocessed value for the given property in this class |
956 | 956 | * |
957 | 957 | * @param string $field_name A valid fieldname |
958 | - * @return mixed Whatever the raw value stored on the property is. |
|
958 | + * @return integer|null Whatever the raw value stored on the property is. |
|
959 | 959 | * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist. |
960 | 960 | */ |
961 | 961 | public function get_raw($field_name) { |
@@ -1055,8 +1055,8 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @access protected |
1057 | 1057 | * @param string $field_name Field on the instantiated EE_Base_Class child object |
1058 | - * @param null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
1059 | - * @param null $tm_frmt Same as above except this is for time format |
|
1058 | + * @param string|null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
1059 | + * @param null|string $tm_frmt Same as above except this is for time format |
|
1060 | 1060 | * @param string $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time. |
1061 | 1061 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
1062 | 1062 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | * sets the time on a datetime property |
1243 | 1243 | * |
1244 | 1244 | * @access protected |
1245 | - * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
|
1245 | + * @param string $time a valid time string for php datetime functions (or DateTime object) |
|
1246 | 1246 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1247 | 1247 | * @throws \EE_Error |
1248 | 1248 | */ |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | * sets the date on a datetime property |
1257 | 1257 | * |
1258 | 1258 | * @access protected |
1259 | - * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
|
1259 | + * @param string $date a valid date string for php datetime functions ( or DateTime object) |
|
1260 | 1260 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1261 | 1261 | * @throws \EE_Error |
1262 | 1262 | */ |
@@ -1313,6 +1313,7 @@ discard block |
||
1313 | 1313 | * @param mixed (array|string) $args This is the arguments that will be passed to the callback. |
1314 | 1314 | * @param string $prepend You can include something to prepend on the timestamp |
1315 | 1315 | * @param string $append You can include something to append on the timestamp |
1316 | + * @param string $args |
|
1316 | 1317 | * @throws EE_Error |
1317 | 1318 | * @return string timestamp |
1318 | 1319 | */ |
@@ -1351,7 +1352,7 @@ discard block |
||
1351 | 1352 | * This calls the `EE_Base_Class::_delete` method. Child classes wishing to change default behaviour should override |
1352 | 1353 | * `EE_Base_Class::_delete` NOT this class. |
1353 | 1354 | * |
1354 | - * @return boolean | int |
|
1355 | + * @return integer | int |
|
1355 | 1356 | * @throws \EE_Error |
1356 | 1357 | */ |
1357 | 1358 | public function delete(){ |
@@ -1384,7 +1385,7 @@ discard block |
||
1384 | 1385 | * This method is called by the public `EE_Base_Class::delete` method. Any child classes desiring to override default |
1385 | 1386 | * functionality for "delete" (which is to call `permanently_delete`) should override this method NOT `EE_Base_Class::delete` |
1386 | 1387 | * |
1387 | - * @return bool|int |
|
1388 | + * @return boolean |
|
1388 | 1389 | * @throws \EE_Error |
1389 | 1390 | */ |
1390 | 1391 | protected function _delete() { |
@@ -1673,7 +1674,7 @@ discard block |
||
1673 | 1674 | * |
1674 | 1675 | * @param array $props_n_values incoming array of properties and their values |
1675 | 1676 | * @param string $classname the classname of the child class |
1676 | - * @param null $timezone |
|
1677 | + * @param string|null $timezone |
|
1677 | 1678 | * @param array $date_formats incoming date_formats in an array where the first value is the |
1678 | 1679 | * date_format and the second value is the time format |
1679 | 1680 | * @return mixed (EE_Base_Class|bool) |
@@ -1749,7 +1750,7 @@ discard block |
||
1749 | 1750 | /** |
1750 | 1751 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
1751 | 1752 | * @param string $model_classname |
1752 | - * @param null $timezone |
|
1753 | + * @param string|null $timezone |
|
1753 | 1754 | * @return EEM_Base |
1754 | 1755 | */ |
1755 | 1756 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |