@@ -1006,7 +1006,7 @@ |
||
1006 | 1006 | * |
1007 | 1007 | * @access public |
1008 | 1008 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1009 | - * @return mixed void|string |
|
1009 | + * @return string void|string |
|
1010 | 1010 | */ |
1011 | 1011 | public function pretty_active_status( $echo = TRUE ) { |
1012 | 1012 | $active_status = $this->get_active_status(); |
@@ -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 | /** |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * date_format and the second value is the time format |
36 | 36 | * @return EE_Event |
37 | 37 | */ |
38 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
39 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
40 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
38 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
39 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
40 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * the website will be used. |
49 | 49 | * @return EE_Event |
50 | 50 | */ |
51 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
52 | - return new self( $props_n_values, TRUE, $timezone ); |
|
51 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
52 | + return new self($props_n_values, TRUE, $timezone); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @param mixed $field_value |
62 | 62 | * @param bool $use_default |
63 | 63 | */ |
64 | - public function set( $field_name, $field_value, $use_default = false ) { |
|
65 | - switch ( $field_name ) { |
|
64 | + public function set($field_name, $field_value, $use_default = false) { |
|
65 | + switch ($field_name) { |
|
66 | 66 | case 'status' : |
67 | - $this->set_status( $field_value, $use_default ); |
|
67 | + $this->set_status($field_value, $use_default); |
|
68 | 68 | break; |
69 | 69 | default : |
70 | - parent::set( $field_name, $field_value, $use_default ); |
|
70 | + parent::set($field_name, $field_value, $use_default); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -86,29 +86,29 @@ discard block |
||
86 | 86 | * @return bool|void |
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | - public function set_status( $new_status = null, $use_default = false ) { |
|
89 | + public function set_status($new_status = null, $use_default = false) { |
|
90 | 90 | // get current Event status |
91 | 91 | $old_status = $this->status(); |
92 | 92 | // if status has changed |
93 | - if ( $old_status != $new_status ) { |
|
93 | + if ($old_status != $new_status) { |
|
94 | 94 | // TO sold_out |
95 | - if ( $new_status == EEM_Event::sold_out ) { |
|
95 | + if ($new_status == EEM_Event::sold_out) { |
|
96 | 96 | // save the previous event status so that we can revert if the event is no longer sold out |
97 | - $this->add_post_meta( '_previous_event_status', $old_status ); |
|
98 | - do_action( 'AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status ); |
|
97 | + $this->add_post_meta('_previous_event_status', $old_status); |
|
98 | + do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
99 | 99 | // OR FROM sold_out |
100 | - } else if ( $old_status == EEM_Event::sold_out ) { |
|
101 | - $this->delete_post_meta( '_previous_event_status' ); |
|
102 | - do_action( 'AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status ); |
|
100 | + } else if ($old_status == EEM_Event::sold_out) { |
|
101 | + $this->delete_post_meta('_previous_event_status'); |
|
102 | + do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
103 | 103 | } |
104 | 104 | // update status |
105 | - parent::set( 'status', $new_status, $use_default ); |
|
106 | - do_action( 'AHEE__EE_Event__set_status__after_update', $this ); |
|
105 | + parent::set('status', $new_status, $use_default); |
|
106 | + do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
107 | 107 | return true; |
108 | 108 | } else { |
109 | 109 | // even though the old value matches the new value, it's still good to |
110 | 110 | // allow the parent set method to have a say |
111 | - parent::set( 'status', $new_status, $use_default ); |
|
111 | + parent::set('status', $new_status, $use_default); |
|
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param array $query_params like EEM_Base::get_all |
122 | 122 | * @return EE_Datetime[] |
123 | 123 | */ |
124 | - public function datetimes( $query_params = array() ) { |
|
125 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
124 | + public function datetimes($query_params = array()) { |
|
125 | + return $this->get_many_related('Datetime', $query_params); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return EE_Datetime[] |
134 | 134 | */ |
135 | 135 | public function datetimes_in_chronological_order() { |
136 | - return $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) ); |
|
136 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param null $limit |
150 | 150 | * @return \EE_Datetime[] |
151 | 151 | */ |
152 | - public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) { |
|
153 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted, $limit ); |
|
152 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) { |
|
153 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted, $limit); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return EE_Datetime |
161 | 161 | */ |
162 | 162 | public function first_datetime() { |
163 | - return $this->get_first_related( 'Datetime' ); |
|
163 | + return $this->get_first_related('Datetime'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @param bool $try_to_exclude_deleted |
172 | 172 | * @return EE_Datetime |
173 | 173 | */ |
174 | - public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) { |
|
175 | - if ( !empty ( $this->_Primary_Datetime ) ) { |
|
174 | + public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) { |
|
175 | + if ( ! empty ($this->_Primary_Datetime)) { |
|
176 | 176 | return $this->_Primary_Datetime; |
177 | 177 | } |
178 | - $this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted ); |
|
178 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted); |
|
179 | 179 | return $this->_Primary_Datetime; |
180 | 180 | } |
181 | 181 | |
@@ -186,30 +186,30 @@ discard block |
||
186 | 186 | * @param array $query_params like EEM_Base::get_all |
187 | 187 | * @return EE_Ticket[] |
188 | 188 | */ |
189 | - public function tickets( $query_params = array() ) { |
|
189 | + public function tickets($query_params = array()) { |
|
190 | 190 | //first get all datetimes |
191 | 191 | $datetimes = $this->datetimes_ordered(); |
192 | - if ( ! $datetimes ) { |
|
192 | + if ( ! $datetimes) { |
|
193 | 193 | return array(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | $datetime_ids = array(); |
197 | - foreach ( $datetimes as $datetime ) { |
|
197 | + foreach ($datetimes as $datetime) { |
|
198 | 198 | $datetime_ids[] = $datetime->ID(); |
199 | 199 | } |
200 | 200 | |
201 | - $where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) ); |
|
201 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
202 | 202 | |
203 | 203 | //if incoming $query_params has where conditions let's merge but not override existing. |
204 | - if ( is_array( $query_params ) && isset( $query_params[0]) ) { |
|
205 | - $where_params = array_merge( $query_params[0], $where_params ); |
|
206 | - unset( $query_params[0] ); |
|
204 | + if (is_array($query_params) && isset($query_params[0])) { |
|
205 | + $where_params = array_merge($query_params[0], $where_params); |
|
206 | + unset($query_params[0]); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | //now add $where_params to $query_params |
210 | 210 | $query_params[0] = $where_params; |
211 | 211 | |
212 | - return EEM_Ticket::instance()->get_all( $query_params ); |
|
212 | + return EEM_Ticket::instance()->get_all($query_params); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @return bool |
219 | 219 | */ |
220 | 220 | function additional_limit() { |
221 | - return $this->get( 'EVT_additional_limit' ); |
|
221 | + return $this->get('EVT_additional_limit'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @return bool |
228 | 228 | */ |
229 | 229 | function allow_overflow() { |
230 | - return $this->get( 'EVT_allow_overflow' ); |
|
230 | + return $this->get('EVT_allow_overflow'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @return bool |
237 | 237 | */ |
238 | 238 | function created() { |
239 | - return $this->get( 'EVT_created' ); |
|
239 | + return $this->get('EVT_created'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @return bool |
246 | 246 | */ |
247 | 247 | function description() { |
248 | - return $this->get( 'EVT_desc' ); |
|
248 | + return $this->get('EVT_desc'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return string of html |
256 | 256 | */ |
257 | 257 | function description_filtered() { |
258 | - return $this->get_pretty( 'EVT_desc' ); |
|
258 | + return $this->get_pretty('EVT_desc'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @return bool |
265 | 265 | */ |
266 | 266 | function display_description() { |
267 | - return $this->get( 'EVT_display_desc' ); |
|
267 | + return $this->get('EVT_display_desc'); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return bool |
274 | 274 | */ |
275 | 275 | function display_ticket_selector() { |
276 | - return (bool)$this->get( 'EVT_display_ticket_selector' ); |
|
276 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return bool |
283 | 283 | */ |
284 | 284 | function external_url() { |
285 | - return $this->get( 'EVT_external_URL' ); |
|
285 | + return $this->get('EVT_external_URL'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | */ |
293 | 293 | function member_only() { |
294 | - return $this->get( 'EVT_member_only' ); |
|
294 | + return $this->get('EVT_member_only'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @return bool |
301 | 301 | */ |
302 | 302 | function phone() { |
303 | - return $this->get( 'EVT_phone' ); |
|
303 | + return $this->get('EVT_phone'); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return bool |
310 | 310 | */ |
311 | 311 | function modified() { |
312 | - return $this->get( 'EVT_modified' ); |
|
312 | + return $this->get('EVT_modified'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return bool |
319 | 319 | */ |
320 | 320 | function name() { |
321 | - return $this->get( 'EVT_name' ); |
|
321 | + return $this->get('EVT_name'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @return bool |
328 | 328 | */ |
329 | 329 | function order() { |
330 | - return $this->get( 'EVT_order' ); |
|
330 | + return $this->get('EVT_order'); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @return bool|string |
337 | 337 | */ |
338 | 338 | function default_registration_status() { |
339 | - $event_default_registration_status = $this->get( 'EVT_default_registration_status' ); |
|
340 | - return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
339 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
340 | + return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * @param bool $not_full_desc |
349 | 349 | * @return bool|string |
350 | 350 | */ |
351 | - function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) { |
|
352 | - $short_desc = $this->get( 'EVT_short_desc' ); |
|
353 | - if ( !empty( $short_desc ) || $not_full_desc ) { |
|
351 | + function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) { |
|
352 | + $short_desc = $this->get('EVT_short_desc'); |
|
353 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
354 | 354 | return $short_desc; |
355 | 355 | } |
356 | 356 | else { |
357 | - $full_desc = $this->get( 'EVT_desc' ); |
|
358 | - return wp_trim_words( $full_desc, $num_words, $more ); |
|
357 | + $full_desc = $this->get('EVT_desc'); |
|
358 | + return wp_trim_words($full_desc, $num_words, $more); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @return bool |
366 | 366 | */ |
367 | 367 | function slug() { |
368 | - return $this->get( 'EVT_slug' ); |
|
368 | + return $this->get('EVT_slug'); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @return bool |
375 | 375 | */ |
376 | 376 | function timezone_string() { |
377 | - return $this->get( 'EVT_timezone_string' ); |
|
377 | + return $this->get('EVT_timezone_string'); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return bool |
384 | 384 | */ |
385 | 385 | function visible_on() { |
386 | - return $this->get( 'EVT_visible_on' ); |
|
386 | + return $this->get('EVT_visible_on'); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @return int |
393 | 393 | */ |
394 | 394 | function wp_user() { |
395 | - return $this->get( 'EVT_wp_user' ); |
|
395 | + return $this->get('EVT_wp_user'); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return bool |
402 | 402 | */ |
403 | 403 | function donations() { |
404 | - return $this->get( 'EVT_donations' ); |
|
404 | + return $this->get('EVT_donations'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | /** |
410 | 410 | * @param $limit |
411 | 411 | */ |
412 | - function set_additional_limit( $limit ) { |
|
413 | - $this->set( 'EVT_additional_limit', $limit ); |
|
412 | + function set_additional_limit($limit) { |
|
413 | + $this->set('EVT_additional_limit', $limit); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | /** |
419 | 419 | * @param $created |
420 | 420 | */ |
421 | - function set_created( $created ) { |
|
422 | - $this->set( 'EVT_created', $created ); |
|
421 | + function set_created($created) { |
|
422 | + $this->set('EVT_created', $created); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | /** |
428 | 428 | * @param $desc |
429 | 429 | */ |
430 | - function set_description( $desc ) { |
|
431 | - $this->set( 'EVT_desc', $desc ); |
|
430 | + function set_description($desc) { |
|
431 | + $this->set('EVT_desc', $desc); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | /** |
437 | 437 | * @param $display_desc |
438 | 438 | */ |
439 | - function set_display_description( $display_desc ) { |
|
440 | - $this->set( 'EVT_display_desc', $display_desc ); |
|
439 | + function set_display_description($display_desc) { |
|
440 | + $this->set('EVT_display_desc', $display_desc); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | /** |
446 | 446 | * @param $display_ticket_selector |
447 | 447 | */ |
448 | - function set_display_ticket_selector( $display_ticket_selector ) { |
|
449 | - $this->set( 'EVT_display_ticket_selector', $display_ticket_selector ); |
|
448 | + function set_display_ticket_selector($display_ticket_selector) { |
|
449 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | /** |
455 | 455 | * @param $external_url |
456 | 456 | */ |
457 | - function set_external_url( $external_url ) { |
|
458 | - $this->set( 'EVT_external_URL', $external_url ); |
|
457 | + function set_external_url($external_url) { |
|
458 | + $this->set('EVT_external_URL', $external_url); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | /** |
464 | 464 | * @param $member_only |
465 | 465 | */ |
466 | - function set_member_only( $member_only ) { |
|
467 | - $this->set( 'EVT_member_only', $member_only ); |
|
466 | + function set_member_only($member_only) { |
|
467 | + $this->set('EVT_member_only', $member_only); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | /** |
473 | 473 | * @param $event_phone |
474 | 474 | */ |
475 | - function set_event_phone( $event_phone ) { |
|
476 | - $this->set( 'EVT_phone', $event_phone ); |
|
475 | + function set_event_phone($event_phone) { |
|
476 | + $this->set('EVT_phone', $event_phone); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | /** |
482 | 482 | * @param $modified |
483 | 483 | */ |
484 | - function set_modified( $modified ) { |
|
485 | - $this->set( 'EVT_modified', $modified ); |
|
484 | + function set_modified($modified) { |
|
485 | + $this->set('EVT_modified', $modified); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | /** |
491 | 491 | * @param $name |
492 | 492 | */ |
493 | - function set_name( $name ) { |
|
494 | - $this->set( 'EVT_name', $name ); |
|
493 | + function set_name($name) { |
|
494 | + $this->set('EVT_name', $name); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | /** |
500 | 500 | * @param $order |
501 | 501 | */ |
502 | - function set_order( $order ) { |
|
503 | - $this->set( 'EVT_order', $order ); |
|
502 | + function set_order($order) { |
|
503 | + $this->set('EVT_order', $order); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | /** |
509 | 509 | * @param $short_desc |
510 | 510 | */ |
511 | - function set_short_description( $short_desc ) { |
|
512 | - $this->set( 'EVT_short_desc', $short_desc ); |
|
511 | + function set_short_description($short_desc) { |
|
512 | + $this->set('EVT_short_desc', $short_desc); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | /** |
518 | 518 | * @param $slug |
519 | 519 | */ |
520 | - function set_slug( $slug ) { |
|
521 | - $this->set( 'EVT_slug', $slug ); |
|
520 | + function set_slug($slug) { |
|
521 | + $this->set('EVT_slug', $slug); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | /** |
527 | 527 | * @param $timezone_string |
528 | 528 | */ |
529 | - function set_timezone_string( $timezone_string ) { |
|
530 | - $this->set( 'EVT_timezone_string', $timezone_string ); |
|
529 | + function set_timezone_string($timezone_string) { |
|
530 | + $this->set('EVT_timezone_string', $timezone_string); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * @param $visible_on |
537 | 537 | */ |
538 | - function set_visible_on( $visible_on ) { |
|
539 | - $this->set( 'EVT_visible_on', $visible_on ); |
|
538 | + function set_visible_on($visible_on) { |
|
539 | + $this->set('EVT_visible_on', $visible_on); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | /** |
545 | 545 | * @param $wp_user |
546 | 546 | */ |
547 | - function set_wp_user( $wp_user ) { |
|
548 | - $this->set( 'EVT_wp_user', $wp_user ); |
|
547 | + function set_wp_user($wp_user) { |
|
548 | + $this->set('EVT_wp_user', $wp_user); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | /** |
554 | 554 | * @param $default_registration_status |
555 | 555 | */ |
556 | - function set_default_registration_status( $default_registration_status ) { |
|
557 | - $this->set( 'EVT_default_registration_status', $default_registration_status ); |
|
556 | + function set_default_registration_status($default_registration_status) { |
|
557 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | /** |
563 | 563 | * @param $donations |
564 | 564 | */ |
565 | - function set_donations( $donations ) { |
|
566 | - $this->set( 'EVT_donations', $donations ); |
|
565 | + function set_donations($donations) { |
|
566 | + $this->set('EVT_donations', $donations); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | * @param EE_Venue /int $venue_id_or_obj |
574 | 574 | * @return EE_Venue |
575 | 575 | */ |
576 | - function add_venue( $venue_id_or_obj ) { |
|
577 | - return $this->_add_relation_to( $venue_id_or_obj, 'Venue' ); |
|
576 | + function add_venue($venue_id_or_obj) { |
|
577 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @param EE_Venue /int $venue_id_or_obj |
585 | 585 | * @return EE_Venue |
586 | 586 | */ |
587 | - function remove_venue( $venue_id_or_obj ) { |
|
588 | - return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' ); |
|
587 | + function remove_venue($venue_id_or_obj) { |
|
588 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | * @param array $query_params like EEM_Base::get_all's $query_params |
596 | 596 | * @return EE_Venue[] |
597 | 597 | */ |
598 | - function venues( $query_params = array() ) { |
|
599 | - return $this->get_many_related( 'Venue', $query_params ); |
|
598 | + function venues($query_params = array()) { |
|
599 | + return $this->get_many_related('Venue', $query_params); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | */ |
609 | 609 | private function _has_ID_and_is_published() { |
610 | 610 | // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
611 | - return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE; |
|
611 | + return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | */ |
621 | 621 | public function is_upcoming() { |
622 | 622 | // check if event id is present and if this event is published |
623 | - if ( $this->is_inactive() ) { |
|
623 | + if ($this->is_inactive()) { |
|
624 | 624 | return FALSE; |
625 | 625 | } |
626 | 626 | return EEM_Datetime::instance($this->_timezone)->count_upcoming_datetimes_for_event($this) > 0; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | */ |
634 | 634 | public function is_active() { |
635 | 635 | // check if event id is present and if this event is published |
636 | - if ( $this->is_inactive() ) { |
|
636 | + if ($this->is_inactive()) { |
|
637 | 637 | return FALSE; |
638 | 638 | } |
639 | 639 | return EEM_Datetime::instance($this->_timezone)->count_active_datetimes_for_event($this) > 0; |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public function is_active_or_upcoming() { |
648 | 648 | // check if event id is present and if this event is published |
649 | - if ( $this->is_inactive() ) { |
|
649 | + if ($this->is_inactive()) { |
|
650 | 650 | return FALSE; |
651 | 651 | } |
652 | 652 | return EEM_Datetime::instance($this->_timezone)->count_active_and_upcoming_datetimes_for_event($this) > 0; |
@@ -659,17 +659,17 @@ discard block |
||
659 | 659 | */ |
660 | 660 | public function is_expired() { |
661 | 661 | // check if event id is present and if this event is published |
662 | - if ( $this->is_inactive() ) { |
|
662 | + if ($this->is_inactive()) { |
|
663 | 663 | return FALSE; |
664 | 664 | } |
665 | 665 | // set initial value |
666 | 666 | $expired = FALSE; |
667 | 667 | //first let's get all datetimes and loop through them |
668 | 668 | $datetimes = $this->datetimes_in_chronological_order(); |
669 | - foreach ( $datetimes as $datetime ) { |
|
670 | - if ( $datetime instanceof EE_Datetime ) { |
|
669 | + foreach ($datetimes as $datetime) { |
|
670 | + if ($datetime instanceof EE_Datetime) { |
|
671 | 671 | //if this dtt is upcoming or active then we return false. |
672 | - if ( $datetime->is_upcoming() || $datetime->is_active() ) { |
|
672 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
673 | 673 | return FALSE; |
674 | 674 | } |
675 | 675 | //otherwise let's check active status |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | */ |
687 | 687 | public function is_inactive() { |
688 | 688 | // check if event id is present and if this event is published |
689 | - if ( $this->_has_ID_and_is_published() ) { |
|
689 | + if ($this->_has_ID_and_is_published()) { |
|
690 | 690 | return FALSE; |
691 | 691 | } |
692 | 692 | return TRUE; |
@@ -704,37 +704,37 @@ discard block |
||
704 | 704 | */ |
705 | 705 | public function perform_sold_out_status_check() { |
706 | 706 | // get all unexpired untrashed tickets |
707 | - $tickets = $this->tickets( array( |
|
707 | + $tickets = $this->tickets(array( |
|
708 | 708 | array( |
709 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
709 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
710 | 710 | 'TKT_deleted' => false |
711 | 711 | ) |
712 | 712 | )); |
713 | 713 | // if all the tickets are just expired, then don't update the event status to sold out |
714 | - if ( empty( $tickets )) { |
|
714 | + if (empty($tickets)) { |
|
715 | 715 | return true; |
716 | 716 | } |
717 | 717 | // set initial value |
718 | 718 | $spaces_remaining = 0; |
719 | - foreach( $tickets as $ticket ) { |
|
720 | - if ( $ticket instanceof EE_Ticket ) { |
|
721 | - $spaces_remaining += $ticket->qty( 'saleable' ); |
|
719 | + foreach ($tickets as $ticket) { |
|
720 | + if ($ticket instanceof EE_Ticket) { |
|
721 | + $spaces_remaining += $ticket->qty('saleable'); |
|
722 | 722 | } |
723 | 723 | } |
724 | - if ( $spaces_remaining === 0 ) { |
|
725 | - $this->set_status( EEM_Event::sold_out ); |
|
726 | - if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) { |
|
724 | + if ($spaces_remaining === 0) { |
|
725 | + $this->set_status(EEM_Event::sold_out); |
|
726 | + if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
727 | 727 | $this->save(); |
728 | 728 | } |
729 | 729 | $sold_out = TRUE; |
730 | 730 | } else { |
731 | 731 | $sold_out = FALSE; |
732 | 732 | // was event previously marked as sold out ? |
733 | - if ( $this->status() == EEM_Event::sold_out ) { |
|
733 | + if ($this->status() == EEM_Event::sold_out) { |
|
734 | 734 | // revert status to previous value, if it was set |
735 | - $previous_event_status = $this->get_post_meta( '_previous_event_status', true ); |
|
736 | - if ( $previous_event_status ) { |
|
737 | - $this->set_status( $previous_event_status ); |
|
735 | + $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
736 | + if ($previous_event_status) { |
|
737 | + $this->set_status($previous_event_status); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | } |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function spaces_remaining_for_sale() { |
760 | 760 | //first get total available spaces including consideration for tickets that have already sold. |
761 | - $spaces_available = $this->total_available_spaces( true ); |
|
761 | + $spaces_available = $this->total_available_spaces(true); |
|
762 | 762 | |
763 | 763 | //if total available = 0, then exit right away because that means everything is expired. |
764 | - if ( $spaces_available === 0 ) { |
|
764 | + if ($spaces_available === 0) { |
|
765 | 765 | return 0; |
766 | 766 | } |
767 | 767 | |
768 | 768 | //subtract total approved registrations from spaces available to get how many are remaining. |
769 | - $spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
769 | + $spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
770 | 770 | $spaces_remaining = $spaces_available - $spots_taken; |
771 | 771 | |
772 | 772 | return $spaces_remaining > 0 ? $spaces_remaining : 0; |
@@ -799,29 +799,29 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
801 | 801 | */ |
802 | - public function total_available_spaces( $current_total_available = false ) { |
|
802 | + public function total_available_spaces($current_total_available = false) { |
|
803 | 803 | $spaces_available = 0; |
804 | 804 | |
805 | 805 | //first get all tickets on the event and include expired tickets |
806 | - $tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) ); |
|
806 | + $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
807 | 807 | $ticket_sums = array(); |
808 | 808 | $datetime_limits = array(); |
809 | 809 | |
810 | 810 | //loop through tickets and normalize them |
811 | - foreach ( $tickets as $ticket ) { |
|
812 | - $datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
811 | + foreach ($tickets as $ticket) { |
|
812 | + $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
813 | 813 | |
814 | - if ( empty( $datetimes ) ) { |
|
814 | + if (empty($datetimes)) { |
|
815 | 815 | continue; |
816 | 816 | } |
817 | 817 | |
818 | 818 | //first datetime should be the lowest datetime |
819 | - $least_datetime = reset( $datetimes ); |
|
819 | + $least_datetime = reset($datetimes); |
|
820 | 820 | |
821 | 821 | //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
822 | 822 | //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
823 | - if ( $current_total_available ) { |
|
824 | - if ( $ticket->is_remaining() ) { |
|
823 | + if ($current_total_available) { |
|
824 | + if ($ticket->is_remaining()) { |
|
825 | 825 | $remaining = $ticket->remaining(); |
826 | 826 | } else { |
827 | 827 | $spaces_available += $ticket->sold(); |
@@ -829,23 +829,23 @@ discard block |
||
829 | 829 | continue; |
830 | 830 | } |
831 | 831 | } else { |
832 | - $remaining = min( $ticket->qty(), $least_datetime->reg_limit() ); |
|
832 | + $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
836 | - if ( $remaining === EE_INF ) { |
|
836 | + if ($remaining === EE_INF) { |
|
837 | 837 | return EE_INF; |
838 | 838 | } |
839 | 839 | |
840 | 840 | //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
841 | 841 | //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
842 | - $ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes ); |
|
842 | + $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
843 | 843 | $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
844 | - foreach ( $datetimes as $datetime ) { |
|
845 | - if ( $datetime->reg_limit() === EE_INF ) { |
|
844 | + foreach ($datetimes as $datetime) { |
|
845 | + if ($datetime->reg_limit() === EE_INF) { |
|
846 | 846 | $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
847 | 847 | } else { |
848 | - $ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
848 | + $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
849 | 849 | } |
850 | 850 | $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
851 | 851 | } |
@@ -856,74 +856,74 @@ discard block |
||
856 | 856 | //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
857 | 857 | //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
858 | 858 | //$current_total_available ) for the datetimes on the ticket. |
859 | - usort( $ticket_sums, function( $a, $b ) { |
|
860 | - if ( $a['sum'] == $b['sum'] ) { |
|
861 | - if ( $a['datetime_sums'] == $b['datetime_sums'] ) { |
|
859 | + usort($ticket_sums, function($a, $b) { |
|
860 | + if ($a['sum'] == $b['sum']) { |
|
861 | + if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
862 | 862 | return 0; |
863 | 863 | } |
864 | 864 | |
865 | 865 | return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
866 | 866 | } |
867 | - return ( $a['sum'] < $b['sum'] ) ? -1 : 1; |
|
867 | + return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
868 | 868 | }); |
869 | 869 | |
870 | 870 | //now let's loop through the sorted tickets and simulate sellouts |
871 | - foreach ( $ticket_sums as $ticket_info ) { |
|
872 | - if ( $ticket_info['ticket'] instanceof EE_Ticket ) { |
|
871 | + foreach ($ticket_sums as $ticket_info) { |
|
872 | + if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
873 | 873 | |
874 | - $datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
874 | + $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
875 | 875 | //need to sort these $datetimes by remaining (only if $current_total_available) |
876 | 876 | //setup datetimes for simulation |
877 | 877 | $ticket_datetimes_remaining = array(); |
878 | - foreach( $datetimes as $datetime ) { |
|
878 | + foreach ($datetimes as $datetime) { |
|
879 | 879 | $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
880 | 880 | $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
881 | 881 | } |
882 | - usort( $ticket_datetimes_remaining, function( $a, $b ) { |
|
883 | - if ( $a['rem'] == $b['rem'] ) { |
|
882 | + usort($ticket_datetimes_remaining, function($a, $b) { |
|
883 | + if ($a['rem'] == $b['rem']) { |
|
884 | 884 | return 0; |
885 | 885 | } |
886 | - return ( $a['rem'] < $b['rem'] ) ? -1 : 1; |
|
886 | + return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
887 | 887 | }); |
888 | 888 | |
889 | 889 | |
890 | 890 | //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
891 | 891 | //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
892 | - $lowest_datetime = reset( $ticket_datetimes_remaining ); |
|
892 | + $lowest_datetime = reset($ticket_datetimes_remaining); |
|
893 | 893 | |
894 | 894 | //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
895 | 895 | // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
896 | 896 | // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
897 | 897 | // to the next ticket. |
898 | - if ( $current_total_available ) { |
|
899 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() ); |
|
898 | + if ($current_total_available) { |
|
899 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
900 | 900 | } else { |
901 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->qty() ); |
|
901 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
905 | 905 | //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
906 | 906 | //available. |
907 | - if ( $remaining === EE_INF ) { |
|
907 | + if ($remaining === EE_INF) { |
|
908 | 908 | $spaces_available += $ticket_info['ticket']->qty(); |
909 | 909 | continue; |
910 | 910 | } |
911 | 911 | |
912 | 912 | //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
913 | - if ( $current_total_available ) { |
|
913 | + if ($current_total_available) { |
|
914 | 914 | $spaces_available += $ticket_info['ticket']->sold(); |
915 | 915 | } |
916 | 916 | |
917 | - if ( $remaining <= 0 ) { |
|
917 | + if ($remaining <= 0) { |
|
918 | 918 | continue; |
919 | 919 | } else { |
920 | 920 | $spaces_available += $remaining; |
921 | 921 | } |
922 | 922 | |
923 | 923 | //loop through the datetimes and sell them out! |
924 | - foreach ( $ticket_datetimes_remaining as $datetime_info ) { |
|
925 | - if ( $datetime_info['datetime'] instanceof EE_Datetime ) { |
|
926 | - $datetime_limits[ $datetime_info['datetime']->ID() ] += - $remaining; |
|
924 | + foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
925 | + if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
926 | + $datetime_limits[$datetime_info['datetime']->ID()] += - $remaining; |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | } |
@@ -939,8 +939,8 @@ discard block |
||
939 | 939 | * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event |
940 | 940 | * @return boolean |
941 | 941 | */ |
942 | - public function is_sold_out( $actual = FALSE ) { |
|
943 | - if ( ! $actual ) { |
|
942 | + public function is_sold_out($actual = FALSE) { |
|
943 | + if ( ! $actual) { |
|
944 | 944 | return $this->status() == EEM_Event::sold_out; |
945 | 945 | } |
946 | 946 | else { |
@@ -985,30 +985,30 @@ discard block |
||
985 | 985 | * |
986 | 986 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
987 | 987 | */ |
988 | - public function get_active_status( $reset = false ) { |
|
988 | + public function get_active_status($reset = false) { |
|
989 | 989 | // if the active status has already been set, then just use that value (unless we are resetting it) |
990 | - if ( ! empty( $this->_active_status ) && ! $reset ) { |
|
990 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
991 | 991 | return $this->_active_status; |
992 | 992 | } |
993 | 993 | //first check if event id is present on this object |
994 | - if ( ! $this->ID() ) { |
|
994 | + if ( ! $this->ID()) { |
|
995 | 995 | return false; |
996 | 996 | } |
997 | 997 | |
998 | - $where_params_for_event = array( array( 'EVT_ID' => $this->ID() ) ); |
|
998 | + $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
999 | 999 | |
1000 | 1000 | //if event is published: |
1001 | - if ( $this->status() === 'publish' ) { |
|
1001 | + if ($this->status() === 'publish') { |
|
1002 | 1002 | //active? |
1003 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::active, $where_params_for_event ) > 0 ) { |
|
1003 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) > 0) { |
|
1004 | 1004 | $this->_active_status = EE_Datetime::active; |
1005 | 1005 | } else { |
1006 | 1006 | //upcoming? |
1007 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::upcoming, $where_params_for_event ) > 0 ) { |
|
1007 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0) { |
|
1008 | 1008 | $this->_active_status = EE_Datetime::upcoming; |
1009 | 1009 | } else { |
1010 | 1010 | //expired? |
1011 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::expired, $where_params_for_event ) > 0 ) { |
|
1011 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0) { |
|
1012 | 1012 | $this->_active_status = EE_Datetime::expired; |
1013 | 1013 | } else { |
1014 | 1014 | //it would be odd if things make it this far because it basically means there are no datetime's |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | } |
1020 | 1020 | } else { |
1021 | 1021 | //the event is not published, so let's just set it's active status according to its' post status |
1022 | - switch ( $this->status() ) { |
|
1022 | + switch ($this->status()) { |
|
1023 | 1023 | case EEM_Event::sold_out : |
1024 | 1024 | $this->_active_status = EE_Datetime::sold_out; |
1025 | 1025 | break; |
@@ -1045,10 +1045,10 @@ discard block |
||
1045 | 1045 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1046 | 1046 | * @return mixed void|string |
1047 | 1047 | */ |
1048 | - public function pretty_active_status( $echo = TRUE ) { |
|
1048 | + public function pretty_active_status($echo = TRUE) { |
|
1049 | 1049 | $active_status = $this->get_active_status(); |
1050 | - $status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>'; |
|
1051 | - if ( $echo ) { |
|
1050 | + $status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>'; |
|
1051 | + if ($echo) { |
|
1052 | 1052 | echo $status; |
1053 | 1053 | return ''; |
1054 | 1054 | } |
@@ -1062,12 +1062,12 @@ discard block |
||
1062 | 1062 | */ |
1063 | 1063 | public function get_number_of_tickets_sold() { |
1064 | 1064 | $tkt_sold = 0; |
1065 | - if ( !$this->ID() ) { |
|
1065 | + if ( ! $this->ID()) { |
|
1066 | 1066 | return 0; |
1067 | 1067 | } |
1068 | 1068 | $datetimes = $this->datetimes(); |
1069 | - foreach ( $datetimes as $datetime ) { |
|
1070 | - if ( $datetime instanceof EE_Datetime ) { |
|
1069 | + foreach ($datetimes as $datetime) { |
|
1070 | + if ($datetime instanceof EE_Datetime) { |
|
1071 | 1071 | $tkt_sold += $datetime->sold(); |
1072 | 1072 | } |
1073 | 1073 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * @return int |
1083 | 1083 | */ |
1084 | 1084 | public function get_count_of_all_registrations() { |
1085 | - return EEM_Event::instance()->count_related( $this, 'Registration' ); |
|
1085 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | |
@@ -1092,9 +1092,9 @@ discard block |
||
1092 | 1092 | * @return EE_Ticket |
1093 | 1093 | */ |
1094 | 1094 | public function get_ticket_with_earliest_start_time() { |
1095 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1096 | - $query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) ); |
|
1097 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1095 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1096 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1097 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | |
@@ -1104,9 +1104,9 @@ discard block |
||
1104 | 1104 | * @return EE_Ticket |
1105 | 1105 | */ |
1106 | 1106 | public function get_ticket_with_latest_end_time() { |
1107 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1108 | - $query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) ); |
|
1109 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1107 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1108 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1109 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | |
@@ -1118,11 +1118,11 @@ discard block |
||
1118 | 1118 | public function tickets_on_sale() { |
1119 | 1119 | $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
1120 | 1120 | $latest_ticket = $this->get_ticket_with_latest_end_time(); |
1121 | - if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) { |
|
1121 | + if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
1122 | 1122 | return FALSE; |
1123 | 1123 | } |
1124 | 1124 | //check on sale for these two tickets. |
1125 | - if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) { |
|
1125 | + if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
1126 | 1126 | return TRUE; |
1127 | 1127 | } |
1128 | 1128 | return FALSE; |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | * @return string |
1137 | 1137 | */ |
1138 | 1138 | public function get_permalink() { |
1139 | - if ( $this->external_url() ) { |
|
1139 | + if ($this->external_url()) { |
|
1140 | 1140 | return $this->external_url(); |
1141 | 1141 | } |
1142 | 1142 | else { |
@@ -1151,10 +1151,10 @@ discard block |
||
1151 | 1151 | * @param array $query_params like EEM_Base::get_all |
1152 | 1152 | * @return EE_Term |
1153 | 1153 | */ |
1154 | - public function first_event_category( $query_params = array() ) { |
|
1155 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1156 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1157 | - return EEM_Term::instance()->get_one( $query_params ); |
|
1154 | + public function first_event_category($query_params = array()) { |
|
1155 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1156 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1157 | + return EEM_Term::instance()->get_one($query_params); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1164,10 +1164,10 @@ discard block |
||
1164 | 1164 | * @param array $query_params |
1165 | 1165 | * @return EE_Term[] |
1166 | 1166 | */ |
1167 | - public function get_all_event_categories( $query_params = array() ) { |
|
1168 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1169 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1170 | - return EEM_Term::instance()->get_all( $query_params ); |
|
1167 | + public function get_all_event_categories($query_params = array()) { |
|
1168 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1169 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1170 | + return EEM_Term::instance()->get_all($query_params); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | /** |
@@ -1175,8 +1175,8 @@ discard block |
||
1175 | 1175 | * @param array $query_params @see EEM_Base::get_all |
1176 | 1176 | * @return EE_Question_Group[] |
1177 | 1177 | */ |
1178 | - public function question_groups($query_params = array()){ |
|
1179 | - $query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' )); |
|
1178 | + public function question_groups($query_params = array()) { |
|
1179 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1180 | 1180 | return $this->get_many_related('Question_Group', $query_params); |
1181 | 1181 | } |
1182 | 1182 | |
@@ -1215,12 +1215,12 @@ discard block |
||
1215 | 1215 | * @return string |
1216 | 1216 | */ |
1217 | 1217 | public function get_admin_edit_link() { |
1218 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1218 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1219 | 1219 | 'page' => 'espresso_events', |
1220 | 1220 | 'action' => 'edit', |
1221 | 1221 | 'post' => $this->ID() |
1222 | 1222 | ), |
1223 | - admin_url( 'admin.php' ) |
|
1223 | + admin_url('admin.php') |
|
1224 | 1224 | ); |
1225 | 1225 | } |
1226 | 1226 | |
@@ -1232,11 +1232,11 @@ discard block |
||
1232 | 1232 | * @return string |
1233 | 1233 | */ |
1234 | 1234 | public function get_admin_settings_link() { |
1235 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1235 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1236 | 1236 | 'page' => 'espresso_events', |
1237 | 1237 | 'action' => 'default_event_settings' |
1238 | 1238 | ), |
1239 | - admin_url( 'admin.php' ) |
|
1239 | + admin_url('admin.php') |
|
1240 | 1240 | ); |
1241 | 1241 | } |
1242 | 1242 | |
@@ -1251,11 +1251,11 @@ discard block |
||
1251 | 1251 | */ |
1252 | 1252 | public function get_admin_overview_link() { |
1253 | 1253 | |
1254 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1254 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1255 | 1255 | 'page' => 'espresso_events', |
1256 | 1256 | 'action' => 'default' |
1257 | 1257 | ), |
1258 | - admin_url( 'admin.php' ) |
|
1258 | + admin_url('admin.php') |
|
1259 | 1259 | ); |
1260 | 1260 | } |
1261 | 1261 |
@@ -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,27 +35,27 @@ 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_Post_Content_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_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_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
56 | 56 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
57 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
58 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
57 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
58 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
59 | 59 | )); |
60 | 60 | $this->_model_relations = array( |
61 | 61 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | ); |
65 | 65 | $this->_model_chain_to_wp_user = 'Event'; |
66 | 66 | //this model is generally available for reading |
67 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
71 | - parent::__construct( $timezone ); |
|
67 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
71 | + parent::__construct($timezone); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | public function create_new_blank_datetime() { |
84 | 84 | $blank_datetime = EE_Datetime::new_instance( |
85 | 85 | array( |
86 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
87 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
86 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
88 | 88 | 'DTT_order' => 1, |
89 | 89 | 'DTT_reg_limit' => EE_INF |
90 | 90 | ), |
91 | 91 | $this->_timezone |
92 | 92 | ); |
93 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
94 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
95 | - return array( $blank_datetime ); |
|
93 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
94 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
95 | + return array($blank_datetime); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param int $EVT_ID |
107 | 107 | * @return EE_Datetime[] array on success, FALSE on fail |
108 | 108 | */ |
109 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
110 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
109 | + public function get_all_event_dates($EVT_ID = 0) { |
|
110 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
111 | 111 | return $this->create_new_blank_datetime(); |
112 | 112 | } |
113 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
113 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | 114 | |
115 | - if ( empty( $results ) ) { |
|
115 | + if (empty($results)) { |
|
116 | 116 | return $this->create_new_blank_datetime(); |
117 | 117 | } |
118 | 118 | |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | * the given number |
134 | 134 | * @return EE_Datetime[] |
135 | 135 | */ |
136 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
136 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
137 | 137 | |
138 | 138 | //sanitize EVT_ID |
139 | - $EVT_ID = intval( $EVT_ID ); |
|
139 | + $EVT_ID = intval($EVT_ID); |
|
140 | 140 | |
141 | 141 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
142 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
143 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
142 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
143 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
144 | 144 | |
145 | - $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' ); |
|
145 | + $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 | 146 | |
147 | - if( ! $include_expired){ |
|
148 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
147 | + if ( ! $include_expired) { |
|
148 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
149 | 149 | } |
150 | - if( $include_deleted){ |
|
151 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
150 | + if ($include_deleted) { |
|
151 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
152 | 152 | } |
153 | 153 | |
154 | - $result = $this->get_all( $query_params ); |
|
155 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
154 | + $result = $this->get_all($query_params); |
|
155 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
156 | 156 | return $result; |
157 | 157 | } |
158 | 158 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param int $limit |
168 | 168 | * @return EE_Datetime[] |
169 | 169 | */ |
170 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
171 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
170 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
171 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
172 | 172 | 'limit'=>$limit, |
173 | 173 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
174 | 174 | 'default_where_conditions' => 'none')); |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param boolean $include_deleted |
184 | 184 | * @return EE_Datetime |
185 | 185 | */ |
186 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
187 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | - if($results){ |
|
186 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
187 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | + if ($results) { |
|
189 | 189 | return array_shift($results); |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return NULL; |
192 | 192 | } |
193 | 193 | } |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | * @param bool $try_to_exclude_deleted |
202 | 202 | * @return \EE_Datetime |
203 | 203 | */ |
204 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
205 | - if($try_to_exclude_expired){ |
|
206 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
207 | - if($non_expired){ |
|
204 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
205 | + if ($try_to_exclude_expired) { |
|
206 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
207 | + if ($non_expired) { |
|
208 | 208 | return $non_expired; |
209 | 209 | } |
210 | 210 | } |
211 | - if($try_to_exclude_deleted){ |
|
211 | + if ($try_to_exclude_deleted) { |
|
212 | 212 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
213 | - if($expired_even){ |
|
213 | + if ($expired_even) { |
|
214 | 214 | return $expired_even; |
215 | 215 | } |
216 | 216 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * @param int $limit |
230 | 230 | * @return EE_Datetime[] |
231 | 231 | */ |
232 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
232 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
233 | 233 | //sanitize EVT_ID |
234 | - $EVT_ID = intval( $EVT_ID ); |
|
234 | + $EVT_ID = intval($EVT_ID); |
|
235 | 235 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
236 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
237 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | - if( ! $include_expired){ |
|
239 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
236 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
237 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | + if ( ! $include_expired) { |
|
239 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
240 | 240 | } |
241 | - if( $include_deleted){ |
|
242 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
241 | + if ($include_deleted) { |
|
242 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
243 | 243 | } |
244 | - if($limit){ |
|
244 | + if ($limit) { |
|
245 | 245 | $query_params['limit'] = $limit; |
246 | 246 | } |
247 | - $result = $this->get_all( $query_params ); |
|
248 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
247 | + $result = $this->get_all($query_params); |
|
248 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
249 | 249 | return $result; |
250 | 250 | } |
251 | 251 | |
@@ -258,23 +258,23 @@ discard block |
||
258 | 258 | * @param int $limit |
259 | 259 | * @return EE_Datetime[] |
260 | 260 | */ |
261 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
261 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
262 | 262 | //sanitize TKT_ID |
263 | - $TKT_ID = intval( $TKT_ID ); |
|
263 | + $TKT_ID = intval($TKT_ID); |
|
264 | 264 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
265 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
266 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | - if( ! $include_expired){ |
|
268 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
265 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
266 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | + if ( ! $include_expired) { |
|
268 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
269 | 269 | } |
270 | - if( $include_deleted){ |
|
271 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
270 | + if ($include_deleted) { |
|
271 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
272 | 272 | } |
273 | - if($limit){ |
|
273 | + if ($limit) { |
|
274 | 274 | $query_params['limit'] = $limit; |
275 | 275 | } |
276 | - $result = $this->get_all( $query_params ); |
|
277 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
276 | + $result = $this->get_all($query_params); |
|
277 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
278 | 278 | return $result; |
279 | 279 | } |
280 | 280 | |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | * that number |
291 | 291 | * @return EE_Datetime[] |
292 | 292 | */ |
293 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
293 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
294 | 294 | //sanitize id. |
295 | - $TKT_ID = intval( $TKT_ID ); |
|
295 | + $TKT_ID = intval($TKT_ID); |
|
296 | 296 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
297 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
298 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
299 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
300 | - if( ! $include_expired){ |
|
301 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
297 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
298 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
299 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
300 | + if ( ! $include_expired) { |
|
301 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
302 | 302 | } |
303 | - if( $include_deleted){ |
|
304 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
303 | + if ($include_deleted) { |
|
304 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
305 | 305 | } |
306 | - if($limit){ |
|
306 | + if ($limit) { |
|
307 | 307 | $query_params['limit'] = $limit; |
308 | 308 | } |
309 | - $result = $this->get_all( $query_params ); |
|
310 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
309 | + $result = $this->get_all($query_params); |
|
310 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
311 | 311 | return $result; |
312 | 312 | } |
313 | 313 | |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | * @param int $EVT_ID |
319 | 319 | * @return EE_Datetime |
320 | 320 | */ |
321 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
321 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
322 | 322 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
323 | - if($results){ |
|
323 | + if ($results) { |
|
324 | 324 | return array_shift($results); |
325 | - }else{ |
|
325 | + } else { |
|
326 | 326 | return null; |
327 | 327 | } |
328 | 328 | } |
@@ -341,77 +341,77 @@ discard block |
||
341 | 341 | * - inactive = Events that are either not published. |
342 | 342 | * @return wpdb results array |
343 | 343 | */ |
344 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
345 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query( 'DTT_EVT_start' ); |
|
346 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query( 'DTT_EVT_end' ); |
|
344 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
345 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
346 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
347 | 347 | |
348 | - switch ( $evt_active_status ) { |
|
348 | + switch ($evt_active_status) { |
|
349 | 349 | case 'upcoming' : |
350 | 350 | $where_params['Event.status'] = 'publish'; |
351 | 351 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
352 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
352 | + if (isset($where_params['DTT_EVT_start'])) { |
|
353 | 353 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
354 | 354 | } |
355 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start ); |
|
355 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'expired' : |
359 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
359 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
360 | 360 | //get events to exclude |
361 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) ); |
|
361 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
362 | 362 | //first get all events that have datetimes where its not expired. |
363 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
364 | - $event_ids = array_keys( $event_ids ); |
|
363 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
364 | + $event_ids = array_keys($event_ids); |
|
365 | 365 | |
366 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
366 | + if (isset($where_params['DTT_EVT_end'])) { |
|
367 | 367 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
368 | 368 | } |
369 | - $where_params['DTT_EVT_end'] = array( '<', $current_time_for_DTT_EVT_end ); |
|
370 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
369 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
370 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
371 | 371 | break; |
372 | 372 | |
373 | 373 | case 'active' : |
374 | 374 | $where_params['Event.status'] = 'publish'; |
375 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
375 | + if (isset($where_params['DTT_EVT_start'])) { |
|
376 | 376 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
377 | 377 | } |
378 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
378 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
379 | 379 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
380 | 380 | } |
381 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start ); |
|
382 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end ); |
|
381 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
382 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
383 | 383 | break; |
384 | 384 | |
385 | 385 | case 'inactive' : |
386 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
387 | - if ( isset( $where_params['OR'] ) ) { |
|
386 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
387 | + if (isset($where_params['OR'])) { |
|
388 | 388 | $where_params['AND']['OR'] = $where_params['OR']; |
389 | 389 | } |
390 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
390 | + if (isset($where_params['DTT_EVT_end'])) { |
|
391 | 391 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
392 | - unset( $where_params['DTT_EVT_end'] ); |
|
392 | + unset($where_params['DTT_EVT_end']); |
|
393 | 393 | } |
394 | 394 | |
395 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
395 | + if (isset($where_params['DTT_EVT_start'])) { |
|
396 | 396 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
397 | - unset( $where_params['DTT_EVT_start'] ); |
|
397 | + unset($where_params['DTT_EVT_start']); |
|
398 | 398 | } |
399 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
399 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
400 | 400 | break; |
401 | 401 | } |
402 | 402 | |
403 | 403 | $query_params[0] = $where_params; |
404 | 404 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
405 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
405 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
406 | 406 | |
407 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'DTT_EVT_start' ); |
|
407 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
408 | 408 | |
409 | 409 | $columns_to_select = array( |
410 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
411 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
412 | - 'dtt_month_num' => array('MONTH(' . $query_interval .')', '%s') |
|
410 | + 'dtt_year' => array('YEAR('.$query_interval.')', '%s'), |
|
411 | + 'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'), |
|
412 | + 'dtt_month_num' => array('MONTH('.$query_interval.')', '%s') |
|
413 | 413 | ); |
414 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
414 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * for the tickets for each datetime) |
420 | 420 | * @param EE_Datetime[] $datetimes |
421 | 421 | */ |
422 | - public function update_sold($datetimes){ |
|
423 | - foreach($datetimes as $datetime){ |
|
422 | + public function update_sold($datetimes) { |
|
423 | + foreach ($datetimes as $datetime) { |
|
424 | 424 | $datetime->update_sold(); |
425 | 425 | } |
426 | 426 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * @param array $query_params |
436 | 436 | * @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. |
437 | 437 | */ |
438 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
439 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
440 | - if ( $datetime instanceof EE_Datetime ) { |
|
441 | - return $datetime->tickets_remaining( $query_params ); |
|
438 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
439 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
440 | + if ($datetime instanceof EE_Datetime) { |
|
441 | + return $datetime->tickets_remaining($query_params); |
|
442 | 442 | } |
443 | 443 | return 0; |
444 | 444 | } |
@@ -460,36 +460,36 @@ discard block |
||
460 | 460 | * EE_Datetime::upcoming |
461 | 461 | * EE_Datetime::expired |
462 | 462 | */ |
463 | - public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) { |
|
463 | + public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) { |
|
464 | 464 | //only accept where conditions for this query. |
465 | - $_where = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
465 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
466 | 466 | $status_query_args = array( |
467 | 467 | EE_Datetime::active => array_merge( |
468 | 468 | $_where, |
469 | - array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) ) |
|
469 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
470 | 470 | ), |
471 | 471 | EE_Datetime::upcoming => array_merge( |
472 | 472 | $_where, |
473 | - array( 'DTT_EVT_start' => array( '>', time() ) ) |
|
473 | + array('DTT_EVT_start' => array('>', time())) |
|
474 | 474 | ), |
475 | 475 | EE_Datetime::expired => array_merge( |
476 | 476 | $_where, |
477 | - array( 'DTT_EVT_end' => array('<', time() ) ) |
|
477 | + array('DTT_EVT_end' => array('<', time())) |
|
478 | 478 | ) |
479 | 479 | ); |
480 | 480 | |
481 | - if ( ! empty( $stati_to_include ) ) { |
|
482 | - foreach( array_keys( $status_query_args ) as $status ) { |
|
483 | - if ( ! in_array( $status, $stati_to_include ) ) { |
|
484 | - unset( $status_query_args[$status] ); |
|
481 | + if ( ! empty($stati_to_include)) { |
|
482 | + foreach (array_keys($status_query_args) as $status) { |
|
483 | + if ( ! in_array($status, $stati_to_include)) { |
|
484 | + unset($status_query_args[$status]); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
489 | 489 | //loop through and query counts for each stati. |
490 | 490 | $status_query_results = array(); |
491 | - foreach( $status_query_args as $status => $status_where_conditions ) { |
|
492 | - $status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true ); |
|
491 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
492 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return $status_query_results; |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | * @param array $query_params |
504 | 504 | * @return int |
505 | 505 | */ |
506 | - public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) { |
|
507 | - $count = $this->get_datetime_counts_by_status( array( $status ), $query_params ); |
|
508 | - return ! empty( $count[$status] ) ? $count[$status] : 0; |
|
506 | + public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) { |
|
507 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
508 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -516,10 +516,10 @@ discard block |
||
516 | 516 | * @param \EE_Event $event |
517 | 517 | * @return int |
518 | 518 | */ |
519 | - public function count_active_datetimes_for_event( EE_Event $event ) { |
|
519 | + public function count_active_datetimes_for_event(EE_Event $event) { |
|
520 | 520 | $datetime_counts = $this->get_datetime_counts_by_status( |
521 | - array( EE_Datetime::active ), |
|
522 | - array('EVT_ID' => $event->ID() ) |
|
521 | + array(EE_Datetime::active), |
|
522 | + array('EVT_ID' => $event->ID()) |
|
523 | 523 | ); |
524 | 524 | return reset($datetime_counts); |
525 | 525 | } |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | * @param \EE_Event $event |
533 | 533 | * @return int |
534 | 534 | */ |
535 | - public function count_upcoming_datetimes_for_event( EE_Event $event ) { |
|
535 | + public function count_upcoming_datetimes_for_event(EE_Event $event) { |
|
536 | 536 | $datetime_counts = $this->get_datetime_counts_by_status( |
537 | - array( EE_Datetime::upcoming ), |
|
538 | - array('EVT_ID' => $event->ID() ) |
|
537 | + array(EE_Datetime::upcoming), |
|
538 | + array('EVT_ID' => $event->ID()) |
|
539 | 539 | ); |
540 | 540 | return reset($datetime_counts); |
541 | 541 | } |
@@ -548,10 +548,10 @@ discard block |
||
548 | 548 | * @param \EE_Event $event |
549 | 549 | * @return int |
550 | 550 | */ |
551 | - public function count_active_and_upcoming_datetimes_for_event( EE_Event $event ) { |
|
551 | + public function count_active_and_upcoming_datetimes_for_event(EE_Event $event) { |
|
552 | 552 | $datetime_counts = $this->get_datetime_counts_by_status( |
553 | - array( EE_Datetime::active, EE_Datetime::upcoming ), |
|
554 | - array('EVT_ID' => $event->ID() ) |
|
553 | + array(EE_Datetime::active, EE_Datetime::upcoming), |
|
554 | + array('EVT_ID' => $event->ID()) |
|
555 | 555 | ); |
556 | 556 | return array_sum($datetime_counts); |
557 | 557 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -187,7 +189,7 @@ discard block |
||
187 | 189 | $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
188 | 190 | if($results){ |
189 | 191 | return array_shift($results); |
190 | - }else{ |
|
192 | + } else{ |
|
191 | 193 | return NULL; |
192 | 194 | } |
193 | 195 | } |
@@ -322,7 +324,7 @@ discard block |
||
322 | 324 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
323 | 325 | if($results){ |
324 | 326 | return array_shift($results); |
325 | - }else{ |
|
327 | + } else{ |
|
326 | 328 | return null; |
327 | 329 | } |
328 | 330 | } |
@@ -356,7 +358,9 @@ discard block |
||
356 | 358 | break; |
357 | 359 | |
358 | 360 | case 'expired' : |
359 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
361 | + if ( isset( $where_params['Event.status'] ) ) { |
|
362 | + unset( $where_params['Event.status'] ); |
|
363 | + } |
|
360 | 364 | //get events to exclude |
361 | 365 | $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) ); |
362 | 366 | //first get all events that have datetimes where its not expired. |
@@ -383,7 +387,9 @@ discard block |
||
383 | 387 | break; |
384 | 388 | |
385 | 389 | case 'inactive' : |
386 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
390 | + if ( isset( $where_params['Event.status'] ) ) { |
|
391 | + unset( $where_params['Event.status'] ); |
|
392 | + } |
|
387 | 393 | if ( isset( $where_params['OR'] ) ) { |
388 | 394 | $where_params['AND']['OR'] = $where_params['OR']; |
389 | 395 | } |