@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Checkout |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since 4.5.0 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Checkout |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since 4.5.0 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Checkout { |
15 | 15 | |
16 | 16 | /** |
@@ -792,10 +792,10 @@ discard block |
||
792 | 792 | */ |
793 | 793 | public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
794 | 794 | return ! $this->revisit |
795 | - || $this->primary_revisit |
|
796 | - || ( |
|
797 | - $this->revisit && $this->reg_url_link === $registration->reg_url_link() |
|
798 | - ) |
|
795 | + || $this->primary_revisit |
|
796 | + || ( |
|
797 | + $this->revisit && $this->reg_url_link === $registration->reg_url_link() |
|
798 | + ) |
|
799 | 799 | ? true |
800 | 800 | : false; |
801 | 801 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | /** |
253 | 253 | * returns true if ANY reg status was updated during checkout |
254 | - * @return array |
|
254 | + * @return boolean |
|
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | 257 | foreach ( $this->reg_status_updated as $reg_status ) { |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | /** |
278 | 278 | * @param $REG_ID |
279 | - * @param $reg_status |
|
279 | + * @param boolean $reg_status |
|
280 | 280 | */ |
281 | 281 | public function set_reg_status_updated( $REG_ID, $reg_status ) { |
282 | 282 | $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * reset_reg_steps |
634 | 634 | * |
635 | 635 | * @access public |
636 | - * @return bool |
|
636 | + * @return boolean|null |
|
637 | 637 | */ |
638 | 638 | public function reset_reg_steps() { |
639 | 639 | $this->sort_reg_steps(); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * stores whether any updates were made to the TXN or it's related registrations |
749 | 749 | * |
750 | 750 | * @access public |
751 | - * @return bool |
|
751 | + * @return boolean|null |
|
752 | 752 | * @throws \EE_Error |
753 | 753 | */ |
754 | 754 | public function track_transaction_and_registration_status_updates() { |
@@ -1110,6 +1110,7 @@ discard block |
||
1110 | 1110 | * |
1111 | 1111 | * @param string | int $reg_cache_ID |
1112 | 1112 | * @param EE_Registration $registration |
1113 | + * @param integer $reg_cache_ID |
|
1113 | 1114 | * @return void |
1114 | 1115 | * @throws \EE_Error |
1115 | 1116 | */ |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | $this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url(); |
243 | 243 | $this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url(); |
244 | 244 | $this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url(); |
245 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE ); |
|
245 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE); |
|
246 | 246 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax; |
247 | - $this->reg_cache_where_params = array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
247 | + $this->reg_cache_where_params = array('order_by' => array('REG_count' => 'ASC')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | * @return array |
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | - foreach ( $this->reg_status_updated as $reg_status ) { |
|
258 | - if ( $reg_status ) { |
|
257 | + foreach ($this->reg_status_updated as $reg_status) { |
|
258 | + if ($reg_status) { |
|
259 | 259 | return true; |
260 | 260 | } |
261 | 261 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param $REG_ID |
269 | 269 | * @return array |
270 | 270 | */ |
271 | - public function reg_status_updated( $REG_ID ) { |
|
272 | - return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false; |
|
271 | + public function reg_status_updated($REG_ID) { |
|
272 | + return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param $REG_ID |
279 | 279 | * @param $reg_status |
280 | 280 | */ |
281 | - public function set_reg_status_updated( $REG_ID, $reg_status ) { |
|
282 | - $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
|
281 | + public function set_reg_status_updated($REG_ID, $reg_status) { |
|
282 | + $this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * can ONLY be set by the Finalize_Registration reg step |
301 | 301 | */ |
302 | 302 | public function set_exit_spco() { |
303 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
303 | + if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
304 | 304 | $this->exit_spco = true; |
305 | 305 | } |
306 | 306 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function reset_for_current_request() { |
319 | 319 | $this->process_form_submission = FALSE; |
320 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true ); |
|
320 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true); |
|
321 | 321 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax; |
322 | 322 | $this->continue_reg = true; |
323 | 323 | $this->redirect = false; |
324 | 324 | // don't reset the cached redirect form if we're about to be asked to display it !!! |
325 | - if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) { |
|
325 | + if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') { |
|
326 | 326 | $this->redirect_form = ''; |
327 | 327 | } |
328 | 328 | $this->redirect_url = ''; |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_SPCO_Reg_Step $reg_step_obj |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) { |
|
343 | - $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj; |
|
342 | + public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) { |
|
343 | + $this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -356,22 +356,22 @@ discard block |
||
356 | 356 | * @return void |
357 | 357 | * @throws \EE_Error |
358 | 358 | */ |
359 | - public function skip_reg_step( $reg_step_slug = '' ) { |
|
360 | - $step_to_skip = $this->find_reg_step( $reg_step_slug ); |
|
361 | - if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) { |
|
362 | - $step_to_skip->set_is_current_step( false ); |
|
359 | + public function skip_reg_step($reg_step_slug = '') { |
|
360 | + $step_to_skip = $this->find_reg_step($reg_step_slug); |
|
361 | + if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) { |
|
362 | + $step_to_skip->set_is_current_step(false); |
|
363 | 363 | $step_to_skip->set_completed(); |
364 | 364 | // advance to the next step |
365 | - $this->set_current_step( $this->next_step->slug() ); |
|
365 | + $this->set_current_step($this->next_step->slug()); |
|
366 | 366 | // also reset the step param in the request in case any other code references that directly |
367 | - EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() ); |
|
367 | + EE_Registry::instance()->REQ->set('step', $this->current_step->slug()); |
|
368 | 368 | // since we are skipping a step and setting the current step to be what was previously the next step, |
369 | 369 | // we need to check that the next step is now correct, and not still set to the current step. |
370 | - if ( $this->current_step->slug() === $this->next_step->slug() ) { |
|
370 | + if ($this->current_step->slug() === $this->next_step->slug()) { |
|
371 | 371 | // correctly setup the next step |
372 | 372 | $this->set_next_step(); |
373 | 373 | } |
374 | - $this->set_reg_step_initiated( $this->current_step ); |
|
374 | + $this->set_reg_step_initiated($this->current_step); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @param bool $reset whether to reset reg steps after removal |
386 | 386 | * @throws EE_Error |
387 | 387 | */ |
388 | - public function remove_reg_step( $reg_step_slug = '', $reset = true ) { |
|
389 | - unset( $this->reg_steps[ $reg_step_slug ] ); |
|
390 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
388 | + public function remove_reg_step($reg_step_slug = '', $reset = true) { |
|
389 | + unset($this->reg_steps[$reg_step_slug]); |
|
390 | + if ($this->transaction instanceof EE_Transaction) { |
|
391 | 391 | /** @type EE_Transaction_Processor $transaction_processor */ |
392 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
392 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
393 | 393 | // now remove reg step from TXN and save |
394 | - $transaction_processor->remove_reg_step( $this->transaction, $reg_step_slug ); |
|
394 | + $transaction_processor->remove_reg_step($this->transaction, $reg_step_slug); |
|
395 | 395 | $this->transaction->save(); |
396 | 396 | } |
397 | - if ( $reset ) { |
|
397 | + if ($reset) { |
|
398 | 398 | $this->reset_reg_steps(); |
399 | 399 | } |
400 | 400 | } |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | * @param int $order |
410 | 410 | * @return void |
411 | 411 | */ |
412 | - public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) { |
|
413 | - if ( isset( $this->reg_steps[ $reg_step_slug ] )) { |
|
414 | - $this->reg_steps[ $reg_step_slug ]->set_order( $order ); |
|
412 | + public function set_reg_step_order($reg_step_slug = '', $order = 100) { |
|
413 | + if (isset($this->reg_steps[$reg_step_slug])) { |
|
414 | + $this->reg_steps[$reg_step_slug]->set_order($order); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
@@ -424,25 +424,25 @@ discard block |
||
424 | 424 | * @param string $current_step |
425 | 425 | * @return void |
426 | 426 | */ |
427 | - public function set_current_step( $current_step ) { |
|
427 | + public function set_current_step($current_step) { |
|
428 | 428 | // grab what step we're on |
429 | - $this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps ); |
|
429 | + $this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps); |
|
430 | 430 | // verify instance |
431 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step ) { |
|
431 | + if ($this->current_step instanceof EE_SPCO_Reg_Step) { |
|
432 | 432 | // we don't want to repeat completed steps if this is the first time through SPCO |
433 | - if ( $this->continue_reg && ! $this->revisit && $this->current_step->completed() ) { |
|
433 | + if ($this->continue_reg && ! $this->revisit && $this->current_step->completed()) { |
|
434 | 434 | // so advance to the next step |
435 | 435 | $this->set_next_step(); |
436 | - if ( $this->next_step instanceof EE_SPCO_Reg_Step ) { |
|
436 | + if ($this->next_step instanceof EE_SPCO_Reg_Step) { |
|
437 | 437 | // and attempt to set it as the current step |
438 | - $this->set_current_step( $this->next_step->slug() ); |
|
438 | + $this->set_current_step($this->next_step->slug()); |
|
439 | 439 | } |
440 | 440 | return; |
441 | 441 | } |
442 | - $this->current_step->set_is_current_step( TRUE ); |
|
442 | + $this->current_step->set_is_current_step(TRUE); |
|
443 | 443 | } else { |
444 | 444 | EE_Error::add_error( |
445 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
445 | + __('The current step could not be set.', 'event_espresso'), |
|
446 | 446 | __FILE__, __FUNCTION__, __LINE__ |
447 | 447 | ); |
448 | 448 | } |
@@ -459,20 +459,20 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function set_next_step() { |
461 | 461 | // set pointer to start of array |
462 | - reset( $this->reg_steps ); |
|
462 | + reset($this->reg_steps); |
|
463 | 463 | // if there is more than one step |
464 | - if ( count( $this->reg_steps ) > 1 ) { |
|
464 | + if (count($this->reg_steps) > 1) { |
|
465 | 465 | // advance to the current step and set pointer |
466 | - while ( key( $this->reg_steps ) !== $this->current_step->slug() && key( $this->reg_steps ) !== '' ) { |
|
467 | - next( $this->reg_steps ); |
|
466 | + while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') { |
|
467 | + next($this->reg_steps); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | // advance one more spot ( if it exists ) |
471 | - $this->next_step = next( $this->reg_steps ); |
|
471 | + $this->next_step = next($this->reg_steps); |
|
472 | 472 | // verify instance |
473 | - $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
473 | + $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
474 | 474 | // then back to current step to reset |
475 | - prev( $this->reg_steps ); |
|
475 | + prev($this->reg_steps); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | * @return EE_SPCO_Reg_Step | null |
487 | 487 | */ |
488 | 488 | public function get_next_reg_step() { |
489 | - $next = next( $this->reg_steps ); |
|
490 | - prev( $this->reg_steps ); |
|
489 | + $next = next($this->reg_steps); |
|
490 | + prev($this->reg_steps); |
|
491 | 491 | return $next instanceof EE_SPCO_Reg_Step ? $next : null; |
492 | 492 | } |
493 | 493 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * @return EE_SPCO_Reg_Step | null |
503 | 503 | */ |
504 | 504 | public function get_prev_reg_step() { |
505 | - $prev = prev( $this->reg_steps ); |
|
506 | - next( $this->reg_steps ); |
|
505 | + $prev = prev($this->reg_steps); |
|
506 | + next($this->reg_steps); |
|
507 | 507 | return $prev instanceof EE_SPCO_Reg_Step ? $prev : null; |
508 | 508 | } |
509 | 509 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | * @return void |
517 | 517 | */ |
518 | 518 | public function sort_reg_steps() { |
519 | - $reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' ); |
|
520 | - uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback )); |
|
519 | + $reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback'); |
|
520 | + uasort($this->reg_steps, array($this, $reg_step_sorting_callback)); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | * @param string $reg_step_slug |
531 | 531 | * @return EE_SPCO_Reg_Step|null |
532 | 532 | */ |
533 | - public function find_reg_step( $reg_step_slug = '' ) { |
|
534 | - if ( ! empty( $reg_step_slug ) ) { |
|
533 | + public function find_reg_step($reg_step_slug = '') { |
|
534 | + if ( ! empty($reg_step_slug)) { |
|
535 | 535 | // copy reg step array |
536 | 536 | $reg_steps = $this->reg_steps; |
537 | 537 | // set pointer to start of array |
538 | - reset( $reg_steps ); |
|
538 | + reset($reg_steps); |
|
539 | 539 | // if there is more than one step |
540 | - if ( count( $reg_steps ) > 1 ) { |
|
540 | + if (count($reg_steps) > 1) { |
|
541 | 541 | // advance to the current step and set pointer |
542 | - while ( key( $reg_steps ) !== $reg_step_slug && key( $reg_steps ) !== '' ) { |
|
543 | - next( $reg_steps ); |
|
542 | + while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') { |
|
543 | + next($reg_steps); |
|
544 | 544 | } |
545 | - return current( $reg_steps ); |
|
545 | + return current($reg_steps); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | return null; |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | * @param EE_SPCO_Reg_Step $reg_step_B |
559 | 559 | * @return array() |
560 | 560 | */ |
561 | - public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) { |
|
561 | + public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) { |
|
562 | 562 | // send finalize_registration step to the end of the array |
563 | - if ( $reg_step_A->slug() === 'finalize_registration' ) { |
|
563 | + if ($reg_step_A->slug() === 'finalize_registration') { |
|
564 | 564 | return 1; |
565 | - } else if ( $reg_step_B->slug() === 'finalize_registration' ) { |
|
565 | + } else if ($reg_step_B->slug() === 'finalize_registration') { |
|
566 | 566 | return -1; |
567 | 567 | } |
568 | - if ( $reg_step_A->order() === $reg_step_B->order() ) { |
|
568 | + if ($reg_step_A->order() === $reg_step_B->order()) { |
|
569 | 569 | return 0; |
570 | 570 | } |
571 | - return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1; |
|
571 | + return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @param EE_SPCO_Reg_Step $reg_step |
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | - public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) { |
|
583 | + public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) { |
|
584 | 584 | // call set_reg_step_initiated ??? |
585 | 585 | if ( |
586 | 586 | // first time visiting SPCO ? |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | ) |
594 | 594 | ) { |
595 | 595 | /** @type EE_Transaction_Processor $transaction_processor */ |
596 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
596 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
597 | 597 | // set the start time for this reg step |
598 | - if ( ! $transaction_processor->set_reg_step_initiated( $this->transaction, $reg_step->slug() ) ) { |
|
599 | - if ( WP_DEBUG ) { |
|
598 | + if ( ! $transaction_processor->set_reg_step_initiated($this->transaction, $reg_step->slug())) { |
|
599 | + if (WP_DEBUG) { |
|
600 | 600 | EE_Error::add_error( |
601 | 601 | sprintf( |
602 | - __( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ), |
|
602 | + __('The "%1$s" registration step was not initialized properly.', 'event_espresso'), |
|
603 | 603 | $reg_step->name() |
604 | 604 | ), |
605 | 605 | __FILE__, __FUNCTION__, __LINE__ |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | * @return void |
619 | 619 | */ |
620 | 620 | public function set_reg_step_JSON_info() { |
621 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array(); |
|
621 | + EE_Registry::$i18n_js_strings['reg_steps'] = array(); |
|
622 | 622 | // pass basic reg step data to JS |
623 | - foreach ( $this->reg_steps as $reg_step ) { |
|
624 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug(); |
|
623 | + foreach ($this->reg_steps as $reg_step) { |
|
624 | + EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug(); |
|
625 | 625 | } |
626 | 626 | // reset reg step html |
627 | 627 | // $this->json_response->set_reg_step_html( '' ); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | */ |
638 | 638 | public function reset_reg_steps() { |
639 | 639 | $this->sort_reg_steps(); |
640 | - $this->set_current_step( EE_Registry::instance()->REQ->get( 'step' )); |
|
640 | + $this->set_current_step(EE_Registry::instance()->REQ->get('step')); |
|
641 | 641 | $this->set_next_step(); |
642 | 642 | // the text that appears on the reg step form submit button |
643 | 643 | $this->current_step->set_submit_button_text(); |
@@ -654,9 +654,9 @@ discard block |
||
654 | 654 | */ |
655 | 655 | public function get_registration_time_limit() { |
656 | 656 | |
657 | - $registration_time_limit = (float)( EE_Registry::instance() ->SSN->expiration() - time() ); |
|
657 | + $registration_time_limit = (float) (EE_Registry::instance() ->SSN->expiration() - time()); |
|
658 | 658 | $time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s'; |
659 | - $registration_time_limit = gmdate( $time_limit_format, $registration_time_limit ); |
|
659 | + $registration_time_limit = gmdate($time_limit_format, $registration_time_limit); |
|
660 | 660 | return apply_filters( |
661 | 661 | 'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit', |
662 | 662 | $registration_time_limit |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | // overpaid TXN |
677 | 677 | // free TXN ( total = 0.00 ) |
678 | 678 | // then payment required is TRUE |
679 | - return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE; |
|
679 | + return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | * @param EE_Transaction $transaction |
689 | 689 | * @return EE_Cart |
690 | 690 | */ |
691 | - public function get_cart_for_transaction( $transaction ) { |
|
692 | - $session = EE_Registry::instance()->load_core( 'Session' ); |
|
693 | - $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction, $session ) : null; |
|
691 | + public function get_cart_for_transaction($transaction) { |
|
692 | + $session = EE_Registry::instance()->load_core('Session'); |
|
693 | + $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null; |
|
694 | 694 | // verify cart |
695 | - if ( ! $cart instanceof EE_Cart ) { |
|
696 | - $cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
695 | + if ( ! $cart instanceof EE_Cart) { |
|
696 | + $cart = EE_Registry::instance()->load_core('Cart'); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | return $cart; |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function initialize_txn_reg_steps_array() { |
711 | 711 | $txn_reg_steps_array = array(); |
712 | - foreach ( $this->reg_steps as $reg_step ) { |
|
713 | - $txn_reg_steps_array[ $reg_step->slug() ] = FALSE; |
|
712 | + foreach ($this->reg_steps as $reg_step) { |
|
713 | + $txn_reg_steps_array[$reg_step->slug()] = FALSE; |
|
714 | 714 | } |
715 | 715 | return $txn_reg_steps_array; |
716 | 716 | } |
@@ -727,15 +727,15 @@ discard block |
||
727 | 727 | public function update_txn_reg_steps_array() { |
728 | 728 | $updated = false; |
729 | 729 | /** @type EE_Transaction_Processor $transaction_processor */ |
730 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
731 | - foreach ( $this->reg_steps as $reg_step ) { |
|
732 | - if ( $reg_step->completed() ) { |
|
733 | - $updated = $transaction_processor->set_reg_step_completed( $this->transaction, $reg_step->slug() ) |
|
730 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
731 | + foreach ($this->reg_steps as $reg_step) { |
|
732 | + if ($reg_step->completed()) { |
|
733 | + $updated = $transaction_processor->set_reg_step_completed($this->transaction, $reg_step->slug()) |
|
734 | 734 | ? true |
735 | 735 | : $updated; |
736 | 736 | } |
737 | 737 | } |
738 | - if ( $updated ) { |
|
738 | + if ($updated) { |
|
739 | 739 | $this->transaction->save(); |
740 | 740 | } |
741 | 741 | return $updated; |
@@ -751,14 +751,14 @@ discard block |
||
751 | 751 | * @throws \EE_Error |
752 | 752 | */ |
753 | 753 | public function stash_transaction_and_checkout() { |
754 | - if ( ! $this->revisit ) { |
|
754 | + if ( ! $this->revisit) { |
|
755 | 755 | $this->update_txn_reg_steps_array(); |
756 | 756 | } |
757 | 757 | $this->track_transaction_and_registration_status_updates(); |
758 | 758 | // save all data to the db, but suppress errors |
759 | 759 | //$this->save_all_data( FALSE ); |
760 | 760 | // cache the checkout in the session |
761 | - EE_Registry::instance()->SSN->set_checkout( $this ); |
|
761 | + EE_Registry::instance()->SSN->set_checkout($this); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -773,21 +773,21 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public function track_transaction_and_registration_status_updates() { |
775 | 775 | // verify the transaction |
776 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
776 | + if ($this->transaction instanceof EE_Transaction) { |
|
777 | 777 | /** @type EE_Transaction_Payments $transaction_payments */ |
778 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
778 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
779 | 779 | /** @type EE_Transaction_Processor $transaction_processor */ |
780 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
780 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
781 | 781 | // has there been a TXN status change during this checkout? |
782 | - if ( $transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated() ) { |
|
782 | + if ($transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated()) { |
|
783 | 783 | $this->txn_status_updated = true; |
784 | 784 | } |
785 | 785 | /** @type EE_Registration_Processor $registration_processor */ |
786 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
786 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
787 | 787 | // grab the saved registrations from the transaction |
788 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
789 | - if ( $registration_processor->reg_status_updated( $registration->ID() ) ) { |
|
790 | - $this->set_reg_status_updated( $registration->ID(), true ); |
|
788 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
789 | + if ($registration_processor->reg_status_updated($registration->ID())) { |
|
790 | + $this->set_reg_status_updated($registration->ID(), true); |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 | } |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | * @return bool |
809 | 809 | * @throws \EE_Error |
810 | 810 | */ |
811 | - public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
|
811 | + public function visit_allows_processing_of_this_registration(EE_Registration $registration) { |
|
812 | 812 | return ! $this->revisit |
813 | 813 | || $this->primary_revisit |
814 | 814 | || ( |
@@ -841,18 +841,18 @@ discard block |
||
841 | 841 | * @return bool |
842 | 842 | * @throws \EE_Error |
843 | 843 | */ |
844 | - public function save_all_data( $show_errors = TRUE ) { |
|
844 | + public function save_all_data($show_errors = TRUE) { |
|
845 | 845 | // verify the transaction |
846 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
846 | + if ($this->transaction instanceof EE_Transaction) { |
|
847 | 847 | // save to ensure that TXN has ID |
848 | 848 | $this->transaction->save(); |
849 | 849 | // grab the saved registrations from the transaction |
850 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
851 | - $this->_save_registration( $registration, $show_errors ); |
|
850 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
851 | + $this->_save_registration($registration, $show_errors); |
|
852 | 852 | } |
853 | 853 | } else { |
854 | - if ( $show_errors ) { |
|
855 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
854 | + if ($show_errors) { |
|
855 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
856 | 856 | } |
857 | 857 | return FALSE; |
858 | 858 | } |
@@ -869,32 +869,32 @@ discard block |
||
869 | 869 | * @return void |
870 | 870 | * @throws \EE_Error |
871 | 871 | */ |
872 | - private function _save_registration( $registration, $show_errors = TRUE ) { |
|
872 | + private function _save_registration($registration, $show_errors = TRUE) { |
|
873 | 873 | // verify object |
874 | - if ( $registration instanceof EE_Registration ) { |
|
874 | + if ($registration instanceof EE_Registration) { |
|
875 | 875 | // should this registration be processed during this visit ? |
876 | - if ( $this->visit_allows_processing_of_this_registration( $registration ) ) { |
|
876 | + if ($this->visit_allows_processing_of_this_registration($registration)) { |
|
877 | 877 | //set TXN ID |
878 | - if ( ! $registration->transaction_ID() ) { |
|
879 | - $registration->set_transaction_id( $this->transaction->ID() ); |
|
878 | + if ( ! $registration->transaction_ID()) { |
|
879 | + $registration->set_transaction_id($this->transaction->ID()); |
|
880 | 880 | } |
881 | 881 | // verify and save the attendee |
882 | - $this->_save_registration_attendee( $registration, $show_errors ); |
|
882 | + $this->_save_registration_attendee($registration, $show_errors); |
|
883 | 883 | // save answers to reg form questions |
884 | - $this->_save_registration_answers( $registration, $show_errors ); |
|
884 | + $this->_save_registration_answers($registration, $show_errors); |
|
885 | 885 | // save changes |
886 | 886 | $registration->save(); |
887 | 887 | // update txn cache |
888 | - if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) { |
|
889 | - if ( $show_errors ) { |
|
890 | - EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
888 | + if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) { |
|
889 | + if ($show_errors) { |
|
890 | + EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | } |
894 | 894 | } else { |
895 | - if ( $show_errors ) { |
|
895 | + if ($show_errors) { |
|
896 | 896 | EE_Error::add_error( |
897 | - __( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
897 | + __('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
898 | 898 | __FILE__, __FUNCTION__, __LINE__ |
899 | 899 | ); |
900 | 900 | } |
@@ -911,25 +911,25 @@ discard block |
||
911 | 911 | * @return void |
912 | 912 | * @throws \EE_Error |
913 | 913 | */ |
914 | - private function _save_registration_attendee( $registration, $show_errors = TRUE ) { |
|
915 | - if ( $registration->attendee() instanceof EE_Attendee ) { |
|
914 | + private function _save_registration_attendee($registration, $show_errors = TRUE) { |
|
915 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
916 | 916 | // save so that ATT has ID |
917 | 917 | $registration->attendee()->save(); |
918 | - if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() ) ) { |
|
919 | - if ( $show_errors ) { |
|
918 | + if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) { |
|
919 | + if ($show_errors) { |
|
920 | 920 | EE_Error::add_error( |
921 | - __( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ), |
|
921 | + __('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'), |
|
922 | 922 | __FILE__, __FUNCTION__, __LINE__ |
923 | 923 | ); |
924 | 924 | } |
925 | 925 | } |
926 | 926 | } else { |
927 | - if ( $show_errors ) { |
|
927 | + if ($show_errors) { |
|
928 | 928 | EE_Error::add_error( |
929 | 929 | sprintf( |
930 | 930 | '%1$s||%1$s $attendee = %2$s', |
931 | - __( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
932 | - var_export( $registration->attendee(), true ) |
|
931 | + __('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
932 | + var_export($registration->attendee(), true) |
|
933 | 933 | ), |
934 | 934 | __FILE__, __FUNCTION__, __LINE__ |
935 | 935 | ); |
@@ -947,25 +947,25 @@ discard block |
||
947 | 947 | * @return void |
948 | 948 | * @throws \EE_Error |
949 | 949 | */ |
950 | - private function _save_registration_answers( $registration, $show_errors = TRUE ) { |
|
950 | + private function _save_registration_answers($registration, $show_errors = TRUE) { |
|
951 | 951 | // now save the answers |
952 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
952 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
953 | 953 | // verify object |
954 | - if ( $answer instanceof EE_Answer ) { |
|
955 | - $answer->set_registration( $registration->ID() ); |
|
954 | + if ($answer instanceof EE_Answer) { |
|
955 | + $answer->set_registration($registration->ID()); |
|
956 | 956 | $answer->save(); |
957 | - if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) { |
|
958 | - if ( $show_errors ) { |
|
957 | + if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) { |
|
958 | + if ($show_errors) { |
|
959 | 959 | EE_Error::add_error( |
960 | - __( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ), |
|
960 | + __('The newly saved Answer object could not be cached on the registration.', 'event_espresso'), |
|
961 | 961 | __FILE__, __FUNCTION__, __LINE__ |
962 | 962 | ); |
963 | 963 | } |
964 | 964 | } |
965 | 965 | } else { |
966 | - if ( $show_errors ) { |
|
966 | + if ($show_errors) { |
|
967 | 967 | EE_Error::add_error( |
968 | - __( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
968 | + __('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
969 | 969 | __FILE__, __FUNCTION__, __LINE__ |
970 | 970 | ); |
971 | 971 | } |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @return bool |
985 | 985 | * @throws \EE_Error |
986 | 986 | */ |
987 | - public function refresh_all_entities( $from_db = false ) { |
|
987 | + public function refresh_all_entities($from_db = false) { |
|
988 | 988 | $from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response' |
989 | 989 | ? true |
990 | 990 | : $from_db; |
@@ -1008,11 +1008,11 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | protected function refresh_from_db() { |
1010 | 1010 | // verify the transaction |
1011 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1011 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1012 | 1012 | // pull fresh TXN data from the db |
1013 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() ); |
|
1013 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID()); |
|
1014 | 1014 | // update EE_Checkout's cached primary_attendee object |
1015 | - $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction ); |
|
1015 | + $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction); |
|
1016 | 1016 | // update EE_Checkout's cached payment object |
1017 | 1017 | $payment = $this->transaction->last_payment(); |
1018 | 1018 | $this->payment = $payment instanceof EE_Payment ? $payment : $this->payment; |
@@ -1020,9 +1020,9 @@ discard block |
||
1020 | 1020 | $payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null; |
1021 | 1021 | $this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method; |
1022 | 1022 | //now refresh the cart, based on the TXN |
1023 | - $this->cart = $this->get_cart_for_transaction( $this->transaction ); |
|
1023 | + $this->cart = $this->get_cart_for_transaction($this->transaction); |
|
1024 | 1024 | } else { |
1025 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1025 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1026 | 1026 | return FALSE; |
1027 | 1027 | } |
1028 | 1028 | return TRUE; |
@@ -1037,21 +1037,21 @@ discard block |
||
1037 | 1037 | * @return EE_Attendee | null |
1038 | 1038 | * @throws \EE_Error |
1039 | 1039 | */ |
1040 | - protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) { |
|
1040 | + protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) { |
|
1041 | 1041 | |
1042 | 1042 | $primary_attendee_obj = null; |
1043 | 1043 | // grab the saved registrations from the transaction |
1044 | - foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) { |
|
1044 | + foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) { |
|
1045 | 1045 | // verify object |
1046 | - if ( $registration instanceof EE_Registration ) { |
|
1046 | + if ($registration instanceof EE_Registration) { |
|
1047 | 1047 | $attendee = $registration->attendee(); |
1048 | 1048 | // verify object && maybe cache primary_attendee_obj ? |
1049 | - if ( $attendee instanceof EE_Attendee&& $registration->is_primary_registrant() ) { |
|
1049 | + if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) { |
|
1050 | 1050 | $primary_attendee_obj = $attendee; |
1051 | 1051 | } |
1052 | 1052 | } else { |
1053 | 1053 | EE_Error::add_error( |
1054 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1054 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1055 | 1055 | __FILE__, __FUNCTION__, __LINE__ |
1056 | 1056 | ); |
1057 | 1057 | } |
@@ -1072,45 +1072,45 @@ discard block |
||
1072 | 1072 | */ |
1073 | 1073 | protected function refresh_entity_map() { |
1074 | 1074 | // verify the transaction |
1075 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1075 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1076 | 1076 | // never cache payment info |
1077 | - $this->transaction->clear_cache( 'Payment' ); |
|
1077 | + $this->transaction->clear_cache('Payment'); |
|
1078 | 1078 | /** @type EE_Transaction_Processor $transaction_processor */ |
1079 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1079 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1080 | 1080 | // is the Payment Options Reg Step completed ? |
1081 | - if ( $transaction_processor->reg_step_completed( $this->transaction, 'payment_options' ) ) { |
|
1081 | + if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) { |
|
1082 | 1082 | // then check for payments and update TXN accordingly |
1083 | 1083 | /** @type EE_Transaction_Payments $transaction_payments */ |
1084 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1085 | - $transaction_payments->calculate_total_payments_and_update_status( $this->transaction ); |
|
1084 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1085 | + $transaction_payments->calculate_total_payments_and_update_status($this->transaction); |
|
1086 | 1086 | } |
1087 | 1087 | // grab the saved registrations from the transaction |
1088 | 1088 | foreach ( |
1089 | - $this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration |
|
1089 | + $this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration |
|
1090 | 1090 | ) { |
1091 | - $this->_refresh_registration( $reg_cache_ID, $registration ); |
|
1091 | + $this->_refresh_registration($reg_cache_ID, $registration); |
|
1092 | 1092 | } |
1093 | 1093 | // make sure our cached TXN is added to the model entity mapper |
1094 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction ); |
|
1094 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction); |
|
1095 | 1095 | |
1096 | 1096 | } else { |
1097 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1097 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1098 | 1098 | return FALSE; |
1099 | 1099 | } |
1100 | 1100 | // verify and update the cart because inaccurate totals are not so much fun |
1101 | - if ( $this->cart instanceof EE_Cart ) { |
|
1101 | + if ($this->cart instanceof EE_Cart) { |
|
1102 | 1102 | $grand_total = $this->cart->get_grand_total(); |
1103 | - if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) { |
|
1103 | + if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) { |
|
1104 | 1104 | $grand_total->recalculate_total_including_taxes(); |
1105 | 1105 | $grand_total = $grand_total->get_model()->refresh_entity_map_with( |
1106 | 1106 | $this->cart->get_grand_total()->ID(), |
1107 | 1107 | $this->cart->get_grand_total() |
1108 | 1108 | ); |
1109 | 1109 | } |
1110 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
1111 | - $this->cart = EE_Cart::instance( $grand_total ); |
|
1110 | + if ($grand_total instanceof EE_Line_Item) { |
|
1111 | + $this->cart = EE_Cart::instance($grand_total); |
|
1112 | 1112 | } else { |
1113 | - EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1113 | + EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1114 | 1114 | return false; |
1115 | 1115 | } |
1116 | 1116 | } |
@@ -1127,19 +1127,19 @@ discard block |
||
1127 | 1127 | * @return void |
1128 | 1128 | * @throws \EE_Error |
1129 | 1129 | */ |
1130 | - protected function _refresh_registration( $reg_cache_ID, $registration ) { |
|
1130 | + protected function _refresh_registration($reg_cache_ID, $registration) { |
|
1131 | 1131 | |
1132 | 1132 | // verify object |
1133 | - if ( $registration instanceof EE_Registration ) { |
|
1133 | + if ($registration instanceof EE_Registration) { |
|
1134 | 1134 | // update the entity mapper attendee |
1135 | - $this->_refresh_registration_attendee( $registration ); |
|
1135 | + $this->_refresh_registration_attendee($registration); |
|
1136 | 1136 | // update the entity mapper answers for reg form questions |
1137 | - $this->_refresh_registration_answers( $registration ); |
|
1137 | + $this->_refresh_registration_answers($registration); |
|
1138 | 1138 | // make sure the cached registration is added to the model entity mapper |
1139 | - $registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration ); |
|
1139 | + $registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration); |
|
1140 | 1140 | } else { |
1141 | 1141 | EE_Error::add_error( |
1142 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1142 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1143 | 1143 | __FILE__, __FUNCTION__, __LINE__ |
1144 | 1144 | ); |
1145 | 1145 | } |
@@ -1154,15 +1154,15 @@ discard block |
||
1154 | 1154 | * @return void |
1155 | 1155 | * @throws \EE_Error |
1156 | 1156 | */ |
1157 | - protected function _refresh_registration_attendee( $registration ) { |
|
1157 | + protected function _refresh_registration_attendee($registration) { |
|
1158 | 1158 | |
1159 | 1159 | $attendee = $registration->attendee(); |
1160 | 1160 | // verify object |
1161 | - if ( $attendee instanceof EE_Attendee && $attendee->ID() ) { |
|
1161 | + if ($attendee instanceof EE_Attendee && $attendee->ID()) { |
|
1162 | 1162 | // make sure the cached attendee is added to the model entity mapper |
1163 | - $registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee ); |
|
1163 | + $registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee); |
|
1164 | 1164 | // maybe cache primary_attendee_obj ? |
1165 | - if ( $registration->is_primary_registrant() ) { |
|
1165 | + if ($registration->is_primary_registrant()) { |
|
1166 | 1166 | $this->primary_attendee_obj = $attendee; |
1167 | 1167 | } |
1168 | 1168 | } |
@@ -1177,19 +1177,19 @@ discard block |
||
1177 | 1177 | * @return void |
1178 | 1178 | * @throws \EE_Error |
1179 | 1179 | */ |
1180 | - protected function _refresh_registration_answers( $registration ) { |
|
1180 | + protected function _refresh_registration_answers($registration) { |
|
1181 | 1181 | |
1182 | 1182 | // now update the answers |
1183 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
1183 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
1184 | 1184 | // verify object |
1185 | - if ( $answer instanceof EE_Answer ) { |
|
1186 | - if ( $answer->ID() ) { |
|
1185 | + if ($answer instanceof EE_Answer) { |
|
1186 | + if ($answer->ID()) { |
|
1187 | 1187 | // make sure the cached answer is added to the model entity mapper |
1188 | - $answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer ); |
|
1188 | + $answer->get_model()->refresh_entity_map_with($answer->ID(), $answer); |
|
1189 | 1189 | } |
1190 | 1190 | } else { |
1191 | 1191 | EE_Error::add_error( |
1192 | - __( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1192 | + __('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1193 | 1193 | __FILE__, __FUNCTION__, __LINE__ |
1194 | 1194 | ); |
1195 | 1195 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object |
1205 | 1205 | */ |
1206 | 1206 | public function __wakeup() { |
1207 | - foreach ( $this->reg_steps as $reg_step ) { |
|
1207 | + foreach ($this->reg_steps as $reg_step) { |
|
1208 | 1208 | $reg_step->checkout = $this; |
1209 | 1209 | } |
1210 | 1210 | } |
@@ -1221,12 +1221,12 @@ discard block |
||
1221 | 1221 | * @param bool $display_request |
1222 | 1222 | * @throws \EE_Error |
1223 | 1223 | */ |
1224 | - public function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) { |
|
1224 | + public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) { |
|
1225 | 1225 | $disabled = true; |
1226 | - if ( WP_DEBUG && ! $disabled ) { |
|
1227 | - $debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() ); |
|
1226 | + if (WP_DEBUG && ! $disabled) { |
|
1227 | + $debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array()); |
|
1228 | 1228 | $default_data = array( |
1229 | - $class => $func . '() : ' . $line, |
|
1229 | + $class => $func.'() : '.$line, |
|
1230 | 1230 | 'request->step' => $this->step, |
1231 | 1231 | 'request->action' => $this->action, |
1232 | 1232 | 'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ? |
@@ -1238,24 +1238,24 @@ discard block |
||
1238 | 1238 | 'reg_url_link' => $this->reg_url_link, |
1239 | 1239 | 'REQ' => $display_request ? $_REQUEST : '', |
1240 | 1240 | ); |
1241 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
1242 | - $default_data[ 'TXN_status' ] = $this->transaction->status_ID(); |
|
1243 | - $default_data[ 'TXN_reg_steps' ] = $this->transaction->reg_steps(); |
|
1244 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) { |
|
1245 | - $default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID(); |
|
1241 | + if ($this->transaction instanceof EE_Transaction) { |
|
1242 | + $default_data['TXN_status'] = $this->transaction->status_ID(); |
|
1243 | + $default_data['TXN_reg_steps'] = $this->transaction->reg_steps(); |
|
1244 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) { |
|
1245 | + $default_data['registrations'][$REG_ID] = $registration->status_ID(); |
|
1246 | 1246 | } |
1247 | - if ( $this->transaction->ID() ) { |
|
1248 | - $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID(); |
|
1247 | + if ($this->transaction->ID()) { |
|
1248 | + $TXN_ID = 'EE_Transaction: '.$this->transaction->ID(); |
|
1249 | 1249 | // don't serialize objects |
1250 | - $info = $this->_strip_objects( $info ); |
|
1251 | - if ( ! isset( $debug_data[ $TXN_ID ] ) ) { |
|
1252 | - $debug_data[ $TXN_ID ] = array(); |
|
1250 | + $info = $this->_strip_objects($info); |
|
1251 | + if ( ! isset($debug_data[$TXN_ID])) { |
|
1252 | + $debug_data[$TXN_ID] = array(); |
|
1253 | 1253 | } |
1254 | - $debug_data[ $TXN_ID ][ microtime() ] = array_merge( |
|
1254 | + $debug_data[$TXN_ID][microtime()] = array_merge( |
|
1255 | 1255 | $default_data, |
1256 | 1256 | $info |
1257 | 1257 | ); |
1258 | - update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data ); |
|
1258 | + update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data); |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | } |
@@ -1268,23 +1268,23 @@ discard block |
||
1268 | 1268 | * @param array $info |
1269 | 1269 | * @return array |
1270 | 1270 | */ |
1271 | - public function _strip_objects( $info = array() ) { |
|
1272 | - foreach ( (array)$info as $key => $value ) { |
|
1273 | - if ( is_array( $value )) { |
|
1274 | - $info[ $key ] = $this->_strip_objects( $value ); |
|
1275 | - } else if ( is_object( $value ) ) { |
|
1276 | - $object_class = get_class( $value ); |
|
1277 | - $info[ $object_class ] = array(); |
|
1278 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0; |
|
1279 | - if ( method_exists( $value, 'status' ) ) { |
|
1280 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
1281 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
1282 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
1271 | + public function _strip_objects($info = array()) { |
|
1272 | + foreach ((array) $info as $key => $value) { |
|
1273 | + if (is_array($value)) { |
|
1274 | + $info[$key] = $this->_strip_objects($value); |
|
1275 | + } else if (is_object($value)) { |
|
1276 | + $object_class = get_class($value); |
|
1277 | + $info[$object_class] = array(); |
|
1278 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0; |
|
1279 | + if (method_exists($value, 'status')) { |
|
1280 | + $info[$object_class]['status'] = $value->status(); |
|
1281 | + } else if (method_exists($value, 'status_ID')) { |
|
1282 | + $info[$object_class]['status'] = $value->status_ID(); |
|
1283 | 1283 | } |
1284 | - unset( $info[ $key ] ); |
|
1284 | + unset($info[$key]); |
|
1285 | 1285 | } |
1286 | 1286 | } |
1287 | - return (array)$info; |
|
1287 | + return (array) $info; |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 |
@@ -817,12 +817,12 @@ |
||
817 | 817 | if ( $registration instanceof EE_Registration ) { |
818 | 818 | // we display all attendee info for the primary registrant |
819 | 819 | if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
820 | - && $registration->is_primary_registrant() |
|
820 | + && $registration->is_primary_registrant() |
|
821 | 821 | ) { |
822 | 822 | $this->checkout->primary_revisit = true; |
823 | 823 | break; |
824 | 824 | } else if ( $this->checkout->revisit |
825 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
825 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
826 | 826 | ) { |
827 | 827 | // but hide info if it doesn't belong to you |
828 | 828 | $transaction->clear_cache( 'Registration', $registration->ID() ); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Single Page Checkout (SPCO) |
4 | 4 | * |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @return EED_Single_Page_Checkout |
39 | 39 | */ |
40 | 40 | public static function instance() { |
41 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
42 | - return parent::get_instance( __CLASS__ ); |
|
41 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
42 | + return parent::get_instance(__CLASS__); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function set_hooks_admin() { |
86 | 86 | EED_Single_Page_Checkout::set_definitions(); |
87 | - if ( defined( 'DOING_AJAX' )) { |
|
87 | + if (defined('DOING_AJAX')) { |
|
88 | 88 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
89 | 89 | ob_start(); |
90 | 90 | EED_Single_Page_Checkout::load_request_handler(); |
91 | 91 | EED_Single_Page_Checkout::load_reg_steps(); |
92 | 92 | } else { |
93 | 93 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
94 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
94 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
95 | 95 | } |
96 | 96 | // set ajax hooks |
97 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
98 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
99 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
100 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
101 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
102 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
97 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
98 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
99 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
100 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
101 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
102 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @param string $ajax_action |
111 | 111 | * @throws \EE_Error |
112 | 112 | */ |
113 | - public static function process_ajax_request( $ajax_action ) { |
|
114 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
113 | + public static function process_ajax_request($ajax_action) { |
|
114 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
115 | 115 | EED_Single_Page_Checkout::instance()->_initialize(); |
116 | 116 | } |
117 | 117 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @throws \EE_Error |
124 | 124 | */ |
125 | 125 | public static function display_reg_step() { |
126 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
126 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @throws \EE_Error |
135 | 135 | */ |
136 | 136 | public static function process_reg_step() { |
137 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
137 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @throws \EE_Error |
146 | 146 | */ |
147 | 147 | public static function update_reg_step() { |
148 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
148 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @throws \EE_Error |
159 | 159 | */ |
160 | 160 | public static function update_checkout() { |
161 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
161 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public static function load_request_handler() { |
173 | 173 | // load core Request_Handler class |
174 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
175 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
174 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
175 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | * @throws \EE_Error |
187 | 187 | */ |
188 | 188 | public static function set_definitions() { |
189 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
190 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
191 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
192 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
193 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
194 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
195 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
196 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
189 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
190 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
191 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
192 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
193 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
194 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
195 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
196 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public static function load_reg_steps() { |
210 | 210 | static $reg_steps_loaded = FALSE; |
211 | - if ( $reg_steps_loaded ) { |
|
211 | + if ($reg_steps_loaded) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | // filter list of reg_steps |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | EED_Single_Page_Checkout::get_reg_steps() |
218 | 218 | ); |
219 | 219 | // sort by key (order) |
220 | - ksort( $reg_steps_to_load ); |
|
220 | + ksort($reg_steps_to_load); |
|
221 | 221 | // loop through folders |
222 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
222 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
223 | 223 | // we need a |
224 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
224 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
225 | 225 | // copy over to the reg_steps_array |
226 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
226 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
227 | 227 | // register custom key route for each reg step |
228 | 228 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
229 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
229 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
230 | 230 | // add AJAX or other hooks |
231 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
231 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
232 | 232 | // setup autoloaders if necessary |
233 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
234 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
233 | + if ( ! class_exists($reg_step['class_name'])) { |
|
234 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
235 | 235 | } |
236 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
237 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
236 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
237 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
@@ -253,28 +253,28 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public static function get_reg_steps() { |
255 | 255 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
256 | - if ( empty( $reg_steps )) { |
|
256 | + if (empty($reg_steps)) { |
|
257 | 257 | $reg_steps = array( |
258 | 258 | 10 => array( |
259 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
259 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
260 | 260 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
261 | 261 | 'slug' => 'attendee_information', |
262 | 262 | 'has_hooks' => FALSE |
263 | 263 | ), |
264 | 264 | 20 => array( |
265 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
265 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
266 | 266 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
267 | 267 | 'slug' => 'registration_confirmation', |
268 | 268 | 'has_hooks' => FALSE |
269 | 269 | ), |
270 | 270 | 30 => array( |
271 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
271 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
272 | 272 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
273 | 273 | 'slug' => 'payment_options', |
274 | 274 | 'has_hooks' => TRUE |
275 | 275 | ), |
276 | 276 | 999 => array( |
277 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
277 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
278 | 278 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
279 | 279 | 'slug' => 'finalize_registration', |
280 | 280 | 'has_hooks' => FALSE |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public static function registration_checkout_for_admin() { |
297 | 297 | EED_Single_Page_Checkout::load_reg_steps(); |
298 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
299 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
300 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
298 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
299 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
300 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
301 | 301 | EED_Single_Page_Checkout::instance()->_initialize(); |
302 | 302 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
303 | 303 | return EE_Registry::instance()->REQ->get_output(); |
@@ -314,15 +314,15 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public static function process_registration_from_admin() { |
316 | 316 | EED_Single_Page_Checkout::load_reg_steps(); |
317 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
318 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
319 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
317 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
318 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
319 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
320 | 320 | EED_Single_Page_Checkout::instance()->_initialize(); |
321 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
322 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
323 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
324 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
325 | - if ( $final_reg_step->process_reg_step() ) { |
|
321 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
322 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
323 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
324 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
325 | + if ($final_reg_step->process_reg_step()) { |
|
326 | 326 | $final_reg_step->set_completed(); |
327 | 327 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
328 | 328 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | * @return void |
343 | 343 | * @throws \EE_Error |
344 | 344 | */ |
345 | - public function run( $WP_Query ) { |
|
345 | + public function run($WP_Query) { |
|
346 | 346 | if ( |
347 | 347 | $WP_Query instanceof WP_Query |
348 | 348 | && $WP_Query->is_main_query() |
349 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
349 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
350 | 350 | ) { |
351 | 351 | $this->_initialize(); |
352 | 352 | } |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | * @return void |
363 | 363 | * @throws \EE_Error |
364 | 364 | */ |
365 | - public static function init( $WP_Query ) { |
|
366 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
365 | + public static function init($WP_Query) { |
|
366 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
@@ -377,36 +377,36 @@ discard block |
||
377 | 377 | */ |
378 | 378 | private function _initialize() { |
379 | 379 | // ensure SPCO doesn't run twice |
380 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
380 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
381 | 381 | return; |
382 | 382 | } |
383 | 383 | try { |
384 | 384 | // setup the EE_Checkout object |
385 | 385 | $this->checkout = $this->_initialize_checkout(); |
386 | 386 | // filter checkout |
387 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
387 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
388 | 388 | // get the $_GET |
389 | 389 | $this->_get_request_vars(); |
390 | 390 | // filter continue_reg |
391 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
391 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
392 | 392 | // load the reg steps array |
393 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
393 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
394 | 394 | EED_Single_Page_Checkout::$_initialized = true; |
395 | 395 | return; |
396 | 396 | } |
397 | 397 | // set the current step |
398 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
398 | + $this->checkout->set_current_step($this->checkout->step); |
|
399 | 399 | // and the next step |
400 | 400 | $this->checkout->set_next_step(); |
401 | 401 | // was there already a valid transaction in the checkout from the session ? |
402 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
402 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
403 | 403 | // get transaction from db or session |
404 | 404 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
405 | 405 | ? $this->_get_transaction_and_cart_for_previous_visit() |
406 | 406 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
407 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
407 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
408 | 408 | EE_Error::add_error( |
409 | - __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), |
|
409 | + __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
410 | 410 | __FILE__, __FUNCTION__, __LINE__ |
411 | 411 | ); |
412 | 412 | // add some style and make it dance |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | return; |
417 | 417 | } |
418 | 418 | // and the registrations for the transaction |
419 | - $this->_get_registrations( $this->checkout->transaction ); |
|
419 | + $this->_get_registrations($this->checkout->transaction); |
|
420 | 420 | } |
421 | 421 | // verify that everything has been setup correctly |
422 | - if ( ! $this->_final_verifications() ) { |
|
422 | + if ( ! $this->_final_verifications()) { |
|
423 | 423 | EED_Single_Page_Checkout::$_initialized = true; |
424 | 424 | return; |
425 | 425 | } |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | // set no cache headers and constants |
445 | 445 | EE_System::do_not_cache(); |
446 | 446 | // add anchor |
447 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
448 | - } catch ( Exception $e ) { |
|
449 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
447 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
448 | + } catch (Exception $e) { |
|
449 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
@@ -464,20 +464,20 @@ discard block |
||
464 | 464 | // look in session for existing checkout |
465 | 465 | $checkout = EE_Registry::instance()->SSN->checkout(); |
466 | 466 | // verify |
467 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
467 | + if ( ! $checkout instanceof EE_Checkout) { |
|
468 | 468 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
469 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
469 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
470 | 470 | } else { |
471 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
471 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
472 | 472 | $this->unlock_transaction(); |
473 | - wp_safe_redirect( $checkout->redirect_url ); |
|
473 | + wp_safe_redirect($checkout->redirect_url); |
|
474 | 474 | exit(); |
475 | 475 | } |
476 | 476 | } |
477 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
477 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
478 | 478 | // verify again |
479 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
480 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
479 | + if ( ! $checkout instanceof EE_Checkout) { |
|
480 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
481 | 481 | } |
482 | 482 | // reset anything that needs a clean slate for each request |
483 | 483 | $checkout->reset_for_current_request(); |
@@ -497,24 +497,24 @@ discard block |
||
497 | 497 | // load classes |
498 | 498 | EED_Single_Page_Checkout::load_request_handler(); |
499 | 499 | //make sure this request is marked as belonging to EE |
500 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
500 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
501 | 501 | // which step is being requested ? |
502 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
502 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
503 | 503 | // which step is being edited ? |
504 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
504 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
505 | 505 | // and what we're doing on the current step |
506 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
506 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
507 | 507 | // returning to edit ? |
508 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
508 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
509 | 509 | // or some other kind of revisit ? |
510 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
510 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
511 | 511 | // and whether or not to generate a reg form for this request |
512 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
512 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
513 | 513 | // and whether or not to process a reg form submission for this request |
514 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
514 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
515 | 515 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
516 | 516 | ? $this->checkout->process_form_submission |
517 | - : FALSE; // TRUE FALSE |
|
517 | + : FALSE; // TRUE FALSE |
|
518 | 518 | // $this->_display_request_vars(); |
519 | 519 | } |
520 | 520 | |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | * @return void |
528 | 528 | */ |
529 | 529 | protected function _display_request_vars() { |
530 | - if ( ! WP_DEBUG ) { |
|
530 | + if ( ! WP_DEBUG) { |
|
531 | 531 | return; |
532 | 532 | } |
533 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
534 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
535 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
536 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
537 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
538 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
539 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
540 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
533 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
534 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
535 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
536 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
537 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
538 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
539 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
540 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | * @return array |
552 | 552 | */ |
553 | 553 | private function _get_first_step() { |
554 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
555 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
554 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
555 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | |
@@ -568,27 +568,27 @@ discard block |
||
568 | 568 | private function _load_and_instantiate_reg_steps() { |
569 | 569 | // have reg_steps already been instantiated ? |
570 | 570 | if ( |
571 | - empty( $this->checkout->reg_steps ) || |
|
572 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
571 | + empty($this->checkout->reg_steps) || |
|
572 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
573 | 573 | ) { |
574 | 574 | // if not, then loop through raw reg steps array |
575 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
576 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
575 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
576 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
577 | 577 | return false; |
578 | 578 | } |
579 | 579 | } |
580 | 580 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
581 | 581 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
582 | 582 | // skip the registration_confirmation page ? |
583 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
583 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
584 | 584 | // just remove it from the reg steps array |
585 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
585 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
586 | 586 | } else if ( |
587 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
587 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
588 | 588 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
589 | 589 | ) { |
590 | 590 | // set the order to something big like 100 |
591 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
591 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
592 | 592 | } |
593 | 593 | // filter the array for good luck |
594 | 594 | $this->checkout->reg_steps = apply_filters( |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | // finally re-sort based on the reg step class order properties |
599 | 599 | $this->checkout->sort_reg_steps(); |
600 | 600 | } else { |
601 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
601 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
602 | 602 | // set all current step stati to FALSE |
603 | - $reg_step->set_is_current_step( FALSE ); |
|
603 | + $reg_step->set_is_current_step(FALSE); |
|
604 | 604 | } |
605 | 605 | } |
606 | - if ( empty( $this->checkout->reg_steps )) { |
|
607 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
606 | + if (empty($this->checkout->reg_steps)) { |
|
607 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
608 | 608 | return false; |
609 | 609 | } |
610 | 610 | // make reg step details available to JS |
@@ -622,10 +622,10 @@ discard block |
||
622 | 622 | * @param int $order |
623 | 623 | * @return bool |
624 | 624 | */ |
625 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
625 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
626 | 626 | |
627 | 627 | // we need a file_path, class_name, and slug to add a reg step |
628 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
628 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
629 | 629 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
630 | 630 | if ( |
631 | 631 | $this->checkout->reg_url_link |
@@ -643,26 +643,26 @@ discard block |
||
643 | 643 | FALSE |
644 | 644 | ); |
645 | 645 | // did we gets the goods ? |
646 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
646 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
647 | 647 | // set reg step order based on config |
648 | - $reg_step_obj->set_order( $order ); |
|
648 | + $reg_step_obj->set_order($order); |
|
649 | 649 | // add instantiated reg step object to the master reg steps array |
650 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
650 | + $this->checkout->add_reg_step($reg_step_obj); |
|
651 | 651 | } else { |
652 | 652 | EE_Error::add_error( |
653 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
653 | + __('The current step could not be set.', 'event_espresso'), |
|
654 | 654 | __FILE__, __FUNCTION__, __LINE__ |
655 | 655 | ); |
656 | 656 | return false; |
657 | 657 | } |
658 | 658 | } else { |
659 | - if ( WP_DEBUG ) { |
|
659 | + if (WP_DEBUG) { |
|
660 | 660 | EE_Error::add_error( |
661 | 661 | sprintf( |
662 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
663 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
664 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
665 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
662 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
663 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
664 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
665 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
666 | 666 | '<ul>', |
667 | 667 | '<li>', |
668 | 668 | '</li>', |
@@ -686,16 +686,16 @@ discard block |
||
686 | 686 | */ |
687 | 687 | private function _get_transaction_and_cart_for_previous_visit() { |
688 | 688 | /** @var $TXN_model EEM_Transaction */ |
689 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
689 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
690 | 690 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
691 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
691 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
692 | 692 | // verify transaction |
693 | - if ( $transaction instanceof EE_Transaction ) { |
|
693 | + if ($transaction instanceof EE_Transaction) { |
|
694 | 694 | // and get the cart that was used for that transaction |
695 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
695 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
696 | 696 | return $transaction; |
697 | 697 | } else { |
698 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
698 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
699 | 699 | return NULL; |
700 | 700 | } |
701 | 701 | } |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | * @param EE_Transaction $transaction |
710 | 710 | * @return EE_Cart |
711 | 711 | */ |
712 | - private function _get_cart_for_transaction( $transaction ) { |
|
713 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
712 | + private function _get_cart_for_transaction($transaction) { |
|
713 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | |
@@ -722,8 +722,8 @@ discard block |
||
722 | 722 | * @param EE_Transaction $transaction |
723 | 723 | * @return EE_Cart |
724 | 724 | */ |
725 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
726 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
725 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
726 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | |
@@ -739,17 +739,17 @@ discard block |
||
739 | 739 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
740 | 740 | // if there's no transaction, then this is the FIRST visit to SPCO |
741 | 741 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
742 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
742 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
743 | 743 | // and then create a new transaction |
744 | 744 | $transaction = $this->_initialize_transaction(); |
745 | 745 | // verify transaction |
746 | - if ( $transaction instanceof EE_Transaction ) { |
|
746 | + if ($transaction instanceof EE_Transaction) { |
|
747 | 747 | // save it so that we have an ID for other objects to use |
748 | 748 | $transaction->save(); |
749 | 749 | // and save TXN data to the cart |
750 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
750 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
751 | 751 | } else { |
752 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
752 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
753 | 753 | } |
754 | 754 | return $transaction; |
755 | 755 | } |
@@ -769,15 +769,15 @@ discard block |
||
769 | 769 | // grab the cart grand total |
770 | 770 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
771 | 771 | // create new TXN |
772 | - return EE_Transaction::new_instance( array( |
|
772 | + return EE_Transaction::new_instance(array( |
|
773 | 773 | 'TXN_timestamp' => time(), |
774 | 774 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
775 | 775 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
776 | 776 | 'TXN_paid' => 0, |
777 | 777 | 'STS_ID' => EEM_Transaction::failed_status_code, |
778 | 778 | )); |
779 | - } catch( Exception $e ) { |
|
780 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
779 | + } catch (Exception $e) { |
|
780 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
781 | 781 | } |
782 | 782 | return NULL; |
783 | 783 | } |
@@ -792,38 +792,38 @@ discard block |
||
792 | 792 | * @return EE_Cart |
793 | 793 | * @throws \EE_Error |
794 | 794 | */ |
795 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
795 | + private function _get_registrations(EE_Transaction $transaction) { |
|
796 | 796 | // first step: grab the registrants { : o |
797 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
797 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
798 | 798 | // verify registrations have been set |
799 | - if ( empty( $registrations )) { |
|
799 | + if (empty($registrations)) { |
|
800 | 800 | // if no cached registrations, then check the db |
801 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
801 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
802 | 802 | // still nothing ? well as long as this isn't a revisit |
803 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
803 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
804 | 804 | // generate new registrations from scratch |
805 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
805 | + $registrations = $this->_initialize_registrations($transaction); |
|
806 | 806 | } |
807 | 807 | } |
808 | 808 | // sort by their original registration order |
809 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
809 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
810 | 810 | // then loop thru the array |
811 | - foreach ( $registrations as $registration ) { |
|
811 | + foreach ($registrations as $registration) { |
|
812 | 812 | // verify each registration |
813 | - if ( $registration instanceof EE_Registration ) { |
|
813 | + if ($registration instanceof EE_Registration) { |
|
814 | 814 | // we display all attendee info for the primary registrant |
815 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
815 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
816 | 816 | && $registration->is_primary_registrant() |
817 | 817 | ) { |
818 | 818 | $this->checkout->primary_revisit = true; |
819 | 819 | break; |
820 | - } else if ( $this->checkout->revisit |
|
820 | + } else if ($this->checkout->revisit |
|
821 | 821 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
822 | 822 | ) { |
823 | 823 | // but hide info if it doesn't belong to you |
824 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
824 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
825 | 825 | } |
826 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
826 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
827 | 827 | } |
828 | 828 | } |
829 | 829 | } |
@@ -838,17 +838,17 @@ discard block |
||
838 | 838 | * @return array |
839 | 839 | * @throws \EE_Error |
840 | 840 | */ |
841 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
841 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
842 | 842 | $att_nmbr = 0; |
843 | 843 | $registrations = array(); |
844 | - if ( $transaction instanceof EE_Transaction ) { |
|
844 | + if ($transaction instanceof EE_Transaction) { |
|
845 | 845 | /** @type EE_Registration_Processor $registration_processor */ |
846 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
846 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
847 | 847 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
848 | 848 | // now let's add the cart items to the $transaction |
849 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
849 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
850 | 850 | //do the following for each ticket of this type they selected |
851 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
851 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
852 | 852 | $att_nmbr++; |
853 | 853 | $registration = $registration_processor->generate_ONE_registration_from_line_item( |
854 | 854 | $line_item, |
@@ -856,12 +856,12 @@ discard block |
||
856 | 856 | $att_nmbr, |
857 | 857 | $this->checkout->total_ticket_count |
858 | 858 | ); |
859 | - if ( $registration instanceof EE_Registration ) { |
|
860 | - $registrations[ $registration->ID() ] = $registration; |
|
859 | + if ($registration instanceof EE_Registration) { |
|
860 | + $registrations[$registration->ID()] = $registration; |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | } |
864 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
864 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
865 | 865 | } |
866 | 866 | return $registrations; |
867 | 867 | } |
@@ -876,12 +876,12 @@ discard block |
||
876 | 876 | * @param EE_Registration $reg_B |
877 | 877 | * @return array() |
878 | 878 | */ |
879 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
879 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
880 | 880 | // this shouldn't ever happen within the same TXN, but oh well |
881 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
881 | + if ($reg_A->count() === $reg_B->count()) { |
|
882 | 882 | return 0; |
883 | 883 | } |
884 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
884 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -896,21 +896,21 @@ discard block |
||
896 | 896 | */ |
897 | 897 | private function _final_verifications() { |
898 | 898 | // filter checkout |
899 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
899 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
900 | 900 | //verify that current step is still set correctly |
901 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
902 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
901 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
902 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
903 | 903 | return false; |
904 | 904 | } |
905 | 905 | // if returning to SPCO, then verify that primary registrant is set |
906 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
906 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
907 | 907 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
908 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
909 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
908 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
909 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
910 | 910 | return false; |
911 | 911 | } |
912 | 912 | $valid_registrant = null; |
913 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
913 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
914 | 914 | if ( |
915 | 915 | $registration instanceof EE_Registration |
916 | 916 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -918,14 +918,14 @@ discard block |
||
918 | 918 | $valid_registrant = $registration; |
919 | 919 | } |
920 | 920 | } |
921 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
922 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
921 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
922 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
923 | 923 | return false; |
924 | 924 | } |
925 | 925 | } |
926 | 926 | // now that things have been kinda sufficiently verified, |
927 | 927 | // let's add the checkout to the session so that's available other systems |
928 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
928 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
929 | 929 | return true; |
930 | 930 | } |
931 | 931 | |
@@ -940,28 +940,28 @@ discard block |
||
940 | 940 | * @param bool $reinitializing |
941 | 941 | * @throws \EE_Error |
942 | 942 | */ |
943 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
944 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
943 | + private function _initialize_reg_steps($reinitializing = false) { |
|
944 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
945 | 945 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
946 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
947 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
946 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
947 | + if ( ! $reg_step->initialize_reg_step()) { |
|
948 | 948 | // if not initialized then maybe this step is being removed... |
949 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
949 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
950 | 950 | // if it was the current step, then we need to start over here |
951 | - $this->_initialize_reg_steps( true ); |
|
951 | + $this->_initialize_reg_steps(true); |
|
952 | 952 | return; |
953 | 953 | } |
954 | 954 | continue; |
955 | 955 | } |
956 | 956 | // i18n |
957 | 957 | $reg_step->translate_js_strings(); |
958 | - if ( $reg_step->is_current_step() ) { |
|
958 | + if ($reg_step->is_current_step()) { |
|
959 | 959 | // the text that appears on the reg step form submit button |
960 | 960 | $reg_step->set_submit_button_text(); |
961 | 961 | } |
962 | 962 | } |
963 | 963 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
964 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
964 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | |
@@ -974,43 +974,43 @@ discard block |
||
974 | 974 | */ |
975 | 975 | private function _check_form_submission() { |
976 | 976 | //does this request require the reg form to be generated ? |
977 | - if ( $this->checkout->generate_reg_form ) { |
|
977 | + if ($this->checkout->generate_reg_form) { |
|
978 | 978 | // ever heard that song by Blue Rodeo ? |
979 | 979 | try { |
980 | 980 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
981 | 981 | // if not displaying a form, then check for form submission |
982 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
982 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
983 | 983 | // clear out any old data in case this step is being run again |
984 | - $this->checkout->current_step->set_valid_data( array() ); |
|
984 | + $this->checkout->current_step->set_valid_data(array()); |
|
985 | 985 | // capture submitted form data |
986 | 986 | $this->checkout->current_step->reg_form->receive_form_submission( |
987 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
987 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
988 | 988 | ); |
989 | 989 | // validate submitted form data |
990 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
990 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
991 | 991 | // thou shall not pass !!! |
992 | 992 | $this->checkout->continue_reg = FALSE; |
993 | 993 | // any form validation errors? |
994 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
994 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
995 | 995 | $submission_error_messages = array(); |
996 | 996 | // bad, bad, bad registrant |
997 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
998 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
997 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
998 | + if ($validation_error instanceof EE_Validation_Error) { |
|
999 | 999 | $submission_error_messages[] = sprintf( |
1000 | - __( '%s : %s', 'event_espresso' ), |
|
1000 | + __('%s : %s', 'event_espresso'), |
|
1001 | 1001 | $validation_error->get_form_section()->html_label_text(), |
1002 | 1002 | $validation_error->getMessage() |
1003 | 1003 | ); |
1004 | 1004 | } |
1005 | 1005 | } |
1006 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1006 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1007 | 1007 | } |
1008 | 1008 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1009 | 1009 | $this->go_to_next_step(); |
1010 | 1010 | return; |
1011 | 1011 | } |
1012 | 1012 | } |
1013 | - } catch( EE_Error $e ) { |
|
1013 | + } catch (EE_Error $e) { |
|
1014 | 1014 | $e->get_error(); |
1015 | 1015 | } |
1016 | 1016 | } |
@@ -1027,22 +1027,22 @@ discard block |
||
1027 | 1027 | */ |
1028 | 1028 | private function _process_form_action() { |
1029 | 1029 | // what cha wanna do? |
1030 | - switch( $this->checkout->action ) { |
|
1030 | + switch ($this->checkout->action) { |
|
1031 | 1031 | // AJAX next step reg form |
1032 | 1032 | case 'display_spco_reg_step' : |
1033 | 1033 | $this->checkout->redirect = FALSE; |
1034 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1035 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1034 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1035 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1036 | 1036 | } |
1037 | 1037 | break; |
1038 | 1038 | |
1039 | 1039 | default : |
1040 | 1040 | // meh... do one of those other steps first |
1041 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1041 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1042 | 1042 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1043 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1043 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1044 | 1044 | // call action on current step |
1045 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1045 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1046 | 1046 | // good registrant, you get to proceed |
1047 | 1047 | if ( |
1048 | 1048 | $this->checkout->current_step->success_message() !== '' |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | ) { |
1054 | 1054 | EE_Error::add_success( |
1055 | 1055 | $this->checkout->current_step->success_message() |
1056 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1056 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1057 | 1057 | ); |
1058 | 1058 | |
1059 | 1059 | } |
@@ -1061,12 +1061,12 @@ discard block |
||
1061 | 1061 | $this->_setup_redirect(); |
1062 | 1062 | } |
1063 | 1063 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1064 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1064 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1065 | 1065 | |
1066 | 1066 | } else { |
1067 | 1067 | EE_Error::add_error( |
1068 | 1068 | sprintf( |
1069 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1069 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1070 | 1070 | $this->checkout->action, |
1071 | 1071 | $this->checkout->current_step->name() |
1072 | 1072 | ), |
@@ -1092,10 +1092,10 @@ discard block |
||
1092 | 1092 | public function add_styles_and_scripts() { |
1093 | 1093 | // i18n |
1094 | 1094 | $this->translate_js_strings(); |
1095 | - if ( $this->checkout->admin_request ) { |
|
1096 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1095 | + if ($this->checkout->admin_request) { |
|
1096 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1097 | 1097 | } else { |
1098 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1098 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | |
@@ -1111,42 +1111,42 @@ discard block |
||
1111 | 1111 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1112 | 1112 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1113 | 1113 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1114 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1115 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1116 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1114 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1115 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1116 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1117 | 1117 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1118 | 1118 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1119 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' ); |
|
1120 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1119 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>'); |
|
1120 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1121 | 1121 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1122 | 1122 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1123 | 1123 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1124 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1125 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1126 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1127 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1128 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1129 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1130 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1131 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1132 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1133 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1134 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1135 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1136 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1137 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1124 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1125 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1126 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1127 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1128 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1129 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1130 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1131 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1132 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1133 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1134 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1135 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1136 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1137 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1138 | 1138 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1139 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1139 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1140 | 1140 | '<h4 class="important-notice">', |
1141 | 1141 | '</h4>', |
1142 | 1142 | '<br />', |
1143 | 1143 | '<p>', |
1144 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1144 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1145 | 1145 | '">', |
1146 | 1146 | '</a>', |
1147 | 1147 | '</p>' |
1148 | 1148 | ); |
1149 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1149 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | |
@@ -1159,25 +1159,25 @@ discard block |
||
1159 | 1159 | */ |
1160 | 1160 | public function enqueue_styles_and_scripts() { |
1161 | 1161 | // load css |
1162 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1163 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1162 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1163 | + wp_enqueue_style('single_page_checkout'); |
|
1164 | 1164 | // load JS |
1165 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1166 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1167 | - wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1168 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1165 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1166 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1167 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1168 | + wp_enqueue_script('single_page_checkout'); |
|
1169 | 1169 | |
1170 | 1170 | /** |
1171 | 1171 | * global action hook for enqueueing styles and scripts with |
1172 | 1172 | * spco calls. |
1173 | 1173 | */ |
1174 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1174 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1175 | 1175 | |
1176 | 1176 | /** |
1177 | 1177 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1178 | 1178 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1179 | 1179 | */ |
1180 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1180 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1181 | 1181 | |
1182 | 1182 | // add css and JS for current step |
1183 | 1183 | $this->checkout->current_step->enqueue_styles_and_scripts(); |
@@ -1194,19 +1194,19 @@ discard block |
||
1194 | 1194 | */ |
1195 | 1195 | private function _display_spco_reg_form() { |
1196 | 1196 | // if registering via the admin, just display the reg form for the current step |
1197 | - if ( $this->checkout->admin_request ) { |
|
1198 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1197 | + if ($this->checkout->admin_request) { |
|
1198 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1199 | 1199 | } else { |
1200 | 1200 | // add powered by EE msg |
1201 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1201 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1202 | 1202 | |
1203 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1203 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1204 | 1204 | $cookies_not_set_msg = ''; |
1205 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1205 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1206 | 1206 | $cookies_not_set_msg = apply_filters( |
1207 | 1207 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1208 | 1208 | sprintf( |
1209 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1209 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1210 | 1210 | '<div class="ee-attention">', |
1211 | 1211 | '</div>', |
1212 | 1212 | '<h6 class="important-notice">', |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | 'layout_strategy' => |
1227 | 1227 | new EE_Template_Layout( |
1228 | 1228 | array( |
1229 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1229 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1230 | 1230 | 'template_args' => array( |
1231 | 1231 | 'empty_cart' => $empty_cart, |
1232 | 1232 | 'revisit' => $this->checkout->revisit, |
@@ -1235,8 +1235,8 @@ discard block |
||
1235 | 1235 | 'empty_msg' => apply_filters( |
1236 | 1236 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1237 | 1237 | sprintf( |
1238 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1239 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1238 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1239 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1240 | 1240 | '">', |
1241 | 1241 | '</a>' |
1242 | 1242 | ) |
@@ -1244,14 +1244,14 @@ discard block |
||
1244 | 1244 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
1245 | 1245 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
1246 | 1246 | 'session_expiration' => |
1247 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
1247 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
1248 | 1248 | ) |
1249 | 1249 | ) |
1250 | 1250 | ) |
1251 | 1251 | ) |
1252 | 1252 | ); |
1253 | 1253 | // load template and add to output sent that gets filtered into the_content() |
1254 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1254 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1255 | 1255 | } |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1265,8 +1265,8 @@ discard block |
||
1265 | 1265 | * @internal param string $label |
1266 | 1266 | * @return string |
1267 | 1267 | */ |
1268 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1269 | - if ( $next_step === 'finalize_registration' ) { |
|
1268 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1269 | + if ($next_step === 'finalize_registration') { |
|
1270 | 1270 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1271 | 1271 | } |
1272 | 1272 | } |
@@ -1280,18 +1280,18 @@ discard block |
||
1280 | 1280 | * @return string |
1281 | 1281 | */ |
1282 | 1282 | public static function display_registration_footer() { |
1283 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1284 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1285 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
1286 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1283 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1284 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1285 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
1286 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1287 | 1287 | echo apply_filters( |
1288 | 1288 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1289 | 1289 | sprintf( |
1290 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1291 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1290 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1291 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1292 | 1292 | '" target="_blank">', |
1293 | 1293 | '</a>', |
1294 | - '<a href="' . $url . '" title="', |
|
1294 | + '<a href="'.$url.'" title="', |
|
1295 | 1295 | '" target="_blank">', |
1296 | 1296 | '</a></div>' |
1297 | 1297 | ) |
@@ -1322,12 +1322,12 @@ discard block |
||
1322 | 1322 | * @return array |
1323 | 1323 | */ |
1324 | 1324 | private function _setup_redirect() { |
1325 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1325 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1326 | 1326 | $this->checkout->redirect = TRUE; |
1327 | - if ( empty( $this->checkout->redirect_url )) { |
|
1327 | + if (empty($this->checkout->redirect_url)) { |
|
1328 | 1328 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1329 | 1329 | } |
1330 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1330 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1331 | 1331 | } |
1332 | 1332 | } |
1333 | 1333 | |
@@ -1341,9 +1341,9 @@ discard block |
||
1341 | 1341 | * @throws \EE_Error |
1342 | 1342 | */ |
1343 | 1343 | public function go_to_next_step() { |
1344 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1344 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1345 | 1345 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1346 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1346 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1347 | 1347 | } |
1348 | 1348 | $this->unlock_transaction(); |
1349 | 1349 | // just return for these conditions |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | */ |
1373 | 1373 | protected function _handle_json_response() { |
1374 | 1374 | // if this is an ajax request |
1375 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1375 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1376 | 1376 | // DEBUG LOG |
1377 | 1377 | //$this->checkout->log( |
1378 | 1378 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | $this->checkout->json_response->set_registration_time_limit( |
1386 | 1386 | $this->checkout->get_registration_time_limit() |
1387 | 1387 | ); |
1388 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1388 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1389 | 1389 | // just send the ajax ( |
1390 | 1390 | $json_response = apply_filters( |
1391 | 1391 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1406,9 +1406,9 @@ discard block |
||
1406 | 1406 | */ |
1407 | 1407 | protected function _handle_html_redirects() { |
1408 | 1408 | // going somewhere ? |
1409 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1409 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1410 | 1410 | // store notices in a transient |
1411 | - EE_Error::get_notices( false, true, true ); |
|
1411 | + EE_Error::get_notices(false, true, true); |
|
1412 | 1412 | // DEBUG LOG |
1413 | 1413 | //$this->checkout->log( |
1414 | 1414 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | // 'headers_list' => headers_list(), |
1419 | 1419 | // ) |
1420 | 1420 | //); |
1421 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1421 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1422 | 1422 | exit(); |
1423 | 1423 | } |
1424 | 1424 | } |
@@ -112,7 +112,7 @@ |
||
112 | 112 | if ( |
113 | 113 | ! ( |
114 | 114 | $this->checkout->payment_method instanceof EE_Payment_Method |
115 | - && $this->checkout->payment_method->is_off_site() |
|
115 | + && $this->checkout->payment_method->is_off_site() |
|
116 | 116 | ) |
117 | 117 | ) { |
118 | 118 | // mark this reg step as completed |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param EE_Checkout $checkout |
23 | 23 | * @return \EE_SPCO_Reg_Step_Finalize_Registration |
24 | 24 | */ |
25 | - public function __construct( EE_Checkout $checkout ) { |
|
25 | + public function __construct(EE_Checkout $checkout) { |
|
26 | 26 | $this->_slug = 'finalize_registration'; |
27 | - $this->_name = __( 'Finalize Registration', 'event_espresso' ); |
|
27 | + $this->_name = __('Finalize Registration', 'event_espresso'); |
|
28 | 28 | $this->_submit_button_text = $this->_name; |
29 | 29 | $this->_template = ''; |
30 | 30 | $this->checkout = $checkout; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function initialize_reg_step() { |
49 | 49 | // there's actually no reg form to process if this is the final step |
50 | - if ( $this->is_current_step() ) { |
|
50 | + if ($this->is_current_step()) { |
|
51 | 51 | $this->checkout->step = $_REQUEST['step'] = $this->slug(); |
52 | 52 | $this->checkout->action = $_REQUEST['action'] = 'process_reg_step'; |
53 | 53 | $this->checkout->generate_reg_form = false; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function process_reg_step() { |
75 | 75 | // ensure all data gets refreshed from the db |
76 | - $this->checkout->refresh_all_entities( true ); |
|
76 | + $this->checkout->refresh_all_entities(true); |
|
77 | 77 | // ensures that all details and statuses for transaction, registration, and payments are updated |
78 | 78 | $txn_update_params = $this->_finalize_transaction(); |
79 | 79 | // DEBUG LOG |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | $txn_update_params |
103 | 103 | ); |
104 | 104 | // check if transaction has a primary registrant and that it has a related Attendee object |
105 | - if ( ! $this->_validate_primary_registrant() ) { |
|
105 | + if ( ! $this->_validate_primary_registrant()) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | // you don't have to go home but you can't stay here ! |
109 | 109 | $this->checkout->redirect = true; |
110 | 110 | $this->checkout->continue_reg = true; |
111 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
111 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
112 | 112 | if ( |
113 | 113 | ! ( |
114 | 114 | $this->checkout->payment_method instanceof EE_Payment_Method |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function _finalize_transaction() { |
135 | 135 | /** @type EE_Transaction_Processor $transaction_processor */ |
136 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
136 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
137 | 137 | //set revisit flag in txn processor |
138 | - $transaction_processor->set_revisit( $this->checkout->revisit ); |
|
138 | + $transaction_processor->set_revisit($this->checkout->revisit); |
|
139 | 139 | // at this point we'll consider a TXN to not have been abandoned |
140 | - $transaction_processor->toggle_abandoned_transaction_status( $this->checkout->transaction ); |
|
141 | - if ( $this->checkout->cart instanceof EE_Cart ) { |
|
140 | + $transaction_processor->toggle_abandoned_transaction_status($this->checkout->transaction); |
|
141 | + if ($this->checkout->cart instanceof EE_Cart) { |
|
142 | 142 | // save TXN data to the cart |
143 | 143 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
144 | 144 | $this->checkout->transaction->ID() |
145 | 145 | ); |
146 | 146 | } |
147 | 147 | /** @type EE_Transaction_Payments $transaction_payments */ |
148 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
148 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
149 | 149 | // maybe update status, but don't save transaction just yet |
150 | - $transaction_payments->update_transaction_status_based_on_total_paid( $this->checkout->transaction, false ); |
|
150 | + $transaction_payments->update_transaction_status_based_on_total_paid($this->checkout->transaction, false); |
|
151 | 151 | // maybe send messages |
152 | 152 | $this->_trigger_notifications(); |
153 | 153 | // this will result in the base session properties getting saved to the TXN_Session_data field |
154 | 154 | $this->checkout->transaction->set_txn_session_data( |
155 | - EE_Registry::instance()->SSN->get_session_data( null, true ) |
|
155 | + EE_Registry::instance()->SSN->get_session_data(null, true) |
|
156 | 156 | ); |
157 | 157 | // update the TXN if payment conditions have changed |
158 | 158 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
@@ -174,30 +174,30 @@ discard block |
||
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | 176 | protected function _trigger_notifications() { |
177 | - if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
178 | - $is_revisit = filter_var( $this->checkout->revisit, FILTER_VALIDATE_BOOLEAN ); |
|
179 | - if ( $this->checkout->payment_method->is_off_site() ) { |
|
177 | + if ($this->checkout->payment_method instanceof EE_Payment_Method) { |
|
178 | + $is_revisit = filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN); |
|
179 | + if ($this->checkout->payment_method->is_off_site()) { |
|
180 | 180 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
181 | 181 | // If the selected method of payment used an off-site gateway... |
182 | - if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) { |
|
182 | + if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) { |
|
183 | 183 | // do NOT trigger notifications because it was already done during the IPN |
184 | - remove_all_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ); |
|
184 | + remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
185 | 185 | add_filter( |
186 | 186 | 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
187 | 187 | '__return_false', |
188 | 188 | 15 |
189 | 189 | ); |
190 | - } else if ( ! $is_revisit ) { |
|
191 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
190 | + } else if ( ! $is_revisit) { |
|
191 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
192 | 192 | } |
193 | 193 | } else if ( |
194 | 194 | // if SPCO revisit and TXN status has changed due to a payment |
195 | - $is_revisit && ( $this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated() ) |
|
195 | + $is_revisit && ($this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated()) |
|
196 | 196 | ) { |
197 | 197 | // send out notifications |
198 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
199 | - } else if ( ! $is_revisit ) { |
|
200 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
198 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
199 | + } else if ( ! $is_revisit) { |
|
200 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | * @throws \EE_Error |
212 | 212 | */ |
213 | 213 | protected function _validate_primary_registrant() { |
214 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
214 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
215 | 215 | EE_Error::add_error( |
216 | - __( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ), |
|
216 | + __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'), |
|
217 | 217 | __FILE__, |
218 | 218 | __FUNCTION__, |
219 | 219 | __LINE__ |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | } |
225 | 225 | // setup URL for redirect |
226 | 226 | $this->checkout->redirect_url = add_query_arg( |
227 | - array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ), |
|
227 | + array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()), |
|
228 | 228 | $this->checkout->thank_you_page_url |
229 | 229 | ); |
230 | 230 | return true; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function update_reg_step() { |
239 | 239 | EE_Error::doing_it_wrong( |
240 | - __CLASS__ . '::' . __FILE__, |
|
240 | + __CLASS__.'::'.__FILE__, |
|
241 | 241 | __( |
242 | 242 | 'Can not call update_reg_step() on the Finalize Registration reg step.', |
243 | 243 | 'event_espresso' |
@@ -310,23 +310,23 @@ discard block |
||
310 | 310 | * @param float $amount |
311 | 311 | * @param string $name |
312 | 312 | * @param string $description |
313 | - * @param string $code |
|
314 | - * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | - * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | - * set the taxes to match $amount |
|
313 | + * @param string $code |
|
314 | + * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | + * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | + * set the taxes to match $amount |
|
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | 319 | public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
320 | 320 | |
321 | - /** |
|
322 | - * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | - * Does NOT save the line items |
|
324 | - * @param EE_Line_Item $line_item |
|
325 | - * @param boolean $taxable |
|
326 | - * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | - * it will be whitelisted (ie, except from becoming taxable) |
|
328 | - */ |
|
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
321 | + /** |
|
322 | + * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | + * Does NOT save the line items |
|
324 | + * @param EE_Line_Item $line_item |
|
325 | + * @param boolean $taxable |
|
326 | + * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | + * it will be whitelisted (ie, except from becoming taxable) |
|
328 | + */ |
|
329 | + public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | */ |
357 | 357 | interface EEHI_Money{ |
358 | 358 | /** |
359 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | - * This should be used to compare floats instead of normal '==' because floats |
|
361 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | - * but actually differ by 0.00000001. |
|
363 | - * @param float $float1 |
|
364 | - * @param float $float2 |
|
365 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | - * @return boolean whether the equation is true or false |
|
367 | - */ |
|
359 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | + * This should be used to compare floats instead of normal '==' because floats |
|
361 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | + * but actually differ by 0.00000001. |
|
363 | + * @param float $float1 |
|
364 | + * @param float $float2 |
|
365 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | + * @return boolean whether the equation is true or false |
|
367 | + */ |
|
368 | 368 | public function compare_floats( $float1, $float2, $operator='=' ); |
369 | 369 | } |
370 | 370 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Interface EEI_Base |
7 | 7 | */ |
8 | -interface EEI_Base{ |
|
8 | +interface EEI_Base { |
|
9 | 9 | /** |
10 | 10 | * gets the unique ID of the model object. If it hasn't been saved yet |
11 | 11 | * to the database, this should be 0 or NULL |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
33 | 33 | * NOTE: if the values haven't changed, returns 0 |
34 | 34 | */ |
35 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL); |
|
35 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param boolean $unique |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function add_extra_meta($meta_key,$meta_value,$unique = false); |
|
46 | + public function add_extra_meta($meta_key, $meta_value, $unique = false); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deletes all the extra meta rows for this record as specified by key. If $meta_value |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $meta_value |
53 | 53 | * @return int number of extra meta rows deleted |
54 | 54 | */ |
55 | - public function delete_extra_meta($meta_key,$meta_value = NULL); |
|
55 | + public function delete_extra_meta($meta_key, $meta_value = NULL); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $default if we don't find anything, what should we return? |
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
|
66 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param EE_Response $response |
91 | 91 | * @return EE_Response |
92 | 92 | */ |
93 | - public function handle_request( EE_Request $request, EE_Response $response ); |
|
93 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param EE_Request $request |
107 | 107 | * @param EE_Response $response |
108 | 108 | */ |
109 | - public function handle_response( EE_Request $request, EE_Response $response ); |
|
109 | + public function handle_response(EE_Request $request, EE_Response $response); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param string $country |
287 | 287 | * @param string $CNT_ISO |
288 | 288 | */ |
289 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
|
289 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | /** |
297 | 297 | * Interface EEHI_Line_Item |
298 | 298 | */ |
299 | -interface EEHI_Line_Item{ |
|
299 | +interface EEHI_Line_Item { |
|
300 | 300 | /** |
301 | 301 | * Adds an item to the purchase in the right spot |
302 | 302 | * @param EE_Line_Item $total_line_item |
303 | 303 | * @param EE_Line_Item $line_item |
304 | 304 | */ |
305 | - public function add_item( EE_Line_Item $total_line_item, EE_Line_Item $line_item ); |
|
305 | + public function add_item(EE_Line_Item $total_line_item, EE_Line_Item $line_item); |
|
306 | 306 | /** |
307 | 307 | * Overwrites the previous tax by clearing out the old taxes, and creates a new |
308 | 308 | * tax and updates the total line item accordingly |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * set the taxes to match $amount |
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | - public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
|
319 | + public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false); |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Makes all the line items which are children of $line_item taxable (or not). |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $code_substring_for_whitelist if this string is part of the line item's code |
327 | 327 | * it will be whitelisted (ie, except from becoming taxable) |
328 | 328 | */ |
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
329 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -340,21 +340,21 @@ discard block |
||
340 | 340 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
341 | 341 | * @return boolean success |
342 | 342 | */ |
343 | - public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null ); |
|
343 | + public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null); |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Gets the line item for the taxes subtotal |
347 | 347 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
348 | 348 | * @return \EE_Line_Item |
349 | 349 | */ |
350 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ); |
|
350 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Money-related helper |
356 | 356 | */ |
357 | -interface EEHI_Money{ |
|
357 | +interface EEHI_Money { |
|
358 | 358 | /** |
359 | 359 | * For comparing floats. Default operator is '=', but see the $operator below for all options. |
360 | 360 | * This should be used to compare floats instead of normal '==' because floats |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
366 | 366 | * @return boolean whether the equation is true or false |
367 | 367 | */ |
368 | - public function compare_floats( $float1, $float2, $operator='=' ); |
|
368 | + public function compare_floats($float1, $float2, $operator = '='); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Interface EEHI_Template |
373 | 373 | */ |
374 | -interface EEHI_Template{ |
|
374 | +interface EEHI_Template { |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * EEH_Template::format_currency |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param string $cur_code_span_class |
385 | 385 | * @return string the html output for the formatted money value |
386 | 386 | */ |
387 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ); |
|
387 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code'); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param array $options |
400 | 400 | * @return mixed |
401 | 401 | */ |
402 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
402 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws EE_Error |
417 | 417 | * @return bool |
418 | 418 | */ |
419 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ); |
|
419 | + public static function ensure_file_exists_and_is_writable($full_file_path = ''); |
|
420 | 420 | |
421 | 421 | /** |
422 | 422 | * ensure_folder_exists_and_is_writable |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @throws EE_Error |
426 | 426 | * @return bool |
427 | 427 | */ |
428 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ); |
|
428 | + public static function ensure_folder_exists_and_is_writable($folder = ''); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | // End of file EEI_Interfaces.php |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * the interaction of EE_Transaction and EE_Registration model objects |
8 | 8 | * Provides methods for manipulating and processing changes to an EE_Transaction |
9 | 9 | * and it's related EE_Registrations with regards to the checkout/registration process |
10 | - |
|
11 | -* |
|
10 | + * |
|
12 | 11 | *@package Event Espresso |
13 | 12 | * @subpackage core |
14 | 13 | * @author Brent Christensen |
@@ -704,7 +703,7 @@ discard block |
||
704 | 703 | foreach ( $available_payment_methods as $available_payment_method ) { |
705 | 704 | if ( |
706 | 705 | $available_payment_method instanceof EE_Payment_Method |
707 | - && $available_payment_method->open_by_default() |
|
706 | + && $available_payment_method->open_by_default() |
|
708 | 707 | ) { |
709 | 708 | $PMD_ID = $available_payment_method->ID(); |
710 | 709 | break; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class EE_Transaction_Processor |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * @param array $registration_query_params |
53 | 53 | *@return EE_Transaction_Processor instance |
54 | 54 | */ |
55 | - public static function instance( $registration_query_params = array() ) { |
|
55 | + public static function instance($registration_query_params = array()) { |
|
56 | 56 | // check if class object is instantiated |
57 | - if ( ! self::$_instance instanceof EE_Transaction_Processor ) { |
|
58 | - self::$_instance = new self( $registration_query_params ); |
|
57 | + if ( ! self::$_instance instanceof EE_Transaction_Processor) { |
|
58 | + self::$_instance = new self($registration_query_params); |
|
59 | 59 | } |
60 | 60 | return self::$_instance; |
61 | 61 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @param array $registration_query_params |
67 | 67 | * @return EE_Transaction_Processor |
68 | 68 | */ |
69 | - private function __construct( $registration_query_params = array() ) { |
|
69 | + private function __construct($registration_query_params = array()) { |
|
70 | 70 | // make sure some query params are set for retrieving registrations |
71 | - $this->_set_registration_query_params( $registration_query_params ); |
|
71 | + $this->_set_registration_query_params($registration_query_params); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @access private |
78 | 78 | * @param array $registration_query_params |
79 | 79 | */ |
80 | - private function _set_registration_query_params( $registration_query_params ) { |
|
81 | - $this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
80 | + private function _set_registration_query_params($registration_query_params) { |
|
81 | + $this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * @param string $old_txn_status |
97 | 97 | */ |
98 | - public function set_old_txn_status( $old_txn_status ) { |
|
98 | + public function set_old_txn_status($old_txn_status) { |
|
99 | 99 | // only set the first time |
100 | - if ( $this->_old_txn_status === null ) { |
|
100 | + if ($this->_old_txn_status === null) { |
|
101 | 101 | $this->_old_txn_status = $old_txn_status; |
102 | 102 | } |
103 | 103 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * @param string $new_txn_status |
118 | 118 | */ |
119 | - public function set_new_txn_status( $new_txn_status ) { |
|
119 | + public function set_new_txn_status($new_txn_status) { |
|
120 | 120 | $this->_new_txn_status = $new_txn_status; |
121 | 121 | } |
122 | 122 | |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * @param bool $check_all |
148 | 148 | * @return boolean | int |
149 | 149 | */ |
150 | - private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) { |
|
150 | + private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) { |
|
151 | 151 | $reg_steps = $transaction->reg_steps(); |
152 | - if ( ! is_array( $reg_steps ) || empty( $reg_steps )) { |
|
152 | + if ( ! is_array($reg_steps) || empty($reg_steps)) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | // loop thru reg steps array) |
156 | - foreach ( $reg_steps as $slug => $reg_step_completed ) { |
|
156 | + foreach ($reg_steps as $slug => $reg_step_completed) { |
|
157 | 157 | // if NOT checking ALL steps (only checking one step) |
158 | - if ( ! $check_all ) { |
|
158 | + if ( ! $check_all) { |
|
159 | 159 | // and this is the one |
160 | - if ( $slug === $reg_step_slug ) { |
|
160 | + if ($slug === $reg_step_slug) { |
|
161 | 161 | return $reg_step_completed; |
162 | 162 | } else { |
163 | 163 | // skip to next reg step in loop |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | // $check_all must be true, else we would never have gotten to this point |
168 | - if ( $slug === $reg_step_slug ) { |
|
168 | + if ($slug === $reg_step_slug) { |
|
169 | 169 | // if we reach this point, then we are testing either: |
170 | 170 | // all_reg_steps_completed_except() or |
171 | 171 | // all_reg_steps_completed_except_final_step(), |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | // ie: "is everything completed except the final step?" |
175 | 175 | // "that is correct... the final step is not completed, but all others are." |
176 | 176 | return $reg_step_completed !== true ? true : false; |
177 | - } else if ( $reg_step_completed !== true ) { |
|
177 | + } else if ($reg_step_completed !== true) { |
|
178 | 178 | // if any reg step is NOT completed, then ALL steps are not completed |
179 | 179 | return false; |
180 | 180 | } |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * @param EE_Transaction $transaction |
196 | 196 | * @return boolean |
197 | 197 | */ |
198 | - public function all_reg_steps_completed( EE_Transaction $transaction ) { |
|
199 | - return $this->_reg_steps_completed( $transaction ); |
|
198 | + public function all_reg_steps_completed(EE_Transaction $transaction) { |
|
199 | + return $this->_reg_steps_completed($transaction); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | * @param string $exception |
214 | 214 | * @return boolean |
215 | 215 | */ |
216 | - public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) { |
|
217 | - return $this->_reg_steps_completed( $transaction, $exception ); |
|
216 | + public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') { |
|
217 | + return $this->_reg_steps_completed($transaction, $exception); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param EE_Transaction $transaction |
231 | 231 | * @return boolean |
232 | 232 | */ |
233 | - public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) { |
|
234 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration' ); |
|
233 | + public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) { |
|
234 | + return $this->_reg_steps_completed($transaction, 'finalize_registration'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $reg_step_slug |
249 | 249 | * @return boolean | int |
250 | 250 | */ |
251 | - public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
252 | - return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE ); |
|
251 | + public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
252 | + return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * @param EE_Transaction $transaction |
266 | 266 | * @return boolean | int |
267 | 267 | */ |
268 | - public function final_reg_step_completed( EE_Transaction $transaction ) { |
|
269 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE ); |
|
268 | + public function final_reg_step_completed(EE_Transaction $transaction) { |
|
269 | + return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @return boolean |
282 | 282 | * @throws \EE_Error |
283 | 283 | */ |
284 | - public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) { |
|
285 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, time() ); |
|
284 | + public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) { |
|
285 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, time()); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * @return boolean |
298 | 298 | * @throws \EE_Error |
299 | 299 | */ |
300 | - public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
301 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, true ); |
|
300 | + public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
301 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, true); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * @return boolean |
314 | 314 | * @throws \EE_Error |
315 | 315 | */ |
316 | - public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
317 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, false ); |
|
316 | + public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
317 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, false); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | |
@@ -330,37 +330,37 @@ discard block |
||
330 | 330 | * @return boolean |
331 | 331 | * @throws \EE_Error |
332 | 332 | */ |
333 | - private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) { |
|
333 | + private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) { |
|
334 | 334 | // validate status |
335 | - $status = is_bool( $status ) || is_int( $status ) ? $status : false; |
|
335 | + $status = is_bool($status) || is_int($status) ? $status : false; |
|
336 | 336 | // get reg steps array |
337 | 337 | $txn_reg_steps = $transaction->reg_steps(); |
338 | 338 | // if reg step does NOT exist |
339 | - if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) { |
|
339 | + if ( ! isset($txn_reg_steps[$reg_step_slug])) { |
|
340 | 340 | return false; |
341 | 341 | } |
342 | 342 | // if we're trying to complete a step that is already completed |
343 | - if ( $txn_reg_steps[ $reg_step_slug ] === true ) { |
|
343 | + if ($txn_reg_steps[$reg_step_slug] === true) { |
|
344 | 344 | return true; |
345 | 345 | } |
346 | 346 | // if we're trying to complete a step that hasn't even started |
347 | - if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) { |
|
347 | + if ($status === true && $txn_reg_steps[$reg_step_slug] === false) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | 350 | // if current status value matches the incoming value (no change) |
351 | 351 | // type casting as int means values should collapse to either 0, 1, or a timestamp like 1234567890 |
352 | - if ( (int)$txn_reg_steps[ $reg_step_slug ] === (int)$status ) { |
|
352 | + if ((int) $txn_reg_steps[$reg_step_slug] === (int) $status) { |
|
353 | 353 | // this will happen in cases where multiple AJAX requests occur during the same step |
354 | 354 | return true; |
355 | 355 | } |
356 | 356 | // if we're trying to set a start time, but it has already been set... |
357 | - if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) { |
|
357 | + if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) { |
|
358 | 358 | // skip the update below, but don't return FALSE so that errors won't be displayed |
359 | 359 | return true; |
360 | 360 | } |
361 | 361 | // update completed status |
362 | - $txn_reg_steps[ $reg_step_slug ] = $status; |
|
363 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
362 | + $txn_reg_steps[$reg_step_slug] = $status; |
|
363 | + $transaction->set_reg_steps($txn_reg_steps); |
|
364 | 364 | $transaction->save(); |
365 | 365 | // DEBUG LOG |
366 | 366 | //$this->log( |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | * @param string $reg_step_slug |
387 | 387 | * @return void |
388 | 388 | */ |
389 | - public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) { |
|
389 | + public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) { |
|
390 | 390 | // get reg steps array |
391 | 391 | $txn_reg_steps = $transaction->reg_steps(); |
392 | - unset( $txn_reg_steps[ $reg_step_slug ] ); |
|
393 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
392 | + unset($txn_reg_steps[$reg_step_slug]); |
|
393 | + $transaction->set_reg_steps($txn_reg_steps); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -405,15 +405,15 @@ discard block |
||
405 | 405 | * @return boolean |
406 | 406 | * @throws \EE_Error |
407 | 407 | */ |
408 | - public function toggle_failed_transaction_status( EE_Transaction $transaction ) { |
|
408 | + public function toggle_failed_transaction_status(EE_Transaction $transaction) { |
|
409 | 409 | $existing_txn_status = $transaction->status_ID(); |
410 | 410 | // set incoming TXN_Status |
411 | - $this->set_old_txn_status( $existing_txn_status ); |
|
411 | + $this->set_old_txn_status($existing_txn_status); |
|
412 | 412 | // if TXN status is still set as "failed"... |
413 | - if ( $existing_txn_status === EEM_Transaction::failed_status_code ) { |
|
413 | + if ($existing_txn_status === EEM_Transaction::failed_status_code) { |
|
414 | 414 | // set incoming TXN_Status |
415 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
416 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
415 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
416 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
417 | 417 | $transaction->save(); |
418 | 418 | return TRUE; |
419 | 419 | } |
@@ -430,27 +430,27 @@ discard block |
||
430 | 430 | * @param EE_Transaction $transaction |
431 | 431 | * @return boolean |
432 | 432 | */ |
433 | - public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) { |
|
433 | + public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { |
|
434 | 434 | // set incoming TXN_Status |
435 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
435 | + $this->set_old_txn_status($transaction->status_ID()); |
|
436 | 436 | // if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"... |
437 | 437 | $txn_status = $transaction->status_ID(); |
438 | 438 | if ( |
439 | 439 | $txn_status === EEM_Transaction::failed_status_code |
440 | 440 | || $txn_status === EEM_Transaction::abandoned_status_code |
441 | 441 | ) { |
442 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
442 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
443 | 443 | // if a contact record for the primary registrant has been created |
444 | 444 | if ( |
445 | 445 | $transaction->primary_registration() instanceof EE_Registration |
446 | 446 | && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
447 | 447 | ) { |
448 | - $transaction->set_status( EEM_Transaction::incomplete_status_code ); |
|
449 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
448 | + $transaction->set_status(EEM_Transaction::incomplete_status_code); |
|
449 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
450 | 450 | } else { |
451 | 451 | // no contact record? yer abandoned! |
452 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
453 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
452 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
453 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
454 | 454 | } |
455 | 455 | return TRUE; |
456 | 456 | } |
@@ -483,10 +483,10 @@ discard block |
||
483 | 483 | ); |
484 | 484 | // send messages |
485 | 485 | /** @type EE_Registration_Processor $registration_processor */ |
486 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
486 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
487 | 487 | $registration_processor->trigger_registration_update_notifications( |
488 | 488 | $transaction->primary_registration(), |
489 | - array( 'manually_updated' => true ) |
|
489 | + array('manually_updated' => true) |
|
490 | 490 | ); |
491 | 491 | do_action( |
492 | 492 | 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
@@ -573,16 +573,16 @@ discard block |
||
573 | 573 | $registration_query_params = array() |
574 | 574 | ) { |
575 | 575 | // set incoming TXN_Status, and consider it new since old status should have been set |
576 | - $this->set_new_txn_status( $transaction->status_ID() ); |
|
577 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' ); |
|
576 | + $this->set_new_txn_status($transaction->status_ID()); |
|
577 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()'); |
|
578 | 578 | // make sure some query params are set for retrieving registrations |
579 | - $this->_set_registration_query_params( $registration_query_params ); |
|
579 | + $this->_set_registration_query_params($registration_query_params); |
|
580 | 580 | // get final reg step status |
581 | - $finalized = $this->final_reg_step_completed( $transaction ); |
|
581 | + $finalized = $this->final_reg_step_completed($transaction); |
|
582 | 582 | // if the 'finalize_registration' step has been initiated (has a timestamp) |
583 | 583 | // but has not yet been fully completed (TRUE) |
584 | - if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) { |
|
585 | - $this->set_reg_step_completed( $transaction, 'finalize_registration' ); |
|
584 | + if (is_int($finalized) && $finalized !== false && $finalized !== true) { |
|
585 | + $this->set_reg_step_completed($transaction, 'finalize_registration'); |
|
586 | 586 | $finalized = true; |
587 | 587 | } |
588 | 588 | $transaction->save(); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | |
606 | 606 | // send messages |
607 | 607 | /** @type EE_Registration_Processor $registration_processor */ |
608 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
608 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
609 | 609 | $registration_processor->trigger_registration_update_notifications( |
610 | 610 | $transaction->primary_registration(), |
611 | 611 | $update_params |
@@ -641,22 +641,22 @@ discard block |
||
641 | 641 | ) { |
642 | 642 | $response = false; |
643 | 643 | /** @type EE_Registration_Processor $registration_processor */ |
644 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
644 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
645 | 645 | // check that method exists |
646 | - if ( ! method_exists( $registration_processor, $method_name )) { |
|
647 | - throw new EE_Error( __( 'Method does not exist.', 'event_espresso' )); |
|
646 | + if ( ! method_exists($registration_processor, $method_name)) { |
|
647 | + throw new EE_Error(__('Method does not exist.', 'event_espresso')); |
|
648 | 648 | } |
649 | 649 | // make sure some query params are set for retrieving registrations |
650 | - $this->_set_registration_query_params( $registration_query_params ); |
|
650 | + $this->_set_registration_query_params($registration_query_params); |
|
651 | 651 | // loop through cached registrations |
652 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
653 | - if ( $registration instanceof EE_Registration ) { |
|
654 | - if ( $additional_param ) { |
|
655 | - $response = $registration_processor->{$method_name}( $registration, $additional_param ) |
|
652 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
653 | + if ($registration instanceof EE_Registration) { |
|
654 | + if ($additional_param) { |
|
655 | + $response = $registration_processor->{$method_name}($registration, $additional_param) |
|
656 | 656 | ? true |
657 | 657 | : $response; |
658 | 658 | } else { |
659 | - $response = $registration_processor->{$method_name}( $registration ) |
|
659 | + $response = $registration_processor->{$method_name}($registration) |
|
660 | 660 | ? true |
661 | 661 | : $response; |
662 | 662 | } |
@@ -683,28 +683,28 @@ discard block |
||
683 | 683 | public function set_transaction_payment_method_based_on_registration_statuses( |
684 | 684 | EE_Registration $edited_registration |
685 | 685 | ) { |
686 | - if ( $edited_registration instanceof EE_Registration ) { |
|
686 | + if ($edited_registration instanceof EE_Registration) { |
|
687 | 687 | $transaction = $edited_registration->transaction(); |
688 | - if ( $transaction instanceof EE_Transaction ) { |
|
688 | + if ($transaction instanceof EE_Transaction) { |
|
689 | 689 | $all_not_approved = true; |
690 | - foreach ( $transaction->registrations() as $registration ) { |
|
691 | - if ( $registration instanceof EE_Registration ) { |
|
690 | + foreach ($transaction->registrations() as $registration) { |
|
691 | + if ($registration instanceof EE_Registration) { |
|
692 | 692 | // if any REG != "Not Approved" then toggle to false |
693 | 693 | $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | // if ALL Registrations are "Not Approved" |
697 | - if ( $all_not_approved ) { |
|
698 | - $transaction->set_payment_method_ID( null ); |
|
697 | + if ($all_not_approved) { |
|
698 | + $transaction->set_payment_method_ID(null); |
|
699 | 699 | $transaction->save(); |
700 | 700 | } else { |
701 | 701 | $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
702 | 702 | $transaction, |
703 | 703 | EEM_Payment_Method::scope_cart |
704 | 704 | ); |
705 | - if ( ! empty( $available_payment_methods ) ) { |
|
705 | + if ( ! empty($available_payment_methods)) { |
|
706 | 706 | $PMD_ID = 0; |
707 | - foreach ( $available_payment_methods as $available_payment_method ) { |
|
707 | + foreach ($available_payment_methods as $available_payment_method) { |
|
708 | 708 | if ( |
709 | 709 | $available_payment_method instanceof EE_Payment_Method |
710 | 710 | && $available_payment_method->open_by_default() |
@@ -713,22 +713,22 @@ discard block |
||
713 | 713 | break; |
714 | 714 | } |
715 | 715 | } |
716 | - if ( ! $PMD_ID ) { |
|
717 | - $first_payment_method = reset( $available_payment_methods ); |
|
718 | - if ( $first_payment_method instanceof EE_Payment_Method ) { |
|
716 | + if ( ! $PMD_ID) { |
|
717 | + $first_payment_method = reset($available_payment_methods); |
|
718 | + if ($first_payment_method instanceof EE_Payment_Method) { |
|
719 | 719 | $PMD_ID = $first_payment_method->ID(); |
720 | 720 | } else { |
721 | 721 | EE_Error::add_error( |
722 | - __( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ), |
|
722 | + __('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), |
|
723 | 723 | __FILE__, __LINE__, __FUNCTION__ |
724 | 724 | ); |
725 | 725 | } |
726 | 726 | } |
727 | - $transaction->set_payment_method_ID( $PMD_ID ); |
|
727 | + $transaction->set_payment_method_ID($PMD_ID); |
|
728 | 728 | $transaction->save(); |
729 | 729 | } else { |
730 | 730 | EE_Error::add_error( |
731 | - __( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ), |
|
731 | + __('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), |
|
732 | 732 | __FILE__, __LINE__, __FUNCTION__ |
733 | 733 | ); |
734 | 734 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @subpackage core/libraries/payment_methods |
16 | 16 | * @author Mike Nelson |
17 | 17 | */ |
18 | -abstract class EE_Gateway{ |
|
18 | +abstract class EE_Gateway { |
|
19 | 19 | /** |
20 | 20 | * a constant used as a possible value for $_currencies_supported to indicate |
21 | 21 | * that ALL currencies are supported by this gateway |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @return EE_Gateway |
95 | 95 | */ |
96 | - public function __construct(){ |
|
96 | + public function __construct() { |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * beginning again) |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public function __sleep(){ |
|
108 | + public function __sleep() { |
|
109 | 109 | $properties = get_object_vars($this); |
110 | - unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] ); |
|
110 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
111 | 111 | return array_keys($properties); |
112 | 112 | } |
113 | 113 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * see $_supports_sending_refunds |
116 | 116 | * @return boolean |
117 | 117 | */ |
118 | - public function supports_sending_refunds(){ |
|
118 | + public function supports_sending_refunds() { |
|
119 | 119 | return $this->_supports_sending_refunds; |
120 | 120 | } |
121 | 121 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * see $_supports_receiving_refunds |
124 | 124 | * @return boolean |
125 | 125 | */ |
126 | - public function supports_receiving_refunds(){ |
|
126 | + public function supports_receiving_refunds() { |
|
127 | 127 | return $this->_supports_receiving_refunds; |
128 | 128 | } |
129 | 129 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return EE_Payment for the refund |
139 | 139 | * @throws EE_Error |
140 | 140 | */ |
141 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
141 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
142 | 142 | return NULL; |
143 | 143 | } |
144 | 144 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * etc |
150 | 150 | * @param array $settings_array |
151 | 151 | */ |
152 | - public function set_settings($settings_array){ |
|
153 | - foreach($settings_array as $name => $value){ |
|
152 | + public function set_settings($settings_array) { |
|
153 | + foreach ($settings_array as $name => $value) { |
|
154 | 154 | $property_name = "_".$name; |
155 | 155 | $this->{$property_name} = $value; |
156 | 156 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | * See this class description |
160 | 160 | * @param EEMI_Payment $payment_model |
161 | 161 | */ |
162 | - public function set_payment_model($payment_model){ |
|
162 | + public function set_payment_model($payment_model) { |
|
163 | 163 | $this->_pay_model = $payment_model; |
164 | 164 | } |
165 | 165 | /** |
166 | 166 | * See this class description |
167 | 167 | * @param EEMI_Payment_Log $payment_log_model |
168 | 168 | */ |
169 | - public function set_payment_log($payment_log_model){ |
|
169 | + public function set_payment_log($payment_log_model) { |
|
170 | 170 | $this->_pay_log = $payment_log_model; |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * See this class description |
175 | 175 | * @param EEHI_Template $template_helper |
176 | 176 | */ |
177 | - public function set_template_helper($template_helper){ |
|
177 | + public function set_template_helper($template_helper) { |
|
178 | 178 | $this->_template = $template_helper; |
179 | 179 | } |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * See this class description |
183 | 183 | * @param EEHI_Line_Item $line_item_helper |
184 | 184 | */ |
185 | - public function set_line_item_helper( $line_item_helper ){ |
|
185 | + public function set_line_item_helper($line_item_helper) { |
|
186 | 186 | $this->_line_item = $line_item_helper; |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * See this class description |
191 | 191 | * @param EEHI_Money $money_helper |
192 | 192 | */ |
193 | - public function set_money_helper( $money_helper ){ |
|
193 | + public function set_money_helper($money_helper) { |
|
194 | 194 | $this->_money = $money_helper; |
195 | 195 | } |
196 | 196 | |
@@ -199,23 +199,23 @@ discard block |
||
199 | 199 | * @param $message |
200 | 200 | * @param $payment |
201 | 201 | */ |
202 | - public function log($message,$payment){ |
|
203 | - if($payment instanceof EEI_Payment){ |
|
204 | - $type='Payment'; |
|
202 | + public function log($message, $payment) { |
|
203 | + if ($payment instanceof EEI_Payment) { |
|
204 | + $type = 'Payment'; |
|
205 | 205 | $id = $payment->ID(); |
206 | - }else{ |
|
206 | + } else { |
|
207 | 207 | $type = 'Payment_Method'; |
208 | 208 | $id = $this->_ID; |
209 | 209 | } |
210 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
210 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
211 | 211 | } |
212 | 212 | /** |
213 | 213 | * Formats the amount so it can generally be sent to gateways |
214 | 214 | * @param float $amount |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public function format_currency($amount){ |
|
218 | - return number_format( $amount, 2, '.', '' ); |
|
217 | + public function format_currency($amount) { |
|
218 | + return number_format($amount, 2, '.', ''); |
|
219 | 219 | // return $this->_template->format_currency($amount, true); |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
225 | 225 | * @return mixed array or string |
226 | 226 | */ |
227 | - public function currencies_supported(){ |
|
227 | + public function currencies_supported() { |
|
228 | 228 | return $this->_currencies_supported; |
229 | 229 | } |
230 | 230 | |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * @param EE_Transaction $transaction |
237 | 237 | * @return float |
238 | 238 | */ |
239 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
239 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
240 | 240 | $total_line_item = $transaction->total_line_item(); |
241 | 241 | $total = 0; |
242 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
243 | - $total += max( $item_line_item->total(), 0 ); |
|
242 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
243 | + $total += max($item_line_item->total(), 0); |
|
244 | 244 | } |
245 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
246 | - $total += max( $tax_line_item->total(), 0 ); |
|
245 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
246 | + $total += max($tax_line_item->total(), 0); |
|
247 | 247 | } |
248 | 248 | return $total; |
249 | 249 | } |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | * @param EEI_Payment $payment |
255 | 255 | * @return boolean |
256 | 256 | */ |
257 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
257 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
258 | 258 | return $this->_money->compare_floats( |
259 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
259 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
260 | 260 | $payment->transaction()->total() ) && |
261 | 261 | $this->_money->compare_floats( |
262 | 262 | $payment->amount(), |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param EE_Payment $payment |
275 | 275 | * @return void |
276 | 276 | */ |
277 | - public function update_txn_based_on_payment( $payment ){ |
|
277 | + public function update_txn_based_on_payment($payment) { |
|
278 | 278 | //maybe update the transaction or line items or registrations |
279 | 279 | //but most gateways don't need to do this, because they only update the payment |
280 | 280 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance; |
20 | 20 | |
21 | 21 | |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
52 | 52 | * Saves the payment that is generated |
53 | - |
|
54 | 53 | * |
55 | 54 | *@param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | |
131 | 130 | |
132 | 131 | /** |
133 | - |
|
134 | 132 | * @param EE_Base_Class|int $transaction |
135 | 133 | * @param EE_Payment_Method $payment_method |
136 | 134 | * @throws EE_Error |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | *@return EE_Payment_Processor |
43 | 43 | */ |
44 | 44 | private function __construct() { |
45 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $update_txn = true, |
82 | 82 | $cancel_url = '' |
83 | 83 | ) { |
84 | - if( (float)$amount < 0 ) { |
|
84 | + if ((float) $amount < 0) { |
|
85 | 85 | throw new EE_Error( |
86 | 86 | sprintf( |
87 | 87 | __( |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | // verify payment method |
97 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
97 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
98 | 98 | // verify transaction |
99 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
100 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
99 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
100 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
101 | 101 | // verify payment method type |
102 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
102 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
103 | 103 | $payment = $payment_method->type_obj()->process_payment( |
104 | 104 | $transaction, |
105 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
105 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
106 | 106 | $billing_form, |
107 | 107 | $return_url, |
108 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
108 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
109 | 109 | $method, |
110 | 110 | $by_admin |
111 | 111 | ); |
112 | 112 | // check if payment method uses an off-site gateway |
113 | - if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) { |
|
113 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
114 | 114 | // don't process payments for off-site gateways yet because no payment has occurred yet |
115 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
115 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
116 | 116 | } |
117 | 117 | return $payment; |
118 | 118 | } else { |
119 | 119 | EE_Error::add_error( |
120 | 120 | sprintf( |
121 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
121 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
122 | 122 | '<br/>', |
123 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
123 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
124 | 124 | ), __FILE__, __FUNCTION__, __LINE__ |
125 | 125 | ); |
126 | 126 | return NULL; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * @throws EE_Error |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
139 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
140 | 140 | /** @type \EE_Transaction $transaction */ |
141 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
141 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
142 | 142 | $primary_reg = $transaction->primary_registration(); |
143 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
143 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
144 | 144 | throw new EE_Error( |
145 | 145 | sprintf( |
146 | 146 | __( |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | } |
154 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
154 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
155 | 155 | $url = add_query_arg( |
156 | 156 | array( |
157 | 157 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -188,92 +188,92 @@ discard block |
||
188 | 188 | $update_txn = true, |
189 | 189 | $separate_IPN_request = true |
190 | 190 | ) { |
191 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
192 | - $_req_data = $this->_remove_unusable_characters_from_array( $_req_data ); |
|
193 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
191 | + EE_Registry::instance()->load_model('Change_Log'); |
|
192 | + $_req_data = $this->_remove_unusable_characters_from_array($_req_data); |
|
193 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
194 | 194 | $obj_for_log = null; |
195 | - if( $transaction instanceof EE_Transaction ){ |
|
195 | + if ($transaction instanceof EE_Transaction) { |
|
196 | 196 | $obj_for_log = $transaction; |
197 | - if( $payment_method instanceof EE_Payment_Method ) { |
|
197 | + if ($payment_method instanceof EE_Payment_Method) { |
|
198 | 198 | $obj_for_log = EEM_Payment::instance()->get_one( |
199 | 199 | array( |
200 | - array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), |
|
201 | - 'order_by' => array( 'PAY_timestamp' => 'desc' ) |
|
200 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
201 | + 'order_by' => array('PAY_timestamp' => 'desc') |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | - } else if( $payment_method instanceof EE_Payment ) { |
|
205 | + } else if ($payment_method instanceof EE_Payment) { |
|
206 | 206 | $obj_for_log = $payment_method; |
207 | 207 | } |
208 | 208 | $log = EEM_Change_Log::instance()->log( |
209 | 209 | EEM_Change_Log::type_gateway, |
210 | - array( 'IPN data received' => $_req_data ), |
|
210 | + array('IPN data received' => $_req_data), |
|
211 | 211 | $obj_for_log |
212 | 212 | ); |
213 | - try{ |
|
213 | + try { |
|
214 | 214 | /** |
215 | 215 | * @var EE_Payment $payment |
216 | 216 | */ |
217 | 217 | $payment = NULL; |
218 | - if($transaction && $payment_method){ |
|
218 | + if ($transaction && $payment_method) { |
|
219 | 219 | /** @type EE_Transaction $transaction */ |
220 | 220 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
221 | 221 | /** @type EE_Payment_Method $payment_method */ |
222 | 222 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
223 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
224 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
223 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
224 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
225 | 225 | $log->set_object($payment); |
226 | 226 | } else { |
227 | 227 | // not a payment |
228 | 228 | EE_Error::add_error( |
229 | 229 | sprintf( |
230 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
230 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
231 | 231 | '<br/>', |
232 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
232 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
233 | 233 | ), |
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else { |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
241 | 241 | $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
242 | - foreach( $active_payment_methods as $active_payment_method ){ |
|
243 | - try{ |
|
244 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
242 | + foreach ($active_payment_methods as $active_payment_method) { |
|
243 | + try { |
|
244 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
245 | 245 | $payment_method = $active_payment_method; |
246 | 246 | EEM_Change_Log::instance()->log( |
247 | 247 | EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment |
248 | 248 | ); |
249 | 249 | break; |
250 | - } catch( EE_Error $e ) { |
|
250 | + } catch (EE_Error $e) { |
|
251 | 251 | //that's fine- it apparently couldn't handle the IPN |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | } |
256 | 256 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
257 | - if( $payment instanceof EE_Payment){ |
|
257 | + if ($payment instanceof EE_Payment) { |
|
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
261 | - }else{ |
|
260 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
261 | + } else { |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | - if($payment_method){ |
|
263 | + if ($payment_method) { |
|
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + }elseif ($transaction) { |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | |
271 | - } catch( EE_Error $e ) { |
|
271 | + } catch (EE_Error $e) { |
|
272 | 272 | do_action( |
273 | 273 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
274 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
275 | - print_r( $transaction, TRUE ), |
|
276 | - print_r( $_req_data, TRUE ), |
|
274 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
275 | + print_r($transaction, TRUE), |
|
276 | + print_r($_req_data, TRUE), |
|
277 | 277 | $e->getMessage() |
278 | 278 | ) |
279 | 279 | ); |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param array $request_data |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - protected function _remove_unusable_characters_from_array( array $request_data ) { |
|
291 | + protected function _remove_unusable_characters_from_array(array $request_data) { |
|
292 | 292 | $return_data = array(); |
293 | - foreach( $request_data as $key => $value ) { |
|
294 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
293 | + foreach ($request_data as $key => $value) { |
|
294 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
295 | 295 | } |
296 | 296 | return $return_data; |
297 | 297 | } |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $request_data |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - protected function _remove_unusable_characters( $request_data ) { |
|
307 | - return preg_replace( '/[^[:print:]]/', '', $request_data ); |
|
306 | + protected function _remove_unusable_characters($request_data) { |
|
307 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
327 | 327 | * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
328 | 328 | */ |
329 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
329 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
330 | 330 | /** @var $transaction EE_Transaction */ |
331 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
331 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
332 | 332 | $last_payment_method = $transaction->payment_method(); |
333 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
334 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
335 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
333 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
334 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
335 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
336 | 336 | return $payment; |
337 | 337 | } else { |
338 | 338 | return NULL; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | EE_Payment $payment_to_refund, |
356 | 356 | $refund_info = array() |
357 | 357 | ) { |
358 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
359 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
360 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
358 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
359 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
360 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
361 | 361 | } |
362 | 362 | return $payment_to_refund; |
363 | 363 | } |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | * TXN is locked before updating |
399 | 399 | * @throws \EE_Error |
400 | 400 | */ |
401 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
401 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
402 | 402 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
403 | 403 | /** @type EE_Transaction $transaction */ |
404 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
404 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
405 | 405 | // can we freely update the TXN at this moment? |
406 | - if ( $IPN && $transaction->is_locked() ) { |
|
406 | + if ($IPN && $transaction->is_locked()) { |
|
407 | 407 | // don't update the transaction at this exact moment |
408 | 408 | // because the TXN is active in another request |
409 | 409 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -413,45 +413,45 @@ discard block |
||
413 | 413 | ); |
414 | 414 | } else { |
415 | 415 | // verify payment and that it has been saved |
416 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
417 | - if( |
|
416 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
417 | + if ( |
|
418 | 418 | $payment->payment_method() instanceof EE_Payment_Method |
419 | 419 | && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
420 | - ){ |
|
421 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
420 | + ) { |
|
421 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
422 | 422 | // update TXN registrations with payment info |
423 | - $this->process_registration_payments( $transaction, $payment ); |
|
423 | + $this->process_registration_payments($transaction, $payment); |
|
424 | 424 | } |
425 | 425 | $do_action = $payment->just_approved() |
426 | 426 | ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
427 | 427 | : $do_action; |
428 | 428 | } else { |
429 | 429 | // send out notifications |
430 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
430 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
431 | 431 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
432 | 432 | } |
433 | 433 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
434 | 434 | // so that we know whether the status has changed and notifications should be triggered |
435 | - if ( $IPN ) { |
|
435 | + if ($IPN) { |
|
436 | 436 | /** @type EE_Transaction_Processor $transaction_processor */ |
437 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
438 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
437 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
438 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
439 | 439 | } |
440 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
440 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
441 | 441 | /** @type EE_Transaction_Payments $transaction_payments */ |
442 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
442 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
443 | 443 | // set new value for total paid |
444 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
444 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
445 | 445 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
446 | - if ( $update_txn ) { |
|
447 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
446 | + if ($update_txn) { |
|
447 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | // granular hook for others to use. |
451 | - do_action( $do_action, $transaction, $payment ); |
|
452 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
451 | + do_action($do_action, $transaction, $payment); |
|
452 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
453 | 453 | //global hook for others to use. |
454 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
454 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -471,25 +471,25 @@ discard block |
||
471 | 471 | $registrations = array() |
472 | 472 | ) { |
473 | 473 | // only process if payment was successful |
474 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
474 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
475 | 475 | return; |
476 | 476 | } |
477 | 477 | //EEM_Registration::instance()->show_next_x_db_queries(); |
478 | - if ( empty( $registrations )) { |
|
478 | + if (empty($registrations)) { |
|
479 | 479 | // find registrations with monies owing that can receive a payment |
480 | 480 | $registrations = $transaction->registrations( |
481 | 481 | array( |
482 | 482 | array( |
483 | 483 | // only these reg statuses can receive payments |
484 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
485 | - 'REG_final_price' => array( '!=', 0 ), |
|
486 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
484 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
485 | + 'REG_final_price' => array('!=', 0), |
|
486 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
487 | 487 | ) |
488 | 488 | ) |
489 | 489 | ); |
490 | 490 | } |
491 | 491 | // still nothing ??!?? |
492 | - if ( empty( $registrations )) { |
|
492 | + if (empty($registrations)) { |
|
493 | 493 | return; |
494 | 494 | } |
495 | 495 | // todo: break out the following logic into a separate strategy class |
@@ -501,28 +501,28 @@ discard block |
||
501 | 501 | |
502 | 502 | $refund = $payment->is_a_refund(); |
503 | 503 | // how much is available to apply to registrations? |
504 | - $available_payment_amount = abs( $payment->amount() ); |
|
505 | - foreach ( $registrations as $registration ) { |
|
506 | - if ( $registration instanceof EE_Registration ) { |
|
504 | + $available_payment_amount = abs($payment->amount()); |
|
505 | + foreach ($registrations as $registration) { |
|
506 | + if ($registration instanceof EE_Registration) { |
|
507 | 507 | // nothing left? |
508 | - if ( $available_payment_amount <= 0 ) { |
|
508 | + if ($available_payment_amount <= 0) { |
|
509 | 509 | break; |
510 | 510 | } |
511 | - if ( $refund ) { |
|
512 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
511 | + if ($refund) { |
|
512 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
513 | 513 | } else { |
514 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
514 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | } |
518 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
518 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
519 | 519 | EE_Error::add_attention( |
520 | 520 | sprintf( |
521 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
522 | - EEH_Template::format_currency( $available_payment_amount ), |
|
523 | - implode( ', ', array_keys( $registrations ) ), |
|
521 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
522 | + EEH_Template::format_currency($available_payment_amount), |
|
523 | + implode(', ', array_keys($registrations)), |
|
524 | 524 | '<br/>', |
525 | - EEH_Template::format_currency( $payment->amount() ) |
|
525 | + EEH_Template::format_currency($payment->amount()) |
|
526 | 526 | ), |
527 | 527 | __FILE__, __FUNCTION__, __LINE__ |
528 | 528 | ); |
@@ -540,17 +540,17 @@ discard block |
||
540 | 540 | * @return float |
541 | 541 | * @throws \EE_Error |
542 | 542 | */ |
543 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
543 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
544 | 544 | $owing = $registration->final_price() - $registration->paid(); |
545 | - if ( $owing > 0 ) { |
|
545 | + if ($owing > 0) { |
|
546 | 546 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
547 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
547 | + $payment_amount = min($available_payment_amount, $owing); |
|
548 | 548 | // update $available_payment_amount |
549 | 549 | $available_payment_amount -= $payment_amount; |
550 | 550 | //calculate and set new REG_paid |
551 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
551 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
552 | 552 | // now save it |
553 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
553 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
554 | 554 | } |
555 | 555 | return $available_payment_amount; |
556 | 556 | } |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | * @return float |
567 | 567 | * @throws \EE_Error |
568 | 568 | */ |
569 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
569 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
570 | 570 | // find any existing reg payment records for this registration and payment |
571 | 571 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
572 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
572 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
573 | 573 | ); |
574 | 574 | // if existing registration payment exists |
575 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
575 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
576 | 576 | // then update that record |
577 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
577 | + $existing_reg_payment->set_amount($payment_amount); |
|
578 | 578 | $existing_reg_payment->save(); |
579 | 579 | } else { |
580 | 580 | // or add new relation between registration and payment and set amount |
581 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
581 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
582 | 582 | // make it stick |
583 | 583 | $registration->save(); |
584 | 584 | } |
@@ -595,21 +595,21 @@ discard block |
||
595 | 595 | * @return float |
596 | 596 | * @throws \EE_Error |
597 | 597 | */ |
598 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
598 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
599 | 599 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
600 | - if ( $registration->paid() > 0 ) { |
|
600 | + if ($registration->paid() > 0) { |
|
601 | 601 | // ensure $available_refund_amount is NOT negative |
602 | - $available_refund_amount = (float)abs( $available_refund_amount ); |
|
602 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
603 | 603 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
604 | - $refund_amount = min( $available_refund_amount, (float)$registration->paid() ); |
|
604 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
605 | 605 | // update $available_payment_amount |
606 | 606 | $available_refund_amount -= $refund_amount; |
607 | 607 | //calculate and set new REG_paid |
608 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
608 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
609 | 609 | // convert payment amount back to a negative value for storage in the db |
610 | - $refund_amount = (float)abs( $refund_amount ) * -1; |
|
610 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
611 | 611 | // now save it |
612 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
612 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
613 | 613 | } |
614 | 614 | return $available_refund_amount; |
615 | 615 | } |
@@ -628,21 +628,21 @@ discard block |
||
628 | 628 | * @param bool $IPN |
629 | 629 | * @throws \EE_Error |
630 | 630 | */ |
631 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
631 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
632 | 632 | |
633 | 633 | /** @type EE_Transaction_Processor $transaction_processor */ |
634 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
634 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
635 | 635 | // is the Payment Options Reg Step completed ? |
636 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
636 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
637 | 637 | // if the Payment Options Reg Step is completed... |
638 | 638 | $revisit = $payment_options_step_completed === true ? true : false; |
639 | 639 | // then this is kinda sorta a revisit with regards to payments at least |
640 | - $transaction_processor->set_revisit( $revisit ); |
|
640 | + $transaction_processor->set_revisit($revisit); |
|
641 | 641 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
642 | 642 | if ( |
643 | 643 | $IPN && |
644 | 644 | $payment_options_step_completed !== true && |
645 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
645 | + ($payment->is_approved() || $payment->is_pending()) |
|
646 | 646 | ) { |
647 | 647 | $payment_options_step_completed = $transaction_processor->set_reg_step_completed( |
648 | 648 | $transaction, |
@@ -650,34 +650,34 @@ discard block |
||
650 | 650 | ); |
651 | 651 | } |
652 | 652 | /** @type EE_Transaction_Payments $transaction_payments */ |
653 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
653 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
654 | 654 | // maybe update status, but don't save transaction just yet |
655 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
655 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
656 | 656 | // check if 'finalize_registration' step has been completed... |
657 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
657 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
658 | 658 | // if this is an IPN and the final step has not been initiated |
659 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
659 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
660 | 660 | // and if it hasn't already been set as being started... |
661 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
661 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
662 | 662 | } |
663 | 663 | $transaction->save(); |
664 | 664 | // because the above will return false if the final step was not fully completed, we need to check again... |
665 | - if ( $IPN && $finalized !== false ) { |
|
665 | + if ($IPN && $finalized !== false) { |
|
666 | 666 | // and if we are all good to go, then send out notifications |
667 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
667 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
668 | 668 | //ok, now process the transaction according to the payment |
669 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
669 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
670 | 670 | } |
671 | 671 | // DEBUG LOG |
672 | 672 | $payment_method = $payment->payment_method(); |
673 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
673 | + if ($payment_method instanceof EE_Payment_Method) { |
|
674 | 674 | $payment_method_type_obj = $payment_method->type_obj(); |
675 | - if ( $payment_method_type_obj instanceof EE_PMT_Base ) { |
|
675 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
676 | 676 | $gateway = $payment_method_type_obj->get_gateway(); |
677 | - if ( $gateway instanceof EE_Gateway ){ |
|
677 | + if ($gateway instanceof EE_Gateway) { |
|
678 | 678 | $gateway->log( |
679 | 679 | array( |
680 | - 'message' => __( 'Post Payment Transaction Details', 'event_espresso' ), |
|
680 | + 'message' => __('Post Payment Transaction Details', 'event_espresso'), |
|
681 | 681 | 'transaction' => $transaction->model_field_array(), |
682 | 682 | 'finalized' => $finalized, |
683 | 683 | 'IPN' => $IPN, |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else{ |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | 260 | $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | 263 | if($payment_method){ |
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + } elseif($transaction){ |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
50 | - * date format |
|
51 | - * |
|
52 | - * pattern or format for displaying dates |
|
53 | - * |
|
54 | - * @access protected |
|
55 | - * @var string |
|
56 | - */ |
|
50 | + * date format |
|
51 | + * |
|
52 | + * pattern or format for displaying dates |
|
53 | + * |
|
54 | + * @access protected |
|
55 | + * @var string |
|
56 | + */ |
|
57 | 57 | protected $_dt_frmt; |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * time format |
|
63 | - * |
|
64 | - * pattern or format for displaying time |
|
65 | - * |
|
66 | - * @access protected |
|
67 | - * @var string |
|
68 | - */ |
|
61 | + /** |
|
62 | + * time format |
|
63 | + * |
|
64 | + * pattern or format for displaying time |
|
65 | + * |
|
66 | + * @access protected |
|
67 | + * @var string |
|
68 | + */ |
|
69 | 69 | protected $_tm_frmt; |
70 | 70 | |
71 | 71 | |
@@ -1420,24 +1420,24 @@ discard block |
||
1420 | 1420 | * |
1421 | 1421 | * @throws \EE_Error |
1422 | 1422 | */ |
1423 | - public function refresh_cache_of_related_objects() { |
|
1424 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1425 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1426 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1427 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1428 | - //this relation only stores a single model object, not an array |
|
1429 | - //but let's make it consistent |
|
1430 | - $related_objects = array( $related_objects ); |
|
1431 | - } |
|
1432 | - foreach( $related_objects as $related_object ) { |
|
1433 | - //only refresh their cache if they're in memory |
|
1434 | - if( $related_object instanceof EE_Base_Class ) { |
|
1423 | + public function refresh_cache_of_related_objects() { |
|
1424 | + foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1425 | + if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1426 | + $related_objects = $this->_model_relations[ $relation_name ]; |
|
1427 | + if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1428 | + //this relation only stores a single model object, not an array |
|
1429 | + //but let's make it consistent |
|
1430 | + $related_objects = array( $related_objects ); |
|
1431 | + } |
|
1432 | + foreach( $related_objects as $related_object ) { |
|
1433 | + //only refresh their cache if they're in memory |
|
1434 | + if( $related_object instanceof EE_Base_Class ) { |
|
1435 | 1435 | $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
1436 | - } |
|
1437 | - } |
|
1438 | - } |
|
1439 | - } |
|
1440 | - } |
|
1436 | + } |
|
1437 | + } |
|
1438 | + } |
|
1439 | + } |
|
1440 | + } |
|
1441 | 1441 | |
1442 | 1442 | |
1443 | 1443 | |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | if ( self::_get_model( $classname )->has_primary_key_field() ) { |
1679 | 1679 | $primary_id_ref = self::_get_primary_key_name( $classname ); |
1680 | 1680 | if ( array_key_exists( $primary_id_ref, $props_n_values ) |
1681 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1681 | + && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1682 | 1682 | ) { |
1683 | 1683 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
1684 | 1684 | $props_n_values[ $primary_id_ref ] |
@@ -1830,9 +1830,9 @@ discard block |
||
1830 | 1830 | $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
1831 | 1831 | //clear cache so future get_many_related and get_first_related() return new results. |
1832 | 1832 | $this->clear_cache( $relationName, $otherObject, TRUE ); |
1833 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1834 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1835 | - } |
|
1833 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1834 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1835 | + } |
|
1836 | 1836 | } else { |
1837 | 1837 | //this thing doesn't exist in the DB, so just cache it |
1838 | 1838 | if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
@@ -1846,18 +1846,18 @@ discard block |
||
1846 | 1846 | } |
1847 | 1847 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
1848 | 1848 | } |
1849 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1850 | - //fix the reciprocal relation too |
|
1851 | - if( $otherObject->ID() ) { |
|
1852 | - //its saved so assumed relations exist in the DB, so we can just |
|
1853 | - //clear the cache so future queries use the updated info in the DB |
|
1854 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1855 | - } else { |
|
1856 | - |
|
1857 | - //it's not saved, so it caches relations like this |
|
1858 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1859 | - } |
|
1860 | - } |
|
1849 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1850 | + //fix the reciprocal relation too |
|
1851 | + if( $otherObject->ID() ) { |
|
1852 | + //its saved so assumed relations exist in the DB, so we can just |
|
1853 | + //clear the cache so future queries use the updated info in the DB |
|
1854 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1855 | + } else { |
|
1856 | + |
|
1857 | + //it's not saved, so it caches relations like this |
|
1858 | + $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1859 | + } |
|
1860 | + } |
|
1861 | 1861 | return $otherObject; |
1862 | 1862 | } |
1863 | 1863 | |
@@ -1888,9 +1888,9 @@ discard block |
||
1888 | 1888 | //this doesn't exist in the DB, just remove it from the cache |
1889 | 1889 | $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
1890 | 1890 | } |
1891 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1892 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | - } |
|
1891 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1892 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | + } |
|
1894 | 1894 | return $otherObject; |
1895 | 1895 | } |
1896 | 1896 | |
@@ -1913,11 +1913,11 @@ discard block |
||
1913 | 1913 | //this doesn't exist in the DB, just remove it from the cache |
1914 | 1914 | $otherObjects = $this->clear_cache( $relationName, null, true ); |
1915 | 1915 | } |
1916 | - if( is_array( $otherObjects ) ) { |
|
1917 | - foreach ( $otherObjects as $otherObject ) { |
|
1918 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1919 | - } |
|
1920 | - } |
|
1916 | + if( is_array( $otherObjects ) ) { |
|
1917 | + foreach ( $otherObjects as $otherObject ) { |
|
1918 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1919 | + } |
|
1920 | + } |
|
1921 | 1921 | return $otherObjects; |
1922 | 1922 | } |
1923 | 1923 |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
171 | 171 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
172 | 172 | $this->_model_relations[$relation_name] = NULL; |
173 | - }else{ |
|
173 | + } else{ |
|
174 | 174 | $this->_model_relations[$relation_name] = array(); |
175 | 175 | } |
176 | 176 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
217 | 217 | $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
218 | 218 | return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
219 | - }else{ |
|
219 | + } else{ |
|
220 | 220 | return NULL; |
221 | 221 | } |
222 | 222 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | : $this->set( $field_name, $this->_fields[$field_name] ); |
274 | 274 | } |
275 | 275 | |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $this->_fields[$field_name] = $holder_of_value; |
278 | 278 | } |
279 | 279 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | //let's unset any cache for this field_name from the $_cached_properties property. |
306 | 306 | $this->_clear_cached_property( $field_name ); |
307 | - }else{ |
|
307 | + } else{ |
|
308 | 308 | throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
309 | 309 | } |
310 | 310 | |
@@ -653,10 +653,10 @@ discard block |
||
653 | 653 | if($clear_all){ |
654 | 654 | $obj_removed = true; |
655 | 655 | $this->_model_relations[$relationName] = null; |
656 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
656 | + } elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
657 | 657 | $obj_removed = $this->_model_relations[$relationName]; |
658 | 658 | $this->_model_relations[$relationName] = null; |
659 | - }else{ |
|
659 | + } else{ |
|
660 | 660 | if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
661 | 661 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
662 | 662 | if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
@@ -676,20 +676,20 @@ discard block |
||
676 | 676 | } |
677 | 677 | if($index_found_at){ |
678 | 678 | $index_in_cache = $index_found_at; |
679 | - }else{ |
|
679 | + } else{ |
|
680 | 680 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
681 | 681 | //if it wasn't in it to begin with. So we're done |
682 | 682 | return $object_to_remove_or_index_into_array; |
683 | 683 | } |
684 | 684 | } |
685 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
685 | + } elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
686 | 686 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
687 | 687 | foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
688 | 688 | if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
689 | 689 | $index_in_cache = $index; |
690 | 690 | } |
691 | 691 | } |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $index_in_cache = $object_to_remove_or_index_into_array; |
694 | 694 | } |
695 | 695 | //supposedly we've found it. But it could just be that the client code |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
760 | 760 | if(is_array($cached_array_or_object)){ |
761 | 761 | return array_shift($cached_array_or_object); |
762 | - }else{ |
|
762 | + } else{ |
|
763 | 763 | return $cached_array_or_object; |
764 | 764 | } |
765 | 765 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | if( $model_object->ID() ){ |
791 | 791 | $model->add_to_entity_map( $model_object ); |
792 | 792 | } |
793 | - }else{ |
|
793 | + } else{ |
|
794 | 794 | throw new EE_Error( |
795 | 795 | sprintf( |
796 | 796 | __( |
@@ -925,10 +925,10 @@ discard block |
||
925 | 925 | if( $field_obj->is_nullable()){ |
926 | 926 | //if the field allows nulls, then let it be null |
927 | 927 | $field_value = NULL; |
928 | - }else{ |
|
928 | + } else{ |
|
929 | 929 | $field_value = $field_obj->get_default_value(); |
930 | 930 | } |
931 | - }else{ |
|
931 | + } else{ |
|
932 | 932 | $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
933 | 933 | } |
934 | 934 | $this->_fields[$field_name] = $field_value; |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | $this->_update_cached_related_model_objs_fks(); |
1514 | 1514 | } |
1515 | 1515 | } |
1516 | - }else{//PK is NOT auto-increment |
|
1516 | + } else{//PK is NOT auto-increment |
|
1517 | 1517 | //so check if one like it already exists in the db |
1518 | 1518 | if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
1519 | 1519 | if( WP_DEBUG && ! $this->in_entity_map() ){ |
@@ -1528,12 +1528,12 @@ discard block |
||
1528 | 1528 | ); |
1529 | 1529 | } |
1530 | 1530 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1531 | - }else{ |
|
1531 | + } else{ |
|
1532 | 1532 | $results = $this->get_model()->insert($save_cols_n_values); |
1533 | 1533 | $this->_update_cached_related_model_objs_fks(); |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | - }else{//there is NO primary key |
|
1536 | + } else{//there is NO primary key |
|
1537 | 1537 | $already_in_db = false; |
1538 | 1538 | foreach($this->get_model()->unique_indexes() as $index){ |
1539 | 1539 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | if( $already_in_db ){ |
1545 | 1545 | $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
1546 | 1546 | $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
1547 | - }else{ |
|
1547 | + } else{ |
|
1548 | 1548 | $results = $this->get_model()->insert( $save_cols_n_values ); |
1549 | 1549 | } |
1550 | 1550 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | //make sure this has been saved |
1607 | 1607 | if( ! $this->ID()){ |
1608 | 1608 | $id = $this->save(); |
1609 | - }else{ |
|
1609 | + } else{ |
|
1610 | 1610 | $id = $this->ID(); |
1611 | 1611 | } |
1612 | 1612 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
@@ -1625,7 +1625,7 @@ discard block |
||
1625 | 1625 | $this->_add_relation_to($related_model_obj, $relationName); |
1626 | 1626 | $related_model_obj->save_new_cached_related_model_objs(); |
1627 | 1627 | // } |
1628 | - }else{ |
|
1628 | + } else{ |
|
1629 | 1629 | foreach($this->_model_relations[$relationName] as $related_model_obj){ |
1630 | 1630 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1631 | 1631 | //but ONLY if it DOES NOT exist in the DB |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | private static function _get_model_classname( $model_name = null){ |
1775 | 1775 | if(strpos($model_name,"EE_")===0){ |
1776 | 1776 | $model_classname=str_replace("EE_","EEM_",$model_name); |
1777 | - }else{ |
|
1777 | + } else{ |
|
1778 | 1778 | $model_classname = "EEM_".$model_name; |
1779 | 1779 | } |
1780 | 1780 | return $model_classname; |
@@ -1815,7 +1815,7 @@ discard block |
||
1815 | 1815 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1816 | 1816 | if( $this->get_model()->has_primary_key_field() ) { |
1817 | 1817 | return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
1818 | - }else{ |
|
1818 | + } else{ |
|
1819 | 1819 | return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
1820 | 1820 | } |
1821 | 1821 | } |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | //if there are query parameters, forget about caching the related model objects. |
1952 | 1952 | if( $query_params ){ |
1953 | 1953 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1954 | - }else{ |
|
1954 | + } else{ |
|
1955 | 1955 | //did we already cache the result of this query? |
1956 | 1956 | $cached_results = $this->get_all_from_cache($relationName); |
1957 | 1957 | if ( ! $cached_results ){ |
@@ -1961,11 +1961,11 @@ discard block |
||
1961 | 1961 | foreach($related_model_objects as $related_model_object){ |
1962 | 1962 | $this->cache($relationName, $related_model_object); |
1963 | 1963 | } |
1964 | - }else{ |
|
1964 | + } else{ |
|
1965 | 1965 | $related_model_objects = $cached_results; |
1966 | 1966 | } |
1967 | 1967 | } |
1968 | - }else{ |
|
1968 | + } else{ |
|
1969 | 1969 | //this doesn't exist in the DB, so just get the related things from the cache |
1970 | 1970 | $related_model_objects = $this->get_all_from_cache($relationName); |
1971 | 1971 | } |
@@ -2020,18 +2020,18 @@ discard block |
||
2020 | 2020 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2021 | 2021 | if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
2022 | 2022 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2023 | - }else{ |
|
2023 | + } else{ |
|
2024 | 2024 | //first, check if we've already cached the result of this query |
2025 | 2025 | $cached_result = $this->get_one_from_cache($relationName); |
2026 | 2026 | if ( ! $cached_result ){ |
2027 | 2027 | |
2028 | 2028 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2029 | 2029 | $this->cache($relationName,$related_model_object); |
2030 | - }else{ |
|
2030 | + } else{ |
|
2031 | 2031 | $related_model_object = $cached_result; |
2032 | 2032 | } |
2033 | 2033 | } |
2034 | - }else{ |
|
2034 | + } else{ |
|
2035 | 2035 | $related_model_object = null; |
2036 | 2036 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2037 | 2037 | if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
@@ -2063,7 +2063,7 @@ discard block |
||
2063 | 2063 | public function delete_related($relationName,$query_params = array()){ |
2064 | 2064 | if($this->ID()){ |
2065 | 2065 | $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
2066 | - }else{ |
|
2066 | + } else{ |
|
2067 | 2067 | $count = count($this->get_all_from_cache($relationName)); |
2068 | 2068 | $this->clear_cache($relationName,NULL,TRUE); |
2069 | 2069 | } |
@@ -2087,7 +2087,7 @@ discard block |
||
2087 | 2087 | public function delete_related_permanently($relationName,$query_params = array()){ |
2088 | 2088 | if($this->ID()){ |
2089 | 2089 | $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
2090 | - }else{ |
|
2090 | + } else{ |
|
2091 | 2091 | $count = count($this->get_all_from_cache($relationName)); |
2092 | 2092 | } |
2093 | 2093 | $this->clear_cache($relationName,NULL,TRUE); |
@@ -2317,10 +2317,10 @@ discard block |
||
2317 | 2317 | $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2318 | 2318 | if ( $result instanceof EE_Extra_Meta ){ |
2319 | 2319 | return $result->value(); |
2320 | - }else{ |
|
2320 | + } else{ |
|
2321 | 2321 | return $default; |
2322 | 2322 | } |
2323 | - }else{ |
|
2323 | + } else{ |
|
2324 | 2324 | $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2325 | 2325 | if($results){ |
2326 | 2326 | $values = array(); |
@@ -2330,7 +2330,7 @@ discard block |
||
2330 | 2330 | } |
2331 | 2331 | } |
2332 | 2332 | return $values; |
2333 | - }else{ |
|
2333 | + } else{ |
|
2334 | 2334 | return $default; |
2335 | 2335 | } |
2336 | 2336 | } |
@@ -2361,7 +2361,7 @@ discard block |
||
2361 | 2361 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2362 | 2362 | } |
2363 | 2363 | } |
2364 | - }else{ |
|
2364 | + } else{ |
|
2365 | 2365 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2366 | 2366 | foreach($extra_meta_objs as $extra_meta_obj){ |
2367 | 2367 | if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
@@ -2388,7 +2388,7 @@ discard block |
||
2388 | 2388 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2389 | 2389 | if($field_we_can_use){ |
2390 | 2390 | return $this->get($field_we_can_use->get_name()); |
2391 | - }else{ |
|
2391 | + } else{ |
|
2392 | 2392 | $first_few_properties = $this->model_field_array(); |
2393 | 2393 | $first_few_properties = array_slice($first_few_properties,0,3); |
2394 | 2394 | $name_parts = array(); |
@@ -2412,7 +2412,7 @@ discard block |
||
2412 | 2412 | if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
2413 | 2413 | //well, if we looked, did we find it in the entity map? |
2414 | 2414 | return TRUE; |
2415 | - }else{ |
|
2415 | + } else{ |
|
2416 | 2416 | return FALSE; |
2417 | 2417 | } |
2418 | 2418 | } |
@@ -2426,7 +2426,7 @@ discard block |
||
2426 | 2426 | public function refresh_from_db(){ |
2427 | 2427 | if( $this->ID() && $this->in_entity_map() ){ |
2428 | 2428 | $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
2429 | - }else{ |
|
2429 | + } else{ |
|
2430 | 2430 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2431 | 2431 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2432 | 2432 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * ------------------------------------------------------------------------ |
25 | 25 | */ |
26 | 26 | |
27 | -abstract class EE_Base_Class{ |
|
27 | +abstract class EE_Base_Class { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * This is an array of the original properties and values provided during construction |
@@ -117,59 +117,59 @@ discard block |
||
117 | 117 | * @throws EE_Error |
118 | 118 | * @return \EE_Base_Class |
119 | 119 | */ |
120 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){ |
|
120 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) { |
|
121 | 121 | |
122 | - $className=get_class($this); |
|
122 | + $className = get_class($this); |
|
123 | 123 | |
124 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
125 | - $model=$this->get_model(); |
|
126 | - $model_fields = $model->field_settings( FALSE ); |
|
124 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
125 | + $model = $this->get_model(); |
|
126 | + $model_fields = $model->field_settings(FALSE); |
|
127 | 127 | // ensure $fieldValues is an array |
128 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
128 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
129 | 129 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
130 | 130 | // verify client code has not passed any invalid field names |
131 | - foreach($fieldValues as $field_name=> $field_value){ |
|
132 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
133 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
131 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
132 | + if ( ! isset($model_fields[$field_name])) { |
|
133 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
137 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
137 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
138 | 138 | |
139 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
139 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
140 | 140 | $this->_dt_frmt = $date_formats[0]; |
141 | 141 | $this->_tm_frmt = $date_formats[1]; |
142 | 142 | } else { |
143 | 143 | //set default formats for date and time |
144 | - $this->_dt_frmt = get_option( 'date_format' ); |
|
145 | - $this->_tm_frmt = get_option( 'time_format' ); |
|
144 | + $this->_dt_frmt = get_option('date_format'); |
|
145 | + $this->_tm_frmt = get_option('time_format'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | //if db model is instantiating |
149 | - if ( $bydb ){ |
|
149 | + if ($bydb) { |
|
150 | 150 | //client code has indicated these field values are from the database |
151 | - foreach( $model_fields as $fieldName => $field ){ |
|
152 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
151 | + foreach ($model_fields as $fieldName => $field) { |
|
152 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | 155 | //we're constructing a brand |
156 | 156 | //new instance of the model object. Generally, this means we'll need to do more field validation |
157 | - foreach( $model_fields as $fieldName => $field ){ |
|
158 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
157 | + foreach ($model_fields as $fieldName => $field) { |
|
158 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | 162 | //remember what values were passed to this constructor |
163 | 163 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
164 | 164 | //remember in entity mapper |
165 | - if( ! $bydb && $model->has_primary_key_field() && $this->ID() ){ |
|
165 | + if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) { |
|
166 | 166 | $model->add_to_entity_map($this); |
167 | 167 | } |
168 | 168 | //setup all the relations |
169 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
170 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
169 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
170 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
171 | 171 | $this->_model_relations[$relation_name] = NULL; |
172 | - }else{ |
|
172 | + } else { |
|
173 | 173 | $this->_model_relations[$relation_name] = array(); |
174 | 174 | } |
175 | 175 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * Action done at the end of each model object construction |
178 | 178 | * @param EE_Base_Class $this the model object just created |
179 | 179 | */ |
180 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
180 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param boolean $allow_persist |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - public function set_allow_persist( $allow_persist ) { |
|
200 | + public function set_allow_persist($allow_persist) { |
|
201 | 201 | return $this->_allow_persist = $allow_persist; |
202 | 202 | } |
203 | 203 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * @return mixed|null |
212 | 212 | * @throws \EE_Error |
213 | 213 | */ |
214 | - public function get_original( $field_name ){ |
|
215 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
216 | - $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
|
217 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
218 | - }else{ |
|
214 | + public function get_original($field_name) { |
|
215 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
216 | + $field_settings = $this->get_model()->field_settings_for($field_name)) { |
|
217 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
218 | + } else { |
|
219 | 219 | return NULL; |
220 | 220 | } |
221 | 221 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param EE_Base_Class $obj |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public function get_class($obj){ |
|
228 | + public function get_class($obj) { |
|
229 | 229 | return get_class($obj); |
230 | 230 | } |
231 | 231 | |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | * @param bool $use_default |
241 | 241 | * @throws \EE_Error |
242 | 242 | */ |
243 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
244 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
245 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
243 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
244 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
245 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
246 | 246 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
247 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
248 | - $field_obj->set_timezone( $this->_timezone ); |
|
249 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
250 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
247 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
248 | + $field_obj->set_timezone($this->_timezone); |
|
249 | + $field_obj->set_date_format($this->_dt_frmt); |
|
250 | + $field_obj->set_time_format($this->_tm_frmt); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
254 | 254 | //should the value be null? |
255 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
255 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
256 | 256 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
257 | 257 | |
258 | 258 | /** |
@@ -264,26 +264,26 @@ discard block |
||
264 | 264 | */ |
265 | 265 | if ( |
266 | 266 | $field_obj instanceof EE_Datetime_Field |
267 | - && $this->_fields[ $field_name ] !== null |
|
267 | + && $this->_fields[$field_name] !== null |
|
268 | 268 | && ! $this->_fields[$field_name] instanceof DateTime |
269 | 269 | ) { |
270 | - empty( $this->_fields[$field_name] ) |
|
271 | - ? $this->set( $field_name, time() ) |
|
272 | - : $this->set( $field_name, $this->_fields[$field_name] ); |
|
270 | + empty($this->_fields[$field_name]) |
|
271 | + ? $this->set($field_name, time()) |
|
272 | + : $this->set($field_name, $this->_fields[$field_name]); |
|
273 | 273 | } |
274 | 274 | |
275 | - }else{ |
|
275 | + } else { |
|
276 | 276 | $this->_fields[$field_name] = $holder_of_value; |
277 | 277 | } |
278 | 278 | |
279 | 279 | //if we're not in the constructor... |
280 | 280 | //now check if what we set was a primary key |
281 | - if( |
|
281 | + if ( |
|
282 | 282 | //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
283 | 283 | $this->_props_n_values_provided_in_constructor |
284 | 284 | && $field_value |
285 | - && $field_name === self::_get_primary_key_name( get_class( $this ) ) |
|
286 | - ){ |
|
285 | + && $field_name === self::_get_primary_key_name(get_class($this)) |
|
286 | + ) { |
|
287 | 287 | //if so, we want all this object's fields to be filled either with |
288 | 288 | //what we've explicitly set on this model |
289 | 289 | //or what we have in the db |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | $fields_on_model = self::_get_model(get_class($this))->field_settings(); |
292 | 292 | |
293 | 293 | $obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value); |
294 | - foreach($fields_on_model as $field_obj){ |
|
295 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
296 | - && $field_obj->get_name() !== $field_name ){ |
|
294 | + foreach ($fields_on_model as $field_obj) { |
|
295 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
296 | + && $field_obj->get_name() !== $field_name) { |
|
297 | 297 | |
298 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
298 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | //oh this model object has an ID? well make sure its in the entity mapper |
302 | 302 | $this->get_model()->add_to_entity_map($this); |
303 | 303 | } |
304 | 304 | //let's unset any cache for this field_name from the $_cached_properties property. |
305 | - $this->_clear_cached_property( $field_name ); |
|
306 | - }else{ |
|
307 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
305 | + $this->_clear_cached_property($field_name); |
|
306 | + } else { |
|
307 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | } |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
325 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
326 | - $this->set( $field_name, $field_value ); |
|
324 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
325 | + if ($this->get_model()->has_field($field_name)) { |
|
326 | + $this->set($field_name, $field_value); |
|
327 | 327 | return true; |
328 | 328 | } else { |
329 | 329 | //ensure this object is saved first so that extra meta can be properly related. |
330 | 330 | $this->save(); |
331 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
331 | + return $this->update_extra_meta($field_name, $field_value); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | * @return mixed|null value for the field if found. null if not found. |
350 | 350 | * @throws \EE_Error |
351 | 351 | */ |
352 | - public function get_field_or_extra_meta( $field_name ) { |
|
353 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
354 | - $column_value = $this->get( $field_name ); |
|
352 | + public function get_field_or_extra_meta($field_name) { |
|
353 | + if ($this->get_model()->has_field($field_name)) { |
|
354 | + $column_value = $this->get($field_name); |
|
355 | 355 | } else { |
356 | 356 | //This isn't a column in the main table, let's see if it is in the extra meta. |
357 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
357 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
358 | 358 | } |
359 | 359 | return $column_value; |
360 | 360 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * @return void |
371 | 371 | * @throws \EE_Error |
372 | 372 | */ |
373 | - public function set_timezone( $timezone = '' ) { |
|
374 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
373 | + public function set_timezone($timezone = '') { |
|
374 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
375 | 375 | //make sure we clear all cached properties because they won't be relevant now |
376 | 376 | $this->_clear_cached_properties(); |
377 | 377 | |
378 | 378 | //make sure we update field settings and the date for all EE_Datetime_Fields |
379 | - $model_fields = $this->get_model()->field_settings( false ); |
|
380 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
381 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
382 | - $field_obj->set_timezone( $this->_timezone ); |
|
383 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
384 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
379 | + $model_fields = $this->get_model()->field_settings(false); |
|
380 | + foreach ($model_fields as $field_name => $field_obj) { |
|
381 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
382 | + $field_obj->set_timezone($this->_timezone); |
|
383 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
384 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @param string $format should be a format recognizable by PHP date() functions. |
412 | 412 | */ |
413 | - public function set_date_format( $format ) { |
|
413 | + public function set_date_format($format) { |
|
414 | 414 | $this->_dt_frmt = $format; |
415 | 415 | //clear cached_properties because they won't be relevant now. |
416 | 416 | $this->_clear_cached_properties(); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @since 4.6 |
427 | 427 | * @param string $format should be a format recognizable by PHP date() functions. |
428 | 428 | */ |
429 | - public function set_time_format( $format ) { |
|
429 | + public function set_time_format($format) { |
|
430 | 430 | $this->_tm_frmt = $format; |
431 | 431 | //clear cached_properties because they won't be relevant now. |
432 | 432 | $this->_clear_cached_properties(); |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return mixed string|array |
445 | 445 | */ |
446 | - public function get_format( $full = true ) { |
|
447 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
446 | + public function get_format($full = true) { |
|
447 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -462,17 +462,17 @@ discard block |
||
462 | 462 | * @throws EE_Error |
463 | 463 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
464 | 464 | */ |
465 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
465 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
466 | 466 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
467 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
467 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
468 | 468 | return FALSE; |
469 | 469 | } |
470 | 470 | // also get "how" the object is related, or throw an error |
471 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
472 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
471 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
472 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
473 | 473 | } |
474 | 474 | // how many things are related ? |
475 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
475 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
476 | 476 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
477 | 477 | // so for these model objects just set it to be cached |
478 | 478 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -480,26 +480,26 @@ discard block |
||
480 | 480 | } else { |
481 | 481 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
482 | 482 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
483 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
483 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
484 | 484 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
485 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
485 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
486 | 486 | } |
487 | 487 | // first check for a cache_id which is normally empty |
488 | - if ( ! empty( $cache_id )) { |
|
488 | + if ( ! empty($cache_id)) { |
|
489 | 489 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
490 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
490 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
491 | 491 | $return = $cache_id; |
492 | - } elseif ( $object_to_cache->ID() ) { |
|
492 | + } elseif ($object_to_cache->ID()) { |
|
493 | 493 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
494 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
494 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
495 | 495 | $return = $object_to_cache->ID(); |
496 | 496 | } else { |
497 | 497 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
498 | 498 | $this->_model_relations[$relationName][] = $object_to_cache; |
499 | 499 | // move the internal pointer to the end of the array |
500 | - end( $this->_model_relations[$relationName] ); |
|
500 | + end($this->_model_relations[$relationName]); |
|
501 | 501 | // and grab the key so that we can return it |
502 | - $return = key( $this->_model_relations[$relationName] ); |
|
502 | + $return = key($this->_model_relations[$relationName]); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | } |
@@ -518,11 +518,11 @@ discard block |
||
518 | 518 | * @return void |
519 | 519 | * @throws \EE_Error |
520 | 520 | */ |
521 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
521 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
522 | 522 | //first make sure this property exists |
523 | 523 | $this->get_model()->field_settings_for($fieldname); |
524 | 524 | |
525 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
525 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
526 | 526 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
527 | 527 | } |
528 | 528 | |
@@ -543,36 +543,36 @@ discard block |
||
543 | 543 | * @return mixed whatever the value for the property is we're retrieving |
544 | 544 | * @throws \EE_Error |
545 | 545 | */ |
546 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
546 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
547 | 547 | //verify the field exists |
548 | 548 | $this->get_model()->field_settings_for($fieldname); |
549 | 549 | |
550 | 550 | $cache_type = $pretty ? 'pretty' : 'standard'; |
551 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
551 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
552 | 552 | |
553 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
553 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
554 | 554 | return $this->_cached_properties[$fieldname][$cache_type]; |
555 | 555 | } |
556 | 556 | |
557 | 557 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
558 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
558 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
559 | 559 | /** |
560 | 560 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
561 | 561 | * formats are correct. |
562 | 562 | */ |
563 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
564 | - $field_obj->set_timezone( $this->_timezone ); |
|
565 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
566 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
563 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
564 | + $field_obj->set_timezone($this->_timezone); |
|
565 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
566 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
567 | 567 | } |
568 | 568 | |
569 | - if( ! isset($this->_fields[$fieldname])){ |
|
569 | + if ( ! isset($this->_fields[$fieldname])) { |
|
570 | 570 | $this->_fields[$fieldname] = NULL; |
571 | 571 | } |
572 | 572 | $value = $pretty |
573 | 573 | ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) |
574 | - : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
575 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
574 | + : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
575 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
576 | 576 | return $value; |
577 | 577 | } |
578 | 578 | return null; |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
599 | 599 | * @return void |
600 | 600 | */ |
601 | - protected function _clear_cached_property( $property_name ) { |
|
602 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
603 | - unset( $this->_cached_properties[ $property_name ] ); |
|
601 | + protected function _clear_cached_property($property_name) { |
|
602 | + if (isset($this->_cached_properties[$property_name])) { |
|
603 | + unset($this->_cached_properties[$property_name]); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
@@ -614,12 +614,12 @@ discard block |
||
614 | 614 | * @return EE_Base_Class |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
617 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
618 | 618 | $other_model_instance = self::_get_model_instance_with_name( |
619 | - self::_get_model_classname( $model_name ), |
|
619 | + self::_get_model_classname($model_name), |
|
620 | 620 | $this->_timezone |
621 | 621 | ); |
622 | - return $other_model_instance->ensure_is_obj( $object_or_id ); |
|
622 | + return $other_model_instance->ensure_is_obj($object_or_id); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | |
@@ -636,32 +636,32 @@ discard block |
||
636 | 636 | * @throws EE_Error |
637 | 637 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
638 | 638 | */ |
639 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
639 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
640 | 640 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
641 | 641 | $index_in_cache = ''; |
642 | - if( ! $relationship_to_model){ |
|
642 | + if ( ! $relationship_to_model) { |
|
643 | 643 | throw new EE_Error( |
644 | 644 | sprintf( |
645 | - __( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ), |
|
645 | + __("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), |
|
646 | 646 | $relationName, |
647 | - get_class( $this ) |
|
647 | + get_class($this) |
|
648 | 648 | ) |
649 | 649 | ); |
650 | 650 | } |
651 | - if($clear_all){ |
|
651 | + if ($clear_all) { |
|
652 | 652 | $obj_removed = true; |
653 | 653 | $this->_model_relations[$relationName] = null; |
654 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
654 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
655 | 655 | $obj_removed = $this->_model_relations[$relationName]; |
656 | 656 | $this->_model_relations[$relationName] = null; |
657 | - }else{ |
|
658 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
657 | + } else { |
|
658 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
659 | 659 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
660 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
660 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
661 | 661 | $index_found_at = NULL; |
662 | 662 | //find this object in the array even though it has a different key |
663 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
664 | - if( |
|
663 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
664 | + if ( |
|
665 | 665 | $obj instanceof EE_Base_Class |
666 | 666 | && ( |
667 | 667 | $obj == $object_to_remove_or_index_into_array |
@@ -672,34 +672,34 @@ discard block |
||
672 | 672 | break; |
673 | 673 | } |
674 | 674 | } |
675 | - if($index_found_at){ |
|
675 | + if ($index_found_at) { |
|
676 | 676 | $index_in_cache = $index_found_at; |
677 | - }else{ |
|
677 | + } else { |
|
678 | 678 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
679 | 679 | //if it wasn't in it to begin with. So we're done |
680 | 680 | return $object_to_remove_or_index_into_array; |
681 | 681 | } |
682 | 682 | } |
683 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
683 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
684 | 684 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
685 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
686 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
685 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
686 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
687 | 687 | $index_in_cache = $index; |
688 | 688 | } |
689 | 689 | } |
690 | - }else{ |
|
690 | + } else { |
|
691 | 691 | $index_in_cache = $object_to_remove_or_index_into_array; |
692 | 692 | } |
693 | 693 | //supposedly we've found it. But it could just be that the client code |
694 | 694 | //provided a bad index/object |
695 | 695 | if ( |
696 | 696 | isset( |
697 | - $this->_model_relations[ $relationName ], |
|
698 | - $this->_model_relations[ $relationName ][ $index_in_cache ] |
|
697 | + $this->_model_relations[$relationName], |
|
698 | + $this->_model_relations[$relationName][$index_in_cache] |
|
699 | 699 | ) |
700 | 700 | ) { |
701 | - $obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ]; |
|
702 | - unset( $this->_model_relations[ $relationName ][ $index_in_cache ] ); |
|
701 | + $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
|
702 | + unset($this->_model_relations[$relationName][$index_in_cache]); |
|
703 | 703 | } else { |
704 | 704 | //that thing was never cached anyways. |
705 | 705 | $obj_removed = null; |
@@ -720,24 +720,24 @@ discard block |
||
720 | 720 | * @return boolean TRUE on success, FALSE on fail |
721 | 721 | * @throws \EE_Error |
722 | 722 | */ |
723 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
723 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
724 | 724 | // verify that incoming object is of the correct type |
725 | - $obj_class = 'EE_' . $relationName; |
|
726 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
725 | + $obj_class = 'EE_'.$relationName; |
|
726 | + if ($newly_saved_object instanceof $obj_class) { |
|
727 | 727 | /* @type EE_Base_Class $newly_saved_object*/ |
728 | 728 | // now get the type of relation |
729 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
729 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
730 | 730 | // if this is a 1:1 relationship |
731 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
731 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
732 | 732 | // then just replace the cached object with the newly saved object |
733 | 733 | $this->_model_relations[$relationName] = $newly_saved_object; |
734 | 734 | return TRUE; |
735 | 735 | // or if it's some kind of sordid feral polyamorous relationship... |
736 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
736 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
737 | 737 | // then remove the current cached item |
738 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
738 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
739 | 739 | // and cache the newly saved object using it's new ID |
740 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
740 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
741 | 741 | return TRUE; |
742 | 742 | } |
743 | 743 | } |
@@ -753,11 +753,11 @@ discard block |
||
753 | 753 | * @param string $relationName |
754 | 754 | * @return EE_Base_Class |
755 | 755 | */ |
756 | - public function get_one_from_cache($relationName){ |
|
757 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
758 | - if(is_array($cached_array_or_object)){ |
|
756 | + public function get_one_from_cache($relationName) { |
|
757 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
758 | + if (is_array($cached_array_or_object)) { |
|
759 | 759 | return array_shift($cached_array_or_object); |
760 | - }else{ |
|
760 | + } else { |
|
761 | 761 | return $cached_array_or_object; |
762 | 762 | } |
763 | 763 | } |
@@ -772,23 +772,23 @@ discard block |
||
772 | 772 | * @throws \EE_Error |
773 | 773 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
774 | 774 | */ |
775 | - public function get_all_from_cache($relationName){ |
|
776 | - $objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
775 | + public function get_all_from_cache($relationName) { |
|
776 | + $objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
777 | 777 | // if the result is not an array, but exists, make it an array |
778 | - $objects = is_array( $objects ) ? $objects : array( $objects ); |
|
778 | + $objects = is_array($objects) ? $objects : array($objects); |
|
779 | 779 | //bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143 |
780 | 780 | //basically, if this model object was stored in the session, and these cached model objects |
781 | 781 | //already have IDs, let's make sure they're in their model's entity mapper |
782 | 782 | //otherwise we will have duplicates next time we call |
783 | 783 | // EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
784 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
785 | - foreach( $objects as $model_object ){ |
|
786 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
784 | + $model = EE_Registry::instance()->load_model($relationName); |
|
785 | + foreach ($objects as $model_object) { |
|
786 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
787 | 787 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
788 | - if( $model_object->ID() ){ |
|
789 | - $model->add_to_entity_map( $model_object ); |
|
788 | + if ($model_object->ID()) { |
|
789 | + $model->add_to_entity_map($model_object); |
|
790 | 790 | } |
791 | - }else{ |
|
791 | + } else { |
|
792 | 792 | throw new EE_Error( |
793 | 793 | sprintf( |
794 | 794 | __( |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | 'event_espresso' |
797 | 797 | ), |
798 | 798 | $relationName, |
799 | - gettype( $model_object ) |
|
799 | + gettype($model_object) |
|
800 | 800 | ) |
801 | 801 | ); |
802 | 802 | } |
@@ -818,15 +818,15 @@ discard block |
||
818 | 818 | * @return array|EE_Base_Class[] |
819 | 819 | * @throws \EE_Error |
820 | 820 | */ |
821 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
822 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
821 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
822 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
823 | 823 | ? $this->get_model()->get_primary_key_field()->get_name() |
824 | 824 | : $field_to_order_by; |
825 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
826 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
825 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
826 | + if (empty($field) || empty($current_value)) { |
|
827 | 827 | return array(); |
828 | 828 | } |
829 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
829 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -843,15 +843,15 @@ discard block |
||
843 | 843 | * @return array|EE_Base_Class[] |
844 | 844 | * @throws \EE_Error |
845 | 845 | */ |
846 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
847 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
846 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
847 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
848 | 848 | ? $this->get_model()->get_primary_key_field()->get_name() |
849 | 849 | : $field_to_order_by; |
850 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
851 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
850 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
851 | + if (empty($field) || empty($current_value)) { |
|
852 | 852 | return array(); |
853 | 853 | } |
854 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
854 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | |
@@ -867,15 +867,15 @@ discard block |
||
867 | 867 | * @return array|EE_Base_Class |
868 | 868 | * @throws \EE_Error |
869 | 869 | */ |
870 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
871 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
870 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
871 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
872 | 872 | ? $this->get_model()->get_primary_key_field()->get_name() |
873 | 873 | : $field_to_order_by; |
874 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
875 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
874 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
875 | + if (empty($field) || empty($current_value)) { |
|
876 | 876 | return array(); |
877 | 877 | } |
878 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
878 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | |
@@ -891,15 +891,15 @@ discard block |
||
891 | 891 | * @return array|EE_Base_Class |
892 | 892 | * @throws \EE_Error |
893 | 893 | */ |
894 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
895 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
894 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
895 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
896 | 896 | ? $this->get_model()->get_primary_key_field()->get_name() |
897 | 897 | : $field_to_order_by; |
898 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
899 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
898 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
899 | + if (empty($field) || empty($current_value)) { |
|
900 | 900 | return array(); |
901 | 901 | } |
902 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
902 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | |
@@ -912,25 +912,25 @@ discard block |
||
912 | 912 | * @param mixed $field_value_from_db |
913 | 913 | * @throws \EE_Error |
914 | 914 | */ |
915 | - public function set_from_db($field_name,$field_value_from_db){ |
|
915 | + public function set_from_db($field_name, $field_value_from_db) { |
|
916 | 916 | $field_obj = $this->get_model()->field_settings_for($field_name); |
917 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
917 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
918 | 918 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
919 | 919 | //eg, a CPT model object could have an entry in the posts table, but no |
920 | 920 | //entry in the meta table. Meaning that all its columns in the meta table |
921 | 921 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
922 | - if($field_value_from_db === NULL ){ |
|
923 | - if( $field_obj->is_nullable()){ |
|
922 | + if ($field_value_from_db === NULL) { |
|
923 | + if ($field_obj->is_nullable()) { |
|
924 | 924 | //if the field allows nulls, then let it be null |
925 | 925 | $field_value = NULL; |
926 | - }else{ |
|
926 | + } else { |
|
927 | 927 | $field_value = $field_obj->get_default_value(); |
928 | 928 | } |
929 | - }else{ |
|
930 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
929 | + } else { |
|
930 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
931 | 931 | } |
932 | 932 | $this->_fields[$field_name] = $field_value; |
933 | - $this->_clear_cached_property( $field_name ); |
|
933 | + $this->_clear_cached_property($field_name); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | * @return mixed |
947 | 947 | * @throws \EE_Error |
948 | 948 | */ |
949 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
950 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
949 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
950 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | |
@@ -980,10 +980,10 @@ discard block |
||
980 | 980 | * just null is returned (because that indicates that likely |
981 | 981 | * this field is nullable). |
982 | 982 | */ |
983 | - public function get_DateTime_object( $field_name ) { |
|
984 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
983 | + public function get_DateTime_object($field_name) { |
|
984 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
985 | 985 | |
986 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
986 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
987 | 987 | EE_Error::add_error( |
988 | 988 | sprintf( |
989 | 989 | __( |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | * @return void |
1016 | 1016 | * @throws \EE_Error |
1017 | 1017 | */ |
1018 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
1018 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
1019 | 1019 | echo $this->get_pretty($field_name, $extra_cache_ref); |
1020 | 1020 | } |
1021 | 1021 | |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @return void |
1030 | 1030 | * @throws \EE_Error |
1031 | 1031 | */ |
1032 | - public function f($field_name){ |
|
1033 | - $this->e($field_name,'form_input'); |
|
1032 | + public function f($field_name) { |
|
1033 | + $this->e($field_name, 'form_input'); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | * @return mixed |
1044 | 1044 | * @throws \EE_Error |
1045 | 1045 | */ |
1046 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
1047 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
1046 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
1047 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | |
@@ -1062,36 +1062,36 @@ discard block |
||
1062 | 1062 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
1063 | 1063 | * @throws \EE_Error |
1064 | 1064 | */ |
1065 | - protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
|
1065 | + protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { |
|
1066 | 1066 | |
1067 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1067 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1068 | 1068 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1069 | 1069 | |
1070 | 1070 | //validate field for datetime and returns field settings if valid. |
1071 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1071 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1072 | 1072 | |
1073 | 1073 | //clear cached property if either formats are not null. |
1074 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1075 | - $this->_clear_cached_property( $field_name ); |
|
1074 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1075 | + $this->_clear_cached_property($field_name); |
|
1076 | 1076 | //reset format properties because they are used in get() |
1077 | 1077 | $this->_dt_frmt = $in_dt_frmt; |
1078 | 1078 | $this->_tm_frmt = $in_tm_frmt; |
1079 | 1079 | } |
1080 | - if ( $echo ) { |
|
1081 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1080 | + if ($echo) { |
|
1081 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1082 | 1082 | } else { |
1083 | - $field->set_date_format( $in_dt_frmt ); |
|
1083 | + $field->set_date_format($in_dt_frmt); |
|
1084 | 1084 | } |
1085 | - if ( $echo ) { |
|
1086 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1085 | + if ($echo) { |
|
1086 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1087 | 1087 | } else { |
1088 | - $field->set_time_format( $in_tm_frmt ); |
|
1088 | + $field->set_time_format($in_tm_frmt); |
|
1089 | 1089 | } |
1090 | 1090 | //set timezone in field object |
1091 | - $field->set_timezone( $this->_timezone ); |
|
1091 | + $field->set_timezone($this->_timezone); |
|
1092 | 1092 | |
1093 | 1093 | //set the output returned |
1094 | - switch ( $date_or_time ) { |
|
1094 | + switch ($date_or_time) { |
|
1095 | 1095 | |
1096 | 1096 | case 'D' : |
1097 | 1097 | $field->set_date_time_output('date'); |
@@ -1106,11 +1106,11 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
1109 | - if ( $echo ) { |
|
1110 | - $this->e( $field_name, $date_or_time ); |
|
1109 | + if ($echo) { |
|
1110 | + $this->e($field_name, $date_or_time); |
|
1111 | 1111 | return ''; |
1112 | 1112 | } |
1113 | - return $this->get( $field_name, $date_or_time ); |
|
1113 | + return $this->get($field_name, $date_or_time); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @return string datetime value formatted |
1124 | 1124 | * @throws \EE_Error |
1125 | 1125 | */ |
1126 | - public function get_date( $field_name, $format = NULL ) { |
|
1127 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1126 | + public function get_date($field_name, $format = NULL) { |
|
1127 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | |
@@ -1134,8 +1134,8 @@ discard block |
||
1134 | 1134 | * @param null $format |
1135 | 1135 | * @throws \EE_Error |
1136 | 1136 | */ |
1137 | - public function e_date( $field_name, $format = NULL ) { |
|
1138 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1137 | + public function e_date($field_name, $format = NULL) { |
|
1138 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | * @return string datetime value formatted |
1149 | 1149 | * @throws \EE_Error |
1150 | 1150 | */ |
1151 | - public function get_time( $field_name, $format = NULL ) { |
|
1152 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1151 | + public function get_time($field_name, $format = NULL) { |
|
1152 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | |
@@ -1159,8 +1159,8 @@ discard block |
||
1159 | 1159 | * @param null $format |
1160 | 1160 | * @throws \EE_Error |
1161 | 1161 | */ |
1162 | - public function e_time( $field_name, $format = NULL ) { |
|
1163 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1162 | + public function e_time($field_name, $format = NULL) { |
|
1163 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
@@ -1174,8 +1174,8 @@ discard block |
||
1174 | 1174 | * @return string datetime value formatted |
1175 | 1175 | * @throws \EE_Error |
1176 | 1176 | */ |
1177 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1178 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1177 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1178 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
@@ -1186,8 +1186,8 @@ discard block |
||
1186 | 1186 | * @param null $tm_frmt |
1187 | 1187 | * @throws \EE_Error |
1188 | 1188 | */ |
1189 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1190 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1189 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1190 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | |
@@ -1201,11 +1201,11 @@ discard block |
||
1201 | 1201 | * @throws \EE_Error |
1202 | 1202 | * field name. |
1203 | 1203 | */ |
1204 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1205 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1204 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1205 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1206 | 1206 | return date_i18n( |
1207 | 1207 | $format, |
1208 | - EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) |
|
1208 | + EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone) |
|
1209 | 1209 | ); |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1218,14 +1218,14 @@ discard block |
||
1218 | 1218 | * @throws EE_Error |
1219 | 1219 | * @return EE_Datetime_Field |
1220 | 1220 | */ |
1221 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1221 | + protected function _get_dtt_field_settings($field_name) { |
|
1222 | 1222 | $field = $this->get_model()->field_settings_for($field_name); |
1223 | 1223 | |
1224 | 1224 | //check if field is dtt |
1225 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1225 | + if ($field instanceof EE_Datetime_Field) { |
|
1226 | 1226 | return $field; |
1227 | 1227 | } else { |
1228 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1228 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1229 | 1229 | } |
1230 | 1230 | } |
1231 | 1231 | |
@@ -1246,8 +1246,8 @@ discard block |
||
1246 | 1246 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1247 | 1247 | * @throws \EE_Error |
1248 | 1248 | */ |
1249 | - protected function _set_time_for( $time, $fieldname ) { |
|
1250 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1249 | + protected function _set_time_for($time, $fieldname) { |
|
1250 | + $this->_set_date_time('T', $time, $fieldname); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | |
@@ -1260,8 +1260,8 @@ discard block |
||
1260 | 1260 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1261 | 1261 | * @throws \EE_Error |
1262 | 1262 | */ |
1263 | - protected function _set_date_for( $date, $fieldname ) { |
|
1264 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1263 | + protected function _set_date_for($date, $fieldname) { |
|
1264 | + $this->_set_date_time('D', $date, $fieldname); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | |
@@ -1275,26 +1275,26 @@ discard block |
||
1275 | 1275 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1276 | 1276 | * @throws \EE_Error |
1277 | 1277 | */ |
1278 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1279 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1280 | - $field->set_timezone( $this->_timezone ); |
|
1281 | - $field->set_date_format( $this->_dt_frmt ); |
|
1282 | - $field->set_time_format( $this->_tm_frmt ); |
|
1283 | - switch ( $what ) { |
|
1278 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1279 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1280 | + $field->set_timezone($this->_timezone); |
|
1281 | + $field->set_date_format($this->_dt_frmt); |
|
1282 | + $field->set_time_format($this->_tm_frmt); |
|
1283 | + switch ($what) { |
|
1284 | 1284 | case 'T' : |
1285 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time( |
|
1285 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( |
|
1286 | 1286 | $datetime_value, |
1287 | - $this->_fields[ $fieldname ] |
|
1287 | + $this->_fields[$fieldname] |
|
1288 | 1288 | ); |
1289 | 1289 | break; |
1290 | 1290 | case 'D' : |
1291 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date( |
|
1291 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( |
|
1292 | 1292 | $datetime_value, |
1293 | - $this->_fields[ $fieldname ] |
|
1293 | + $this->_fields[$fieldname] |
|
1294 | 1294 | ); |
1295 | 1295 | break; |
1296 | 1296 | case 'B' : |
1297 | - $this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value ); |
|
1297 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1298 | 1298 | break; |
1299 | 1299 | } |
1300 | 1300 | $this->_clear_cached_property($fieldname); |
@@ -1316,17 +1316,17 @@ discard block |
||
1316 | 1316 | * @throws EE_Error |
1317 | 1317 | * @return string timestamp |
1318 | 1318 | */ |
1319 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1319 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1320 | 1320 | $timezone = EEH_DTT_Helper::get_timezone(); |
1321 | - if ( $timezone === $this->_timezone ) { |
|
1321 | + if ($timezone === $this->_timezone) { |
|
1322 | 1322 | return ''; |
1323 | 1323 | } |
1324 | 1324 | $original_timezone = $this->_timezone; |
1325 | - $this->set_timezone( $timezone ); |
|
1325 | + $this->set_timezone($timezone); |
|
1326 | 1326 | |
1327 | 1327 | $fn = (array) $field_name; |
1328 | - $args = array_merge( $fn, (array) $args ); |
|
1329 | - if ( ! method_exists( $this, $callback ) ) { |
|
1328 | + $args = array_merge($fn, (array) $args); |
|
1329 | + if ( ! method_exists($this, $callback)) { |
|
1330 | 1330 | throw new EE_Error( |
1331 | 1331 | sprintf( |
1332 | 1332 | __( |
@@ -1338,9 +1338,9 @@ discard block |
||
1338 | 1338 | ); |
1339 | 1339 | } |
1340 | 1340 | $args = (array) $args; |
1341 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1341 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1342 | 1342 | |
1343 | - $this->set_timezone( $original_timezone ); |
|
1343 | + $this->set_timezone($original_timezone); |
|
1344 | 1344 | return $return; |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | * @return boolean | int |
1355 | 1355 | * @throws \EE_Error |
1356 | 1356 | */ |
1357 | - public function delete(){ |
|
1357 | + public function delete() { |
|
1358 | 1358 | /** |
1359 | 1359 | * Called just before the `EE_Base_Class::_delete` method call. |
1360 | 1360 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | * |
1364 | 1364 | * @param EE_Base_Class $model_object about to be 'deleted' |
1365 | 1365 | */ |
1366 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1366 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1367 | 1367 | $result = $this->_delete(); |
1368 | 1368 | /** |
1369 | 1369 | * Called just after the `EE_Base_Class::_delete` method call. |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | * @param EE_Base_Class $model_object that was just 'deleted' |
1374 | 1374 | * @param boolean $result |
1375 | 1375 | */ |
1376 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1376 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1377 | 1377 | return $result; |
1378 | 1378 | } |
1379 | 1379 | |
@@ -1399,22 +1399,22 @@ discard block |
||
1399 | 1399 | * @return bool | int |
1400 | 1400 | * @throws \EE_Error |
1401 | 1401 | */ |
1402 | - public function delete_permanently(){ |
|
1402 | + public function delete_permanently() { |
|
1403 | 1403 | /** |
1404 | 1404 | * Called just before HARD deleting a model object |
1405 | 1405 | * |
1406 | 1406 | * @param EE_Base_Class $model_object about to be 'deleted' |
1407 | 1407 | */ |
1408 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1409 | - $model=$this->get_model(); |
|
1410 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
1408 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1409 | + $model = $this->get_model(); |
|
1410 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
1411 | 1411 | $this->refresh_cache_of_related_objects(); |
1412 | 1412 | /** |
1413 | 1413 | * Called just after HARD deleting a model object |
1414 | 1414 | * @param EE_Base_Class $model_object that was just 'deleted' |
1415 | 1415 | * @param boolean $result |
1416 | 1416 | */ |
1417 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1417 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1418 | 1418 | return $result; |
1419 | 1419 | } |
1420 | 1420 | |
@@ -1427,18 +1427,18 @@ discard block |
||
1427 | 1427 | * @throws \EE_Error |
1428 | 1428 | */ |
1429 | 1429 | public function refresh_cache_of_related_objects() { |
1430 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1431 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1432 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1433 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1430 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1431 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1432 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1433 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1434 | 1434 | //this relation only stores a single model object, not an array |
1435 | 1435 | //but let's make it consistent |
1436 | - $related_objects = array( $related_objects ); |
|
1436 | + $related_objects = array($related_objects); |
|
1437 | 1437 | } |
1438 | - foreach( $related_objects as $related_object ) { |
|
1438 | + foreach ($related_objects as $related_object) { |
|
1439 | 1439 | //only refresh their cache if they're in memory |
1440 | - if( $related_object instanceof EE_Base_Class ) { |
|
1441 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1440 | + if ($related_object instanceof EE_Base_Class) { |
|
1441 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1442 | 1442 | } |
1443 | 1443 | } |
1444 | 1444 | } |
@@ -1458,17 +1458,17 @@ discard block |
||
1458 | 1458 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1459 | 1459 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1460 | 1460 | */ |
1461 | - public function save($set_cols_n_values=array()) { |
|
1461 | + public function save($set_cols_n_values = array()) { |
|
1462 | 1462 | /** |
1463 | 1463 | * Filters the fields we're about to save on the model object |
1464 | 1464 | * |
1465 | 1465 | * @param array $set_cols_n_values |
1466 | 1466 | * @param EE_Base_Class $model_object |
1467 | 1467 | */ |
1468 | - $set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1468 | + $set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1469 | 1469 | //set attributes as provided in $set_cols_n_values |
1470 | - foreach($set_cols_n_values as $column=>$value){ |
|
1471 | - $this->set($column,$value); |
|
1470 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1471 | + $this->set($column, $value); |
|
1472 | 1472 | } |
1473 | 1473 | /** |
1474 | 1474 | * Saving a model object. |
@@ -1476,8 +1476,8 @@ discard block |
||
1476 | 1476 | * Before we perform a save, this action is fired. |
1477 | 1477 | * @param EE_Base_Class $model_object the model object about to be saved. |
1478 | 1478 | */ |
1479 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1480 | - if( ! $this->allow_persist() ) { |
|
1479 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1480 | + if ( ! $this->allow_persist()) { |
|
1481 | 1481 | return 0; |
1482 | 1482 | } |
1483 | 1483 | //now get current attribute values |
@@ -1487,61 +1487,61 @@ discard block |
||
1487 | 1487 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1488 | 1488 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1489 | 1489 | //does this model have an autoincrement PK? |
1490 | - if($this->get_model()->has_primary_key_field()){ |
|
1491 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1490 | + if ($this->get_model()->has_primary_key_field()) { |
|
1491 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1492 | 1492 | //ok check if it's set, if so: update; if not, insert |
1493 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1494 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1493 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1494 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1495 | 1495 | } else { |
1496 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1497 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1498 | - if($results){ |
|
1496 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1497 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1498 | + if ($results) { |
|
1499 | 1499 | //if successful, set the primary key |
1500 | 1500 | //but don't use the normal SET method, because it will check if |
1501 | 1501 | //an item with the same ID exists in the mapper & db, then |
1502 | 1502 | //will find it in the db (because we just added it) and THAT object |
1503 | 1503 | //will get added to the mapper before we can add this one! |
1504 | 1504 | //but if we just avoid using the SET method, all that headache can be avoided |
1505 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1505 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1506 | 1506 | $this->_fields[$pk_field_name] = $results; |
1507 | 1507 | $this->_clear_cached_property($pk_field_name); |
1508 | - $this->get_model()->add_to_entity_map( $this ); |
|
1508 | + $this->get_model()->add_to_entity_map($this); |
|
1509 | 1509 | $this->_update_cached_related_model_objs_fks(); |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | - }else{//PK is NOT auto-increment |
|
1512 | + } else {//PK is NOT auto-increment |
|
1513 | 1513 | //so check if one like it already exists in the db |
1514 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1515 | - if( WP_DEBUG && ! $this->in_entity_map() ){ |
|
1514 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1515 | + if (WP_DEBUG && ! $this->in_entity_map()) { |
|
1516 | 1516 | throw new EE_Error( |
1517 | 1517 | sprintf( |
1518 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1518 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1519 | 1519 | get_class($this), |
1520 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1521 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1520 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1521 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1522 | 1522 | '<br />' |
1523 | 1523 | ) |
1524 | 1524 | ); |
1525 | 1525 | } |
1526 | 1526 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1527 | - }else{ |
|
1527 | + } else { |
|
1528 | 1528 | $results = $this->get_model()->insert($save_cols_n_values); |
1529 | 1529 | $this->_update_cached_related_model_objs_fks(); |
1530 | 1530 | } |
1531 | 1531 | } |
1532 | - }else{//there is NO primary key |
|
1532 | + } else {//there is NO primary key |
|
1533 | 1533 | $already_in_db = false; |
1534 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1534 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1535 | 1535 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1536 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1536 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1537 | 1537 | $already_in_db = true; |
1538 | 1538 | } |
1539 | 1539 | } |
1540 | - if( $already_in_db ){ |
|
1541 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1542 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
1543 | - }else{ |
|
1544 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1540 | + if ($already_in_db) { |
|
1541 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1542 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
1543 | + } else { |
|
1544 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1545 | 1545 | } |
1546 | 1546 | } |
1547 | 1547 | //restore the old assumption about values being prepared by the model object |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1555 | 1555 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1556 | 1556 | */ |
1557 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1557 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1558 | 1558 | return $results; |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1569,15 +1569,15 @@ discard block |
||
1569 | 1569 | * @return void |
1570 | 1570 | * @throws \EE_Error |
1571 | 1571 | */ |
1572 | - protected function _update_cached_related_model_objs_fks(){ |
|
1573 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1574 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1575 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1572 | + protected function _update_cached_related_model_objs_fks() { |
|
1573 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1574 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1575 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1576 | 1576 | $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( |
1577 | 1577 | $this->get_model()->get_this_model_name() |
1578 | 1578 | ); |
1579 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1580 | - if( $related_model_obj_in_cache->ID() ){ |
|
1579 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1580 | + if ($related_model_obj_in_cache->ID()) { |
|
1581 | 1581 | $related_model_obj_in_cache->save(); |
1582 | 1582 | } |
1583 | 1583 | } |
@@ -1598,21 +1598,21 @@ discard block |
||
1598 | 1598 | * @return int ID of new model object on save; 0 on failure+ |
1599 | 1599 | * @throws \EE_Error |
1600 | 1600 | */ |
1601 | - public function save_new_cached_related_model_objs(){ |
|
1601 | + public function save_new_cached_related_model_objs() { |
|
1602 | 1602 | //make sure this has been saved |
1603 | - if( ! $this->ID()){ |
|
1603 | + if ( ! $this->ID()) { |
|
1604 | 1604 | $id = $this->save(); |
1605 | - }else{ |
|
1605 | + } else { |
|
1606 | 1606 | $id = $this->ID(); |
1607 | 1607 | } |
1608 | 1608 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1609 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1609 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1610 | 1610 | |
1611 | 1611 | |
1612 | - if($this->_model_relations[$relationName]){ |
|
1612 | + if ($this->_model_relations[$relationName]) { |
|
1613 | 1613 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1614 | 1614 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1615 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1615 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1616 | 1616 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1617 | 1617 | //but ONLY if it DOES NOT exist in the DB |
1618 | 1618 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1621,8 +1621,8 @@ discard block |
||
1621 | 1621 | $this->_add_relation_to($related_model_obj, $relationName); |
1622 | 1622 | $related_model_obj->save_new_cached_related_model_objs(); |
1623 | 1623 | // } |
1624 | - }else{ |
|
1625 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1624 | + } else { |
|
1625 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1626 | 1626 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1627 | 1627 | //but ONLY if it DOES NOT exist in the DB |
1628 | 1628 | // if( ! $related_model_obj->ID()){ |
@@ -1643,8 +1643,8 @@ discard block |
||
1643 | 1643 | * @return \EEM_Base | \EEM_CPT_Base |
1644 | 1644 | */ |
1645 | 1645 | public function get_model() { |
1646 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1647 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1646 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1647 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | |
@@ -1655,10 +1655,10 @@ discard block |
||
1655 | 1655 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1656 | 1656 | * @throws \EE_Error |
1657 | 1657 | */ |
1658 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1658 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1659 | 1659 | //TODO: will not work for Term_Relationships because they have no PK! |
1660 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1661 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1660 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1661 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1662 | 1662 | $id = $props_n_values[$primary_id_ref]; |
1663 | 1663 | return self::_get_model($classname)->get_from_entity_map($id); |
1664 | 1664 | } |
@@ -1679,37 +1679,37 @@ discard block |
||
1679 | 1679 | * @return mixed (EE_Base_Class|bool) |
1680 | 1680 | * @throws \EE_Error |
1681 | 1681 | */ |
1682 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1682 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1683 | 1683 | $existing = null; |
1684 | - if ( self::_get_model( $classname )->has_primary_key_field() ) { |
|
1685 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1686 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) |
|
1687 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1684 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1685 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1686 | + if (array_key_exists($primary_id_ref, $props_n_values) |
|
1687 | + && ! empty($props_n_values[$primary_id_ref]) |
|
1688 | 1688 | ) { |
1689 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1690 | - $props_n_values[ $primary_id_ref ] |
|
1689 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1690 | + $props_n_values[$primary_id_ref] |
|
1691 | 1691 | ); |
1692 | 1692 | } |
1693 | - } elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) { |
|
1693 | + } elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1694 | 1694 | //no primary key on this model, but there's still a matching item in the DB |
1695 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1696 | - self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values ) |
|
1695 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1696 | + self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values) |
|
1697 | 1697 | ); |
1698 | 1698 | } |
1699 | - if ( $existing ) { |
|
1699 | + if ($existing) { |
|
1700 | 1700 | |
1701 | 1701 | //set date formats if present before setting values |
1702 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1703 | - $existing->set_date_format( $date_formats[0] ); |
|
1704 | - $existing->set_time_format( $date_formats[1] ); |
|
1702 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1703 | + $existing->set_date_format($date_formats[0]); |
|
1704 | + $existing->set_time_format($date_formats[1]); |
|
1705 | 1705 | } else { |
1706 | 1706 | //set default formats for date and time |
1707 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1708 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1707 | + $existing->set_date_format(get_option('date_format')); |
|
1708 | + $existing->set_time_format(get_option('time_format')); |
|
1709 | 1709 | } |
1710 | 1710 | |
1711 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1712 | - $existing->set( $property, $field_value ); |
|
1711 | + foreach ($props_n_values as $property => $field_value) { |
|
1712 | + $existing->set($property, $field_value); |
|
1713 | 1713 | } |
1714 | 1714 | return $existing; |
1715 | 1715 | } else { |
@@ -1727,9 +1727,9 @@ discard block |
||
1727 | 1727 | * @throws EE_Error |
1728 | 1728 | * @return EEM_Base |
1729 | 1729 | */ |
1730 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1730 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1731 | 1731 | //find model for this class |
1732 | - if( ! $classname ){ |
|
1732 | + if ( ! $classname) { |
|
1733 | 1733 | throw new EE_Error( |
1734 | 1734 | sprintf( |
1735 | 1735 | __( |
@@ -1740,8 +1740,8 @@ discard block |
||
1740 | 1740 | ) |
1741 | 1741 | ); |
1742 | 1742 | } |
1743 | - $modelName=self::_get_model_classname($classname); |
|
1744 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1743 | + $modelName = self::_get_model_classname($classname); |
|
1744 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | |
@@ -1752,10 +1752,10 @@ discard block |
||
1752 | 1752 | * @param null $timezone |
1753 | 1753 | * @return EEM_Base |
1754 | 1754 | */ |
1755 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1756 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1757 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1758 | - $model->set_timezone( $timezone ); |
|
1755 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1756 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1757 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1758 | + $model->set_timezone($timezone); |
|
1759 | 1759 | return $model; |
1760 | 1760 | } |
1761 | 1761 | |
@@ -1767,10 +1767,10 @@ discard block |
||
1767 | 1767 | * @param null $model_name |
1768 | 1768 | * @return string like EEM_Attendee |
1769 | 1769 | */ |
1770 | - private static function _get_model_classname( $model_name = null){ |
|
1771 | - if(strpos($model_name,"EE_")===0){ |
|
1772 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1773 | - }else{ |
|
1770 | + private static function _get_model_classname($model_name = null) { |
|
1771 | + if (strpos($model_name, "EE_") === 0) { |
|
1772 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1773 | + } else { |
|
1774 | 1774 | $model_classname = "EEM_".$model_name; |
1775 | 1775 | } |
1776 | 1776 | return $model_classname; |
@@ -1784,16 +1784,16 @@ discard block |
||
1784 | 1784 | * @throws EE_Error |
1785 | 1785 | * @return string |
1786 | 1786 | */ |
1787 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1788 | - if( ! $classname){ |
|
1787 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1788 | + if ( ! $classname) { |
|
1789 | 1789 | throw new EE_Error( |
1790 | 1790 | sprintf( |
1791 | - __( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ), |
|
1791 | + __("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), |
|
1792 | 1792 | $classname |
1793 | 1793 | ) |
1794 | 1794 | ); |
1795 | 1795 | } |
1796 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1796 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1797 | 1797 | } |
1798 | 1798 | |
1799 | 1799 | |
@@ -1807,12 +1807,12 @@ discard block |
||
1807 | 1807 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1808 | 1808 | * @throws \EE_Error |
1809 | 1809 | */ |
1810 | - public function ID(){ |
|
1810 | + public function ID() { |
|
1811 | 1811 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1812 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1813 | - return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
|
1814 | - }else{ |
|
1815 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1812 | + if ($this->get_model()->has_primary_key_field()) { |
|
1813 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1814 | + } else { |
|
1815 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1816 | 1816 | } |
1817 | 1817 | } |
1818 | 1818 | |
@@ -1830,38 +1830,38 @@ discard block |
||
1830 | 1830 | * @throws EE_Error |
1831 | 1831 | * @return EE_Base_Class the object the relation was added to |
1832 | 1832 | */ |
1833 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1833 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1834 | 1834 | //if this thing exists in the DB, save the relation to the DB |
1835 | - if( $this->ID() ){ |
|
1836 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1835 | + if ($this->ID()) { |
|
1836 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1837 | 1837 | //clear cache so future get_many_related and get_first_related() return new results. |
1838 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1839 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1840 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1838 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1839 | + if ($otherObject instanceof EE_Base_Class) { |
|
1840 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1841 | 1841 | } |
1842 | 1842 | } else { |
1843 | 1843 | //this thing doesn't exist in the DB, so just cache it |
1844 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1845 | - throw new EE_Error( sprintf( |
|
1846 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1844 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1845 | + throw new EE_Error(sprintf( |
|
1846 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1847 | 1847 | $otherObjectModelObjectOrID, |
1848 | - get_class( $this ) |
|
1848 | + get_class($this) |
|
1849 | 1849 | )); |
1850 | 1850 | } else { |
1851 | 1851 | $otherObject = $otherObjectModelObjectOrID; |
1852 | 1852 | } |
1853 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1853 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1854 | 1854 | } |
1855 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1855 | + if ($otherObject instanceof EE_Base_Class) { |
|
1856 | 1856 | //fix the reciprocal relation too |
1857 | - if( $otherObject->ID() ) { |
|
1857 | + if ($otherObject->ID()) { |
|
1858 | 1858 | //its saved so assumed relations exist in the DB, so we can just |
1859 | 1859 | //clear the cache so future queries use the updated info in the DB |
1860 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1860 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1861 | 1861 | } else { |
1862 | 1862 | |
1863 | 1863 | //it's not saved, so it caches relations like this |
1864 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1864 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1865 | 1865 | } |
1866 | 1866 | } |
1867 | 1867 | return $otherObject; |
@@ -1885,17 +1885,17 @@ discard block |
||
1885 | 1885 | * @return EE_Base_Class the relation was removed from |
1886 | 1886 | * @throws \EE_Error |
1887 | 1887 | */ |
1888 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1889 | - if ( $this->ID() ) { |
|
1888 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1889 | + if ($this->ID()) { |
|
1890 | 1890 | //if this exists in the DB, save the relation change to the DB too |
1891 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1892 | - $this->clear_cache( $relationName, $otherObject ); |
|
1891 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1892 | + $this->clear_cache($relationName, $otherObject); |
|
1893 | 1893 | } else { |
1894 | 1894 | //this doesn't exist in the DB, just remove it from the cache |
1895 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1895 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1896 | 1896 | } |
1897 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1898 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1897 | + if ($otherObject instanceof EE_Base_Class) { |
|
1898 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1899 | 1899 | } |
1900 | 1900 | return $otherObject; |
1901 | 1901 | } |
@@ -1910,18 +1910,18 @@ discard block |
||
1910 | 1910 | * @return EE_Base_Class |
1911 | 1911 | * @throws \EE_Error |
1912 | 1912 | */ |
1913 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1914 | - if ( $this->ID() ) { |
|
1913 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1914 | + if ($this->ID()) { |
|
1915 | 1915 | //if this exists in the DB, save the relation change to the DB too |
1916 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1917 | - $this->clear_cache( $relationName, null, true ); |
|
1916 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1917 | + $this->clear_cache($relationName, null, true); |
|
1918 | 1918 | } else { |
1919 | 1919 | //this doesn't exist in the DB, just remove it from the cache |
1920 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1920 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1921 | 1921 | } |
1922 | - if( is_array( $otherObjects ) ) { |
|
1923 | - foreach ( $otherObjects as $otherObject ) { |
|
1924 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1922 | + if (is_array($otherObjects)) { |
|
1923 | + foreach ($otherObjects as $otherObject) { |
|
1924 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | return $otherObjects; |
@@ -1941,27 +1941,27 @@ discard block |
||
1941 | 1941 | * @throws \EE_Error |
1942 | 1942 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1943 | 1943 | */ |
1944 | - public function get_many_related($relationName,$query_params = array()){ |
|
1945 | - if($this->ID()){ |
|
1944 | + public function get_many_related($relationName, $query_params = array()) { |
|
1945 | + if ($this->ID()) { |
|
1946 | 1946 | //this exists in the DB, so get the related things from either the cache or the DB |
1947 | 1947 | //if there are query parameters, forget about caching the related model objects. |
1948 | - if( $query_params ){ |
|
1948 | + if ($query_params) { |
|
1949 | 1949 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1950 | - }else{ |
|
1950 | + } else { |
|
1951 | 1951 | //did we already cache the result of this query? |
1952 | 1952 | $cached_results = $this->get_all_from_cache($relationName); |
1953 | - if ( ! $cached_results ){ |
|
1953 | + if ( ! $cached_results) { |
|
1954 | 1954 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1955 | 1955 | //if no query parameters were passed, then we got all the related model objects |
1956 | 1956 | //for that relation. We can cache them then. |
1957 | - foreach($related_model_objects as $related_model_object){ |
|
1957 | + foreach ($related_model_objects as $related_model_object) { |
|
1958 | 1958 | $this->cache($relationName, $related_model_object); |
1959 | 1959 | } |
1960 | - }else{ |
|
1960 | + } else { |
|
1961 | 1961 | $related_model_objects = $cached_results; |
1962 | 1962 | } |
1963 | 1963 | } |
1964 | - }else{ |
|
1964 | + } else { |
|
1965 | 1965 | //this doesn't exist in the DB, so just get the related things from the cache |
1966 | 1966 | $related_model_objects = $this->get_all_from_cache($relationName); |
1967 | 1967 | } |
@@ -1979,8 +1979,8 @@ discard block |
||
1979 | 1979 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
1980 | 1980 | * @return int |
1981 | 1981 | */ |
1982 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1983 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
1982 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1983 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
1995 | 1995 | * @return int |
1996 | 1996 | */ |
1997 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
1997 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
1998 | 1998 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
1999 | 1999 | } |
2000 | 2000 | |
@@ -2008,33 +2008,33 @@ discard block |
||
2008 | 2008 | * @return EE_Base_Class (not an array, a single object) |
2009 | 2009 | * @throws \EE_Error |
2010 | 2010 | */ |
2011 | - public function get_first_related($relationName,$query_params = array()){ |
|
2012 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
2011 | + public function get_first_related($relationName, $query_params = array()) { |
|
2012 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
2013 | 2013 | |
2014 | 2014 | //if they've provided some query parameters, don't bother trying to cache the result |
2015 | 2015 | //also make sure we're not caching the result of get_first_related |
2016 | 2016 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2017 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2018 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2019 | - }else{ |
|
2017 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2018 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2019 | + } else { |
|
2020 | 2020 | //first, check if we've already cached the result of this query |
2021 | 2021 | $cached_result = $this->get_one_from_cache($relationName); |
2022 | - if ( ! $cached_result ){ |
|
2022 | + if ( ! $cached_result) { |
|
2023 | 2023 | |
2024 | 2024 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2025 | - $this->cache($relationName,$related_model_object); |
|
2026 | - }else{ |
|
2025 | + $this->cache($relationName, $related_model_object); |
|
2026 | + } else { |
|
2027 | 2027 | $related_model_object = $cached_result; |
2028 | 2028 | } |
2029 | 2029 | } |
2030 | - }else{ |
|
2030 | + } else { |
|
2031 | 2031 | $related_model_object = null; |
2032 | 2032 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2033 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2034 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2033 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2034 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2035 | 2035 | } |
2036 | 2036 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
2037 | - if( ! $related_model_object){ |
|
2037 | + if ( ! $related_model_object) { |
|
2038 | 2038 | $related_model_object = $this->get_one_from_cache($relationName); |
2039 | 2039 | } |
2040 | 2040 | |
@@ -2056,12 +2056,12 @@ discard block |
||
2056 | 2056 | * @return int how many deleted |
2057 | 2057 | * @throws \EE_Error |
2058 | 2058 | */ |
2059 | - public function delete_related($relationName,$query_params = array()){ |
|
2060 | - if($this->ID()){ |
|
2061 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2062 | - }else{ |
|
2059 | + public function delete_related($relationName, $query_params = array()) { |
|
2060 | + if ($this->ID()) { |
|
2061 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2062 | + } else { |
|
2063 | 2063 | $count = count($this->get_all_from_cache($relationName)); |
2064 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2064 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2065 | 2065 | } |
2066 | 2066 | return $count; |
2067 | 2067 | } |
@@ -2080,13 +2080,13 @@ discard block |
||
2080 | 2080 | * @return int how many deleted (including those soft deleted) |
2081 | 2081 | * @throws \EE_Error |
2082 | 2082 | */ |
2083 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
2084 | - if($this->ID()){ |
|
2085 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2086 | - }else{ |
|
2083 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
2084 | + if ($this->ID()) { |
|
2085 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2086 | + } else { |
|
2087 | 2087 | $count = count($this->get_all_from_cache($relationName)); |
2088 | 2088 | } |
2089 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2089 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2090 | 2090 | return $count; |
2091 | 2091 | } |
2092 | 2092 | |
@@ -2102,7 +2102,7 @@ discard block |
||
2102 | 2102 | * @param string $field_name property to check |
2103 | 2103 | * @return bool TRUE if existing,FALSE if not. |
2104 | 2104 | */ |
2105 | - public function is_set( $field_name ) { |
|
2105 | + public function is_set($field_name) { |
|
2106 | 2106 | return isset($this->_fields[$field_name]); |
2107 | 2107 | } |
2108 | 2108 | |
@@ -2114,11 +2114,11 @@ discard block |
||
2114 | 2114 | * @throws EE_Error |
2115 | 2115 | * @return bool TRUE if existing, throw EE_Error if not. |
2116 | 2116 | */ |
2117 | - protected function _property_exists( $properties ) { |
|
2117 | + protected function _property_exists($properties) { |
|
2118 | 2118 | |
2119 | - foreach ( (array) $properties as $property_name ) { |
|
2119 | + foreach ((array) $properties as $property_name) { |
|
2120 | 2120 | //first make sure this property exists |
2121 | - if ( ! $this->_fields[ $property_name ] ) { |
|
2121 | + if ( ! $this->_fields[$property_name]) { |
|
2122 | 2122 | throw new EE_Error( |
2123 | 2123 | sprintf( |
2124 | 2124 | __( |
@@ -2146,7 +2146,7 @@ discard block |
||
2146 | 2146 | $fields = $this->get_model()->field_settings(FALSE); |
2147 | 2147 | $properties = array(); |
2148 | 2148 | //remove prepended underscore |
2149 | - foreach ( $fields as $field_name => $settings ) { |
|
2149 | + foreach ($fields as $field_name => $settings) { |
|
2150 | 2150 | $properties[$field_name] = $this->get($field_name); |
2151 | 2151 | } |
2152 | 2152 | return $properties; |
@@ -2176,10 +2176,10 @@ discard block |
||
2176 | 2176 | * @throws EE_Error |
2177 | 2177 | * @return mixed whatever the plugin which calls add_filter decides |
2178 | 2178 | */ |
2179 | - public function __call($methodName,$args){ |
|
2180 | - $className=get_class($this); |
|
2181 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2182 | - if ( ! has_filter( $tagName ) ) { |
|
2179 | + public function __call($methodName, $args) { |
|
2180 | + $className = get_class($this); |
|
2181 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2182 | + if ( ! has_filter($tagName)) { |
|
2183 | 2183 | throw new EE_Error( |
2184 | 2184 | sprintf( |
2185 | 2185 | __( |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | ) |
2193 | 2193 | ); |
2194 | 2194 | } |
2195 | - return apply_filters($tagName,null,$this,$args); |
|
2195 | + return apply_filters($tagName, null, $this, $args); |
|
2196 | 2196 | } |
2197 | 2197 | |
2198 | 2198 | |
@@ -2208,7 +2208,7 @@ discard block |
||
2208 | 2208 | * @throws \EE_Error |
2209 | 2209 | * NOTE: if the values haven't changed, returns 0 |
2210 | 2210 | */ |
2211 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2211 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2212 | 2212 | $query_params = array( |
2213 | 2213 | array( |
2214 | 2214 | 'EXM_key' => $meta_key, |
@@ -2216,17 +2216,17 @@ discard block |
||
2216 | 2216 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2217 | 2217 | ) |
2218 | 2218 | ); |
2219 | - if ( $previous_value !== null ) { |
|
2219 | + if ($previous_value !== null) { |
|
2220 | 2220 | $query_params[0]['EXM_value'] = $meta_value; |
2221 | 2221 | } |
2222 | - $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params ); |
|
2223 | - if ( ! $existing_rows_like_that ) { |
|
2224 | - return $this->add_extra_meta( $meta_key, $meta_value ); |
|
2222 | + $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
|
2223 | + if ( ! $existing_rows_like_that) { |
|
2224 | + return $this->add_extra_meta($meta_key, $meta_value); |
|
2225 | 2225 | } else { |
2226 | - foreach ( $existing_rows_like_that as $existing_row ) { |
|
2227 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2226 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2227 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2228 | 2228 | } |
2229 | - return count( $existing_rows_like_that ); |
|
2229 | + return count($existing_rows_like_that); |
|
2230 | 2230 | } |
2231 | 2231 | } |
2232 | 2232 | |
@@ -2243,8 +2243,8 @@ discard block |
||
2243 | 2243 | * @return boolean |
2244 | 2244 | * @throws \EE_Error |
2245 | 2245 | */ |
2246 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2247 | - if ( $unique ) { |
|
2246 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2247 | + if ($unique) { |
|
2248 | 2248 | $existing_extra_meta = EEM_Extra_Meta::instance()->get_one( |
2249 | 2249 | array( |
2250 | 2250 | array( |
@@ -2254,7 +2254,7 @@ discard block |
||
2254 | 2254 | ) |
2255 | 2255 | ) |
2256 | 2256 | ); |
2257 | - if ( $existing_extra_meta ) { |
|
2257 | + if ($existing_extra_meta) { |
|
2258 | 2258 | return false; |
2259 | 2259 | } |
2260 | 2260 | } |
@@ -2281,7 +2281,7 @@ discard block |
||
2281 | 2281 | * @return int number of extra meta rows deleted |
2282 | 2282 | * @throws \EE_Error |
2283 | 2283 | */ |
2284 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2284 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2285 | 2285 | $query_params = array( |
2286 | 2286 | array( |
2287 | 2287 | 'EXM_key' => $meta_key, |
@@ -2289,10 +2289,10 @@ discard block |
||
2289 | 2289 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2290 | 2290 | ) |
2291 | 2291 | ); |
2292 | - if ( $meta_value !== null ) { |
|
2292 | + if ($meta_value !== null) { |
|
2293 | 2293 | $query_params[0]['EXM_value'] = $meta_value; |
2294 | 2294 | } |
2295 | - return EEM_Extra_Meta::instance()->delete( $query_params ); |
|
2295 | + return EEM_Extra_Meta::instance()->delete($query_params); |
|
2296 | 2296 | } |
2297 | 2297 | |
2298 | 2298 | |
@@ -2308,25 +2308,25 @@ discard block |
||
2308 | 2308 | * @return mixed single value if $single; array if ! $single |
2309 | 2309 | * @throws \EE_Error |
2310 | 2310 | */ |
2311 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2312 | - if($single){ |
|
2313 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2314 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2311 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2312 | + if ($single) { |
|
2313 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2314 | + if ($result instanceof EE_Extra_Meta) { |
|
2315 | 2315 | return $result->value(); |
2316 | - }else{ |
|
2316 | + } else { |
|
2317 | 2317 | return $default; |
2318 | 2318 | } |
2319 | - }else{ |
|
2320 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2321 | - if($results){ |
|
2319 | + } else { |
|
2320 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2321 | + if ($results) { |
|
2322 | 2322 | $values = array(); |
2323 | - foreach($results as $result){ |
|
2324 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2323 | + foreach ($results as $result) { |
|
2324 | + if ($result instanceof EE_Extra_Meta) { |
|
2325 | 2325 | $values[$result->ID()] = $result->value(); |
2326 | 2326 | } |
2327 | 2327 | } |
2328 | 2328 | return $values; |
2329 | - }else{ |
|
2329 | + } else { |
|
2330 | 2330 | return $default; |
2331 | 2331 | } |
2332 | 2332 | } |
@@ -2348,20 +2348,20 @@ discard block |
||
2348 | 2348 | * @return array |
2349 | 2349 | * @throws \EE_Error |
2350 | 2350 | */ |
2351 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2351 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2352 | 2352 | $return_array = array(); |
2353 | - if($one_of_each_key){ |
|
2353 | + if ($one_of_each_key) { |
|
2354 | 2354 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2355 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2356 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2355 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2356 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2357 | 2357 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2358 | 2358 | } |
2359 | 2359 | } |
2360 | - }else{ |
|
2360 | + } else { |
|
2361 | 2361 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2362 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2363 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2364 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2362 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2363 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2364 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2365 | 2365 | $return_array[$extra_meta_obj->key()] = array(); |
2366 | 2366 | } |
2367 | 2367 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2379,19 +2379,19 @@ discard block |
||
2379 | 2379 | * @return string |
2380 | 2380 | * @throws \EE_Error |
2381 | 2381 | */ |
2382 | - public function name(){ |
|
2382 | + public function name() { |
|
2383 | 2383 | //find a field that's not a text field |
2384 | 2384 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2385 | - if($field_we_can_use){ |
|
2385 | + if ($field_we_can_use) { |
|
2386 | 2386 | return $this->get($field_we_can_use->get_name()); |
2387 | - }else{ |
|
2387 | + } else { |
|
2388 | 2388 | $first_few_properties = $this->model_field_array(); |
2389 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2389 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2390 | 2390 | $name_parts = array(); |
2391 | - foreach( $first_few_properties as $name=> $value ){ |
|
2391 | + foreach ($first_few_properties as $name=> $value) { |
|
2392 | 2392 | $name_parts[] = "$name:$value"; |
2393 | 2393 | } |
2394 | - return implode(",",$name_parts); |
|
2394 | + return implode(",", $name_parts); |
|
2395 | 2395 | } |
2396 | 2396 | } |
2397 | 2397 | |
@@ -2404,11 +2404,11 @@ discard block |
||
2404 | 2404 | * @return boolean |
2405 | 2405 | * @throws \EE_Error |
2406 | 2406 | */ |
2407 | - public function in_entity_map(){ |
|
2408 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2407 | + public function in_entity_map() { |
|
2408 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2409 | 2409 | //well, if we looked, did we find it in the entity map? |
2410 | 2410 | return TRUE; |
2411 | - }else{ |
|
2411 | + } else { |
|
2412 | 2412 | return FALSE; |
2413 | 2413 | } |
2414 | 2414 | } |
@@ -2419,21 +2419,21 @@ discard block |
||
2419 | 2419 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2420 | 2420 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2421 | 2421 | */ |
2422 | - public function refresh_from_db(){ |
|
2423 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2424 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2425 | - }else{ |
|
2422 | + public function refresh_from_db() { |
|
2423 | + if ($this->ID() && $this->in_entity_map()) { |
|
2424 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2425 | + } else { |
|
2426 | 2426 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2427 | 2427 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2428 | 2428 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2429 | 2429 | //absolutely nothing in it for this ID |
2430 | - if( WP_DEBUG ) { |
|
2430 | + if (WP_DEBUG) { |
|
2431 | 2431 | throw new EE_Error( |
2432 | 2432 | sprintf( |
2433 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2433 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2434 | 2434 | $this->ID(), |
2435 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2436 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2435 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2436 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2437 | 2437 | ) |
2438 | 2438 | ); |
2439 | 2439 | } |
@@ -2447,11 +2447,11 @@ discard block |
||
2447 | 2447 | * (probably a bad assumption they have made, oh well) |
2448 | 2448 | * @return string |
2449 | 2449 | */ |
2450 | - public function __toString(){ |
|
2450 | + public function __toString() { |
|
2451 | 2451 | try { |
2452 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2453 | - } catch ( Exception $e ) { |
|
2454 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
2452 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2453 | + } catch (Exception $e) { |
|
2454 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
2455 | 2455 | return ''; |
2456 | 2456 | } |
2457 | 2457 | } |
@@ -2487,16 +2487,16 @@ discard block |
||
2487 | 2487 | * @throws \EE_Error |
2488 | 2488 | */ |
2489 | 2489 | public function __sleep() { |
2490 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2491 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2492 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2493 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2494 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2495 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2490 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2491 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2492 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2493 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2494 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2495 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2496 | 2496 | } |
2497 | 2497 | } |
2498 | 2498 | } |
2499 | - return array_keys( get_object_vars( $this ) ); |
|
2499 | + return array_keys(get_object_vars($this)); |
|
2500 | 2500 | } |
2501 | 2501 | |
2502 | 2502 |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * |
863 | 863 | * @param null $field_to_order_by What field is being used as the reference point. |
864 | 864 | * @param array $query_params Any additional conditions on the query. |
865 | - * @param null $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
865 | + * @param string $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
866 | 866 | * you can indicate just the columns you want returned |
867 | 867 | * @return array|EE_Base_Class |
868 | 868 | * @throws \EE_Error |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @param null $field_to_order_by What field is being used as the reference point. |
888 | 888 | * @param array $query_params Any additional conditions on the query. |
889 | - * @param null $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
889 | + * @param string $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
890 | 890 | * you can indicate just the column you want returned |
891 | 891 | * @return array|EE_Base_Class |
892 | 892 | * @throws \EE_Error |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * This method simply returns the RAW unprocessed value for the given property in this class |
956 | 956 | * |
957 | 957 | * @param string $field_name A valid fieldname |
958 | - * @return mixed Whatever the raw value stored on the property is. |
|
958 | + * @return integer|null Whatever the raw value stored on the property is. |
|
959 | 959 | * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist. |
960 | 960 | */ |
961 | 961 | public function get_raw($field_name) { |
@@ -1055,8 +1055,8 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @access protected |
1057 | 1057 | * @param string $field_name Field on the instantiated EE_Base_Class child object |
1058 | - * @param null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
1059 | - * @param null $tm_frmt Same as above except this is for time format |
|
1058 | + * @param string|null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
1059 | + * @param null|string $tm_frmt Same as above except this is for time format |
|
1060 | 1060 | * @param string $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time. |
1061 | 1061 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
1062 | 1062 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | * sets the time on a datetime property |
1243 | 1243 | * |
1244 | 1244 | * @access protected |
1245 | - * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
|
1245 | + * @param string $time a valid time string for php datetime functions (or DateTime object) |
|
1246 | 1246 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1247 | 1247 | * @throws \EE_Error |
1248 | 1248 | */ |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | * sets the date on a datetime property |
1257 | 1257 | * |
1258 | 1258 | * @access protected |
1259 | - * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
|
1259 | + * @param string $date a valid date string for php datetime functions ( or DateTime object) |
|
1260 | 1260 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1261 | 1261 | * @throws \EE_Error |
1262 | 1262 | */ |
@@ -1313,6 +1313,7 @@ discard block |
||
1313 | 1313 | * @param mixed (array|string) $args This is the arguments that will be passed to the callback. |
1314 | 1314 | * @param string $prepend You can include something to prepend on the timestamp |
1315 | 1315 | * @param string $append You can include something to append on the timestamp |
1316 | + * @param string $args |
|
1316 | 1317 | * @throws EE_Error |
1317 | 1318 | * @return string timestamp |
1318 | 1319 | */ |
@@ -1351,7 +1352,7 @@ discard block |
||
1351 | 1352 | * This calls the `EE_Base_Class::_delete` method. Child classes wishing to change default behaviour should override |
1352 | 1353 | * `EE_Base_Class::_delete` NOT this class. |
1353 | 1354 | * |
1354 | - * @return boolean | int |
|
1355 | + * @return integer | int |
|
1355 | 1356 | * @throws \EE_Error |
1356 | 1357 | */ |
1357 | 1358 | public function delete(){ |
@@ -1384,7 +1385,7 @@ discard block |
||
1384 | 1385 | * This method is called by the public `EE_Base_Class::delete` method. Any child classes desiring to override default |
1385 | 1386 | * functionality for "delete" (which is to call `permanently_delete`) should override this method NOT `EE_Base_Class::delete` |
1386 | 1387 | * |
1387 | - * @return bool|int |
|
1388 | + * @return boolean |
|
1388 | 1389 | * @throws \EE_Error |
1389 | 1390 | */ |
1390 | 1391 | protected function _delete() { |
@@ -1673,7 +1674,7 @@ discard block |
||
1673 | 1674 | * |
1674 | 1675 | * @param array $props_n_values incoming array of properties and their values |
1675 | 1676 | * @param string $classname the classname of the child class |
1676 | - * @param null $timezone |
|
1677 | + * @param string|null $timezone |
|
1677 | 1678 | * @param array $date_formats incoming date_formats in an array where the first value is the |
1678 | 1679 | * date_format and the second value is the time format |
1679 | 1680 | * @return mixed (EE_Base_Class|bool) |
@@ -1749,7 +1750,7 @@ discard block |
||
1749 | 1750 | /** |
1750 | 1751 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
1751 | 1752 | * @param string $model_classname |
1752 | - * @param null $timezone |
|
1753 | + * @param string|null $timezone |
|
1753 | 1754 | * @return EEM_Base |
1754 | 1755 | */ |
1755 | 1756 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
3 | 3 | /** |
4 | 4 | * EE_Payment_Method class |
5 | 5 | * Should be parent of all payment method classes |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage includes/classes/EE_Checkin.class.php |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_Payment_Method extends EE_Base_Class{ |
|
11 | +class EE_Payment_Method extends EE_Base_Class { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Payment Method type object, which has all the info about this type of payment method, |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | * @return EE_Payment_Method |
25 | 25 | * @throws \EE_Error |
26 | 26 | */ |
27 | - public static function new_instance( $props_n_values = array()) { |
|
28 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
29 | - return $has_object ? $has_object : new self( $props_n_values, FALSE ); |
|
27 | + public static function new_instance($props_n_values = array()) { |
|
28 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
29 | + return $has_object ? $has_object : new self($props_n_values, FALSE); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * @return EE_Payment_Method |
37 | 37 | * @throws \EE_Error |
38 | 38 | */ |
39 | - public static function new_instance_from_db ( $props_n_values = array()) { |
|
40 | - return new self( $props_n_values, TRUE ); |
|
39 | + public static function new_instance_from_db($props_n_values = array()) { |
|
40 | + return new self($props_n_values, TRUE); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return boolean |
67 | 67 | */ |
68 | 68 | public function active() { |
69 | - return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()),$this->scope()); |
|
69 | + return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope()); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @throws \EE_Error |
79 | 79 | */ |
80 | - public function set_active(){ |
|
80 | + public function set_active() { |
|
81 | 81 | $default_scopes = array(EEM_Payment_Method::scope_cart); |
82 | - if($this->type_obj() && |
|
83 | - $this->type_obj()->payment_occurs() === EE_PMT_Base::offline){ |
|
82 | + if ($this->type_obj() && |
|
83 | + $this->type_obj()->payment_occurs() === EE_PMT_Base::offline) { |
|
84 | 84 | $default_scopes[] = EEM_Payment_Method::scope_admin; |
85 | 85 | } |
86 | 86 | $this->set_scope($default_scopes); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it. |
93 | 93 | */ |
94 | - public function deactivate(){ |
|
94 | + public function deactivate() { |
|
95 | 95 | $this->set_scope(array()); |
96 | 96 | } |
97 | 97 | |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * @param mixed $field_value |
283 | 283 | * @param boolean $use_default |
284 | 284 | */ |
285 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
286 | - if( $field_name === 'PMD_type' ){ |
|
285 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
286 | + if ($field_name === 'PMD_type') { |
|
287 | 287 | //the type has probably changed, so forget about its old type object |
288 | 288 | $this->_type_obj = NULL; |
289 | 289 | } |
@@ -357,26 +357,26 @@ discard block |
||
357 | 357 | * @return EE_PMT_Base |
358 | 358 | * @throws EE_Error |
359 | 359 | */ |
360 | - public function type_obj(){ |
|
361 | - if( ! $this->_type_obj ) { |
|
362 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
363 | - if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $this->type() )) { |
|
364 | - $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type( $this->type() ); |
|
365 | - if ( ! class_exists( $class_name )) { |
|
360 | + public function type_obj() { |
|
361 | + if ( ! $this->_type_obj) { |
|
362 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
363 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) { |
|
364 | + $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type()); |
|
365 | + if ( ! class_exists($class_name)) { |
|
366 | 366 | throw new EE_Error( |
367 | 367 | sprintf( |
368 | - __( 'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s', 'event_espresso' ), |
|
368 | + __('An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s', 'event_espresso'), |
|
369 | 369 | $class_name, |
370 | 370 | '<br />', |
371 | - '<a href="' . admin_url('plugins.php') . '">', |
|
371 | + '<a href="'.admin_url('plugins.php').'">', |
|
372 | 372 | '</a>' |
373 | 373 | ) |
374 | 374 | ); |
375 | 375 | } |
376 | - $r = new ReflectionClass( $class_name ); |
|
377 | - $this->_type_obj = $r->newInstanceArgs( array( $this )); |
|
376 | + $r = new ReflectionClass($class_name); |
|
377 | + $this->_type_obj = $r->newInstanceArgs(array($this)); |
|
378 | 378 | } else { |
379 | - throw new EE_Error( sprintf( __( 'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s', 'event_espresso' ), $this->type(), implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names() ) ) ); |
|
379 | + throw new EE_Error(sprintf(__('A payment method of type "%1$s" does not exist. Only ones existing are: %2$s', 'event_espresso'), $this->type(), implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names()))); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | return $this->_type_obj; |
@@ -389,18 +389,18 @@ discard block |
||
389 | 389 | * and the extra meta. Mostly used for passing off ot gateways. * |
390 | 390 | * @return array |
391 | 391 | */ |
392 | - public function settings_array(){ |
|
392 | + public function settings_array() { |
|
393 | 393 | $fields = $this->model_field_array(); |
394 | 394 | $extra_meta = $this->all_extra_meta_array(); |
395 | 395 | //remove the model's prefix from the fields |
396 | 396 | $combined_settings_array = array(); |
397 | - foreach($fields as $key => $value){ |
|
398 | - if(strpos($key, 'PMD_')===0){ |
|
397 | + foreach ($fields as $key => $value) { |
|
398 | + if (strpos($key, 'PMD_') === 0) { |
|
399 | 399 | $key_sans_model_prefix = str_replace('PMD_', '', $key); |
400 | 400 | $combined_settings_array [$key_sans_model_prefix] = $value; |
401 | 401 | } |
402 | 402 | } |
403 | - $combined_settings_array = array_merge( $extra_meta,$combined_settings_array ); |
|
403 | + $combined_settings_array = array_merge($extra_meta, $combined_settings_array); |
|
404 | 404 | return $combined_settings_array; |
405 | 405 | } |
406 | 406 | |
@@ -414,12 +414,12 @@ discard block |
||
414 | 414 | * @return string of HTML for displaying the button |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - public function button_html( $url = '', $css_class = '' ){ |
|
417 | + public function button_html($url = '', $css_class = '') { |
|
418 | 418 | $payment_occurs = $this->type_obj()->payment_occurs(); |
419 | 419 | return ' |
420 | - <div id="' . $this->slug() . '-payment-option-dv" class="'. $payment_occurs .'-payment-gateway reg-page-payment-option-dv' . $css_class . '"> |
|
421 | - <a id="payment-gateway-button-' . $this->slug() . '" class="reg-page-payment-option-lnk" rel="' . $this->slug() . '" href="' . $url . '" > |
|
422 | - <img src="' . $this->button_url() . '" alt="' . sprintf( esc_attr__( 'Pay using %s', 'event_espresso' ), $this->get_pretty('PMD_name','form_input') ) . '" /> |
|
420 | + <div id="' . $this->slug().'-payment-option-dv" class="'.$payment_occurs.'-payment-gateway reg-page-payment-option-dv'.$css_class.'"> |
|
421 | + <a id="payment-gateway-button-' . $this->slug().'" class="reg-page-payment-option-lnk" rel="'.$this->slug().'" href="'.$url.'" > |
|
422 | + <img src="' . $this->button_url().'" alt="'.sprintf(esc_attr__('Pay using %s', 'event_espresso'), $this->get_pretty('PMD_name', 'form_input')).'" /> |
|
423 | 423 | </a> |
424 | 424 | </div> |
425 | 425 | '; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * @return EE_Currency[] |
435 | 435 | * @throws \EE_Error |
436 | 436 | */ |
437 | - public function get_all_usable_currencies(){ |
|
437 | + public function get_all_usable_currencies() { |
|
438 | 438 | return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj()); |
439 | 439 | } |
440 | 440 | |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | * @return boolean |
448 | 448 | * @throws \EE_Error |
449 | 449 | */ |
450 | - public function usable_for_currency( $currency_code ) { |
|
451 | - foreach( $this->get_all_usable_currencies() as $currency_obj ) { |
|
452 | - if( $currency_obj->ID() === $currency_code ){ |
|
450 | + public function usable_for_currency($currency_code) { |
|
451 | + foreach ($this->get_all_usable_currencies() as $currency_obj) { |
|
452 | + if ($currency_obj->ID() === $currency_code) { |
|
453 | 453 | return TRUE; |
454 | 454 | } |
455 | 455 | } |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return bool |
465 | 465 | * @throws \EE_Error |
466 | 466 | */ |
467 | - public function is_on_site(){ |
|
467 | + public function is_on_site() { |
|
468 | 468 | return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite; |
469 | 469 | } |
470 | 470 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @return bool |
477 | 477 | * @throws \EE_Error |
478 | 478 | */ |
479 | - public function is_off_site(){ |
|
479 | + public function is_off_site() { |
|
480 | 480 | return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite; |
481 | 481 | } |
482 | 482 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * @return bool |
489 | 489 | * @throws \EE_Error |
490 | 490 | */ |
491 | - public function is_off_line(){ |
|
491 | + public function is_off_line() { |
|
492 | 492 | return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline; |
493 | 493 | } |
494 | 494 | |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | * to load the required classes, and don't need them at the time of unserialization |
499 | 499 | * @return array |
500 | 500 | */ |
501 | - public function __sleep(){ |
|
502 | - $properties = get_object_vars( $this ); |
|
503 | - unset( $properties[ '_type_obj' ] ); |
|
504 | - return array_keys( $properties ); |
|
501 | + public function __sleep() { |
|
502 | + $properties = get_object_vars($this); |
|
503 | + unset($properties['_type_obj']); |
|
504 | + return array_keys($properties); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 |