@@ -53,7 +53,7 @@ |
||
53 | 53 | 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
54 | 54 | 'event_espresso' |
55 | 55 | ), |
56 | - '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
56 | + '<img src="'.admin_url('images/media-button-image.gif').'">' |
|
57 | 57 | ); |
58 | 58 | ?> |
59 | 59 | </li> |
@@ -12,62 +12,62 @@ discard block |
||
12 | 12 | <strong><?php esc_html_e('Name', 'event_espresso'); ?></strong> |
13 | 13 | <br> |
14 | 14 | <?php esc_html_e( |
15 | - 'The name of the payment method as customers see it in the registration form, in emails, in receipts, etc.', |
|
16 | - 'event_espresso' |
|
17 | - ); ?> |
|
15 | + 'The name of the payment method as customers see it in the registration form, in emails, in receipts, etc.', |
|
16 | + 'event_espresso' |
|
17 | + ); ?> |
|
18 | 18 | </li> |
19 | 19 | <li> |
20 | 20 | <strong><?php esc_html_e('Description', 'event_espresso'); ?></strong> |
21 | 21 | <br /> |
22 | 22 | <?php esc_html_e( |
23 | - 'The description of how to use the payment method as customers will see it. This is mostly only seen during registration.', |
|
24 | - 'event_espresso' |
|
25 | - ); ?> |
|
23 | + 'The description of how to use the payment method as customers will see it. This is mostly only seen during registration.', |
|
24 | + 'event_espresso' |
|
25 | + ); ?> |
|
26 | 26 | </li> |
27 | 27 | <li> |
28 | 28 | <strong><?php esc_html_e('Admin-Only Name', 'event_espresso'); ?></strong> |
29 | 29 | <br /> |
30 | 30 | <?php esc_html_e( |
31 | - 'The name of the payment method as seen internally by site administrators and staff.', |
|
32 | - 'event_espresso' |
|
33 | - ); ?> |
|
31 | + 'The name of the payment method as seen internally by site administrators and staff.', |
|
32 | + 'event_espresso' |
|
33 | + ); ?> |
|
34 | 34 | </li> |
35 | 35 | <li> |
36 | 36 | <strong><?php esc_html_e('Admin-Only Description', 'event_espresso'); ?></strong> |
37 | 37 | <br /> |
38 | 38 | <?php esc_html_e( |
39 | - 'The description of the payment method as seen internally by site administrators and staff.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?> |
|
39 | + 'The description of the payment method as seen internally by site administrators and staff.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?> |
|
42 | 42 | </li> |
43 | 43 | <li> |
44 | 44 | <strong><?php esc_html_e('Debug (sandbox) Mode', 'event_espresso'); ?></strong> |
45 | 45 | <br /> |
46 | 46 | <?php esc_html_e( |
47 | - 'Many payment methods have a debug/sandbox mode where payments are not processed but are only simulated. This is helpful when setup and debugging.', |
|
48 | - 'event_espresso' |
|
49 | - ); ?> |
|
47 | + 'Many payment methods have a debug/sandbox mode where payments are not processed but are only simulated. This is helpful when setup and debugging.', |
|
48 | + 'event_espresso' |
|
49 | + ); ?> |
|
50 | 50 | </li> |
51 | 51 | <li> |
52 | 52 | <strong><?php esc_html_e('Open by Default', 'event_espresso'); ?></strong> |
53 | 53 | <br /> |
54 | 54 | <?php esc_html_e( |
55 | - 'If checked, this payment method will be selected by default (assuming no other valid payment methods are also marked as open by default.)', |
|
56 | - 'event_espresso' |
|
57 | - ); ?> |
|
55 | + 'If checked, this payment method will be selected by default (assuming no other valid payment methods are also marked as open by default.)', |
|
56 | + 'event_espresso' |
|
57 | + ); ?> |
|
58 | 58 | </li> |
59 | 59 | <li> |
60 | 60 | <strong><?php esc_html_e('Button URL', 'event_espresso'); ?></strong> |
61 | 61 | <br /> |
62 | 62 | <?php |
63 | - printf( |
|
64 | - esc_html__( |
|
65 | - 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
69 | - ); |
|
70 | - ?> |
|
63 | + printf( |
|
64 | + esc_html__( |
|
65 | + 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
69 | + ); |
|
70 | + ?> |
|
71 | 71 | </li> |
72 | 72 | <li> |
73 | 73 | <strong><?php esc_html_e('Usable From', 'event_espresso'); ?></strong> |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | <ul> |
77 | 77 | <li> |
78 | 78 | <?php esc_html_e( |
79 | - 'Front-end Registration Page: the payment method will appear as an option during the normal registration process to customers and they can use it to process payments.', |
|
80 | - 'event_espresso' |
|
81 | - ); ?> |
|
79 | + 'Front-end Registration Page: the payment method will appear as an option during the normal registration process to customers and they can use it to process payments.', |
|
80 | + 'event_espresso' |
|
81 | + ); ?> |
|
82 | 82 | </li> |
83 | 83 | <li> |
84 | 84 | <?php esc_html_e( |
85 | - 'Admin Registration Page: when recording payments made from the transaction admin page, the payment method will appear as an option. Note: currently payments can only be RECORDED from the admin, they cannot be PROCESSED.', |
|
86 | - 'event_espresso' |
|
87 | - ); ?> |
|
85 | + 'Admin Registration Page: when recording payments made from the transaction admin page, the payment method will appear as an option. Note: currently payments can only be RECORDED from the admin, they cannot be PROCESSED.', |
|
86 | + 'event_espresso' |
|
87 | + ); ?> |
|
88 | 88 | </li> |
89 | 89 | </ul> |
90 | 90 | </li> |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
93 | 93 | <br /> |
94 | 94 | <?php esc_html_e( |
95 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
96 | - 'event_espresso' |
|
95 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
96 | + 'event_espresso' |
|
97 | 97 | ); ?> |
98 | 98 | <p> |
99 | 99 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
100 | 100 | <br /> |
101 | 101 | <?php esc_html_e( |
102 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
103 | - 'event_espresso' |
|
104 | - ); ?> |
|
102 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
103 | + 'event_espresso' |
|
104 | + ); ?> |
|
105 | 105 | </p> |
@@ -8,31 +8,31 @@ |
||
8 | 8 | |
9 | 9 | class SitePermissions extends JsonDataNode |
10 | 10 | { |
11 | - const NODE_NAME = 'sitePermissions'; |
|
12 | - |
|
13 | - /** |
|
14 | - * @var FeatureFlags |
|
15 | - */ |
|
16 | - private $feature_flags; |
|
17 | - |
|
18 | - |
|
19 | - /** |
|
20 | - * @param FeatureFlags $feature_flags |
|
21 | - * @param JsonDataNodeValidator $validator |
|
22 | - */ |
|
23 | - public function __construct(FeatureFlags $feature_flags, JsonDataNodeValidator $validator) |
|
24 | - { |
|
25 | - $this->feature_flags = $feature_flags; |
|
26 | - parent::__construct($validator); |
|
27 | - $this->setNodeName(SitePermissions::NODE_NAME); |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @inheritDoc |
|
33 | - */ |
|
34 | - public function initialize() |
|
35 | - { |
|
36 | - $this->setDataArray($this->feature_flags->getAllowedFeatures()); |
|
37 | - } |
|
11 | + const NODE_NAME = 'sitePermissions'; |
|
12 | + |
|
13 | + /** |
|
14 | + * @var FeatureFlags |
|
15 | + */ |
|
16 | + private $feature_flags; |
|
17 | + |
|
18 | + |
|
19 | + /** |
|
20 | + * @param FeatureFlags $feature_flags |
|
21 | + * @param JsonDataNodeValidator $validator |
|
22 | + */ |
|
23 | + public function __construct(FeatureFlags $feature_flags, JsonDataNodeValidator $validator) |
|
24 | + { |
|
25 | + $this->feature_flags = $feature_flags; |
|
26 | + parent::__construct($validator); |
|
27 | + $this->setNodeName(SitePermissions::NODE_NAME); |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @inheritDoc |
|
33 | + */ |
|
34 | + public function initialize() |
|
35 | + { |
|
36 | + $this->setDataArray($this->feature_flags->getAllowedFeatures()); |
|
37 | + } |
|
38 | 38 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ), |
122 | 122 | ], |
123 | 123 | ]; |
124 | - $this->_model_relations = [ |
|
124 | + $this->_model_relations = [ |
|
125 | 125 | 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
126 | 126 | 'Event' => new EE_Belongs_To_Relation(), |
127 | 127 | 'Checkin' => new EE_Has_Many_Relation(), |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | $this->model_chain_to_password = $path_to_event_model; |
132 | 132 | $this->_model_chain_to_wp_user = $path_to_event_model; |
133 | 133 | // this model is generally available for reading |
134 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = |
|
134 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = |
|
135 | 135 | new EE_Restriction_Generator_Event_Related_Public( |
136 | 136 | $path_to_event_model |
137 | 137 | ); |
138 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
138 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = |
|
139 | 139 | new EE_Restriction_Generator_Event_Related_Protected( |
140 | 140 | $path_to_event_model |
141 | 141 | ); |
142 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = |
|
142 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = |
|
143 | 143 | new EE_Restriction_Generator_Event_Related_Protected( |
144 | 144 | $path_to_event_model |
145 | 145 | ); |
146 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
146 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = |
|
147 | 147 | new EE_Restriction_Generator_Event_Related_Protected( |
148 | 148 | $path_to_event_model, |
149 | 149 | EEM_Base::caps_edit |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @param int $end_data Unix timestamp representing now + 30 days in seconds. |
186 | 186 | * @return int Unix timestamp |
187 | 187 | */ |
188 | - $end_date = apply_filters( |
|
188 | + $end_date = apply_filters( |
|
189 | 189 | 'FHEE__EEM_Datetime__create_new_blank_datetime__end_date', |
190 | 190 | $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS |
191 | 191 | ); |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | */ |
252 | 252 | private function validateStartAndEndTimeForBlankDate(array $start_time, array $end_time) |
253 | 253 | { |
254 | - if (! is_array($start_time)) { |
|
254 | + if ( ! is_array($start_time)) { |
|
255 | 255 | throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
256 | 256 | } |
257 | - if (! is_array($end_time)) { |
|
257 | + if ( ! is_array($end_time)) { |
|
258 | 258 | throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
259 | 259 | } |
260 | 260 | if (count($start_time) !== 2) { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function get_all_event_dates($EVT_ID = 0) |
291 | 291 | { |
292 | - if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
292 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
293 | 293 | return $this->create_new_blank_datetime(); |
294 | 294 | } |
295 | 295 | $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $query_params, |
427 | 427 | EEM_Base::default_where_conditions_this_only |
428 | 428 | ); |
429 | - $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
429 | + $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
430 | 430 | return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
431 | 431 | } |
432 | 432 | |
@@ -587,14 +587,14 @@ discard block |
||
587 | 587 | $query_params['group_by'] = ['dtt_year', 'dtt_month']; |
588 | 588 | $query_params = $this->addOrderByQueryParams($query_params, 'DTT_EVT_start', 'DESC'); |
589 | 589 | |
590 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
590 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
591 | 591 | $this->get_timezone(), |
592 | 592 | 'DTT_EVT_start' |
593 | 593 | ); |
594 | 594 | $columns_to_select = [ |
595 | - 'dtt_year' => ['YEAR(' . $query_interval . ')', '%s'], |
|
596 | - 'dtt_month' => ['MONTHNAME(' . $query_interval . ')', '%s'], |
|
597 | - 'dtt_month_num' => ['MONTH(' . $query_interval . ')', '%s'], |
|
595 | + 'dtt_year' => ['YEAR('.$query_interval.')', '%s'], |
|
596 | + 'dtt_month' => ['MONTHNAME('.$query_interval.')', '%s'], |
|
597 | + 'dtt_month_num' => ['MONTH('.$query_interval.')', '%s'], |
|
598 | 598 | ]; |
599 | 599 | return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
600 | 600 | } |
@@ -676,17 +676,17 @@ discard block |
||
676 | 676 | ['DTT_EVT_end' => ['<', time()]] |
677 | 677 | ), |
678 | 678 | ]; |
679 | - if (! empty($stati_to_include)) { |
|
679 | + if ( ! empty($stati_to_include)) { |
|
680 | 680 | foreach (array_keys($status_query_args) as $status) { |
681 | - if (! in_array($status, $stati_to_include, true)) { |
|
682 | - unset($status_query_args[ $status ]); |
|
681 | + if ( ! in_array($status, $stati_to_include, true)) { |
|
682 | + unset($status_query_args[$status]); |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | } |
686 | 686 | // loop through and query counts for each stati. |
687 | 687 | $status_query_results = []; |
688 | 688 | foreach ($status_query_args as $status => $status_where_conditions) { |
689 | - $status_query_results[ $status ] = EEM_Datetime::count( |
|
689 | + $status_query_results[$status] = EEM_Datetime::count( |
|
690 | 690 | [$status_where_conditions], |
691 | 691 | 'DTT_ID', |
692 | 692 | true |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = []) |
708 | 708 | { |
709 | 709 | $count = $this->get_datetime_counts_by_status([$status], $query_params); |
710 | - return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
710 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | */ |
807 | 807 | private function addExpiredWhereParams(array $where_params, bool $include_expired = true) |
808 | 808 | { |
809 | - if (! $include_expired) { |
|
809 | + if ( ! $include_expired) { |
|
810 | 810 | $where_params['DTT_EVT_end'] = ['>=', current_time('mysql', true)]; |
811 | 811 | } |
812 | 812 | return $where_params; |
@@ -16,840 +16,840 @@ |
||
16 | 16 | */ |
17 | 17 | class EEM_Datetime extends EEM_Soft_Delete_Base |
18 | 18 | { |
19 | - protected static ?EEM_Datetime $_instance = null; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * private constructor to prevent direct creation |
|
24 | - * |
|
25 | - * @param string|null $timezone A string representing the timezone we want to set for returned Date Time Strings |
|
26 | - * (and any incoming timezone data that gets saved). |
|
27 | - * Note this just sends the timezone info to the date time model field objects. |
|
28 | - * Default is NULL |
|
29 | - * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
30 | - * @throws EE_Error |
|
31 | - */ |
|
32 | - protected function __construct(?string $timezone = '') |
|
33 | - { |
|
34 | - $this->singular_item = esc_html__('Datetime', 'event_espresso'); |
|
35 | - $this->plural_item = esc_html__('Datetimes', 'event_espresso'); |
|
36 | - $this->_tables = [ |
|
37 | - 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
38 | - ]; |
|
39 | - $this->_fields = [ |
|
40 | - 'Datetime' => [ |
|
41 | - 'DTT_ID' => new EE_Primary_Key_Int_Field( |
|
42 | - 'DTT_ID', |
|
43 | - esc_html__('Datetime ID', 'event_espresso') |
|
44 | - ), |
|
45 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
46 | - 'EVT_ID', |
|
47 | - esc_html__('Event ID', 'event_espresso'), |
|
48 | - false, |
|
49 | - 0, |
|
50 | - 'Event' |
|
51 | - ), |
|
52 | - 'VNU_ID' => new EE_Foreign_Key_Int_Field( |
|
53 | - 'VNU_ID', |
|
54 | - __('Venue ID', 'event_espresso'), |
|
55 | - false, |
|
56 | - 0, |
|
57 | - 'Venue' |
|
58 | - ), |
|
59 | - 'DTT_name' => new EE_Plain_Text_Field( |
|
60 | - 'DTT_name', |
|
61 | - esc_html__('Datetime Name', 'event_espresso'), |
|
62 | - false, |
|
63 | - '' |
|
64 | - ), |
|
65 | - 'DTT_description' => new EE_Post_Content_Field( |
|
66 | - 'DTT_description', |
|
67 | - esc_html__('Description for Datetime', 'event_espresso'), |
|
68 | - false, |
|
69 | - '' |
|
70 | - ), |
|
71 | - 'DTT_EVT_start' => new EE_Datetime_Field( |
|
72 | - 'DTT_EVT_start', |
|
73 | - esc_html__('Start time/date of Event', 'event_espresso'), |
|
74 | - false, |
|
75 | - EE_Datetime_Field::now, |
|
76 | - $timezone |
|
77 | - ), |
|
78 | - 'DTT_EVT_end' => new EE_Datetime_Field( |
|
79 | - 'DTT_EVT_end', |
|
80 | - esc_html__('End time/date of Event', 'event_espresso'), |
|
81 | - false, |
|
82 | - EE_Datetime_Field::now, |
|
83 | - $timezone |
|
84 | - ), |
|
85 | - 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
86 | - 'DTT_reg_limit', |
|
87 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
88 | - false, |
|
89 | - EE_INF |
|
90 | - ), |
|
91 | - 'DTT_sold' => new EE_Integer_Field( |
|
92 | - 'DTT_sold', |
|
93 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
94 | - false, |
|
95 | - 0 |
|
96 | - ), |
|
97 | - 'DTT_reserved' => new EE_Integer_Field( |
|
98 | - 'DTT_reserved', |
|
99 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
100 | - false, |
|
101 | - 0 |
|
102 | - ), |
|
103 | - 'DTT_is_primary' => new EE_Boolean_Field( |
|
104 | - 'DTT_is_primary', |
|
105 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
106 | - false, |
|
107 | - false |
|
108 | - ), |
|
109 | - 'DTT_order' => new EE_Integer_Field( |
|
110 | - 'DTT_order', |
|
111 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso'), |
|
112 | - false, |
|
113 | - 0 |
|
114 | - ), |
|
115 | - 'DTT_parent' => new EE_Integer_Field( |
|
116 | - 'DTT_parent', |
|
117 | - esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'), |
|
118 | - true, |
|
119 | - 0 |
|
120 | - ), |
|
121 | - 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
122 | - 'DTT_deleted', |
|
123 | - esc_html__('Flag indicating datetime is archived', 'event_espresso'), |
|
124 | - false, |
|
125 | - false |
|
126 | - ), |
|
127 | - ], |
|
128 | - ]; |
|
129 | - $this->_model_relations = [ |
|
130 | - 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
131 | - 'Event' => new EE_Belongs_To_Relation(), |
|
132 | - 'Checkin' => new EE_Has_Many_Relation(), |
|
133 | - 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
134 | - 'Venue' => new EE_Belongs_To_Relation(), |
|
135 | - ]; |
|
136 | - $path_to_event_model = 'Event'; |
|
137 | - $this->model_chain_to_password = $path_to_event_model; |
|
138 | - $this->_model_chain_to_wp_user = $path_to_event_model; |
|
139 | - // this model is generally available for reading |
|
140 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = |
|
141 | - new EE_Restriction_Generator_Event_Related_Public( |
|
142 | - $path_to_event_model |
|
143 | - ); |
|
144 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
145 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
146 | - $path_to_event_model |
|
147 | - ); |
|
148 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = |
|
149 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
150 | - $path_to_event_model |
|
151 | - ); |
|
152 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
153 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
154 | - $path_to_event_model, |
|
155 | - EEM_Base::caps_edit |
|
156 | - ); |
|
157 | - parent::__construct($timezone); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * create new blank datetime |
|
163 | - * |
|
164 | - * @access public |
|
165 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
166 | - * @throws EE_Error |
|
167 | - * @throws InvalidArgumentException |
|
168 | - * @throws InvalidDataTypeException |
|
169 | - * @throws ReflectionException |
|
170 | - * @throws InvalidInterfaceException |
|
171 | - */ |
|
172 | - public function create_new_blank_datetime() |
|
173 | - { |
|
174 | - // makes sure timezone is always set. |
|
175 | - $timezone_string = $this->get_timezone(); |
|
176 | - /** |
|
177 | - * Filters the initial start date for the new datetime. |
|
178 | - * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
179 | - * |
|
180 | - * @param int $start_date Unix timestamp representing now + 30 days in seconds. |
|
181 | - * @return int Unix timestamp |
|
182 | - */ |
|
183 | - $start_date = apply_filters( |
|
184 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__start_date', |
|
185 | - $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS |
|
186 | - ); |
|
187 | - /** |
|
188 | - * Filters the initial end date for the new datetime. |
|
189 | - * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
190 | - * |
|
191 | - * @param int $end_data Unix timestamp representing now + 30 days in seconds. |
|
192 | - * @return int Unix timestamp |
|
193 | - */ |
|
194 | - $end_date = apply_filters( |
|
195 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__end_date', |
|
196 | - $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS |
|
197 | - ); |
|
198 | - $blank_datetime = EE_Datetime::new_instance( |
|
199 | - [ |
|
200 | - 'DTT_EVT_start' => $start_date, |
|
201 | - 'DTT_EVT_end' => $end_date, |
|
202 | - 'DTT_order' => 1, |
|
203 | - 'DTT_reg_limit' => EE_INF_IN_DB, |
|
204 | - ], |
|
205 | - $timezone_string |
|
206 | - ); |
|
207 | - /** |
|
208 | - * Filters the initial start time and format for the new EE_Datetime instance. |
|
209 | - * |
|
210 | - * @param array $start_time An array having size 2. First element is the time, second element is the time |
|
211 | - * format. |
|
212 | - * @return array |
|
213 | - */ |
|
214 | - $start_time = apply_filters( |
|
215 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__start_time', |
|
216 | - ['8am', 'ga'] |
|
217 | - ); |
|
218 | - /** |
|
219 | - * Filters the initial end time and format for the new EE_Datetime instance. |
|
220 | - * |
|
221 | - * @param array $end_time An array having size 2. First element is the time, second element is the time |
|
222 | - * format |
|
223 | - * @return array |
|
224 | - */ |
|
225 | - $end_time = apply_filters( |
|
226 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__end_time', |
|
227 | - ['5pm', 'ga'] |
|
228 | - ); |
|
229 | - $this->validateStartAndEndTimeForBlankDate($start_time, $end_time); |
|
230 | - $blank_datetime->set_start_time( |
|
231 | - $this->convert_datetime_for_query( |
|
232 | - 'DTT_EVT_start', |
|
233 | - $start_time[0], |
|
234 | - $start_time[1], |
|
235 | - $timezone_string |
|
236 | - ) |
|
237 | - ); |
|
238 | - $blank_datetime->set_end_time( |
|
239 | - $this->convert_datetime_for_query( |
|
240 | - 'DTT_EVT_end', |
|
241 | - $end_time[0], |
|
242 | - $end_time[1], |
|
243 | - $timezone_string |
|
244 | - ) |
|
245 | - ); |
|
246 | - return [$blank_datetime]; |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * Validates whether the start_time and end_time are in the expected format. |
|
252 | - * |
|
253 | - * @param array $start_time |
|
254 | - * @param array $end_time |
|
255 | - * @throws InvalidArgumentException |
|
256 | - * @throws InvalidDataTypeException |
|
257 | - */ |
|
258 | - private function validateStartAndEndTimeForBlankDate(array $start_time, array $end_time) |
|
259 | - { |
|
260 | - if (! is_array($start_time)) { |
|
261 | - throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
|
262 | - } |
|
263 | - if (! is_array($end_time)) { |
|
264 | - throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
|
265 | - } |
|
266 | - if (count($start_time) !== 2) { |
|
267 | - throw new InvalidArgumentException( |
|
268 | - sprintf( |
|
269 | - 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
270 | - . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
271 | - '$start_time' |
|
272 | - ) |
|
273 | - ); |
|
274 | - } |
|
275 | - if (count($end_time) !== 2) { |
|
276 | - throw new InvalidArgumentException( |
|
277 | - sprintf( |
|
278 | - 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
279 | - . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
280 | - '$end_time' |
|
281 | - ) |
|
282 | - ); |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * get event start date from db |
|
289 | - * |
|
290 | - * @access public |
|
291 | - * @param int $EVT_ID |
|
292 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
293 | - * @throws EE_Error |
|
294 | - * @throws ReflectionException |
|
295 | - */ |
|
296 | - public function get_all_event_dates($EVT_ID = 0) |
|
297 | - { |
|
298 | - if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
299 | - return $this->create_new_blank_datetime(); |
|
300 | - } |
|
301 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
302 | - if (empty($results)) { |
|
303 | - return $this->create_new_blank_datetime(); |
|
304 | - } |
|
305 | - return $results; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * get all datetimes attached to an event ordered by the DTT_order field |
|
311 | - * |
|
312 | - * @public |
|
313 | - * @param int $EVT_ID event id |
|
314 | - * @param boolean $include_expired |
|
315 | - * @param boolean $include_deleted |
|
316 | - * @param int $limit If included then limit the count of results by |
|
317 | - * the given number |
|
318 | - * @return EE_Datetime[] |
|
319 | - * @throws EE_Error |
|
320 | - */ |
|
321 | - public function get_datetimes_for_event_ordered_by_DTT_order( |
|
322 | - int $EVT_ID, |
|
323 | - bool $include_expired = true, |
|
324 | - bool $include_deleted = true, |
|
325 | - $limit = 0 |
|
326 | - ) { |
|
327 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
328 | - $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
329 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
330 | - $query_params = $this->addDefaultWhereConditions($query_params); |
|
331 | - $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
332 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * Gets the datetimes for the event (with the given limit), and orders them by "importance". |
|
338 | - * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW), |
|
339 | - * and then the earlier datetimes are the most important. |
|
340 | - * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
341 | - * |
|
342 | - * @param int $EVT_ID |
|
343 | - * @param int $limit |
|
344 | - * @return EE_Datetime[]|EE_Base_Class[] |
|
345 | - * @throws EE_Error |
|
346 | - */ |
|
347 | - public function get_datetimes_for_event_ordered_by_importance(int $EVT_ID, $limit = 0) |
|
348 | - { |
|
349 | - $query_params[0] = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
350 | - $query_params = $this->addDefaultWhereConditions($query_params); |
|
351 | - $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
352 | - return $this->get_all($query_params); |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * @param int $EVT_ID |
|
358 | - * @param boolean $include_expired |
|
359 | - * @param boolean $include_deleted |
|
360 | - * @return EE_Datetime |
|
361 | - * @throws EE_Error |
|
362 | - */ |
|
363 | - public function get_oldest_datetime_for_event( |
|
364 | - int $EVT_ID, |
|
365 | - bool $include_expired = false, |
|
366 | - bool $include_deleted = false |
|
367 | - ) { |
|
368 | - $results = $this->get_datetimes_for_event_ordered_by_start_time( |
|
369 | - $EVT_ID, |
|
370 | - $include_expired, |
|
371 | - $include_deleted, |
|
372 | - 1 |
|
373 | - ); |
|
374 | - if ($results) { |
|
375 | - return array_shift($results); |
|
376 | - } |
|
377 | - return null; |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - /** |
|
382 | - * Gets the 'primary' datetime for an event. |
|
383 | - * |
|
384 | - * @param int $EVT_ID |
|
385 | - * @param bool $try_to_exclude_expired |
|
386 | - * @param bool $try_to_exclude_deleted |
|
387 | - * @return EE_Datetime |
|
388 | - * @throws EE_Error |
|
389 | - */ |
|
390 | - public function get_primary_datetime_for_event( |
|
391 | - int $EVT_ID, |
|
392 | - bool $try_to_exclude_expired = true, |
|
393 | - bool $try_to_exclude_deleted = true |
|
394 | - ) { |
|
395 | - if ($try_to_exclude_expired) { |
|
396 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
397 | - if ($non_expired) { |
|
398 | - return $non_expired; |
|
399 | - } |
|
400 | - } |
|
401 | - if ($try_to_exclude_deleted) { |
|
402 | - $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
403 | - if ($expired_even) { |
|
404 | - return $expired_even; |
|
405 | - } |
|
406 | - } |
|
407 | - return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
413 | - * only by start date |
|
414 | - * |
|
415 | - * @param int $EVT_ID |
|
416 | - * @param boolean $include_expired |
|
417 | - * @param boolean $include_deleted |
|
418 | - * @param int $limit |
|
419 | - * @return EE_Datetime[] |
|
420 | - * @throws EE_Error |
|
421 | - */ |
|
422 | - public function get_datetimes_for_event_ordered_by_start_time( |
|
423 | - int $EVT_ID, |
|
424 | - bool $include_expired = true, |
|
425 | - bool $include_deleted = true, |
|
426 | - $limit = 0 |
|
427 | - ) { |
|
428 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
429 | - $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
430 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
431 | - $query_params = $this->addDefaultWhereConditions( |
|
432 | - $query_params, |
|
433 | - EEM_Base::default_where_conditions_this_only |
|
434 | - ); |
|
435 | - $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
436 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
442 | - * only by start date |
|
443 | - * |
|
444 | - * @param int $TKT_ID |
|
445 | - * @param boolean $include_expired |
|
446 | - * @param boolean $include_deleted |
|
447 | - * @param int $limit |
|
448 | - * @return EE_Datetime[] |
|
449 | - * @throws EE_Error |
|
450 | - */ |
|
451 | - public function get_datetimes_for_ticket_ordered_by_start_time( |
|
452 | - int $TKT_ID, |
|
453 | - bool $include_expired = true, |
|
454 | - bool $include_deleted = true, |
|
455 | - $limit = 0 |
|
456 | - ) { |
|
457 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
458 | - $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
459 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
460 | - $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
461 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - /** |
|
466 | - * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
467 | - * datetimes. |
|
468 | - * |
|
469 | - * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
470 | - * @param boolean $include_expired whether to include expired datetimes or not |
|
471 | - * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
472 | - * @param int|null $limit if null, no limit, if int then limit results by |
|
473 | - * that number |
|
474 | - * @return EE_Datetime[] |
|
475 | - * @throws EE_Error |
|
476 | - */ |
|
477 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
478 | - int $TKT_ID, |
|
479 | - bool $include_expired = true, |
|
480 | - bool $include_deleted = true, |
|
481 | - $limit = 0 |
|
482 | - ) { |
|
483 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
484 | - $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
485 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
486 | - $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
487 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
488 | - } |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
493 | - * reason it doesn't exist, we consider the earliest event the most important) |
|
494 | - * |
|
495 | - * @param int $EVT_ID |
|
496 | - * @return EE_Datetime |
|
497 | - * @throws EE_Error |
|
498 | - */ |
|
499 | - public function get_most_important_datetime_for_event(int $EVT_ID) |
|
500 | - { |
|
501 | - $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
502 | - if ($results) { |
|
503 | - return array_shift($results); |
|
504 | - } |
|
505 | - return null; |
|
506 | - } |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
511 | - * grouped by month and year. |
|
512 | - * |
|
513 | - * @param array $where_params @see |
|
514 | - * https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
515 | - * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
516 | - * Can be: |
|
517 | - * - '' = no filter |
|
518 | - * - upcoming = Published events with at least one upcoming datetime. |
|
519 | - * - expired = Events with all datetimes expired. |
|
520 | - * - active = Events that are published and have at least one datetime that |
|
521 | - * starts before now and ends after now. |
|
522 | - * - inactive = Events that are either not published. |
|
523 | - * @return stdClass[] |
|
524 | - * @throws EE_Error |
|
525 | - * @throws InvalidArgumentException |
|
526 | - * @throws InvalidArgumentException |
|
527 | - */ |
|
528 | - public function get_dtt_months_and_years(array $where_params, $evt_active_status = '') |
|
529 | - { |
|
530 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
531 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
532 | - switch ($evt_active_status) { |
|
533 | - case 'upcoming': |
|
534 | - $where_params['Event.status'] = 'publish'; |
|
535 | - // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
536 | - if (isset($where_params['DTT_EVT_start'])) { |
|
537 | - $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
538 | - } |
|
539 | - $where_params['DTT_EVT_start'] = ['>', $current_time_for_DTT_EVT_start]; |
|
540 | - break; |
|
541 | - case 'expired': |
|
542 | - if (isset($where_params['Event.status'])) { |
|
543 | - unset($where_params['Event.status']); |
|
544 | - } |
|
545 | - // get events to exclude |
|
546 | - $exclude_query[0] = array_merge( |
|
547 | - $where_params, |
|
548 | - ['DTT_EVT_end' => ['>', $current_time_for_DTT_EVT_end]] |
|
549 | - ); |
|
550 | - // first get all events that have datetimes where its not expired. |
|
551 | - $event_ids = $this->_get_all_wpdb_results( |
|
552 | - $exclude_query, |
|
553 | - OBJECT_K, |
|
554 | - 'Datetime.EVT_ID' |
|
555 | - ); |
|
556 | - $event_ids = array_keys($event_ids); |
|
557 | - if (isset($where_params['DTT_EVT_end'])) { |
|
558 | - $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
559 | - } |
|
560 | - $where_params['DTT_EVT_end'] = ['<', $current_time_for_DTT_EVT_end]; |
|
561 | - $where_params['Event.EVT_ID'] = ['NOT IN', $event_ids]; |
|
562 | - break; |
|
563 | - case 'active': |
|
564 | - $where_params['Event.status'] = 'publish'; |
|
565 | - if (isset($where_params['DTT_EVT_start'])) { |
|
566 | - $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
567 | - } |
|
568 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
569 | - $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
570 | - } |
|
571 | - $where_params['DTT_EVT_start'] = ['<', $current_time_for_DTT_EVT_start]; |
|
572 | - $where_params['DTT_EVT_end'] = ['>', $current_time_for_DTT_EVT_end]; |
|
573 | - break; |
|
574 | - case 'inactive': |
|
575 | - if (isset($where_params['Event.status'])) { |
|
576 | - unset($where_params['Event.status']); |
|
577 | - } |
|
578 | - if (isset($where_params['OR'])) { |
|
579 | - $where_params['AND']['OR'] = $where_params['OR']; |
|
580 | - } |
|
581 | - if (isset($where_params['DTT_EVT_end'])) { |
|
582 | - $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
583 | - unset($where_params['DTT_EVT_end']); |
|
584 | - } |
|
585 | - if (isset($where_params['DTT_EVT_start'])) { |
|
586 | - $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
587 | - unset($where_params['DTT_EVT_start']); |
|
588 | - } |
|
589 | - $where_params['AND']['Event.status'] = ['!=', 'publish']; |
|
590 | - break; |
|
591 | - } |
|
592 | - $query_params[0] = $where_params; |
|
593 | - $query_params['group_by'] = ['dtt_year', 'dtt_month']; |
|
594 | - $query_params = $this->addOrderByQueryParams($query_params, 'DTT_EVT_start', 'DESC'); |
|
595 | - |
|
596 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
597 | - $this->get_timezone(), |
|
598 | - 'DTT_EVT_start' |
|
599 | - ); |
|
600 | - $columns_to_select = [ |
|
601 | - 'dtt_year' => ['YEAR(' . $query_interval . ')', '%s'], |
|
602 | - 'dtt_month' => ['MONTHNAME(' . $query_interval . ')', '%s'], |
|
603 | - 'dtt_month_num' => ['MONTH(' . $query_interval . ')', '%s'], |
|
604 | - ]; |
|
605 | - return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
606 | - } |
|
607 | - |
|
608 | - |
|
609 | - /** |
|
610 | - * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
611 | - * for the tickets for each datetime) |
|
612 | - * |
|
613 | - * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
614 | - * @throws EE_Error |
|
615 | - * @throws ReflectionException |
|
616 | - */ |
|
617 | - public function update_sold(array $datetimes) |
|
618 | - { |
|
619 | - EE_Error::doing_it_wrong( |
|
620 | - __FUNCTION__, |
|
621 | - esc_html__( |
|
622 | - 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
623 | - 'event_espresso' |
|
624 | - ), |
|
625 | - '4.9.32.rc.005' |
|
626 | - ); |
|
627 | - foreach ($datetimes as $datetime) { |
|
628 | - $datetime->update_sold(); |
|
629 | - } |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * Gets the total number of tickets available at a particular datetime |
|
635 | - * (does NOT take into account the datetime's spaces available) |
|
636 | - * |
|
637 | - * @param int $DTT_ID |
|
638 | - * @param array $query_params |
|
639 | - * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
640 | - * tickets attached to datetime then FALSE is returned. |
|
641 | - * @throws EE_Error |
|
642 | - * @throws ReflectionException |
|
643 | - */ |
|
644 | - public function sum_tickets_currently_available_at_datetime(int $DTT_ID, array $query_params = []) |
|
645 | - { |
|
646 | - $datetime = $this->get_one_by_ID($DTT_ID); |
|
647 | - if ($datetime instanceof EE_Datetime) { |
|
648 | - return $datetime->tickets_remaining($query_params); |
|
649 | - } |
|
650 | - return 0; |
|
651 | - } |
|
652 | - |
|
653 | - |
|
654 | - /** |
|
655 | - * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
656 | - * |
|
657 | - * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
658 | - * stati you want counts for as values in the array. An empty array returns counts |
|
659 | - * for all valid stati. |
|
660 | - * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
661 | - * only for Datetimes connected to a specific event, or specific ticket. |
|
662 | - * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
663 | - * @throws EE_Error |
|
664 | - * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming |
|
665 | - * EE_Datetime::expired |
|
666 | - */ |
|
667 | - public function get_datetime_counts_by_status(array $stati_to_include = [], array $query_params = []) |
|
668 | - { |
|
669 | - // only accept where conditions for this query. |
|
670 | - $_where = isset($query_params[0]) ? $query_params[0] : []; |
|
671 | - $status_query_args = [ |
|
672 | - EE_Datetime::active => array_merge( |
|
673 | - $_where, |
|
674 | - ['DTT_EVT_start' => ['<', time()], 'DTT_EVT_end' => ['>', time()]] |
|
675 | - ), |
|
676 | - EE_Datetime::upcoming => array_merge( |
|
677 | - $_where, |
|
678 | - ['DTT_EVT_start' => ['>', time()]] |
|
679 | - ), |
|
680 | - EE_Datetime::expired => array_merge( |
|
681 | - $_where, |
|
682 | - ['DTT_EVT_end' => ['<', time()]] |
|
683 | - ), |
|
684 | - ]; |
|
685 | - if (! empty($stati_to_include)) { |
|
686 | - foreach (array_keys($status_query_args) as $status) { |
|
687 | - if (! in_array($status, $stati_to_include, true)) { |
|
688 | - unset($status_query_args[ $status ]); |
|
689 | - } |
|
690 | - } |
|
691 | - } |
|
692 | - // loop through and query counts for each stati. |
|
693 | - $status_query_results = []; |
|
694 | - foreach ($status_query_args as $status => $status_where_conditions) { |
|
695 | - $status_query_results[ $status ] = EEM_Datetime::count( |
|
696 | - [$status_where_conditions], |
|
697 | - 'DTT_ID', |
|
698 | - true |
|
699 | - ); |
|
700 | - } |
|
701 | - return $status_query_results; |
|
702 | - } |
|
703 | - |
|
704 | - |
|
705 | - /** |
|
706 | - * Returns the specific count for a given Datetime status matching any given query_params. |
|
707 | - * |
|
708 | - * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
709 | - * @param array $query_params |
|
710 | - * @return int |
|
711 | - * @throws EE_Error |
|
712 | - */ |
|
713 | - public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = []) |
|
714 | - { |
|
715 | - $count = $this->get_datetime_counts_by_status([$status], $query_params); |
|
716 | - return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
717 | - } |
|
718 | - |
|
719 | - |
|
720 | - /** |
|
721 | - * @return bool|int |
|
722 | - * @since 5.0.0.p |
|
723 | - */ |
|
724 | - private function prepModelForQuery() |
|
725 | - { |
|
726 | - $prev_data_prep_value = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
727 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
728 | - return $prev_data_prep_value; |
|
729 | - } |
|
730 | - |
|
731 | - |
|
732 | - /** |
|
733 | - * @param array $query_params |
|
734 | - * @param bool|int $prev_data_prep_value |
|
735 | - * @return EE_Base_Class[]|EE_Datetime[] |
|
736 | - * @throws EE_Error |
|
737 | - * @since 5.0.0.p |
|
738 | - */ |
|
739 | - private function getDatetimesAndRestoreModel(array $query_params, $prev_data_prep_value) |
|
740 | - { |
|
741 | - $result = $this->get_all($query_params); |
|
742 | - $this->assume_values_already_prepared_by_model_object($prev_data_prep_value); |
|
743 | - return $result; |
|
744 | - } |
|
745 | - |
|
746 | - |
|
747 | - /** |
|
748 | - * @param array $query_params |
|
749 | - * @param int $limit |
|
750 | - * @param string $order_by |
|
751 | - * @param string $order |
|
752 | - * @return array |
|
753 | - * @since 5.0.0.p |
|
754 | - */ |
|
755 | - private function addDefaultQueryParams(array $query_params, $limit = 0, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
756 | - { |
|
757 | - $query_params = $this->addOrderByQueryParams($query_params, $order_by, $order); |
|
758 | - $query_params = $this->addLimitQueryParams($query_params, $limit); |
|
759 | - return $query_params; |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - /** |
|
764 | - * @param array $query_params |
|
765 | - * @param string $default_where_conditions |
|
766 | - * @return array |
|
767 | - * @since 5.0.0.p |
|
768 | - */ |
|
769 | - private function addDefaultWhereConditions( |
|
770 | - array $query_params, |
|
771 | - $default_where_conditions = EEM_Base::default_where_conditions_none |
|
772 | - ) { |
|
773 | - $query_params['default_where_conditions'] = $default_where_conditions; |
|
774 | - return $query_params; |
|
775 | - } |
|
776 | - |
|
777 | - |
|
778 | - /** |
|
779 | - * @param array $where_params |
|
780 | - * @param bool $include_deleted |
|
781 | - * @param bool $include_expired |
|
782 | - * @return array |
|
783 | - * @since 5.0.0.p |
|
784 | - */ |
|
785 | - private function addDefaultWhereParams( |
|
786 | - array $where_params, |
|
787 | - bool $include_deleted = true, |
|
788 | - bool $include_expired = true |
|
789 | - ) { |
|
790 | - $where_params = $this->addExpiredWhereParams($where_params, $include_expired); |
|
791 | - $where_params = $this->addDeletedWhereParams($where_params, $include_deleted); |
|
792 | - return $where_params; |
|
793 | - } |
|
794 | - |
|
795 | - |
|
796 | - /** |
|
797 | - * @param array $where_params |
|
798 | - * @param bool $include_deleted |
|
799 | - * @return array |
|
800 | - * @since 5.0.0.p |
|
801 | - */ |
|
802 | - private function addDeletedWhereParams(array $where_params, bool $include_deleted = true) |
|
803 | - { |
|
804 | - $deleted = $include_deleted ? [true, false] : [false]; |
|
805 | - $where_params['DTT_deleted'] = ['IN', $deleted]; |
|
806 | - return $where_params; |
|
807 | - } |
|
808 | - |
|
809 | - |
|
810 | - /** |
|
811 | - * @param array $where_params |
|
812 | - * @param bool $include_expired |
|
813 | - * @return array |
|
814 | - * @since 5.0.0.p |
|
815 | - */ |
|
816 | - private function addExpiredWhereParams(array $where_params, bool $include_expired = true) |
|
817 | - { |
|
818 | - if (! $include_expired) { |
|
819 | - $where_params['DTT_EVT_end'] = ['>=', current_time('mysql', true)]; |
|
820 | - } |
|
821 | - return $where_params; |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - /** |
|
826 | - * @param array $query_params |
|
827 | - * @param int $limit |
|
828 | - * @return array |
|
829 | - * @since 5.0.0.p |
|
830 | - */ |
|
831 | - private function addLimitQueryParams(array $query_params, $limit = 0) |
|
832 | - { |
|
833 | - if ($limit) { |
|
834 | - $query_params['limit'] = $limit; |
|
835 | - } |
|
836 | - return $query_params; |
|
837 | - } |
|
838 | - |
|
839 | - |
|
840 | - /** |
|
841 | - * @param array $query_params |
|
842 | - * @param string $order_by |
|
843 | - * @param string $order |
|
844 | - * @return array |
|
845 | - * @since 5.0.0.p |
|
846 | - */ |
|
847 | - private function addOrderByQueryParams(array $query_params, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
848 | - { |
|
849 | - $order = $order === 'ASC' ? 'ASC' : 'DESC'; |
|
850 | - $valid_order_columns = ['DTT_ID', 'DTT_EVT_start', 'DTT_EVT_end', 'DTT_order']; |
|
851 | - $order_by = in_array($order_by, $valid_order_columns, true) ? $order_by : 'DTT_EVT_start'; |
|
852 | - $query_params['order_by'] = [$order_by => $order]; |
|
853 | - return $query_params; |
|
854 | - } |
|
19 | + protected static ?EEM_Datetime $_instance = null; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * private constructor to prevent direct creation |
|
24 | + * |
|
25 | + * @param string|null $timezone A string representing the timezone we want to set for returned Date Time Strings |
|
26 | + * (and any incoming timezone data that gets saved). |
|
27 | + * Note this just sends the timezone info to the date time model field objects. |
|
28 | + * Default is NULL |
|
29 | + * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
30 | + * @throws EE_Error |
|
31 | + */ |
|
32 | + protected function __construct(?string $timezone = '') |
|
33 | + { |
|
34 | + $this->singular_item = esc_html__('Datetime', 'event_espresso'); |
|
35 | + $this->plural_item = esc_html__('Datetimes', 'event_espresso'); |
|
36 | + $this->_tables = [ |
|
37 | + 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
38 | + ]; |
|
39 | + $this->_fields = [ |
|
40 | + 'Datetime' => [ |
|
41 | + 'DTT_ID' => new EE_Primary_Key_Int_Field( |
|
42 | + 'DTT_ID', |
|
43 | + esc_html__('Datetime ID', 'event_espresso') |
|
44 | + ), |
|
45 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
46 | + 'EVT_ID', |
|
47 | + esc_html__('Event ID', 'event_espresso'), |
|
48 | + false, |
|
49 | + 0, |
|
50 | + 'Event' |
|
51 | + ), |
|
52 | + 'VNU_ID' => new EE_Foreign_Key_Int_Field( |
|
53 | + 'VNU_ID', |
|
54 | + __('Venue ID', 'event_espresso'), |
|
55 | + false, |
|
56 | + 0, |
|
57 | + 'Venue' |
|
58 | + ), |
|
59 | + 'DTT_name' => new EE_Plain_Text_Field( |
|
60 | + 'DTT_name', |
|
61 | + esc_html__('Datetime Name', 'event_espresso'), |
|
62 | + false, |
|
63 | + '' |
|
64 | + ), |
|
65 | + 'DTT_description' => new EE_Post_Content_Field( |
|
66 | + 'DTT_description', |
|
67 | + esc_html__('Description for Datetime', 'event_espresso'), |
|
68 | + false, |
|
69 | + '' |
|
70 | + ), |
|
71 | + 'DTT_EVT_start' => new EE_Datetime_Field( |
|
72 | + 'DTT_EVT_start', |
|
73 | + esc_html__('Start time/date of Event', 'event_espresso'), |
|
74 | + false, |
|
75 | + EE_Datetime_Field::now, |
|
76 | + $timezone |
|
77 | + ), |
|
78 | + 'DTT_EVT_end' => new EE_Datetime_Field( |
|
79 | + 'DTT_EVT_end', |
|
80 | + esc_html__('End time/date of Event', 'event_espresso'), |
|
81 | + false, |
|
82 | + EE_Datetime_Field::now, |
|
83 | + $timezone |
|
84 | + ), |
|
85 | + 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
86 | + 'DTT_reg_limit', |
|
87 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
88 | + false, |
|
89 | + EE_INF |
|
90 | + ), |
|
91 | + 'DTT_sold' => new EE_Integer_Field( |
|
92 | + 'DTT_sold', |
|
93 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
94 | + false, |
|
95 | + 0 |
|
96 | + ), |
|
97 | + 'DTT_reserved' => new EE_Integer_Field( |
|
98 | + 'DTT_reserved', |
|
99 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
100 | + false, |
|
101 | + 0 |
|
102 | + ), |
|
103 | + 'DTT_is_primary' => new EE_Boolean_Field( |
|
104 | + 'DTT_is_primary', |
|
105 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
106 | + false, |
|
107 | + false |
|
108 | + ), |
|
109 | + 'DTT_order' => new EE_Integer_Field( |
|
110 | + 'DTT_order', |
|
111 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso'), |
|
112 | + false, |
|
113 | + 0 |
|
114 | + ), |
|
115 | + 'DTT_parent' => new EE_Integer_Field( |
|
116 | + 'DTT_parent', |
|
117 | + esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'), |
|
118 | + true, |
|
119 | + 0 |
|
120 | + ), |
|
121 | + 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
122 | + 'DTT_deleted', |
|
123 | + esc_html__('Flag indicating datetime is archived', 'event_espresso'), |
|
124 | + false, |
|
125 | + false |
|
126 | + ), |
|
127 | + ], |
|
128 | + ]; |
|
129 | + $this->_model_relations = [ |
|
130 | + 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
131 | + 'Event' => new EE_Belongs_To_Relation(), |
|
132 | + 'Checkin' => new EE_Has_Many_Relation(), |
|
133 | + 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
134 | + 'Venue' => new EE_Belongs_To_Relation(), |
|
135 | + ]; |
|
136 | + $path_to_event_model = 'Event'; |
|
137 | + $this->model_chain_to_password = $path_to_event_model; |
|
138 | + $this->_model_chain_to_wp_user = $path_to_event_model; |
|
139 | + // this model is generally available for reading |
|
140 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = |
|
141 | + new EE_Restriction_Generator_Event_Related_Public( |
|
142 | + $path_to_event_model |
|
143 | + ); |
|
144 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
145 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
146 | + $path_to_event_model |
|
147 | + ); |
|
148 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = |
|
149 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
150 | + $path_to_event_model |
|
151 | + ); |
|
152 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
153 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
154 | + $path_to_event_model, |
|
155 | + EEM_Base::caps_edit |
|
156 | + ); |
|
157 | + parent::__construct($timezone); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * create new blank datetime |
|
163 | + * |
|
164 | + * @access public |
|
165 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
166 | + * @throws EE_Error |
|
167 | + * @throws InvalidArgumentException |
|
168 | + * @throws InvalidDataTypeException |
|
169 | + * @throws ReflectionException |
|
170 | + * @throws InvalidInterfaceException |
|
171 | + */ |
|
172 | + public function create_new_blank_datetime() |
|
173 | + { |
|
174 | + // makes sure timezone is always set. |
|
175 | + $timezone_string = $this->get_timezone(); |
|
176 | + /** |
|
177 | + * Filters the initial start date for the new datetime. |
|
178 | + * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
179 | + * |
|
180 | + * @param int $start_date Unix timestamp representing now + 30 days in seconds. |
|
181 | + * @return int Unix timestamp |
|
182 | + */ |
|
183 | + $start_date = apply_filters( |
|
184 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__start_date', |
|
185 | + $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS |
|
186 | + ); |
|
187 | + /** |
|
188 | + * Filters the initial end date for the new datetime. |
|
189 | + * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
190 | + * |
|
191 | + * @param int $end_data Unix timestamp representing now + 30 days in seconds. |
|
192 | + * @return int Unix timestamp |
|
193 | + */ |
|
194 | + $end_date = apply_filters( |
|
195 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__end_date', |
|
196 | + $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS |
|
197 | + ); |
|
198 | + $blank_datetime = EE_Datetime::new_instance( |
|
199 | + [ |
|
200 | + 'DTT_EVT_start' => $start_date, |
|
201 | + 'DTT_EVT_end' => $end_date, |
|
202 | + 'DTT_order' => 1, |
|
203 | + 'DTT_reg_limit' => EE_INF_IN_DB, |
|
204 | + ], |
|
205 | + $timezone_string |
|
206 | + ); |
|
207 | + /** |
|
208 | + * Filters the initial start time and format for the new EE_Datetime instance. |
|
209 | + * |
|
210 | + * @param array $start_time An array having size 2. First element is the time, second element is the time |
|
211 | + * format. |
|
212 | + * @return array |
|
213 | + */ |
|
214 | + $start_time = apply_filters( |
|
215 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__start_time', |
|
216 | + ['8am', 'ga'] |
|
217 | + ); |
|
218 | + /** |
|
219 | + * Filters the initial end time and format for the new EE_Datetime instance. |
|
220 | + * |
|
221 | + * @param array $end_time An array having size 2. First element is the time, second element is the time |
|
222 | + * format |
|
223 | + * @return array |
|
224 | + */ |
|
225 | + $end_time = apply_filters( |
|
226 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__end_time', |
|
227 | + ['5pm', 'ga'] |
|
228 | + ); |
|
229 | + $this->validateStartAndEndTimeForBlankDate($start_time, $end_time); |
|
230 | + $blank_datetime->set_start_time( |
|
231 | + $this->convert_datetime_for_query( |
|
232 | + 'DTT_EVT_start', |
|
233 | + $start_time[0], |
|
234 | + $start_time[1], |
|
235 | + $timezone_string |
|
236 | + ) |
|
237 | + ); |
|
238 | + $blank_datetime->set_end_time( |
|
239 | + $this->convert_datetime_for_query( |
|
240 | + 'DTT_EVT_end', |
|
241 | + $end_time[0], |
|
242 | + $end_time[1], |
|
243 | + $timezone_string |
|
244 | + ) |
|
245 | + ); |
|
246 | + return [$blank_datetime]; |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * Validates whether the start_time and end_time are in the expected format. |
|
252 | + * |
|
253 | + * @param array $start_time |
|
254 | + * @param array $end_time |
|
255 | + * @throws InvalidArgumentException |
|
256 | + * @throws InvalidDataTypeException |
|
257 | + */ |
|
258 | + private function validateStartAndEndTimeForBlankDate(array $start_time, array $end_time) |
|
259 | + { |
|
260 | + if (! is_array($start_time)) { |
|
261 | + throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
|
262 | + } |
|
263 | + if (! is_array($end_time)) { |
|
264 | + throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
|
265 | + } |
|
266 | + if (count($start_time) !== 2) { |
|
267 | + throw new InvalidArgumentException( |
|
268 | + sprintf( |
|
269 | + 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
270 | + . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
271 | + '$start_time' |
|
272 | + ) |
|
273 | + ); |
|
274 | + } |
|
275 | + if (count($end_time) !== 2) { |
|
276 | + throw new InvalidArgumentException( |
|
277 | + sprintf( |
|
278 | + 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
279 | + . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
280 | + '$end_time' |
|
281 | + ) |
|
282 | + ); |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * get event start date from db |
|
289 | + * |
|
290 | + * @access public |
|
291 | + * @param int $EVT_ID |
|
292 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
293 | + * @throws EE_Error |
|
294 | + * @throws ReflectionException |
|
295 | + */ |
|
296 | + public function get_all_event_dates($EVT_ID = 0) |
|
297 | + { |
|
298 | + if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
299 | + return $this->create_new_blank_datetime(); |
|
300 | + } |
|
301 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
302 | + if (empty($results)) { |
|
303 | + return $this->create_new_blank_datetime(); |
|
304 | + } |
|
305 | + return $results; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * get all datetimes attached to an event ordered by the DTT_order field |
|
311 | + * |
|
312 | + * @public |
|
313 | + * @param int $EVT_ID event id |
|
314 | + * @param boolean $include_expired |
|
315 | + * @param boolean $include_deleted |
|
316 | + * @param int $limit If included then limit the count of results by |
|
317 | + * the given number |
|
318 | + * @return EE_Datetime[] |
|
319 | + * @throws EE_Error |
|
320 | + */ |
|
321 | + public function get_datetimes_for_event_ordered_by_DTT_order( |
|
322 | + int $EVT_ID, |
|
323 | + bool $include_expired = true, |
|
324 | + bool $include_deleted = true, |
|
325 | + $limit = 0 |
|
326 | + ) { |
|
327 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
328 | + $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
329 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
330 | + $query_params = $this->addDefaultWhereConditions($query_params); |
|
331 | + $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
332 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
333 | + } |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * Gets the datetimes for the event (with the given limit), and orders them by "importance". |
|
338 | + * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW), |
|
339 | + * and then the earlier datetimes are the most important. |
|
340 | + * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
341 | + * |
|
342 | + * @param int $EVT_ID |
|
343 | + * @param int $limit |
|
344 | + * @return EE_Datetime[]|EE_Base_Class[] |
|
345 | + * @throws EE_Error |
|
346 | + */ |
|
347 | + public function get_datetimes_for_event_ordered_by_importance(int $EVT_ID, $limit = 0) |
|
348 | + { |
|
349 | + $query_params[0] = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
350 | + $query_params = $this->addDefaultWhereConditions($query_params); |
|
351 | + $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
352 | + return $this->get_all($query_params); |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * @param int $EVT_ID |
|
358 | + * @param boolean $include_expired |
|
359 | + * @param boolean $include_deleted |
|
360 | + * @return EE_Datetime |
|
361 | + * @throws EE_Error |
|
362 | + */ |
|
363 | + public function get_oldest_datetime_for_event( |
|
364 | + int $EVT_ID, |
|
365 | + bool $include_expired = false, |
|
366 | + bool $include_deleted = false |
|
367 | + ) { |
|
368 | + $results = $this->get_datetimes_for_event_ordered_by_start_time( |
|
369 | + $EVT_ID, |
|
370 | + $include_expired, |
|
371 | + $include_deleted, |
|
372 | + 1 |
|
373 | + ); |
|
374 | + if ($results) { |
|
375 | + return array_shift($results); |
|
376 | + } |
|
377 | + return null; |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + /** |
|
382 | + * Gets the 'primary' datetime for an event. |
|
383 | + * |
|
384 | + * @param int $EVT_ID |
|
385 | + * @param bool $try_to_exclude_expired |
|
386 | + * @param bool $try_to_exclude_deleted |
|
387 | + * @return EE_Datetime |
|
388 | + * @throws EE_Error |
|
389 | + */ |
|
390 | + public function get_primary_datetime_for_event( |
|
391 | + int $EVT_ID, |
|
392 | + bool $try_to_exclude_expired = true, |
|
393 | + bool $try_to_exclude_deleted = true |
|
394 | + ) { |
|
395 | + if ($try_to_exclude_expired) { |
|
396 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
397 | + if ($non_expired) { |
|
398 | + return $non_expired; |
|
399 | + } |
|
400 | + } |
|
401 | + if ($try_to_exclude_deleted) { |
|
402 | + $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
403 | + if ($expired_even) { |
|
404 | + return $expired_even; |
|
405 | + } |
|
406 | + } |
|
407 | + return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
413 | + * only by start date |
|
414 | + * |
|
415 | + * @param int $EVT_ID |
|
416 | + * @param boolean $include_expired |
|
417 | + * @param boolean $include_deleted |
|
418 | + * @param int $limit |
|
419 | + * @return EE_Datetime[] |
|
420 | + * @throws EE_Error |
|
421 | + */ |
|
422 | + public function get_datetimes_for_event_ordered_by_start_time( |
|
423 | + int $EVT_ID, |
|
424 | + bool $include_expired = true, |
|
425 | + bool $include_deleted = true, |
|
426 | + $limit = 0 |
|
427 | + ) { |
|
428 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
429 | + $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
430 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
431 | + $query_params = $this->addDefaultWhereConditions( |
|
432 | + $query_params, |
|
433 | + EEM_Base::default_where_conditions_this_only |
|
434 | + ); |
|
435 | + $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
436 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
442 | + * only by start date |
|
443 | + * |
|
444 | + * @param int $TKT_ID |
|
445 | + * @param boolean $include_expired |
|
446 | + * @param boolean $include_deleted |
|
447 | + * @param int $limit |
|
448 | + * @return EE_Datetime[] |
|
449 | + * @throws EE_Error |
|
450 | + */ |
|
451 | + public function get_datetimes_for_ticket_ordered_by_start_time( |
|
452 | + int $TKT_ID, |
|
453 | + bool $include_expired = true, |
|
454 | + bool $include_deleted = true, |
|
455 | + $limit = 0 |
|
456 | + ) { |
|
457 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
458 | + $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
459 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
460 | + $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
461 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + /** |
|
466 | + * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
467 | + * datetimes. |
|
468 | + * |
|
469 | + * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
470 | + * @param boolean $include_expired whether to include expired datetimes or not |
|
471 | + * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
472 | + * @param int|null $limit if null, no limit, if int then limit results by |
|
473 | + * that number |
|
474 | + * @return EE_Datetime[] |
|
475 | + * @throws EE_Error |
|
476 | + */ |
|
477 | + public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
478 | + int $TKT_ID, |
|
479 | + bool $include_expired = true, |
|
480 | + bool $include_deleted = true, |
|
481 | + $limit = 0 |
|
482 | + ) { |
|
483 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
484 | + $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
485 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
486 | + $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
487 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
488 | + } |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
493 | + * reason it doesn't exist, we consider the earliest event the most important) |
|
494 | + * |
|
495 | + * @param int $EVT_ID |
|
496 | + * @return EE_Datetime |
|
497 | + * @throws EE_Error |
|
498 | + */ |
|
499 | + public function get_most_important_datetime_for_event(int $EVT_ID) |
|
500 | + { |
|
501 | + $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
502 | + if ($results) { |
|
503 | + return array_shift($results); |
|
504 | + } |
|
505 | + return null; |
|
506 | + } |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
511 | + * grouped by month and year. |
|
512 | + * |
|
513 | + * @param array $where_params @see |
|
514 | + * https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
515 | + * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
516 | + * Can be: |
|
517 | + * - '' = no filter |
|
518 | + * - upcoming = Published events with at least one upcoming datetime. |
|
519 | + * - expired = Events with all datetimes expired. |
|
520 | + * - active = Events that are published and have at least one datetime that |
|
521 | + * starts before now and ends after now. |
|
522 | + * - inactive = Events that are either not published. |
|
523 | + * @return stdClass[] |
|
524 | + * @throws EE_Error |
|
525 | + * @throws InvalidArgumentException |
|
526 | + * @throws InvalidArgumentException |
|
527 | + */ |
|
528 | + public function get_dtt_months_and_years(array $where_params, $evt_active_status = '') |
|
529 | + { |
|
530 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
531 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
532 | + switch ($evt_active_status) { |
|
533 | + case 'upcoming': |
|
534 | + $where_params['Event.status'] = 'publish'; |
|
535 | + // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
536 | + if (isset($where_params['DTT_EVT_start'])) { |
|
537 | + $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
538 | + } |
|
539 | + $where_params['DTT_EVT_start'] = ['>', $current_time_for_DTT_EVT_start]; |
|
540 | + break; |
|
541 | + case 'expired': |
|
542 | + if (isset($where_params['Event.status'])) { |
|
543 | + unset($where_params['Event.status']); |
|
544 | + } |
|
545 | + // get events to exclude |
|
546 | + $exclude_query[0] = array_merge( |
|
547 | + $where_params, |
|
548 | + ['DTT_EVT_end' => ['>', $current_time_for_DTT_EVT_end]] |
|
549 | + ); |
|
550 | + // first get all events that have datetimes where its not expired. |
|
551 | + $event_ids = $this->_get_all_wpdb_results( |
|
552 | + $exclude_query, |
|
553 | + OBJECT_K, |
|
554 | + 'Datetime.EVT_ID' |
|
555 | + ); |
|
556 | + $event_ids = array_keys($event_ids); |
|
557 | + if (isset($where_params['DTT_EVT_end'])) { |
|
558 | + $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
559 | + } |
|
560 | + $where_params['DTT_EVT_end'] = ['<', $current_time_for_DTT_EVT_end]; |
|
561 | + $where_params['Event.EVT_ID'] = ['NOT IN', $event_ids]; |
|
562 | + break; |
|
563 | + case 'active': |
|
564 | + $where_params['Event.status'] = 'publish'; |
|
565 | + if (isset($where_params['DTT_EVT_start'])) { |
|
566 | + $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
567 | + } |
|
568 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
569 | + $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
570 | + } |
|
571 | + $where_params['DTT_EVT_start'] = ['<', $current_time_for_DTT_EVT_start]; |
|
572 | + $where_params['DTT_EVT_end'] = ['>', $current_time_for_DTT_EVT_end]; |
|
573 | + break; |
|
574 | + case 'inactive': |
|
575 | + if (isset($where_params['Event.status'])) { |
|
576 | + unset($where_params['Event.status']); |
|
577 | + } |
|
578 | + if (isset($where_params['OR'])) { |
|
579 | + $where_params['AND']['OR'] = $where_params['OR']; |
|
580 | + } |
|
581 | + if (isset($where_params['DTT_EVT_end'])) { |
|
582 | + $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
583 | + unset($where_params['DTT_EVT_end']); |
|
584 | + } |
|
585 | + if (isset($where_params['DTT_EVT_start'])) { |
|
586 | + $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
587 | + unset($where_params['DTT_EVT_start']); |
|
588 | + } |
|
589 | + $where_params['AND']['Event.status'] = ['!=', 'publish']; |
|
590 | + break; |
|
591 | + } |
|
592 | + $query_params[0] = $where_params; |
|
593 | + $query_params['group_by'] = ['dtt_year', 'dtt_month']; |
|
594 | + $query_params = $this->addOrderByQueryParams($query_params, 'DTT_EVT_start', 'DESC'); |
|
595 | + |
|
596 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
597 | + $this->get_timezone(), |
|
598 | + 'DTT_EVT_start' |
|
599 | + ); |
|
600 | + $columns_to_select = [ |
|
601 | + 'dtt_year' => ['YEAR(' . $query_interval . ')', '%s'], |
|
602 | + 'dtt_month' => ['MONTHNAME(' . $query_interval . ')', '%s'], |
|
603 | + 'dtt_month_num' => ['MONTH(' . $query_interval . ')', '%s'], |
|
604 | + ]; |
|
605 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
606 | + } |
|
607 | + |
|
608 | + |
|
609 | + /** |
|
610 | + * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
611 | + * for the tickets for each datetime) |
|
612 | + * |
|
613 | + * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
614 | + * @throws EE_Error |
|
615 | + * @throws ReflectionException |
|
616 | + */ |
|
617 | + public function update_sold(array $datetimes) |
|
618 | + { |
|
619 | + EE_Error::doing_it_wrong( |
|
620 | + __FUNCTION__, |
|
621 | + esc_html__( |
|
622 | + 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
623 | + 'event_espresso' |
|
624 | + ), |
|
625 | + '4.9.32.rc.005' |
|
626 | + ); |
|
627 | + foreach ($datetimes as $datetime) { |
|
628 | + $datetime->update_sold(); |
|
629 | + } |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * Gets the total number of tickets available at a particular datetime |
|
635 | + * (does NOT take into account the datetime's spaces available) |
|
636 | + * |
|
637 | + * @param int $DTT_ID |
|
638 | + * @param array $query_params |
|
639 | + * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
640 | + * tickets attached to datetime then FALSE is returned. |
|
641 | + * @throws EE_Error |
|
642 | + * @throws ReflectionException |
|
643 | + */ |
|
644 | + public function sum_tickets_currently_available_at_datetime(int $DTT_ID, array $query_params = []) |
|
645 | + { |
|
646 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
647 | + if ($datetime instanceof EE_Datetime) { |
|
648 | + return $datetime->tickets_remaining($query_params); |
|
649 | + } |
|
650 | + return 0; |
|
651 | + } |
|
652 | + |
|
653 | + |
|
654 | + /** |
|
655 | + * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
656 | + * |
|
657 | + * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
658 | + * stati you want counts for as values in the array. An empty array returns counts |
|
659 | + * for all valid stati. |
|
660 | + * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
661 | + * only for Datetimes connected to a specific event, or specific ticket. |
|
662 | + * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
663 | + * @throws EE_Error |
|
664 | + * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming |
|
665 | + * EE_Datetime::expired |
|
666 | + */ |
|
667 | + public function get_datetime_counts_by_status(array $stati_to_include = [], array $query_params = []) |
|
668 | + { |
|
669 | + // only accept where conditions for this query. |
|
670 | + $_where = isset($query_params[0]) ? $query_params[0] : []; |
|
671 | + $status_query_args = [ |
|
672 | + EE_Datetime::active => array_merge( |
|
673 | + $_where, |
|
674 | + ['DTT_EVT_start' => ['<', time()], 'DTT_EVT_end' => ['>', time()]] |
|
675 | + ), |
|
676 | + EE_Datetime::upcoming => array_merge( |
|
677 | + $_where, |
|
678 | + ['DTT_EVT_start' => ['>', time()]] |
|
679 | + ), |
|
680 | + EE_Datetime::expired => array_merge( |
|
681 | + $_where, |
|
682 | + ['DTT_EVT_end' => ['<', time()]] |
|
683 | + ), |
|
684 | + ]; |
|
685 | + if (! empty($stati_to_include)) { |
|
686 | + foreach (array_keys($status_query_args) as $status) { |
|
687 | + if (! in_array($status, $stati_to_include, true)) { |
|
688 | + unset($status_query_args[ $status ]); |
|
689 | + } |
|
690 | + } |
|
691 | + } |
|
692 | + // loop through and query counts for each stati. |
|
693 | + $status_query_results = []; |
|
694 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
695 | + $status_query_results[ $status ] = EEM_Datetime::count( |
|
696 | + [$status_where_conditions], |
|
697 | + 'DTT_ID', |
|
698 | + true |
|
699 | + ); |
|
700 | + } |
|
701 | + return $status_query_results; |
|
702 | + } |
|
703 | + |
|
704 | + |
|
705 | + /** |
|
706 | + * Returns the specific count for a given Datetime status matching any given query_params. |
|
707 | + * |
|
708 | + * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
709 | + * @param array $query_params |
|
710 | + * @return int |
|
711 | + * @throws EE_Error |
|
712 | + */ |
|
713 | + public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = []) |
|
714 | + { |
|
715 | + $count = $this->get_datetime_counts_by_status([$status], $query_params); |
|
716 | + return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
717 | + } |
|
718 | + |
|
719 | + |
|
720 | + /** |
|
721 | + * @return bool|int |
|
722 | + * @since 5.0.0.p |
|
723 | + */ |
|
724 | + private function prepModelForQuery() |
|
725 | + { |
|
726 | + $prev_data_prep_value = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
727 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
728 | + return $prev_data_prep_value; |
|
729 | + } |
|
730 | + |
|
731 | + |
|
732 | + /** |
|
733 | + * @param array $query_params |
|
734 | + * @param bool|int $prev_data_prep_value |
|
735 | + * @return EE_Base_Class[]|EE_Datetime[] |
|
736 | + * @throws EE_Error |
|
737 | + * @since 5.0.0.p |
|
738 | + */ |
|
739 | + private function getDatetimesAndRestoreModel(array $query_params, $prev_data_prep_value) |
|
740 | + { |
|
741 | + $result = $this->get_all($query_params); |
|
742 | + $this->assume_values_already_prepared_by_model_object($prev_data_prep_value); |
|
743 | + return $result; |
|
744 | + } |
|
745 | + |
|
746 | + |
|
747 | + /** |
|
748 | + * @param array $query_params |
|
749 | + * @param int $limit |
|
750 | + * @param string $order_by |
|
751 | + * @param string $order |
|
752 | + * @return array |
|
753 | + * @since 5.0.0.p |
|
754 | + */ |
|
755 | + private function addDefaultQueryParams(array $query_params, $limit = 0, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
756 | + { |
|
757 | + $query_params = $this->addOrderByQueryParams($query_params, $order_by, $order); |
|
758 | + $query_params = $this->addLimitQueryParams($query_params, $limit); |
|
759 | + return $query_params; |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + /** |
|
764 | + * @param array $query_params |
|
765 | + * @param string $default_where_conditions |
|
766 | + * @return array |
|
767 | + * @since 5.0.0.p |
|
768 | + */ |
|
769 | + private function addDefaultWhereConditions( |
|
770 | + array $query_params, |
|
771 | + $default_where_conditions = EEM_Base::default_where_conditions_none |
|
772 | + ) { |
|
773 | + $query_params['default_where_conditions'] = $default_where_conditions; |
|
774 | + return $query_params; |
|
775 | + } |
|
776 | + |
|
777 | + |
|
778 | + /** |
|
779 | + * @param array $where_params |
|
780 | + * @param bool $include_deleted |
|
781 | + * @param bool $include_expired |
|
782 | + * @return array |
|
783 | + * @since 5.0.0.p |
|
784 | + */ |
|
785 | + private function addDefaultWhereParams( |
|
786 | + array $where_params, |
|
787 | + bool $include_deleted = true, |
|
788 | + bool $include_expired = true |
|
789 | + ) { |
|
790 | + $where_params = $this->addExpiredWhereParams($where_params, $include_expired); |
|
791 | + $where_params = $this->addDeletedWhereParams($where_params, $include_deleted); |
|
792 | + return $where_params; |
|
793 | + } |
|
794 | + |
|
795 | + |
|
796 | + /** |
|
797 | + * @param array $where_params |
|
798 | + * @param bool $include_deleted |
|
799 | + * @return array |
|
800 | + * @since 5.0.0.p |
|
801 | + */ |
|
802 | + private function addDeletedWhereParams(array $where_params, bool $include_deleted = true) |
|
803 | + { |
|
804 | + $deleted = $include_deleted ? [true, false] : [false]; |
|
805 | + $where_params['DTT_deleted'] = ['IN', $deleted]; |
|
806 | + return $where_params; |
|
807 | + } |
|
808 | + |
|
809 | + |
|
810 | + /** |
|
811 | + * @param array $where_params |
|
812 | + * @param bool $include_expired |
|
813 | + * @return array |
|
814 | + * @since 5.0.0.p |
|
815 | + */ |
|
816 | + private function addExpiredWhereParams(array $where_params, bool $include_expired = true) |
|
817 | + { |
|
818 | + if (! $include_expired) { |
|
819 | + $where_params['DTT_EVT_end'] = ['>=', current_time('mysql', true)]; |
|
820 | + } |
|
821 | + return $where_params; |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + /** |
|
826 | + * @param array $query_params |
|
827 | + * @param int $limit |
|
828 | + * @return array |
|
829 | + * @since 5.0.0.p |
|
830 | + */ |
|
831 | + private function addLimitQueryParams(array $query_params, $limit = 0) |
|
832 | + { |
|
833 | + if ($limit) { |
|
834 | + $query_params['limit'] = $limit; |
|
835 | + } |
|
836 | + return $query_params; |
|
837 | + } |
|
838 | + |
|
839 | + |
|
840 | + /** |
|
841 | + * @param array $query_params |
|
842 | + * @param string $order_by |
|
843 | + * @param string $order |
|
844 | + * @return array |
|
845 | + * @since 5.0.0.p |
|
846 | + */ |
|
847 | + private function addOrderByQueryParams(array $query_params, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
848 | + { |
|
849 | + $order = $order === 'ASC' ? 'ASC' : 'DESC'; |
|
850 | + $valid_order_columns = ['DTT_ID', 'DTT_EVT_start', 'DTT_EVT_end', 'DTT_order']; |
|
851 | + $order_by = in_array($order_by, $valid_order_columns, true) ? $order_by : 'DTT_EVT_start'; |
|
852 | + $query_params['order_by'] = [$order_by => $order]; |
|
853 | + return $query_params; |
|
854 | + } |
|
855 | 855 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | && ! function_exists('json_basic_auth_handler') |
43 | 43 | && ! function_exists('json_basic_auth_error') |
44 | 44 | ) { |
45 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
45 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth/basic-auth.php'; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
@@ -6,40 +6,40 @@ |
||
6 | 6 | |
7 | 7 | class ThirdPartyPluginHandler |
8 | 8 | { |
9 | - private RequestInterface $request; |
|
10 | - |
|
11 | - |
|
12 | - /** |
|
13 | - * ThirdPartyPluginHandler constructor. |
|
14 | - * |
|
15 | - * @param RequestInterface $request |
|
16 | - */ |
|
17 | - public function __construct(RequestInterface $request) |
|
18 | - { |
|
19 | - $this->request = $request; |
|
20 | - } |
|
21 | - |
|
22 | - |
|
23 | - public function loadPlugins() |
|
24 | - { |
|
25 | - $this->wpApiBasicAuth(); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - private function wpApiBasicAuth() |
|
30 | - { |
|
31 | - // if the WP API basic auth plugin isn't already loaded, load it now. |
|
32 | - // We want it for mobile apps. Just include the entire plugin |
|
33 | - // also, don't load the basic auth when a plugin is getting activated, because |
|
34 | - // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
35 | - // and causes a fatal error |
|
36 | - if ( |
|
37 | - ($this->request->isWordPressApi() || $this->request->isApi()) |
|
38 | - && ! $this->request->isActivation() |
|
39 | - && ! function_exists('json_basic_auth_handler') |
|
40 | - && ! function_exists('json_basic_auth_error') |
|
41 | - ) { |
|
42 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
43 | - } |
|
44 | - } |
|
9 | + private RequestInterface $request; |
|
10 | + |
|
11 | + |
|
12 | + /** |
|
13 | + * ThirdPartyPluginHandler constructor. |
|
14 | + * |
|
15 | + * @param RequestInterface $request |
|
16 | + */ |
|
17 | + public function __construct(RequestInterface $request) |
|
18 | + { |
|
19 | + $this->request = $request; |
|
20 | + } |
|
21 | + |
|
22 | + |
|
23 | + public function loadPlugins() |
|
24 | + { |
|
25 | + $this->wpApiBasicAuth(); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + private function wpApiBasicAuth() |
|
30 | + { |
|
31 | + // if the WP API basic auth plugin isn't already loaded, load it now. |
|
32 | + // We want it for mobile apps. Just include the entire plugin |
|
33 | + // also, don't load the basic auth when a plugin is getting activated, because |
|
34 | + // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
35 | + // and causes a fatal error |
|
36 | + if ( |
|
37 | + ($this->request->isWordPressApi() || $this->request->isApi()) |
|
38 | + && ! $this->request->isActivation() |
|
39 | + && ! function_exists('json_basic_auth_handler') |
|
40 | + && ! function_exists('json_basic_auth_error') |
|
41 | + ) { |
|
42 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
@@ -33,14 +33,14 @@ |
||
33 | 33 | */ |
34 | 34 | public function __construct(string $fully_qualified_name) |
35 | 35 | { |
36 | - if (! is_string($fully_qualified_name)) { |
|
36 | + if ( ! is_string($fully_qualified_name)) { |
|
37 | 37 | throw new InvalidDataTypeException( |
38 | 38 | '$fully_qualified_name', |
39 | 39 | $fully_qualified_name, |
40 | 40 | 'string' |
41 | 41 | ); |
42 | 42 | } |
43 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | + if ( ! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
44 | 44 | if (strpos($fully_qualified_name, 'Interface') !== false) { |
45 | 45 | throw new InvalidInterfaceException($fully_qualified_name); |
46 | 46 | } |
@@ -16,53 +16,53 @@ |
||
16 | 16 | */ |
17 | 17 | class FullyQualifiedName |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string $fully_qualified_name |
|
21 | - */ |
|
22 | - private $fully_qualified_name; |
|
19 | + /** |
|
20 | + * @var string $fully_qualified_name |
|
21 | + */ |
|
22 | + private $fully_qualified_name; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * FullyQualifiedName constructor. |
|
27 | - * |
|
28 | - * @param string $fully_qualified_name |
|
29 | - * @throws InvalidClassException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - */ |
|
33 | - public function __construct(string $fully_qualified_name) |
|
34 | - { |
|
35 | - if (! is_string($fully_qualified_name)) { |
|
36 | - throw new InvalidDataTypeException( |
|
37 | - '$fully_qualified_name', |
|
38 | - $fully_qualified_name, |
|
39 | - 'string' |
|
40 | - ); |
|
41 | - } |
|
42 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
44 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
45 | - } |
|
46 | - throw new InvalidClassException($fully_qualified_name); |
|
47 | - } |
|
48 | - $this->fully_qualified_name = $fully_qualified_name; |
|
49 | - } |
|
25 | + /** |
|
26 | + * FullyQualifiedName constructor. |
|
27 | + * |
|
28 | + * @param string $fully_qualified_name |
|
29 | + * @throws InvalidClassException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + */ |
|
33 | + public function __construct(string $fully_qualified_name) |
|
34 | + { |
|
35 | + if (! is_string($fully_qualified_name)) { |
|
36 | + throw new InvalidDataTypeException( |
|
37 | + '$fully_qualified_name', |
|
38 | + $fully_qualified_name, |
|
39 | + 'string' |
|
40 | + ); |
|
41 | + } |
|
42 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
44 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
45 | + } |
|
46 | + throw new InvalidClassException($fully_qualified_name); |
|
47 | + } |
|
48 | + $this->fully_qualified_name = $fully_qualified_name; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function string(): string |
|
56 | - { |
|
57 | - return $this->fully_qualified_name; |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function string(): string |
|
56 | + { |
|
57 | + return $this->fully_qualified_name; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function __toString(): string |
|
65 | - { |
|
66 | - return $this->fully_qualified_name; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function __toString(): string |
|
65 | + { |
|
66 | + return $this->fully_qualified_name; |
|
67 | + } |
|
68 | 68 | } |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | public static function getEventEspressoCoreDomain(): DomainInterface |
77 | 77 | { |
78 | 78 | $fqcn = 'EventEspresso\core\domain\Domain'; |
79 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
79 | + if ( ! isset(DomainFactory::$domains[$fqcn])) { |
|
80 | 80 | DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
81 | 81 | } |
82 | - return DomainFactory::$domains[ $fqcn ]; |
|
82 | + return DomainFactory::$domains[$fqcn]; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | */ |
91 | 91 | private static function getDomain(string $fqcn, array $arguments): DomainInterface |
92 | 92 | { |
93 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | - if (! isset($arguments[0], $arguments[1])) { |
|
93 | + if ( ! isset(DomainFactory::$domains[$fqcn])) { |
|
94 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
95 | 95 | throw new InvalidArgumentException( |
96 | 96 | esc_html__( |
97 | 97 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
103 | 103 | $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
104 | 104 | $domain = new $fqcn($filepath, $version); |
105 | - if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
105 | + if ( ! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | 106 | throw new DomainException( |
107 | 107 | sprintf( |
108 | 108 | esc_html__( |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | } |
116 | - DomainFactory::$domains[ $fqcn ] = $domain; |
|
116 | + DomainFactory::$domains[$fqcn] = $domain; |
|
117 | 117 | // we still need to share this with the core loader to facilitate automatic dependency injection |
118 | 118 | LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
119 | 119 | } |
120 | - return DomainFactory::$domains[ $fqcn ]; |
|
120 | + return DomainFactory::$domains[$fqcn]; |
|
121 | 121 | } |
122 | 122 | } |
@@ -22,101 +22,101 @@ |
||
22 | 22 | */ |
23 | 23 | class DomainFactory |
24 | 24 | { |
25 | - /** |
|
26 | - * @var DomainInterface[] |
|
27 | - */ |
|
28 | - protected static array $domains = []; |
|
25 | + /** |
|
26 | + * @var DomainInterface[] |
|
27 | + */ |
|
28 | + protected static array $domains = []; |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @param string $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | - * @param string $main_file [required] path to the main plugin file |
|
34 | - * @param string $version [required] version string for the plugin |
|
35 | - * @return DomainInterface |
|
36 | - * @throws DomainException |
|
37 | - * @throws InvalidArgumentException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws InvalidInterfaceException |
|
40 | - */ |
|
41 | - public static function create(string $domain_fqcn, string $main_file, string $version): DomainInterface |
|
42 | - { |
|
43 | - $fqcn = new FullyQualifiedName($domain_fqcn); |
|
44 | - return DomainFactory::getDomain($fqcn->string(), [$main_file, $version]); |
|
45 | - } |
|
31 | + /** |
|
32 | + * @param string $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | + * @param string $main_file [required] path to the main plugin file |
|
34 | + * @param string $version [required] version string for the plugin |
|
35 | + * @return DomainInterface |
|
36 | + * @throws DomainException |
|
37 | + * @throws InvalidArgumentException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws InvalidInterfaceException |
|
40 | + */ |
|
41 | + public static function create(string $domain_fqcn, string $main_file, string $version): DomainInterface |
|
42 | + { |
|
43 | + $fqcn = new FullyQualifiedName($domain_fqcn); |
|
44 | + return DomainFactory::getDomain($fqcn->string(), [$main_file, $version]); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
50 | - * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
51 | - * constructor. Must at least include the following two value objects: |
|
52 | - * [ |
|
53 | - * EventEspresso\core\domain\values\FilePath $plugin_file |
|
54 | - * EventEspresso\core\domain\values\Version $version |
|
55 | - * ] |
|
56 | - * @return DomainInterface |
|
57 | - * @throws DomainException |
|
58 | - * @throws InvalidArgumentException |
|
59 | - * @throws InvalidDataTypeException |
|
60 | - * @throws InvalidInterfaceException |
|
61 | - */ |
|
62 | - public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments): DomainInterface |
|
63 | - { |
|
64 | - return DomainFactory::getDomain($domain_fqcn->string(), $arguments); |
|
65 | - } |
|
48 | + /** |
|
49 | + * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
50 | + * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
51 | + * constructor. Must at least include the following two value objects: |
|
52 | + * [ |
|
53 | + * EventEspresso\core\domain\values\FilePath $plugin_file |
|
54 | + * EventEspresso\core\domain\values\Version $version |
|
55 | + * ] |
|
56 | + * @return DomainInterface |
|
57 | + * @throws DomainException |
|
58 | + * @throws InvalidArgumentException |
|
59 | + * @throws InvalidDataTypeException |
|
60 | + * @throws InvalidInterfaceException |
|
61 | + */ |
|
62 | + public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments): DomainInterface |
|
63 | + { |
|
64 | + return DomainFactory::getDomain($domain_fqcn->string(), $arguments); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return DomainInterface |
|
70 | - * @throws DomainException |
|
71 | - * @throws InvalidArgumentException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidFilePathException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - */ |
|
76 | - public static function getEventEspressoCoreDomain(): DomainInterface |
|
77 | - { |
|
78 | - $fqcn = 'EventEspresso\core\domain\Domain'; |
|
79 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
80 | - DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
|
81 | - } |
|
82 | - return DomainFactory::$domains[ $fqcn ]; |
|
83 | - } |
|
68 | + /** |
|
69 | + * @return DomainInterface |
|
70 | + * @throws DomainException |
|
71 | + * @throws InvalidArgumentException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidFilePathException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + */ |
|
76 | + public static function getEventEspressoCoreDomain(): DomainInterface |
|
77 | + { |
|
78 | + $fqcn = 'EventEspresso\core\domain\Domain'; |
|
79 | + if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
80 | + DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
|
81 | + } |
|
82 | + return DomainFactory::$domains[ $fqcn ]; |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param string $fqcn |
|
88 | - * @param array $arguments |
|
89 | - * @return DomainInterface |
|
90 | - */ |
|
91 | - private static function getDomain(string $fqcn, array $arguments): DomainInterface |
|
92 | - { |
|
93 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | - if (! isset($arguments[0], $arguments[1])) { |
|
95 | - throw new InvalidArgumentException( |
|
96 | - esc_html__( |
|
97 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
98 | - 'event_espresso' |
|
99 | - ) |
|
100 | - ); |
|
101 | - } |
|
102 | - $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
|
103 | - $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
|
104 | - $domain = new $fqcn($filepath, $version); |
|
105 | - if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | - throw new DomainException( |
|
107 | - sprintf( |
|
108 | - esc_html__( |
|
109 | - 'The requested Domain class "%1$s" could not be loaded.', |
|
110 | - 'event_espresso' |
|
111 | - ), |
|
112 | - $fqcn |
|
113 | - ) |
|
114 | - ); |
|
115 | - } |
|
116 | - DomainFactory::$domains[ $fqcn ] = $domain; |
|
117 | - // we still need to share this with the core loader to facilitate automatic dependency injection |
|
118 | - LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
|
119 | - } |
|
120 | - return DomainFactory::$domains[ $fqcn ]; |
|
121 | - } |
|
86 | + /** |
|
87 | + * @param string $fqcn |
|
88 | + * @param array $arguments |
|
89 | + * @return DomainInterface |
|
90 | + */ |
|
91 | + private static function getDomain(string $fqcn, array $arguments): DomainInterface |
|
92 | + { |
|
93 | + if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | + if (! isset($arguments[0], $arguments[1])) { |
|
95 | + throw new InvalidArgumentException( |
|
96 | + esc_html__( |
|
97 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
98 | + 'event_espresso' |
|
99 | + ) |
|
100 | + ); |
|
101 | + } |
|
102 | + $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
|
103 | + $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
|
104 | + $domain = new $fqcn($filepath, $version); |
|
105 | + if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | + throw new DomainException( |
|
107 | + sprintf( |
|
108 | + esc_html__( |
|
109 | + 'The requested Domain class "%1$s" could not be loaded.', |
|
110 | + 'event_espresso' |
|
111 | + ), |
|
112 | + $fqcn |
|
113 | + ) |
|
114 | + ); |
|
115 | + } |
|
116 | + DomainFactory::$domains[ $fqcn ] = $domain; |
|
117 | + // we still need to share this with the core loader to facilitate automatic dependency injection |
|
118 | + LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
|
119 | + } |
|
120 | + return DomainFactory::$domains[ $fqcn ]; |
|
121 | + } |
|
122 | 122 | } |
@@ -3,25 +3,25 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php |
6 | - printf( |
|
7 | - esc_html__( |
|
8 | - 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | - 'event_espresso' |
|
10 | - ), |
|
11 | - '<em>', |
|
12 | - '</em>' |
|
13 | - ); |
|
14 | - ?> |
|
6 | + printf( |
|
7 | + esc_html__( |
|
8 | + 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | + 'event_espresso' |
|
10 | + ), |
|
11 | + '<em>', |
|
12 | + '</em>' |
|
13 | + ); |
|
14 | + ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <?php esc_html_e( |
18 | - 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </p> |
22 | 22 | <p> |
23 | 23 | <?php esc_html_e( |
24 | - 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | - 'event_espresso' |
|
26 | - ); ?> |
|
24 | + 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | + 'event_espresso' |
|
26 | + ); ?> |
|
27 | 27 | </p> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | private function _get_datetimes_from_event(EE_Event $event) |
169 | 169 | { |
170 | 170 | return isset($this->_extra_data['data']->events) |
171 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | + ? $this->_extra_data['data']->events[$event->ID()]['dtt_objs'] |
|
172 | 172 | : []; |
173 | 173 | } |
174 | 174 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
183 | 183 | { |
184 | 184 | return isset($this->_extra_data['data']->tickets) |
185 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
185 | + ? $this->_extra_data['data']->tickets[$ticket->ID()]['dtt_objs'] |
|
186 | 186 | : []; |
187 | 187 | } |
188 | 188 | } |
@@ -18,168 +18,168 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Datetime_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | - $this->_shortcodes = [ |
|
26 | - '[DATETIME_LIST]' => esc_html__( |
|
27 | - 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - ]; |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @param string $shortcode |
|
36 | - * @return string |
|
37 | - * @throws EE_Error |
|
38 | - * @throws ReflectionException |
|
39 | - */ |
|
40 | - protected function _parser($shortcode) |
|
41 | - { |
|
42 | - if ($shortcode == '[DATETIME_LIST]') { |
|
43 | - return $this->_get_datetime_list(); |
|
44 | - } |
|
45 | - return ''; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - private function _get_datetime_list() |
|
57 | - { |
|
58 | - $this->_validate_list_requirements(); |
|
59 | - |
|
60 | - if ($this->_data['data'] instanceof EE_Ticket) { |
|
61 | - return $this->_get_datetime_list_for_ticket(); |
|
62 | - } |
|
63 | - if ($this->_data['data'] instanceof EE_Event) { |
|
64 | - return $this->_get_datetime_list_for_event(); |
|
65 | - } |
|
66 | - if ( |
|
67 | - $this->_data['data'] instanceof EE_Messages_Addressee |
|
68 | - && $this->_data['data']->reg_obj instanceof EE_Registration |
|
69 | - ) { |
|
70 | - return $this->_get_datetime_list_for_registration(); |
|
71 | - } |
|
72 | - // prevent recursive loop |
|
73 | - return ''; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * return parsed list of datetimes for an event |
|
79 | - * |
|
80 | - * @return string |
|
81 | - * @throws EE_Error |
|
82 | - * @throws ReflectionException |
|
83 | - */ |
|
84 | - private function _get_datetime_list_for_event() |
|
85 | - { |
|
86 | - $event = $this->_data['data']; |
|
87 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
88 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
89 | - ? $this->_data['template']['datetime_list'] |
|
90 | - : $this->_extra_data['template']['datetime_list']; |
|
91 | - |
|
92 | - // here we're setting up the datetimes for the datetime list template for THIS event. |
|
93 | - $dtt_parsed = ''; |
|
94 | - $datetimes = $this->_get_datetimes_from_event($event); |
|
95 | - |
|
96 | - // each datetime in this case should be an datetime object. |
|
97 | - foreach ($datetimes as $datetime) { |
|
98 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
99 | - $template, |
|
100 | - $datetime, |
|
101 | - $valid_shortcodes, |
|
102 | - $this->_extra_data |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - return $dtt_parsed; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * return parsed list of datetimes for an ticket |
|
112 | - * |
|
113 | - * @return string |
|
114 | - * @throws EE_Error |
|
115 | - */ |
|
116 | - private function _get_datetime_list_for_ticket() |
|
117 | - { |
|
118 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
119 | - |
|
120 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
121 | - ? $this->_data['template']['datetime_list'] |
|
122 | - : $this->_extra_data['template']['datetime_list']; |
|
123 | - $ticket = $this->_data['data']; |
|
124 | - |
|
125 | - // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
126 | - $dtt_parsed = ''; |
|
127 | - $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
128 | - |
|
129 | - // each datetime in this case should be an datetime object. |
|
130 | - foreach ($datetimes as $datetime) { |
|
131 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
132 | - $template, |
|
133 | - $datetime, |
|
134 | - $valid_shortcodes, |
|
135 | - $this->_extra_data |
|
136 | - ); |
|
137 | - } |
|
138 | - |
|
139 | - return $dtt_parsed; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * return parsed list of datetimes from a given registration. |
|
145 | - * |
|
146 | - * @return string |
|
147 | - * @throws EE_Error |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - private function _get_datetime_list_for_registration() |
|
151 | - { |
|
152 | - $registration = $this->_data['data']->reg_obj; |
|
153 | - |
|
154 | - // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
155 | - $this->_data['data'] = $registration->ticket(); |
|
156 | - return $this->_get_datetime_list_for_ticket(); |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @param EE_Event $event |
|
162 | - * @return array|mixed |
|
163 | - * @throws EE_Error |
|
164 | - * @throws ReflectionException |
|
165 | - */ |
|
166 | - private function _get_datetimes_from_event(EE_Event $event) |
|
167 | - { |
|
168 | - return isset($this->_extra_data['data']->events) |
|
169 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
170 | - : []; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * @param EE_Ticket $ticket |
|
176 | - * @return array|mixed |
|
177 | - * @throws EE_Error |
|
178 | - */ |
|
179 | - private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
180 | - { |
|
181 | - return isset($this->_extra_data['data']->tickets) |
|
182 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
183 | - : []; |
|
184 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | + $this->_shortcodes = [ |
|
26 | + '[DATETIME_LIST]' => esc_html__( |
|
27 | + 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + ]; |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @param string $shortcode |
|
36 | + * @return string |
|
37 | + * @throws EE_Error |
|
38 | + * @throws ReflectionException |
|
39 | + */ |
|
40 | + protected function _parser($shortcode) |
|
41 | + { |
|
42 | + if ($shortcode == '[DATETIME_LIST]') { |
|
43 | + return $this->_get_datetime_list(); |
|
44 | + } |
|
45 | + return ''; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + private function _get_datetime_list() |
|
57 | + { |
|
58 | + $this->_validate_list_requirements(); |
|
59 | + |
|
60 | + if ($this->_data['data'] instanceof EE_Ticket) { |
|
61 | + return $this->_get_datetime_list_for_ticket(); |
|
62 | + } |
|
63 | + if ($this->_data['data'] instanceof EE_Event) { |
|
64 | + return $this->_get_datetime_list_for_event(); |
|
65 | + } |
|
66 | + if ( |
|
67 | + $this->_data['data'] instanceof EE_Messages_Addressee |
|
68 | + && $this->_data['data']->reg_obj instanceof EE_Registration |
|
69 | + ) { |
|
70 | + return $this->_get_datetime_list_for_registration(); |
|
71 | + } |
|
72 | + // prevent recursive loop |
|
73 | + return ''; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * return parsed list of datetimes for an event |
|
79 | + * |
|
80 | + * @return string |
|
81 | + * @throws EE_Error |
|
82 | + * @throws ReflectionException |
|
83 | + */ |
|
84 | + private function _get_datetime_list_for_event() |
|
85 | + { |
|
86 | + $event = $this->_data['data']; |
|
87 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
88 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
89 | + ? $this->_data['template']['datetime_list'] |
|
90 | + : $this->_extra_data['template']['datetime_list']; |
|
91 | + |
|
92 | + // here we're setting up the datetimes for the datetime list template for THIS event. |
|
93 | + $dtt_parsed = ''; |
|
94 | + $datetimes = $this->_get_datetimes_from_event($event); |
|
95 | + |
|
96 | + // each datetime in this case should be an datetime object. |
|
97 | + foreach ($datetimes as $datetime) { |
|
98 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
99 | + $template, |
|
100 | + $datetime, |
|
101 | + $valid_shortcodes, |
|
102 | + $this->_extra_data |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + return $dtt_parsed; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * return parsed list of datetimes for an ticket |
|
112 | + * |
|
113 | + * @return string |
|
114 | + * @throws EE_Error |
|
115 | + */ |
|
116 | + private function _get_datetime_list_for_ticket() |
|
117 | + { |
|
118 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
119 | + |
|
120 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
121 | + ? $this->_data['template']['datetime_list'] |
|
122 | + : $this->_extra_data['template']['datetime_list']; |
|
123 | + $ticket = $this->_data['data']; |
|
124 | + |
|
125 | + // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
126 | + $dtt_parsed = ''; |
|
127 | + $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
128 | + |
|
129 | + // each datetime in this case should be an datetime object. |
|
130 | + foreach ($datetimes as $datetime) { |
|
131 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
132 | + $template, |
|
133 | + $datetime, |
|
134 | + $valid_shortcodes, |
|
135 | + $this->_extra_data |
|
136 | + ); |
|
137 | + } |
|
138 | + |
|
139 | + return $dtt_parsed; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * return parsed list of datetimes from a given registration. |
|
145 | + * |
|
146 | + * @return string |
|
147 | + * @throws EE_Error |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + private function _get_datetime_list_for_registration() |
|
151 | + { |
|
152 | + $registration = $this->_data['data']->reg_obj; |
|
153 | + |
|
154 | + // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
155 | + $this->_data['data'] = $registration->ticket(); |
|
156 | + return $this->_get_datetime_list_for_ticket(); |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @param EE_Event $event |
|
162 | + * @return array|mixed |
|
163 | + * @throws EE_Error |
|
164 | + * @throws ReflectionException |
|
165 | + */ |
|
166 | + private function _get_datetimes_from_event(EE_Event $event) |
|
167 | + { |
|
168 | + return isset($this->_extra_data['data']->events) |
|
169 | + ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
170 | + : []; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * @param EE_Ticket $ticket |
|
176 | + * @return array|mixed |
|
177 | + * @throws EE_Error |
|
178 | + */ |
|
179 | + private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
180 | + { |
|
181 | + return isset($this->_extra_data['data']->tickets) |
|
182 | + ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
183 | + : []; |
|
184 | + } |
|
185 | 185 | } |
@@ -163,7 +163,7 @@ |
||
163 | 163 | private function _get_events_from_registration(EE_Registration $registration) |
164 | 164 | { |
165 | 165 | return isset($this->_extra_data['data']->registrations) |
166 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
166 | + ? [$this->_extra_data['data']->registrations[$registration->ID()]['evt_obj']] |
|
167 | 167 | : []; |
168 | 168 | } |
169 | 169 | } |
@@ -18,155 +18,155 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Event_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct(); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _init_props() |
|
28 | - { |
|
29 | - $this->label = esc_html__('Event List Shortcodes', 'event_espresso'); |
|
30 | - $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso'); |
|
31 | - $this->_shortcodes = [ |
|
32 | - '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'), |
|
33 | - ]; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $shortcode |
|
39 | - * @return string |
|
40 | - * @throws EE_Error |
|
41 | - * @throws ReflectionException |
|
42 | - */ |
|
43 | - protected function _parser($shortcode) |
|
44 | - { |
|
45 | - if ($shortcode == '[EVENT_LIST]') { |
|
46 | - return $this->_get_event_list(); |
|
47 | - } |
|
48 | - return ''; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
54 | - * |
|
55 | - * @return string |
|
56 | - * @throws EE_Error |
|
57 | - * @throws ReflectionException |
|
58 | - */ |
|
59 | - private function _get_event_list() |
|
60 | - { |
|
61 | - $this->_validate_list_requirements(); |
|
62 | - |
|
63 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
64 | - return $this->_get_event_list_for_main(); |
|
65 | - } |
|
66 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
67 | - return $this->_get_event_list_for_registration(); |
|
68 | - } |
|
69 | - // prevent recursive loop |
|
70 | - return ''; |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * This returns the parsed event list for main template |
|
76 | - * |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - private function _get_event_list_for_main() |
|
80 | - { |
|
81 | - |
|
82 | - $valid_shortcodes = [ |
|
83 | - 'event', |
|
84 | - 'attendee_list', |
|
85 | - 'ticket_list', |
|
86 | - 'datetime_list', |
|
87 | - 'venue', |
|
88 | - 'attendee', |
|
89 | - 'recipient_list', |
|
90 | - 'recipient_details', |
|
91 | - 'primary_registration_list', |
|
92 | - 'primary_registration_details', |
|
93 | - 'event_author', |
|
94 | - 'organization', |
|
95 | - ]; |
|
96 | - $template = $this->_data['template']; |
|
97 | - $data = $this->_data['data']; |
|
98 | - $events = ''; |
|
99 | - |
|
100 | - // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper. |
|
101 | - foreach ($data->events as $event) { |
|
102 | - $events .= $this->_shortcode_helper->parse_event_list_template( |
|
103 | - $template, |
|
104 | - $event['event'], |
|
105 | - $valid_shortcodes, |
|
106 | - $this->_extra_data |
|
107 | - ); |
|
108 | - } |
|
109 | - return $events; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * This returns the parsed event list for an attendee |
|
115 | - * |
|
116 | - * @return string |
|
117 | - * @throws EE_Error |
|
118 | - * @throws ReflectionException |
|
119 | - */ |
|
120 | - private function _get_event_list_for_registration() |
|
121 | - { |
|
122 | - $valid_shortcodes = [ |
|
123 | - 'event', |
|
124 | - 'ticket_list', |
|
125 | - 'datetime_list', |
|
126 | - 'attendee', |
|
127 | - 'event_author', |
|
128 | - 'recipient_details', |
|
129 | - 'recipient_list', |
|
130 | - 'venue', |
|
131 | - 'organization', |
|
132 | - ]; |
|
133 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['event_list']) |
|
134 | - ? $this->_data['template']['event_list'] |
|
135 | - : $this->_extra_data['template']['event_list']; |
|
136 | - $registration = $this->_data['data']; |
|
137 | - |
|
138 | - // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion. |
|
139 | - $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
140 | - |
|
141 | - // here we're setting up the events for the event_list template for THIS registration. |
|
142 | - $all_events = $this->_get_events_from_registration($registration); |
|
143 | - |
|
144 | - // we're NOT going to prepare a list of attendees this time around |
|
145 | - $events = ''; |
|
146 | - |
|
147 | - foreach ($all_events as $event) { |
|
148 | - $events .= $this->_shortcode_helper->parse_event_list_template( |
|
149 | - $template, |
|
150 | - $event, |
|
151 | - $valid_shortcodes, |
|
152 | - $this->_extra_data |
|
153 | - ); |
|
154 | - } |
|
155 | - |
|
156 | - return $events; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @param EE_Registration $registration |
|
162 | - * @return array |
|
163 | - * @throws EE_Error |
|
164 | - * @throws ReflectionException |
|
165 | - */ |
|
166 | - private function _get_events_from_registration(EE_Registration $registration) |
|
167 | - { |
|
168 | - return isset($this->_extra_data['data']->registrations) |
|
169 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
170 | - : []; |
|
171 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _init_props() |
|
28 | + { |
|
29 | + $this->label = esc_html__('Event List Shortcodes', 'event_espresso'); |
|
30 | + $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso'); |
|
31 | + $this->_shortcodes = [ |
|
32 | + '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'), |
|
33 | + ]; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $shortcode |
|
39 | + * @return string |
|
40 | + * @throws EE_Error |
|
41 | + * @throws ReflectionException |
|
42 | + */ |
|
43 | + protected function _parser($shortcode) |
|
44 | + { |
|
45 | + if ($shortcode == '[EVENT_LIST]') { |
|
46 | + return $this->_get_event_list(); |
|
47 | + } |
|
48 | + return ''; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
54 | + * |
|
55 | + * @return string |
|
56 | + * @throws EE_Error |
|
57 | + * @throws ReflectionException |
|
58 | + */ |
|
59 | + private function _get_event_list() |
|
60 | + { |
|
61 | + $this->_validate_list_requirements(); |
|
62 | + |
|
63 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
64 | + return $this->_get_event_list_for_main(); |
|
65 | + } |
|
66 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
67 | + return $this->_get_event_list_for_registration(); |
|
68 | + } |
|
69 | + // prevent recursive loop |
|
70 | + return ''; |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * This returns the parsed event list for main template |
|
76 | + * |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + private function _get_event_list_for_main() |
|
80 | + { |
|
81 | + |
|
82 | + $valid_shortcodes = [ |
|
83 | + 'event', |
|
84 | + 'attendee_list', |
|
85 | + 'ticket_list', |
|
86 | + 'datetime_list', |
|
87 | + 'venue', |
|
88 | + 'attendee', |
|
89 | + 'recipient_list', |
|
90 | + 'recipient_details', |
|
91 | + 'primary_registration_list', |
|
92 | + 'primary_registration_details', |
|
93 | + 'event_author', |
|
94 | + 'organization', |
|
95 | + ]; |
|
96 | + $template = $this->_data['template']; |
|
97 | + $data = $this->_data['data']; |
|
98 | + $events = ''; |
|
99 | + |
|
100 | + // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper. |
|
101 | + foreach ($data->events as $event) { |
|
102 | + $events .= $this->_shortcode_helper->parse_event_list_template( |
|
103 | + $template, |
|
104 | + $event['event'], |
|
105 | + $valid_shortcodes, |
|
106 | + $this->_extra_data |
|
107 | + ); |
|
108 | + } |
|
109 | + return $events; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * This returns the parsed event list for an attendee |
|
115 | + * |
|
116 | + * @return string |
|
117 | + * @throws EE_Error |
|
118 | + * @throws ReflectionException |
|
119 | + */ |
|
120 | + private function _get_event_list_for_registration() |
|
121 | + { |
|
122 | + $valid_shortcodes = [ |
|
123 | + 'event', |
|
124 | + 'ticket_list', |
|
125 | + 'datetime_list', |
|
126 | + 'attendee', |
|
127 | + 'event_author', |
|
128 | + 'recipient_details', |
|
129 | + 'recipient_list', |
|
130 | + 'venue', |
|
131 | + 'organization', |
|
132 | + ]; |
|
133 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['event_list']) |
|
134 | + ? $this->_data['template']['event_list'] |
|
135 | + : $this->_extra_data['template']['event_list']; |
|
136 | + $registration = $this->_data['data']; |
|
137 | + |
|
138 | + // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion. |
|
139 | + $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
140 | + |
|
141 | + // here we're setting up the events for the event_list template for THIS registration. |
|
142 | + $all_events = $this->_get_events_from_registration($registration); |
|
143 | + |
|
144 | + // we're NOT going to prepare a list of attendees this time around |
|
145 | + $events = ''; |
|
146 | + |
|
147 | + foreach ($all_events as $event) { |
|
148 | + $events .= $this->_shortcode_helper->parse_event_list_template( |
|
149 | + $template, |
|
150 | + $event, |
|
151 | + $valid_shortcodes, |
|
152 | + $this->_extra_data |
|
153 | + ); |
|
154 | + } |
|
155 | + |
|
156 | + return $events; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @param EE_Registration $registration |
|
162 | + * @return array |
|
163 | + * @throws EE_Error |
|
164 | + * @throws ReflectionException |
|
165 | + */ |
|
166 | + private function _get_events_from_registration(EE_Registration $registration) |
|
167 | + { |
|
168 | + return isset($this->_extra_data['data']->registrations) |
|
169 | + ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
170 | + : []; |
|
171 | + } |
|
172 | 172 | } |