@@ -161,7 +161,7 @@ |
||
161 | 161 | * @param EE_Transaction $transaction |
162 | 162 | * @param string $payment_status One of EEM_Payment's statuses, like 'PAP' (Approved). |
163 | 163 | * By default, searches for approved payments |
164 | - * @return float|false float on success, false on fail |
|
164 | + * @return double float on success, false on fail |
|
165 | 165 | * @throws \EE_Error |
166 | 166 | */ |
167 | 167 | public function recalculate_total_payments_for_transaction( EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved ) { |
@@ -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_Payments |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function instance() { |
44 | 44 | // check if class object is instantiated |
45 | - if ( ! self::$_instance instanceof EE_Transaction_Payments ) { |
|
45 | + if ( ! self::$_instance instanceof EE_Transaction_Payments) { |
|
46 | 46 | self::$_instance = new self(); |
47 | 47 | } |
48 | 48 | return self::$_instance; |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | * @return bool true if TXN total was updated, false if not |
60 | 60 | * @throws \EE_Error |
61 | 61 | */ |
62 | - public function recalculate_transaction_total( EE_Transaction $transaction, $update_txn = true ) { |
|
62 | + public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) { |
|
63 | 63 | $total_line_item = $transaction->total_line_item(); |
64 | - if ( ! $total_line_item instanceof EE_Line_Item ) { |
|
64 | + if ( ! $total_line_item instanceof EE_Line_Item) { |
|
65 | 65 | EE_Error::add_error( |
66 | - sprintf( __( 'The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso' ), $transaction->ID() ), |
|
66 | + sprintf(__('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), $transaction->ID()), |
|
67 | 67 | __FILE__, __FUNCTION__, __LINE__ |
68 | 68 | ); |
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | $new_total = $total_line_item->recalculate_total_including_taxes(); |
72 | - $transaction->set_total( $new_total ); |
|
73 | - if ( $update_txn ) { |
|
72 | + $transaction->set_total($new_total); |
|
73 | + if ($update_txn) { |
|
74 | 74 | return $transaction->save() ? true : false; |
75 | 75 | } |
76 | 76 | return false; |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | * @return boolean whether the TXN was saved |
94 | 94 | * @throws \EE_Error |
95 | 95 | */ |
96 | - public function calculate_total_payments_and_update_status( EE_Transaction $transaction, $update_txn = true ){ |
|
96 | + public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) { |
|
97 | 97 | // verify transaction |
98 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
99 | - EE_Error::add_error( __( 'Please provide a valid EE_Transaction object.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
98 | + if ( ! $transaction instanceof EE_Transaction) { |
|
99 | + EE_Error::add_error(__('Please provide a valid EE_Transaction object.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | // calculate total paid |
103 | - $total_paid = $this->recalculate_total_payments_for_transaction( $transaction ); |
|
103 | + $total_paid = $this->recalculate_total_payments_for_transaction($transaction); |
|
104 | 104 | // if total paid has changed |
105 | - if ( $total_paid !== false && (float)$total_paid !== $transaction->paid() ) { |
|
106 | - $transaction->set_paid( $total_paid ); |
|
105 | + if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) { |
|
106 | + $transaction->set_paid($total_paid); |
|
107 | 107 | // maybe update status, and make sure to save transaction if not done already |
108 | - if ( ! $transaction->update_status_based_on_total_paid( $update_txn ) ) { |
|
109 | - if ( $update_txn ) { |
|
108 | + if ( ! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
109 | + if ($update_txn) { |
|
110 | 110 | return $transaction->save() ? true : false; |
111 | 111 | } |
112 | 112 | } else { |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | * @return float|false float on success, false on fail |
131 | 131 | * @throws \EE_Error |
132 | 132 | */ |
133 | - public function recalculate_total_payments_for_transaction( EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved ) { |
|
133 | + public function recalculate_total_payments_for_transaction(EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved) { |
|
134 | 134 | // verify transaction |
135 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
136 | - EE_Error::add_error( __( 'Please provide a valid EE_Transaction object.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
135 | + if ( ! $transaction instanceof EE_Transaction) { |
|
136 | + EE_Error::add_error(__('Please provide a valid EE_Transaction object.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | // ensure Payment model is loaded |
140 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
140 | + EE_Registry::instance()->load_model('Payment'); |
|
141 | 141 | // calls EEM_Base::sum() |
142 | 142 | return EEM_Payment::instance()->sum( |
143 | 143 | // query params |
144 | - array( array( 'TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status )), |
|
144 | + array(array('TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status)), |
|
145 | 145 | // field to sum |
146 | 146 | 'PAY_amount' |
147 | 147 | ); |
@@ -159,17 +159,17 @@ discard block |
||
159 | 159 | * @return boolean |
160 | 160 | * @throws \EE_Error |
161 | 161 | */ |
162 | - public function delete_payment_and_update_transaction( EE_Payment $payment ) { |
|
162 | + public function delete_payment_and_update_transaction(EE_Payment $payment) { |
|
163 | 163 | // verify payment |
164 | - if ( ! $payment instanceof EE_Payment ) { |
|
165 | - EE_Error::add_error( __( 'A valid Payment object was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
164 | + if ( ! $payment instanceof EE_Payment) { |
|
165 | + EE_Error::add_error(__('A valid Payment object was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
166 | 166 | return false; |
167 | 167 | } |
168 | - if ( ! $this->delete_registration_payments_and_update_registrations( $payment ) ) { |
|
168 | + if ( ! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
169 | 169 | return false; |
170 | 170 | } |
171 | - if ( ! $payment->delete() ) { |
|
172 | - EE_Error::add_error( __( 'The payment could not be deleted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
171 | + if ( ! $payment->delete()) { |
|
172 | + EE_Error::add_error(__('The payment could not be deleted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
@@ -180,14 +180,14 @@ discard block |
||
180 | 180 | || $TXN_status === EEM_Transaction::failed_status_code |
181 | 181 | || $payment->amount() === 0 |
182 | 182 | ) { |
183 | - EE_Error::add_success( __( 'The Payment was successfully deleted.', 'event_espresso' ) ); |
|
183 | + EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso')); |
|
184 | 184 | return true; |
185 | 185 | } |
186 | 186 | |
187 | 187 | |
188 | 188 | //if this fails, that just means that the transaction didn't get its status changed and/or updated. |
189 | 189 | //however the payment was still deleted. |
190 | - if ( ! $this->calculate_total_payments_and_update_status( $transaction ) ) { |
|
190 | + if ( ! $this->calculate_total_payments_and_update_status($transaction)) { |
|
191 | 191 | |
192 | 192 | EE_Error::add_attention( |
193 | 193 | __( |
@@ -221,28 +221,28 @@ discard block |
||
221 | 221 | * @return bool |
222 | 222 | * @throws \EE_Error |
223 | 223 | */ |
224 | - public function delete_registration_payments_and_update_registrations( EE_Payment $payment, $reg_payment_query_params = array() ) { |
|
224 | + public function delete_registration_payments_and_update_registrations(EE_Payment $payment, $reg_payment_query_params = array()) { |
|
225 | 225 | $save_payment = false; |
226 | - $reg_payment_query_params = ! empty( $reg_payment_query_params ) ? $reg_payment_query_params : array( array( 'PAY_ID' => $payment->ID() ) ); |
|
227 | - $registration_payments = EEM_Registration_Payment::instance()->get_all( $reg_payment_query_params ); |
|
228 | - if ( ! empty( $registration_payments )) { |
|
229 | - foreach ( $registration_payments as $registration_payment ) { |
|
230 | - if ( $registration_payment instanceof EE_Registration_Payment ) { |
|
226 | + $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params : array(array('PAY_ID' => $payment->ID())); |
|
227 | + $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
|
228 | + if ( ! empty($registration_payments)) { |
|
229 | + foreach ($registration_payments as $registration_payment) { |
|
230 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
231 | 231 | $amount_paid = $registration_payment->amount(); |
232 | 232 | $registration = $registration_payment->registration(); |
233 | - if ( $registration instanceof EE_Registration ) { |
|
234 | - $registration->set_paid( $registration->paid() - $amount_paid ); |
|
235 | - if ( $registration->save() ) { |
|
236 | - if ( $registration_payment->delete() ) { |
|
237 | - $registration->_remove_relation_to( $payment, 'Payment' ); |
|
238 | - $payment->_remove_relation_to( $registration, 'Registration' ); |
|
233 | + if ($registration instanceof EE_Registration) { |
|
234 | + $registration->set_paid($registration->paid() - $amount_paid); |
|
235 | + if ($registration->save()) { |
|
236 | + if ($registration_payment->delete()) { |
|
237 | + $registration->_remove_relation_to($payment, 'Payment'); |
|
238 | + $payment->_remove_relation_to($registration, 'Registration'); |
|
239 | 239 | } |
240 | 240 | $save_payment = true; |
241 | 241 | } |
242 | 242 | } else { |
243 | 243 | EE_Error::add_error( |
244 | 244 | sprintf( |
245 | - __( 'An invalid Registration object was associated with Registration Payment ID# %1$d.', 'event_espresso' ), |
|
245 | + __('An invalid Registration object was associated with Registration Payment ID# %1$d.', 'event_espresso'), |
|
246 | 246 | $registration_payment->ID() |
247 | 247 | ), |
248 | 248 | __FILE__, __FUNCTION__, __LINE__ |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } else { |
253 | 253 | EE_Error::add_error( |
254 | 254 | sprintf( |
255 | - __( 'An invalid Registration Payment object was associated with payment ID# %1$d.', 'event_espresso' ), |
|
255 | + __('An invalid Registration Payment object was associated with payment ID# %1$d.', 'event_espresso'), |
|
256 | 256 | $payment->ID() |
257 | 257 | ), |
258 | 258 | __FILE__, __FUNCTION__, __LINE__ |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | } |
262 | 262 | } |
263 | 263 | } |
264 | - if ( $save_payment ) { |
|
264 | + if ($save_payment) { |
|
265 | 265 | $payment->save(); |
266 | 266 | } |
267 | 267 | return true; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true) |
286 | 286 | { |
287 | 287 | EE_Error::doing_it_wrong( |
288 | - __CLASS__ . '::' . __FUNCTION__, |
|
288 | + __CLASS__.'::'.__FUNCTION__, |
|
289 | 289 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
290 | 290 | 'EE_Transaction::update_status_based_on_total_paid()'), |
291 | 291 | '4.9.1', |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @deprecated 4.9.12 |
328 | 328 | * @param string $old_txn_status |
329 | 329 | */ |
330 | - public function set_old_txn_status( $old_txn_status ) { |
|
330 | + public function set_old_txn_status($old_txn_status) { |
|
331 | 331 | EE_Error::doing_it_wrong( |
332 | 332 | __METHOD__, |
333 | 333 | esc_html__( |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | '4.9.12' |
338 | 338 | ); |
339 | 339 | // only set the first time |
340 | - if ( $this->_old_txn_status === null ) { |
|
340 | + if ($this->_old_txn_status === null) { |
|
341 | 341 | $this->_old_txn_status = $old_txn_status; |
342 | 342 | } |
343 | 343 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @deprecated 4.9.12 |
367 | 367 | * @param string $new_txn_status |
368 | 368 | */ |
369 | - public function set_new_txn_status( $new_txn_status ) { |
|
369 | + public function set_new_txn_status($new_txn_status) { |
|
370 | 370 | EE_Error::doing_it_wrong( |
371 | 371 | __METHOD__, |
372 | 372 | esc_html__( |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | /** |
421 | 421 | * @param $old_event |
422 | - * @param $new_cpt_id |
|
422 | + * @param integer $new_cpt_id |
|
423 | 423 | * @return int |
424 | 424 | */ |
425 | 425 | private function _insert_event_meta( $old_event, $new_cpt_id){ |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | |
677 | 677 | |
678 | 678 | /** |
679 | - * @param $new_event_id |
|
680 | - * @param $new_venue_id |
|
679 | + * @param integer $new_event_id |
|
680 | + * @param integer $new_venue_id |
|
681 | 681 | * @return int |
682 | 682 | */ |
683 | 683 | private function _insert_new_venue_to_event( $new_event_id, $new_venue_id){ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
159 | 159 | )); |
160 | 160 | */ |
161 | -class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage{ |
|
161 | +class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage { |
|
162 | 162 | private $_old_table; |
163 | 163 | private $_old_start_end_table; |
164 | 164 | private $_new_table; |
@@ -205,43 +205,43 @@ discard block |
||
205 | 205 | * @param int $num_items_to_migrate |
206 | 206 | * @return int number of items ACTUALLY migrated |
207 | 207 | */ |
208 | - protected function _migration_step( $num_items_to_migrate = 50) { |
|
208 | + protected function _migration_step($num_items_to_migrate = 50) { |
|
209 | 209 | global $wpdb; |
210 | 210 | //because the migration of each event can be a LOT more work, make each step smaller |
211 | - $num_items_to_migrate = max(1,$num_items_to_migrate/5); |
|
212 | - $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$this->count_records_migrated(),$num_items_to_migrate),ARRAY_A); |
|
211 | + $num_items_to_migrate = max(1, $num_items_to_migrate / 5); |
|
212 | + $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $this->count_records_migrated(), $num_items_to_migrate), ARRAY_A); |
|
213 | 213 | $items_migrated_this_step = 0; |
214 | 214 | |
215 | - foreach($events as $event_row){ |
|
215 | + foreach ($events as $event_row) { |
|
216 | 216 | $guid = null; |
217 | 217 | //insert new 4.1 Attendee object using $wpdb |
218 | 218 | $post_id = $this->_insert_cpt($event_row); |
219 | - if($post_id){ |
|
219 | + if ($post_id) { |
|
220 | 220 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_table, $post_id); |
221 | 221 | $meta_id = $this->_insert_event_meta($event_row, $post_id); |
222 | - if($meta_id){ |
|
222 | + if ($meta_id) { |
|
223 | 223 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_meta_table, $meta_id); |
224 | 224 | } |
225 | - $this->_convert_start_end_times($event_row,$post_id); |
|
225 | + $this->_convert_start_end_times($event_row, $post_id); |
|
226 | 226 | $event_meta = maybe_unserialize($event_row['event_meta']); |
227 | 227 | $guid = isset($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : null; |
228 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid,$post_id,$this); |
|
228 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $post_id, $this); |
|
229 | 229 | |
230 | 230 | //maybe create a venue from info on the event? |
231 | 231 | $new_venue_id = $this->_maybe_create_venue($event_row); |
232 | - if($new_venue_id){ |
|
233 | - $this->_insert_new_venue_to_event($post_id,$new_venue_id); |
|
232 | + if ($new_venue_id) { |
|
233 | + $this->_insert_new_venue_to_event($post_id, $new_venue_id); |
|
234 | 234 | } |
235 | 235 | $this->_add_post_metas($event_row, $post_id); |
236 | 236 | } |
237 | 237 | $items_migrated_this_step++; |
238 | - if($guid){ |
|
238 | + if ($guid) { |
|
239 | 239 | //if we had to check for an image attachment |
240 | 240 | //then let's call it a day (avoid timing out, because this took a long time) |
241 | 241 | break; |
242 | 242 | } |
243 | 243 | } |
244 | - if($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()){ |
|
244 | + if ($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()) { |
|
245 | 245 | $this->set_status(EE_Data_Migration_Manager::status_completed); |
246 | 246 | } |
247 | 247 | return $items_migrated_this_step; |
@@ -253,28 +253,28 @@ discard block |
||
253 | 253 | * @param int $post_id |
254 | 254 | * @return void |
255 | 255 | */ |
256 | - private function _add_post_metas($old_event,$post_id){ |
|
256 | + private function _add_post_metas($old_event, $post_id) { |
|
257 | 257 | $event_meta = maybe_unserialize($old_event['event_meta']); |
258 | - if( ! $event_meta || ! is_array( $event_meta ) ){ |
|
258 | + if ( ! $event_meta || ! is_array($event_meta)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | - unset($event_meta['date_submitted']);//factored into CPT |
|
262 | - unset($event_meta['additional_attendee_reg_info']);//factored into event meta table |
|
263 | - unset($event_meta['default_payment_status']);//dido |
|
264 | - unset($event_meta['event_thumbnail_url']);//used to find post featured image |
|
265 | - foreach($event_meta as $meta_key => $meta_value){ |
|
266 | - if ($meta_key){//if the meta key is just an empty string, ignore it |
|
267 | - $success = add_post_meta($post_id,$meta_key,$meta_value,true); |
|
268 | - if( ! $success ){ |
|
269 | - $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"),$post_id,$meta_key,$meta_value,implode(",",$old_event))); |
|
261 | + unset($event_meta['date_submitted']); //factored into CPT |
|
262 | + unset($event_meta['additional_attendee_reg_info']); //factored into event meta table |
|
263 | + unset($event_meta['default_payment_status']); //dido |
|
264 | + unset($event_meta['event_thumbnail_url']); //used to find post featured image |
|
265 | + foreach ($event_meta as $meta_key => $meta_value) { |
|
266 | + if ($meta_key) {//if the meta key is just an empty string, ignore it |
|
267 | + $success = add_post_meta($post_id, $meta_key, $meta_value, true); |
|
268 | + if ( ! $success) { |
|
269 | + $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"), $post_id, $meta_key, $meta_value, implode(",", $old_event))); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
273 | - if($old_event['alt_email']){ |
|
274 | - add_post_meta($post_id,'alt_email',$old_event['alt_email']); |
|
273 | + if ($old_event['alt_email']) { |
|
274 | + add_post_meta($post_id, 'alt_email', $old_event['alt_email']); |
|
275 | 275 | } |
276 | - if($old_event['recurrence_id']){ |
|
277 | - add_post_meta($post_id,'recurrence_id',$old_event['recurrence_id']); |
|
276 | + if ($old_event['recurrence_id']) { |
|
277 | + add_post_meta($post_id, 'recurrence_id', $old_event['recurrence_id']); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @param string $new_post_status a post status |
290 | 290 | * @return string |
291 | 291 | */ |
292 | - private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish'){ |
|
292 | + private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish') { |
|
293 | 293 | $count = 0; |
294 | 294 | $original_name = $event_name ? sanitize_title($event_name) : $old_identifier; |
295 | - return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0 ); |
|
295 | + return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | * @param string $slug |
302 | 302 | * @return boolean |
303 | 303 | */ |
304 | - private function _other_post_exists_with_that_slug($slug){ |
|
304 | + private function _other_post_exists_with_that_slug($slug) { |
|
305 | 305 | global $wpdb; |
306 | - $query = $wpdb->prepare("SELECT COUNT(ID) FROM {$this->_new_table} WHERE post_name = %s",$slug); |
|
306 | + $query = $wpdb->prepare("SELECT COUNT(ID) FROM {$this->_new_table} WHERE post_name = %s", $slug); |
|
307 | 307 | $count = $wpdb->get_var($query); |
308 | - return (boolean)intval($count); |
|
308 | + return (boolean) intval($count); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param $old_event |
315 | 315 | * @return int |
316 | 316 | */ |
317 | - private function _insert_cpt( $old_event ){ |
|
317 | + private function _insert_cpt($old_event) { |
|
318 | 318 | global $wpdb; |
319 | 319 | //convert 3.1 event status to 4.1 CPT status |
320 | 320 | //for reference, 3.1 event stati available for setting are: |
@@ -333,66 +333,66 @@ discard block |
||
333 | 333 | // and 3 custom ones: cancelled,postponed,sold_out |
334 | 334 | $status_conversions = array( |
335 | 335 | 'R'=>'draft', |
336 | - 'X'=>'draft',//4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
336 | + 'X'=>'draft', //4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
337 | 337 | 'P'=>'pending', |
338 | - 'IA'=>'draft',//draft and in the past |
|
338 | + 'IA'=>'draft', //draft and in the past |
|
339 | 339 | //IA=inactive in 3.1: events were switched to this when they expired. in 4.1 that's just calculated |
340 | - 'O'=>'publish',//@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
340 | + 'O'=>'publish', //@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
341 | 341 | 'A'=>'publish', |
342 | - 'S'=>'draft',//@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
342 | + 'S'=>'draft', //@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
343 | 343 | 'D'=>'trash', |
344 | 344 | ); |
345 | 345 | $post_status = $status_conversions[$old_event['event_status']]; |
346 | 346 | //check if we've sold out |
347 | - if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])){ |
|
347 | + if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])) { |
|
348 | 348 | $post_status = 'sold_out'; |
349 | 349 | } |
350 | 350 | // FYI postponed and cancelled don't exist in 3.1 |
351 | 351 | $cols_n_values = array( |
352 | - 'post_title'=>stripslashes($old_event['event_name']),//EVT_name |
|
353 | - 'post_content'=>stripslashes($old_event['event_desc']),//EVT_desc |
|
354 | - 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status ),//EVT_slug |
|
355 | - 'post_date'=>$old_event['submitted'],//EVT_created NOT |
|
352 | + 'post_title'=>stripslashes($old_event['event_name']), //EVT_name |
|
353 | + 'post_content'=>stripslashes($old_event['event_desc']), //EVT_desc |
|
354 | + 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status), //EVT_slug |
|
355 | + 'post_date'=>$old_event['submitted'], //EVT_created NOT |
|
356 | 356 | 'post_date_gmt'=>get_gmt_from_date($old_event['submitted']), |
357 | - 'post_excerpt'=>'',//EVT_short_desc |
|
358 | - 'post_modified'=>$old_event['submitted'],//EVT_modified |
|
357 | + 'post_excerpt'=>'', //EVT_short_desc |
|
358 | + 'post_modified'=>$old_event['submitted'], //EVT_modified |
|
359 | 359 | 'post_modified_gmt'=>get_gmt_from_date($old_event['submitted']), |
360 | - 'post_author'=>$old_event['wp_user'],//EVT_wp_user |
|
361 | - 'post_parent'=>0,//parent maybe get this from some REM field? |
|
362 | - 'menu_order'=>0,//EVT_order |
|
363 | - 'post_type'=>'espresso_events',//post_type |
|
364 | - 'post_status'=>$post_status,//status |
|
360 | + 'post_author'=>$old_event['wp_user'], //EVT_wp_user |
|
361 | + 'post_parent'=>0, //parent maybe get this from some REM field? |
|
362 | + 'menu_order'=>0, //EVT_order |
|
363 | + 'post_type'=>'espresso_events', //post_type |
|
364 | + 'post_status'=>$post_status, //status |
|
365 | 365 | ); |
366 | 366 | $cols_n_values_with_no_invalid_text = array(); |
367 | - foreach( $cols_n_values as $col => $value ) { |
|
368 | - $value_sans_invalid_chars = $wpdb->strip_invalid_text_for_column( $this->_new_table, $col, $value ); |
|
369 | - if( ! is_wp_error( $value_sans_invalid_chars ) ) { |
|
370 | - $cols_n_values_with_no_invalid_text[ $col ] = $value_sans_invalid_chars; |
|
367 | + foreach ($cols_n_values as $col => $value) { |
|
368 | + $value_sans_invalid_chars = $wpdb->strip_invalid_text_for_column($this->_new_table, $col, $value); |
|
369 | + if ( ! is_wp_error($value_sans_invalid_chars)) { |
|
370 | + $cols_n_values_with_no_invalid_text[$col] = $value_sans_invalid_chars; |
|
371 | 371 | } else { |
372 | 372 | //otherwise leave it as-is. It will blow everything up and stop the migration |
373 | - $cols_n_values_with_no_invalid_text[ $col ] = $value; |
|
373 | + $cols_n_values_with_no_invalid_text[$col] = $value; |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | $cols_n_values = $cols_n_values_with_no_invalid_text; |
377 | 377 | $datatypes = array( |
378 | - '%s',//EVT_name |
|
379 | - '%s',//EVT_desc |
|
380 | - '%s',//EVT_slug |
|
381 | - '%s',//EVT_created |
|
378 | + '%s', //EVT_name |
|
379 | + '%s', //EVT_desc |
|
380 | + '%s', //EVT_slug |
|
381 | + '%s', //EVT_created |
|
382 | 382 | '%s', |
383 | - '%s',//EVT_short_desc |
|
384 | - '%s',//EVT_modified |
|
383 | + '%s', //EVT_short_desc |
|
384 | + '%s', //EVT_modified |
|
385 | 385 | '%s', |
386 | - '%s',//EVT_wp_user |
|
387 | - '%d',//post_parent |
|
388 | - '%d',//EVT_order |
|
389 | - '%s',//post_type |
|
390 | - '%s',//status |
|
386 | + '%s', //EVT_wp_user |
|
387 | + '%d', //post_parent |
|
388 | + '%d', //EVT_order |
|
389 | + '%s', //post_type |
|
390 | + '%s', //status |
|
391 | 391 | ); |
392 | 392 | $success = $wpdb->insert($this->_new_table, |
393 | 393 | $cols_n_values, |
394 | 394 | $datatypes); |
395 | - if( ! $success ){ |
|
395 | + if ( ! $success) { |
|
396 | 396 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes)); |
397 | 397 | return 0; |
398 | 398 | } |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | * @param int $event_id |
406 | 406 | * @return int |
407 | 407 | */ |
408 | - public static function count_registrations($event_id){ |
|
408 | + public static function count_registrations($event_id) { |
|
409 | 409 | global $wpdb; |
410 | - $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d",$event_id)); |
|
410 | + $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d", $event_id)); |
|
411 | 411 | return intval($count); |
412 | 412 | } |
413 | 413 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @param $new_cpt_id |
419 | 419 | * @return int |
420 | 420 | */ |
421 | - private function _insert_event_meta( $old_event, $new_cpt_id){ |
|
421 | + private function _insert_event_meta($old_event, $new_cpt_id) { |
|
422 | 422 | global $wpdb; |
423 | 423 | $event_meta = maybe_unserialize($old_event['event_meta']); |
424 | 424 | // for reference, 3.1 'default_payment_status' are: $default_payment_status = array( |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | //); |
430 | 430 | $default_reg_status = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(isset($event_meta['default_payment_status']) ? $event_meta['default_payment_status'] : '', intval($old_event['require_pre_approval'])); |
431 | 431 | $cols_n_values = array( |
432 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID_fk |
|
432 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID_fk |
|
433 | 433 | 'EVT_display_desc'=> 'Y' == $old_event['display_desc'], |
434 | - 'EVT_display_ticket_selector'=> 'Y'== $old_event['display_reg_form'], |
|
435 | - 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this,$old_event,current_time('mysql'),$old_event['timezone_string']),//don't use the old 'visible_on', as it wasn't ever used |
|
434 | + 'EVT_display_ticket_selector'=> 'Y' == $old_event['display_reg_form'], |
|
435 | + 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this, $old_event, current_time('mysql'), $old_event['timezone_string']), //don't use the old 'visible_on', as it wasn't ever used |
|
436 | 436 | 'EVT_additional_limit'=> $old_event['allow_multiple'] == 'N' ? 1 : $old_event['additional_limit'], |
437 | 437 | 'EVT_default_registration_status' => $default_reg_status, |
438 | 438 | 'EVT_member_only'=>$old_event['member_only'], |
@@ -444,23 +444,23 @@ discard block |
||
444 | 444 | |
445 | 445 | ); |
446 | 446 | $datatypes = array( |
447 | - '%s',//EVT_ID |
|
448 | - '%d',//EVT_display_desc |
|
449 | - '%d',//EVT_display_ticket_selector |
|
450 | - '%s',//EVT_visible_on |
|
451 | - '%d',//EVT_additional_limit |
|
452 | - '%s',//EVT_default_registration_status |
|
453 | - '%d',//EVT_member_only |
|
454 | - '%s',//EVT_phone |
|
455 | - '%d',//EVT_allow_overflow |
|
456 | - '%s',//EVT_timezone_string |
|
457 | - '%s',//EVT_external_URL |
|
458 | - '%d',//EVT_donations |
|
447 | + '%s', //EVT_ID |
|
448 | + '%d', //EVT_display_desc |
|
449 | + '%d', //EVT_display_ticket_selector |
|
450 | + '%s', //EVT_visible_on |
|
451 | + '%d', //EVT_additional_limit |
|
452 | + '%s', //EVT_default_registration_status |
|
453 | + '%d', //EVT_member_only |
|
454 | + '%s', //EVT_phone |
|
455 | + '%d', //EVT_allow_overflow |
|
456 | + '%s', //EVT_timezone_string |
|
457 | + '%s', //EVT_external_URL |
|
458 | + '%d', //EVT_donations |
|
459 | 459 | ); |
460 | 460 | $success = $wpdb->insert($this->_new_meta_table, |
461 | 461 | $cols_n_values, |
462 | 462 | $datatypes); |
463 | - if( ! $success ){ |
|
463 | + if ( ! $success) { |
|
464 | 464 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $cols_n_values, $datatypes)); |
465 | 465 | return 0; |
466 | 466 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | * @param $old_event |
474 | 474 | * @return int |
475 | 475 | */ |
476 | - private function _maybe_create_venue( $old_event){ |
|
477 | - if( $old_event['address'] || |
|
476 | + private function _maybe_create_venue($old_event) { |
|
477 | + if ($old_event['address'] || |
|
478 | 478 | $old_event['address2'] || |
479 | 479 | $old_event['city'] || |
480 | 480 | $old_event['state'] || |
@@ -485,21 +485,21 @@ discard block |
||
485 | 485 | $old_event['venue_phone'] || |
486 | 486 | $old_event['virtual_url'] || |
487 | 487 | $old_event['virtual_phone'] |
488 | - ){ |
|
489 | - $old_id = $this->_duplicate_venue_exists( $old_event ); |
|
490 | - if( $old_id ){ |
|
488 | + ) { |
|
489 | + $old_id = $this->_duplicate_venue_exists($old_event); |
|
490 | + if ($old_id) { |
|
491 | 491 | return $old_id; |
492 | 492 | } |
493 | 493 | $new_id = $this->_insert_venue_into_posts($old_event); |
494 | - if( $new_id ){ |
|
494 | + if ($new_id) { |
|
495 | 495 | $this->_insert_venue_into_meta_table($new_id, $old_event); |
496 | - $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
497 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id,$this); |
|
496 | + $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
497 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
498 | 498 | } |
499 | 499 | //we don't bother recording the conversion from old events to venues as that |
500 | 500 | //will complicate finding the conversion from old venues to new events |
501 | 501 | return $new_id; |
502 | - }else{ |
|
502 | + } else { |
|
503 | 503 | return 0; |
504 | 504 | } |
505 | 505 | } |
@@ -510,29 +510,29 @@ discard block |
||
510 | 510 | * @param array $old_event |
511 | 511 | * @return int duplicate venue id |
512 | 512 | */ |
513 | - private function _duplicate_venue_exists($old_event){ |
|
513 | + private function _duplicate_venue_exists($old_event) { |
|
514 | 514 | global $wpdb; |
515 | 515 | $conditions = array( |
516 | - 'VNU_address' => $old_event [ 'address' ], |
|
517 | - 'VNU_address2' => $old_event[ 'address2' ], |
|
518 | - 'VNU_city' => $old_event[ 'city' ], |
|
519 | - 'VNU_zip' => $old_event[ 'zip' ], |
|
520 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ), |
|
521 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
522 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
523 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
524 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
516 | + 'VNU_address' => $old_event ['address'], |
|
517 | + 'VNU_address2' => $old_event['address2'], |
|
518 | + 'VNU_city' => $old_event['city'], |
|
519 | + 'VNU_zip' => $old_event['zip'], |
|
520 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), |
|
521 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
522 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
523 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
524 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
525 | 525 | ); |
526 | 526 | $sql_conditions = array(); |
527 | - foreach($conditions as $column => $value){ |
|
528 | - $sql_conditions [] = $wpdb->prepare("$column = %s", $value ); |
|
527 | + foreach ($conditions as $column => $value) { |
|
528 | + $sql_conditions [] = $wpdb->prepare("$column = %s", $value); |
|
529 | 529 | } |
530 | 530 | $query = "SELECT VNU_ID |
531 | 531 | FROM |
532 | 532 | {$wpdb->posts} as p INNER JOIN |
533 | 533 | {$wpdb->prefix}esp_venue_meta as v ON p.ID = v.VNU_ID |
534 | - WHERE " . implode( " AND ",$sql_conditions ) . " LIMIT 1"; |
|
535 | - $id = $wpdb->get_var( $query ); |
|
534 | + WHERE ".implode(" AND ", $sql_conditions)." LIMIT 1"; |
|
535 | + $id = $wpdb->get_var($query); |
|
536 | 536 | return $id; |
537 | 537 | } |
538 | 538 | |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | * @param array $event_data_array keys are events_details columns and values are their values |
542 | 542 | * @return string |
543 | 543 | */ |
544 | - protected function _get_venue_title_for_event( $event_data_array ) { |
|
545 | - return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes( sprintf( __( 'Venue of %s', 'event_espresso' ), $event_data_array['event_name'])); |
|
544 | + protected function _get_venue_title_for_event($event_data_array) { |
|
545 | + return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes(sprintf(__('Venue of %s', 'event_espresso'), $event_data_array['event_name'])); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -551,40 +551,40 @@ discard block |
||
551 | 551 | * @param array $old_event keys are cols, values are col values |
552 | 552 | * @return int |
553 | 553 | */ |
554 | - private function _insert_venue_into_posts($old_event){ |
|
554 | + private function _insert_venue_into_posts($old_event) { |
|
555 | 555 | global $wpdb; |
556 | 556 | $insertion_array = array( |
557 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ),//VNU_name |
|
558 | - 'post_content'=>'',//VNU_desc |
|
559 | - 'post_name'=> $this->_find_unique_slug( $old_event['venue_title'], sanitize_title( 'venue-of-' . $old_event['event_name'] ) ),//VNU_identifier |
|
560 | - 'post_date'=>current_time('mysql'),//VNU_created |
|
557 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), //VNU_name |
|
558 | + 'post_content'=>'', //VNU_desc |
|
559 | + 'post_name'=> $this->_find_unique_slug($old_event['venue_title'], sanitize_title('venue-of-'.$old_event['event_name'])), //VNU_identifier |
|
560 | + 'post_date'=>current_time('mysql'), //VNU_created |
|
561 | 561 | 'post_date_gmt'=>get_gmt_from_date(current_time('mysql')), |
562 | - 'post_excerpt'=>'',//VNU_short_desc arbitrary only 50 characters |
|
563 | - 'post_modified'=>current_time('mysql'),//VNU_modified |
|
562 | + 'post_excerpt'=>'', //VNU_short_desc arbitrary only 50 characters |
|
563 | + 'post_modified'=>current_time('mysql'), //VNU_modified |
|
564 | 564 | 'post_modified_gmt'=>get_gmt_from_date(current_time('mysql')), |
565 | - 'post_author'=>$old_event['wp_user'],//VNU_wp_user |
|
566 | - 'post_parent'=>0,//parent |
|
567 | - 'menu_order'=>0,//VNU_order |
|
565 | + 'post_author'=>$old_event['wp_user'], //VNU_wp_user |
|
566 | + 'post_parent'=>0, //parent |
|
567 | + 'menu_order'=>0, //VNU_order |
|
568 | 568 | 'post_type'=>'espresso_venues'//post_type |
569 | 569 | ); |
570 | 570 | $datatypes_array = array( |
571 | - '%s',//VNU_name |
|
572 | - '%s',//VNU_desc |
|
573 | - '%s',//VNU_identifier |
|
574 | - '%s',//VNU_created |
|
571 | + '%s', //VNU_name |
|
572 | + '%s', //VNU_desc |
|
573 | + '%s', //VNU_identifier |
|
574 | + '%s', //VNU_created |
|
575 | 575 | '%s', |
576 | - '%s',//VNU_short_desc |
|
577 | - '%s',//VNU_modified |
|
576 | + '%s', //VNU_short_desc |
|
577 | + '%s', //VNU_modified |
|
578 | 578 | '%s', |
579 | - '%d',//VNU_wp_user |
|
580 | - '%d',//parent |
|
581 | - '%d',//VNU_order |
|
582 | - '%s',//post_type |
|
579 | + '%d', //VNU_wp_user |
|
580 | + '%d', //parent |
|
581 | + '%d', //VNU_order |
|
582 | + '%s', //post_type |
|
583 | 583 | ); |
584 | 584 | $success = $wpdb->insert($wpdb->posts, |
585 | 585 | $insertion_array, |
586 | 586 | $datatypes_array); |
587 | - if( ! $success ){ |
|
587 | + if ( ! $success) { |
|
588 | 588 | $this->add_error( |
589 | 589 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
590 | 590 | $this->_old_table, |
@@ -605,64 +605,64 @@ discard block |
||
605 | 605 | * @param array $old_event |
606 | 606 | * @return int |
607 | 607 | */ |
608 | - private function _insert_venue_into_meta_table($cpt_id,$old_event){ |
|
608 | + private function _insert_venue_into_meta_table($cpt_id, $old_event) { |
|
609 | 609 | global $wpdb; |
610 | 610 | |
611 | 611 | //assume the country is the same as the organization's old settings |
612 | 612 | $country_iso = $this->get_migration_script()->get_default_country_iso(); |
613 | 613 | //find the state from the venue, or the organization, or just guess california |
614 | - if( ! $old_event['state']){ |
|
614 | + if ( ! $old_event['state']) { |
|
615 | 615 | $old_org_options = get_option('events_organization_settings'); |
616 | 616 | $state_name = stripslashes($old_org_options['organization_state']); |
617 | - }else{ |
|
617 | + } else { |
|
618 | 618 | $state_name = $old_event['state']; |
619 | 619 | } |
620 | - if ( ! $state_name ){ |
|
620 | + if ( ! $state_name) { |
|
621 | 621 | $state_name = 'CA'; |
622 | 622 | } |
623 | 623 | //get a state ID with the same name, if possible |
624 | - try{ |
|
625 | - $state = $this->get_migration_script()->get_or_create_state($state_name,$country_iso); |
|
624 | + try { |
|
625 | + $state = $this->get_migration_script()->get_or_create_state($state_name, $country_iso); |
|
626 | 626 | $state_id = $state['STA_ID']; |
627 | - }catch(EE_Error $e){ |
|
627 | + } catch (EE_Error $e) { |
|
628 | 628 | $this->add_error($e->getMessage()); |
629 | 629 | $state_id = 0; |
630 | 630 | } |
631 | 631 | //now insert into meta table |
632 | 632 | $insertion_array = array( |
633 | - 'VNU_ID'=>$cpt_id,//VNU_ID_fk |
|
634 | - 'VNU_address'=>stripslashes($old_event['address']),//VNU_address |
|
635 | - 'VNU_address2'=>stripslashes($old_event['address2']),//VNU_address2 |
|
636 | - 'VNU_city'=>stripslashes($old_event['city']),//VNU_city |
|
637 | - 'STA_ID'=>$state_id,//STA_ID |
|
638 | - 'CNT_ISO'=>$country_iso,//CNT_ISO |
|
639 | - 'VNU_zip'=>$old_event['zip'],//VNU_zip |
|
640 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
641 | - 'VNU_capacity'=>-1,//VNU_capacity |
|
642 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
643 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
644 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
645 | - 'VNU_google_map_link'=>'',//VNU_google_map_link |
|
633 | + 'VNU_ID'=>$cpt_id, //VNU_ID_fk |
|
634 | + 'VNU_address'=>stripslashes($old_event['address']), //VNU_address |
|
635 | + 'VNU_address2'=>stripslashes($old_event['address2']), //VNU_address2 |
|
636 | + 'VNU_city'=>stripslashes($old_event['city']), //VNU_city |
|
637 | + 'STA_ID'=>$state_id, //STA_ID |
|
638 | + 'CNT_ISO'=>$country_iso, //CNT_ISO |
|
639 | + 'VNU_zip'=>$old_event['zip'], //VNU_zip |
|
640 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
641 | + 'VNU_capacity'=>-1, //VNU_capacity |
|
642 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
643 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
644 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
645 | + 'VNU_google_map_link'=>'', //VNU_google_map_link |
|
646 | 646 | 'VNU_enable_for_gmap'=>true //VNU_enable_for_gmap |
647 | 647 | ); |
648 | 648 | $datatypes = array( |
649 | - '%d',//VNU_ID_fk |
|
650 | - '%s',//VNU_address |
|
651 | - '%s',//VNU_address2 |
|
652 | - '%s',//VNU_city |
|
653 | - '%d',//STA_ID |
|
654 | - '%s',//CNT_ISO |
|
655 | - '%s',//VNU_zip |
|
656 | - '%s',//VNU_phone |
|
657 | - '%d',//VNU_capacity |
|
658 | - '%s',//VNU_url |
|
659 | - '%s',//VNU_virtual_phone |
|
660 | - '%s',//VNU_virtual_url |
|
661 | - '%s',//VNU_google_map_link |
|
662 | - '%d',//VNU_enable_for_gmap |
|
649 | + '%d', //VNU_ID_fk |
|
650 | + '%s', //VNU_address |
|
651 | + '%s', //VNU_address2 |
|
652 | + '%s', //VNU_city |
|
653 | + '%d', //STA_ID |
|
654 | + '%s', //CNT_ISO |
|
655 | + '%s', //VNU_zip |
|
656 | + '%s', //VNU_phone |
|
657 | + '%d', //VNU_capacity |
|
658 | + '%s', //VNU_url |
|
659 | + '%s', //VNU_virtual_phone |
|
660 | + '%s', //VNU_virtual_url |
|
661 | + '%s', //VNU_google_map_link |
|
662 | + '%d', //VNU_enable_for_gmap |
|
663 | 663 | ); |
664 | - $success = $wpdb->insert($wpdb->prefix."esp_venue_meta",$insertion_array,$datatypes); |
|
665 | - if( ! $success ){ |
|
664 | + $success = $wpdb->insert($wpdb->prefix."esp_venue_meta", $insertion_array, $datatypes); |
|
665 | + if ( ! $success) { |
|
666 | 666 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $insertion_array, $datatypes)); |
667 | 667 | return 0; |
668 | 668 | } |
@@ -676,14 +676,14 @@ discard block |
||
676 | 676 | * @param $new_venue_id |
677 | 677 | * @return int |
678 | 678 | */ |
679 | - private function _insert_new_venue_to_event( $new_event_id, $new_venue_id){ |
|
679 | + private function _insert_new_venue_to_event($new_event_id, $new_venue_id) { |
|
680 | 680 | global $wpdb; |
681 | - if( ! $new_event_id){ |
|
682 | - $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"),$new_event_id)); |
|
681 | + if ( ! $new_event_id) { |
|
682 | + $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $new_event_id)); |
|
683 | 683 | return 0; |
684 | 684 | } |
685 | - if( ! $new_venue_id){ |
|
686 | - $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"),$new_venue_id)); |
|
685 | + if ( ! $new_venue_id) { |
|
686 | + $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $new_venue_id)); |
|
687 | 687 | return 0; |
688 | 688 | } |
689 | 689 | $cols_n_values = array( |
@@ -692,12 +692,12 @@ discard block |
||
692 | 692 | 'EVV_primary'=>true |
693 | 693 | ); |
694 | 694 | $datatypes = array( |
695 | - '%d',//EVT_ID |
|
696 | - '%d',//VNU_ID |
|
697 | - '%d',//EVT_primary |
|
695 | + '%d', //EVT_ID |
|
696 | + '%d', //VNU_ID |
|
697 | + '%d', //EVT_primary |
|
698 | 698 | ); |
699 | - $success = $wpdb->insert($wpdb->prefix."esp_event_venue",$cols_n_values,$datatypes); |
|
700 | - if ( ! $success){ |
|
699 | + $success = $wpdb->insert($wpdb->prefix."esp_event_venue", $cols_n_values, $datatypes); |
|
700 | + if ( ! $success) { |
|
701 | 701 | $this->add_error( |
702 | 702 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
703 | 703 | $this->_old_table, |
@@ -719,11 +719,11 @@ discard block |
||
719 | 719 | * @param int $new_cpt_id new post ID |
720 | 720 | * @return void (if there are errors though, adds them to the stage's error list |
721 | 721 | */ |
722 | - private function _convert_start_end_times($old_event,$new_cpt_id){ |
|
722 | + private function _convert_start_end_times($old_event, $new_cpt_id) { |
|
723 | 723 | $start_end_times = $this->_get_old_start_end_times($old_event['id']); |
724 | - foreach($start_end_times as $start_end_time){ |
|
725 | - $datetime_id = $this->_insert_new_datetime($start_end_time,$old_event,$new_cpt_id); |
|
726 | - if($datetime_id){ |
|
724 | + foreach ($start_end_times as $start_end_time) { |
|
725 | + $datetime_id = $this->_insert_new_datetime($start_end_time, $old_event, $new_cpt_id); |
|
726 | + if ($datetime_id) { |
|
727 | 727 | $this->get_migration_script()->set_mapping($this->_old_start_end_table, $start_end_time['id'], $this->_new_datetime_table, $datetime_id); |
728 | 728 | } |
729 | 729 | } |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | * @param int $old_event_id |
735 | 735 | * @return array |
736 | 736 | */ |
737 | - private function _get_old_start_end_times($old_event_id){ |
|
737 | + private function _get_old_start_end_times($old_event_id) { |
|
738 | 738 | global $wpdb; |
739 | - return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d",$old_event_id),ARRAY_A); |
|
739 | + return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d", $old_event_id), ARRAY_A); |
|
740 | 740 | } |
741 | 741 | /** |
742 | 742 | * Inserts a 4.1 datetime given the 3.1 start_end db row and event_details row |
@@ -745,40 +745,40 @@ discard block |
||
745 | 745 | * @param int $new_cpt_id |
746 | 746 | * @return int ID of new datetime |
747 | 747 | */ |
748 | - private function _insert_new_datetime($start_end_time_row,$old_event_row,$new_cpt_id){ |
|
748 | + private function _insert_new_datetime($start_end_time_row, $old_event_row, $new_cpt_id) { |
|
749 | 749 | global $wpdb; |
750 | 750 | $start_date = $old_event_row['start_date']; |
751 | 751 | $start_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['start_time']); |
752 | 752 | $end_date = $old_event_row['end_date']; |
753 | 753 | $end_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['end_time']); |
754 | 754 | $existing_datetimes = $this->_count_other_datetimes_exist_for_new_event($new_cpt_id); |
755 | - $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$start_date $start_time:00",$old_event_row['timezone_string']); |
|
756 | - $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$end_date $end_time:00",$old_event_row['timezone_string']); |
|
755 | + $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$start_date $start_time:00", $old_event_row['timezone_string']); |
|
756 | + $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$end_date $end_time:00", $old_event_row['timezone_string']); |
|
757 | 757 | $cols_n_values = array( |
758 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID |
|
759 | - 'DTT_EVT_start'=>$start_datetime_utc,//DTT_EVT_start |
|
760 | - 'DTT_EVT_end'=> $end_datetime_utc,//DTT_EVT_end |
|
761 | - 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'],//DTT_reg_limit |
|
762 | - 'DTT_sold'=>0,//note: we will increment this as registrations are added during the migration |
|
758 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID |
|
759 | + 'DTT_EVT_start'=>$start_datetime_utc, //DTT_EVT_start |
|
760 | + 'DTT_EVT_end'=> $end_datetime_utc, //DTT_EVT_end |
|
761 | + 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'], //DTT_reg_limit |
|
762 | + 'DTT_sold'=>0, //note: we will increment this as registrations are added during the migration |
|
763 | 763 | // 'DTT_is_primary'=> 0 == $existing_datetimes ,//DTT_is_primary... if count==0, then we'll call it the 'primary' |
764 | - 'DTT_order'=> $existing_datetimes,//DTT_order, just give it the same order as the count of how many datetimes already exist |
|
764 | + 'DTT_order'=> $existing_datetimes, //DTT_order, just give it the same order as the count of how many datetimes already exist |
|
765 | 765 | 'DTT_parent'=>0, |
766 | 766 | 'DTT_deleted'=>false |
767 | 767 | ); |
768 | 768 | $datatypes = array( |
769 | - '%d',//EVT_Id |
|
770 | - '%s',//DTT_EVT_start |
|
771 | - '%s',//DTT_EVT_end |
|
772 | - '%d',//DTT_reg_limit |
|
773 | - '%d',//DTT_sold |
|
769 | + '%d', //EVT_Id |
|
770 | + '%s', //DTT_EVT_start |
|
771 | + '%s', //DTT_EVT_end |
|
772 | + '%d', //DTT_reg_limit |
|
773 | + '%d', //DTT_sold |
|
774 | 774 | // '%d',//DTT_is_primary |
775 | - '%d',//DTT_order |
|
776 | - '%d',//DTT_parent |
|
777 | - '%d',//DTT_deleted |
|
775 | + '%d', //DTT_order |
|
776 | + '%d', //DTT_parent |
|
777 | + '%d', //DTT_deleted |
|
778 | 778 | ); |
779 | - $success = $wpdb->insert($this->_new_datetime_table,$cols_n_values,$datatypes); |
|
780 | - if ( ! $success){ |
|
781 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row,$start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
779 | + $success = $wpdb->insert($this->_new_datetime_table, $cols_n_values, $datatypes); |
|
780 | + if ( ! $success) { |
|
781 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row, $start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
782 | 782 | return 0; |
783 | 783 | } |
784 | 784 | return $wpdb->insert_id; |
@@ -791,9 +791,9 @@ discard block |
||
791 | 791 | * @param int $cpt_event_id |
792 | 792 | * @return int |
793 | 793 | */ |
794 | - private function _count_other_datetimes_exist_for_new_event($cpt_event_id){ |
|
794 | + private function _count_other_datetimes_exist_for_new_event($cpt_event_id) { |
|
795 | 795 | global $wpdb; |
796 | - $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d",$cpt_event_id)); |
|
796 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d", $cpt_event_id)); |
|
797 | 797 | return intval($count); |
798 | 798 | } |
799 | 799 |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param int $PAY_ID |
171 | 171 | */ |
172 | 172 | public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) { |
173 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
173 | + do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
174 | 174 | if ( absint( $TXN_ID )) { |
175 | 175 | self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
176 | 176 | add_action( |
@@ -303,7 +303,6 @@ discard block |
||
303 | 303 | |
304 | 304 | /** |
305 | 305 | * finalize_abandoned_transactions |
306 | - |
|
307 | 306 | * loops through the self::$_abandoned_transactions array |
308 | 307 | * and attempts to finalize any TXNs that have not been completed |
309 | 308 | * but have had their sessions expired, most likely due to a user not |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return EE_Cron_Tasks |
29 | 29 | */ |
30 | 30 | public static function instance() { |
31 | - if ( ! self::$_instance instanceof EE_Cron_Tasks ) { |
|
31 | + if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
32 | 32 | self::$_instance = new self(); |
33 | 33 | } |
34 | 34 | return self::$_instance; |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * @return EE_Cron_Tasks |
42 | 42 | */ |
43 | 43 | private function __construct() { |
44 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
44 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
45 | 45 | // verify that WP Cron is enabled |
46 | - if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON && is_admin() ) { |
|
46 | + if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON && is_admin()) { |
|
47 | 47 | EE_Error::add_persistent_admin_notice( |
48 | 48 | 'wp_cron_disabled', |
49 | 49 | sprintf( |
@@ -58,26 +58,26 @@ discard block |
||
58 | 58 | // UPDATE TRANSACTION WITH PAYMENT |
59 | 59 | add_action( |
60 | 60 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
61 | - array( 'EE_Cron_Tasks', 'setup_update_for_transaction_with_payment' ), |
|
61 | + array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
62 | 62 | 10, 2 |
63 | 63 | ); |
64 | 64 | // FINALIZE ABANDONED TRANSACTIONS |
65 | 65 | add_action( |
66 | 66 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
67 | - array( 'EE_Cron_Tasks', 'check_for_abandoned_transactions' ), |
|
67 | + array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
68 | 68 | 10, 1 |
69 | 69 | ); |
70 | 70 | // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
71 | 71 | add_action( |
72 | 72 | 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
73 | - array( 'EE_Cron_Tasks', 'clean_out_junk_transactions' ) |
|
73 | + array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
74 | 74 | ); |
75 | 75 | // logging |
76 | 76 | add_action( |
77 | 77 | 'AHEE__EE_System__load_core_configuration__complete', |
78 | - array( 'EE_Cron_Tasks', 'log_scheduled_ee_crons' ) |
|
78 | + array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
79 | 79 | ); |
80 | - EE_Registry::instance()->load_lib( 'Messages_Scheduler' ); |
|
80 | + EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
93 | 93 | 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
94 | 94 | ); |
95 | - $crons = get_option( 'cron' ); |
|
96 | - if ( ! is_array( $crons ) ) { |
|
95 | + $crons = get_option('cron'); |
|
96 | + if ( ! is_array($crons)) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | - foreach ( $crons as $timestamp => $cron ) { |
|
100 | - foreach ( $ee_crons as $ee_cron ) { |
|
101 | - if ( isset( $cron[ $ee_cron ] ) ) { |
|
102 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron' ); |
|
103 | - foreach ( $cron[ $ee_cron ] as $ee_cron_details ) { |
|
104 | - if ( ! empty( $ee_cron_details[ 'args' ] )) { |
|
105 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, print_r( $ee_cron_details[ 'args' ], true ), "$ee_cron args" ); |
|
99 | + foreach ($crons as $timestamp => $cron) { |
|
100 | + foreach ($ee_crons as $ee_cron) { |
|
101 | + if (isset($cron[$ee_cron])) { |
|
102 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
103 | + foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
104 | + if ( ! empty($ee_cron_details['args'])) { |
|
105 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, print_r($ee_cron_details['args'], true), "$ee_cron args"); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | $TXN_ID, |
140 | 140 | $PAY_ID |
141 | 141 | ) { |
142 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
142 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
143 | 143 | // validate $TXN_ID and $timestamp |
144 | - $TXN_ID = absint( $TXN_ID ); |
|
145 | - $timestamp = absint( $timestamp ); |
|
146 | - if ( $TXN_ID && $timestamp ) { |
|
144 | + $TXN_ID = absint($TXN_ID); |
|
145 | + $timestamp = absint($timestamp); |
|
146 | + if ($TXN_ID && $timestamp) { |
|
147 | 147 | wp_schedule_single_event( |
148 | 148 | $timestamp, |
149 | 149 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
150 | - array( $TXN_ID, $PAY_ID ) |
|
150 | + array($TXN_ID, $PAY_ID) |
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 | } |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | * @param int $TXN_ID |
170 | 170 | * @param int $PAY_ID |
171 | 171 | */ |
172 | - public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) { |
|
173 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
174 | - if ( absint( $TXN_ID )) { |
|
175 | - self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
|
172 | + public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) { |
|
173 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
174 | + if (absint($TXN_ID)) { |
|
175 | + self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
176 | 176 | add_action( |
177 | 177 | 'shutdown', |
178 | - array( 'EE_Cron_Tasks', 'update_transaction_with_payment' ), |
|
178 | + array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
179 | 179 | 5 |
180 | 180 | ); |
181 | 181 | } |
@@ -194,18 +194,18 @@ discard block |
||
194 | 194 | * @throws \EE_Error |
195 | 195 | */ |
196 | 196 | public static function update_transaction_with_payment() { |
197 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
197 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
198 | 198 | // are there any TXNs that need cleaning up ? |
199 | - if ( ! empty( self::$_update_transactions_with_payment ) ) { |
|
199 | + if ( ! empty(self::$_update_transactions_with_payment)) { |
|
200 | 200 | /** @type EE_Payment_Processor $payment_processor */ |
201 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
201 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
202 | 202 | // set revisit flag for payment processor |
203 | - $payment_processor->set_revisit( false ); |
|
203 | + $payment_processor->set_revisit(false); |
|
204 | 204 | // load EEM_Transaction |
205 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
206 | - foreach ( self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID ) { |
|
205 | + EE_Registry::instance()->load_model('Transaction'); |
|
206 | + foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
207 | 207 | // reschedule the cron if we can't hit the db right now |
208 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
208 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
209 | 209 | // reset cron job for updating the TXN |
210 | 210 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
211 | 211 | time() + EE_Cron_Tasks::reschedule_timeout, |
@@ -214,14 +214,14 @@ discard block |
||
214 | 214 | ); |
215 | 215 | continue; |
216 | 216 | } |
217 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
218 | - $payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID ); |
|
217 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
218 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
219 | 219 | // verify transaction |
220 | - if ( $transaction instanceof EE_Transaction && $payment instanceof EE_Payment ) { |
|
220 | + if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
221 | 221 | // now try to update the TXN with any payments |
222 | - $payment_processor->update_txn_based_on_payment( $transaction, $payment, true, true ); |
|
222 | + $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
223 | 223 | } |
224 | - unset( self::$_update_transactions_with_payment[ $TXN_ID ] ); |
|
224 | + unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | $TXN_ID |
259 | 259 | ) { |
260 | 260 | // validate $TXN_ID and $timestamp |
261 | - $TXN_ID = absint( $TXN_ID ); |
|
262 | - $timestamp = absint( $timestamp ); |
|
263 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
264 | - if ( $TXN_ID && $timestamp ) { |
|
261 | + $TXN_ID = absint($TXN_ID); |
|
262 | + $timestamp = absint($timestamp); |
|
263 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
264 | + if ($TXN_ID && $timestamp) { |
|
265 | 265 | wp_schedule_single_event( |
266 | 266 | $timestamp, |
267 | 267 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
268 | - array( $TXN_ID ) |
|
268 | + array($TXN_ID) |
|
269 | 269 | ); |
270 | 270 | } |
271 | 271 | } |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @param int $TXN_ID |
289 | 289 | */ |
290 | - public static function check_for_abandoned_transactions( $TXN_ID = 0 ) { |
|
291 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
292 | - if ( absint( $TXN_ID )) { |
|
293 | - self::$_abandoned_transactions[] = $TXN_ID; |
|
290 | + public static function check_for_abandoned_transactions($TXN_ID = 0) { |
|
291 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
292 | + if (absint($TXN_ID)) { |
|
293 | + self::$_abandoned_transactions[] = $TXN_ID; |
|
294 | 294 | add_action( |
295 | 295 | 'shutdown', |
296 | - array( 'EE_Cron_Tasks', 'finalize_abandoned_transactions' ), |
|
296 | + array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
297 | 297 | 5 |
298 | 298 | ); |
299 | 299 | } |
@@ -312,21 +312,21 @@ discard block |
||
312 | 312 | * @throws \EE_Error |
313 | 313 | */ |
314 | 314 | public static function finalize_abandoned_transactions() { |
315 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
315 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
316 | 316 | // are there any TXNs that need cleaning up ? |
317 | - if ( ! empty( self::$_abandoned_transactions ) ) { |
|
317 | + if ( ! empty(self::$_abandoned_transactions)) { |
|
318 | 318 | /** @type EE_Transaction_Processor $transaction_processor */ |
319 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
319 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
320 | 320 | // set revisit flag for txn processor |
321 | - $transaction_processor->set_revisit( false ); |
|
321 | + $transaction_processor->set_revisit(false); |
|
322 | 322 | /** @type EE_Payment_Processor $payment_processor */ |
323 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
323 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
324 | 324 | // load EEM_Transaction |
325 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
326 | - foreach ( self::$_abandoned_transactions as $TXN_ID ) { |
|
327 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
325 | + EE_Registry::instance()->load_model('Transaction'); |
|
326 | + foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
327 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
328 | 328 | // reschedule the cron if we can't hit the db right now |
329 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
329 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
330 | 330 | // reset cron job for finalizing the TXN |
331 | 331 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
332 | 332 | time() + EE_Cron_Tasks::reschedule_timeout, |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | ); |
335 | 335 | continue; |
336 | 336 | } |
337 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
337 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
338 | 338 | // verify transaction |
339 | - if ( $transaction instanceof EE_Transaction ) { |
|
339 | + if ($transaction instanceof EE_Transaction) { |
|
340 | 340 | // don't finalize the TXN if it has already been completed |
341 | - if ( $transaction->all_reg_steps_completed() === true ) { |
|
341 | + if ($transaction->all_reg_steps_completed() === true) { |
|
342 | 342 | continue; |
343 | 343 | } |
344 | 344 | // let's simulate an IPN here which will trigger any notifications that need to go out |
345 | - $payment_processor->update_txn_based_on_payment( $transaction, $transaction->last_payment(), true, true ); |
|
345 | + $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true); |
|
346 | 346 | } |
347 | - unset( self::$_abandoned_transactions[ $TXN_ID ] ); |
|
347 | + unset(self::$_abandoned_transactions[$TXN_ID]); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | //when a transaction is initially made, schedule this check. |
361 | 361 | //if it has NO REG data by the time it has expired, forget about it |
362 | 362 | public static function clean_out_junk_transactions() { |
363 | - if( EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
363 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
364 | 364 | EEM_Transaction::instance('')->delete_junk_transactions(); |
365 | 365 | EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
366 | 366 | EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
@@ -282,7 +282,7 @@ |
||
282 | 282 | /** |
283 | 283 | * Gets the first event for this payment (it's possible that it could be for multiple) |
284 | 284 | * @param EEI_Payment $payment |
285 | - * @return EEI_Event|null |
|
285 | + * @return EE_Event|null |
|
286 | 286 | */ |
287 | 287 | protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
288 | 288 | $transaction = $payment->transaction(); |
@@ -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 | } |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * @param EEI_Payment $payment |
285 | 285 | * @return EEI_Event|null |
286 | 286 | */ |
287 | - protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
|
287 | + protected function _get_first_event_for_payment(EEI_Payment $payment) { |
|
288 | 288 | $transaction = $payment->transaction(); |
289 | - if( $transaction instanceof EEI_Transaction ) { |
|
289 | + if ($transaction instanceof EEI_Transaction) { |
|
290 | 290 | $primary_registrant = $transaction->primary_registration(); |
291 | - if( $primary_registrant instanceof EE_Registration ) { |
|
291 | + if ($primary_registrant instanceof EE_Registration) { |
|
292 | 292 | return $primary_registrant->event_obj(); |
293 | 293 | } |
294 | 294 | } |
@@ -300,19 +300,19 @@ discard block |
||
300 | 300 | * @param EEI_Payment $payment |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
|
304 | - $event = $this->_get_first_event_for_payment( $payment ); |
|
305 | - return $event instanceof EEI_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
303 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) { |
|
304 | + $event = $this->_get_first_event_for_payment($payment); |
|
305 | + return $event instanceof EEI_Event ? $event->name() : __('Event', 'event_espresso'); |
|
306 | 306 | } |
307 | 307 | /** |
308 | 308 | * Gets the text to use for a gateway's line item name when this is a partial payment |
309 | 309 | * @param EE_Payment $payment |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - protected function _format_partial_payment_line_item_name( EEI_Payment $payment ){ |
|
312 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) { |
|
313 | 313 | return apply_filters( |
314 | 314 | 'EEG_Paypal_Pro__do_direct_payment__partial_amount_line_item_name', |
315 | - $this->_get_first_event_name_for_payment( $payment ), |
|
315 | + $this->_get_first_event_name_for_payment($payment), |
|
316 | 316 | $this, |
317 | 317 | $payment |
318 | 318 | ); |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | * @param EEI_Payment $payment |
323 | 323 | * @return string |
324 | 324 | */ |
325 | - protected function _format_partial_payment_line_item_desc( EEI_Payment $payment ) { |
|
325 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) { |
|
326 | 326 | return apply_filters( |
327 | 327 | 'FHEE__EE_Gateway___partial_payment_desc', |
328 | 328 | sprintf( |
329 | 329 | __("Payment of %s for %s", "event_espresso"), |
330 | - $payment->get_pretty( 'PAY_amount', 'no_currency_code' ), |
|
331 | - $this->_get_first_event_name_for_payment( $payment ) ), |
|
330 | + $payment->get_pretty('PAY_amount', 'no_currency_code'), |
|
331 | + $this->_get_first_event_name_for_payment($payment) ), |
|
332 | 332 | $this, |
333 | 333 | $payment |
334 | 334 | ); |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | * @param EEI_Payment $payment |
341 | 341 | * @return string |
342 | 342 | */ |
343 | - protected function _format_line_item_name( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
343 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
344 | 344 | return apply_filters( |
345 | 345 | 'FHEE__EE_gateway___line_item_name', |
346 | - sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), |
|
346 | + sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), |
|
347 | 347 | $this, |
348 | 348 | $line_item, |
349 | 349 | $payment |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param EEI_Payment $payment |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - protected function _format_line_item_desc( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
359 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
360 | 360 | return apply_filters( |
361 | 361 | 'FHEE__EE_Gateway___line_item_desc', |
362 | 362 | $line_item->desc(), |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | * @return type |
373 | 373 | */ |
374 | - protected function _format_order_description( EEI_Payment $payment ) { |
|
374 | + protected function _format_order_description(EEI_Payment $payment) { |
|
375 | 375 | return apply_filters( |
376 | 376 | 'FHEE__EE_Gateway___order_description', |
377 | 377 | sprintf( |
378 | 378 | __('Event Registrations from %1$s for %2$s', "event_espresso"), |
379 | 379 | get_bloginfo('name'), |
380 | - $this->_get_first_event_name_for_payment( $payment ) ), |
|
380 | + $this->_get_first_event_name_for_payment($payment) ), |
|
381 | 381 | $this, |
382 | 382 | $payment |
383 | 383 | ); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @author Mike Nelson |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEG_Mijireh extends EE_Offsite_Gateway{ |
|
11 | +class EEG_Mijireh extends EE_Offsite_Gateway { |
|
12 | 12 | |
13 | 13 | protected $_access_key; |
14 | 14 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | $primary_attendee = $primary_registrant->attendee(); |
38 | 38 | $items = array(); |
39 | 39 | //if we're are charging for the full amount, show the normal line items |
40 | - if( $this->_can_easily_itemize_transaction_for( $payment )){ |
|
40 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
41 | 41 | $total_line_item = $transaction->total_line_item(); |
42 | 42 | $tax_total = $total_line_item->get_total_tax(); |
43 | - foreach($total_line_item->get_items() as $line_item){ |
|
43 | + foreach ($total_line_item->get_items() as $line_item) { |
|
44 | 44 | $items[] = array( |
45 | 45 | 'name'=>apply_filters( |
46 | 46 | 'FHEE__EEG_Mijireh__set_redirection_info__full_amount_line_item_name', |
47 | - $this->_format_line_item_name( $line_item, $payment ), |
|
47 | + $this->_format_line_item_name($line_item, $payment), |
|
48 | 48 | $line_item, |
49 | 49 | $payment, |
50 | 50 | $primary_registrant |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | 'quantity'=>$line_item->quantity() |
55 | 55 | ); |
56 | 56 | } |
57 | - }else{//its a partial payment |
|
57 | + } else {//its a partial payment |
|
58 | 58 | $tax_total = 0; |
59 | 59 | //partial payment, so just add 1 item |
60 | 60 | $items[] = array( |
61 | 61 | 'name'=> apply_filters( |
62 | 62 | 'FHEE__EEG_Mijireh__set_redirection_info__partial_amount_line_item_name', |
63 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
63 | + $this->_format_partial_payment_line_item_name($payment), |
|
64 | 64 | $payment, |
65 | 65 | $primary_registrant |
66 | 66 | ), |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | $order = array( |
73 | 73 | 'total'=>$this->format_currency($payment->amount()), |
74 | 74 | 'return_url'=>$return_url, |
75 | - 'items'=>$this->_prepare_for_mijireh( $items ), |
|
75 | + 'items'=>$this->_prepare_for_mijireh($items), |
|
76 | 76 | 'email'=>$primary_attendee->email(), |
77 | 77 | 'first_name'=>$primary_attendee->fname(), |
78 | 78 | 'last_name'=>$primary_attendee->lname(), |
79 | 79 | 'tax'=>$this->format_currency($tax_total), |
80 | 80 | 'partner_id'=>'ee'); |
81 | 81 | //setup address? |
82 | - if( $primary_attendee->address() && |
|
83 | - $primary_attendee->city() && |
|
84 | - $primary_attendee->state_ID() && |
|
85 | - $primary_attendee->country_ID() && |
|
86 | - $primary_attendee->zip() ){ |
|
82 | + if ($primary_attendee->address() && |
|
83 | + $primary_attendee->city() && |
|
84 | + $primary_attendee->state_ID() && |
|
85 | + $primary_attendee->country_ID() && |
|
86 | + $primary_attendee->zip()) { |
|
87 | 87 | $shipping_address = array( |
88 | 88 | 'first_name'=>$primary_attendee->fname(), |
89 | 89 | 'last_name'=>$primary_attendee->lname(), |
@@ -93,62 +93,62 @@ discard block |
||
93 | 93 | 'zip_code' => $primary_attendee->zip(), |
94 | 94 | 'country' => $primary_attendee->country_ID() |
95 | 95 | ); |
96 | - if( $primary_attendee->address2() ){ |
|
97 | - $shipping_address[ 'apt_suite' ] = $primary_attendee->address2(); |
|
96 | + if ($primary_attendee->address2()) { |
|
97 | + $shipping_address['apt_suite'] = $primary_attendee->address2(); |
|
98 | 98 | } |
99 | - if( $primary_attendee->phone() ){ |
|
100 | - $shipping_address[ 'phone' ] = $primary_attendee->phone(); |
|
99 | + if ($primary_attendee->phone()) { |
|
100 | + $shipping_address['phone'] = $primary_attendee->phone(); |
|
101 | 101 | } |
102 | - $order[ 'shipping_address' ] = $shipping_address; |
|
102 | + $order['shipping_address'] = $shipping_address; |
|
103 | 103 | } |
104 | - $order = apply_filters( 'FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant ); |
|
105 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)) ); |
|
104 | + $order = apply_filters('FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant); |
|
105 | + do_action('AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this))); |
|
106 | 106 | $args = array( |
107 | 107 | 'headers' => array( |
108 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
108 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
109 | 109 | 'Accept'=>'application/json' |
110 | 110 | ), |
111 | 111 | 'body'=> json_encode($order) |
112 | 112 | ); |
113 | - $response = wp_remote_post( $this->_mijireh_api_orders_url, $args ); |
|
113 | + $response = wp_remote_post($this->_mijireh_api_orders_url, $args); |
|
114 | 114 | $problems_string = false; |
115 | - $this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment); |
|
116 | - if( ! $response instanceof WP_Error ){ |
|
115 | + $this->log(array('get checkout url request_args' => $args, 'response' => $response), $payment); |
|
116 | + if ( ! $response instanceof WP_Error) { |
|
117 | 117 | $response_body = json_decode($response['body']); |
118 | - if($response_body && isset($response_body->checkout_url)){ |
|
118 | + if ($response_body && isset($response_body->checkout_url)) { |
|
119 | 119 | $payment->set_redirect_url($response_body->checkout_url); |
120 | 120 | $payment->set_txn_id_chq_nmbr($response_body->order_number); |
121 | 121 | $payment->set_details($response['body']); |
122 | 122 | } else { |
123 | - if( is_array( $response_body ) || is_object( $response_body)){ |
|
124 | - $response_body_as_array = (array)$response_body; |
|
125 | - foreach($response_body_as_array as $problem_parameter => $problems){ |
|
126 | - $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
123 | + if (is_array($response_body) || is_object($response_body)) { |
|
124 | + $response_body_as_array = (array) $response_body; |
|
125 | + foreach ($response_body_as_array as $problem_parameter => $problems) { |
|
126 | + $problems_string .= sprintf(__('\nProblems with %s: %s', 'event_espresso'), $problem_parameter, implode(", ", $problems)); |
|
127 | 127 | } |
128 | - }else{ |
|
128 | + } else { |
|
129 | 129 | $problems_string = $response['body']; |
130 | 130 | } |
131 | - if( ! $problems_string ) { |
|
131 | + if ( ! $problems_string) { |
|
132 | 132 | //no message to show? wack |
133 | - if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
134 | - $problems_string = $response[ 'headers' ][ 'status' ]; |
|
135 | - }else{ |
|
136 | - $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
133 | + if (isset($response['headers']['status'])) { |
|
134 | + $problems_string = $response['headers']['status']; |
|
135 | + } else { |
|
136 | + $problems_string = __('No response from Mijireh', 'event_espresso'); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | } |
140 | - }else{ |
|
141 | - $problems_string = implode( ",", $response->get_error_messages() ); |
|
140 | + } else { |
|
141 | + $problems_string = implode(",", $response->get_error_messages()); |
|
142 | 142 | } |
143 | 143 | |
144 | - if( $problems_string ) { |
|
145 | - $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
146 | - $payment->set_details( $response ); |
|
147 | - $payment->set_redirect_url( null ); |
|
144 | + if ($problems_string) { |
|
145 | + $payment->set_gateway_response(sprintf(__('Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string)); |
|
146 | + $payment->set_details($response); |
|
147 | + $payment->set_redirect_url(null); |
|
148 | 148 | //even though the payment's status is failed at this point anyways, |
149 | 149 | //let's be explicit about it. The fact that the redirect url is null |
150 | 150 | //should be enough to client code that they can't redirect the user |
151 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
151 | + $payment->set_status($this->_pay_model->failed_status()); |
|
152 | 152 | } |
153 | 153 | return $payment; |
154 | 154 | } |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | * @param mixed $data |
162 | 162 | * @return mixed same type as $data |
163 | 163 | */ |
164 | - private function _prepare_for_mijireh( $data ){ |
|
165 | - if( is_array( $data ) ){ |
|
164 | + private function _prepare_for_mijireh($data) { |
|
165 | + if (is_array($data)) { |
|
166 | 166 | $prepared_data = array(); |
167 | - foreach($data as $key => $datum ){ |
|
168 | - $prepared_data[ $key ] = $this->_prepare_for_mijireh( $datum ); |
|
167 | + foreach ($data as $key => $datum) { |
|
168 | + $prepared_data[$key] = $this->_prepare_for_mijireh($datum); |
|
169 | 169 | } |
170 | 170 | return $prepared_data; |
171 | - }elseif(is_string( $data ) ){ |
|
172 | - return str_replace( '%', 'percent', $data ); |
|
173 | - }else{ |
|
171 | + }elseif (is_string($data)) { |
|
172 | + return str_replace('%', 'percent', $data); |
|
173 | + } else { |
|
174 | 174 | return $data; |
175 | 175 | } |
176 | 176 | } |
@@ -191,30 +191,30 @@ discard block |
||
191 | 191 | |
192 | 192 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL; |
193 | 193 | |
194 | - if ( ! $payment instanceof EEI_Payment ){ |
|
195 | - throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) ); |
|
194 | + if ( ! $payment instanceof EEI_Payment) { |
|
195 | + throw new EE_Error(sprintf(__("Could not find Mijireh payment for transaction %s", 'event_espresso'), $transaction->ID())); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $request_args = array( |
199 | 199 | 'headers' => array( |
200 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
200 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
201 | 201 | 'Accept'=>'application/json' |
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | |
205 | 205 | $response = wp_remote_get( |
206 | - $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(), |
|
206 | + $this->_mijireh_api_orders_url.'/'.$payment->txn_id_chq_nmbr(), |
|
207 | 207 | $request_args |
208 | 208 | ); |
209 | 209 | |
210 | 210 | $this->log( |
211 | - array( 'get payment status request_args' => $request_args, 'response' => $response ), |
|
211 | + array('get payment status request_args' => $request_args, 'response' => $response), |
|
212 | 212 | $payment |
213 | 213 | ); |
214 | 214 | // validate response |
215 | - $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : ''; |
|
216 | - if( $response && $response_body ){ |
|
217 | - switch( $response_body->status ){ |
|
215 | + $response_body = isset($response['body']) ? json_decode($response['body']) : ''; |
|
216 | + if ($response && $response_body) { |
|
217 | + switch ($response_body->status) { |
|
218 | 218 | case 'paid': |
219 | 219 | $payment->set_status($this->_pay_model->approved_status()); |
220 | 220 | break; |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | } else { |
229 | - $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) ); |
|
230 | - $payment->set_details( $response ); |
|
231 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
229 | + $payment->set_gateway_response(__('Response from Mijireh could not be understood.', 'event_espresso')); |
|
230 | + $payment->set_details($response); |
|
231 | + $payment->set_status($this->_pay_model->failed_status()); |
|
232 | 232 | } |
233 | 233 | // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage |
234 | 234 | // $payment->set_status( $this->_pay_model->pending_status() ); |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Aim extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Aim extends EE_Onsite_Gateway { |
|
29 | 29 | |
30 | 30 | const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll'; //Authnet URL |
31 | 31 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param EEG_Aim $gateway_object |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function possibly_use_deprecated_aim_server( $url, EEG_Aim $gateway_object ) { |
|
161 | - if( $gateway_object->_server === 'authorize.net' |
|
162 | - && ! $gateway_object->_debug_mode ) { |
|
160 | + public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) { |
|
161 | + if ($gateway_object->_server === 'authorize.net' |
|
162 | + && ! $gateway_object->_debug_mode) { |
|
163 | 163 | return 'https://secure.authorize.net/gateway/transact.dll'; |
164 | 164 | } else { |
165 | 165 | return $url; |
@@ -182,33 +182,33 @@ discard block |
||
182 | 182 | */ |
183 | 183 | |
184 | 184 | public function do_direct_payment($payment, $billing_info = null) { |
185 | - add_filter( 'FHEE__EEG_Aim___get_server_url', array( $this, 'possibly_use_deprecated_aim_server' ), 10, 2 ); |
|
185 | + add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2); |
|
186 | 186 | // Enable test mode if needed |
187 | 187 | //4007000000027 <-- test successful visa |
188 | 188 | //4222222222222 <-- test failure card number |
189 | 189 | |
190 | 190 | $item_num = 1; |
191 | 191 | $transaction = $payment->transaction(); |
192 | - $order_description = $this->_format_order_description( $payment ); |
|
192 | + $order_description = $this->_format_order_description($payment); |
|
193 | 193 | $primary_registrant = $transaction->primary_registration(); |
194 | 194 | //if we're are charging for the full amount, show the normal line items |
195 | 195 | //and the itemized total adds up properly |
196 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
196 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
197 | 197 | $total_line_item = $transaction->total_line_item(); |
198 | 198 | foreach ($total_line_item->get_items() as $line_item) { |
199 | - if( $line_item->quantity() == 0 ){ |
|
199 | + if ($line_item->quantity() == 0) { |
|
200 | 200 | continue; |
201 | 201 | } |
202 | 202 | $this->addLineItem( |
203 | 203 | $item_num++, |
204 | - $this->_format_line_item_name( $line_item, $payment ), |
|
205 | - $this->_format_line_item_desc( $line_item, $payment ), |
|
204 | + $this->_format_line_item_name($line_item, $payment), |
|
205 | + $this->_format_line_item_desc($line_item, $payment), |
|
206 | 206 | $line_item->quantity(), |
207 | 207 | $line_item->unit_price(), |
208 | 208 | 'N'); |
209 | 209 | $order_description .= $line_item->desc().', '; |
210 | 210 | } |
211 | - foreach($total_line_item->tax_descendants() as $tax_line_item){ |
|
211 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
212 | 212 | $this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N'); |
213 | 213 | } |
214 | 214 | } |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | //start transaction |
220 | 220 | //if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
221 | 221 | $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
222 | - $this->setField( 'solution_id', $partner_id ); |
|
222 | + $this->setField('solution_id', $partner_id); |
|
223 | 223 | $this->setField('amount', $this->format_currency($payment->amount())); |
224 | - $this->setField('description',substr(rtrim($order_description, ', '), 0, 255)); |
|
225 | - $this->_set_sensitive_billing_data( $billing_info ); |
|
224 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
225 | + $this->_set_sensitive_billing_data($billing_info); |
|
226 | 226 | $this->setField('first_name', $billing_info['first_name']); |
227 | 227 | $this->setField('last_name', $billing_info['last_name']); |
228 | 228 | $this->setField('email', $billing_info['email']); |
229 | 229 | $this->setField('company', $billing_info['company']); |
230 | 230 | $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
231 | 231 | $this->setField('city', $billing_info['city']); |
232 | - $this->setField('state', $billing_info['state'] ); |
|
233 | - $this->setField('country', $billing_info['country'] ); |
|
232 | + $this->setField('state', $billing_info['state']); |
|
233 | + $this->setField('country', $billing_info['country']); |
|
234 | 234 | $this->setField('zip', $billing_info['zip']); |
235 | 235 | $this->setField('fax', $billing_info['fax']); |
236 | 236 | $this->setField('cust_id', $primary_registrant->ID()); |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | //invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
239 | 239 | //press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
240 | 240 | //in which case, we need to generate teh invoice num per request right here... |
241 | - $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
241 | + $this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
242 | 242 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
243 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
243 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
244 | 244 | |
245 | 245 | |
246 | 246 | if ($this->_test_transactions) { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | //Capture response |
251 | 251 | $this->type = "AUTH_CAPTURE"; |
252 | 252 | $response = $this->_sendRequest($payment); |
253 | - if (!empty($response)){ |
|
253 | + if ( ! empty($response)) { |
|
254 | 254 | if ($this->_debug_mode) { |
255 | 255 | $txn_id = $response->invoice_number; |
256 | 256 | } else { |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
260 | 260 | $payment->set_status($payment_status); |
261 | 261 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
262 | - $payment->set_amount( (float) $response->amount ); |
|
263 | - $payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code)); |
|
264 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
262 | + $payment->set_amount((float) $response->amount); |
|
263 | + $payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code)); |
|
264 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
265 | 265 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
266 | - $payment->set_details(print_r($response,true)); |
|
266 | + $payment->set_details(print_r($response, true)); |
|
267 | 267 | } else { |
268 | 268 | $payment->set_status($this->_pay_model->failed_status()); |
269 | 269 | $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
270 | - $payment->set_details(print_r($response,true)); |
|
270 | + $payment->set_details(print_r($response, true)); |
|
271 | 271 | } |
272 | 272 | return $payment; |
273 | 273 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * what billing data gets sent |
279 | 279 | * @param array $billing_info |
280 | 280 | */ |
281 | - protected function _set_sensitive_billing_data( $billing_info ) { |
|
281 | + protected function _set_sensitive_billing_data($billing_info) { |
|
282 | 282 | $this->setField('card_num', $billing_info['credit_card']); |
283 | 283 | $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
284 | 284 | $this->setField('card_code', $billing_info['cvv']); |
@@ -337,22 +337,22 @@ discard block |
||
337 | 337 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
338 | 338 | $x_keys = array(); |
339 | 339 | foreach ($this->_x_post_fields as $key => $value) { |
340 | - $x_keys[] = "x_$key=" . urlencode($value); |
|
340 | + $x_keys[] = "x_$key=".urlencode($value); |
|
341 | 341 | } |
342 | 342 | // Add line items |
343 | 343 | foreach ($this->_additional_line_items as $key => $value) { |
344 | - $x_keys[] = "x_line_item=" . urlencode($value); |
|
344 | + $x_keys[] = "x_line_item=".urlencode($value); |
|
345 | 345 | } |
346 | 346 | $this->_log_clean_request($x_keys, $payment); |
347 | 347 | $post_url = $this->_get_server_url(); |
348 | 348 | $curl_request = curl_init($post_url); |
349 | - curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys)); |
|
349 | + curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys)); |
|
350 | 350 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
351 | 351 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
352 | 352 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
353 | 353 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
354 | 354 | if ($this->VERIFY_PEER) { |
355 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem'); |
|
355 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem'); |
|
356 | 356 | } else { |
357 | 357 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
358 | 358 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $response = curl_exec($curl_request); |
365 | 365 | |
366 | 366 | curl_close($curl_request); |
367 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
367 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
368 | 368 | |
369 | 369 | return $this->_log_and_clean_response($response_obj, $payment); |
370 | 370 | } |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | * @param array $request_array |
374 | 374 | * @param EEI_Payment $payment |
375 | 375 | */ |
376 | - protected function _log_clean_request($request_array,$payment){ |
|
377 | - $keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' ); |
|
378 | - foreach($request_array as $index => $keyvaltogether ) { |
|
379 | - foreach( $keys_to_filter_out as $key ) { |
|
380 | - if( strpos( $keyvaltogether, $key ) === 0 ){ |
|
376 | + protected function _log_clean_request($request_array, $payment) { |
|
377 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
378 | + foreach ($request_array as $index => $keyvaltogether) { |
|
379 | + foreach ($keys_to_filter_out as $key) { |
|
380 | + if (strpos($keyvaltogether, $key) === 0) { |
|
381 | 381 | //found it at the first character |
382 | 382 | //so its one of them |
383 | - unset( $request_array[ $index ] ); |
|
383 | + unset($request_array[$index]); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
387 | - $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment); |
|
387 | + $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @param EE_Payment $payment |
397 | 397 | * @return \EE_AuthorizeNetAIM_Response |
398 | 398 | */ |
399 | - private function _log_and_clean_response($response_obj,$payment){ |
|
399 | + private function _log_and_clean_response($response_obj, $payment) { |
|
400 | 400 | $response_obj->account_number = ''; |
401 | - $this->log(array('AIM Response received:'=>$response_obj),$payment); |
|
401 | + $this->log(array('AIM Response received:'=>$response_obj), $payment); |
|
402 | 402 | return $response_obj; |
403 | 403 | } |
404 | 404 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | // Split Array |
498 | 498 | $this->response = $response; |
499 | 499 | if ($encap_char) { |
500 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
500 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
501 | 501 | } else { |
502 | 502 | $this->_response_array = explode($delimiter, $response); |
503 | 503 | } |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $this->held = ($this->response_code === self::HELD); |
568 | 568 | |
569 | 569 | if ($this->error || $this->declined || $this->held) { |
570 | - $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
570 | + $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
571 | 571 | |
572 | 572 | |
573 | 573 | /* $this->error_message = "AuthorizeNet Error: |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | } |
588 | 588 | |
589 | -if ( ! class_exists( 'AuthorizeNetException' ) ) { |
|
589 | +if ( ! class_exists('AuthorizeNetException')) { |
|
590 | 590 | /** |
591 | 591 | * Class AuthorizeNetException |
592 | 592 | * |
@@ -602,8 +602,8 @@ discard block |
||
602 | 602 | * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
603 | 603 | * @since 5.1.0 |
604 | 604 | */ |
605 | - public function __construct( $message = "", $code = 0, Exception $previous = null ) { |
|
606 | - parent::__construct( $message, $code, $previous ); |
|
605 | + public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
606 | + parent::__construct($message, $code, $previous); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | '[PRIMARY_REGISTRANT_ADDRESS2]' => __('Whatever was in the address 2 field for the primary registrant for the transaction.', 'event_espresso'), |
46 | 46 | '[PRIMARY_REGISTRANT_CITY]' => __('The city for the primary registrant for the transaction.', 'event_espresso'), |
47 | 47 | '[PRIMARY_REGISTRANT_ZIP_PC]' => __('The ZIP (or Postal) Code for the primary registrant for the transaction.', 'event_espresso'), |
48 | - '[PRIMARY_REGISTRANT_ADDRESS_STATE]' => __('The state/province for the primary registrant for the transaction.', 'event_espresso' ), |
|
48 | + '[PRIMARY_REGISTRANT_ADDRESS_STATE]' => __('The state/province for the primary registrant for the transaction.', 'event_espresso'), |
|
49 | 49 | '[PRIMARY_REGISTRANT_COUNTRY]' => __('The country for the primary registrant for the transaction.', 'event_espresso'), |
50 | 50 | '[PRIMARY_REGISTRANT_REGISTRATION_DATE]' => __('The date the registration occured for the primary registration.', 'event_espresso'), |
51 | 51 | '[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]' => __('Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso'), |
52 | - '[PRIMARY_REGISTRANT_ANSWER_*]' => __('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this primary registrant, then it will be output in place of this shortcode.', 'event_espresso' ) |
|
52 | + '[PRIMARY_REGISTRANT_ANSWER_*]' => __('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this primary registrant, then it will be output in place of this shortcode.', 'event_espresso') |
|
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | - protected function _parser( $shortcode ) { |
|
58 | + protected function _parser($shortcode) { |
|
59 | 59 | //make sure we end up with a copy of the EE_Messages_Addressee object |
60 | 60 | $primary_registration = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; |
61 | - $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && is_array($this->_data) && isset( $this->_data['data'] ) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $primary_registration; |
|
62 | - $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && !empty( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $primary_registration; |
|
61 | + $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && is_array($this->_data) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $primary_registration; |
|
62 | + $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $primary_registration; |
|
63 | 63 | |
64 | - if ( ! $primary_registration instanceof EE_Messages_Addressee ) |
|
64 | + if ( ! $primary_registration instanceof EE_Messages_Addressee) |
|
65 | 65 | return ''; |
66 | 66 | |
67 | 67 | $attendee = $primary_registration->primary_att_obj; |
68 | 68 | $primary_reg = $primary_registration->primary_reg_obj; |
69 | 69 | |
70 | - if ( ! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration ) |
|
70 | + if ( ! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration) |
|
71 | 71 | return ''; |
72 | 72 | |
73 | - switch ( $shortcode ) { |
|
73 | + switch ($shortcode) { |
|
74 | 74 | case '[PRIMARY_REGISTRANT_FNAME]' : |
75 | 75 | return $attendee->fname(); |
76 | 76 | break; |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | break; |
119 | 119 | |
120 | 120 | case '[PRIMARY_REGISTRANT_REGISTRATION_DATE]' : |
121 | - if ( ! $primary_registration->primary_reg_obj instanceof EE_Registration ) |
|
121 | + if ( ! $primary_registration->primary_reg_obj instanceof EE_Registration) |
|
122 | 122 | return ''; |
123 | - return $primary_registration->primary_reg_obj->get_i18n_datetime( 'REG_date', get_option( 'date_format' ) ); |
|
123 | + return $primary_registration->primary_reg_obj->get_i18n_datetime('REG_date', get_option('date_format')); |
|
124 | 124 | break; |
125 | 125 | |
126 | 126 | case '[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]' : |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | break; |
129 | 129 | } |
130 | 130 | |
131 | - if ( strpos( $shortcode, '[PRIMARY_REGISTRANT_ANSWER_*' ) !== false ) { |
|
132 | - $shortcode = str_replace( '[PRIMARY_REGISTRANT_ANSWER_*', '', $shortcode ); |
|
133 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
131 | + if (strpos($shortcode, '[PRIMARY_REGISTRANT_ANSWER_*') !== false) { |
|
132 | + $shortcode = str_replace('[PRIMARY_REGISTRANT_ANSWER_*', '', $shortcode); |
|
133 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
134 | 134 | |
135 | 135 | |
136 | 136 | //now let's figure out what question has this text |
137 | - if ( empty( $primary_registration->questions ) ) { |
|
137 | + if (empty($primary_registration->questions)) { |
|
138 | 138 | return ''; |
139 | 139 | } |
140 | 140 | |
141 | - foreach ( $primary_registration->questions as $ansid => $question ) { |
|
141 | + foreach ($primary_registration->questions as $ansid => $question) { |
|
142 | 142 | if ( |
143 | - trim( $question->get( 'QST_display_text' ) ) == trim( $shortcode ) |
|
144 | - && isset( $primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ] ) |
|
143 | + trim($question->get('QST_display_text')) == trim($shortcode) |
|
144 | + && isset($primary_registration->registrations[$primary_reg->ID()]['ans_objs'][$ansid]) |
|
145 | 145 | ) { |
146 | - return $primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ]->get_pretty( 'ANS_value', 'no_wpautop' ); |
|
146 | + return $primary_registration->registrations[$primary_reg->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', 'no_wpautop'); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -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 | * Class EE_Country_Select_Input |
4 | 4 | * |
@@ -11,23 +11,23 @@ discard block |
||
11 | 11 | * @since $VID:$ |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Country_Select_Input extends EE_Select_Input{ |
|
14 | +class EE_Country_Select_Input extends EE_Select_Input { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $country_options |
18 | 18 | * @param array $input_settings |
19 | 19 | * @return EE_Country_Select_Input |
20 | 20 | */ |
21 | - public function __construct( $country_options = NULL, $input_settings = array() ){ |
|
21 | + public function __construct($country_options = NULL, $input_settings = array()) { |
|
22 | 22 | $country_options = apply_filters( |
23 | 23 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
24 | - $this->get_country_answer_options( $country_options ), |
|
24 | + $this->get_country_answer_options($country_options), |
|
25 | 25 | $this |
26 | 26 | ); |
27 | - $input_settings['html_class'] = isset( $input_settings['html_class'] ) |
|
28 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
27 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
28 | + ? $input_settings['html_class'].' ee-country-select-js' |
|
29 | 29 | : 'ee-country-select-js'; |
30 | - parent::__construct( $country_options, $input_settings ); |
|
30 | + parent::__construct($country_options, $input_settings); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @param array $country_options |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function get_country_answer_options( $country_options = NULL ){ |
|
41 | + public function get_country_answer_options($country_options = NULL) { |
|
42 | 42 | // if passed something that is NOT an array |
43 | - if ( ! is_array( $country_options )) { |
|
43 | + if ( ! is_array($country_options)) { |
|
44 | 44 | // get possibly cached list of countries |
45 | 45 | $countries = EEM_Country::instance()->get_all_active_countries(); |
46 | - if ( ! empty( $countries )) { |
|
47 | - $country_options[ '' ] = ''; |
|
48 | - foreach( $countries as $country ){ |
|
49 | - if ( $country instanceof EE_Country ) { |
|
50 | - $country_options[ $country->ID() ] = $country->name(); |
|
46 | + if ( ! empty($countries)) { |
|
47 | + $country_options[''] = ''; |
|
48 | + foreach ($countries as $country) { |
|
49 | + if ($country instanceof EE_Country) { |
|
50 | + $country_options[$country->ID()] = $country->name(); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } else { |
@@ -6,22 +6,22 @@ discard block |
||
6 | 6 | * @subpackage |
7 | 7 | * @author Mike Nelson |
8 | 8 | */ |
9 | -class EE_State_Select_Input extends EE_Select_Input{ |
|
9 | +class EE_State_Select_Input extends EE_Select_Input { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @param array $state_options |
13 | 13 | * @param array $input_settings |
14 | 14 | */ |
15 | - function __construct( $state_options, $input_settings = array() ){ |
|
15 | + function __construct($state_options, $input_settings = array()) { |
|
16 | 16 | $state_options = apply_filters( |
17 | 17 | 'FHEE__EE_State_Select_Input____construct__state_options', |
18 | - $this->get_state_answer_options( $state_options ), |
|
18 | + $this->get_state_answer_options($state_options), |
|
19 | 19 | $this |
20 | 20 | ); |
21 | - $input_settings['html_class'] = isset( $input_settings['html_class'] ) |
|
22 | - ? $input_settings['html_class'] . ' ee-state-select-js' |
|
21 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
22 | + ? $input_settings['html_class'].' ee-state-select-js' |
|
23 | 23 | : 'ee-state-select-js'; |
24 | - parent::__construct( $state_options, $input_settings ); |
|
24 | + parent::__construct($state_options, $input_settings); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * @param array $state_options |
33 | 33 | * @return array |
34 | 34 | */ |
35 | - public function get_state_answer_options( $state_options = NULL ){ |
|
35 | + public function get_state_answer_options($state_options = NULL) { |
|
36 | 36 | // if passed something that is NOT an array |
37 | - if ( ! is_array( $state_options )) { |
|
37 | + if ( ! is_array($state_options)) { |
|
38 | 38 | // get possibly cached list of states |
39 | 39 | $states = EEM_State::instance()->get_all_active_states(); |
40 | - if ( ! empty( $states )) { |
|
40 | + if ( ! empty($states)) { |
|
41 | 41 | //set the default |
42 | 42 | $state_options[''][''] = ''; |
43 | - foreach( $states as $state ){ |
|
44 | - if ( $state instanceof EE_State ) { |
|
45 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
43 | + foreach ($states as $state) { |
|
44 | + if ($state instanceof EE_State) { |
|
45 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } else { |