@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\commands\CommandHandler; |
7 | 7 | use EventEspresso\core\services\commands\CommandInterface; |
8 | 8 | |
9 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param \EventEspresso\core\services\commands\CommandInterface $command |
49 | 49 | * @return boolean |
50 | 50 | */ |
51 | - public function handle( CommandInterface $command ) |
|
51 | + public function handle(CommandInterface $command) |
|
52 | 52 | { |
53 | 53 | /** @var UpdateRegistrationAndTransactionAfterChangeCommand $command */ |
54 | - if ( ! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand ) { |
|
54 | + if ( ! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand) { |
|
55 | 55 | throw new InvalidEntityException( |
56 | 56 | get_class($command), |
57 | 57 | 'UpdateRegistrationAndTransactionAfterChangeCommand' |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\exceptions; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param \Exception $exception |
26 | 26 | */ |
27 | - public function __construct( \Exception $exception ) { |
|
28 | - $this->log( $exception ); |
|
27 | + public function __construct(\Exception $exception) { |
|
28 | + $this->log($exception); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
@@ -36,22 +36,22 @@ discard block |
||
36 | 36 | * @param \Exception $exception |
37 | 37 | * @param int $time |
38 | 38 | */ |
39 | - public function log( \Exception $exception, $time = 0 ) { |
|
40 | - if ( ! $time ) { |
|
39 | + public function log(\Exception $exception, $time = 0) { |
|
40 | + if ( ! $time) { |
|
41 | 41 | $time = time(); |
42 | 42 | } |
43 | 43 | $exception_log = '----------------------------------------------------------------------------------------'; |
44 | 44 | $exception_log .= PHP_EOL; |
45 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
46 | - $exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL; |
|
47 | - $exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL; |
|
48 | - $exception_log .= 'File: ' . $exception->getFile() . PHP_EOL; |
|
49 | - $exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL; |
|
50 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
51 | - $exception_log .= $exception->getTraceAsString() . PHP_EOL; |
|
45 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
46 | + $exception_log .= 'Message: '.$exception->getMessage().PHP_EOL; |
|
47 | + $exception_log .= 'Code: '.$exception->getCode().PHP_EOL; |
|
48 | + $exception_log .= 'File: '.$exception->getFile().PHP_EOL; |
|
49 | + $exception_log .= 'Line No: '.$exception->getLine().PHP_EOL; |
|
50 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
51 | + $exception_log .= $exception->getTraceAsString().PHP_EOL; |
|
52 | 52 | $exception_log .= '----------------------------------------------------------------------------------------'; |
53 | - $exception_log .= PHP_EOL; |
|
54 | - error_log( $exception_log ); |
|
53 | + $exception_log .= PHP_EOL; |
|
54 | + error_log($exception_log); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
2 | 2 | |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * EE_Registration class |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * date_format and the second value is the time format |
44 | 44 | * @return EE_Registration |
45 | 45 | */ |
46 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
47 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
48 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
46 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
47 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
48 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * the website will be used. |
57 | 57 | * @return EE_Registration |
58 | 58 | */ |
59 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
60 | - return new self( $props_n_values, TRUE, $timezone ); |
|
59 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
60 | + return new self($props_n_values, TRUE, $timezone); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @access public |
69 | 69 | * @param int $EVT_ID Event ID |
70 | 70 | */ |
71 | - public function set_event( $EVT_ID = 0 ) { |
|
72 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
71 | + public function set_event($EVT_ID = 0) { |
|
72 | + $this->set('EVT_ID', $EVT_ID); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | * @param mixed $field_value |
81 | 81 | * @param bool $use_default |
82 | 82 | */ |
83 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
84 | - switch( $field_name ) { |
|
83 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
84 | + switch ($field_name) { |
|
85 | 85 | case 'REG_code' : |
86 | - if ( ! empty( $field_value ) && $this->reg_code() == '' ) { |
|
87 | - $this->set_reg_code( $field_value, $use_default ); |
|
86 | + if ( ! empty($field_value) && $this->reg_code() == '') { |
|
87 | + $this->set_reg_code($field_value, $use_default); |
|
88 | 88 | } |
89 | 89 | break; |
90 | 90 | case 'STS_ID' : |
91 | - $this->set_status( $field_value, $use_default ); |
|
91 | + $this->set_status($field_value, $use_default); |
|
92 | 92 | break; |
93 | 93 | default : |
94 | - parent::set( $field_name, $field_value, $use_default ); |
|
94 | + parent::set($field_name, $field_value, $use_default); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -109,30 +109,30 @@ discard block |
||
109 | 109 | * @return bool |
110 | 110 | * @throws \EE_Error |
111 | 111 | */ |
112 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
112 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
113 | 113 | // get current REG_Status |
114 | 114 | $old_STS_ID = $this->status_ID(); |
115 | 115 | // if status has changed |
116 | - if ( $old_STS_ID !== $new_STS_ID ) { |
|
116 | + if ($old_STS_ID !== $new_STS_ID) { |
|
117 | 117 | // TO approved |
118 | - if ( $new_STS_ID === EEM_Registration::status_id_approved ) { |
|
118 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
119 | 119 | // reserve a space by incrementing ticket and datetime sold values |
120 | 120 | $this->_reserve_registration_space(); |
121 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
121 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
122 | 122 | // OR FROM approved |
123 | - } else if ( $old_STS_ID === EEM_Registration::status_id_approved ) { |
|
123 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
124 | 124 | // release a space by decrementing ticket and datetime sold values |
125 | 125 | $this->_release_registration_space(); |
126 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
126 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
127 | 127 | } |
128 | 128 | // update status |
129 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
130 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
129 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
130 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
131 | 131 | return TRUE; |
132 | - }else{ |
|
132 | + } else { |
|
133 | 133 | //even though the old value matches the new value, it's still good to |
134 | 134 | //allow the parent set method to have a say |
135 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
135 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
136 | 136 | return TRUE; |
137 | 137 | } |
138 | 138 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @access public |
145 | 145 | */ |
146 | 146 | public function status_ID() { |
147 | - return $this->get( 'STS_ID' ); |
|
147 | + return $this->get('STS_ID'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * @param boolean $include_archived whether to include archived tickets or not. |
170 | 170 | * @return EE_Ticket |
171 | 171 | */ |
172 | - public function ticket( $include_archived = TRUE ) { |
|
172 | + public function ticket($include_archived = TRUE) { |
|
173 | 173 | $query_params = array(); |
174 | - if ( $include_archived ) { |
|
175 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
174 | + if ($include_archived) { |
|
175 | + $query_params['default_where_conditions'] = 'none'; |
|
176 | 176 | } |
177 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
177 | + return $this->get_first_related('Ticket', $query_params); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function wp_user() { |
204 | 204 | $event = $this->event(); |
205 | - if ( $event instanceof EE_Event ) { |
|
205 | + if ($event instanceof EE_Event) { |
|
206 | 206 | return $event->wp_user(); |
207 | 207 | } |
208 | 208 | return 0; |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * @access public |
229 | 229 | * @param int $ATT_ID Attendee ID |
230 | 230 | */ |
231 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
232 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
231 | + public function set_attendee_id($ATT_ID = 0) { |
|
232 | + $this->set('ATT_ID', $ATT_ID); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @access public |
241 | 241 | * @param int $TXN_ID Transaction ID |
242 | 242 | */ |
243 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
244 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
243 | + public function set_transaction_id($TXN_ID = 0) { |
|
244 | + $this->set('TXN_ID', $TXN_ID); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @access public |
253 | 253 | * @param string $REG_session PHP Session ID |
254 | 254 | */ |
255 | - public function set_session( $REG_session = '' ) { |
|
256 | - $this->set( 'REG_session', $REG_session ); |
|
255 | + public function set_session($REG_session = '') { |
|
256 | + $this->set('REG_session', $REG_session); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | * @access public |
265 | 265 | * @param string $REG_url_link Registration URL Link |
266 | 266 | */ |
267 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
268 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
267 | + public function set_reg_url_link($REG_url_link = '') { |
|
268 | + $this->set('REG_url_link', $REG_url_link); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | * @access public |
277 | 277 | * @param int $REG_count Primary Attendee |
278 | 278 | */ |
279 | - public function set_count( $REG_count = 1 ) { |
|
280 | - $this->set( 'REG_count', $REG_count ); |
|
279 | + public function set_count($REG_count = 1) { |
|
280 | + $this->set('REG_count', $REG_count); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | * @access public |
289 | 289 | * @param boolean $REG_group_size Group Registration |
290 | 290 | */ |
291 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
292 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
291 | + public function set_group_size($REG_group_size = FALSE) { |
|
292 | + $this->set('REG_group_size', $REG_group_size); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * @access public |
373 | 373 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
374 | 374 | */ |
375 | - public function set_reg_date( $REG_date = FALSE ) { |
|
376 | - $this->set( 'REG_date', $REG_date ); |
|
375 | + public function set_reg_date($REG_date = FALSE) { |
|
376 | + $this->set('REG_date', $REG_date); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | * @access public |
385 | 385 | * @param float $REG_final_price |
386 | 386 | */ |
387 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
388 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
387 | + public function set_final_price($REG_final_price = 0.00) { |
|
388 | + $this->set('REG_final_price', $REG_final_price); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -396,8 +396,8 @@ discard block |
||
396 | 396 | * @access public |
397 | 397 | * @param float $REG_paid |
398 | 398 | */ |
399 | - public function set_paid( $REG_paid = 0.00 ) { |
|
400 | - $this->set( 'REG_paid', $REG_paid ); |
|
399 | + public function set_paid($REG_paid = 0.00) { |
|
400 | + $this->set('REG_paid', $REG_paid); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @access public |
409 | 409 | * @param boolean $REG_att_is_going Attendee Is Going |
410 | 410 | */ |
411 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
412 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
411 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
412 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * @return EE_Attendee |
420 | 420 | */ |
421 | 421 | public function attendee() { |
422 | - return $this->get_first_related( 'Attendee' ); |
|
422 | + return $this->get_first_related('Attendee'); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @access public |
430 | 430 | */ |
431 | 431 | public function event_ID() { |
432 | - return $this->get( 'EVT_ID' ); |
|
432 | + return $this->get('EVT_ID'); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | public function event_name() { |
442 | 442 | $event = $this->event_obj(); |
443 | - if ( $event ) { |
|
443 | + if ($event) { |
|
444 | 444 | return $event->name(); |
445 | 445 | } else { |
446 | 446 | return NULL; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @return EE_Event |
455 | 455 | */ |
456 | 456 | public function event_obj() { |
457 | - return $this->get_first_related( 'Event' ); |
|
457 | + return $this->get_first_related('Event'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @access public |
465 | 465 | */ |
466 | 466 | public function attendee_ID() { |
467 | - return $this->get( 'ATT_ID' ); |
|
467 | + return $this->get('ATT_ID'); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * @access public |
475 | 475 | */ |
476 | 476 | public function session_ID() { |
477 | - return $this->get( 'REG_session' ); |
|
477 | + return $this->get('REG_session'); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
485 | 485 | * @return string |
486 | 486 | */ |
487 | - public function receipt_url( $messenger = 'html' ) { |
|
487 | + public function receipt_url($messenger = 'html') { |
|
488 | 488 | |
489 | 489 | /** |
490 | 490 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @since 4.5.0 |
493 | 493 | */ |
494 | 494 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
495 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
495 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
496 | 496 | |
497 | - if ( $has_custom ) { |
|
498 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
497 | + if ($has_custom) { |
|
498 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
499 | 499 | } |
500 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
500 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | |
@@ -508,28 +508,28 @@ discard block |
||
508 | 508 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
509 | 509 | * @return string |
510 | 510 | */ |
511 | - public function invoice_url( $messenger = 'html' ) { |
|
511 | + public function invoice_url($messenger = 'html') { |
|
512 | 512 | /** |
513 | 513 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
514 | 514 | * |
515 | 515 | * @since 4.5.0 |
516 | 516 | */ |
517 | 517 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
518 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
518 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
519 | 519 | |
520 | - if ( $has_custom ) { |
|
521 | - if ( $messenger == 'html' ) { |
|
522 | - return $this->invoice_url( 'launch' ); |
|
520 | + if ($has_custom) { |
|
521 | + if ($messenger == 'html') { |
|
522 | + return $this->invoice_url('launch'); |
|
523 | 523 | } |
524 | 524 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
525 | 525 | |
526 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
527 | - if ( $messenger == 'html' ) { |
|
526 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
527 | + if ($messenger == 'html') { |
|
528 | 528 | $query_args['html'] = TRUE; |
529 | 529 | } |
530 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
530 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
531 | 531 | } |
532 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
532 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @throws \EE_Error |
543 | 543 | */ |
544 | 544 | public function reg_url_link() { |
545 | - return (string)$this->get( 'REG_url_link' ); |
|
545 | + return (string) $this->get('REG_url_link'); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
553 | 553 | * @return void |
554 | 554 | */ |
555 | - public function e_invoice_url( $type = 'launch' ) { |
|
556 | - echo $this->invoice_url( $type ); |
|
555 | + public function e_invoice_url($type = 'launch') { |
|
556 | + echo $this->invoice_url($type); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | * @return string |
574 | 574 | */ |
575 | 575 | public function payment_overview_url() { |
576 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
576 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @return string |
585 | 585 | */ |
586 | 586 | public function edit_attendee_information_url() { |
587 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
587 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * @return string |
595 | 595 | */ |
596 | 596 | public function get_admin_edit_url() { |
597 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
597 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @access public |
605 | 605 | */ |
606 | 606 | public function is_primary_registrant() { |
607 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
607 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | |
@@ -613,12 +613,12 @@ discard block |
||
613 | 613 | * This returns the primary registration object for this registration group (which may be this object). |
614 | 614 | * @return EE_Registration |
615 | 615 | */ |
616 | - public function get_primary_registration() { |
|
617 | - if ( $this->is_primary_registrant() ) |
|
616 | + public function get_primary_registration() { |
|
617 | + if ($this->is_primary_registrant()) |
|
618 | 618 | return $this; |
619 | 619 | |
620 | 620 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
621 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
621 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
622 | 622 | return $primary_registrant; |
623 | 623 | } |
624 | 624 | |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @access public |
630 | 630 | */ |
631 | 631 | public function count() { |
632 | - return $this->get( 'REG_count' ); |
|
632 | + return $this->get('REG_count'); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | * @access public |
640 | 640 | */ |
641 | 641 | public function group_size() { |
642 | - return $this->get( 'REG_group_size' ); |
|
642 | + return $this->get('REG_group_size'); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | * @access public |
650 | 650 | */ |
651 | 651 | public function date() { |
652 | - return $this->get( 'REG_date' ); |
|
652 | + return $this->get('REG_date'); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | |
@@ -660,8 +660,8 @@ discard block |
||
660 | 660 | * @param string $time_format |
661 | 661 | * @return string |
662 | 662 | */ |
663 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
664 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
663 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
664 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * @return float |
675 | 675 | */ |
676 | 676 | public function final_price() { |
677 | - return $this->get( 'REG_final_price' ); |
|
677 | + return $this->get('REG_final_price'); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @return string |
686 | 686 | */ |
687 | 687 | public function pretty_final_price() { |
688 | - return $this->get_pretty( 'REG_final_price' ); |
|
688 | + return $this->get_pretty('REG_final_price'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | * @return float |
697 | 697 | */ |
698 | 698 | public function paid() { |
699 | - return $this->get( 'REG_paid' ); |
|
699 | + return $this->get('REG_paid'); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @return float |
708 | 708 | */ |
709 | 709 | public function pretty_paid() { |
710 | - return $this->get_pretty( 'REG_paid' ); |
|
710 | + return $this->get_pretty('REG_paid'); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | |
@@ -719,11 +719,11 @@ discard block |
||
719 | 719 | * @param array $requires_payment |
720 | 720 | * @return bool |
721 | 721 | */ |
722 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
722 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
723 | 723 | // these reg statuses require payment (if event is not free) |
724 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
724 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
725 | 725 | if ( |
726 | - in_array( $this->status_ID(), $requires_payment ) && |
|
726 | + in_array($this->status_ID(), $requires_payment) && |
|
727 | 727 | $this->final_price() != 0 && |
728 | 728 | $this->final_price() != $this->paid() |
729 | 729 | ) { |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | * @param bool $show_icons |
741 | 741 | * @return void |
742 | 742 | */ |
743 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
744 | - echo $this->pretty_status( $show_icons ); |
|
743 | + public function e_pretty_status($show_icons = FALSE) { |
|
744 | + echo $this->pretty_status($show_icons); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | |
@@ -752,10 +752,10 @@ discard block |
||
752 | 752 | * @param bool $show_icons |
753 | 753 | * @return string |
754 | 754 | */ |
755 | - public function pretty_status( $show_icons = FALSE ) { |
|
756 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
755 | + public function pretty_status($show_icons = FALSE) { |
|
756 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
757 | 757 | $icon = ''; |
758 | - switch ( $this->status_ID() ) { |
|
758 | + switch ($this->status_ID()) { |
|
759 | 759 | case EEM_Registration::status_id_approved: |
760 | 760 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
761 | 761 | break; |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
776 | 776 | break; |
777 | 777 | } |
778 | - return $icon . $status[ $this->status_ID() ]; |
|
778 | + return $icon.$status[$this->status_ID()]; |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * @access public |
786 | 786 | */ |
787 | 787 | public function att_is_going() { |
788 | - return $this->get( 'REG_att_is_going' ); |
|
788 | + return $this->get('REG_att_is_going'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | |
@@ -795,8 +795,8 @@ discard block |
||
795 | 795 | * @param array $query_params like EEM_Base::get_all |
796 | 796 | * @return EE_Answer[] |
797 | 797 | */ |
798 | - public function answers( $query_params = NULL ) { |
|
799 | - return $this->get_many_related( 'Answer', $query_params ); |
|
798 | + public function answers($query_params = NULL) { |
|
799 | + return $this->get_many_related('Answer', $query_params); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | |
@@ -810,9 +810,9 @@ discard block |
||
810 | 810 | * (because the answer might be an array of answer values, so passing pretty_value=true |
811 | 811 | * will convert it into some kind of string) |
812 | 812 | */ |
813 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
813 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
814 | 814 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
815 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
815 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | |
@@ -825,13 +825,13 @@ discard block |
||
825 | 825 | */ |
826 | 826 | public function question_groups() { |
827 | 827 | $question_groups = array(); |
828 | - if ( $this->event() instanceof EE_Event ) { |
|
828 | + if ($this->event() instanceof EE_Event) { |
|
829 | 829 | $question_groups = $this->event()->question_groups( |
830 | 830 | array( |
831 | 831 | array( |
832 | 832 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
833 | 833 | ), |
834 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
834 | + 'order_by' => array('QSG_order' => 'ASC') |
|
835 | 835 | ) |
836 | 836 | ); |
837 | 837 | } |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | */ |
849 | 849 | public function count_question_groups() { |
850 | 850 | $qg_count = 0; |
851 | - if ( $this->event() instanceof EE_Event ) { |
|
851 | + if ($this->event() instanceof EE_Event) { |
|
852 | 852 | $qg_count = $this->event()->count_related( |
853 | 853 | 'Question_Group', |
854 | 854 | array( |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * @return string |
870 | 870 | */ |
871 | 871 | public function reg_date() { |
872 | - return $this->get_datetime( 'REG_date' ); |
|
872 | + return $this->get_datetime('REG_date'); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | * @return EE_Datetime_Ticket |
882 | 882 | */ |
883 | 883 | public function datetime_ticket() { |
884 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
884 | + return $this->get_first_related('Datetime_Ticket'); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -891,15 +891,15 @@ discard block |
||
891 | 891 | * @param EE_Datetime_Ticket $datetime_ticket |
892 | 892 | * @return EE_Datetime_Ticket |
893 | 893 | */ |
894 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
895 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
894 | + public function set_datetime_ticket($datetime_ticket) { |
|
895 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
896 | 896 | } |
897 | 897 | /** |
898 | 898 | * Gets deleted |
899 | 899 | * @return boolean |
900 | 900 | */ |
901 | 901 | public function deleted() { |
902 | - return $this->get( 'REG_deleted' ); |
|
902 | + return $this->get('REG_deleted'); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | * @return boolean |
909 | 909 | */ |
910 | 910 | public function set_deleted($deleted) { |
911 | - $this->set( 'REG_deleted', $deleted ); |
|
911 | + $this->set('REG_deleted', $deleted); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | * @return EE_Status |
919 | 919 | */ |
920 | 920 | public function status_obj() { |
921 | - return $this->get_first_related( 'Status' ); |
|
921 | + return $this->get_first_related('Status'); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | * @return int |
930 | 930 | */ |
931 | 931 | public function count_checkins() { |
932 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
932 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | * @return int |
940 | 940 | */ |
941 | 941 | public function count_checkins_not_checkedout() { |
942 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
942 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | |
@@ -952,20 +952,20 @@ discard block |
||
952 | 952 | * |
953 | 953 | * @return bool |
954 | 954 | */ |
955 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
956 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
955 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
956 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
957 | 957 | |
958 | 958 | //first check registration status |
959 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
959 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
960 | 960 | return false; |
961 | 961 | } |
962 | 962 | //is there a datetime ticket that matches this dtt_ID? |
963 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
963 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
964 | 964 | return false; |
965 | 965 | } |
966 | 966 | |
967 | 967 | //final check is against TKT_uses |
968 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
968 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | |
@@ -978,10 +978,10 @@ discard block |
||
978 | 978 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
979 | 979 | * @return bool true means can checkin. false means cannot checkin. |
980 | 980 | */ |
981 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
982 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
981 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
982 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
983 | 983 | |
984 | - if ( ! $DTT_ID ) { |
|
984 | + if ( ! $DTT_ID) { |
|
985 | 985 | return false; |
986 | 986 | } |
987 | 987 | |
@@ -989,23 +989,23 @@ discard block |
||
989 | 989 | |
990 | 990 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
991 | 991 | // or not. |
992 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
992 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
993 | 993 | return true; |
994 | 994 | } |
995 | 995 | |
996 | 996 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
997 | 997 | //go ahead and toggle. |
998 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
998 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
999 | 999 | return true; |
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
1003 | 1003 | //disallows further check-ins. |
1004 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
1004 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
1005 | 1005 | // checkins have already reached their max number of uses |
1006 | 1006 | // so registrant can NOT checkin |
1007 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1008 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1007 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1008 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1009 | 1009 | return false; |
1010 | 1010 | } |
1011 | 1011 | return true; |
@@ -1026,15 +1026,15 @@ discard block |
||
1026 | 1026 | * @param bool $verify If true then can_checkin() is used to verify whether the person can be checked in or not. Otherwise this forces change in checkin status. |
1027 | 1027 | * @return int|BOOL the chk_in status toggled to OR false if nothing got changed. |
1028 | 1028 | */ |
1029 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1030 | - if ( empty( $DTT_ID ) ) { |
|
1029 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1030 | + if (empty($DTT_ID)) { |
|
1031 | 1031 | $datetime = $this->get_related_primary_datetime(); |
1032 | 1032 | $DTT_ID = $datetime->ID(); |
1033 | 1033 | // verify the registration can checkin for the given DTT_ID |
1034 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1034 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1035 | 1035 | EE_Error::add_error( |
1036 | 1036 | sprintf( |
1037 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1037 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1038 | 1038 | $this->ID(), |
1039 | 1039 | $DTT_ID |
1040 | 1040 | ), |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1049 | 1049 | ); |
1050 | 1050 | //start by getting the current status so we know what status we'll be changing to. |
1051 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1052 | - $status_to = $status_paths[ $cur_status ]; |
|
1051 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1052 | + $status_to = $status_paths[$cur_status]; |
|
1053 | 1053 | // database only records true for checked IN or false for checked OUT |
1054 | 1054 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1055 | 1055 | $new_status = $status_to == EE_Registration::checkin_status_in ? true : false; |
@@ -1057,24 +1057,24 @@ discard block |
||
1057 | 1057 | // because we are keeping track of Check-ins over time. |
1058 | 1058 | // Eventually we'll probably want to show a list table |
1059 | 1059 | // for the individual Check-ins so that they can be managed. |
1060 | - $checkin = EE_Checkin::new_instance( array( |
|
1060 | + $checkin = EE_Checkin::new_instance(array( |
|
1061 | 1061 | 'REG_ID' => $this->ID(), |
1062 | 1062 | 'DTT_ID' => $DTT_ID, |
1063 | 1063 | 'CHK_in' => $new_status |
1064 | - ) ); |
|
1064 | + )); |
|
1065 | 1065 | // if the record could not be saved then return false |
1066 | - if ( $checkin->save() === 0 ) { |
|
1067 | - if ( WP_DEBUG ) { |
|
1066 | + if ($checkin->save() === 0) { |
|
1067 | + if (WP_DEBUG) { |
|
1068 | 1068 | global $wpdb; |
1069 | 1069 | $error = sprintf( |
1070 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1070 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1071 | 1071 | '<br />', |
1072 | 1072 | $wpdb->last_error |
1073 | 1073 | ); |
1074 | 1074 | } else { |
1075 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1075 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1076 | 1076 | } |
1077 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1077 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1078 | 1078 | return false; |
1079 | 1079 | } |
1080 | 1080 | return $status_to; |
@@ -1098,19 +1098,19 @@ discard block |
||
1098 | 1098 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
1099 | 1099 | * @return int Integer representing Check-in status. |
1100 | 1100 | */ |
1101 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = NULL ) { |
|
1102 | - if ( empty( $DTT_ID ) && ! $checkin instanceof EE_Checkin ) { |
|
1101 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = NULL) { |
|
1102 | + if (empty($DTT_ID) && ! $checkin instanceof EE_Checkin) { |
|
1103 | 1103 | $datetime = $this->get_related_primary_datetime(); |
1104 | - if ( ! $datetime instanceof EE_Datetime ) { |
|
1104 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1105 | 1105 | return 0; |
1106 | 1106 | } |
1107 | 1107 | $DTT_ID = $datetime->ID(); |
1108 | 1108 | //verify the registration can checkin for the given DTT_ID |
1109 | 1109 | } |
1110 | 1110 | //get checkin object (if exists) |
1111 | - $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ), 'order_by' => array( 'CHK_timestamp' => 'DESC' ) ) ); |
|
1112 | - if ( $checkin instanceof EE_Checkin ) { |
|
1113 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1111 | + $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related('Checkin', array(array('DTT_ID' => $DTT_ID), 'order_by' => array('CHK_timestamp' => 'DESC'))); |
|
1112 | + if ($checkin instanceof EE_Checkin) { |
|
1113 | + if ($checkin->get('CHK_in')) { |
|
1114 | 1114 | return EE_Registration::checkin_status_in; //checked in |
1115 | 1115 | } else { |
1116 | 1116 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1128,28 +1128,28 @@ discard block |
||
1128 | 1128 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1129 | 1129 | * @return string internationalized message |
1130 | 1130 | */ |
1131 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1131 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1132 | 1132 | //let's get the attendee first so we can include the name of the attendee |
1133 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1134 | - if ( $attendee instanceof EE_Attendee ) { |
|
1135 | - if ( $error ) { |
|
1136 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1133 | + $attendee = $this->get_first_related('Attendee'); |
|
1134 | + if ($attendee instanceof EE_Attendee) { |
|
1135 | + if ($error) { |
|
1136 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1137 | 1137 | } |
1138 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1138 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1139 | 1139 | //what is the status message going to be? |
1140 | - switch ( $cur_status ) { |
|
1140 | + switch ($cur_status) { |
|
1141 | 1141 | case EE_Registration::checkin_status_never : |
1142 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1142 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1143 | 1143 | break; |
1144 | 1144 | case EE_Registration::checkin_status_in : |
1145 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1145 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1146 | 1146 | break; |
1147 | 1147 | case EE_Registration::checkin_status_out : |
1148 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1148 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1149 | 1149 | break; |
1150 | 1150 | } |
1151 | 1151 | } |
1152 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1152 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * @access public |
1175 | 1175 | */ |
1176 | 1176 | public function reg_code() { |
1177 | - return $this->get( 'REG_code' ); |
|
1177 | + return $this->get('REG_code'); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | * @access public |
1185 | 1185 | */ |
1186 | 1186 | public function transaction_ID() { |
1187 | - return $this->get( 'TXN_ID' ); |
|
1187 | + return $this->get('TXN_ID'); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | * @return int |
1194 | 1194 | */ |
1195 | 1195 | public function ticket_ID() { |
1196 | - return $this->get( 'TKT_ID' ); |
|
1196 | + return $this->get('TKT_ID'); |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | |
@@ -1205,17 +1205,17 @@ discard block |
||
1205 | 1205 | * @param string $REG_code Registration Code |
1206 | 1206 | * @param boolean $use_default |
1207 | 1207 | */ |
1208 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1209 | - if ( empty( $REG_code )) { |
|
1210 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1208 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1209 | + if (empty($REG_code)) { |
|
1210 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1211 | 1211 | return; |
1212 | 1212 | } |
1213 | - if ( ! $this->reg_code() ) { |
|
1214 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1213 | + if ( ! $this->reg_code()) { |
|
1214 | + parent::set('REG_code', $REG_code, $use_default); |
|
1215 | 1215 | } else { |
1216 | 1216 | EE_Error::doing_it_wrong( |
1217 | - __CLASS__ . '::' . __FUNCTION__, |
|
1218 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1217 | + __CLASS__.'::'.__FUNCTION__, |
|
1218 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1219 | 1219 | '4.6.0' |
1220 | 1220 | ); |
1221 | 1221 | } |
@@ -1235,17 +1235,17 @@ discard block |
||
1235 | 1235 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1236 | 1236 | */ |
1237 | 1237 | public function get_all_other_registrations_in_group() { |
1238 | - if ( $this->group_size() < 2 ) { |
|
1238 | + if ($this->group_size() < 2) { |
|
1239 | 1239 | return array(); |
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | $query[0] = array( |
1243 | 1243 | 'TXN_ID' => $this->transaction_ID(), |
1244 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1244 | + 'REG_ID' => array('!=', $this->ID()), |
|
1245 | 1245 | 'TKT_ID' => $this->ticket_ID() |
1246 | 1246 | ); |
1247 | 1247 | |
1248 | - $registrations = $this->get_model()->get_all( $query ); |
|
1248 | + $registrations = $this->get_model()->get_all($query); |
|
1249 | 1249 | return $registrations; |
1250 | 1250 | } |
1251 | 1251 | |
@@ -1254,14 +1254,14 @@ discard block |
||
1254 | 1254 | * @return string |
1255 | 1255 | */ |
1256 | 1256 | public function get_admin_details_link() { |
1257 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1257 | + EE_Registry::instance()->load_helper('URL'); |
|
1258 | 1258 | return EEH_URL::add_query_args_and_nonce( |
1259 | 1259 | array( |
1260 | 1260 | 'page' => 'espresso_registrations', |
1261 | 1261 | 'action' => 'view_registration', |
1262 | 1262 | '_REG_ID' => $this->ID() |
1263 | 1263 | ), |
1264 | - admin_url( 'admin.php' ) |
|
1264 | + admin_url('admin.php') |
|
1265 | 1265 | ); |
1266 | 1266 | } |
1267 | 1267 | |
@@ -1286,12 +1286,12 @@ discard block |
||
1286 | 1286 | * @return string |
1287 | 1287 | */ |
1288 | 1288 | public function get_admin_overview_link() { |
1289 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1289 | + EE_Registry::instance()->load_helper('URL'); |
|
1290 | 1290 | return EEH_URL::add_query_args_and_nonce( |
1291 | 1291 | array( |
1292 | 1292 | 'page' => 'espresso_registrations' |
1293 | 1293 | ), |
1294 | - admin_url( 'admin.php' ) |
|
1294 | + admin_url('admin.php') |
|
1295 | 1295 | ); |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1302,8 +1302,8 @@ discard block |
||
1302 | 1302 | * @return \EE_Registration[] |
1303 | 1303 | * @throws \EE_Error |
1304 | 1304 | */ |
1305 | - public function payments( $query_params = array() ) { |
|
1306 | - return $this->get_many_related( 'Payment', $query_params ); |
|
1305 | + public function payments($query_params = array()) { |
|
1306 | + return $this->get_many_related('Payment', $query_params); |
|
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | |
@@ -1313,8 +1313,8 @@ discard block |
||
1313 | 1313 | * @return \EE_Registration_Payment[] |
1314 | 1314 | * @throws \EE_Error |
1315 | 1315 | */ |
1316 | - public function registration_payments( $query_params = array() ) { |
|
1317 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
1316 | + public function registration_payments($query_params = array()) { |
|
1317 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | * @return EE_Payment_Method|null |
1328 | 1328 | */ |
1329 | 1329 | public function payment_method() { |
1330 | - return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
|
1330 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1331 | 1331 | } |
1332 | 1332 | |
1333 | 1333 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Transaction class |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | * @return EE_Transaction |
26 | 26 | * @throws \EE_Error |
27 | 27 | */ |
28 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
29 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
28 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
29 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
30 | 30 | return $has_object |
31 | 31 | ? $has_object |
32 | - : new self( $props_n_values, false, $timezone, $date_formats ); |
|
32 | + : new self($props_n_values, false, $timezone, $date_formats); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * @return EE_Transaction |
42 | 42 | * @throws \EE_Error |
43 | 43 | */ |
44 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
45 | - return new self( $props_n_values, TRUE, $timezone ); |
|
44 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
45 | + return new self($props_n_values, TRUE, $timezone); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function lock() { |
60 | 60 | // attempt to set lock, but if that fails... |
61 | - if ( ! $this->add_extra_meta( 'lock', time(), true ) ) { |
|
61 | + if ( ! $this->add_extra_meta('lock', time(), true)) { |
|
62 | 62 | // then attempt to remove the lock in case it is expired |
63 | - if ( $this->_remove_expired_lock() ) { |
|
63 | + if ($this->_remove_expired_lock()) { |
|
64 | 64 | // if removal was successful, then try setting lock again |
65 | 65 | $this->lock(); |
66 | 66 | } else { |
67 | 67 | // but if the lock can not be removed, then throw an exception |
68 | 68 | throw new EE_Error( |
69 | 69 | sprintf( |
70 | - __( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ), |
|
70 | + __('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'), |
|
71 | 71 | $this->ID() |
72 | 72 | ) |
73 | 73 | ); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @throws \EE_Error |
87 | 87 | */ |
88 | 88 | public function unlock() { |
89 | - return $this->delete_extra_meta( 'lock' ); |
|
89 | + return $this->delete_extra_meta('lock'); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function is_locked() { |
109 | 109 | // if TXN is not locked, then return false immediately |
110 | - if ( ! $this->_get_lock() ) { |
|
110 | + if ( ! $this->_get_lock()) { |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | // if not, then let's try and remove the lock in case it's expired... |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | 130 | protected function _get_lock() { |
131 | - return (int)$this->get_extra_meta( 'lock', true, 0 ); |
|
131 | + return (int) $this->get_extra_meta('lock', true, 0); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function _remove_expired_lock() { |
145 | 145 | $locked = $this->_get_lock(); |
146 | - if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) { |
|
146 | + if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) { |
|
147 | 147 | return $this->unlock(); |
148 | 148 | } |
149 | 149 | return 0; |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param float $total total value of transaction |
159 | 159 | * @throws \EE_Error |
160 | 160 | */ |
161 | - public function set_total( $total = 0.00 ) { |
|
162 | - $this->set( 'TXN_total', (float)$total ); |
|
161 | + public function set_total($total = 0.00) { |
|
162 | + $this->set('TXN_total', (float) $total); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param float $total_paid total amount paid to date (sum of all payments) |
172 | 172 | * @throws \EE_Error |
173 | 173 | */ |
174 | - public function set_paid( $total_paid = 0.00 ) { |
|
175 | - $this->set( 'TXN_paid', (float)$total_paid ); |
|
174 | + public function set_paid($total_paid = 0.00) { |
|
175 | + $this->set('TXN_paid', (float) $total_paid); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set |
185 | 185 | * @throws \EE_Error |
186 | 186 | */ |
187 | - public function set_status( $status = '' ) { |
|
188 | - $this->set( 'STS_ID', $status ); |
|
187 | + public function set_status($status = '') { |
|
188 | + $this->set('STS_ID', $status); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param string $hash_salt required for some payment gateways |
198 | 198 | * @throws \EE_Error |
199 | 199 | */ |
200 | - public function set_hash_salt( $hash_salt = '' ) { |
|
201 | - $this->set( 'TXN_hash_salt', $hash_salt ); |
|
200 | + public function set_hash_salt($hash_salt = '') { |
|
201 | + $this->set('TXN_hash_salt', $hash_salt); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | * @param array $txn_reg_steps |
210 | 210 | * @throws \EE_Error |
211 | 211 | */ |
212 | - public function set_reg_steps( array $txn_reg_steps ) { |
|
213 | - $this->set( 'TXN_reg_steps', $txn_reg_steps ); |
|
212 | + public function set_reg_steps(array $txn_reg_steps) { |
|
213 | + $this->set('TXN_reg_steps', $txn_reg_steps); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | * @throws \EE_Error |
223 | 223 | */ |
224 | 224 | public function reg_steps() { |
225 | - $TXN_reg_steps = $this->get( 'TXN_reg_steps' ); |
|
226 | - return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array(); |
|
225 | + $TXN_reg_steps = $this->get('TXN_reg_steps'); |
|
226 | + return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array(); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @throws \EE_Error |
234 | 234 | */ |
235 | 235 | public function pretty_total() { |
236 | - return $this->get_pretty( 'TXN_total' ); |
|
236 | + return $this->get_pretty('TXN_total'); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @throws \EE_Error |
246 | 246 | */ |
247 | 247 | public function pretty_paid() { |
248 | - return $this->get_pretty( 'TXN_paid' ); |
|
248 | + return $this->get_pretty('TXN_paid'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | 260 | public function remaining() { |
261 | - return (float)( $this->total() - $this->paid() ); |
|
261 | + return (float) ($this->total() - $this->paid()); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @throws \EE_Error |
272 | 272 | */ |
273 | 273 | public function total() { |
274 | - return (float)$this->get( 'TXN_total' ); |
|
274 | + return (float) $this->get('TXN_total'); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @throws \EE_Error |
285 | 285 | */ |
286 | 286 | public function paid() { |
287 | - return (float)$this->get( 'TXN_paid' ); |
|
287 | + return (float) $this->get('TXN_paid'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * @throws \EE_Error |
297 | 297 | */ |
298 | 298 | public function get_cart_session() { |
299 | - $session_data = (array)$this->get( 'TXN_session_data' ); |
|
300 | - return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart |
|
301 | - ? $session_data[ 'cart' ] |
|
299 | + $session_data = (array) $this->get('TXN_session_data'); |
|
300 | + return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart |
|
301 | + ? $session_data['cart'] |
|
302 | 302 | : null; |
303 | 303 | } |
304 | 304 | |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @throws \EE_Error |
312 | 312 | */ |
313 | 313 | public function session_data() { |
314 | - $session_data = $this->get( 'TXN_session_data' ); |
|
315 | - if ( empty( $session_data ) ) { |
|
314 | + $session_data = $this->get('TXN_session_data'); |
|
315 | + if (empty($session_data)) { |
|
316 | 316 | $session_data = array( |
317 | 317 | 'id' => null, |
318 | 318 | 'user_id' => null, |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | * @param EE_Session|array $session_data |
336 | 336 | * @throws \EE_Error |
337 | 337 | */ |
338 | - public function set_txn_session_data( $session_data ) { |
|
339 | - if ( $session_data instanceof EE_Session ) { |
|
340 | - $this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE )); |
|
338 | + public function set_txn_session_data($session_data) { |
|
339 | + if ($session_data instanceof EE_Session) { |
|
340 | + $this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE)); |
|
341 | 341 | } else { |
342 | - $this->set( 'TXN_session_data', $session_data ); |
|
342 | + $this->set('TXN_session_data', $session_data); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @throws \EE_Error |
353 | 353 | */ |
354 | 354 | public function hash_salt_() { |
355 | - return $this->get( 'TXN_hash_salt' ); |
|
355 | + return $this->get('TXN_hash_salt'); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | * @return string | int |
373 | 373 | * @throws \EE_Error |
374 | 374 | */ |
375 | - public function datetime( $format = FALSE, $gmt = FALSE ) { |
|
376 | - if ( $format ) { |
|
377 | - return $this->get_pretty( 'TXN_timestamp' ); |
|
378 | - } else if ( $gmt ) { |
|
379 | - return $this->get_raw( 'TXN_timestamp' ); |
|
375 | + public function datetime($format = FALSE, $gmt = FALSE) { |
|
376 | + if ($format) { |
|
377 | + return $this->get_pretty('TXN_timestamp'); |
|
378 | + } else if ($gmt) { |
|
379 | + return $this->get_raw('TXN_timestamp'); |
|
380 | 380 | } else { |
381 | - return $this->get( 'TXN_timestamp' ); |
|
381 | + return $this->get('TXN_timestamp'); |
|
382 | 382 | } |
383 | 383 | } |
384 | 384 | |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @return EE_Registration[] |
393 | 393 | * @throws \EE_Error |
394 | 394 | */ |
395 | - public function registrations( $query_params = array(), $get_cached = FALSE ) { |
|
396 | - $query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) |
|
395 | + public function registrations($query_params = array(), $get_cached = FALSE) { |
|
396 | + $query_params = (empty($query_params) || ! is_array($query_params)) |
|
397 | 397 | ? array( |
398 | 398 | 'order_by' => array( |
399 | 399 | 'Event.EVT_name' => 'ASC', |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | ) |
404 | 404 | : $query_params; |
405 | 405 | $query_params = $get_cached ? array() : $query_params; |
406 | - return $this->get_many_related( 'Registration', $query_params ); |
|
406 | + return $this->get_many_related('Registration', $query_params); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function attendees() { |
419 | - return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) ); |
|
419 | + return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID()))); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @return EE_Payment[] |
429 | 429 | * @throws \EE_Error |
430 | 430 | */ |
431 | - public function payments( $query_params = array() ) { |
|
432 | - return $this->get_many_related( 'Payment', $query_params ); |
|
431 | + public function payments($query_params = array()) { |
|
432 | + return $this->get_many_related('Payment', $query_params); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * @throws \EE_Error |
442 | 442 | */ |
443 | 443 | public function approved_payments() { |
444 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
445 | - return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) ); |
|
444 | + EE_Registry::instance()->load_model('Payment'); |
|
445 | + return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC'))); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @return string |
455 | 455 | * @throws \EE_Error |
456 | 456 | */ |
457 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
458 | - echo $this->pretty_status( $show_icons ); |
|
457 | + public function e_pretty_status($show_icons = FALSE) { |
|
458 | + echo $this->pretty_status($show_icons); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
@@ -467,10 +467,10 @@ discard block |
||
467 | 467 | * @return string |
468 | 468 | * @throws \EE_Error |
469 | 469 | */ |
470 | - public function pretty_status( $show_icons = FALSE ) { |
|
471 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
470 | + public function pretty_status($show_icons = FALSE) { |
|
471 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
472 | 472 | $icon = ''; |
473 | - switch ( $this->status_ID() ) { |
|
473 | + switch ($this->status_ID()) { |
|
474 | 474 | case EEM_Transaction::complete_status_code: |
475 | 475 | $icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : ''; |
476 | 476 | break; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : ''; |
488 | 488 | break; |
489 | 489 | } |
490 | - return $icon . $status[ $this->status_ID() ]; |
|
490 | + return $icon.$status[$this->status_ID()]; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | * @throws \EE_Error |
500 | 500 | */ |
501 | 501 | public function status_ID() { |
502 | - return $this->get( 'STS_ID' ); |
|
502 | + return $this->get('STS_ID'); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @throws \EE_Error |
512 | 512 | */ |
513 | 513 | public function is_free() { |
514 | - return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' ); |
|
514 | + return EEH_Money::compare_floats($this->get('TXN_total'), 0, '=='); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | |
@@ -591,12 +591,12 @@ discard block |
||
591 | 591 | * @return string |
592 | 592 | * @throws \EE_Error |
593 | 593 | */ |
594 | - public function invoice_url( $type = 'html' ) { |
|
594 | + public function invoice_url($type = 'html') { |
|
595 | 595 | $REG = $this->primary_registration(); |
596 | - if ( ! $REG instanceof EE_Registration ) { |
|
596 | + if ( ! $REG instanceof EE_Registration) { |
|
597 | 597 | return ''; |
598 | 598 | } |
599 | - return $REG->invoice_url( $type ); |
|
599 | + return $REG->invoice_url($type); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | 610 | public function primary_registration() { |
611 | - return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) ); |
|
611 | + return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -620,12 +620,12 @@ discard block |
||
620 | 620 | * @return string |
621 | 621 | * @throws \EE_Error |
622 | 622 | */ |
623 | - public function receipt_url( $type = 'html' ) { |
|
623 | + public function receipt_url($type = 'html') { |
|
624 | 624 | $REG = $this->primary_registration(); |
625 | - if ( ! $REG instanceof EE_Registration ) { |
|
625 | + if ( ! $REG instanceof EE_Registration) { |
|
626 | 626 | return ''; |
627 | 627 | } |
628 | - return $REG->receipt_url( $type ); |
|
628 | + return $REG->receipt_url($type); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | * @throws \EE_Error |
651 | 651 | */ |
652 | 652 | public function gateway_response_on_transaction() { |
653 | - $payment = $this->get_first_related( 'Payment' ); |
|
653 | + $payment = $this->get_first_related('Payment'); |
|
654 | 654 | return $payment instanceof EE_Payment ? $payment->gateway_response() : ''; |
655 | 655 | } |
656 | 656 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * @throws \EE_Error |
664 | 664 | */ |
665 | 665 | public function status_obj() { |
666 | - return $this->get_first_related( 'Status' ); |
|
666 | + return $this->get_first_related('Status'); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | |
@@ -675,8 +675,8 @@ discard block |
||
675 | 675 | * @return EE_Extra_Meta |
676 | 676 | * @throws \EE_Error |
677 | 677 | */ |
678 | - public function extra_meta( $query_params = array() ) { |
|
679 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
678 | + public function extra_meta($query_params = array()) { |
|
679 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -688,8 +688,8 @@ discard block |
||
688 | 688 | * @return EE_Base_Class the relation was added to |
689 | 689 | * @throws \EE_Error |
690 | 690 | */ |
691 | - public function add_registration( EE_Registration $registration ) { |
|
692 | - return $this->_add_relation_to( $registration, 'Registration' ); |
|
691 | + public function add_registration(EE_Registration $registration) { |
|
692 | + return $this->_add_relation_to($registration, 'Registration'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | * @return EE_Base_Class that was removed from being related |
703 | 703 | * @throws \EE_Error |
704 | 704 | */ |
705 | - public function remove_registration_with_id( $registration_or_id ) { |
|
706 | - return $this->_remove_relation_to( $registration_or_id, 'Registration' ); |
|
705 | + public function remove_registration_with_id($registration_or_id) { |
|
706 | + return $this->_remove_relation_to($registration_or_id, 'Registration'); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | * @throws \EE_Error |
716 | 716 | */ |
717 | 717 | public function items_purchased() { |
718 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) ); |
|
718 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item))); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | * @return EE_Base_Class the relation was added to |
728 | 728 | * @throws \EE_Error |
729 | 729 | */ |
730 | - public function add_line_item( EE_Line_Item $line_item ) { |
|
731 | - return $this->_add_relation_to( $line_item, 'Line_Item' ); |
|
730 | + public function add_line_item(EE_Line_Item $line_item) { |
|
731 | + return $this->_add_relation_to($line_item, 'Line_Item'); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | * @return EE_Line_Item[] |
741 | 741 | * @throws \EE_Error |
742 | 742 | */ |
743 | - public function line_items( $query_params = array() ) { |
|
744 | - return $this->get_many_related( 'Line_Item', $query_params ); |
|
743 | + public function line_items($query_params = array()) { |
|
744 | + return $this->get_many_related('Line_Item', $query_params); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * @throws \EE_Error |
754 | 754 | */ |
755 | 755 | public function tax_items() { |
756 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) ); |
|
756 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | |
@@ -766,9 +766,9 @@ discard block |
||
766 | 766 | * @throws \EE_Error |
767 | 767 | */ |
768 | 768 | public function total_line_item() { |
769 | - $item = $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) ); |
|
770 | - if( ! $item ){ |
|
771 | - $item = EEH_Line_Item::create_total_line_item( $this ); |
|
769 | + $item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total))); |
|
770 | + if ( ! $item) { |
|
771 | + $item = EEH_Line_Item::create_total_line_item($this); |
|
772 | 772 | } |
773 | 773 | return $item; |
774 | 774 | } |
@@ -784,10 +784,10 @@ discard block |
||
784 | 784 | */ |
785 | 785 | public function tax_total() { |
786 | 786 | $tax_line_item = $this->tax_total_line_item(); |
787 | - if ( $tax_line_item ) { |
|
788 | - return (float)$tax_line_item->total(); |
|
787 | + if ($tax_line_item) { |
|
788 | + return (float) $tax_line_item->total(); |
|
789 | 789 | } else { |
790 | - return (float)0; |
|
790 | + return (float) 0; |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 | |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | * @throws \EE_Error |
801 | 801 | */ |
802 | 802 | public function tax_total_line_item() { |
803 | - return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() ); |
|
803 | + return EEH_Line_Item::get_taxes_subtotal($this->total_line_item()); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | |
@@ -811,20 +811,20 @@ discard block |
||
811 | 811 | * @return EE_Form_Section_Proper |
812 | 812 | * @throws \EE_Error |
813 | 813 | */ |
814 | - public function billing_info(){ |
|
814 | + public function billing_info() { |
|
815 | 815 | $payment_method = $this->payment_method(); |
816 | - if ( !$payment_method){ |
|
816 | + if ( ! $payment_method) { |
|
817 | 817 | EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
818 | 818 | return false; |
819 | 819 | } |
820 | 820 | $primary_reg = $this->primary_registration(); |
821 | - if ( ! $primary_reg ) { |
|
822 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
821 | + if ( ! $primary_reg) { |
|
822 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
823 | 823 | return FALSE; |
824 | 824 | } |
825 | 825 | $attendee = $primary_reg->attendee(); |
826 | - if ( ! $attendee ) { |
|
827 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
826 | + if ( ! $attendee) { |
|
827 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
828 | 828 | return FALSE; |
829 | 829 | } |
830 | 830 | return $attendee->billing_info_for_payment_method($payment_method); |
@@ -865,15 +865,15 @@ discard block |
||
865 | 865 | * @return EE_Payment_Method |
866 | 866 | * @throws \EE_Error |
867 | 867 | */ |
868 | - public function payment_method(){ |
|
868 | + public function payment_method() { |
|
869 | 869 | $pm = $this->get_first_related('Payment_Method'); |
870 | - if( $pm instanceof EE_Payment_Method ){ |
|
870 | + if ($pm instanceof EE_Payment_Method) { |
|
871 | 871 | return $pm; |
872 | - }else{ |
|
872 | + } else { |
|
873 | 873 | $last_payment = $this->last_payment(); |
874 | - if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){ |
|
874 | + if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) { |
|
875 | 875 | return $last_payment->payment_method(); |
876 | - }else{ |
|
876 | + } else { |
|
877 | 877 | return NULL; |
878 | 878 | } |
879 | 879 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | * @throws \EE_Error |
889 | 889 | */ |
890 | 890 | public function last_payment() { |
891 | - return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) ); |
|
891 | + return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc'))); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | |
@@ -899,8 +899,8 @@ discard block |
||
899 | 899 | * @return EE_Line_Item[] |
900 | 900 | * @throws \EE_Error |
901 | 901 | */ |
902 | - public function non_ticket_line_items(){ |
|
903 | - return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() ); |
|
902 | + public function non_ticket_line_items() { |
|
903 | + return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID()); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | public function update_based_on_payments() |
949 | 949 | { |
950 | 950 | EE_Error::doing_it_wrong( |
951 | - __CLASS__ . '::' . __FUNCTION__, |
|
951 | + __CLASS__.'::'.__FUNCTION__, |
|
952 | 952 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
953 | 953 | 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
954 | 954 | '4.6.0' |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\UnexpectedEntityException; |
2 | 2 | |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * Event Espresso |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * date_format and the second value is the time format |
69 | 69 | * @return EE_Ticket |
70 | 70 | */ |
71 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
72 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
73 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
71 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
72 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
73 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * the website will be used. |
82 | 82 | * @return EE_Ticket |
83 | 83 | */ |
84 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
85 | - return new self( $props_n_values, TRUE, $timezone ); |
|
84 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
85 | + return new self($props_n_values, TRUE, $timezone); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return bool |
92 | 92 | */ |
93 | 93 | public function parent() { |
94 | - return $this->get( 'TKT_parent' ); |
|
94 | + return $this->get('TKT_parent'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | * @param int $DTT_ID the primary key for a particular datetime |
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | - public function available( $DTT_ID = 0 ) { |
|
104 | + public function available($DTT_ID = 0) { |
|
105 | 105 | // are we checking availability for a particular datetime ? |
106 | - if ( $DTT_ID ) { |
|
106 | + if ($DTT_ID) { |
|
107 | 107 | // get that datetime object |
108 | - $datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
|
108 | + $datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID))); |
|
109 | 109 | // if ticket sales for this datetime have exceeded the reg limit... |
110 | - if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) { |
|
110 | + if ($datetime instanceof EE_Datetime && $datetime->sold_out()) { |
|
111 | 111 | return FALSE; |
112 | 112 | } |
113 | 113 | } |
@@ -122,21 +122,21 @@ discard block |
||
122 | 122 | * @param bool $display true = we'll return a localized string, otherwise we just return the value of the relevant status const |
123 | 123 | * @return mixed(int|string) status int if the display string isn't requested |
124 | 124 | */ |
125 | - public function ticket_status( $display = FALSE ) { |
|
126 | - if ( ! $this->is_remaining() ) { |
|
127 | - return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out; |
|
125 | + public function ticket_status($display = FALSE) { |
|
126 | + if ( ! $this->is_remaining()) { |
|
127 | + return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out; |
|
128 | 128 | } |
129 | - if ( $this->get( 'TKT_deleted' ) ) { |
|
130 | - return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived; |
|
129 | + if ($this->get('TKT_deleted')) { |
|
130 | + return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived; |
|
131 | 131 | } |
132 | - if ( $this->is_expired() ) { |
|
133 | - return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired; |
|
132 | + if ($this->is_expired()) { |
|
133 | + return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired; |
|
134 | 134 | } |
135 | - if ( $this->is_pending() ) { |
|
136 | - return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending; |
|
135 | + if ($this->is_pending()) { |
|
136 | + return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending; |
|
137 | 137 | } |
138 | - if ( $this->is_on_sale() ) { |
|
139 | - return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale; |
|
138 | + if ($this->is_on_sale()) { |
|
139 | + return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale; |
|
140 | 140 | } |
141 | 141 | return ''; |
142 | 142 | } |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | * @param int $DTT_ID if an int above 0 is included here then we get a specific dtt. |
151 | 151 | * @return boolean true = tickets remaining, false not. |
152 | 152 | */ |
153 | - public function is_remaining( $DTT_ID = 0 ) { |
|
154 | - $num_remaining = $this->remaining( $DTT_ID ); |
|
155 | - if ( $num_remaining === 0 ) { |
|
153 | + public function is_remaining($DTT_ID = 0) { |
|
154 | + $num_remaining = $this->remaining($DTT_ID); |
|
155 | + if ($num_remaining === 0) { |
|
156 | 156 | return FALSE; |
157 | 157 | } |
158 | - if ( $num_remaining > 0 && $num_remaining < $this->min() ) { |
|
158 | + if ($num_remaining > 0 && $num_remaining < $this->min()) { |
|
159 | 159 | return FALSE; |
160 | 160 | } |
161 | 161 | return TRUE; |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | * all related datetimes |
170 | 170 | * @return int |
171 | 171 | */ |
172 | - public function remaining( $DTT_ID = 0 ) { |
|
172 | + public function remaining($DTT_ID = 0) { |
|
173 | 173 | // are we checking availability for a particular datetime ? |
174 | - if ( $DTT_ID ) { |
|
174 | + if ($DTT_ID) { |
|
175 | 175 | // get array with the one requested datetime |
176 | - $datetimes = $this->get_many_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
|
176 | + $datetimes = $this->get_many_related('Datetime', array(array('DTT_ID' => $DTT_ID))); |
|
177 | 177 | } else { |
178 | 178 | // we need to check availability of ALL datetimes |
179 | - $datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) ); |
|
179 | + $datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
180 | 180 | } |
181 | 181 | // d( $datetimes ); |
182 | 182 | // if datetime reg limit is not unlimited |
183 | - if ( ! empty( $datetimes ) ) { |
|
183 | + if ( ! empty($datetimes)) { |
|
184 | 184 | // although TKT_qty and $datetime->spaces_remaining() could both be EE_INF |
185 | 185 | // we only need to check for EE_INF explicitly if we want to optimize. |
186 | 186 | // because EE_INF - x = EE_INF; and min(x,EE_INF) = x; |
187 | 187 | $tickets_remaining = $this->qty() - $this->sold(); |
188 | - foreach ( $datetimes as $datetime ) { |
|
189 | - if ( $datetime instanceof EE_Datetime ) { |
|
190 | - $tickets_remaining = min( $tickets_remaining, $datetime->spaces_remaining() ); |
|
188 | + foreach ($datetimes as $datetime) { |
|
189 | + if ($datetime instanceof EE_Datetime) { |
|
190 | + $tickets_remaining = min($tickets_remaining, $datetime->spaces_remaining()); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | return $tickets_remaining; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return int |
203 | 203 | */ |
204 | 204 | function min() { |
205 | - return $this->get( 'TKT_min' ); |
|
205 | + return $this->get('TKT_min'); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @return boolean |
213 | 213 | */ |
214 | 214 | public function is_expired() { |
215 | - return ( $this->get_raw( 'TKT_end_date' ) < time() ); |
|
215 | + return ($this->get_raw('TKT_end_date') < time()); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @return boolean |
223 | 223 | */ |
224 | 224 | public function is_pending() { |
225 | - return ( $this->get_raw( 'TKT_start_date' ) > time() ); |
|
225 | + return ($this->get_raw('TKT_start_date') > time()); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @return boolean |
233 | 233 | */ |
234 | 234 | public function is_on_sale() { |
235 | - return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() ); |
|
235 | + return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time()); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
244 | 244 | * @return array |
245 | 245 | */ |
246 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
247 | - $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : ''; |
|
248 | - $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : ''; |
|
246 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
247 | + $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : ''; |
|
248 | + $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : ''; |
|
249 | 249 | |
250 | - return $first_date && $last_date ? $first_date . $conjunction . $last_date : ''; |
|
250 | + return $first_date && $last_date ? $first_date.$conjunction.$last_date : ''; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @return EE_Datetime |
258 | 258 | */ |
259 | 259 | public function first_datetime() { |
260 | - $datetimes = $this->datetimes( array( 'limit' => 1 ) ); |
|
261 | - return reset( $datetimes ); |
|
260 | + $datetimes = $this->datetimes(array('limit' => 1)); |
|
261 | + return reset($datetimes); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * @param array $query_params see EEM_Base::get_all() |
270 | 270 | * @return EE_Datetime[] |
271 | 271 | */ |
272 | - public function datetimes( $query_params = array() ) { |
|
273 | - if ( ! isset( $query_params[ 'order_by' ] ) ) { |
|
274 | - $query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC'; |
|
272 | + public function datetimes($query_params = array()) { |
|
273 | + if ( ! isset($query_params['order_by'])) { |
|
274 | + $query_params['order_by']['DTT_order'] = 'ASC'; |
|
275 | 275 | } |
276 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
276 | + return $this->get_many_related('Datetime', $query_params); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | * @return EE_Datetime |
284 | 284 | */ |
285 | 285 | public function last_datetime() { |
286 | - $datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) ); |
|
287 | - return end( $datetimes ); |
|
286 | + $datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC'))); |
|
287 | + return end($datetimes); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -298,22 +298,22 @@ discard block |
||
298 | 298 | * @param int $dtt_id [optional] include the dtt_id with $what = 'datetime'. |
299 | 299 | * @return mixed (array|int) how many tickets have sold |
300 | 300 | */ |
301 | - public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) { |
|
301 | + public function tickets_sold($what = 'ticket', $dtt_id = NULL) { |
|
302 | 302 | $total = 0; |
303 | 303 | $tickets_sold = $this->_all_tickets_sold(); |
304 | - switch ( $what ) { |
|
304 | + switch ($what) { |
|
305 | 305 | case 'ticket' : |
306 | - return $tickets_sold[ 'ticket' ]; |
|
306 | + return $tickets_sold['ticket']; |
|
307 | 307 | break; |
308 | 308 | case 'datetime' : |
309 | - if ( empty( $tickets_sold[ 'datetime' ] ) ) { |
|
309 | + if (empty($tickets_sold['datetime'])) { |
|
310 | 310 | return $total; |
311 | 311 | } |
312 | - if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) { |
|
313 | - EE_Error::add_error( __( "You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included. Are you SURE that is a datetime related to this ticket?", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
312 | + if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) { |
|
313 | + EE_Error::add_error(__("You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included. Are you SURE that is a datetime related to this ticket?", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
314 | 314 | return $total; |
315 | 315 | } |
316 | - return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ]; |
|
316 | + return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id]; |
|
317 | 317 | break; |
318 | 318 | default: |
319 | 319 | return $total; |
@@ -327,15 +327,15 @@ discard block |
||
327 | 327 | * @return EE_Ticket[] |
328 | 328 | */ |
329 | 329 | protected function _all_tickets_sold() { |
330 | - $datetimes = $this->get_many_related( 'Datetime' ); |
|
330 | + $datetimes = $this->get_many_related('Datetime'); |
|
331 | 331 | $tickets_sold = array(); |
332 | - if ( ! empty( $datetimes ) ) { |
|
333 | - foreach ( $datetimes as $datetime ) { |
|
334 | - $tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' ); |
|
332 | + if ( ! empty($datetimes)) { |
|
333 | + foreach ($datetimes as $datetime) { |
|
334 | + $tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold'); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | //Tickets sold |
338 | - $tickets_sold[ 'ticket' ] = $this->sold(); |
|
338 | + $tickets_sold['ticket'] = $this->sold(); |
|
339 | 339 | return $tickets_sold; |
340 | 340 | } |
341 | 341 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @param bool $return_array whether to return as an array indexed by price id or just the object. |
349 | 349 | * @return EE_Price |
350 | 350 | */ |
351 | - public function base_price( $return_array = FALSE ) { |
|
352 | - $_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price ); |
|
353 | - return $return_array ? $this->get_many_related( 'Price', array( $_where ) ) : $this->get_first_related( 'Price', array( $_where ) ); |
|
351 | + public function base_price($return_array = FALSE) { |
|
352 | + $_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price); |
|
353 | + return $return_array ? $this->get_many_related('Price', array($_where)) : $this->get_first_related('Price', array($_where)); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | * @return EE_Price[] |
363 | 363 | */ |
364 | 364 | public function price_modifiers() { |
365 | - $query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) ); |
|
366 | - return $this->prices( $query_params ); |
|
365 | + $query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax)))); |
|
366 | + return $this->prices($query_params); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | * @param array $query_params like EEM_Base::get_all |
374 | 374 | * @return EE_Price[] |
375 | 375 | */ |
376 | - public function prices( $query_params = array() ) { |
|
377 | - return $this->get_many_related( 'Price', $query_params ); |
|
376 | + public function prices($query_params = array()) { |
|
377 | + return $this->get_many_related('Price', $query_params); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | * @param array $query_params see EEM_Base::get_all() |
385 | 385 | * @return EE_Datetime_Ticket |
386 | 386 | */ |
387 | - public function datetime_tickets( $query_params = array() ) { |
|
388 | - return $this->get_many_related( 'Datetime_Ticket', $query_params ); |
|
387 | + public function datetime_tickets($query_params = array()) { |
|
388 | + return $this->get_many_related('Datetime_Ticket', $query_params); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -396,8 +396,8 @@ discard block |
||
396 | 396 | * @param boolean $show_deleted |
397 | 397 | * @return EE_Datetime[] |
398 | 398 | */ |
399 | - public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) { |
|
400 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted ); |
|
399 | + public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) { |
|
400 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @return string |
408 | 408 | */ |
409 | 409 | function ID() { |
410 | - return $this->get( 'TKT_ID' ); |
|
410 | + return $this->get('TKT_ID'); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @return EE_Ticket_Template |
432 | 432 | */ |
433 | 433 | public function template() { |
434 | - return $this->get_first_related( 'Ticket_Template' ); |
|
434 | + return $this->get_first_related('Ticket_Template'); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @return bool |
451 | 451 | */ |
452 | 452 | public function ticket_price() { |
453 | - return $this->get( 'TKT_price' ); |
|
453 | + return $this->get('TKT_price'); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @return mixed |
460 | 460 | */ |
461 | 461 | public function pretty_price() { |
462 | - return $this->get_pretty( 'TKT_price' ); |
|
462 | + return $this->get_pretty('TKT_price'); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
@@ -478,17 +478,17 @@ discard block |
||
478 | 478 | * @param bool $no_cache |
479 | 479 | * @return float |
480 | 480 | */ |
481 | - public function get_ticket_total_with_taxes( $no_cache = FALSE ) { |
|
482 | - if ( ! isset( $this->_ticket_total_with_taxes ) || $no_cache ) { |
|
481 | + public function get_ticket_total_with_taxes($no_cache = FALSE) { |
|
482 | + if ( ! isset($this->_ticket_total_with_taxes) || $no_cache) { |
|
483 | 483 | $this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin(); |
484 | 484 | } |
485 | - return (float)$this->_ticket_total_with_taxes; |
|
485 | + return (float) $this->_ticket_total_with_taxes; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
489 | 489 | |
490 | 490 | public function ensure_TKT_Price_correct() { |
491 | - $this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) ); |
|
491 | + $this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this)); |
|
492 | 492 | $this->save(); |
493 | 493 | } |
494 | 494 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * @return float |
499 | 499 | */ |
500 | 500 | public function get_ticket_subtotal() { |
501 | - return EE_Taxes::get_subtotal_for_admin( $this ); |
|
501 | + return EE_Taxes::get_subtotal_for_admin($this); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return float |
509 | 509 | */ |
510 | 510 | public function get_ticket_taxes_total_for_admin() { |
511 | - return EE_Taxes::get_total_taxes_for_admin( $this ); |
|
511 | + return EE_Taxes::get_total_taxes_for_admin($this); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -518,8 +518,8 @@ discard block |
||
518 | 518 | * @param string $name |
519 | 519 | * @return boolean |
520 | 520 | */ |
521 | - function set_name( $name ) { |
|
522 | - $this->set( 'TKT_name', $name ); |
|
521 | + function set_name($name) { |
|
522 | + $this->set('TKT_name', $name); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @return string |
530 | 530 | */ |
531 | 531 | function description() { |
532 | - return $this->get( 'TKT_description' ); |
|
532 | + return $this->get('TKT_description'); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @param string $description |
540 | 540 | * @return boolean |
541 | 541 | */ |
542 | - function set_description( $description ) { |
|
543 | - $this->set( 'TKT_description', $description ); |
|
542 | + function set_description($description) { |
|
543 | + $this->set('TKT_description', $description); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | * @param string $tm_frmt |
552 | 552 | * @return string |
553 | 553 | */ |
554 | - function start_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
555 | - return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt ); |
|
554 | + function start_date($dt_frmt = '', $tm_frmt = '') { |
|
555 | + return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | * @param string $start_date |
563 | 563 | * @return void |
564 | 564 | */ |
565 | - function set_start_date( $start_date ) { |
|
566 | - $this->_set_date_time( 'B', $start_date, 'TKT_start_date' ); |
|
565 | + function set_start_date($start_date) { |
|
566 | + $this->_set_date_time('B', $start_date, 'TKT_start_date'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | * @param string $tm_frmt |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - function end_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
578 | - return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt ); |
|
577 | + function end_date($dt_frmt = '', $tm_frmt = '') { |
|
578 | + return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -585,8 +585,8 @@ discard block |
||
585 | 585 | * @param string $end_date |
586 | 586 | * @return void |
587 | 587 | */ |
588 | - function set_end_date( $end_date ) { |
|
589 | - $this->_set_date_time( 'B', $end_date, 'TKT_end_date' ); |
|
588 | + function set_end_date($end_date) { |
|
589 | + $this->_set_date_time('B', $end_date, 'TKT_end_date'); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -598,8 +598,8 @@ discard block |
||
598 | 598 | * |
599 | 599 | * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
600 | 600 | */ |
601 | - function set_end_time( $time ) { |
|
602 | - $this->_set_time_for( $time, 'TKT_end_date' ); |
|
601 | + function set_end_time($time) { |
|
602 | + $this->_set_time_for($time, 'TKT_end_date'); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | * @param int $min |
610 | 610 | * @return boolean |
611 | 611 | */ |
612 | - function set_min( $min ) { |
|
613 | - $this->set( 'TKT_min', $min ); |
|
612 | + function set_min($min) { |
|
613 | + $this->set('TKT_min', $min); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @return int |
621 | 621 | */ |
622 | 622 | function max() { |
623 | - return $this->get( 'TKT_max' ); |
|
623 | + return $this->get('TKT_max'); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | * @param int $max |
631 | 631 | * @return boolean |
632 | 632 | */ |
633 | - function set_max( $max ) { |
|
634 | - $this->set( 'TKT_max', $max ); |
|
633 | + function set_max($max) { |
|
634 | + $this->set('TKT_max', $max); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -641,8 +641,8 @@ discard block |
||
641 | 641 | * @param float $price |
642 | 642 | * @return boolean |
643 | 643 | */ |
644 | - function set_price( $price ) { |
|
645 | - $this->set( 'TKT_price', $price ); |
|
644 | + function set_price($price) { |
|
645 | + $this->set('TKT_price', $price); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | * @return int |
653 | 653 | */ |
654 | 654 | function sold() { |
655 | - return $this->get_raw( 'TKT_sold' ); |
|
655 | + return $this->get_raw('TKT_sold'); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | |
@@ -662,10 +662,10 @@ discard block |
||
662 | 662 | * @param int $qty |
663 | 663 | * @return boolean |
664 | 664 | */ |
665 | - function increase_sold( $qty = 1 ) { |
|
665 | + function increase_sold($qty = 1) { |
|
666 | 666 | $sold = $this->sold() + $qty; |
667 | - $this->_increase_sold_for_datetimes( $qty ); |
|
668 | - return $this->set_sold( $sold ); |
|
667 | + $this->_increase_sold_for_datetimes($qty); |
|
668 | + return $this->set_sold($sold); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | |
@@ -675,12 +675,12 @@ discard block |
||
675 | 675 | * @param int $qty |
676 | 676 | * @return boolean |
677 | 677 | */ |
678 | - protected function _increase_sold_for_datetimes( $qty = 1 ) { |
|
678 | + protected function _increase_sold_for_datetimes($qty = 1) { |
|
679 | 679 | $datetimes = $this->datetimes(); |
680 | - if ( is_array( $datetimes ) ) { |
|
681 | - foreach ( $datetimes as $datetime ) { |
|
682 | - if ( $datetime instanceof EE_Datetime ) { |
|
683 | - $datetime->increase_sold( $qty ); |
|
680 | + if (is_array($datetimes)) { |
|
681 | + foreach ($datetimes as $datetime) { |
|
682 | + if ($datetime instanceof EE_Datetime) { |
|
683 | + $datetime->increase_sold($qty); |
|
684 | 684 | $datetime->save(); |
685 | 685 | } |
686 | 686 | } |
@@ -694,10 +694,10 @@ discard block |
||
694 | 694 | * @param int $sold |
695 | 695 | * @return boolean |
696 | 696 | */ |
697 | - function set_sold( $sold ) { |
|
697 | + function set_sold($sold) { |
|
698 | 698 | // sold can not go below zero |
699 | - $sold = max( 0, $sold ); |
|
700 | - $this->set( 'TKT_sold', $sold ); |
|
699 | + $sold = max(0, $sold); |
|
700 | + $this->set('TKT_sold', $sold); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -707,10 +707,10 @@ discard block |
||
707 | 707 | * @param int $qty |
708 | 708 | * @return boolean |
709 | 709 | */ |
710 | - function decrease_sold( $qty = 1 ) { |
|
710 | + function decrease_sold($qty = 1) { |
|
711 | 711 | $sold = $this->sold() - $qty; |
712 | - $this->_decrease_sold_for_datetimes( $qty ); |
|
713 | - return $this->set_sold( $sold ); |
|
712 | + $this->_decrease_sold_for_datetimes($qty); |
|
713 | + return $this->set_sold($sold); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | |
@@ -721,12 +721,12 @@ discard block |
||
721 | 721 | * @param int $qty |
722 | 722 | * @return boolean |
723 | 723 | */ |
724 | - protected function _decrease_sold_for_datetimes( $qty = 1 ) { |
|
724 | + protected function _decrease_sold_for_datetimes($qty = 1) { |
|
725 | 725 | $datetimes = $this->datetimes(); |
726 | - if ( is_array( $datetimes ) ) { |
|
727 | - foreach ( $datetimes as $datetime ) { |
|
728 | - if ( $datetime instanceof EE_Datetime ) { |
|
729 | - $datetime->decrease_sold( $qty ); |
|
726 | + if (is_array($datetimes)) { |
|
727 | + foreach ($datetimes as $datetime) { |
|
728 | + if ($datetime instanceof EE_Datetime) { |
|
729 | + $datetime->decrease_sold($qty); |
|
730 | 730 | $datetime->save(); |
731 | 731 | } |
732 | 732 | } |
@@ -747,14 +747,14 @@ discard block |
||
747 | 747 | * |
748 | 748 | * @return int |
749 | 749 | */ |
750 | - function qty( $context = '' ) { |
|
751 | - switch ( $context ) { |
|
750 | + function qty($context = '') { |
|
751 | + switch ($context) { |
|
752 | 752 | case 'reg_limit' : |
753 | 753 | return $this->real_quantity_on_ticket(); |
754 | 754 | case 'saleable' : |
755 | - return $this->real_quantity_on_ticket( 'saleable' ); |
|
755 | + return $this->real_quantity_on_ticket('saleable'); |
|
756 | 756 | default: |
757 | - return $this->get_raw( 'TKT_qty' ); |
|
757 | + return $this->get_raw('TKT_qty'); |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | |
@@ -771,38 +771,38 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @return int |
773 | 773 | */ |
774 | - function real_quantity_on_ticket( $context = 'reg_limit' ) { |
|
774 | + function real_quantity_on_ticket($context = 'reg_limit') { |
|
775 | 775 | // start with the original db value for ticket quantity |
776 | - $raw = $this->get_raw( 'TKT_qty' ); |
|
776 | + $raw = $this->get_raw('TKT_qty'); |
|
777 | 777 | // return immediately if it's zero |
778 | - if ( $raw === 0 ) { |
|
778 | + if ($raw === 0) { |
|
779 | 779 | return $raw; |
780 | 780 | } |
781 | 781 | // ensure qty doesn't exceed raw value for THIS ticket |
782 | - $qty = min( EE_INF, $raw ); |
|
782 | + $qty = min(EE_INF, $raw); |
|
783 | 783 | // NOW that we know the maximum number of tickets available for the ticket |
784 | 784 | // we need to calculate the maximum number of tickets available for the datetime |
785 | 785 | // without really factoring this ticket into the calculations |
786 | 786 | $datetimes = $this->datetimes(); |
787 | - foreach ( $datetimes as $datetime ) { |
|
788 | - if ( $datetime instanceof EE_Datetime ) { |
|
787 | + foreach ($datetimes as $datetime) { |
|
788 | + if ($datetime instanceof EE_Datetime) { |
|
789 | 789 | // initialize with no restrictions for each datetime |
790 | 790 | // but adjust datetime qty based on datetime reg limit |
791 | - $datetime_qty = min( EE_INF, $datetime->reg_limit() ); |
|
791 | + $datetime_qty = min(EE_INF, $datetime->reg_limit()); |
|
792 | 792 | // if we want the actual saleable amount, then we need to consider OTHER ticket sales |
793 | 793 | // for this datetime, that do NOT include sales for this ticket (so we add THIS ticket's sales back in) |
794 | - if ( $context == 'saleable' ) { |
|
795 | - $datetime_qty = max( $datetime_qty - $datetime->sold() + $this->sold(), 0 ); |
|
794 | + if ($context == 'saleable') { |
|
795 | + $datetime_qty = max($datetime_qty - $datetime->sold() + $this->sold(), 0); |
|
796 | 796 | $datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0; |
797 | 797 | } |
798 | - $qty = min( $datetime_qty, $qty ); |
|
798 | + $qty = min($datetime_qty, $qty); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | } |
802 | 802 | // we need to factor in the details for this specific ticket |
803 | - if ( $qty > 0 && $context == 'saleable' ) { |
|
803 | + if ($qty > 0 && $context == 'saleable') { |
|
804 | 804 | // and subtract the sales for THIS ticket |
805 | - $qty = max( $qty - $this->sold(), 0 ); |
|
805 | + $qty = max($qty - $this->sold(), 0); |
|
806 | 806 | //echo ' $qty: ' . $qty . "<br />"; |
807 | 807 | } |
808 | 808 | //echo '$qty: ' . $qty . "<br />"; |
@@ -818,14 +818,14 @@ discard block |
||
818 | 818 | * @return bool |
819 | 819 | * @throws \EE_Error |
820 | 820 | */ |
821 | - function set_qty( $qty ) { |
|
821 | + function set_qty($qty) { |
|
822 | 822 | $datetimes = $this->datetimes(); |
823 | - foreach ( $datetimes as $datetime ) { |
|
824 | - if ( $datetime instanceof EE_Datetime ) { |
|
825 | - $qty = min( $qty, $datetime->reg_limit() ); |
|
823 | + foreach ($datetimes as $datetime) { |
|
824 | + if ($datetime instanceof EE_Datetime) { |
|
825 | + $qty = min($qty, $datetime->reg_limit()); |
|
826 | 826 | } |
827 | 827 | } |
828 | - $this->set( 'TKT_qty', $qty ); |
|
828 | + $this->set('TKT_qty', $qty); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @return int |
836 | 836 | */ |
837 | 837 | function uses() { |
838 | - return $this->get( 'TKT_uses' ); |
|
838 | + return $this->get('TKT_uses'); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -845,8 +845,8 @@ discard block |
||
845 | 845 | * @param int $uses |
846 | 846 | * @return boolean |
847 | 847 | */ |
848 | - function set_uses( $uses ) { |
|
849 | - $this->set( 'TKT_uses', $uses ); |
|
848 | + function set_uses($uses) { |
|
849 | + $this->set('TKT_uses', $uses); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * @return boolean |
857 | 857 | */ |
858 | 858 | public function required() { |
859 | - return $this->get( 'TKT_required' ); |
|
859 | + return $this->get('TKT_required'); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | * @param boolean $required |
867 | 867 | * @return boolean |
868 | 868 | */ |
869 | - public function set_required( $required ) { |
|
870 | - $this->set( 'TKT_required', $required ); |
|
869 | + public function set_required($required) { |
|
870 | + $this->set('TKT_required', $required); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | * @return boolean |
878 | 878 | */ |
879 | 879 | function taxable() { |
880 | - return $this->get( 'TKT_taxable' ); |
|
880 | + return $this->get('TKT_taxable'); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | * @param boolean $taxable |
888 | 888 | * @return boolean |
889 | 889 | */ |
890 | - function set_taxable( $taxable ) { |
|
891 | - $this->set( 'TKT_taxable', $taxable ); |
|
890 | + function set_taxable($taxable) { |
|
891 | + $this->set('TKT_taxable', $taxable); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | * @return boolean |
899 | 899 | */ |
900 | 900 | function is_default() { |
901 | - return $this->get( 'TKT_is_default' ); |
|
901 | + return $this->get('TKT_is_default'); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | |
@@ -908,8 +908,8 @@ discard block |
||
908 | 908 | * @param boolean $is_default |
909 | 909 | * @return boolean |
910 | 910 | */ |
911 | - function set_is_default( $is_default ) { |
|
912 | - $this->set( 'TKT_is_default', $is_default ); |
|
911 | + function set_is_default($is_default) { |
|
912 | + $this->set('TKT_is_default', $is_default); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | * @return int |
920 | 920 | */ |
921 | 921 | function order() { |
922 | - return $this->get( 'TKT_order' ); |
|
922 | + return $this->get('TKT_order'); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | |
@@ -929,8 +929,8 @@ discard block |
||
929 | 929 | * @param int $order |
930 | 930 | * @return boolean |
931 | 931 | */ |
932 | - function set_order( $order ) { |
|
933 | - $this->set( 'TKT_order', $order ); |
|
932 | + function set_order($order) { |
|
933 | + $this->set('TKT_order', $order); |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | * @return int |
941 | 941 | */ |
942 | 942 | function row() { |
943 | - return $this->get( 'TKT_row' ); |
|
943 | + return $this->get('TKT_row'); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | * @param int $row |
951 | 951 | * @return boolean |
952 | 952 | */ |
953 | - function set_row( $row ) { |
|
954 | - $this->set( 'TKT_row', $row ); |
|
953 | + function set_row($row) { |
|
954 | + $this->set('TKT_row', $row); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | * @return boolean |
962 | 962 | */ |
963 | 963 | function deleted() { |
964 | - return $this->get( 'TKT_deleted' ); |
|
964 | + return $this->get('TKT_deleted'); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | |
@@ -971,8 +971,8 @@ discard block |
||
971 | 971 | * @param boolean $deleted |
972 | 972 | * @return boolean |
973 | 973 | */ |
974 | - function set_deleted( $deleted ) { |
|
975 | - $this->set( 'TKT_deleted', $deleted ); |
|
974 | + function set_deleted($deleted) { |
|
975 | + $this->set('TKT_deleted', $deleted); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @return int |
983 | 983 | */ |
984 | 984 | function parent_ID() { |
985 | - return $this->get( 'TKT_parent' ); |
|
985 | + return $this->get('TKT_parent'); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | |
@@ -992,8 +992,8 @@ discard block |
||
992 | 992 | * @param int $parent |
993 | 993 | * @return boolean |
994 | 994 | */ |
995 | - function set_parent_ID( $parent ) { |
|
996 | - $this->set( 'TKT_parent', $parent ); |
|
995 | + function set_parent_ID($parent) { |
|
996 | + $this->set('TKT_parent', $parent); |
|
997 | 997 | } |
998 | 998 | |
999 | 999 | |
@@ -1004,10 +1004,10 @@ discard block |
||
1004 | 1004 | */ |
1005 | 1005 | function name_and_info() { |
1006 | 1006 | $times = array(); |
1007 | - foreach ( $this->datetimes() as $datetime ) { |
|
1007 | + foreach ($this->datetimes() as $datetime) { |
|
1008 | 1008 | $times[] = $datetime->start_date_and_time(); |
1009 | 1009 | } |
1010 | - return $this->name() . " @ " . implode( ", ", $times ) . " for " . $this->pretty_price(); |
|
1010 | + return $this->name()." @ ".implode(", ", $times)." for ".$this->pretty_price(); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | * @return string |
1018 | 1018 | */ |
1019 | 1019 | function name() { |
1020 | - return $this->get( 'TKT_name' ); |
|
1020 | + return $this->get('TKT_name'); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | * @return float |
1028 | 1028 | */ |
1029 | 1029 | function price() { |
1030 | - return $this->get( 'TKT_price' ); |
|
1030 | + return $this->get('TKT_price'); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | * @param array $query_params like EEM_Base::get_all's |
1038 | 1038 | * @return EE_Registration[] |
1039 | 1039 | */ |
1040 | - public function registrations( $query_params = array() ) { |
|
1041 | - return $this->get_many_related( 'Registration', $query_params ); |
|
1040 | + public function registrations($query_params = array()) { |
|
1041 | + return $this->get_many_related('Registration', $query_params); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | |
@@ -1049,8 +1049,8 @@ discard block |
||
1049 | 1049 | * @return int |
1050 | 1050 | */ |
1051 | 1051 | public function update_tickets_sold() { |
1052 | - $count_regs_for_this_ticket = $this->count_registrations( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0 ) ) ); |
|
1053 | - $this->set_sold( $count_regs_for_this_ticket ); |
|
1052 | + $count_regs_for_this_ticket = $this->count_registrations(array(array('STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0))); |
|
1053 | + $this->set_sold($count_regs_for_this_ticket); |
|
1054 | 1054 | $this->save(); |
1055 | 1055 | return $count_regs_for_this_ticket; |
1056 | 1056 | } |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | * @param array $query_params like EEM_Base::get_all's |
1063 | 1063 | * @return int |
1064 | 1064 | */ |
1065 | - public function count_registrations( $query_params = array() ) { |
|
1065 | + public function count_registrations($query_params = array()) { |
|
1066 | 1066 | return $this->count_related('Registration', $query_params); |
1067 | 1067 | } |
1068 | 1068 | |
@@ -1087,23 +1087,23 @@ discard block |
||
1087 | 1087 | public function get_related_event() { |
1088 | 1088 | //get one datetime to use for getting the event |
1089 | 1089 | $datetime = $this->first_datetime(); |
1090 | - if ( ! $datetime instanceof \EE_Datetime ) { |
|
1090 | + if ( ! $datetime instanceof \EE_Datetime) { |
|
1091 | 1091 | throw new UnexpectedEntityException( |
1092 | 1092 | $datetime, |
1093 | 1093 | 'EE_Datetime', |
1094 | 1094 | sprintf( |
1095 | - __( "The ticket (%s) is not associated with any valid datetimes.", "event_espresso" ), |
|
1095 | + __("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), |
|
1096 | 1096 | $datetime->name() |
1097 | 1097 | ) |
1098 | 1098 | ); |
1099 | 1099 | } |
1100 | 1100 | $event = $datetime->event(); |
1101 | - if ( ! $event instanceof \EE_Event ) { |
|
1101 | + if ( ! $event instanceof \EE_Event) { |
|
1102 | 1102 | throw new UnexpectedEntityException( |
1103 | 1103 | $event, |
1104 | 1104 | 'EE_Event', |
1105 | 1105 | sprintf( |
1106 | - __( "The ticket (%s) is not associated with a valid event.", "event_espresso" ), |
|
1106 | + __("The ticket (%s) is not associated with a valid event.", "event_espresso"), |
|
1107 | 1107 | $this->name() |
1108 | 1108 | ) |
1109 | 1109 | ); |
@@ -3,35 +3,35 @@ |
||
3 | 3 | <br/> |
4 | 4 | <?php //echo EEH_Debug_Tools::printr( $event_attendees, 'event_attendees' ); ?> |
5 | 5 | <?php echo $attendee_notice; ?> |
6 | -<?php if ( !empty($attendees) ) : ?> |
|
6 | +<?php if ( ! empty($attendees)) : ?> |
|
7 | 7 | <div class="admin-primary-mbox-tbl-wrap"> |
8 | 8 | <table class="admin-primary-mbox-tbl"> |
9 | 9 | <thead> |
10 | 10 | <tr> |
11 | - <th class="jst-left"><?php _e( '#', 'event_espresso' );?></th> |
|
12 | - <th class="jst-left"><?php _e( 'Event Name', 'event_espresso' );?></th> |
|
13 | - <th class="jst-left"><?php _e( 'Attendee', 'event_espresso' );?></th> |
|
14 | - <th class="jst-rght"><?php _e( 'Price Paid', 'event_espresso' );?></th> |
|
15 | - <th class="jst-left"><?php _e( 'Email', 'event_espresso' );?></th> |
|
16 | - <th class="jst-left"><?php _e( 'Address', 'event_espresso' );?></th> |
|
17 | - <!--<th class="jst-cntr"><?php _e( 'Actions', 'event_espresso' );?></th>--> |
|
11 | + <th class="jst-left"><?php _e('#', 'event_espresso'); ?></th> |
|
12 | + <th class="jst-left"><?php _e('Event Name', 'event_espresso'); ?></th> |
|
13 | + <th class="jst-left"><?php _e('Attendee', 'event_espresso'); ?></th> |
|
14 | + <th class="jst-rght"><?php _e('Price Paid', 'event_espresso'); ?></th> |
|
15 | + <th class="jst-left"><?php _e('Email', 'event_espresso'); ?></th> |
|
16 | + <th class="jst-left"><?php _e('Address', 'event_espresso'); ?></th> |
|
17 | + <!--<th class="jst-cntr"><?php _e('Actions', 'event_espresso'); ?></th>--> |
|
18 | 18 | </tr> |
19 | 19 | </thead> |
20 | 20 | <tbody> |
21 | 21 | |
22 | - <?php foreach ( $attendees as $att_nmbr => $attendee ) : ?> |
|
22 | + <?php foreach ($attendees as $att_nmbr => $attendee) : ?> |
|
23 | 23 | |
24 | 24 | <tr> |
25 | - <td class="jst-left"><?php echo $att_nmbr;?></td> |
|
26 | - <td class="jst-left"><?php echo $attendee['event_name'];?></td> |
|
25 | + <td class="jst-left"><?php echo $att_nmbr; ?></td> |
|
26 | + <td class="jst-left"><?php echo $attendee['event_name']; ?></td> |
|
27 | 27 | <td class="jst-left"> |
28 | - <a href="<?php echo $attendee['att_link']; ?>" title="<?php esc_attr_e( 'View details for this attendee', 'event_espresso' );?>"> |
|
29 | - <?php echo $attendee['fname'] . ' ' . $attendee['lname'];?> |
|
28 | + <a href="<?php echo $attendee['att_link']; ?>" title="<?php esc_attr_e('View details for this attendee', 'event_espresso'); ?>"> |
|
29 | + <?php echo $attendee['fname'].' '.$attendee['lname']; ?> |
|
30 | 30 | </a> |
31 | 31 | </td> |
32 | - <td class="jst-rght"><?php echo $currency_sign . ' ' . number_format( $attendee['final_price'], 2 );?></td> |
|
33 | - <td class="jst-left"><?php echo $attendee['email'];?></td> |
|
34 | - <td class="jst-left"><?php echo $attendee['address'];?></td> |
|
32 | + <td class="jst-rght"><?php echo $currency_sign.' '.number_format($attendee['final_price'], 2); ?></td> |
|
33 | + <td class="jst-left"><?php echo $attendee['email']; ?></td> |
|
34 | + <td class="jst-left"><?php echo $attendee['address']; ?></td> |
|
35 | 35 | <!--<th class="jst-cntr">view</th>--> |
36 | 36 | </tr> |
37 | 37 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
101 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) { |
|
100 | + if ( ! isset($_SERVER['PHP_AUTH_USER']) |
|
101 | + && ! isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
102 | 102 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
103 | 103 | return; |
104 | 104 | } |
105 | 105 | //ok they're using the WP API with Basic Auth |
106 | 106 | $message = sprintf( |
107 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
107 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
108 | 108 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
109 | 109 | '</a>', |
110 | 110 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
111 | 111 | '<br/>' |
112 | 112 | ); |
113 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
114 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
115 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
113 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
114 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
115 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
116 | 116 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
117 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
117 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
118 | 118 | //and send the message to the site admin too |
119 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
120 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
119 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
120 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | /** |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | * appear the same as they always did |
126 | 126 | */ |
127 | 127 | protected static function _set_hooks_for_changes() { |
128 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
129 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
128 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
129 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
130 | 130 | //ignore the base parent class |
131 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
131 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
132 | 132 | continue; |
133 | 133 | } |
134 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
135 | - if ( class_exists( $full_classname )) { |
|
134 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
135 | + if (class_exists($full_classname)) { |
|
136 | 136 | $instance_of_class = new $full_classname; |
137 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
137 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
138 | 138 | $instance_of_class->set_hooks(); |
139 | 139 | } |
140 | 140 | } |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
148 | 148 | */ |
149 | 149 | public static function register_routes() { |
150 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
151 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
152 | - foreach( $routes as $route ) { |
|
150 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
151 | + foreach ($relative_urls as $endpoint => $routes) { |
|
152 | + foreach ($routes as $route) { |
|
153 | 153 | register_rest_route( |
154 | 154 | $namespace, |
155 | 155 | $endpoint, |
156 | 156 | array( |
157 | - 'callback' => $route[ 'callback' ], |
|
158 | - 'methods' => $route[ 'methods' ], |
|
159 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
157 | + 'callback' => $route['callback'], |
|
158 | + 'methods' => $route['methods'], |
|
159 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
160 | 160 | ) |
161 | 161 | ); |
162 | 162 | } |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * next time the WP API is used |
171 | 171 | */ |
172 | 172 | public static function invalidate_cached_route_data_on_version_change() { |
173 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
173 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
174 | 174 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
175 | 175 | } |
176 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
177 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
176 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
177 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
178 | 178 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
179 | 179 | } |
180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public static function invalidate_cached_route_data() { |
187 | 187 | //delete the saved EE REST API routes |
188 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names ); |
|
188 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public static function get_ee_route_data() { |
200 | 200 | $ee_routes = array(); |
201 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
202 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
201 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
202 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
203 | 203 | } |
204 | 204 | return $ee_routes; |
205 | 205 | } |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | * @param boolean $hidden_endpoints |
212 | 212 | * @return array |
213 | 213 | */ |
214 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
215 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
216 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
217 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
214 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
215 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
216 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
217 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
218 | 218 | } |
219 | 219 | return $ee_routes; |
220 | 220 | } |
@@ -228,18 +228,18 @@ discard block |
||
228 | 228 | * @param boolean $hidden_endpoints |
229 | 229 | * @return mixed|null|void |
230 | 230 | */ |
231 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
231 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
232 | 232 | $instance = self::instance(); |
233 | 233 | $routes = apply_filters( |
234 | 234 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
235 | 235 | array_replace_recursive( |
236 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
237 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
238 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
239 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
236 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
237 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
238 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
239 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
240 | 240 | ) |
241 | 241 | ); |
242 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
242 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
243 | 243 | return $routes; |
244 | 244 | } |
245 | 245 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | */ |
252 | 252 | public static function save_ee_routes() { |
253 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
253 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
254 | 254 | $instance = self::instance(); |
255 | 255 | $routes = apply_filters( |
256 | 256 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $instance->_register_rpc_routes() |
262 | 262 | ) |
263 | 263 | ); |
264 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
264 | + update_option(self::saved_routes_option_names, $routes, true); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | */ |
273 | 273 | protected function _register_model_routes() { |
274 | 274 | $model_routes = array( ); |
275 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
276 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
275 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
276 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
277 | 277 | } |
278 | 278 | return $model_routes; |
279 | 279 | } |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * @param boolean $hidden_endpoint |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
288 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
287 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
288 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
289 | 289 | $models_to_register = apply_filters( |
290 | 290 | 'FHEE__EED_Core_REST_API___register_model_routes', |
291 | 291 | $model_version_info->models_for_requested_version() |
@@ -294,21 +294,21 @@ discard block |
||
294 | 294 | unset($models_to_register['Extra_Meta']); |
295 | 295 | unset($models_to_register['Extra_Join']); |
296 | 296 | $model_routes = array(); |
297 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
298 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
297 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
298 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
299 | 299 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
300 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
301 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
302 | - $model_routes[ $plural_model_route ] = array( |
|
300 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
301 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
302 | + $model_routes[$plural_model_route] = array( |
|
303 | 303 | array( |
304 | 304 | 'callback' => array( |
305 | 305 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
306 | 306 | 'handle_request_get_all' ), |
307 | 307 | 'methods' => WP_REST_Server::READABLE, |
308 | 308 | 'hidden_endpoint' => $hidden_endpoint, |
309 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
309 | + 'args' => $this->_get_read_query_params($model, $version), |
|
310 | 310 | '_links' => array( |
311 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
311 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
312 | 312 | ) |
313 | 313 | ), |
314 | 314 | // array( |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | // 'hidden_endpoint' => $hidden_endpoint |
320 | 320 | // ) |
321 | 321 | ); |
322 | - $model_routes[ $singular_model_route ] = array( |
|
322 | + $model_routes[$singular_model_route] = array( |
|
323 | 323 | array( |
324 | 324 | 'callback' => array( |
325 | 325 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
326 | 326 | 'handle_request_get_one' ), |
327 | 327 | 'methods' => WP_REST_Server::READABLE, |
328 | 328 | 'hidden_endpoint' => $hidden_endpoint, |
329 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
329 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
330 | 330 | ), |
331 | 331 | // array( |
332 | 332 | // 'callback' => array( |
@@ -337,19 +337,19 @@ discard block |
||
337 | 337 | // ), |
338 | 338 | ); |
339 | 339 | //@todo: also handle DELETE for a single item |
340 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
340 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
341 | 341 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
342 | 342 | $relation_name, |
343 | 343 | $relation_obj |
344 | 344 | ); |
345 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
345 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
346 | 346 | array( |
347 | 347 | 'callback' => array( |
348 | 348 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
349 | 349 | 'handle_request_get_related' ), |
350 | 350 | 'methods' => WP_REST_Server::READABLE, |
351 | 351 | 'hidden_endpoint' => $hidden_endpoint, |
352 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
352 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
353 | 353 | ), |
354 | 354 | // array( |
355 | 355 | // 'callback' => array( |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function _register_rpc_routes() { |
374 | 374 | $routes = array(); |
375 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
376 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
375 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
376 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
377 | 377 | } |
378 | 378 | return $routes; |
379 | 379 | } |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | * @param boolean $hidden_endpoint |
385 | 385 | * @return array |
386 | 386 | */ |
387 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
387 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
388 | 388 | $this_versions_routes = array(); |
389 | 389 | //checkin endpoint |
390 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
390 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
391 | 391 | array( |
392 | 392 | 'callback' => array( |
393 | 393 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'force' => array( |
399 | 399 | 'required' => false, |
400 | 400 | 'default' => false, |
401 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
401 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
402 | 402 | ) |
403 | 403 | ) |
404 | 404 | ) |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param string $version |
418 | 418 | * @return array |
419 | 419 | */ |
420 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
420 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
421 | 421 | return apply_filters( |
422 | 422 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
423 | 423 | array( |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | 'calculate' => array( |
429 | 429 | 'required' => false, |
430 | 430 | 'default' => '', |
431 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
431 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
432 | 432 | ) |
433 | 433 | ), |
434 | 434 | $model, |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | * @return array describing the args acceptable when querying this model |
447 | 447 | * @throws \EE_Error |
448 | 448 | */ |
449 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
449 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
450 | 450 | $default_orderby = array(); |
451 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
452 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
451 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
452 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
453 | 453 | } |
454 | 454 | return array_merge( |
455 | - $this->_get_response_selection_query_params( $model, $version ), |
|
455 | + $this->_get_response_selection_query_params($model, $version), |
|
456 | 456 | array( |
457 | 457 | 'where' => array( |
458 | 458 | 'required' => false, |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | */ |
490 | 490 | protected function _register_config_routes() { |
491 | 491 | $config_routes = array(); |
492 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
493 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
492 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
493 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
494 | 494 | } |
495 | 495 | return $config_routes; |
496 | 496 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param boolean $hidden_endpoint |
502 | 502 | * @return array |
503 | 503 | */ |
504 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
504 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
505 | 505 | return array( |
506 | 506 | 'config' => array( |
507 | 507 | array( |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | */ |
523 | 523 | protected function _register_meta_routes() { |
524 | 524 | $meta_routes = array(); |
525 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
526 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
525 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
526 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
527 | 527 | } |
528 | 528 | return $meta_routes; |
529 | 529 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @param boolean $hidden_endpoint |
535 | 535 | * @return array |
536 | 536 | */ |
537 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
537 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
538 | 538 | return array( |
539 | 539 | 'resources' => array( |
540 | 540 | array( |
@@ -556,25 +556,25 @@ discard block |
||
556 | 556 | * @param array $route_data |
557 | 557 | * @return array |
558 | 558 | */ |
559 | - public static function hide_old_endpoints( $route_data ) { |
|
559 | + public static function hide_old_endpoints($route_data) { |
|
560 | 560 | //allow API clients to override which endpoints get hidden, in case |
561 | 561 | //they want to discover particular endpoints |
562 | 562 | //also, we don't have access to the request so we have to just grab it from the superglobal |
563 | 563 | $force_show_ee_namespace = ltrim( |
564 | - EEH_Array::is_set( $_REQUEST, 'force_show_ee_namespace', '' ), |
|
564 | + EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
565 | 565 | '/' |
566 | 566 | ); |
567 | 567 | |
568 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
569 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
570 | - foreach( $routes as $route ) { |
|
568 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
569 | + foreach ($relative_urls as $endpoint => $routes) { |
|
570 | + foreach ($routes as $route) { |
|
571 | 571 | //by default, hide "hidden_endpoint"s, unless the request indicates |
572 | 572 | //to $force_show_ee_namespace, in which case only show that one |
573 | 573 | //namespace's endpoints (and hide all others) |
574 | - if( ( $route[ 'hidden_endpoint' ] && $force_show_ee_namespace === '' ) |
|
575 | - || ( $force_show_ee_namespace !== null && $force_show_ee_namespace !== $namespace ) ) { |
|
576 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
577 | - unset( $route_data[ $full_route ] ); |
|
574 | + if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
575 | + || ($force_show_ee_namespace !== null && $force_show_ee_namespace !== $namespace)) { |
|
576 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
577 | + unset($route_data[$full_route]); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | } |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public static function latest_rest_api_version() { |
615 | 615 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
616 | - $versions_served_keys = array_keys( $versions_served ); |
|
617 | - return end( $versions_served_keys ); |
|
616 | + $versions_served_keys = array_keys($versions_served); |
|
617 | + return end($versions_served_keys); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /** |
@@ -628,32 +628,32 @@ discard block |
||
628 | 628 | public static function versions_served() { |
629 | 629 | $versions_served = array(); |
630 | 630 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
631 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
632 | - reset( $possibly_served_versions ); |
|
633 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
634 | - $latest_version = end( $versions_served_historically ); |
|
635 | - reset( $versions_served_historically ); |
|
631 | + $lowest_compatible_version = end($possibly_served_versions); |
|
632 | + reset($possibly_served_versions); |
|
633 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
634 | + $latest_version = end($versions_served_historically); |
|
635 | + reset($versions_served_historically); |
|
636 | 636 | //for each version of core we have ever served: |
637 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
637 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
638 | 638 | //if it's not above the current core version, and it's compatible with the current version of core |
639 | - if( $key_versioned_endpoint == $latest_version ) { |
|
639 | + if ($key_versioned_endpoint == $latest_version) { |
|
640 | 640 | //don't hide the latest version in the index |
641 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
642 | - } else if( |
|
641 | + $versions_served[$key_versioned_endpoint] = false; |
|
642 | + } else if ( |
|
643 | 643 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
644 | 644 | && $key_versioned_endpoint >= $lowest_compatible_version |
645 | 645 | ) { |
646 | 646 | //include, but hide, previous versions which are still supported |
647 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
648 | - } elseif( |
|
647 | + $versions_served[$key_versioned_endpoint] = true; |
|
648 | + } elseif ( |
|
649 | 649 | apply_filters( |
650 | 650 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
651 | 651 | false, |
652 | 652 | $possibly_served_versions |
653 | 653 | ) |
654 | - ){ |
|
654 | + ) { |
|
655 | 655 | //if a version is no longer supported, don't include it in index or list of versions served |
656 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
656 | + $versions_served[$key_versioned_endpoint] = true; |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | return $versions_served; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @return string |
667 | 667 | */ |
668 | 668 | public static function core_version() { |
669 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
669 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @param WP $WP |
692 | 692 | * @return void |
693 | 693 | */ |
694 | - public function run( $WP ) { |
|
694 | + public function run($WP) { |
|
695 | 695 | |
696 | 696 | } |
697 | 697 |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @return void |
881 | 881 | */ |
882 | 882 | public function deactivate_messenger( $messenger_name ) { |
883 | - $this->_initialize_collections(); |
|
884 | - if ( $messenger_name instanceof EE_messenger ) { |
|
883 | + $this->_initialize_collections(); |
|
884 | + if ( $messenger_name instanceof EE_messenger ) { |
|
885 | 885 | $messenger_name = $messenger_name->name; |
886 | 886 | } |
887 | 887 | unset( $this->_active_messengers[ $messenger_name ] ); |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * @param string $message_type_name name of message type being deactivated |
898 | 898 | */ |
899 | 899 | public function deactivate_message_type( $message_type_name ) { |
900 | - $this->_initialize_collections(); |
|
900 | + $this->_initialize_collections(); |
|
901 | 901 | if ( $message_type_name instanceof EE_message_type ) { |
902 | 902 | $message_type_name = $message_type_name->name; |
903 | 903 | } |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * @param string $messenger_name Name of messenger the message type is being deactivated for. |
928 | 928 | */ |
929 | 929 | public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) { |
930 | - $this->_initialize_collections(); |
|
930 | + $this->_initialize_collections(); |
|
931 | 931 | if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
932 | 932 | unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
933 | 933 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * @return void |
135 | 135 | */ |
136 | 136 | protected function _initialize_collections() { |
137 | - if ( $this->_initialized ) { |
|
137 | + if ($this->_initialized) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | $this->_initialized = true; |
141 | 141 | $this->_messenger_collection_loader->load_messengers_from_folder(); |
142 | 142 | $this->_message_type_collection_loader->load_message_types_from_folder(); |
143 | - $this->get_has_activated_messengers_option( true ); |
|
143 | + $this->get_has_activated_messengers_option(true); |
|
144 | 144 | $this->_set_active_messengers_and_message_types(); |
145 | 145 | } |
146 | 146 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @param string $messenger_name |
171 | 171 | * @return \EE_messenger |
172 | 172 | */ |
173 | - public function get_messenger( $messenger_name ) { |
|
174 | - return $this->messenger_collection()->get_by_info( $messenger_name ); |
|
173 | + public function get_messenger($messenger_name) { |
|
174 | + return $this->messenger_collection()->get_by_info($messenger_name); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @param string $messenger |
183 | 183 | * @return EE_messenger | null |
184 | 184 | */ |
185 | - public function get_active_messenger( $messenger ) { |
|
185 | + public function get_active_messenger($messenger) { |
|
186 | 186 | $this->_initialize_collections(); |
187 | - return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null; |
|
187 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * @return \EE_messenger[] |
194 | 194 | */ |
195 | 195 | public function installed_messengers() { |
196 | - if ( empty( $this->_installed_messengers ) ) { |
|
196 | + if (empty($this->_installed_messengers)) { |
|
197 | 197 | $this->_installed_messengers = array(); |
198 | 198 | $this->messenger_collection()->rewind(); |
199 | - while ( $this->messenger_collection()->valid() ) { |
|
200 | - $this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current(); |
|
199 | + while ($this->messenger_collection()->valid()) { |
|
200 | + $this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current(); |
|
201 | 201 | $this->messenger_collection()->next(); |
202 | 202 | } |
203 | 203 | } |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | * @return \EE_messenger |
212 | 212 | * @throws \EE_Error |
213 | 213 | */ |
214 | - public function valid_messenger( $messenger_name ) { |
|
215 | - $messenger = $this->get_messenger( $messenger_name ); |
|
216 | - if ( $messenger instanceof EE_messenger ) { |
|
214 | + public function valid_messenger($messenger_name) { |
|
215 | + $messenger = $this->get_messenger($messenger_name); |
|
216 | + if ($messenger instanceof EE_messenger) { |
|
217 | 217 | return $messenger; |
218 | 218 | } |
219 | 219 | throw new EE_Error( |
220 | 220 | sprintf( |
221 | - __( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ), |
|
221 | + __('The "%1$s" messenger is either invalid or not installed', 'event_espresso'), |
|
222 | 222 | $messenger_name |
223 | 223 | ) |
224 | 224 | ); |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @param string $message_type_name |
251 | 251 | * @return \EE_message_type |
252 | 252 | */ |
253 | - public function get_message_type( $message_type_name ) { |
|
254 | - return $this->message_type_collection()->get_by_info( $message_type_name ); |
|
253 | + public function get_message_type($message_type_name) { |
|
254 | + return $this->message_type_collection()->get_by_info($message_type_name); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | * @param string $message_type_name |
264 | 264 | * @return \EE_message_type|null |
265 | 265 | */ |
266 | - public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
267 | - return $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
268 | - ? $this->get_message_type( $message_type_name ) |
|
266 | + public function get_active_message_type_for_messenger($messenger_name, $message_type_name) { |
|
267 | + return $this->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
268 | + ? $this->get_message_type($message_type_name) |
|
269 | 269 | : null; |
270 | 270 | } |
271 | 271 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return bool |
281 | 281 | */ |
282 | - public function is_message_type_active_for_messenger( $messenger_name, $message_type_name ) { |
|
282 | + public function is_message_type_active_for_messenger($messenger_name, $message_type_name) { |
|
283 | 283 | $this->_initialize_collections(); |
284 | - return ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
284 | + return ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @param string $messenger_name the name of the messenger to check if active. |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | - public function is_messenger_active( $messenger_name ) { |
|
295 | + public function is_messenger_active($messenger_name) { |
|
296 | 296 | $this->_initialize_collections(); |
297 | - return ! empty( $this->_active_message_types[ $messenger_name ] ); |
|
297 | + return ! empty($this->_active_message_types[$messenger_name]); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | * @param string $message_type_name The slug of the message type getting the settings for. |
306 | 306 | * @return array |
307 | 307 | */ |
308 | - public function get_message_type_settings_for_messenger( $messenger_name, $message_type_name ) { |
|
308 | + public function get_message_type_settings_for_messenger($messenger_name, $message_type_name) { |
|
309 | 309 | $settings = array(); |
310 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
311 | - $settings = isset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] ) |
|
312 | - ? $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] |
|
310 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
311 | + $settings = isset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings']) |
|
312 | + ? $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] |
|
313 | 313 | : array(); |
314 | 314 | } |
315 | 315 | return $settings; |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * @param string $messenger_name |
325 | 325 | * @return bool |
326 | 326 | */ |
327 | - public function messenger_has_active_message_types( $messenger_name ) { |
|
327 | + public function messenger_has_active_message_types($messenger_name) { |
|
328 | 328 | $this->_initialize_collections(); |
329 | 329 | return |
330 | - ! empty( $this->_active_message_types[ $messenger_name ] ) |
|
331 | - && ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ] ); |
|
330 | + ! empty($this->_active_message_types[$messenger_name]) |
|
331 | + && ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types']); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | * @param string $messenger_name The messenger being checked |
342 | 342 | * @return EE_message_type[]|array (empty array if no active_message_types) |
343 | 343 | */ |
344 | - public function get_active_message_types_for_messenger( $messenger_name ) { |
|
344 | + public function get_active_message_types_for_messenger($messenger_name) { |
|
345 | 345 | $message_types = array(); |
346 | - if ( ! $this->messenger_has_active_message_types( $messenger_name ) ) { |
|
346 | + if ( ! $this->messenger_has_active_message_types($messenger_name)) { |
|
347 | 347 | return $message_types; |
348 | 348 | } |
349 | 349 | $installed_message_types = $this->installed_message_types(); |
350 | - foreach ( $installed_message_types as $message_type_name => $message_type ) { |
|
351 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
352 | - $message_types[ $message_type_name ] = $message_type; |
|
350 | + foreach ($installed_message_types as $message_type_name => $message_type) { |
|
351 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
352 | + $message_types[$message_type_name] = $message_type; |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | return $message_types; |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | public function list_of_active_message_types() { |
368 | 368 | $active_message_type_names = array(); |
369 | 369 | $this->_initialize_collections(); |
370 | - foreach ( $this->_active_message_types as $messenger => $messenger_settings ) { |
|
371 | - if ( ! isset( $messenger_settings['settings'][ $messenger . '-message_types' ] ) ) { |
|
370 | + foreach ($this->_active_message_types as $messenger => $messenger_settings) { |
|
371 | + if ( ! isset($messenger_settings['settings'][$messenger.'-message_types'])) { |
|
372 | 372 | continue; |
373 | 373 | } |
374 | - foreach ( $messenger_settings['settings'][ $messenger . '-message_types' ] as $message_type_name => $message_type_config ) { |
|
375 | - if ( ! in_array( $message_type_name, $active_message_type_names ) ) { |
|
374 | + foreach ($messenger_settings['settings'][$messenger.'-message_types'] as $message_type_name => $message_type_config) { |
|
375 | + if ( ! in_array($message_type_name, $active_message_type_names)) { |
|
376 | 376 | $active_message_type_names[] = $message_type_name; |
377 | 377 | } |
378 | 378 | } |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | $active_message_types = array(); |
393 | 393 | $installed_message_types = $this->installed_message_types(); |
394 | 394 | $active_message_type_names = $this->list_of_active_message_types(); |
395 | - foreach ( $active_message_type_names as $active_message_type_name ) { |
|
396 | - if ( isset( $installed_message_types[ $active_message_type_name ] ) ) { |
|
397 | - $active_message_types[ $active_message_type_name ] = $installed_message_types[ $active_message_type_name ]; |
|
395 | + foreach ($active_message_type_names as $active_message_type_name) { |
|
396 | + if (isset($installed_message_types[$active_message_type_name])) { |
|
397 | + $active_message_types[$active_message_type_name] = $installed_message_types[$active_message_type_name]; |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | return $active_message_types; |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | * @return \EE_message_type[] |
407 | 407 | */ |
408 | 408 | public function installed_message_types() { |
409 | - if ( empty( $this->_installed_message_types ) ) { |
|
409 | + if (empty($this->_installed_message_types)) { |
|
410 | 410 | $this->message_type_collection()->rewind(); |
411 | - while ( $this->message_type_collection()->valid() ) { |
|
412 | - $this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current(); |
|
411 | + while ($this->message_type_collection()->valid()) { |
|
412 | + $this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current(); |
|
413 | 413 | $this->message_type_collection()->next(); |
414 | 414 | } |
415 | 415 | } |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | * @return \EE_message_type |
423 | 423 | * @throws \EE_Error |
424 | 424 | */ |
425 | - public function valid_message_type( $message_type_name ) { |
|
426 | - $message_type = $this->get_message_type( $message_type_name ); |
|
427 | - if ( $message_type instanceof EE_message_type ) { |
|
425 | + public function valid_message_type($message_type_name) { |
|
426 | + $message_type = $this->get_message_type($message_type_name); |
|
427 | + if ($message_type instanceof EE_message_type) { |
|
428 | 428 | return $message_type; |
429 | 429 | } |
430 | 430 | throw new EE_Error( |
431 | 431 | sprintf( |
432 | - __( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ), |
|
432 | + __('The "%1$s" message type is either invalid or not installed', 'event_espresso'), |
|
433 | 433 | $message_type_name |
434 | 434 | ) |
435 | 435 | ); |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | * @return boolean |
446 | 446 | * @throws \EE_Error |
447 | 447 | */ |
448 | - public function valid_message_type_for_messenger( EE_messenger $messenger, $message_type_name ) { |
|
448 | + public function valid_message_type_for_messenger(EE_messenger $messenger, $message_type_name) { |
|
449 | 449 | $valid_message_types = $messenger->get_valid_message_types(); |
450 | - if ( ! in_array( $message_type_name, $valid_message_types ) ) { |
|
450 | + if ( ! in_array($message_type_name, $valid_message_types)) { |
|
451 | 451 | throw new EE_Error( |
452 | 452 | sprintf( |
453 | 453 | __( |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return array |
476 | 476 | */ |
477 | - public function get_active_messengers_option( $reset = false) { |
|
478 | - if ( $reset ) { |
|
479 | - $this->_active_message_types = get_option( 'ee_active_messengers', array() ); |
|
477 | + public function get_active_messengers_option($reset = false) { |
|
478 | + if ($reset) { |
|
479 | + $this->_active_message_types = get_option('ee_active_messengers', array()); |
|
480 | 480 | } |
481 | 481 | return $this->_active_message_types; |
482 | 482 | } |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * representing this data is used. |
491 | 491 | * @return bool FALSE if not updated, TRUE if updated. |
492 | 492 | */ |
493 | - public function update_active_messengers_option( $active_messenger_settings = array() ) { |
|
494 | - $active_messenger_settings = empty( $active_messenger_settings ) ? $this->_active_message_types : $active_messenger_settings; |
|
493 | + public function update_active_messengers_option($active_messenger_settings = array()) { |
|
494 | + $active_messenger_settings = empty($active_messenger_settings) ? $this->_active_message_types : $active_messenger_settings; |
|
495 | 495 | //make sure _active_message_types is updated (this is the internal cache for the settings). |
496 | 496 | $this->_active_message_types = $active_messenger_settings; |
497 | - return update_option( 'ee_active_messengers', $active_messenger_settings ); |
|
497 | + return update_option('ee_active_messengers', $active_messenger_settings); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | * |
510 | 510 | * @return array |
511 | 511 | */ |
512 | - public function get_has_activated_messengers_option( $reset = false ) { |
|
513 | - if ( $reset || empty( $this->_has_activated_messengers_and_message_types ) ) { |
|
514 | - $this->_has_activated_messengers_and_message_types = get_option( 'ee_has_activated_messenger', array() ); |
|
512 | + public function get_has_activated_messengers_option($reset = false) { |
|
513 | + if ($reset || empty($this->_has_activated_messengers_and_message_types)) { |
|
514 | + $this->_has_activated_messengers_and_message_types = get_option('ee_has_activated_messenger', array()); |
|
515 | 515 | } |
516 | 516 | return $this->_has_activated_messengers_and_message_types; |
517 | 517 | } |
@@ -526,15 +526,15 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return bool FALSE if not updated, TRUE if updated. |
528 | 528 | */ |
529 | - public function update_has_activated_messengers_option( $has_activated_messengers = array() ) { |
|
529 | + public function update_has_activated_messengers_option($has_activated_messengers = array()) { |
|
530 | 530 | //make sure the option has been retrieved from first so we don't overwrite it accidentally. |
531 | - if ( empty( $has_activated_messengers ) && empty( $this->_has_activated_messengers_and_message_types ) ) { |
|
531 | + if (empty($has_activated_messengers) && empty($this->_has_activated_messengers_and_message_types)) { |
|
532 | 532 | $this->get_has_activated_messengers_option(); |
533 | 533 | } |
534 | - $has_activated_messengers = empty( $has_activated_messengers ) |
|
534 | + $has_activated_messengers = empty($has_activated_messengers) |
|
535 | 535 | ? $this->_has_activated_messengers_and_message_types |
536 | 536 | : $has_activated_messengers; |
537 | - return update_option( 'ee_has_activated_messenger', $has_activated_messengers ); |
|
537 | + return update_option('ee_has_activated_messenger', $has_activated_messengers); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n"; |
557 | 557 | // list of activated messengers as set via the admin |
558 | 558 | // note calling `get_active_messengers_options` also initializes the _active_message_types property. |
559 | - $this->get_active_messengers_option( true ); |
|
560 | - $this->ensure_messengers_are_active( array(), false, true ); |
|
559 | + $this->get_active_messengers_option(true); |
|
560 | + $this->ensure_messengers_are_active(array(), false, true); |
|
561 | 561 | $this->update_active_messengers_option(); |
562 | 562 | $this->update_has_activated_messengers_option(); |
563 | 563 | } |
@@ -575,11 +575,11 @@ discard block |
||
575 | 575 | * @param bool $update_option Whether to update the option in the db or not. |
576 | 576 | * @return boolean true if either already active or successfully activated. |
577 | 577 | */ |
578 | - public function ensure_messenger_is_active( $messenger_name, $update_option = true ) { |
|
579 | - if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) { |
|
578 | + public function ensure_messenger_is_active($messenger_name, $update_option = true) { |
|
579 | + if ( ! isset($this->_active_messengers[$messenger_name])) { |
|
580 | 580 | try { |
581 | - $this->activate_messenger( $messenger_name, array(), $update_option ); |
|
582 | - } catch( EE_Error $e ) { |
|
581 | + $this->activate_messenger($messenger_name, array(), $update_option); |
|
582 | + } catch (EE_Error $e) { |
|
583 | 583 | EE_Error::add_error( |
584 | 584 | $e->getMessage(), |
585 | 585 | __FILE__, |
@@ -606,25 +606,25 @@ discard block |
||
606 | 606 | * and a messenger is indicated as active, but is NOT installed, then it will automatically be |
607 | 607 | * deactivated. |
608 | 608 | */ |
609 | - public function ensure_messengers_are_active( $messenger_names = array(), $update_option = true, $verify = false ) { |
|
610 | - $messenger_names = empty( $messenger_names ) ? array_keys( $this->_active_message_types ) : $messenger_names; |
|
609 | + public function ensure_messengers_are_active($messenger_names = array(), $update_option = true, $verify = false) { |
|
610 | + $messenger_names = empty($messenger_names) ? array_keys($this->_active_message_types) : $messenger_names; |
|
611 | 611 | |
612 | 612 | $not_installed = array(); |
613 | - foreach( $messenger_names as $messenger_name ) { |
|
614 | - if ( $verify && ! $this->messenger_collection()->has_by_name( $messenger_name ) ) { |
|
613 | + foreach ($messenger_names as $messenger_name) { |
|
614 | + if ($verify && ! $this->messenger_collection()->has_by_name($messenger_name)) { |
|
615 | 615 | $not_installed[] = $messenger_name; |
616 | - $this->deactivate_messenger( $messenger_name ); |
|
616 | + $this->deactivate_messenger($messenger_name); |
|
617 | 617 | continue; |
618 | 618 | } |
619 | - $this->ensure_messenger_is_active( $messenger_name, $update_option ); |
|
619 | + $this->ensure_messenger_is_active($messenger_name, $update_option); |
|
620 | 620 | } |
621 | 621 | |
622 | - if ( ! empty( $not_installed_messenger ) ) { |
|
622 | + if ( ! empty($not_installed_messenger)) { |
|
623 | 623 | EE_Error::add_error( |
624 | 624 | sprintf( |
625 | - __( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ), |
|
625 | + __('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'), |
|
626 | 626 | '<br />', |
627 | - implode( ', ', $not_installed_messenger ) |
|
627 | + implode(', ', $not_installed_messenger) |
|
628 | 628 | ), |
629 | 629 | __FILE__, __FUNCTION__, __LINE__ |
630 | 630 | ); |
@@ -643,18 +643,18 @@ discard block |
||
643 | 643 | * @return bool Returns true if already is active or if was activated successfully. |
644 | 644 | * @throws \EE_Error |
645 | 645 | */ |
646 | - public function ensure_message_type_is_active( $message_type_name, $messenger_name, $update_option = true ) { |
|
646 | + public function ensure_message_type_is_active($message_type_name, $messenger_name, $update_option = true) { |
|
647 | 647 | // grab the messenger to work with. |
648 | - $messenger = $this->valid_messenger( $messenger_name ); |
|
649 | - if ( $this->valid_message_type_for_messenger( $messenger, $message_type_name ) ) { |
|
648 | + $messenger = $this->valid_messenger($messenger_name); |
|
649 | + if ($this->valid_message_type_for_messenger($messenger, $message_type_name)) { |
|
650 | 650 | //ensure messenger is active (that's an inherent coupling between active message types and the |
651 | 651 | //messenger they are being activated for. |
652 | 652 | try { |
653 | - if ( ! $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
653 | + if ( ! $this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
654 | 654 | //all is good so let's just get it active |
655 | - $this->activate_messenger( $messenger_name, array( $message_type_name ), $update_option ); |
|
655 | + $this->activate_messenger($messenger_name, array($message_type_name), $update_option); |
|
656 | 656 | } |
657 | - } catch( EE_Error $e ) { |
|
657 | + } catch (EE_Error $e) { |
|
658 | 658 | EE_Error::add_error( |
659 | 659 | $e->getMessage(), |
660 | 660 | __FILE__, |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * @param string $messenger_name The name of the messenger that the message types are to be activated on. |
679 | 679 | * @param bool $update_option Whether to persist the activation to the database or not (default true). |
680 | 680 | */ |
681 | - public function ensure_message_types_are_active( $message_type_names, $messenger_name, $update_option = true ) { |
|
681 | + public function ensure_message_types_are_active($message_type_names, $messenger_name, $update_option = true) { |
|
682 | 682 | $message_type_names = (array) $message_type_names; |
683 | - foreach ( $message_type_names as $message_type_name ) { |
|
683 | + foreach ($message_type_names as $message_type_name) { |
|
684 | 684 | // note, intentionally not updating option here because we're in a loop. |
685 | 685 | // We'll follow the instructions of the incoming $update_option argument after the loop. |
686 | - $this->ensure_message_type_is_active( $message_type_name, $messenger_name, false ); |
|
686 | + $this->ensure_message_type_is_active($message_type_name, $messenger_name, false); |
|
687 | 687 | } |
688 | - if ( $update_option ) { |
|
688 | + if ($update_option) { |
|
689 | 689 | $this->update_active_messengers_option(); |
690 | 690 | $this->update_has_activated_messengers_option(); |
691 | 691 | } |
@@ -712,24 +712,24 @@ discard block |
||
712 | 712 | ) { |
713 | 713 | $templates = array(); |
714 | 714 | // grab the messenger to work with. |
715 | - $messenger = $this->messenger_collection()->get_by_info( $messenger_name ); |
|
715 | + $messenger = $this->messenger_collection()->get_by_info($messenger_name); |
|
716 | 716 | // it's inactive. Activate it. |
717 | - if ( $messenger instanceof EE_messenger ) { |
|
718 | - $this->_active_messengers[ $messenger->name ] = $messenger; |
|
717 | + if ($messenger instanceof EE_messenger) { |
|
718 | + $this->_active_messengers[$messenger->name] = $messenger; |
|
719 | 719 | //activate incoming message types set to be activated with messenger. |
720 | - $message_type_names = $this->_activate_message_types( $messenger, $message_type_names ); |
|
720 | + $message_type_names = $this->_activate_message_types($messenger, $message_type_names); |
|
721 | 721 | // setup any initial settings for the messenger if necessary. |
722 | - $this->add_settings_for_messenger( $messenger->name ); |
|
723 | - if ( $update_active_messengers_option ) { |
|
722 | + $this->add_settings_for_messenger($messenger->name); |
|
723 | + if ($update_active_messengers_option) { |
|
724 | 724 | $this->update_active_messengers_option(); |
725 | 725 | $this->update_has_activated_messengers_option(); |
726 | 726 | } |
727 | 727 | //generate new templates if necessary and ensure all related templates that are already in the database are |
728 | 728 | //marked active. Note, this will also deactivate a message type for a messenger if the template |
729 | 729 | //cannot be successfully created during its attempt (only happens for global template attempts). |
730 | - if ( ! empty( $message_type_names ) ) { |
|
731 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true ); |
|
732 | - EEH_MSG_Template::update_to_active( array( $messenger->name ), $message_type_names ); |
|
730 | + if ( ! empty($message_type_names)) { |
|
731 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); |
|
732 | + EEH_MSG_Template::update_to_active(array($messenger->name), $message_type_names); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | return $templates; |
@@ -748,29 +748,29 @@ discard block |
||
748 | 748 | * |
749 | 749 | * @return array |
750 | 750 | */ |
751 | - protected function _activate_message_types( EE_messenger $messenger, $message_type_names = array() ) { |
|
751 | + protected function _activate_message_types(EE_messenger $messenger, $message_type_names = array()) { |
|
752 | 752 | //If $message_type_names is empty, AND $this->_active_message_types is empty, then that means |
753 | 753 | //things have never been initialized (which should happen on EEH_Activation::generate_message_templates). |
754 | 754 | //So ONLY then do we need to actually grab defaults and cycle through them. Otherwise we |
755 | 755 | //only override _active_message_types when an explicit array of $message_type_names has been provided. |
756 | - $message_type_names = empty( $message_type_names ) && ! isset( $this->_active_message_types[ $messenger->name ] ) |
|
756 | + $message_type_names = empty($message_type_names) && ! isset($this->_active_message_types[$messenger->name]) |
|
757 | 757 | ? $messenger->get_default_message_types() |
758 | 758 | : (array) $message_type_names; |
759 | 759 | |
760 | 760 | //now we ALWAYS need to make sure that the messenger is active for the message types we're activating! |
761 | - if ( ! isset( $this->_active_message_types[ $messenger->name ] ) ) { |
|
762 | - $this->_active_message_types[ $messenger->name ]['settings'] = array(); |
|
761 | + if ( ! isset($this->_active_message_types[$messenger->name])) { |
|
762 | + $this->_active_message_types[$messenger->name]['settings'] = array(); |
|
763 | 763 | } |
764 | 764 | |
765 | - if ( $message_type_names ) { |
|
765 | + if ($message_type_names) { |
|
766 | 766 | // cycle thru message types |
767 | - foreach ( $message_type_names as $message_type_name ) { |
|
767 | + foreach ($message_type_names as $message_type_name) { |
|
768 | 768 | //only register the message type as active IF it isn't already active |
769 | 769 | //and if its actually installed. |
770 | 770 | if ( |
771 | - ! $this->is_message_type_active_for_messenger( $messenger->name, $message_type_name ) |
|
771 | + ! $this->is_message_type_active_for_messenger($messenger->name, $message_type_name) |
|
772 | 772 | ) { |
773 | - $this->add_settings_for_message_type( $messenger->name, $message_type_name ); |
|
773 | + $this->add_settings_for_message_type($messenger->name, $message_type_name); |
|
774 | 774 | $this->_set_messenger_has_activated_message_type( |
775 | 775 | $messenger, |
776 | 776 | $message_type_name |
@@ -793,24 +793,24 @@ discard block |
||
793 | 793 | * @param string $message_type_name The name of the message type adding the settings for |
794 | 794 | * @param array $new_settings Any new settings being set for the message type and messenger |
795 | 795 | */ |
796 | - public function add_settings_for_message_type( $messenger_name, $message_type_name, $new_settings = array() ) { |
|
796 | + public function add_settings_for_message_type($messenger_name, $message_type_name, $new_settings = array()) { |
|
797 | 797 | // get installed message type from collection |
798 | - $message_type = $this->message_type_collection()->get_by_info( $message_type_name ); |
|
799 | - $existing_settings = $this->get_message_type_settings_for_messenger( $messenger_name, $message_type_name ); |
|
798 | + $message_type = $this->message_type_collection()->get_by_info($message_type_name); |
|
799 | + $existing_settings = $this->get_message_type_settings_for_messenger($messenger_name, $message_type_name); |
|
800 | 800 | //we need to setup any initial settings for message types |
801 | - if ( $message_type instanceof EE_message_type ) { |
|
801 | + if ($message_type instanceof EE_message_type) { |
|
802 | 802 | $default_settings = $message_type->get_admin_settings_fields(); |
803 | - foreach ( $default_settings as $field => $values ) { |
|
804 | - if ( isset( $new_settings[ $field ] ) ) { |
|
805 | - $existing_settings[ $field ] = $new_settings[ $field ]; |
|
803 | + foreach ($default_settings as $field => $values) { |
|
804 | + if (isset($new_settings[$field])) { |
|
805 | + $existing_settings[$field] = $new_settings[$field]; |
|
806 | 806 | continue; |
807 | 807 | } |
808 | - if ( ! isset( $existing_settings[ $field ] ) ) { |
|
809 | - $existing_settings[ $field ] = $values['default']; |
|
808 | + if ( ! isset($existing_settings[$field])) { |
|
809 | + $existing_settings[$field] = $values['default']; |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | } |
813 | - $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] = $existing_settings; |
|
813 | + $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] = $existing_settings; |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -823,20 +823,20 @@ discard block |
||
823 | 823 | * @param \EE_messenger $messenger |
824 | 824 | * @param string $message_type_name |
825 | 825 | */ |
826 | - protected function _set_messenger_has_activated_message_type( EE_messenger $messenger, $message_type_name ) { |
|
826 | + protected function _set_messenger_has_activated_message_type(EE_messenger $messenger, $message_type_name) { |
|
827 | 827 | |
828 | 828 | //if _has_activated_messengers_and_message_types is empty then lets ensure its initialized |
829 | - if ( empty( $this->_has_activated_messengers_and_message_types ) ) { |
|
829 | + if (empty($this->_has_activated_messengers_and_message_types)) { |
|
830 | 830 | $this->get_has_activated_messengers_option(); |
831 | 831 | } |
832 | 832 | |
833 | 833 | // make sure this messenger has a record in the has_activated array |
834 | - if ( ! isset( $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
835 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ] = array(); |
|
834 | + if ( ! isset($this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
835 | + $this->_has_activated_messengers_and_message_types[$messenger->name] = array(); |
|
836 | 836 | } |
837 | 837 | // check if message type has already been added |
838 | - if ( ! in_array( $message_type_name, $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
839 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ][] = $message_type_name; |
|
838 | + if ( ! in_array($message_type_name, $this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
839 | + $this->_has_activated_messengers_and_message_types[$messenger->name][] = $message_type_name; |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | |
@@ -851,20 +851,20 @@ discard block |
||
851 | 851 | * @param string $messenger_name The name of the messenger the settings is being added for. |
852 | 852 | * @param array $new_settings An array of settings to update the existing settings. |
853 | 853 | */ |
854 | - public function add_settings_for_messenger( $messenger_name, $new_settings = array() ) { |
|
855 | - $messenger = $this->get_messenger( $messenger_name ); |
|
856 | - if ( $messenger instanceof EE_messenger ) { |
|
854 | + public function add_settings_for_messenger($messenger_name, $new_settings = array()) { |
|
855 | + $messenger = $this->get_messenger($messenger_name); |
|
856 | + if ($messenger instanceof EE_messenger) { |
|
857 | 857 | $msgr_settings = $messenger->get_admin_settings_fields(); |
858 | - if ( ! empty( $msgr_settings ) ) { |
|
859 | - foreach ( $msgr_settings as $field => $value ) { |
|
858 | + if ( ! empty($msgr_settings)) { |
|
859 | + foreach ($msgr_settings as $field => $value) { |
|
860 | 860 | //is there a new setting for this? |
861 | - if ( isset( $new_settings[ $field ] ) ) { |
|
862 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $new_settings[ $field ]; |
|
861 | + if (isset($new_settings[$field])) { |
|
862 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $new_settings[$field]; |
|
863 | 863 | continue; |
864 | 864 | } |
865 | 865 | //only set the default if it isn't already set. |
866 | - if ( ! isset( $this->_active_message_types[ $messenger->name ]['settings'][ $field ] ) ) { |
|
867 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $value; |
|
866 | + if ( ! isset($this->_active_message_types[$messenger->name]['settings'][$field])) { |
|
867 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $value; |
|
868 | 868 | } |
869 | 869 | } |
870 | 870 | } |
@@ -879,14 +879,14 @@ discard block |
||
879 | 879 | * @param string|EE_messenger $messenger_name name of messenger |
880 | 880 | * @return void |
881 | 881 | */ |
882 | - public function deactivate_messenger( $messenger_name ) { |
|
882 | + public function deactivate_messenger($messenger_name) { |
|
883 | 883 | $this->_initialize_collections(); |
884 | - if ( $messenger_name instanceof EE_messenger ) { |
|
884 | + if ($messenger_name instanceof EE_messenger) { |
|
885 | 885 | $messenger_name = $messenger_name->name; |
886 | 886 | } |
887 | - unset( $this->_active_messengers[ $messenger_name ] ); |
|
888 | - unset( $this->_active_message_types[ $messenger_name ] ); |
|
889 | - $this->_message_template_group_model->deactivate_message_template_groups_for( $messenger_name ); |
|
887 | + unset($this->_active_messengers[$messenger_name]); |
|
888 | + unset($this->_active_message_types[$messenger_name]); |
|
889 | + $this->_message_template_group_model->deactivate_message_template_groups_for($messenger_name); |
|
890 | 890 | $this->update_active_messengers_option(); |
891 | 891 | } |
892 | 892 | |
@@ -896,22 +896,22 @@ discard block |
||
896 | 896 | * |
897 | 897 | * @param string $message_type_name name of message type being deactivated |
898 | 898 | */ |
899 | - public function deactivate_message_type( $message_type_name ) { |
|
899 | + public function deactivate_message_type($message_type_name) { |
|
900 | 900 | $this->_initialize_collections(); |
901 | - if ( $message_type_name instanceof EE_message_type ) { |
|
901 | + if ($message_type_name instanceof EE_message_type) { |
|
902 | 902 | $message_type_name = $message_type_name->name; |
903 | 903 | } |
904 | - foreach ( $this->_active_message_types as $messenger_name => $settings ) { |
|
904 | + foreach ($this->_active_message_types as $messenger_name => $settings) { |
|
905 | 905 | unset( |
906 | - $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] |
|
906 | + $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name] |
|
907 | 907 | ); |
908 | 908 | |
909 | 909 | //we always record (even on deactivation) that a message type has been activated because there should at |
910 | 910 | //least be a record in the "has_activated" option that it WAS active at one point. |
911 | - $messenger = $this->get_messenger( $messenger_name ); |
|
912 | - $this->_set_messenger_has_activated_message_type( $messenger, $message_type_name ); |
|
911 | + $messenger = $this->get_messenger($messenger_name); |
|
912 | + $this->_set_messenger_has_activated_message_type($messenger, $message_type_name); |
|
913 | 913 | } |
914 | - $this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name ); |
|
914 | + $this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name); |
|
915 | 915 | $this->update_active_messengers_option(); |
916 | 916 | $this->update_has_activated_messengers_option(); |
917 | 917 | } |
@@ -926,12 +926,12 @@ discard block |
||
926 | 926 | * @param string $message_type_name Name of message type being deactivated. |
927 | 927 | * @param string $messenger_name Name of messenger the message type is being deactivated for. |
928 | 928 | */ |
929 | - public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) { |
|
929 | + public function deactivate_message_type_for_messenger($message_type_name, $messenger_name) { |
|
930 | 930 | $this->_initialize_collections(); |
931 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
932 | - unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
931 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
932 | + unset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
933 | 933 | } |
934 | - $this->_message_template_group_model->deactivate_message_template_groups_for( array( $messenger_name ), array( $message_type_name ) ); |
|
934 | + $this->_message_template_group_model->deactivate_message_template_groups_for(array($messenger_name), array($message_type_name)); |
|
935 | 935 | $this->update_active_messengers_option(); |
936 | 936 | } |
937 | 937 | |
@@ -948,12 +948,12 @@ discard block |
||
948 | 948 | * |
949 | 949 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
950 | 950 | */ |
951 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
951 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
952 | 952 | //get the $messengers the message type says it can be used with. |
953 | - foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) { |
|
953 | + foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) { |
|
954 | 954 | if ( |
955 | 955 | $messenger->name === $generating_messenger |
956 | - && $this->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) |
|
956 | + && $this->is_message_type_active_for_messenger($messenger->name, $message_type->name) |
|
957 | 957 | ) { |
958 | 958 | return true; |
959 | 959 | } |
@@ -990,25 +990,25 @@ discard block |
||
990 | 990 | * or all contexts indexed by message type. |
991 | 991 | * @return array |
992 | 992 | */ |
993 | - public function get_all_contexts( $slugs_only = true ) { |
|
993 | + public function get_all_contexts($slugs_only = true) { |
|
994 | 994 | $key = $slugs_only ? 'slugs' : 'all'; |
995 | 995 | // check if contexts has been setup yet. |
996 | - if ( empty( $this->_contexts[ $key ] ) ) { |
|
996 | + if (empty($this->_contexts[$key])) { |
|
997 | 997 | // So let's get all active message type objects and loop through to get all unique contexts |
998 | - foreach ( $this->get_active_message_type_objects() as $message_type ) { |
|
999 | - if ( $message_type instanceof EE_message_type ) { |
|
998 | + foreach ($this->get_active_message_type_objects() as $message_type) { |
|
999 | + if ($message_type instanceof EE_message_type) { |
|
1000 | 1000 | $message_type_contexts = $message_type->get_contexts(); |
1001 | - if ( $slugs_only ) { |
|
1002 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
1003 | - $this->_contexts[ $key ][ $context ] = $context_details[ 'label' ]; |
|
1001 | + if ($slugs_only) { |
|
1002 | + foreach ($message_type_contexts as $context => $context_details) { |
|
1003 | + $this->_contexts[$key][$context] = $context_details['label']; |
|
1004 | 1004 | } |
1005 | 1005 | } else { |
1006 | - $this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts; |
|
1006 | + $this->_contexts[$key][$message_type->name] = $message_type_contexts; |
|
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | } |
1011 | - return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array(); |
|
1011 | + return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array(); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | |
@@ -1027,9 +1027,9 @@ discard block |
||
1027 | 1027 | $installed_message_types = $this->installed_message_types(); |
1028 | 1028 | $all_message_types_valid = true; |
1029 | 1029 | //loop through list of active message types and verify they are installed. |
1030 | - foreach( $list_of_active_message_type_names as $message_type_name ) { |
|
1031 | - if ( ! isset( $installed_message_types[$message_type_name] ) ) { |
|
1032 | - $this->deactivate_message_type( $message_type_name ); |
|
1030 | + foreach ($list_of_active_message_type_names as $message_type_name) { |
|
1031 | + if ( ! isset($installed_message_types[$message_type_name])) { |
|
1032 | + $this->deactivate_message_type($message_type_name); |
|
1033 | 1033 | $all_message_types_valid = false; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1048,10 +1048,10 @@ discard block |
||
1048 | 1048 | * @param $messenger_name |
1049 | 1049 | * @return bool |
1050 | 1050 | */ |
1051 | - public function has_message_type_been_activated_for_messenger( $message_type_name, $messenger_name ) { |
|
1051 | + public function has_message_type_been_activated_for_messenger($message_type_name, $messenger_name) { |
|
1052 | 1052 | $has_activated = $this->get_has_activated_messengers_option(); |
1053 | - return isset( $has_activated[ $messenger_name ] ) |
|
1054 | - && in_array( $message_type_name, $has_activated[ $messenger_name ] ); |
|
1053 | + return isset($has_activated[$messenger_name]) |
|
1054 | + && in_array($message_type_name, $has_activated[$messenger_name]); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | // End of file EE_Message_Resource_Manager.lib.php |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * EE_Attendee_Shortcodes constructor. |
|
44 | - */ |
|
45 | - public function __construct() { |
|
42 | + /** |
|
43 | + * EE_Attendee_Shortcodes constructor. |
|
44 | + */ |
|
45 | + public function __construct() { |
|
46 | 46 | parent::__construct(); |
47 | 47 | } |
48 | 48 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | |
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * handles shortcode parsing |
|
77 | - * |
|
78 | - * @access protected |
|
79 | - * @param string $shortcode the shortcode to be parsed. |
|
80 | - * @return string |
|
81 | - * @throws \EE_Error |
|
82 | - */ |
|
83 | - protected function _parser( $shortcode ) { |
|
75 | + /** |
|
76 | + * handles shortcode parsing |
|
77 | + * |
|
78 | + * @access protected |
|
79 | + * @param string $shortcode the shortcode to be parsed. |
|
80 | + * @return string |
|
81 | + * @throws \EE_Error |
|
82 | + */ |
|
83 | + protected function _parser( $shortcode ) { |
|
84 | 84 | |
85 | 85 | |
86 | 86 | $this->_xtra = !empty($this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : NULL; |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | if ( ! $registration instanceof EE_Registration ) { |
92 | 92 | //let's attempt to get the txn_id for the error message. |
93 | 93 | $txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction ? $this->_xtra->txn->ID() : __('Unknown', 'event_espresso' ); |
94 | - $msg = __('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
|
95 | - 'event_espresso'); |
|
96 | - $dev_msg = sprintf(__('The transaction ID for this request is: %s', 'event_espresso'), $txn_id); |
|
94 | + $msg = __('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
|
95 | + 'event_espresso'); |
|
96 | + $dev_msg = sprintf(__('The transaction ID for this request is: %s', 'event_espresso'), $txn_id); |
|
97 | 97 | throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
98 | 98 | } |
99 | 99 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $attendee = isset( $this->_xtra->registrations[$registration->ID()]['att_obj'] ) ? $this->_xtra->registrations[$registration->ID()]['att_obj'] : null ; |
102 | 102 | |
103 | 103 | if ( ! $attendee instanceof EE_Attendee ) { |
104 | - $msg = __('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
|
105 | - 'event_espresso'); |
|
106 | - $dev_msg = sprintf(__('The registration ID for this request is: %s', 'event_espresso'), |
|
107 | - $registration->ID()); |
|
104 | + $msg = __('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
|
105 | + 'event_espresso'); |
|
106 | + $dev_msg = sprintf(__('The registration ID for this request is: %s', 'event_espresso'), |
|
107 | + $registration->ID()); |
|
108 | 108 | throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
109 | 109 | } |
110 | 110 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | '[ADDRESS2]' => __('Whatever was in the address 2 field for the registration.', 'event_espresso'), |
66 | 66 | '[CITY]' => __('The city for the registration.', 'event_espresso'), |
67 | 67 | '[ZIP_PC]' => __('The ZIP (or Postal) Code for the Registration.', 'event_espresso'), |
68 | - '[ADDRESS_STATE]' => __('The state/province for the registration.', 'event_espresso' ), |
|
68 | + '[ADDRESS_STATE]' => __('The state/province for the registration.', 'event_espresso'), |
|
69 | 69 | '[COUNTRY]' => __('The country for the registration.', 'event_espresso') |
70 | 70 | ); |
71 | 71 | } |
@@ -80,27 +80,27 @@ discard block |
||
80 | 80 | * @return string |
81 | 81 | * @throws \EE_Error |
82 | 82 | */ |
83 | - protected function _parser( $shortcode ) { |
|
83 | + protected function _parser($shortcode) { |
|
84 | 84 | |
85 | 85 | |
86 | - $this->_xtra = !empty($this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : NULL; |
|
86 | + $this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : NULL; |
|
87 | 87 | |
88 | 88 | //incoming object should only be a registration object. |
89 | 89 | $registration = ! $this->_data instanceof EE_Registration ? NULL : $this->_data; |
90 | 90 | |
91 | - if ( ! $registration instanceof EE_Registration ) { |
|
91 | + if ( ! $registration instanceof EE_Registration) { |
|
92 | 92 | //let's attempt to get the txn_id for the error message. |
93 | - $txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction ? $this->_xtra->txn->ID() : __('Unknown', 'event_espresso' ); |
|
93 | + $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction ? $this->_xtra->txn->ID() : __('Unknown', 'event_espresso'); |
|
94 | 94 | $msg = __('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
95 | 95 | 'event_espresso'); |
96 | 96 | $dev_msg = sprintf(__('The transaction ID for this request is: %s', 'event_espresso'), $txn_id); |
97 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
97 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //attendee obj for this registration |
101 | - $attendee = isset( $this->_xtra->registrations[$registration->ID()]['att_obj'] ) ? $this->_xtra->registrations[$registration->ID()]['att_obj'] : null ; |
|
101 | + $attendee = isset($this->_xtra->registrations[$registration->ID()]['att_obj']) ? $this->_xtra->registrations[$registration->ID()]['att_obj'] : null; |
|
102 | 102 | |
103 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
103 | + if ( ! $attendee instanceof EE_Attendee) { |
|
104 | 104 | $msg = __('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
105 | 105 | 'event_espresso'); |
106 | 106 | $dev_msg = sprintf(__('The registration ID for this request is: %s', 'event_espresso'), |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
109 | 109 | } |
110 | 110 | |
111 | - switch ( $shortcode ) { |
|
111 | + switch ($shortcode) { |
|
112 | 112 | |
113 | 113 | case '[FNAME]' : |
114 | 114 | return $attendee->fname(); |