Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like EE_Event often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EE_Event, and based on these observations, apply Extract Interface, too.
1 | <?php use EventEspresso\core\exceptions\InvalidStatusException; |
||
15 | class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * cached value for the the logical active status for the event |
||
20 | * |
||
21 | * @see get_active_status() |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $_active_status = ''; |
||
25 | |||
26 | /** |
||
27 | * This is just used for caching the Primary Datetime for the Event on initial retrieval |
||
28 | * |
||
29 | * @var EE_Datetime |
||
30 | */ |
||
31 | protected $_Primary_Datetime; |
||
32 | |||
33 | |||
34 | /** |
||
35 | * @param array $props_n_values incoming values |
||
36 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
37 | * used.) |
||
38 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
39 | * date_format and the second value is the time format |
||
40 | * @return EE_Event |
||
41 | * @throws EE_Error |
||
42 | */ |
||
43 | public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
||
48 | |||
49 | |||
50 | /** |
||
51 | * @param array $props_n_values incoming values from the database |
||
52 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
53 | * the website will be used. |
||
54 | * @return EE_Event |
||
55 | * @throws EE_Error |
||
56 | */ |
||
57 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
||
58 | { |
||
59 | return new self($props_n_values, true, $timezone); |
||
60 | } |
||
61 | |||
62 | |||
63 | /** |
||
64 | * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
||
65 | * |
||
66 | * @param string $field_name |
||
67 | * @param mixed $field_value |
||
68 | * @param bool $use_default |
||
69 | * @throws EE_Error |
||
70 | */ |
||
71 | public function set($field_name, $field_value, $use_default = false) |
||
72 | { |
||
73 | switch ($field_name) { |
||
74 | case 'status' : |
||
75 | $this->set_status($field_value, $use_default); |
||
76 | break; |
||
77 | default : |
||
78 | parent::set($field_name, $field_value, $use_default); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | |||
83 | /** |
||
84 | * set_status |
||
85 | * Checks if event status is being changed to SOLD OUT |
||
86 | * and updates event meta data with previous event status |
||
87 | * so that we can revert things if/when the event is no longer sold out |
||
88 | * |
||
89 | * @access public |
||
90 | * @param string $new_status |
||
91 | * @param bool $use_default |
||
92 | * @return void |
||
93 | * @throws EE_Error |
||
94 | */ |
||
95 | public function set_status($new_status = null, $use_default = false) |
||
96 | { |
||
97 | // if nothing is set, and we aren't explicitly wanting to reset the status, then just leave |
||
98 | if (empty($new_status) && !$use_default) { |
||
99 | return; |
||
100 | } |
||
101 | // get current Event status |
||
102 | $old_status = $this->status(); |
||
103 | // if status has changed |
||
104 | if ($old_status !== $new_status) { |
||
105 | // TO sold_out |
||
106 | if ($new_status === EEM_Event::sold_out) { |
||
107 | // save the previous event status so that we can revert if the event is no longer sold out |
||
108 | $this->add_post_meta('_previous_event_status', $old_status); |
||
109 | do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
||
110 | // OR FROM sold_out |
||
111 | } else if ($old_status === EEM_Event::sold_out) { |
||
112 | $this->delete_post_meta('_previous_event_status'); |
||
113 | do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
||
114 | } |
||
115 | // update status |
||
116 | parent::set('status', $new_status, $use_default); |
||
117 | do_action('AHEE__EE_Event__set_status__after_update', $this); |
||
118 | return; |
||
119 | } |
||
120 | // even though the old value matches the new value, it's still good to |
||
121 | // allow the parent set method to have a say |
||
122 | parent::set('status', $new_status, $use_default); |
||
123 | } |
||
124 | |||
125 | |||
126 | /** |
||
127 | * Gets all the datetimes for this event |
||
128 | * |
||
129 | * @param array $query_params like EEM_Base::get_all |
||
130 | * @return EE_Base_Class[]|EE_Datetime[] |
||
131 | * @throws EE_Error |
||
132 | */ |
||
133 | public function datetimes($query_params = array()) |
||
134 | { |
||
135 | return $this->get_many_related('Datetime', $query_params); |
||
136 | } |
||
137 | |||
138 | |||
139 | /** |
||
140 | * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
||
141 | * |
||
142 | * @return EE_Base_Class[]|EE_Datetime[] |
||
143 | * @throws EE_Error |
||
144 | */ |
||
145 | public function datetimes_in_chronological_order() |
||
146 | { |
||
147 | return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
||
148 | } |
||
149 | |||
150 | |||
151 | /** |
||
152 | * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
||
153 | * @darren, we should probably UNSET timezone on the EEM_Datetime model |
||
154 | * after running our query, so that this timezone isn't set for EVERY query |
||
155 | * on EEM_Datetime for the rest of the request, no? |
||
156 | * |
||
157 | * @param boolean $show_expired whether or not to include expired events |
||
158 | * @param boolean $show_deleted whether or not to include deleted events |
||
159 | * @param null $limit |
||
160 | * @return EE_Datetime[] |
||
161 | * @throws EE_Error |
||
162 | */ |
||
163 | public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
||
164 | { |
||
165 | return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order( |
||
166 | $this->ID(), |
||
167 | $show_expired, |
||
168 | $show_deleted, |
||
169 | $limit |
||
170 | ); |
||
171 | } |
||
172 | |||
173 | |||
174 | /** |
||
175 | * Returns one related datetime. Mostly only used by some legacy code. |
||
176 | * |
||
177 | * @return EE_Base_Class|EE_Datetime |
||
178 | * @throws EE_Error |
||
179 | */ |
||
180 | public function first_datetime() |
||
181 | { |
||
182 | return $this->get_first_related('Datetime'); |
||
183 | } |
||
184 | |||
185 | |||
186 | /** |
||
187 | * Returns the 'primary' datetime for the event |
||
188 | * |
||
189 | * @param bool $try_to_exclude_expired |
||
190 | * @param bool $try_to_exclude_deleted |
||
191 | * @return EE_Datetime |
||
192 | * @throws EE_Error |
||
193 | */ |
||
194 | public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
||
195 | { |
||
196 | if (!empty ($this->_Primary_Datetime)) { |
||
197 | return $this->_Primary_Datetime; |
||
198 | } |
||
199 | $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event( |
||
200 | $this->ID(), |
||
201 | $try_to_exclude_expired, |
||
202 | $try_to_exclude_deleted |
||
203 | ); |
||
204 | return $this->_Primary_Datetime; |
||
205 | } |
||
206 | |||
207 | |||
208 | /** |
||
209 | * Gets all the tickets available for purchase of this event |
||
210 | * |
||
211 | * @param array $query_params like EEM_Base::get_all |
||
212 | * @return EE_Base_Class[]|EE_Ticket[] |
||
213 | * @throws EE_Error |
||
214 | */ |
||
215 | public function tickets($query_params = array()) |
||
216 | { |
||
217 | //first get all datetimes |
||
218 | $datetimes = $this->datetimes_ordered(); |
||
219 | if (!$datetimes) { |
||
|
|||
220 | return array(); |
||
221 | } |
||
222 | $datetime_ids = array(); |
||
223 | foreach ($datetimes as $datetime) { |
||
224 | $datetime_ids[] = $datetime->ID(); |
||
225 | } |
||
226 | $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
||
227 | //if incoming $query_params has where conditions let's merge but not override existing. |
||
228 | if (is_array($query_params) && isset($query_params[0])) { |
||
229 | $where_params = array_merge($query_params[0], $where_params); |
||
230 | unset($query_params[0]); |
||
231 | } |
||
232 | //now add $where_params to $query_params |
||
233 | $query_params[0] = $where_params; |
||
234 | return EEM_Ticket::instance()->get_all($query_params); |
||
235 | } |
||
236 | |||
237 | |||
238 | /** |
||
239 | * get all unexpired untrashed tickets |
||
240 | * |
||
241 | * @return EE_Ticket[] |
||
242 | * @throws EE_Error |
||
243 | */ |
||
244 | public function active_tickets() |
||
245 | { |
||
246 | return $this->tickets(array( |
||
247 | array( |
||
248 | 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
||
249 | 'TKT_deleted' => false, |
||
250 | ), |
||
251 | )); |
||
252 | } |
||
253 | |||
254 | |||
255 | /** |
||
256 | * @return bool |
||
257 | * @throws EE_Error |
||
258 | */ |
||
259 | public function additional_limit() |
||
260 | { |
||
261 | return $this->get('EVT_additional_limit'); |
||
262 | } |
||
263 | |||
264 | |||
265 | /** |
||
266 | * @return bool |
||
267 | * @throws EE_Error |
||
268 | */ |
||
269 | public function allow_overflow() |
||
270 | { |
||
271 | return $this->get('EVT_allow_overflow'); |
||
272 | } |
||
273 | |||
274 | |||
275 | /** |
||
276 | * @return bool |
||
277 | * @throws EE_Error |
||
278 | */ |
||
279 | public function created() |
||
280 | { |
||
281 | return $this->get('EVT_created'); |
||
282 | } |
||
283 | |||
284 | |||
285 | /** |
||
286 | * @return bool |
||
287 | * @throws EE_Error |
||
288 | */ |
||
289 | public function description() |
||
290 | { |
||
291 | return $this->get('EVT_desc'); |
||
292 | } |
||
293 | |||
294 | |||
295 | /** |
||
296 | * Runs do_shortcode and wpautop on the description |
||
297 | * |
||
298 | * @return string of html |
||
299 | * @throws EE_Error |
||
300 | */ |
||
301 | public function description_filtered() |
||
302 | { |
||
303 | return $this->get_pretty('EVT_desc'); |
||
304 | } |
||
305 | |||
306 | |||
307 | /** |
||
308 | * @return bool |
||
309 | * @throws EE_Error |
||
310 | */ |
||
311 | public function display_description() |
||
312 | { |
||
313 | return $this->get('EVT_display_desc'); |
||
314 | } |
||
315 | |||
316 | |||
317 | /** |
||
318 | * @return bool |
||
319 | * @throws EE_Error |
||
320 | */ |
||
321 | public function display_ticket_selector() |
||
322 | { |
||
323 | return (bool)$this->get('EVT_display_ticket_selector'); |
||
324 | } |
||
325 | |||
326 | |||
327 | /** |
||
328 | * @return bool |
||
329 | * @throws EE_Error |
||
330 | */ |
||
331 | public function external_url() |
||
332 | { |
||
333 | return $this->get('EVT_external_URL'); |
||
334 | } |
||
335 | |||
336 | |||
337 | /** |
||
338 | * @return bool |
||
339 | * @throws EE_Error |
||
340 | */ |
||
341 | public function member_only() |
||
342 | { |
||
343 | return $this->get('EVT_member_only'); |
||
344 | } |
||
345 | |||
346 | |||
347 | /** |
||
348 | * @return bool |
||
349 | * @throws EE_Error |
||
350 | */ |
||
351 | public function phone() |
||
352 | { |
||
353 | return $this->get('EVT_phone'); |
||
354 | } |
||
355 | |||
356 | |||
357 | /** |
||
358 | * @return bool |
||
359 | * @throws EE_Error |
||
360 | */ |
||
361 | public function modified() |
||
365 | |||
366 | |||
367 | /** |
||
368 | * @return bool |
||
369 | * @throws EE_Error |
||
370 | */ |
||
371 | public function name() |
||
372 | { |
||
373 | return $this->get('EVT_name'); |
||
374 | } |
||
375 | |||
376 | |||
377 | /** |
||
378 | * @return bool |
||
379 | * @throws EE_Error |
||
380 | */ |
||
381 | public function order() |
||
382 | { |
||
383 | return $this->get('EVT_order'); |
||
384 | } |
||
385 | |||
386 | |||
387 | /** |
||
388 | * @return bool|string |
||
389 | * @throws EE_Error |
||
390 | */ |
||
391 | public function default_registration_status() |
||
398 | |||
399 | |||
400 | /** |
||
401 | * @param int $num_words |
||
402 | * @param null $more |
||
403 | * @param bool $not_full_desc |
||
404 | * @return bool|string |
||
405 | * @throws EE_Error |
||
406 | */ |
||
407 | public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
||
416 | |||
417 | |||
418 | /** |
||
419 | * @return bool |
||
420 | * @throws EE_Error |
||
421 | */ |
||
422 | public function slug() |
||
426 | |||
427 | |||
428 | /** |
||
429 | * @return bool |
||
430 | * @throws EE_Error |
||
431 | */ |
||
432 | public function timezone_string() |
||
436 | |||
437 | |||
438 | /** |
||
439 | * @return bool |
||
440 | * @throws EE_Error |
||
441 | */ |
||
442 | public function visible_on() |
||
446 | |||
447 | |||
448 | /** |
||
449 | * @return int |
||
450 | * @throws EE_Error |
||
451 | */ |
||
452 | public function wp_user() |
||
456 | |||
457 | |||
458 | /** |
||
459 | * @return bool |
||
460 | * @throws EE_Error |
||
461 | */ |
||
462 | public function donations() |
||
466 | |||
467 | |||
468 | /** |
||
469 | * @param $limit |
||
470 | * @throws EE_Error |
||
471 | */ |
||
472 | public function set_additional_limit($limit) |
||
476 | |||
477 | |||
478 | /** |
||
479 | * @param $created |
||
480 | * @throws EE_Error |
||
481 | */ |
||
482 | public function set_created($created) |
||
486 | |||
487 | |||
488 | /** |
||
489 | * @param $desc |
||
490 | * @throws EE_Error |
||
491 | */ |
||
492 | public function set_description($desc) |
||
496 | |||
497 | |||
498 | /** |
||
499 | * @param $display_desc |
||
500 | * @throws EE_Error |
||
501 | */ |
||
502 | public function set_display_description($display_desc) |
||
506 | |||
507 | |||
508 | /** |
||
509 | * @param $display_ticket_selector |
||
510 | * @throws EE_Error |
||
511 | */ |
||
512 | public function set_display_ticket_selector($display_ticket_selector) |
||
516 | |||
517 | |||
518 | /** |
||
519 | * @param $external_url |
||
520 | * @throws EE_Error |
||
521 | */ |
||
522 | public function set_external_url($external_url) |
||
526 | |||
527 | |||
528 | /** |
||
529 | * @param $member_only |
||
530 | * @throws EE_Error |
||
531 | */ |
||
532 | public function set_member_only($member_only) |
||
536 | |||
537 | |||
538 | /** |
||
539 | * @param $event_phone |
||
540 | * @throws EE_Error |
||
541 | */ |
||
542 | public function set_event_phone($event_phone) |
||
546 | |||
547 | |||
548 | /** |
||
549 | * @param $modified |
||
550 | * @throws EE_Error |
||
551 | */ |
||
552 | public function set_modified($modified) |
||
556 | |||
557 | |||
558 | /** |
||
559 | * @param $name |
||
560 | * @throws EE_Error |
||
561 | */ |
||
562 | public function set_name($name) |
||
566 | |||
567 | |||
568 | /** |
||
569 | * @param $order |
||
570 | * @throws EE_Error |
||
571 | */ |
||
572 | public function set_order($order) |
||
576 | |||
577 | |||
578 | /** |
||
579 | * @param $short_desc |
||
580 | * @throws EE_Error |
||
581 | */ |
||
582 | public function set_short_description($short_desc) |
||
586 | |||
587 | |||
588 | /** |
||
589 | * @param $slug |
||
590 | * @throws EE_Error |
||
591 | */ |
||
592 | public function set_slug($slug) |
||
596 | |||
597 | |||
598 | /** |
||
599 | * @param $timezone_string |
||
600 | * @throws EE_Error |
||
601 | */ |
||
602 | public function set_timezone_string($timezone_string) |
||
606 | |||
607 | |||
608 | /** |
||
609 | * @param $visible_on |
||
610 | * @throws EE_Error |
||
611 | */ |
||
612 | public function set_visible_on($visible_on) |
||
616 | |||
617 | |||
618 | /** |
||
619 | * @param $wp_user |
||
620 | * @throws EE_Error |
||
621 | */ |
||
622 | public function set_wp_user($wp_user) |
||
626 | |||
627 | |||
628 | /** |
||
629 | * @param $default_registration_status |
||
630 | * @throws EE_Error |
||
631 | */ |
||
632 | public function set_default_registration_status($default_registration_status) |
||
636 | |||
637 | |||
638 | /** |
||
639 | * @param $donations |
||
640 | * @throws EE_Error |
||
641 | */ |
||
642 | public function set_donations($donations) |
||
646 | |||
647 | |||
648 | /** |
||
649 | * Adds a venue to this event |
||
650 | * |
||
651 | * @param EE_Venue /int $venue_id_or_obj |
||
652 | * @return EE_Base_Class|EE_Venue |
||
653 | * @throws EE_Error |
||
654 | */ |
||
655 | public function add_venue($venue_id_or_obj) |
||
659 | |||
660 | |||
661 | /** |
||
662 | * Removes a venue from the event |
||
663 | * |
||
664 | * @param EE_Venue /int $venue_id_or_obj |
||
665 | * @return EE_Base_Class|EE_Venue |
||
666 | * @throws EE_Error |
||
667 | */ |
||
668 | public function remove_venue($venue_id_or_obj) |
||
672 | |||
673 | |||
674 | /** |
||
675 | * Gets all the venues related ot the event. May provide additional $query_params if desired |
||
676 | * |
||
677 | * @param array $query_params like EEM_Base::get_all's $query_params |
||
678 | * @return EE_Base_Class[]|EE_Venue[] |
||
679 | * @throws EE_Error |
||
680 | */ |
||
681 | public function venues($query_params = array()) |
||
685 | |||
686 | |||
687 | /** |
||
688 | * check if event id is present and if event is published |
||
689 | * |
||
690 | * @access public |
||
691 | * @return boolean true yes, false no |
||
692 | * @throws EE_Error |
||
693 | */ |
||
694 | private function _has_ID_and_is_published() |
||
707 | |||
708 | |||
709 | /** |
||
710 | * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
||
711 | * |
||
712 | * @access public |
||
713 | * @return boolean true yes, false no |
||
714 | * @throws EE_Error |
||
715 | */ |
||
716 | View Code Duplication | public function is_upcoming() |
|
742 | |||
743 | |||
744 | /** |
||
745 | * @return bool |
||
746 | * @throws EE_Error |
||
747 | */ |
||
748 | View Code Duplication | public function is_active() |
|
774 | |||
775 | |||
776 | /** |
||
777 | * @return bool |
||
778 | * @throws EE_Error |
||
779 | */ |
||
780 | View Code Duplication | public function is_expired() |
|
802 | |||
803 | |||
804 | /** |
||
805 | * @return bool |
||
806 | * @throws EE_Error |
||
807 | */ |
||
808 | public function is_inactive() |
||
816 | |||
817 | |||
818 | /** |
||
819 | * calculate spaces remaining based on "saleable" tickets |
||
820 | * |
||
821 | * @param array $tickets |
||
822 | * @param bool $filtered |
||
823 | * @return int|float |
||
824 | * @throws EE_Error |
||
825 | */ |
||
826 | public function spaces_remaining($tickets = array(), $filtered = true) |
||
848 | |||
849 | |||
850 | /** |
||
851 | * perform_sold_out_status_check |
||
852 | * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces available... |
||
853 | * if NOT, then the event status will get toggled to 'sold_out' |
||
854 | * |
||
855 | * @access public |
||
856 | * @return bool return the ACTUAL sold out state. |
||
857 | * @throws EE_Error |
||
858 | */ |
||
859 | public function perform_sold_out_status_check() |
||
887 | |||
888 | |||
889 | /** |
||
890 | * This returns the total remaining spaces for sale on this event. |
||
891 | * ############################ |
||
892 | * VERY IMPORTANT FOR DEVELOPERS: |
||
893 | * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
||
894 | * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
||
895 | * ############################ |
||
896 | * |
||
897 | * @uses EE_Event::total_available_spaces() |
||
898 | * @return float|int (EE_INF is returned as float) |
||
899 | * @throws InvalidArgumentException |
||
900 | * @throws InvalidStatusException |
||
901 | * @throws EE_Error |
||
902 | */ |
||
903 | public function spaces_remaining_for_sale() |
||
916 | |||
917 | |||
918 | /** |
||
919 | * This returns the total spaces available for an event while considering all the qtys on the tickets and the reg limits |
||
920 | * on the datetimes attached to this event. |
||
921 | * ############################ |
||
922 | * VERY IMPORTANT FOR DEVELOPERS: |
||
923 | * While included here, this method is still being tested internally, so its signature and behaviour COULD change. While |
||
924 | * this comment block is in place, usage is at your own risk and know that it may change in future builds. |
||
925 | * ############################ |
||
926 | * Note: by "spaces available" we are not returning how many spaces remain. That is a calculation involving using the value |
||
927 | * from this method and subtracting the approved registrations for the event. |
||
928 | * |
||
929 | * @param bool $current_total_available Whether to consider any tickets that have already sold in our calculation. |
||
930 | * If this is false, then we return the most tickets that could ever be sold |
||
931 | * for this event with the datetime and tickets setup on the event under optimal |
||
932 | * selling conditions. Otherwise we return a live calculation of spaces available |
||
933 | * based on tickets sold. Depending on setup and stage of sales, this |
||
934 | * may appear to equal remaining tickets. However, the more tickets are |
||
935 | * sold out, the more accurate the "live" total is. |
||
936 | * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
||
937 | * @throws EE_Error |
||
938 | */ |
||
939 | public function total_available_spaces($current_total_available = false) |
||
1064 | |||
1065 | |||
1066 | /** |
||
1067 | * Checks if the event is set to sold out |
||
1068 | * |
||
1069 | * @param bool $actual whether or not to perform calculations to not only figure the |
||
1070 | * actual status but also to flip the status if necessary to sold |
||
1071 | * out If false, we just check the existing status of the event |
||
1072 | * @return boolean |
||
1073 | * @throws EE_Error |
||
1074 | */ |
||
1075 | public function is_sold_out($actual = false) |
||
1082 | |||
1083 | |||
1084 | /** |
||
1085 | * Checks if the event is marked as postponed |
||
1086 | * |
||
1087 | * @return boolean |
||
1088 | */ |
||
1089 | public function is_postponed() |
||
1093 | |||
1094 | |||
1095 | /** |
||
1096 | * Checks if the event is marked as cancelled |
||
1097 | * |
||
1098 | * @return boolean |
||
1099 | */ |
||
1100 | public function is_cancelled() |
||
1104 | |||
1105 | |||
1106 | /** |
||
1107 | * Get the logical active status in a hierarchical order for all the datetimes. Note |
||
1108 | * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
||
1109 | * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
||
1110 | * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
||
1111 | * the event is considered expired. |
||
1112 | * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a status |
||
1113 | * set on the EVENT when it is not published and thus is done |
||
1114 | * |
||
1115 | * @param bool $reset |
||
1116 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
||
1117 | * @throws EE_Error |
||
1118 | */ |
||
1119 | public function get_active_status($reset = false) |
||
1170 | |||
1171 | |||
1172 | /** |
||
1173 | * pretty_active_status |
||
1174 | * |
||
1175 | * @access public |
||
1176 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
||
1177 | * @return mixed void|string |
||
1178 | * @throws EE_Error |
||
1179 | */ |
||
1180 | public function pretty_active_status($echo = true) |
||
1194 | |||
1195 | |||
1196 | /** |
||
1197 | * @return bool|int |
||
1198 | * @throws EE_Error |
||
1199 | */ |
||
1200 | public function get_number_of_tickets_sold() |
||
1214 | |||
1215 | |||
1216 | /** |
||
1217 | * This just returns a count of all the registrations for this event |
||
1218 | * |
||
1219 | * @access public |
||
1220 | * @return int |
||
1221 | * @throws EE_Error |
||
1222 | */ |
||
1223 | public function get_count_of_all_registrations() |
||
1227 | |||
1228 | |||
1229 | /** |
||
1230 | * This returns the ticket with the earliest start time that is |
||
1231 | * available for this event (across all datetimes attached to the event) |
||
1232 | * |
||
1233 | * @return EE_Base_Class|EE_Ticket|null |
||
1234 | * @throws EE_Error |
||
1235 | */ |
||
1236 | public function get_ticket_with_earliest_start_time() |
||
1242 | |||
1243 | |||
1244 | /** |
||
1245 | * This returns the ticket with the latest end time that is available |
||
1246 | * for this event (across all datetimes attached to the event) |
||
1247 | * |
||
1248 | * @return EE_Base_Class|EE_Ticket|null |
||
1249 | * @throws EE_Error |
||
1250 | */ |
||
1251 | public function get_ticket_with_latest_end_time() |
||
1257 | |||
1258 | |||
1259 | /** |
||
1260 | * This returns whether there are any tickets on sale for this event. |
||
1261 | * |
||
1262 | * @return bool true = YES tickets on sale. |
||
1263 | * @throws EE_Error |
||
1264 | */ |
||
1265 | public function tickets_on_sale() |
||
1278 | |||
1279 | |||
1280 | /** |
||
1281 | * Gets the URL for viewing this event on the front-end. Overrides parent |
||
1282 | * to check for an external URL first |
||
1283 | * |
||
1284 | * @return string |
||
1285 | * @throws EE_Error |
||
1286 | */ |
||
1287 | public function get_permalink() |
||
1294 | |||
1295 | |||
1296 | /** |
||
1297 | * Gets the first term for 'espresso_event_categories' we can find |
||
1298 | * |
||
1299 | * @param array $query_params like EEM_Base::get_all |
||
1300 | * @return EE_Base_Class|EE_Term|null |
||
1301 | * @throws EE_Error |
||
1302 | */ |
||
1303 | public function first_event_category($query_params = array()) |
||
1309 | |||
1310 | |||
1311 | /** |
||
1312 | * Gets all terms for 'espresso_event_categories' we can find |
||
1313 | * |
||
1314 | * @param array $query_params |
||
1315 | * @return EE_Base_Class[]|EE_Term[] |
||
1316 | * @throws EE_Error |
||
1317 | */ |
||
1318 | public function get_all_event_categories($query_params = array()) |
||
1324 | |||
1325 | |||
1326 | /** |
||
1327 | * Gets all the question groups, ordering them by QSG_order ascending |
||
1328 | * |
||
1329 | * @param array $query_params @see EEM_Base::get_all |
||
1330 | * @return EE_Base_Class[]|EE_Question_Group[] |
||
1331 | * @throws EE_Error |
||
1332 | */ |
||
1333 | public function question_groups($query_params = array()) |
||
1338 | |||
1339 | |||
1340 | /** |
||
1341 | * Implementation for EEI_Has_Icon interface method. |
||
1342 | * |
||
1343 | * @see EEI_Visual_Representation for comments |
||
1344 | * @return string |
||
1345 | */ |
||
1346 | public function get_icon() |
||
1350 | |||
1351 | |||
1352 | /** |
||
1353 | * Implementation for EEI_Admin_Links interface method. |
||
1354 | * |
||
1355 | * @see EEI_Admin_Links for comments |
||
1356 | * @return string |
||
1357 | * @throws EE_Error |
||
1358 | */ |
||
1359 | public function get_admin_details_link() |
||
1363 | |||
1364 | |||
1365 | /** |
||
1366 | * Implementation for EEI_Admin_Links interface method. |
||
1367 | * |
||
1368 | * @see EEI_Admin_Links for comments |
||
1369 | * @return string |
||
1370 | * @throws EE_Error |
||
1371 | */ |
||
1372 | public function get_admin_edit_link() |
||
1382 | |||
1383 | |||
1384 | /** |
||
1385 | * Implementation for EEI_Admin_Links interface method. |
||
1386 | * |
||
1387 | * @see EEI_Admin_Links for comments |
||
1388 | * @return string |
||
1389 | */ |
||
1390 | public function get_admin_settings_link() |
||
1399 | |||
1400 | |||
1401 | /** |
||
1402 | * Implementation for EEI_Admin_Links interface method. |
||
1403 | * |
||
1404 | * @see EEI_Admin_Links for comments |
||
1405 | * @return string |
||
1406 | */ |
||
1407 | public function get_admin_overview_link() |
||
1416 | |||
1417 | } |
||
1418 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.