@@ -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 | * Event Espresso |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * date_format and the second value is the time format |
67 | 67 | * @return EE_Ticket |
68 | 68 | */ |
69 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
70 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
71 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
69 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
70 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
71 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | * the website will be used. |
80 | 80 | * @return EE_Ticket |
81 | 81 | */ |
82 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
83 | - return new self( $props_n_values, TRUE, $timezone ); |
|
82 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
83 | + return new self($props_n_values, TRUE, $timezone); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return bool |
90 | 90 | */ |
91 | 91 | public function parent() { |
92 | - return $this->get( 'TKT_parent' ); |
|
92 | + return $this->get('TKT_parent'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | * @param int $DTT_ID the primary key for a particular datetime |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function available( $DTT_ID = 0 ) { |
|
102 | + public function available($DTT_ID = 0) { |
|
103 | 103 | // are we checking availability for a particular datetime ? |
104 | - if ( $DTT_ID ) { |
|
104 | + if ($DTT_ID) { |
|
105 | 105 | // get that datetime object |
106 | - $datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
|
106 | + $datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID))); |
|
107 | 107 | // if ticket sales for this datetime have exceeded the reg limit... |
108 | - if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) { |
|
108 | + if ($datetime instanceof EE_Datetime && $datetime->sold_out()) { |
|
109 | 109 | return FALSE; |
110 | 110 | } |
111 | 111 | } |
@@ -121,22 +121,22 @@ discard block |
||
121 | 121 | * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing |
122 | 122 | * @return mixed status int if the display string isn't requested |
123 | 123 | */ |
124 | - public function ticket_status( $display = FALSE, $remaining = null ) { |
|
125 | - $remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining(); |
|
126 | - if ( ! $remaining ) { |
|
127 | - return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out; |
|
124 | + public function ticket_status($display = FALSE, $remaining = null) { |
|
125 | + $remaining = is_bool($remaining) ? $remaining : $this->is_remaining(); |
|
126 | + if ( ! $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; |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * set to 0 for all related datetimes |
171 | 171 | * @return int |
172 | 172 | */ |
173 | - public function remaining( $DTT_ID = 0 ) { |
|
174 | - return $this->real_quantity_on_ticket('saleable', $DTT_ID ); |
|
173 | + public function remaining($DTT_ID = 0) { |
|
174 | + return $this->real_quantity_on_ticket('saleable', $DTT_ID); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return int |
182 | 182 | */ |
183 | 183 | function min() { |
184 | - return $this->get( 'TKT_min' ); |
|
184 | + return $this->get('TKT_min'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @return boolean |
192 | 192 | */ |
193 | 193 | public function is_expired() { |
194 | - return ( $this->get_raw( 'TKT_end_date' ) < time() ); |
|
194 | + return ($this->get_raw('TKT_end_date') < time()); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @return boolean |
202 | 202 | */ |
203 | 203 | public function is_pending() { |
204 | - return ( $this->get_raw( 'TKT_start_date' ) > time() ); |
|
204 | + return ($this->get_raw('TKT_start_date') > time()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @return boolean |
212 | 212 | */ |
213 | 213 | public function is_on_sale() { |
214 | - return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() ); |
|
214 | + return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time()); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | * @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 |
223 | 223 | * @return array |
224 | 224 | */ |
225 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
226 | - $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : ''; |
|
227 | - $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : ''; |
|
225 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
226 | + $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : ''; |
|
227 | + $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : ''; |
|
228 | 228 | |
229 | - return $first_date && $last_date ? $first_date . $conjunction . $last_date : ''; |
|
229 | + return $first_date && $last_date ? $first_date.$conjunction.$last_date : ''; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | * @return EE_Datetime |
237 | 237 | */ |
238 | 238 | public function first_datetime() { |
239 | - $datetimes = $this->datetimes( array( 'limit' => 1 ) ); |
|
240 | - return reset( $datetimes ); |
|
239 | + $datetimes = $this->datetimes(array('limit' => 1)); |
|
240 | + return reset($datetimes); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | * @param array $query_params see EEM_Base::get_all() |
249 | 249 | * @return EE_Datetime[] |
250 | 250 | */ |
251 | - public function datetimes( $query_params = array() ) { |
|
252 | - if ( ! isset( $query_params[ 'order_by' ] ) ) { |
|
253 | - $query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC'; |
|
251 | + public function datetimes($query_params = array()) { |
|
252 | + if ( ! isset($query_params['order_by'])) { |
|
253 | + $query_params['order_by']['DTT_order'] = 'ASC'; |
|
254 | 254 | } |
255 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
255 | + return $this->get_many_related('Datetime', $query_params); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @return EE_Datetime |
263 | 263 | */ |
264 | 264 | public function last_datetime() { |
265 | - $datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) ); |
|
266 | - return end( $datetimes ); |
|
265 | + $datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC'))); |
|
266 | + return end($datetimes); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -277,22 +277,22 @@ discard block |
||
277 | 277 | * @param int $dtt_id [optional] include the dtt_id with $what = 'datetime'. |
278 | 278 | * @return mixed (array|int) how many tickets have sold |
279 | 279 | */ |
280 | - public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) { |
|
280 | + public function tickets_sold($what = 'ticket', $dtt_id = NULL) { |
|
281 | 281 | $total = 0; |
282 | 282 | $tickets_sold = $this->_all_tickets_sold(); |
283 | - switch ( $what ) { |
|
283 | + switch ($what) { |
|
284 | 284 | case 'ticket' : |
285 | - return $tickets_sold[ 'ticket' ]; |
|
285 | + return $tickets_sold['ticket']; |
|
286 | 286 | break; |
287 | 287 | case 'datetime' : |
288 | - if ( empty( $tickets_sold[ 'datetime' ] ) ) { |
|
288 | + if (empty($tickets_sold['datetime'])) { |
|
289 | 289 | return $total; |
290 | 290 | } |
291 | - if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) { |
|
292 | - 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__ ); |
|
291 | + if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) { |
|
292 | + 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__); |
|
293 | 293 | return $total; |
294 | 294 | } |
295 | - return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ]; |
|
295 | + return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id]; |
|
296 | 296 | break; |
297 | 297 | default: |
298 | 298 | return $total; |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | * @return EE_Ticket[] |
307 | 307 | */ |
308 | 308 | protected function _all_tickets_sold() { |
309 | - $datetimes = $this->get_many_related( 'Datetime' ); |
|
309 | + $datetimes = $this->get_many_related('Datetime'); |
|
310 | 310 | $tickets_sold = array(); |
311 | - if ( ! empty( $datetimes ) ) { |
|
312 | - foreach ( $datetimes as $datetime ) { |
|
313 | - $tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' ); |
|
311 | + if ( ! empty($datetimes)) { |
|
312 | + foreach ($datetimes as $datetime) { |
|
313 | + $tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold'); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | //Tickets sold |
317 | - $tickets_sold[ 'ticket' ] = $this->sold(); |
|
317 | + $tickets_sold['ticket'] = $this->sold(); |
|
318 | 318 | return $tickets_sold; |
319 | 319 | } |
320 | 320 | |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | * @param bool $return_array whether to return as an array indexed by price id or just the object. |
328 | 328 | * @return EE_Price |
329 | 329 | */ |
330 | - public function base_price( $return_array = FALSE ) { |
|
331 | - $_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price ); |
|
332 | - return $return_array ? $this->get_many_related( 'Price', array( $_where ) ) : $this->get_first_related( 'Price', array( $_where ) ); |
|
330 | + public function base_price($return_array = FALSE) { |
|
331 | + $_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price); |
|
332 | + return $return_array ? $this->get_many_related('Price', array($_where)) : $this->get_first_related('Price', array($_where)); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * @return EE_Price[] |
342 | 342 | */ |
343 | 343 | public function price_modifiers() { |
344 | - $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 ) ) ) ); |
|
345 | - return $this->prices( $query_params ); |
|
344 | + $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)))); |
|
345 | + return $this->prices($query_params); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | * @param array $query_params like EEM_Base::get_all |
353 | 353 | * @return EE_Price[] |
354 | 354 | */ |
355 | - public function prices( $query_params = array() ) { |
|
356 | - return $this->get_many_related( 'Price', $query_params ); |
|
355 | + public function prices($query_params = array()) { |
|
356 | + return $this->get_many_related('Price', $query_params); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | * @param array $query_params see EEM_Base::get_all() |
364 | 364 | * @return EE_Datetime_Ticket |
365 | 365 | */ |
366 | - public function datetime_tickets( $query_params = array() ) { |
|
367 | - return $this->get_many_related( 'Datetime_Ticket', $query_params ); |
|
366 | + public function datetime_tickets($query_params = array()) { |
|
367 | + return $this->get_many_related('Datetime_Ticket', $query_params); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | * @param boolean $show_deleted |
376 | 376 | * @return EE_Datetime[] |
377 | 377 | */ |
378 | - public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) { |
|
379 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted ); |
|
378 | + public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) { |
|
379 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * @return string |
387 | 387 | */ |
388 | 388 | function ID() { |
389 | - return $this->get( 'TKT_ID' ); |
|
389 | + return $this->get('TKT_ID'); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return EE_Ticket_Template |
411 | 411 | */ |
412 | 412 | public function template() { |
413 | - return $this->get_first_related( 'Ticket_Template' ); |
|
413 | + return $this->get_first_related('Ticket_Template'); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @return bool |
430 | 430 | */ |
431 | 431 | public function ticket_price() { |
432 | - return $this->get( 'TKT_price' ); |
|
432 | + return $this->get('TKT_price'); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @return mixed |
439 | 439 | */ |
440 | 440 | public function pretty_price() { |
441 | - return $this->get_pretty( 'TKT_price' ); |
|
441 | + return $this->get_pretty('TKT_price'); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | |
@@ -457,17 +457,17 @@ discard block |
||
457 | 457 | * @param bool $no_cache |
458 | 458 | * @return float |
459 | 459 | */ |
460 | - public function get_ticket_total_with_taxes( $no_cache = FALSE ) { |
|
461 | - if ( ! isset( $this->_ticket_total_with_taxes ) || $no_cache ) { |
|
460 | + public function get_ticket_total_with_taxes($no_cache = FALSE) { |
|
461 | + if ( ! isset($this->_ticket_total_with_taxes) || $no_cache) { |
|
462 | 462 | $this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin(); |
463 | 463 | } |
464 | - return (float)$this->_ticket_total_with_taxes; |
|
464 | + return (float) $this->_ticket_total_with_taxes; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
468 | 468 | |
469 | 469 | public function ensure_TKT_Price_correct() { |
470 | - $this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) ); |
|
470 | + $this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this)); |
|
471 | 471 | $this->save(); |
472 | 472 | } |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return float |
478 | 478 | */ |
479 | 479 | public function get_ticket_subtotal() { |
480 | - return EE_Taxes::get_subtotal_for_admin( $this ); |
|
480 | + return EE_Taxes::get_subtotal_for_admin($this); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @return float |
488 | 488 | */ |
489 | 489 | public function get_ticket_taxes_total_for_admin() { |
490 | - return EE_Taxes::get_total_taxes_for_admin( $this ); |
|
490 | + return EE_Taxes::get_total_taxes_for_admin($this); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | |
@@ -497,8 +497,8 @@ discard block |
||
497 | 497 | * @param string $name |
498 | 498 | * @return boolean |
499 | 499 | */ |
500 | - function set_name( $name ) { |
|
501 | - $this->set( 'TKT_name', $name ); |
|
500 | + function set_name($name) { |
|
501 | + $this->set('TKT_name', $name); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return string |
509 | 509 | */ |
510 | 510 | function description() { |
511 | - return $this->get( 'TKT_description' ); |
|
511 | + return $this->get('TKT_description'); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -518,8 +518,8 @@ discard block |
||
518 | 518 | * @param string $description |
519 | 519 | * @return boolean |
520 | 520 | */ |
521 | - function set_description( $description ) { |
|
522 | - $this->set( 'TKT_description', $description ); |
|
521 | + function set_description($description) { |
|
522 | + $this->set('TKT_description', $description); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @param string $tm_frmt |
531 | 531 | * @return string |
532 | 532 | */ |
533 | - function start_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
534 | - return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt ); |
|
533 | + function start_date($dt_frmt = '', $tm_frmt = '') { |
|
534 | + return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | * @param string $start_date |
542 | 542 | * @return void |
543 | 543 | */ |
544 | - function set_start_date( $start_date ) { |
|
545 | - $this->_set_date_time( 'B', $start_date, 'TKT_start_date' ); |
|
544 | + function set_start_date($start_date) { |
|
545 | + $this->_set_date_time('B', $start_date, 'TKT_start_date'); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * @param string $tm_frmt |
554 | 554 | * @return string |
555 | 555 | */ |
556 | - function end_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
557 | - return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt ); |
|
556 | + function end_date($dt_frmt = '', $tm_frmt = '') { |
|
557 | + return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | * @param string $end_date |
565 | 565 | * @return void |
566 | 566 | */ |
567 | - function set_end_date( $end_date ) { |
|
568 | - $this->_set_date_time( 'B', $end_date, 'TKT_end_date' ); |
|
567 | + function set_end_date($end_date) { |
|
568 | + $this->_set_date_time('B', $end_date, 'TKT_end_date'); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -577,8 +577,8 @@ discard block |
||
577 | 577 | * |
578 | 578 | * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
579 | 579 | */ |
580 | - function set_end_time( $time ) { |
|
581 | - $this->_set_time_for( $time, 'TKT_end_date' ); |
|
580 | + function set_end_time($time) { |
|
581 | + $this->_set_time_for($time, 'TKT_end_date'); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | * @param int $min |
589 | 589 | * @return boolean |
590 | 590 | */ |
591 | - function set_min( $min ) { |
|
592 | - $this->set( 'TKT_min', $min ); |
|
591 | + function set_min($min) { |
|
592 | + $this->set('TKT_min', $min); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * @return int |
600 | 600 | */ |
601 | 601 | function max() { |
602 | - return $this->get( 'TKT_max' ); |
|
602 | + return $this->get('TKT_max'); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | * @param int $max |
610 | 610 | * @return boolean |
611 | 611 | */ |
612 | - function set_max( $max ) { |
|
613 | - $this->set( 'TKT_max', $max ); |
|
612 | + function set_max($max) { |
|
613 | + $this->set('TKT_max', $max); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | |
@@ -620,8 +620,8 @@ discard block |
||
620 | 620 | * @param float $price |
621 | 621 | * @return boolean |
622 | 622 | */ |
623 | - function set_price( $price ) { |
|
624 | - $this->set( 'TKT_price', $price ); |
|
623 | + function set_price($price) { |
|
624 | + $this->set('TKT_price', $price); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * @return int |
632 | 632 | */ |
633 | 633 | function sold() { |
634 | - return $this->get_raw( 'TKT_sold' ); |
|
634 | + return $this->get_raw('TKT_sold'); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -641,10 +641,10 @@ discard block |
||
641 | 641 | * @param int $sold |
642 | 642 | * @return boolean |
643 | 643 | */ |
644 | - function set_sold( $sold ) { |
|
644 | + function set_sold($sold) { |
|
645 | 645 | // sold can not go below zero |
646 | - $sold = max( 0, $sold ); |
|
647 | - $this->set( 'TKT_sold', $sold ); |
|
646 | + $sold = max(0, $sold); |
|
647 | + $this->set('TKT_sold', $sold); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | * @param int $qty |
655 | 655 | * @return boolean |
656 | 656 | */ |
657 | - function increase_sold( $qty = 1 ) { |
|
657 | + function increase_sold($qty = 1) { |
|
658 | 658 | $sold = $this->sold() + $qty; |
659 | 659 | // remove ticket reservation, but don't adjust datetime reservations, because that will happen |
660 | 660 | // via \EE_Datetime::increase_sold() when \EE_Ticket::_increase_sold_for_datetimes() is called |
661 | - $this->decrease_reserved( $qty, false ); |
|
662 | - $this->_increase_sold_for_datetimes( $qty ); |
|
663 | - return $this->set_sold( $sold ); |
|
661 | + $this->decrease_reserved($qty, false); |
|
662 | + $this->_increase_sold_for_datetimes($qty); |
|
663 | + return $this->set_sold($sold); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | |
@@ -670,12 +670,12 @@ discard block |
||
670 | 670 | * @param int $qty |
671 | 671 | * @return boolean |
672 | 672 | */ |
673 | - protected function _increase_sold_for_datetimes( $qty = 1 ) { |
|
673 | + protected function _increase_sold_for_datetimes($qty = 1) { |
|
674 | 674 | $datetimes = $this->datetimes(); |
675 | - if ( is_array( $datetimes ) ) { |
|
676 | - foreach ( $datetimes as $datetime ) { |
|
677 | - if ( $datetime instanceof EE_Datetime ) { |
|
678 | - $datetime->increase_sold( $qty ); |
|
675 | + if (is_array($datetimes)) { |
|
676 | + foreach ($datetimes as $datetime) { |
|
677 | + if ($datetime instanceof EE_Datetime) { |
|
678 | + $datetime->increase_sold($qty); |
|
679 | 679 | $datetime->save(); |
680 | 680 | } |
681 | 681 | } |
@@ -689,10 +689,10 @@ discard block |
||
689 | 689 | * @param int $qty |
690 | 690 | * @return boolean |
691 | 691 | */ |
692 | - function decrease_sold( $qty = 1 ) { |
|
692 | + function decrease_sold($qty = 1) { |
|
693 | 693 | $sold = $this->sold() - $qty; |
694 | - $this->_decrease_sold_for_datetimes( $qty ); |
|
695 | - return $this->set_sold( $sold ); |
|
694 | + $this->_decrease_sold_for_datetimes($qty); |
|
695 | + return $this->set_sold($sold); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | |
@@ -703,12 +703,12 @@ discard block |
||
703 | 703 | * @param int $qty |
704 | 704 | * @return boolean |
705 | 705 | */ |
706 | - protected function _decrease_sold_for_datetimes( $qty = 1 ) { |
|
706 | + protected function _decrease_sold_for_datetimes($qty = 1) { |
|
707 | 707 | $datetimes = $this->datetimes(); |
708 | - if ( is_array( $datetimes ) ) { |
|
709 | - foreach ( $datetimes as $datetime ) { |
|
710 | - if ( $datetime instanceof EE_Datetime ) { |
|
711 | - $datetime->decrease_sold( $qty ); |
|
708 | + if (is_array($datetimes)) { |
|
709 | + foreach ($datetimes as $datetime) { |
|
710 | + if ($datetime instanceof EE_Datetime) { |
|
711 | + $datetime->decrease_sold($qty); |
|
712 | 712 | $datetime->save(); |
713 | 713 | } |
714 | 714 | } |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * @return int |
723 | 723 | */ |
724 | 724 | function reserved() { |
725 | - return $this->get_raw( 'TKT_reserved' ); |
|
725 | + return $this->get_raw('TKT_reserved'); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | |
@@ -732,10 +732,10 @@ discard block |
||
732 | 732 | * @param int $reserved |
733 | 733 | * @return boolean |
734 | 734 | */ |
735 | - function set_reserved( $reserved ) { |
|
735 | + function set_reserved($reserved) { |
|
736 | 736 | // reserved can not go below zero |
737 | - $reserved = max( 0, intval( $reserved ) ); |
|
738 | - $this->set( 'TKT_reserved', $reserved ); |
|
737 | + $reserved = max(0, intval($reserved)); |
|
738 | + $this->set('TKT_reserved', $reserved); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | * @param int $qty |
746 | 746 | * @return boolean |
747 | 747 | */ |
748 | - function increase_reserved( $qty = 1 ) { |
|
749 | - $qty = absint( $qty ); |
|
748 | + function increase_reserved($qty = 1) { |
|
749 | + $qty = absint($qty); |
|
750 | 750 | $reserved = $this->reserved() + $qty; |
751 | - $this->_increase_reserved_for_datetimes( $qty ); |
|
752 | - return $this->set_reserved( $reserved ); |
|
751 | + $this->_increase_reserved_for_datetimes($qty); |
|
752 | + return $this->set_reserved($reserved); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | |
@@ -760,12 +760,12 @@ discard block |
||
760 | 760 | * @param int $qty |
761 | 761 | * @return boolean |
762 | 762 | */ |
763 | - protected function _increase_reserved_for_datetimes( $qty = 1 ) { |
|
763 | + protected function _increase_reserved_for_datetimes($qty = 1) { |
|
764 | 764 | $datetimes = $this->datetimes(); |
765 | - if ( is_array( $datetimes ) ) { |
|
766 | - foreach ( $datetimes as $datetime ) { |
|
767 | - if ( $datetime instanceof EE_Datetime ) { |
|
768 | - $datetime->increase_reserved( $qty ); |
|
765 | + if (is_array($datetimes)) { |
|
766 | + foreach ($datetimes as $datetime) { |
|
767 | + if ($datetime instanceof EE_Datetime) { |
|
768 | + $datetime->increase_reserved($qty); |
|
769 | 769 | $datetime->save(); |
770 | 770 | } |
771 | 771 | } |
@@ -781,12 +781,12 @@ discard block |
||
781 | 781 | * @param bool $adjust_datetimes |
782 | 782 | * @return bool |
783 | 783 | */ |
784 | - function decrease_reserved( $qty = 1, $adjust_datetimes = true ) { |
|
785 | - $reserved = $this->reserved() - absint( $qty ); |
|
786 | - if ( $adjust_datetimes ) { |
|
787 | - $this->_decrease_reserved_for_datetimes( $qty ); |
|
784 | + function decrease_reserved($qty = 1, $adjust_datetimes = true) { |
|
785 | + $reserved = $this->reserved() - absint($qty); |
|
786 | + if ($adjust_datetimes) { |
|
787 | + $this->_decrease_reserved_for_datetimes($qty); |
|
788 | 788 | } |
789 | - return $this->set_reserved( $reserved ); |
|
789 | + return $this->set_reserved($reserved); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | |
@@ -797,12 +797,12 @@ discard block |
||
797 | 797 | * @param int $qty |
798 | 798 | * @return boolean |
799 | 799 | */ |
800 | - protected function _decrease_reserved_for_datetimes( $qty = 1 ) { |
|
800 | + protected function _decrease_reserved_for_datetimes($qty = 1) { |
|
801 | 801 | $datetimes = $this->datetimes(); |
802 | - if ( is_array( $datetimes ) ) { |
|
803 | - foreach ( $datetimes as $datetime ) { |
|
804 | - if ( $datetime instanceof EE_Datetime ) { |
|
805 | - $datetime->decrease_reserved( $qty ); |
|
802 | + if (is_array($datetimes)) { |
|
803 | + foreach ($datetimes as $datetime) { |
|
804 | + if ($datetime instanceof EE_Datetime) { |
|
805 | + $datetime->decrease_reserved($qty); |
|
806 | 806 | $datetime->save(); |
807 | 807 | } |
808 | 808 | } |
@@ -823,14 +823,14 @@ discard block |
||
823 | 823 | * |
824 | 824 | * @return int |
825 | 825 | */ |
826 | - function qty( $context = '' ) { |
|
827 | - switch ( $context ) { |
|
826 | + function qty($context = '') { |
|
827 | + switch ($context) { |
|
828 | 828 | case 'reg_limit' : |
829 | 829 | return $this->real_quantity_on_ticket(); |
830 | 830 | case 'saleable' : |
831 | - return $this->real_quantity_on_ticket( 'saleable' ); |
|
831 | + return $this->real_quantity_on_ticket('saleable'); |
|
832 | 832 | default: |
833 | - return $this->get_raw( 'TKT_qty' ); |
|
833 | + return $this->get_raw('TKT_qty'); |
|
834 | 834 | } |
835 | 835 | } |
836 | 836 | |
@@ -849,15 +849,15 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @return int |
851 | 851 | */ |
852 | - function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) { |
|
853 | - $raw = $this->get_raw( 'TKT_qty' ); |
|
852 | + function real_quantity_on_ticket($context = 'reg_limit', $DTT_ID = 0) { |
|
853 | + $raw = $this->get_raw('TKT_qty'); |
|
854 | 854 | // return immediately if it's zero |
855 | - if ( $raw === 0 ) { |
|
855 | + if ($raw === 0) { |
|
856 | 856 | return $raw; |
857 | 857 | } |
858 | 858 | //echo "\n\n<br />Ticket: " . $this->name() . '<br />'; |
859 | 859 | // ensure qty doesn't exceed raw value for THIS ticket |
860 | - $qty = min( EE_INF, $raw ); |
|
860 | + $qty = min(EE_INF, $raw); |
|
861 | 861 | //echo "\n . qty: " . $qty . '<br />'; |
862 | 862 | // calculate this ticket's total sales and reservations |
863 | 863 | $sold_and_reserved_for_this_ticket = $this->sold() + $this->reserved(); |
@@ -866,23 +866,23 @@ discard block |
||
866 | 866 | //echo "\n . sold_and_reserved_for_this_ticket: " . $sold_and_reserved_for_this_ticket . '<br />'; |
867 | 867 | // first we need to calculate the maximum number of tickets available for the datetime |
868 | 868 | // do we want data for one datetime or all of them ? |
869 | - $query_params = $DTT_ID ? array( array( 'DTT_ID' => $DTT_ID ) ) : array(); |
|
870 | - $datetimes = $this->datetimes( $query_params ); |
|
871 | - if ( is_array( $datetimes ) && ! empty( $datetimes ) ) { |
|
872 | - foreach ( $datetimes as $datetime ) { |
|
873 | - if ( $datetime instanceof EE_Datetime ) { |
|
869 | + $query_params = $DTT_ID ? array(array('DTT_ID' => $DTT_ID)) : array(); |
|
870 | + $datetimes = $this->datetimes($query_params); |
|
871 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
872 | + foreach ($datetimes as $datetime) { |
|
873 | + if ($datetime instanceof EE_Datetime) { |
|
874 | 874 | $datetime->refresh_from_db(); |
875 | 875 | //echo "\n . . datetime name: " . $datetime->name() . '<br />'; |
876 | 876 | //echo "\n . . datetime ID: " . $datetime->ID() . '<br />'; |
877 | 877 | // initialize with no restrictions for each datetime |
878 | 878 | // but adjust datetime qty based on datetime reg limit |
879 | - $datetime_qty = min( EE_INF, $datetime->reg_limit() ); |
|
879 | + $datetime_qty = min(EE_INF, $datetime->reg_limit()); |
|
880 | 880 | //echo "\n . . . datetime reg_limit: " . $datetime->reg_limit() . '<br />'; |
881 | 881 | //echo "\n . . . datetime_qty: " . $datetime_qty . '<br />'; |
882 | 882 | // if we want the actual saleable amount, then we need to consider OTHER ticket sales |
883 | 883 | // and reservations for this datetime, that do NOT include sales and reservations |
884 | 884 | // for this ticket (so we add $this->sold() and $this->reserved() back in) |
885 | - if ( $context == 'saleable' ) { |
|
885 | + if ($context == 'saleable') { |
|
886 | 886 | $datetime_qty = max( |
887 | 887 | $datetime_qty - $datetime->sold_and_reserved() + $sold_and_reserved_for_this_ticket, |
888 | 888 | 0 |
@@ -894,16 +894,16 @@ discard block |
||
894 | 894 | $datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0; |
895 | 895 | //echo "\n . . . datetime_qty: " . $datetime_qty . '<br />'; |
896 | 896 | } |
897 | - $qty = min( $datetime_qty, $qty ); |
|
897 | + $qty = min($datetime_qty, $qty); |
|
898 | 898 | //echo "\n . . qty: " . $qty . '<br />'; |
899 | 899 | } |
900 | 900 | } |
901 | 901 | } |
902 | 902 | // NOW that we know the maximum number of tickets available for the datetime |
903 | 903 | // we can finally factor in the details for this specific ticket |
904 | - if ( $qty > 0 && $context == 'saleable' ) { |
|
904 | + if ($qty > 0 && $context == 'saleable') { |
|
905 | 905 | // and subtract the sales for THIS ticket |
906 | - $qty = max( $qty - $sold_and_reserved_for_this_ticket, 0 ); |
|
906 | + $qty = max($qty - $sold_and_reserved_for_this_ticket, 0); |
|
907 | 907 | //echo "\n . qty: " . $qty . '<br />'; |
908 | 908 | } |
909 | 909 | //echo "\nFINAL QTY: " . $qty . "<br /><br />"; |
@@ -919,14 +919,14 @@ discard block |
||
919 | 919 | * @return bool |
920 | 920 | * @throws \EE_Error |
921 | 921 | */ |
922 | - function set_qty( $qty ) { |
|
922 | + function set_qty($qty) { |
|
923 | 923 | $datetimes = $this->datetimes(); |
924 | - foreach ( $datetimes as $datetime ) { |
|
925 | - if ( $datetime instanceof EE_Datetime ) { |
|
926 | - $qty = min( $qty, $datetime->reg_limit() ); |
|
924 | + foreach ($datetimes as $datetime) { |
|
925 | + if ($datetime instanceof EE_Datetime) { |
|
926 | + $qty = min($qty, $datetime->reg_limit()); |
|
927 | 927 | } |
928 | 928 | } |
929 | - $this->set( 'TKT_qty', $qty ); |
|
929 | + $this->set('TKT_qty', $qty); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * @return int |
937 | 937 | */ |
938 | 938 | function uses() { |
939 | - return $this->get( 'TKT_uses' ); |
|
939 | + return $this->get('TKT_uses'); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | * @param int $uses |
947 | 947 | * @return boolean |
948 | 948 | */ |
949 | - function set_uses( $uses ) { |
|
950 | - $this->set( 'TKT_uses', $uses ); |
|
949 | + function set_uses($uses) { |
|
950 | + $this->set('TKT_uses', $uses); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | * @return boolean |
958 | 958 | */ |
959 | 959 | public function required() { |
960 | - return $this->get( 'TKT_required' ); |
|
960 | + return $this->get('TKT_required'); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | |
@@ -967,8 +967,8 @@ discard block |
||
967 | 967 | * @param boolean $required |
968 | 968 | * @return boolean |
969 | 969 | */ |
970 | - public function set_required( $required ) { |
|
971 | - $this->set( 'TKT_required', $required ); |
|
970 | + public function set_required($required) { |
|
971 | + $this->set('TKT_required', $required); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | * @return boolean |
979 | 979 | */ |
980 | 980 | function taxable() { |
981 | - return $this->get( 'TKT_taxable' ); |
|
981 | + return $this->get('TKT_taxable'); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | |
@@ -988,8 +988,8 @@ discard block |
||
988 | 988 | * @param boolean $taxable |
989 | 989 | * @return boolean |
990 | 990 | */ |
991 | - function set_taxable( $taxable ) { |
|
992 | - $this->set( 'TKT_taxable', $taxable ); |
|
991 | + function set_taxable($taxable) { |
|
992 | + $this->set('TKT_taxable', $taxable); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | * @return boolean |
1000 | 1000 | */ |
1001 | 1001 | function is_default() { |
1002 | - return $this->get( 'TKT_is_default' ); |
|
1002 | + return $this->get('TKT_is_default'); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | |
@@ -1009,8 +1009,8 @@ discard block |
||
1009 | 1009 | * @param boolean $is_default |
1010 | 1010 | * @return boolean |
1011 | 1011 | */ |
1012 | - function set_is_default( $is_default ) { |
|
1013 | - $this->set( 'TKT_is_default', $is_default ); |
|
1012 | + function set_is_default($is_default) { |
|
1013 | + $this->set('TKT_is_default', $is_default); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | * @return int |
1021 | 1021 | */ |
1022 | 1022 | function order() { |
1023 | - return $this->get( 'TKT_order' ); |
|
1023 | + return $this->get('TKT_order'); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | |
@@ -1030,8 +1030,8 @@ discard block |
||
1030 | 1030 | * @param int $order |
1031 | 1031 | * @return boolean |
1032 | 1032 | */ |
1033 | - function set_order( $order ) { |
|
1034 | - $this->set( 'TKT_order', $order ); |
|
1033 | + function set_order($order) { |
|
1034 | + $this->set('TKT_order', $order); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | * @return int |
1042 | 1042 | */ |
1043 | 1043 | function row() { |
1044 | - return $this->get( 'TKT_row' ); |
|
1044 | + return $this->get('TKT_row'); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | |
@@ -1051,8 +1051,8 @@ discard block |
||
1051 | 1051 | * @param int $row |
1052 | 1052 | * @return boolean |
1053 | 1053 | */ |
1054 | - function set_row( $row ) { |
|
1055 | - $this->set( 'TKT_row', $row ); |
|
1054 | + function set_row($row) { |
|
1055 | + $this->set('TKT_row', $row); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | * @return boolean |
1063 | 1063 | */ |
1064 | 1064 | function deleted() { |
1065 | - return $this->get( 'TKT_deleted' ); |
|
1065 | + return $this->get('TKT_deleted'); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
@@ -1072,8 +1072,8 @@ discard block |
||
1072 | 1072 | * @param boolean $deleted |
1073 | 1073 | * @return boolean |
1074 | 1074 | */ |
1075 | - function set_deleted( $deleted ) { |
|
1076 | - $this->set( 'TKT_deleted', $deleted ); |
|
1075 | + function set_deleted($deleted) { |
|
1076 | + $this->set('TKT_deleted', $deleted); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | |
@@ -1083,7 +1083,7 @@ discard block |
||
1083 | 1083 | * @return int |
1084 | 1084 | */ |
1085 | 1085 | function parent_ID() { |
1086 | - return $this->get( 'TKT_parent' ); |
|
1086 | + return $this->get('TKT_parent'); |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | |
@@ -1093,8 +1093,8 @@ discard block |
||
1093 | 1093 | * @param int $parent |
1094 | 1094 | * @return boolean |
1095 | 1095 | */ |
1096 | - function set_parent_ID( $parent ) { |
|
1097 | - $this->set( 'TKT_parent', $parent ); |
|
1096 | + function set_parent_ID($parent) { |
|
1097 | + $this->set('TKT_parent', $parent); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | |
@@ -1105,10 +1105,10 @@ discard block |
||
1105 | 1105 | */ |
1106 | 1106 | function name_and_info() { |
1107 | 1107 | $times = array(); |
1108 | - foreach ( $this->datetimes() as $datetime ) { |
|
1108 | + foreach ($this->datetimes() as $datetime) { |
|
1109 | 1109 | $times[] = $datetime->start_date_and_time(); |
1110 | 1110 | } |
1111 | - return $this->name() . " @ " . implode( ", ", $times ) . " for " . $this->price(); |
|
1111 | + return $this->name()." @ ".implode(", ", $times)." for ".$this->price(); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | * @return string |
1119 | 1119 | */ |
1120 | 1120 | function name() { |
1121 | - return $this->get( 'TKT_name' ); |
|
1121 | + return $this->get('TKT_name'); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | * @return float |
1129 | 1129 | */ |
1130 | 1130 | function price() { |
1131 | - return $this->get( 'TKT_price' ); |
|
1131 | + return $this->get('TKT_price'); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
@@ -1138,8 +1138,8 @@ discard block |
||
1138 | 1138 | * @param array $query_params like EEM_Base::get_all's |
1139 | 1139 | * @return EE_Registration[] |
1140 | 1140 | */ |
1141 | - public function registrations( $query_params = array() ) { |
|
1142 | - return $this->get_many_related( 'Registration', $query_params ); |
|
1141 | + public function registrations($query_params = array()) { |
|
1142 | + return $this->get_many_related('Registration', $query_params); |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | |
@@ -1150,8 +1150,8 @@ discard block |
||
1150 | 1150 | * @return int |
1151 | 1151 | */ |
1152 | 1152 | public function update_tickets_sold() { |
1153 | - $count_regs_for_this_ticket = $this->count_registrations( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0 ) ) ); |
|
1154 | - $this->set_sold( $count_regs_for_this_ticket ); |
|
1153 | + $count_regs_for_this_ticket = $this->count_registrations(array(array('STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0))); |
|
1154 | + $this->set_sold($count_regs_for_this_ticket); |
|
1155 | 1155 | $this->save(); |
1156 | 1156 | return $count_regs_for_this_ticket; |
1157 | 1157 | } |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | * @param array $query_params like EEM_Base::get_all's |
1164 | 1164 | * @return int |
1165 | 1165 | */ |
1166 | - public function count_registrations( $query_params = array() ) { |
|
1166 | + public function count_registrations($query_params = array()) { |
|
1167 | 1167 | return $this->count_related('Registration', $query_params); |
1168 | 1168 | } |
1169 | 1169 | |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | public function get_related_event() { |
1189 | 1189 | //get one datetime to use for getting the event |
1190 | 1190 | $datetime = $this->first_datetime(); |
1191 | - if ( $datetime instanceof EE_Datetime ) { |
|
1191 | + if ($datetime instanceof EE_Datetime) { |
|
1192 | 1192 | return $datetime->event(); |
1193 | 1193 | } |
1194 | 1194 | return null; |
@@ -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 | * Event Espresso |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * date_format and the second value is the time format |
75 | 75 | * @return EE_Datetime |
76 | 76 | */ |
77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * the website will be used. |
88 | 88 | * @return EE_Datetime |
89 | 89 | */ |
90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
91 | + return new self($props_n_values, TRUE, $timezone); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @param $name |
98 | 98 | */ |
99 | - public function set_name( $name ) { |
|
100 | - $this->set( 'DTT_name', $name ); |
|
99 | + public function set_name($name) { |
|
100 | + $this->set('DTT_name', $name); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param $description |
107 | 107 | */ |
108 | - public function set_description( $description ) { |
|
109 | - $this->set( 'DTT_description', $description ); |
|
108 | + public function set_description($description) { |
|
109 | + $this->set('DTT_description', $description); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @access public |
120 | 120 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
121 | 121 | */ |
122 | - public function set_start_date( $date ) { |
|
123 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
122 | + public function set_start_date($date) { |
|
123 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @access public |
134 | 134 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
135 | 135 | */ |
136 | - public function set_start_time( $time ) { |
|
137 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
136 | + public function set_start_time($time) { |
|
137 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @access public |
148 | 148 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
149 | 149 | */ |
150 | - public function set_end_date( $date ) { |
|
151 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
150 | + public function set_end_date($date) { |
|
151 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @access public |
162 | 162 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
163 | 163 | */ |
164 | - public function set_end_time( $time ) { |
|
165 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
164 | + public function set_end_time($time) { |
|
165 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param int $reg_limit |
177 | 177 | */ |
178 | - public function set_reg_limit( $reg_limit ) { |
|
179 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
178 | + public function set_reg_limit($reg_limit) { |
|
179 | + $this->set('DTT_reg_limit', $reg_limit); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @return mixed int on success, FALSE on fail |
189 | 189 | */ |
190 | 190 | public function sold() { |
191 | - return $this->get_raw( 'DTT_sold' ); |
|
191 | + return $this->get_raw('DTT_sold'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @access public |
200 | 200 | * @param int $sold |
201 | 201 | */ |
202 | - public function set_sold( $sold ) { |
|
202 | + public function set_sold($sold) { |
|
203 | 203 | // sold can not go below zero |
204 | - $sold = max( 0, $sold ); |
|
205 | - $this->set( 'DTT_sold', $sold ); |
|
204 | + $sold = max(0, $sold); |
|
205 | + $this->set('DTT_sold', $sold); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * increments sold by amount passed by $qty |
212 | 212 | * @param int $qty |
213 | 213 | */ |
214 | - function increase_sold( $qty = 1 ) { |
|
214 | + function increase_sold($qty = 1) { |
|
215 | 215 | $sold = $this->sold() + $qty; |
216 | 216 | // remove ticket reservation |
217 | - $this->decrease_reserved( $qty ); |
|
218 | - $this->set_sold( $sold ); |
|
217 | + $this->decrease_reserved($qty); |
|
218 | + $this->set_sold($sold); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * decrements (subtracts) sold amount passed by $qty |
225 | 225 | * @param int $qty |
226 | 226 | */ |
227 | - function decrease_sold( $qty = 1 ) { |
|
227 | + function decrease_sold($qty = 1) { |
|
228 | 228 | $sold = $this->sold() - $qty; |
229 | - $this->set_sold( $sold ); |
|
229 | + $this->set_sold($sold); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return int |
238 | 238 | */ |
239 | 239 | function reserved() { |
240 | - return $this->get_raw( 'DTT_reserved' ); |
|
240 | + return $this->get_raw('DTT_reserved'); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | * @param int $reserved |
249 | 249 | * @return boolean |
250 | 250 | */ |
251 | - function set_reserved( $reserved ) { |
|
251 | + function set_reserved($reserved) { |
|
252 | 252 | // reserved can not go below zero |
253 | - $reserved = max( 0, intval( $reserved ) ); |
|
254 | - $this->set( 'DTT_reserved', $reserved ); |
|
253 | + $reserved = max(0, intval($reserved)); |
|
254 | + $this->set('DTT_reserved', $reserved); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | * @param int $qty |
263 | 263 | * @return boolean |
264 | 264 | */ |
265 | - function increase_reserved( $qty = 1 ) { |
|
266 | - $reserved = $this->reserved() + absint( $qty ); |
|
267 | - return $this->set_reserved( $reserved ); |
|
265 | + function increase_reserved($qty = 1) { |
|
266 | + $reserved = $this->reserved() + absint($qty); |
|
267 | + return $this->set_reserved($reserved); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @param int $qty |
276 | 276 | * @return boolean |
277 | 277 | */ |
278 | - function decrease_reserved( $qty = 1 ) { |
|
279 | - $reserved = $this->reserved() - absint( $qty ); |
|
280 | - return $this->set_reserved( $reserved ); |
|
278 | + function decrease_reserved($qty = 1) { |
|
279 | + $reserved = $this->reserved() - absint($qty); |
|
280 | + return $this->set_reserved($reserved); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return string |
299 | 299 | */ |
300 | 300 | public function name() { |
301 | - return $this->get( 'DTT_name' ); |
|
301 | + return $this->get('DTT_name'); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return string |
309 | 309 | */ |
310 | 310 | public function description() { |
311 | - return $this->get( 'DTT_description' ); |
|
311 | + return $this->get('DTT_description'); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return boolean TRUE if is primary, FALSE if not. |
319 | 319 | */ |
320 | 320 | public function is_primary() { |
321 | - return $this->get( 'DTT_is_primary' ); |
|
321 | + return $this->get('DTT_is_primary'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return int The order of the datetime for this event. |
329 | 329 | */ |
330 | 330 | public function order() { |
331 | - return $this->get( 'DTT_order' ); |
|
331 | + return $this->get('DTT_order'); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @return int |
339 | 339 | */ |
340 | 340 | public function parent() { |
341 | - return $this->get( 'DTT_parent' ); |
|
341 | + return $this->get('DTT_parent'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
355 | 355 | * @return string|bool|void string on success, FALSE on fail |
356 | 356 | */ |
357 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
357 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
358 | 358 | $field_name = "DTT_EVT_{$start_or_end}"; |
359 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
360 | - if ( ! $echo ) { |
|
359 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
360 | + if ( ! $echo) { |
|
361 | 361 | return $dtt; |
362 | 362 | } |
363 | 363 | return ''; |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
374 | 374 | * @return mixed string on success, FALSE on fail |
375 | 375 | */ |
376 | - public function start_date( $dt_frmt = NULL ) { |
|
377 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
376 | + public function start_date($dt_frmt = NULL) { |
|
377 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | * Echoes start_date() |
384 | 384 | * @param string $dt_frmt |
385 | 385 | */ |
386 | - public function e_start_date( $dt_frmt = NULL ) { |
|
387 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
386 | + public function e_start_date($dt_frmt = NULL) { |
|
387 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
398 | 398 | * @return mixed string on success, FALSE on fail |
399 | 399 | */ |
400 | - public function end_date( $dt_frmt = NULL ) { |
|
401 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
400 | + public function end_date($dt_frmt = NULL) { |
|
401 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | * Echoes the end date. See end_date() |
408 | 408 | * @param string $dt_frmt |
409 | 409 | */ |
410 | - public function e_end_date( $dt_frmt = NULL ) { |
|
411 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
410 | + public function e_end_date($dt_frmt = NULL) { |
|
411 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * @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 |
422 | 422 | * @return mixed string on success, FALSE on fail |
423 | 423 | */ |
424 | - public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
425 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
426 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
427 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
428 | - return $start != $end ? $start . $conjunction . $end : $start; |
|
424 | + public function date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
425 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
426 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
427 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
428 | + return $start != $end ? $start.$conjunction.$end : $start; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @param null $dt_frmt |
435 | 435 | * @param string $conjunction |
436 | 436 | */ |
437 | - public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
438 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
437 | + public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
438 | + echo $this->date_range($dt_frmt, $conjunction); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
448 | 448 | * @return mixed string on success, FALSE on fail |
449 | 449 | */ |
450 | - public function start_time( $tm_format = NULL ) { |
|
451 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
450 | + public function start_time($tm_format = NULL) { |
|
451 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @param null $tm_format |
458 | 458 | */ |
459 | - public function e_start_time( $tm_format = NULL ) { |
|
460 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
459 | + public function e_start_time($tm_format = NULL) { |
|
460 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
470 | 470 | * @return mixed string on success, FALSE on fail |
471 | 471 | */ |
472 | - public function end_time( $tm_format = NULL ) { |
|
473 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
472 | + public function end_time($tm_format = NULL) { |
|
473 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | /** |
479 | 479 | * @param null $tm_format |
480 | 480 | */ |
481 | - public function e_end_time( $tm_format = NULL ) { |
|
482 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
481 | + public function e_end_time($tm_format = NULL) { |
|
482 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @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 |
493 | 493 | * @return mixed string on success, FALSE on fail |
494 | 494 | */ |
495 | - public function time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
496 | - $tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
495 | + public function time_range($tm_format = NULL, $conjunction = ' - ') { |
|
496 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
497 | 497 | |
498 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
499 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
500 | - return $start != $end ? $start . $conjunction . $end : $start; |
|
498 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
499 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
500 | + return $start != $end ? $start.$conjunction.$end : $start; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | * @param null $tm_format |
507 | 507 | * @param string $conjunction |
508 | 508 | */ |
509 | - public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
510 | - echo $this->time_range( $tm_format, $conjunction ); |
|
509 | + public function e_time_range($tm_format = NULL, $conjunction = ' - ') { |
|
510 | + echo $this->time_range($tm_format, $conjunction); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
521 | 521 | * @return mixed string on success, FALSE on fail |
522 | 522 | */ |
523 | - public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) { |
|
524 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
523 | + public function start_date_and_time($dt_format = NULL, $tm_format = NULL) { |
|
524 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @param null $dt_frmt |
531 | 531 | * @param null $tm_format |
532 | 532 | */ |
533 | - public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) { |
|
534 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
533 | + public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) { |
|
534 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | * @param bool $round_up |
546 | 546 | * @return float|int|mixed |
547 | 547 | */ |
548 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
549 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
550 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
548 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
549 | + $start = $this->get_raw('DTT_EVT_start'); |
|
550 | + $end = $this->get_raw('DTT_EVT_end'); |
|
551 | 551 | $length_in_units = $end - $start; |
552 | - switch ( $units ) { |
|
552 | + switch ($units) { |
|
553 | 553 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
554 | 554 | /** @noinspection PhpMissingBreakStatementInspection */ |
555 | 555 | case 'days': |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | $length_in_units /= 60; |
563 | 563 | case 'seconds': |
564 | 564 | default: |
565 | - $length_in_units = ceil( $length_in_units ); |
|
565 | + $length_in_units = ceil($length_in_units); |
|
566 | 566 | } |
567 | - if ( $round_up ) { |
|
568 | - $length_in_units = max( $length_in_units, 1 ); |
|
567 | + if ($round_up) { |
|
568 | + $length_in_units = max($length_in_units, 1); |
|
569 | 569 | } |
570 | 570 | return $length_in_units; |
571 | 571 | } |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @param bool | string $tm_format - string representation of time format defaults to 'g:i a' |
581 | 581 | * @return mixed string on success, FALSE on fail |
582 | 582 | */ |
583 | - public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
584 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
583 | + public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
584 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @param bool $dt_frmt |
591 | 591 | * @param bool $tm_format |
592 | 592 | */ |
593 | - public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
594 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
593 | + public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
594 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | * @return int |
604 | 604 | */ |
605 | 605 | public function start() { |
606 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
606 | + return $this->get_raw('DTT_EVT_start'); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @return int |
616 | 616 | */ |
617 | 617 | public function end() { |
618 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
618 | + return $this->get_raw('DTT_EVT_end'); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @return mixed int on success, FALSE on fail |
628 | 628 | */ |
629 | 629 | public function reg_limit() { |
630 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
630 | + return $this->get_raw('DTT_reg_limit'); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | |
@@ -656,15 +656,15 @@ discard block |
||
656 | 656 | * the spaces remaining for this particular datetime, hence the flag. |
657 | 657 | * @return int |
658 | 658 | */ |
659 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
659 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
660 | 660 | // tickets remaining available for purchase |
661 | 661 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
662 | 662 | $dtt_remaining = $this->reg_limit() - $this->sold(); |
663 | - if ( ! $consider_tickets ) { |
|
663 | + if ( ! $consider_tickets) { |
|
664 | 664 | return $dtt_remaining; |
665 | 665 | } |
666 | 666 | $tickets_remaining = $this->tickets_remaining(); |
667 | - return min( $dtt_remaining, $tickets_remaining ); |
|
667 | + return min($dtt_remaining, $tickets_remaining); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -675,19 +675,19 @@ discard block |
||
675 | 675 | * @param array $query_params like EEM_Base::get_all's |
676 | 676 | * @return int |
677 | 677 | */ |
678 | - public function tickets_remaining( $query_params = array() ) { |
|
678 | + public function tickets_remaining($query_params = array()) { |
|
679 | 679 | $sum = 0; |
680 | - $tickets = $this->tickets( $query_params ); |
|
681 | - if ( ! empty( $tickets ) ) { |
|
682 | - foreach ( $tickets as $ticket ) { |
|
683 | - if ( $ticket instanceof EE_Ticket ) { |
|
680 | + $tickets = $this->tickets($query_params); |
|
681 | + if ( ! empty($tickets)) { |
|
682 | + foreach ($tickets as $ticket) { |
|
683 | + if ($ticket instanceof EE_Ticket) { |
|
684 | 684 | // get the actual amount of tickets that can be sold |
685 | - $qty = $ticket->qty( 'saleable' ); |
|
686 | - if ( $qty === EE_INF ) { |
|
685 | + $qty = $ticket->qty('saleable'); |
|
686 | + if ($qty === EE_INF) { |
|
687 | 687 | return EE_INF; |
688 | 688 | } |
689 | 689 | // no negative ticket quantities plz |
690 | - if ( $qty > 0 ) { |
|
690 | + if ($qty > 0) { |
|
691 | 691 | $sum += $qty; |
692 | 692 | } |
693 | 693 | } |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | * @param array $query_params like EEM_Base::get_all's |
705 | 705 | * @return int |
706 | 706 | */ |
707 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
708 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
707 | + public function sum_tickets_initially_available($query_params = array()) { |
|
708 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @return int |
718 | 718 | */ |
719 | 719 | public function total_tickets_available_at_this_datetime() { |
720 | - return $this->spaces_remaining( true ); |
|
720 | + return $this->spaces_remaining(true); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @return boolean |
729 | 729 | */ |
730 | 730 | public function is_upcoming() { |
731 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
731 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | * @return boolean |
739 | 739 | */ |
740 | 740 | public function is_active() { |
741 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
741 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * @return boolean |
749 | 749 | */ |
750 | 750 | public function is_expired() { |
751 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
751 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -759,16 +759,16 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public function get_active_status() { |
761 | 761 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
762 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
762 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
763 | 763 | return EE_Datetime::sold_out; |
764 | 764 | } |
765 | - if ( $this->is_expired() ) { |
|
765 | + if ($this->is_expired()) { |
|
766 | 766 | return EE_Datetime::expired; |
767 | 767 | } |
768 | - if ( $this->is_upcoming() ) { |
|
768 | + if ($this->is_upcoming()) { |
|
769 | 769 | return EE_Datetime::upcoming; |
770 | 770 | } |
771 | - if ( $this->is_active() ) { |
|
771 | + if ($this->is_active()) { |
|
772 | 772 | return EE_Datetime::active; |
773 | 773 | } |
774 | 774 | return NULL; |
@@ -782,24 +782,24 @@ discard block |
||
782 | 782 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
783 | 783 | * @return string |
784 | 784 | */ |
785 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
786 | - if ( $use_dtt_name ) { |
|
785 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
786 | + if ($use_dtt_name) { |
|
787 | 787 | $dtt_name = $this->name(); |
788 | - if ( !empty( $dtt_name ) ) { |
|
788 | + if ( ! empty($dtt_name)) { |
|
789 | 789 | return $dtt_name; |
790 | 790 | } |
791 | 791 | } |
792 | 792 | //first condition is to see if the months are different |
793 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
794 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
793 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
794 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
795 | 795 | //next condition is if its the same month but different day |
796 | 796 | } |
797 | 797 | else { |
798 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
799 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
798 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
799 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
800 | 800 | } |
801 | 801 | else { |
802 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
802 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
803 | 803 | } |
804 | 804 | } |
805 | 805 | return $display_date; |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | *@param array $query_params see EEM_Base::get_all() |
814 | 814 | * @return EE_Ticket[] |
815 | 815 | */ |
816 | - public function tickets( $query_params = array() ) { |
|
817 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
816 | + public function tickets($query_params = array()) { |
|
817 | + return $this->get_many_related('Ticket', $query_params); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | |
@@ -824,21 +824,21 @@ discard block |
||
824 | 824 | * @param array $query_params like EEM_Base::get_all's |
825 | 825 | * @return EE_Ticket[] |
826 | 826 | */ |
827 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
827 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
828 | 828 | // first check if datetime is valid |
829 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
829 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
830 | 830 | return array(); |
831 | 831 | } |
832 | - if ( empty( $query_params ) ) { |
|
832 | + if (empty($query_params)) { |
|
833 | 833 | $query_params = array( |
834 | 834 | array( |
835 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
836 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
835 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
836 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
837 | 837 | 'TKT_deleted' => false |
838 | 838 | ) |
839 | 839 | ); |
840 | 840 | } |
841 | - return $this->tickets( $query_params ); |
|
841 | + return $this->tickets($query_params); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | * @return EE_Event |
849 | 849 | */ |
850 | 850 | public function event() { |
851 | - return $this->get_first_related( 'Event' ); |
|
851 | + return $this->get_first_related('Event'); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | |
@@ -860,13 +860,13 @@ discard block |
||
860 | 860 | */ |
861 | 861 | public function update_sold() { |
862 | 862 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
863 | - array( array( |
|
863 | + array(array( |
|
864 | 864 | 'STS_ID' => EEM_Registration::status_id_approved, |
865 | 865 | 'REG_deleted' => 0, |
866 | 866 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
867 | - ) ) |
|
867 | + )) |
|
868 | 868 | ); |
869 | - $this->set( 'DTT_sold', $count_regs_for_this_datetime ); |
|
869 | + $this->set('DTT_sold', $count_regs_for_this_datetime); |
|
870 | 870 | $this->save(); |
871 | 871 | return $count_regs_for_this_datetime; |
872 | 872 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.0 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEH_Debug_Tools{ |
|
11 | +class EEH_Debug_Tools { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
45 | 45 | self::$_instance = new self(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function __construct() { |
59 | 59 | // load Kint PHP debugging library |
60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
67 | 67 | } |
68 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
68 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
70 | 70 | } |
71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public static function show_db_name() { |
85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function espresso_session_footer_dump() { |
98 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
99 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
100 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
98 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
99 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
100 | + Kint::dump(EE_Registry::instance()->SSN); |
|
101 | 101 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
102 | 102 | $this->espresso_list_hooked_functions(); |
103 | 103 | $this->show_times(); |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | * @param bool $tag |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
117 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
118 | 118 | global $wp_filter; |
119 | 119 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
120 | - if ( $tag ) { |
|
121 | - $hook[$tag]=$wp_filter[$tag]; |
|
122 | - if ( ! is_array( $hook[$tag] )) { |
|
123 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
120 | + if ($tag) { |
|
121 | + $hook[$tag] = $wp_filter[$tag]; |
|
122 | + if ( ! is_array($hook[$tag])) { |
|
123 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
124 | 124 | return; |
125 | 125 | } |
126 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
126 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
127 | 127 | } |
128 | 128 | else { |
129 | - $hook=$wp_filter; |
|
130 | - ksort( $hook ); |
|
129 | + $hook = $wp_filter; |
|
130 | + ksort($hook); |
|
131 | 131 | } |
132 | - foreach( $hook as $tag => $priorities ) { |
|
132 | + foreach ($hook as $tag => $priorities) { |
|
133 | 133 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
134 | - ksort( $priorities ); |
|
135 | - foreach( $priorities as $priority => $function ){ |
|
134 | + ksort($priorities); |
|
135 | + foreach ($priorities as $priority => $function) { |
|
136 | 136 | echo $priority; |
137 | - foreach( $function as $name => $properties ) { |
|
137 | + foreach ($function as $name => $properties) { |
|
138 | 138 | echo "\t$name<br />"; |
139 | 139 | } |
140 | 140 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @param string $hook_name |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
153 | + public static function registered_filter_callbacks($hook_name = '') { |
|
154 | 154 | $filters = array(); |
155 | 155 | global $wp_filter; |
156 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
157 | - $filters[ $hook_name ] = array(); |
|
158 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
159 | - $filters[ $hook_name ][ $priority ] = array(); |
|
160 | - foreach ( $callbacks as $callback ) { |
|
161 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
156 | + if (isset($wp_filter[$hook_name])) { |
|
157 | + $filters[$hook_name] = array(); |
|
158 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
159 | + $filters[$hook_name][$priority] = array(); |
|
160 | + foreach ($callbacks as $callback) { |
|
161 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * start_timer |
172 | 172 | * @param null $timer_name |
173 | 173 | */ |
174 | - public function start_timer( $timer_name = NULL ){ |
|
175 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
174 | + public function start_timer($timer_name = NULL) { |
|
175 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * stop_timer |
182 | 182 | * @param string $timer_name |
183 | 183 | */ |
184 | - public function stop_timer($timer_name = 'default'){ |
|
185 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
186 | - $start_time = $this->_start_times[ $timer_name ]; |
|
187 | - unset( $this->_start_times[ $timer_name ] ); |
|
188 | - }else{ |
|
189 | - $start_time = array_pop( $this->_start_times ); |
|
184 | + public function stop_timer($timer_name = 'default') { |
|
185 | + if (isset($this->_start_times[$timer_name])) { |
|
186 | + $start_time = $this->_start_times[$timer_name]; |
|
187 | + unset($this->_start_times[$timer_name]); |
|
188 | + } else { |
|
189 | + $start_time = array_pop($this->_start_times); |
|
190 | 190 | } |
191 | - $total_time = microtime( TRUE ) - $start_time; |
|
192 | - switch ( $total_time ) { |
|
191 | + $total_time = microtime(TRUE) - $start_time; |
|
192 | + switch ($total_time) { |
|
193 | 193 | case $total_time < 0.00001 : |
194 | 194 | $color = '#8A549A'; |
195 | 195 | $bold = 'normal'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $bold = 'bold'; |
216 | 216 | break; |
217 | 217 | } |
218 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
218 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
219 | 219 | } |
220 | 220 | /** |
221 | 221 | * Measure the memory usage by PHP so far. |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function measure_memory( $label, $output_now = false ) { |
|
227 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
228 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
229 | - if( $output_now ) { |
|
226 | + public function measure_memory($label, $output_now = false) { |
|
227 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
228 | + $this->_memory_usage_points[$label] = $memory_used; |
|
229 | + if ($output_now) { |
|
230 | 230 | echo "\r\n<br>$label : $memory_used"; |
231 | 231 | } |
232 | 232 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param int $size |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function convert( $size ) { |
|
240 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
241 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ]; |
|
239 | + public function convert($size) { |
|
240 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
241 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param bool $output_now |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function show_times($output_now=true){ |
|
252 | - $output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points ); |
|
253 | - if($output_now){ |
|
251 | + public function show_times($output_now = true) { |
|
252 | + $output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points); |
|
253 | + if ($output_now) { |
|
254 | 254 | echo $output; |
255 | 255 | return ''; |
256 | 256 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | * @return void |
266 | 266 | */ |
267 | 267 | public static function ee_plugin_activation_errors() { |
268 | - if ( WP_DEBUG ) { |
|
268 | + if (WP_DEBUG) { |
|
269 | 269 | $activation_errors = ob_get_contents(); |
270 | - if ( ! empty( $activation_errors ) ) { |
|
271 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
270 | + if ( ! empty($activation_errors)) { |
|
271 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
272 | 272 | } |
273 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
274 | - if ( class_exists( 'EEH_File' )) { |
|
273 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
274 | + if (class_exists('EEH_File')) { |
|
275 | 275 | try { |
276 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
277 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
278 | - } catch( EE_Error $e ){ |
|
279 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
276 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
277 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
278 | + } catch (EE_Error $e) { |
|
279 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | // old school attempt |
283 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
283 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
284 | 284 | } |
285 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
286 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
285 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
286 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -299,22 +299,22 @@ discard block |
||
299 | 299 | * @param int $error_type |
300 | 300 | * @uses trigger_error() |
301 | 301 | */ |
302 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
303 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
305 | - $error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version ); |
|
302 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
303 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
305 | + $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version); |
|
306 | 306 | |
307 | 307 | //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request. |
308 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
309 | - $error_message .= esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso' ); |
|
308 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
309 | + $error_message .= esc_html__('This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso'); |
|
310 | 310 | $error_message .= '<ul><li>'; |
311 | - $error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() ); |
|
311 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
312 | 312 | $error_message .= '</ul>'; |
313 | - EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' ); |
|
313 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
314 | 314 | //now we set this on the transient so it shows up on the next request. |
315 | - EE_Error::get_notices( is_admin(), true ); |
|
315 | + EE_Error::get_notices(is_admin(), true); |
|
316 | 316 | } else { |
317 | - trigger_error( $error_message, $error_type ); |
|
317 | + trigger_error($error_message, $error_type); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | * @param string $debug_index |
337 | 337 | * @param string $debug_key |
338 | 338 | */ |
339 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
340 | - if ( WP_DEBUG /*&& false*/ ) { |
|
341 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
342 | - $debug_data = get_option( $debug_key, array() ); |
|
339 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
340 | + if (WP_DEBUG /*&& false*/) { |
|
341 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
342 | + $debug_data = get_option($debug_key, array()); |
|
343 | 343 | $default_data = array( |
344 | - $class => $func . '() : ' . $line, |
|
344 | + $class => $func.'() : '.$line, |
|
345 | 345 | 'REQ' => $display_request ? $_REQUEST : '', |
346 | 346 | ); |
347 | 347 | // don't serialize objects |
348 | - $info = self::strip_objects( $info ); |
|
349 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
350 | - if ( ! isset( $debug_data[$index] ) ) { |
|
348 | + $info = self::strip_objects($info); |
|
349 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
350 | + if ( ! isset($debug_data[$index])) { |
|
351 | 351 | $debug_data[$index] = array(); |
352 | 352 | } |
353 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
354 | - update_option( $debug_key, $debug_data ); |
|
353 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
354 | + update_option($debug_key, $debug_data); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -363,26 +363,26 @@ discard block |
||
363 | 363 | * @param array $info |
364 | 364 | * @return array |
365 | 365 | */ |
366 | - public static function strip_objects( $info = array() ) { |
|
367 | - foreach ( $info as $key => $value ) { |
|
368 | - if ( is_array( $value ) ) { |
|
369 | - $info[ $key ] = self::strip_objects( $value ); |
|
370 | - } else if ( is_object( $value ) ) { |
|
371 | - $object_class = get_class( $value ); |
|
372 | - $info[ $object_class ] = array(); |
|
373 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
374 | - if ( method_exists( $value, 'ID' ) ) { |
|
375 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
366 | + public static function strip_objects($info = array()) { |
|
367 | + foreach ($info as $key => $value) { |
|
368 | + if (is_array($value)) { |
|
369 | + $info[$key] = self::strip_objects($value); |
|
370 | + } else if (is_object($value)) { |
|
371 | + $object_class = get_class($value); |
|
372 | + $info[$object_class] = array(); |
|
373 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
374 | + if (method_exists($value, 'ID')) { |
|
375 | + $info[$object_class]['ID'] = $value->ID(); |
|
376 | 376 | } |
377 | - if ( method_exists( $value, 'status' ) ) { |
|
378 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
379 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
380 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
377 | + if (method_exists($value, 'status')) { |
|
378 | + $info[$object_class]['status'] = $value->status(); |
|
379 | + } else if (method_exists($value, 'status_ID')) { |
|
380 | + $info[$object_class]['status'] = $value->status_ID(); |
|
381 | 381 | } |
382 | - unset( $info[ $key ] ); |
|
382 | + unset($info[$key]); |
|
383 | 383 | } |
384 | 384 | } |
385 | - return (array)$info; |
|
385 | + return (array) $info; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -399,24 +399,24 @@ discard block |
||
399 | 399 | * @param int $header |
400 | 400 | * @param bool $die |
401 | 401 | */ |
402 | - public static function printv( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
402 | + public static function printv($var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
403 | 403 | $var_name = ! $var_name ? 'string' : $var_name; |
404 | 404 | $heading_tag = 'h'; |
405 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
406 | - $var_name = ucwords( str_replace( '$', '', $var_name ) ); |
|
407 | - $is_method = method_exists( $var_name, $var ); |
|
408 | - $var_name = ucwords( str_replace( '_', ' ', $var_name ) ); |
|
405 | + $heading_tag .= is_int($header) ? $header : 5; |
|
406 | + $var_name = ucwords(str_replace('$', '', $var_name)); |
|
407 | + $is_method = method_exists($var_name, $var); |
|
408 | + $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
409 | 409 | ob_start(); |
410 | - echo '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>'; |
|
410 | + echo '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>'; |
|
411 | 411 | echo $is_method |
412 | - ? '<span style="color:#999">::</span><span style="color:#E76700">' . $var . '()</span><br />' |
|
413 | - : '<span style="color:#999"> : </span><span style="color:#E76700">' . $var . '</span><br />'; |
|
414 | - echo '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file; |
|
415 | - echo '<br />line no: ' . $line . '</span>'; |
|
416 | - echo '</' . $heading_tag . '>'; |
|
412 | + ? '<span style="color:#999">::</span><span style="color:#E76700">'.$var.'()</span><br />' |
|
413 | + : '<span style="color:#999"> : </span><span style="color:#E76700">'.$var.'</span><br />'; |
|
414 | + echo '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file; |
|
415 | + echo '<br />line no: '.$line.'</span>'; |
|
416 | + echo '</'.$heading_tag.'>'; |
|
417 | 417 | $result = ob_get_clean(); |
418 | - if ( $die ) { |
|
419 | - die( $result ); |
|
418 | + if ($die) { |
|
419 | + die($result); |
|
420 | 420 | } else { |
421 | 421 | echo $result; |
422 | 422 | } |
@@ -435,36 +435,36 @@ discard block |
||
435 | 435 | * @param int $header |
436 | 436 | * @param bool $die |
437 | 437 | */ |
438 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
439 | - $file = str_replace( rtrim( ABSPATH, '\\/' ), '', $file ); |
|
438 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
439 | + $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
440 | 440 | //$print_r = false; |
441 | - if ( is_string( $var ) ) { |
|
442 | - EEH_Debug_Tools::printv( $var, $var_name, $file, $line, $header, $die ); |
|
441 | + if (is_string($var)) { |
|
442 | + EEH_Debug_Tools::printv($var, $var_name, $file, $line, $header, $die); |
|
443 | 443 | return; |
444 | - } else if ( is_object( $var ) ) { |
|
444 | + } else if (is_object($var)) { |
|
445 | 445 | $var_name = ! $var_name ? 'object' : $var_name; |
446 | 446 | //$print_r = true; |
447 | - } else if ( is_array( $var ) ) { |
|
447 | + } else if (is_array($var)) { |
|
448 | 448 | $var_name = ! $var_name ? 'array' : $var_name; |
449 | 449 | //$print_r = true; |
450 | - } else if ( is_numeric( $var ) ) { |
|
450 | + } else if (is_numeric($var)) { |
|
451 | 451 | $var_name = ! $var_name ? 'numeric' : $var_name; |
452 | - } else if ( is_null( $var ) ) { |
|
452 | + } else if (is_null($var)) { |
|
453 | 453 | $var_name = ! $var_name ? 'null' : $var_name; |
454 | 454 | } |
455 | 455 | $heading_tag = 'h'; |
456 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
457 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
456 | + $heading_tag .= is_int($header) ? $header : 5; |
|
457 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
458 | 458 | ob_start(); |
459 | - echo '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>'; |
|
459 | + echo '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>'; |
|
460 | 460 | echo '<span style="color:#999;"> : </span><span style="color:#E76700;">'; |
461 | 461 | echo '<pre style="color:#999; padding:1em; background: #fff">'; |
462 | - var_dump( $var ); |
|
463 | - echo '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file; |
|
464 | - echo '<br />line no: ' . $line . '</span></' . $heading_tag . '>'; |
|
462 | + var_dump($var); |
|
463 | + echo '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file; |
|
464 | + echo '<br />line no: '.$line.'</span></'.$heading_tag.'>'; |
|
465 | 465 | $result = ob_get_clean(); |
466 | - if ( $die ) { |
|
467 | - die( $result ); |
|
466 | + if ($die) { |
|
467 | + die($result); |
|
468 | 468 | } else { |
469 | 469 | echo $result; |
470 | 470 | } |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * borrowed from Kint Debugger |
482 | 482 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
483 | 483 | */ |
484 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
485 | - function dump_wp_query(){ |
|
484 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
485 | + function dump_wp_query() { |
|
486 | 486 | global $wp_query; |
487 | 487 | d($wp_query); |
488 | 488 | } |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | * borrowed from Kint Debugger |
493 | 493 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
494 | 494 | */ |
495 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
496 | - function dump_wp(){ |
|
495 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
496 | + function dump_wp() { |
|
497 | 497 | global $wp; |
498 | 498 | d($wp); |
499 | 499 | } |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | * borrowed from Kint Debugger |
504 | 504 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
505 | 505 | */ |
506 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
507 | - function dump_post(){ |
|
506 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
507 | + function dump_post() { |
|
508 | 508 | global $post; |
509 | 509 | d($post); |
510 | 510 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,28 +35,28 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Datetime','event_espresso'); |
|
40 | - $this->plural_item = __('Datetimes','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
40 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Datetime'=>array( |
47 | - 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')), |
|
48 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
47 | + 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
48 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
49 | 49 | 'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''), |
50 | 50 | 'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''), |
51 | - 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ), |
|
52 | - 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ), |
|
53 | - 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF), |
|
54 | - 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ), |
|
55 | - 'DTT_reserved' => new EE_Integer_Field('DTT_reserved',__('Quantity of tickets that are reserved, but not yet fully purchased','event_espresso'),false,0), |
|
56 | - 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false), |
|
51 | + 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
54 | + 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0), |
|
55 | + 'DTT_reserved' => new EE_Integer_Field('DTT_reserved', __('Quantity of tickets that are reserved, but not yet fully purchased', 'event_espresso'), false, 0), |
|
56 | + 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
57 | 57 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
58 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
59 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
58 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
59 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
60 | 60 | )); |
61 | 61 | $this->_model_relations = array( |
62 | 62 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | ); |
66 | 66 | $this->_model_chain_to_wp_user = 'Event'; |
67 | 67 | //this model is generally available for reading |
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
71 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
72 | - parent::__construct( $timezone ); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
71 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
72 | + parent::__construct($timezone); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | public function create_new_blank_datetime() { |
85 | 85 | $blank_datetime = EE_Datetime::new_instance( |
86 | 86 | array( |
87 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
88 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
88 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
89 | 89 | 'DTT_order' => 1, |
90 | 90 | 'DTT_reg_limit' => EE_INF |
91 | 91 | ), |
92 | 92 | $this->_timezone |
93 | 93 | ); |
94 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
95 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
96 | - return array( $blank_datetime ); |
|
94 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
95 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
96 | + return array($blank_datetime); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @param int $EVT_ID |
108 | 108 | * @return EE_Datetime[] array on success, FALSE on fail |
109 | 109 | */ |
110 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
111 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
110 | + public function get_all_event_dates($EVT_ID = 0) { |
|
111 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
112 | 112 | return $this->create_new_blank_datetime(); |
113 | 113 | } |
114 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
115 | 115 | |
116 | - if ( empty( $results ) ) { |
|
116 | + if (empty($results)) { |
|
117 | 117 | return $this->create_new_blank_datetime(); |
118 | 118 | } |
119 | 119 | |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * the given number |
135 | 135 | * @return EE_Datetime[] |
136 | 136 | */ |
137 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
137 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
138 | 138 | |
139 | 139 | //sanitize EVT_ID |
140 | - $EVT_ID = intval( $EVT_ID ); |
|
140 | + $EVT_ID = intval($EVT_ID); |
|
141 | 141 | |
142 | 142 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
143 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
144 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
143 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
144 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
145 | 145 | |
146 | - $query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ); |
|
146 | + $query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none'); |
|
147 | 147 | |
148 | - if( ! $include_expired){ |
|
149 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
148 | + if ( ! $include_expired) { |
|
149 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
150 | 150 | } |
151 | - if( $include_deleted){ |
|
152 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
151 | + if ($include_deleted) { |
|
152 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
153 | 153 | } |
154 | 154 | |
155 | - $result = $this->get_all( $query_params ); |
|
156 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
155 | + $result = $this->get_all($query_params); |
|
156 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
157 | 157 | return $result; |
158 | 158 | } |
159 | 159 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param int $limit |
169 | 169 | * @return EE_Datetime[] |
170 | 170 | */ |
171 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
172 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
171 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
172 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
173 | 173 | 'limit'=>$limit, |
174 | 174 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
175 | 175 | 'default_where_conditions' => 'none')); |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @param boolean $include_deleted |
185 | 185 | * @return EE_Datetime |
186 | 186 | */ |
187 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
188 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
189 | - if($results){ |
|
187 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
188 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
189 | + if ($results) { |
|
190 | 190 | return array_shift($results); |
191 | - }else{ |
|
191 | + } else { |
|
192 | 192 | return NULL; |
193 | 193 | } |
194 | 194 | } |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | * @param bool $try_to_exclude_deleted |
203 | 203 | * @return \EE_Datetime |
204 | 204 | */ |
205 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
206 | - if($try_to_exclude_expired){ |
|
207 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
208 | - if($non_expired){ |
|
205 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
206 | + if ($try_to_exclude_expired) { |
|
207 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
208 | + if ($non_expired) { |
|
209 | 209 | return $non_expired; |
210 | 210 | } |
211 | 211 | } |
212 | - if($try_to_exclude_deleted){ |
|
212 | + if ($try_to_exclude_deleted) { |
|
213 | 213 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
214 | - if($expired_even){ |
|
214 | + if ($expired_even) { |
|
215 | 215 | return $expired_even; |
216 | 216 | } |
217 | 217 | } |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * @param int $limit |
231 | 231 | * @return EE_Datetime[] |
232 | 232 | */ |
233 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
233 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
234 | 234 | //sanitize EVT_ID |
235 | - $EVT_ID = intval( $EVT_ID ); |
|
235 | + $EVT_ID = intval($EVT_ID); |
|
236 | 236 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
237 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
238 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
239 | - if( ! $include_expired){ |
|
240 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
237 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
238 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
239 | + if ( ! $include_expired) { |
|
240 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
241 | 241 | } |
242 | - if( $include_deleted){ |
|
243 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
242 | + if ($include_deleted) { |
|
243 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
244 | 244 | } |
245 | - if($limit){ |
|
245 | + if ($limit) { |
|
246 | 246 | $query_params['limit'] = $limit; |
247 | 247 | } |
248 | - $result = $this->get_all( $query_params ); |
|
249 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
248 | + $result = $this->get_all($query_params); |
|
249 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
250 | 250 | return $result; |
251 | 251 | } |
252 | 252 | |
@@ -259,23 +259,23 @@ discard block |
||
259 | 259 | * @param int $limit |
260 | 260 | * @return EE_Datetime[] |
261 | 261 | */ |
262 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
262 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
263 | 263 | //sanitize TKT_ID |
264 | - $TKT_ID = intval( $TKT_ID ); |
|
264 | + $TKT_ID = intval($TKT_ID); |
|
265 | 265 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
266 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
267 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
268 | - if( ! $include_expired){ |
|
269 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
266 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
267 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
268 | + if ( ! $include_expired) { |
|
269 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
270 | 270 | } |
271 | - if( $include_deleted){ |
|
272 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
271 | + if ($include_deleted) { |
|
272 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
273 | 273 | } |
274 | - if($limit){ |
|
274 | + if ($limit) { |
|
275 | 275 | $query_params['limit'] = $limit; |
276 | 276 | } |
277 | - $result = $this->get_all( $query_params ); |
|
278 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
277 | + $result = $this->get_all($query_params); |
|
278 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
279 | 279 | return $result; |
280 | 280 | } |
281 | 281 | |
@@ -291,24 +291,24 @@ discard block |
||
291 | 291 | * that number |
292 | 292 | * @return EE_Datetime[] |
293 | 293 | */ |
294 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
294 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
295 | 295 | //sanitize id. |
296 | - $TKT_ID = intval( $TKT_ID ); |
|
296 | + $TKT_ID = intval($TKT_ID); |
|
297 | 297 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
298 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
299 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
300 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
301 | - if( ! $include_expired){ |
|
302 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
298 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
299 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
300 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
301 | + if ( ! $include_expired) { |
|
302 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
303 | 303 | } |
304 | - if( $include_deleted){ |
|
305 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
304 | + if ($include_deleted) { |
|
305 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
306 | 306 | } |
307 | - if($limit){ |
|
307 | + if ($limit) { |
|
308 | 308 | $query_params['limit'] = $limit; |
309 | 309 | } |
310 | - $result = $this->get_all( $query_params ); |
|
311 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
310 | + $result = $this->get_all($query_params); |
|
311 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
312 | 312 | return $result; |
313 | 313 | } |
314 | 314 | |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | * @param int $EVT_ID |
320 | 320 | * @return EE_Datetime |
321 | 321 | */ |
322 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
322 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
323 | 323 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
324 | - if($results){ |
|
324 | + if ($results) { |
|
325 | 325 | return array_shift($results); |
326 | - }else{ |
|
326 | + } else { |
|
327 | 327 | return null; |
328 | 328 | } |
329 | 329 | } |
@@ -342,78 +342,78 @@ discard block |
||
342 | 342 | * - inactive = Events that are either not published. |
343 | 343 | * @return wpdb results array |
344 | 344 | */ |
345 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
346 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query( 'DTT_EVT_start' ); |
|
347 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query( 'DTT_EVT_end' ); |
|
345 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
346 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
347 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
348 | 348 | |
349 | - switch ( $evt_active_status ) { |
|
349 | + switch ($evt_active_status) { |
|
350 | 350 | case 'upcoming' : |
351 | 351 | $where_params['Event.status'] = 'publish'; |
352 | 352 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
353 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
353 | + if (isset($where_params['DTT_EVT_start'])) { |
|
354 | 354 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
355 | 355 | } |
356 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start ); |
|
356 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
357 | 357 | break; |
358 | 358 | |
359 | 359 | case 'expired' : |
360 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
360 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
361 | 361 | //get events to exclude |
362 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) ); |
|
362 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
363 | 363 | //first get all events that have datetimes where its not expired. |
364 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
365 | - $event_ids = array_keys( $event_ids ); |
|
364 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
365 | + $event_ids = array_keys($event_ids); |
|
366 | 366 | |
367 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
367 | + if (isset($where_params['DTT_EVT_end'])) { |
|
368 | 368 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
369 | 369 | } |
370 | - $where_params['DTT_EVT_end'] = array( '<', $current_time_for_DTT_EVT_end ); |
|
371 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
370 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
371 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
372 | 372 | break; |
373 | 373 | |
374 | 374 | case 'active' : |
375 | 375 | $where_params['Event.status'] = 'publish'; |
376 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
376 | + if (isset($where_params['DTT_EVT_start'])) { |
|
377 | 377 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
378 | 378 | } |
379 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
379 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
380 | 380 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
381 | 381 | } |
382 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start ); |
|
383 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end ); |
|
382 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
383 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
384 | 384 | break; |
385 | 385 | |
386 | 386 | case 'inactive' : |
387 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
388 | - if ( isset( $where_params['OR'] ) ) { |
|
387 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
388 | + if (isset($where_params['OR'])) { |
|
389 | 389 | $where_params['AND']['OR'] = $where_params['OR']; |
390 | 390 | } |
391 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
391 | + if (isset($where_params['DTT_EVT_end'])) { |
|
392 | 392 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
393 | - unset( $where_params['DTT_EVT_end'] ); |
|
393 | + unset($where_params['DTT_EVT_end']); |
|
394 | 394 | } |
395 | 395 | |
396 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
396 | + if (isset($where_params['DTT_EVT_start'])) { |
|
397 | 397 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
398 | - unset( $where_params['DTT_EVT_start'] ); |
|
398 | + unset($where_params['DTT_EVT_start']); |
|
399 | 399 | } |
400 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
400 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
401 | 401 | break; |
402 | 402 | } |
403 | 403 | |
404 | 404 | $query_params[0] = $where_params; |
405 | 405 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
406 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
406 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
407 | 407 | |
408 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
409 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'DTT_EVT_start' ); |
|
408 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
409 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
410 | 410 | |
411 | 411 | $columns_to_select = array( |
412 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
413 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
414 | - 'dtt_month_num' => array('MONTH(' . $query_interval .')', '%s') |
|
412 | + 'dtt_year' => array('YEAR('.$query_interval.')', '%s'), |
|
413 | + 'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'), |
|
414 | + 'dtt_month_num' => array('MONTH('.$query_interval.')', '%s') |
|
415 | 415 | ); |
416 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
416 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * for the tickets for each datetime) |
422 | 422 | * @param EE_Datetime[] $datetimes |
423 | 423 | */ |
424 | - public function update_sold($datetimes){ |
|
425 | - foreach($datetimes as $datetime){ |
|
424 | + public function update_sold($datetimes) { |
|
425 | + foreach ($datetimes as $datetime) { |
|
426 | 426 | $datetime->update_sold(); |
427 | 427 | } |
428 | 428 | } |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | * @param array $query_params |
438 | 438 | * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO tickets attached to datetime then FALSE is returned. |
439 | 439 | */ |
440 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
441 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
442 | - if ( $datetime instanceof EE_Datetime ) { |
|
443 | - return $datetime->tickets_remaining( $query_params ); |
|
440 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
441 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
442 | + if ($datetime instanceof EE_Datetime) { |
|
443 | + return $datetime->tickets_remaining($query_params); |
|
444 | 444 | } |
445 | 445 | return 0; |
446 | 446 | } |
@@ -462,36 +462,36 @@ discard block |
||
462 | 462 | * EE_Datetime::upcoming |
463 | 463 | * EE_Datetime::expired |
464 | 464 | */ |
465 | - public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) { |
|
465 | + public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) { |
|
466 | 466 | //only accept where conditions for this query. |
467 | - $_where = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
467 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
468 | 468 | $status_query_args = array( |
469 | 469 | EE_Datetime::active => array_merge( |
470 | 470 | $_where, |
471 | - array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) ) |
|
471 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
472 | 472 | ), |
473 | 473 | EE_Datetime::upcoming => array_merge( |
474 | 474 | $_where, |
475 | - array( 'DTT_EVT_start' => array( '>', time() ) ) |
|
475 | + array('DTT_EVT_start' => array('>', time())) |
|
476 | 476 | ), |
477 | 477 | EE_Datetime::expired => array_merge( |
478 | 478 | $_where, |
479 | - array( 'DTT_EVT_end' => array('<', time() ) ) |
|
479 | + array('DTT_EVT_end' => array('<', time())) |
|
480 | 480 | ) |
481 | 481 | ); |
482 | 482 | |
483 | - if ( ! empty( $stati_to_include ) ) { |
|
484 | - foreach( array_keys( $status_query_args ) as $status ) { |
|
485 | - if ( ! in_array( $status, $stati_to_include ) ) { |
|
486 | - unset( $status_query_args[$status] ); |
|
483 | + if ( ! empty($stati_to_include)) { |
|
484 | + foreach (array_keys($status_query_args) as $status) { |
|
485 | + if ( ! in_array($status, $stati_to_include)) { |
|
486 | + unset($status_query_args[$status]); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | 491 | //loop through and query counts for each stati. |
492 | 492 | $status_query_results = array(); |
493 | - foreach( $status_query_args as $status => $status_where_conditions ) { |
|
494 | - $status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true ); |
|
493 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
494 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | return $status_query_results; |
@@ -505,9 +505,9 @@ discard block |
||
505 | 505 | * @param array $query_params |
506 | 506 | * @return int |
507 | 507 | */ |
508 | - public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) { |
|
509 | - $count = $this->get_datetime_counts_by_status( array( $status ), $query_params ); |
|
510 | - return ! empty( $count[$status] ) ? $count[$status] : 0; |
|
508 | + public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) { |
|
509 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
510 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 |