@@ -5,42 +5,42 @@ |
||
5 | 5 | <table class="admin-primary-mbox-tbl"> |
6 | 6 | <thead> |
7 | 7 | <tr> |
8 | - <th class="jst-left"><?php esc_html_e( 'Event Name', 'event_espresso' );?></th> |
|
9 | - <th class="jst-left"><?php esc_html_e( 'REG ID', 'event_espresso' );?></th> |
|
10 | - <th class="jst-left"><?php esc_html_e( 'TXN ID', 'event_espresso' );?></th> |
|
11 | - <th class="jst-left"><?php esc_html_e( 'Reg Code', 'event_espresso' );?></th> |
|
12 | - <th class="jst-rght"><?php esc_html_e( 'Ticket Price', 'event_espresso' );?></th> |
|
8 | + <th class="jst-left"><?php esc_html_e('Event Name', 'event_espresso'); ?></th> |
|
9 | + <th class="jst-left"><?php esc_html_e('REG ID', 'event_espresso'); ?></th> |
|
10 | + <th class="jst-left"><?php esc_html_e('TXN ID', 'event_espresso'); ?></th> |
|
11 | + <th class="jst-left"><?php esc_html_e('Reg Code', 'event_espresso'); ?></th> |
|
12 | + <th class="jst-rght"><?php esc_html_e('Ticket Price', 'event_espresso'); ?></th> |
|
13 | 13 | </tr> |
14 | 14 | </thead> |
15 | 15 | <tbody> |
16 | - <?php foreach( $registrations as $registration ) : ?> |
|
16 | + <?php foreach ($registrations as $registration) : ?> |
|
17 | 17 | <tr> |
18 | 18 | <td class="jst-left"> |
19 | 19 | <?php |
20 | - $event_url = add_query_arg( array( 'action' => 'edit', 'post' => $registration->event_ID() ), admin_url( 'admin.php?page=espresso_events' )); |
|
21 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $registration->event_ID() ) ? '<a href="'. $event_url .'" title="'. esc_attr__( 'Edit Event', 'event_espresso' ) .'">' . $registration->event_name() . '</a>' : $registration->event_name(); |
|
20 | + $event_url = add_query_arg(array('action' => 'edit', 'post' => $registration->event_ID()), admin_url('admin.php?page=espresso_events')); |
|
21 | + echo EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $registration->event_ID()) ? '<a href="'.$event_url.'" title="'.esc_attr__('Edit Event', 'event_espresso').'">'.$registration->event_name().'</a>' : $registration->event_name(); |
|
22 | 22 | ?> |
23 | 23 | </td> |
24 | 24 | <td class="jst-left"> |
25 | 25 | <?php |
26 | - $reg_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
|
27 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $registration->ID() ) ? ' |
|
28 | - <a href="'.$reg_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . |
|
29 | - esc_html__( 'View Registration', 'event_espresso' ) . |
|
26 | + $reg_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL); |
|
27 | + echo EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? ' |
|
28 | + <a href="'.$reg_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'. |
|
29 | + esc_html__('View Registration', 'event_espresso'). |
|
30 | 30 | '</a>' : $registration->ID(); |
31 | 31 | ?> |
32 | 32 | </td> |
33 | 33 | <td class="jst-left"> |
34 | 34 | <?php |
35 | - $txn_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID() ), TXN_ADMIN_URL ); |
|
36 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ? ' |
|
37 | - <a href="'.$txn_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '">' . |
|
38 | - sprintf( esc_html__('View Transaction %d', 'event_espresso'), $registration->transaction_ID() ) . |
|
35 | + $txn_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID()), TXN_ADMIN_URL); |
|
36 | + echo EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? ' |
|
37 | + <a href="'.$txn_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'">'. |
|
38 | + sprintf(esc_html__('View Transaction %d', 'event_espresso'), $registration->transaction_ID()). |
|
39 | 39 | '</a>' : $registration->transaction_ID(); |
40 | 40 | ?> |
41 | 41 | </td> |
42 | - <td class="jst-left"><?php echo $registration->reg_code();?></td> |
|
43 | - <td class="jst-rght"><?php echo EEH_Template::format_currency( $registration->final_price() );?></td> |
|
42 | + <td class="jst-left"><?php echo $registration->reg_code(); ?></td> |
|
43 | + <td class="jst-rght"><?php echo EEH_Template::format_currency($registration->final_price()); ?></td> |
|
44 | 44 | </tr> |
45 | 45 | <?php endforeach; ?> |
46 | 46 | </tbody> |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * given two paths, this determines if there is a common base path between the two |
284 | 284 | * |
285 | - * @param array $paths |
|
285 | + * @param string[] $paths |
|
286 | 286 | * @return string |
287 | 287 | */ |
288 | 288 | protected static function _find_common_base_path( $paths ) { |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
310 | 310 | * @param array $template_args an array of arguments to be extracted for use in the template |
311 | 311 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
312 | - * @return mixed string |
|
312 | + * @return string string |
|
313 | 313 | */ |
314 | 314 | public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
315 | 315 | //require the template validator for verifying variables are set according to how the template requires |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
3 | 3 | /** |
4 | - * Event Espresso |
|
5 | - * |
|
6 | - * Event Registration and Management Plugin for WordPress |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @author Event Espresso |
|
10 | - * @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
|
11 | - * @license http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing ** |
|
12 | - * @link http://www.eventespresso.com |
|
13 | - * @version 4.0 |
|
14 | - */ |
|
4 | + * Event Espresso |
|
5 | + * |
|
6 | + * Event Registration and Management Plugin for WordPress |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @author Event Espresso |
|
10 | + * @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
|
11 | + * @license http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing ** |
|
12 | + * @link http://www.eventespresso.com |
|
13 | + * @version 4.0 |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | |
17 | 17 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
102 | - unset( $espresso_themes[ $key ] ); |
|
102 | + unset( $espresso_themes[ $key ] ); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | 105 | foreach ( $espresso_themes as $espresso_theme ) { |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | ); |
710 | 710 | |
711 | 711 | if ( empty( $items_label ) |
712 | - || ! is_array( $items_label ) |
|
713 | - || ! isset( $items_label['single'] ) |
|
714 | - || ! isset( $items_label['plural'] ) ) { |
|
712 | + || ! is_array( $items_label ) |
|
713 | + || ! isset( $items_label['single'] ) |
|
714 | + || ! isset( $items_label['plural'] ) ) { |
|
715 | 715 | $items_label = array( |
716 | 716 | 'single' => __( '1 item', 'event_espresso' ), |
717 | 717 | 'plural' => __( '%s items', 'event_espresso' ) |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -171,26 +171,26 @@ discard block |
||
171 | 171 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
172 | 172 | * @return mixed |
173 | 173 | */ |
174 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
174 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
175 | 175 | // first use WP locate_template to check for template in the current theme folder |
176 | - $template_path = locate_template( $templates ); |
|
176 | + $template_path = locate_template($templates); |
|
177 | 177 | |
178 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
178 | + if ($check_if_custom && ! empty($template_path)) |
|
179 | 179 | return TRUE; |
180 | 180 | |
181 | 181 | // not in the theme |
182 | - if ( empty( $template_path )) { |
|
182 | + if (empty($template_path)) { |
|
183 | 183 | // not even a template to look for ? |
184 | - if ( empty( $templates )) { |
|
184 | + if (empty($templates)) { |
|
185 | 185 | // get post_type |
186 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
186 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
187 | 187 | // get array of EE Custom Post Types |
188 | 188 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
189 | 189 | // build template name based on request |
190 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
191 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
192 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
193 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
190 | + if (isset($EE_CPTs[$post_type])) { |
|
191 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
192 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
193 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | // currently active EE template theme |
@@ -199,80 +199,80 @@ discard block |
||
199 | 199 | // array of paths to folders that may contain templates |
200 | 200 | $template_folder_paths = array( |
201 | 201 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
202 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
202 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
203 | 203 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
204 | 204 | EVENT_ESPRESSO_TEMPLATE_DIR |
205 | 205 | ); |
206 | 206 | |
207 | 207 | //add core plugin folders for checking only if we're not $check_if_custom |
208 | - if ( ! $check_if_custom ) { |
|
208 | + if ( ! $check_if_custom) { |
|
209 | 209 | $core_paths = array( |
210 | 210 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
211 | - EE_PUBLIC . $current_theme, |
|
211 | + EE_PUBLIC.$current_theme, |
|
212 | 212 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
213 | - EE_TEMPLATES . $current_theme, |
|
213 | + EE_TEMPLATES.$current_theme, |
|
214 | 214 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
215 | 215 | EE_PLUGIN_DIR_PATH |
216 | 216 | ); |
217 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
217 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // now filter that array |
221 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
222 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
223 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
221 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
222 | + $templates = is_array($templates) ? $templates : array($templates); |
|
223 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
224 | 224 | // array to hold all possible template paths |
225 | 225 | $full_template_paths = array(); |
226 | 226 | |
227 | 227 | EE_Registry::instance()->load_helper('File'); |
228 | 228 | // loop through $templates |
229 | - foreach ( $templates as $template ) { |
|
229 | + foreach ($templates as $template) { |
|
230 | 230 | // normalize directory separators |
231 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
232 | - $file_name = basename( $template ); |
|
233 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
231 | + $template = EEH_File::standardise_directory_separators($template); |
|
232 | + $file_name = basename($template); |
|
233 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
234 | 234 | // while looping through all template folder paths |
235 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
235 | + foreach ($template_folder_paths as $template_folder_path) { |
|
236 | 236 | // normalize directory separators |
237 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
237 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
238 | 238 | // determine if any common base path exists between the two paths |
239 | 239 | $common_base_path = EEH_Template::_find_common_base_path( |
240 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
240 | + array($template_folder_path, $template_path_minus_file_name) |
|
241 | 241 | ); |
242 | - if ( $common_base_path !== '' ) { |
|
242 | + if ($common_base_path !== '') { |
|
243 | 243 | // both paths have a common base, so just tack the filename onto our search path |
244 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
244 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
245 | 245 | } else { |
246 | 246 | // no common base path, so let's just concatenate |
247 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
247 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
248 | 248 | } |
249 | 249 | // build up our template locations array by adding our resolved paths |
250 | 250 | $full_template_paths[] = $resolved_path; |
251 | 251 | } |
252 | 252 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
253 | - array_unshift( $full_template_paths, $template ); |
|
253 | + array_unshift($full_template_paths, $template); |
|
254 | 254 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
255 | - array_unshift( $full_template_paths, get_template_directory() . DS . $file_name ); |
|
255 | + array_unshift($full_template_paths, get_template_directory().DS.$file_name); |
|
256 | 256 | } |
257 | 257 | // filter final array of full template paths |
258 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths ); |
|
258 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths); |
|
259 | 259 | // now loop through our final array of template location paths and check each location |
260 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
261 | - if ( is_readable( $full_template_path )) { |
|
262 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
260 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
261 | + if (is_readable($full_template_path)) { |
|
262 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
263 | 263 | break; |
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
267 | 267 | // if we got it and you want to see it... |
268 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
269 | - if ( $return_string ) { |
|
270 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
268 | + if ($template_path && $load && ! $check_if_custom) { |
|
269 | + if ($return_string) { |
|
270 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
271 | 271 | } else { |
272 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
272 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
273 | 273 | } |
274 | 274 | } |
275 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
275 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -285,21 +285,21 @@ discard block |
||
285 | 285 | * @param array $paths |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - protected static function _find_common_base_path( $paths ) { |
|
288 | + protected static function _find_common_base_path($paths) { |
|
289 | 289 | $last_offset = 0; |
290 | 290 | $common_base_path = ''; |
291 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
291 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
292 | 292 | $dir_length = $index - $last_offset + 1; |
293 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
294 | - foreach ( $paths as $path ) { |
|
295 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
293 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
294 | + foreach ($paths as $path) { |
|
295 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
296 | 296 | return $common_base_path; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | $common_base_path .= $directory; |
300 | 300 | $last_offset = $index + 1; |
301 | 301 | } |
302 | - return substr( $common_base_path, 0, -1 ); |
|
302 | + return substr($common_base_path, 0, -1); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
312 | 312 | * @return mixed string |
313 | 313 | */ |
314 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
314 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
315 | 315 | //require the template validator for verifying variables are set according to how the template requires |
316 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
316 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -324,26 +324,26 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @since 4.6.0 |
326 | 326 | */ |
327 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
328 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
327 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
328 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
329 | 329 | |
330 | 330 | // you gimme nuttin - YOU GET NUTTIN !! |
331 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
331 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
332 | 332 | return ''; |
333 | 333 | } |
334 | 334 | // if $template_args are not in an array, then make it so |
335 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
336 | - $template_args = array( $template_args ); |
|
335 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
336 | + $template_args = array($template_args); |
|
337 | 337 | } |
338 | - extract( (array) $template_args); |
|
338 | + extract((array) $template_args); |
|
339 | 339 | |
340 | - if ( $return_string ) { |
|
340 | + if ($return_string) { |
|
341 | 341 | // because we want to return a string, we are going to capture the output |
342 | 342 | ob_start(); |
343 | - include( $template_path ); |
|
343 | + include($template_path); |
|
344 | 344 | return ob_get_clean(); |
345 | 345 | } else { |
346 | - include( $template_path ); |
|
346 | + include($template_path); |
|
347 | 347 | } |
348 | 348 | return ''; |
349 | 349 | } |
@@ -361,27 +361,27 @@ discard block |
||
361 | 361 | * @param string $suffix added to the end of the generated class |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
364 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
365 | 365 | // in the beginning... |
366 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
366 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
367 | 367 | // da muddle |
368 | 368 | $class = ''; |
369 | 369 | // the end |
370 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
370 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
371 | 371 | // is the passed object an EE object ? |
372 | - if ( $object instanceof EE_Base_Class ) { |
|
372 | + if ($object instanceof EE_Base_Class) { |
|
373 | 373 | // grab the exact type of object |
374 | - $obj_class = get_class( $object ); |
|
374 | + $obj_class = get_class($object); |
|
375 | 375 | // depending on the type of object... |
376 | - switch ( $obj_class ) { |
|
376 | + switch ($obj_class) { |
|
377 | 377 | // no specifics just yet... |
378 | 378 | default : |
379 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
380 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
379 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
380 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | } |
384 | - return $prefix . $class . $suffix; |
|
384 | + return $prefix.$class.$suffix; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -397,50 +397,50 @@ discard block |
||
397 | 397 | * @param string $cur_code_span_class |
398 | 398 | * @return string the html output for the formatted money value |
399 | 399 | */ |
400 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
400 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
401 | 401 | // ensure amount was received |
402 | - if ( is_null( $amount ) ) { |
|
403 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
404 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
402 | + if (is_null($amount)) { |
|
403 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
404 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
405 | 405 | return ''; |
406 | 406 | } |
407 | 407 | //ensure amount is float |
408 | 408 | $amount = (float) $amount; |
409 | 409 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
410 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
410 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
411 | 411 | // still a number or was amount converted to a string like "free" ? |
412 | - if ( is_float( $amount_formatted )) { |
|
412 | + if (is_float($amount_formatted)) { |
|
413 | 413 | // was a country ISO code passed ? if so generate currency config object for that country |
414 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
414 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
415 | 415 | // verify results |
416 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
416 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
417 | 417 | // set default config country currency settings |
418 | 418 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
419 | 419 | } |
420 | 420 | // format float |
421 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
421 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
422 | 422 | // add formatting ? |
423 | - if ( ! $return_raw ) { |
|
423 | + if ( ! $return_raw) { |
|
424 | 424 | // add currency sign |
425 | - if( $mny->sign_b4 ){ |
|
426 | - if( $amount >= 0 ){ |
|
427 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
428 | - }else{ |
|
429 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
425 | + if ($mny->sign_b4) { |
|
426 | + if ($amount >= 0) { |
|
427 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
428 | + } else { |
|
429 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
430 | 430 | } |
431 | 431 | |
432 | - }else{ |
|
433 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
432 | + } else { |
|
433 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | // add currency code ? |
437 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
437 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
438 | 438 | } |
439 | 439 | // filter results |
440 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
440 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
441 | 441 | } |
442 | 442 | // clean up vars |
443 | - unset( $mny ); |
|
443 | + unset($mny); |
|
444 | 444 | // return formatted currency amount |
445 | 445 | return $amount_formatted; |
446 | 446 | } |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
456 | 456 | * @return string The localized label for the status id. |
457 | 457 | */ |
458 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
458 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
459 | 459 | /** @type EEM_Status $EEM_Status */ |
460 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
461 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
462 | - return $status[ $status_id ]; |
|
460 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
461 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
462 | + return $status[$status_id]; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | * @param string $icon |
473 | 473 | * @return string the html output for the button |
474 | 474 | */ |
475 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
476 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
477 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
475 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
476 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
477 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
478 | 478 | return $button; |
479 | 479 | } |
480 | 480 | |
@@ -491,21 +491,21 @@ discard block |
||
491 | 491 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
492 | 492 | * @return string generated link |
493 | 493 | */ |
494 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
494 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
495 | 495 | |
496 | - if ( ! $page ) |
|
497 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
496 | + if ( ! $page) |
|
497 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
498 | 498 | |
499 | - if ( ! $action ) |
|
500 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
499 | + if ( ! $action) |
|
500 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
501 | 501 | |
502 | 502 | $action = empty($action) ? 'default' : $action; |
503 | 503 | |
504 | 504 | |
505 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
506 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
507 | - $help_text = !$help_text ? '' : $help_text; |
|
508 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
505 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
506 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
507 | + $help_text = ! $help_text ? '' : $help_text; |
|
508 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -517,31 +517,31 @@ discard block |
||
517 | 517 | * @param EE_Help_Tour |
518 | 518 | * @return string html |
519 | 519 | */ |
520 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
520 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
521 | 521 | $id = $tour->get_slug(); |
522 | 522 | $stops = $tour->get_stops(); |
523 | 523 | |
524 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
524 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
525 | 525 | |
526 | - foreach ( $stops as $stop ) { |
|
527 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
528 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
526 | + foreach ($stops as $stop) { |
|
527 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
528 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
529 | 529 | |
530 | 530 | //if container is set to modal then let's make sure we set the options accordingly |
531 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
531 | + if (empty($data_id) && empty($data_class)) { |
|
532 | 532 | $stop['options']['modal'] = true; |
533 | 533 | $stop['options']['expose'] = true; |
534 | 534 | } |
535 | 535 | |
536 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
537 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
536 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
537 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
538 | 538 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
539 | 539 | |
540 | 540 | //options |
541 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
541 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
542 | 542 | $options = ' data-options="'; |
543 | - foreach ( $stop['options'] as $option => $value ) { |
|
544 | - $options .= $option . ':' . $value . ';'; |
|
543 | + foreach ($stop['options'] as $option => $value) { |
|
544 | + $options .= $option.':'.$value.';'; |
|
545 | 545 | } |
546 | 546 | $options .= '"'; |
547 | 547 | } else { |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | |
551 | 551 | //let's put all together |
552 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
552 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | $content .= '</ol>'; |
@@ -570,31 +570,31 @@ discard block |
||
570 | 570 | * @throws EE_Error |
571 | 571 | * @return string html structure for status. |
572 | 572 | */ |
573 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
574 | - if ( !is_array( $status_array ) ) |
|
575 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
573 | + public static function status_legend($status_array, $active_status = '') { |
|
574 | + if ( ! is_array($status_array)) |
|
575 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
576 | 576 | |
577 | 577 | $setup_array = array(); |
578 | - foreach ( $status_array as $item => $status ) { |
|
578 | + foreach ($status_array as $item => $status) { |
|
579 | 579 | $setup_array[$item] = array( |
580 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
581 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
580 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
581 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
582 | 582 | 'status' => $status |
583 | 583 | ); |
584 | 584 | } |
585 | 585 | |
586 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
587 | - $content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
588 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
589 | - foreach ( $setup_array as $item => $details ) { |
|
586 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
587 | + $content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
588 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
589 | + foreach ($setup_array as $item => $details) { |
|
590 | 590 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
591 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
592 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
593 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
594 | - $content .= '</dt>' . "\n"; |
|
591 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
592 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
593 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
594 | + $content .= '</dt>'."\n"; |
|
595 | 595 | } |
596 | - $content .= '</dl>' . "\n"; |
|
597 | - $content .= '</div>' . "\n"; |
|
596 | + $content .= '</dl>'."\n"; |
|
597 | + $content .= '</div>'."\n"; |
|
598 | 598 | return $content; |
599 | 599 | } |
600 | 600 | |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | * @return string |
608 | 608 | */ |
609 | 609 | public static function layout_array_as_table($data) { |
610 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
611 | - $data = (array)$data; |
|
610 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
611 | + $data = (array) $data; |
|
612 | 612 | } |
613 | 613 | EE_Registry::instance()->load_helper('Array'); |
614 | 614 | ob_start(); |
@@ -622,10 +622,10 @@ discard block |
||
622 | 622 | ?> |
623 | 623 | <tr> |
624 | 624 | <td> |
625 | - <?php echo $data_key;?> |
|
625 | + <?php echo $data_key; ?> |
|
626 | 626 | </td> |
627 | 627 | <td> |
628 | - <?php echo self::layout_array_as_table($data_values);?> |
|
628 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
629 | 629 | </td> |
630 | 630 | </tr> |
631 | 631 | <?php |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | <ul> |
640 | 640 | <?php |
641 | 641 | foreach ($data as $datum) { |
642 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
642 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
643 | 643 | }?> |
644 | 644 | </ul> |
645 | 645 | <?php |
@@ -669,8 +669,8 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @return string |
671 | 671 | */ |
672 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
673 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
672 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
673 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | * ) |
695 | 695 | * @return string |
696 | 696 | */ |
697 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
697 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
698 | 698 | $page_links = array(); |
699 | 699 | $disable_first = $disable_last = ''; |
700 | 700 | $total_items = (int) $total_items; |
701 | 701 | $per_page = (int) $per_page; |
702 | 702 | $current = (int) $current; |
703 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
703 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
704 | 704 | |
705 | 705 | //filter items_label |
706 | 706 | $items_label = apply_filters( |
@@ -708,68 +708,68 @@ discard block |
||
708 | 708 | $items_label |
709 | 709 | ); |
710 | 710 | |
711 | - if ( empty( $items_label ) |
|
712 | - || ! is_array( $items_label ) |
|
713 | - || ! isset( $items_label['single'] ) |
|
714 | - || ! isset( $items_label['plural'] ) ) { |
|
711 | + if (empty($items_label) |
|
712 | + || ! is_array($items_label) |
|
713 | + || ! isset($items_label['single']) |
|
714 | + || ! isset($items_label['plural'])) { |
|
715 | 715 | $items_label = array( |
716 | - 'single' => __( '1 item', 'event_espresso' ), |
|
717 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
716 | + 'single' => __('1 item', 'event_espresso'), |
|
717 | + 'plural' => __('%s items', 'event_espresso') |
|
718 | 718 | ); |
719 | 719 | } else { |
720 | 720 | $items_label = array( |
721 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
722 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
721 | + 'single' => '1 '.esc_html($items_label['single']), |
|
722 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
723 | 723 | ); |
724 | 724 | } |
725 | 725 | |
726 | - $total_pages = ceil( $total_items / $per_page ); |
|
726 | + $total_pages = ceil($total_items / $per_page); |
|
727 | 727 | |
728 | - if ( $total_pages <= 1 ) |
|
728 | + if ($total_pages <= 1) |
|
729 | 729 | return ''; |
730 | 730 | |
731 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
731 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
732 | 732 | |
733 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
733 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
734 | 734 | |
735 | - if ( $current === 1 ) { |
|
735 | + if ($current === 1) { |
|
736 | 736 | $disable_first = ' disabled'; |
737 | 737 | } |
738 | - if ( $current == $total_pages ) { |
|
738 | + if ($current == $total_pages) { |
|
739 | 739 | $disable_last = ' disabled'; |
740 | 740 | } |
741 | 741 | |
742 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
743 | - 'first-page' . $disable_first, |
|
744 | - esc_attr__( 'Go to the first page' ), |
|
745 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
742 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
743 | + 'first-page'.$disable_first, |
|
744 | + esc_attr__('Go to the first page'), |
|
745 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
746 | 746 | '«' |
747 | 747 | ); |
748 | 748 | |
749 | 749 | $page_links[] = sprintf( |
750 | 750 | '<a class="%s" title="%s" href="%s">%s</a>', |
751 | - 'prev-page' . $disable_first, |
|
752 | - esc_attr__( 'Go to the previous page' ), |
|
753 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
751 | + 'prev-page'.$disable_first, |
|
752 | + esc_attr__('Go to the previous page'), |
|
753 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
754 | 754 | '‹' |
755 | 755 | ); |
756 | 756 | |
757 | - if ( ! $show_num_field ) { |
|
757 | + if ( ! $show_num_field) { |
|
758 | 758 | $html_current_page = $current; |
759 | 759 | } else { |
760 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
761 | - esc_attr__( 'Current page' ), |
|
760 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
761 | + esc_attr__('Current page'), |
|
762 | 762 | $current, |
763 | - strlen( $total_pages ) |
|
763 | + strlen($total_pages) |
|
764 | 764 | ); |
765 | 765 | } |
766 | 766 | |
767 | 767 | $html_total_pages = sprintf( |
768 | 768 | '<span class="total-pages">%s</span>', |
769 | - number_format_i18n( $total_pages ) |
|
769 | + number_format_i18n($total_pages) |
|
770 | 770 | ); |
771 | 771 | $page_links[] = sprintf( |
772 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
772 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
773 | 773 | $html_current_page, |
774 | 774 | $html_total_pages, |
775 | 775 | '<span class="paging-input">', |
@@ -778,29 +778,29 @@ discard block |
||
778 | 778 | |
779 | 779 | $page_links[] = sprintf( |
780 | 780 | '<a class="%s" title="%s" href="%s">%s</a>', |
781 | - 'next-page' . $disable_last, |
|
782 | - esc_attr__( 'Go to the next page' ), |
|
783 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
781 | + 'next-page'.$disable_last, |
|
782 | + esc_attr__('Go to the next page'), |
|
783 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
784 | 784 | '›' |
785 | 785 | ); |
786 | 786 | |
787 | 787 | $page_links[] = sprintf( |
788 | 788 | '<a class="%s" title="%s" href="%s">%s</a>', |
789 | - 'last-page' . $disable_last, |
|
790 | - esc_attr__( 'Go to the last page' ), |
|
791 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
789 | + 'last-page'.$disable_last, |
|
790 | + esc_attr__('Go to the last page'), |
|
791 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
792 | 792 | '»' |
793 | 793 | ); |
794 | 794 | |
795 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
795 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
796 | 796 | // set page class |
797 | - if ( $total_pages ) { |
|
797 | + if ($total_pages) { |
|
798 | 798 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
799 | 799 | } else { |
800 | 800 | $page_class = ' no-pages'; |
801 | 801 | } |
802 | 802 | |
803 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
803 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
804 | 804 | } |
805 | 805 | |
806 | 806 |
@@ -32,7 +32,6 @@ |
||
32 | 32 | /** |
33 | 33 | * |
34 | 34 | * @param string $model_name |
35 | - * @param string $comparison_model_name |
|
36 | 35 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 36 | * @return EE_Model_Field_Base |
38 | 37 | */ |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Joins any two models together via a has-and-belongs-to-many relation, using |
|
4 | - * the esp_extra_join table. |
|
5 | - */ |
|
3 | + * Joins any two models together via a has-and-belongs-to-many relation, using |
|
4 | + * the esp_extra_join table. |
|
5 | + */ |
|
6 | 6 | class EE_HABTM_Any_Relation extends EE_HABTM_Relation{ |
7 | 7 | /** |
8 | 8 | * |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Joins any two models together via a has-and-belongs-to-many relation, using |
4 | 4 | * the esp_extra_join table. |
5 | 5 | */ |
6 | -class EE_HABTM_Any_Relation extends EE_HABTM_Relation{ |
|
6 | +class EE_HABTM_Any_Relation extends EE_HABTM_Relation { |
|
7 | 7 | /** |
8 | 8 | * |
9 | 9 | * @var string |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model |
18 | 18 | * @param type $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
19 | 19 | */ |
20 | - function __construct( $block_deletes = true, $blocking_delete_error_message =''){ |
|
21 | - parent::__construct( 'Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
20 | + function __construct($block_deletes = true, $blocking_delete_error_message = '') { |
|
21 | + parent::__construct('Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
22 | 22 | } |
23 | - function _construct_finalize_set_models($this_model_name, $other_model_name){ |
|
24 | - if( $this_model_name < $other_model_name ) { |
|
23 | + function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
24 | + if ($this_model_name < $other_model_name) { |
|
25 | 25 | $this->_alphabetically_first_model_name = $this_model_name; |
26 | - } else{ |
|
26 | + } else { |
|
27 | 27 | $this->_alphabetically_first_model_name = $other_model_name; |
28 | 28 | } |
29 | - return parent::_construct_finalize_set_models( $this_model_name, $other_model_name ); |
|
29 | + return parent::_construct_finalize_set_models($this_model_name, $other_model_name); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 37 | * @return EE_Model_Field_Base |
38 | 38 | */ |
39 | - function get_join_table_fk_field_to( $model_name, $id_or_name_field ) { |
|
39 | + function get_join_table_fk_field_to($model_name, $id_or_name_field) { |
|
40 | 40 | $order = null; |
41 | - if( $model_name === $this->_alphabetically_first_model_name ) { |
|
41 | + if ($model_name === $this->_alphabetically_first_model_name) { |
|
42 | 42 | $order = 'first'; |
43 | 43 | } else { |
44 | 44 | $order = 'second'; |
45 | 45 | } |
46 | - return $this->get_join_model()->field_settings_for( 'EXJ_' . $order . '_model_' . $id_or_name_field ); |
|
46 | + return $this->get_join_model()->field_settings_for('EXJ_'.$order.'_model_'.$id_or_name_field); |
|
47 | 47 | } |
48 | 48 | /** |
49 | 49 | * Gets the SQL string for joining the main model's table containing the pk to the join table. Eg "LEFT JOIN real_join_table AS join_table_alias ON this_table_alias.pk = join_table_alias.fk_to_this_table" |
50 | 50 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
51 | 51 | * @return string of SQL |
52 | 52 | */ |
53 | - function get_join_to_intermediate_model_statement($model_relation_chain){ |
|
53 | + function get_join_to_intermediate_model_statement($model_relation_chain) { |
|
54 | 54 | //create sql like |
55 | 55 | //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this |
56 | 56 | //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $field_with_model_name = $this->get_join_table_fk_field_to( |
65 | 65 | $this->get_this_model()->get_this_model_name(), |
66 | 66 | 'name' ); |
67 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
68 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
67 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
68 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
69 | 69 | $join_table = $this->get_join_model()->get_table_for_alias($join_table_alias); |
70 | 70 | //phew! ok, we have all the info we need, now we can create the SQL join string |
71 | 71 | $SQL = $this->_left_join( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $join_table_fk_field_to_this_table->get_table_column(), |
75 | 75 | $this_table_alias, |
76 | 76 | $this_table_pk_field->get_table_column(), |
77 | - $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ) . |
|
77 | + $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ). |
|
78 | 78 | $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
79 | 79 | |
80 | 80 | return $SQL; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
88 | 88 | * @return string of SQL |
89 | 89 | */ |
90 | - function get_join_statement($model_relation_chain){ |
|
91 | - if( $this->_model_relation_chain_to_join_model === NULL ){ |
|
92 | - throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' ))); |
|
90 | + function get_join_statement($model_relation_chain) { |
|
91 | + if ($this->_model_relation_chain_to_join_model === NULL) { |
|
92 | + throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso'))); |
|
93 | 93 | } |
94 | 94 | $join_table_fk_field_to_this_table = $this->get_join_table_fk_field_to( |
95 | 95 | $this->get_this_model()->get_this_model_name(), |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $this->get_other_model()->get_this_model_name(), |
102 | 102 | 'name' ); |
103 | 103 | |
104 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
104 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
105 | 105 | |
106 | 106 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
107 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
107 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
108 | 108 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
109 | 109 | |
110 | 110 | $SQL = $this->_left_join( |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $join_table_alias, |
115 | 115 | $join_table_fk_field_to_other_table->get_table_column(), |
116 | 116 | $field_with_other_model_name->get_qualified_column()."='".$this->get_other_model()->get_this_model_name()."'" |
117 | - ) . |
|
117 | + ). |
|
118 | 118 | $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
119 | 119 | return $SQL; |
120 | 120 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param array $extra_join_model_fields_n_values col=>val pairs that are used as extra conditions for checking existing values and for setting new rows if no exact matches. |
127 | 127 | * @return EE_Base_Class |
128 | 128 | */ |
129 | - function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
129 | + function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
130 | 130 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
131 | 131 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
132 | 132 | //check if such a relationship already exists |
@@ -143,31 +143,31 @@ discard block |
||
143 | 143 | $this->get_other_model()->get_this_model_name(), |
144 | 144 | 'name' ); |
145 | 145 | |
146 | - $cols_n_values = array( |
|
146 | + $cols_n_values = array( |
|
147 | 147 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
148 | 148 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
149 | 149 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
150 | 150 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
151 | 151 | |
152 | 152 | //if $where_query exists lets add them to the query_params. |
153 | - if ( !empty( $extra_join_model_fields_n_values ) ) { |
|
153 | + if ( ! empty($extra_join_model_fields_n_values)) { |
|
154 | 154 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
155 | 155 | //make sure we strip THIS models name from the query param |
156 | - foreach ( $extra_join_model_fields_n_values as $query_param => $val ) { |
|
157 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
156 | + foreach ($extra_join_model_fields_n_values as $query_param => $val) { |
|
157 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
158 | 158 | $parsed_query[$query_param] = $val; |
159 | 159 | } |
160 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
160 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
161 | 161 | } |
162 | 162 | |
163 | - $query_params = array( $cols_n_values ); |
|
163 | + $query_params = array($cols_n_values); |
|
164 | 164 | |
165 | 165 | |
166 | 166 | $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params); |
167 | 167 | //if there is already an entry in the join table, indicating a relationship, we're done |
168 | 168 | //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to |
169 | 169 | //the other tables, use the joining model directly! |
170 | - if( ! $existing_entry_in_join_table ){ |
|
170 | + if ( ! $existing_entry_in_join_table) { |
|
171 | 171 | $this->get_join_model()->insert($cols_n_values); |
172 | 172 | } |
173 | 173 | return $other_model_obj; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * * @param array $where_query col=>val pairs that are used as extra conditions for checking existing values and for removing existing rows if exact matches exist. |
180 | 180 | * @return EE_Base_Class |
181 | 181 | */ |
182 | - function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
182 | + function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
183 | 183 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
184 | 184 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
185 | 185 | //check if such a relationship already exists |
@@ -196,24 +196,24 @@ discard block |
||
196 | 196 | $this->get_other_model()->get_this_model_name(), |
197 | 197 | 'name' ); |
198 | 198 | |
199 | - $cols_n_values = array( |
|
199 | + $cols_n_values = array( |
|
200 | 200 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
201 | 201 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
202 | 202 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
203 | 203 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
204 | 204 | |
205 | 205 | //if $where_query exists lets add them to the query_params. |
206 | - if ( !empty( $where_query ) ) { |
|
206 | + if ( ! empty($where_query)) { |
|
207 | 207 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
208 | 208 | //make sure we strip THIS models name from the query param |
209 | - foreach ( $where_query as $query_param => $val ) { |
|
210 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
209 | + foreach ($where_query as $query_param => $val) { |
|
210 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
211 | 211 | $parsed_query[$query_param] = $val; |
212 | 212 | } |
213 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
213 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
214 | 214 | } |
215 | 215 | |
216 | - $existing_entry_in_join_table = $this->get_join_model()->delete( array($cols_n_values) ); |
|
216 | + $existing_entry_in_join_table = $this->get_join_model()->delete(array($cols_n_values)); |
|
217 | 217 | return $other_model_obj; |
218 | 218 | } |
219 | 219 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Contains definition for EE_Extra_Join model object |
|
4 | - * @package Event Espresso |
|
5 | - * @subpackage models |
|
6 | - * @since $VID$ |
|
7 | - */ |
|
3 | + * Contains definition for EE_Extra_Join model object |
|
4 | + * @package Event Espresso |
|
5 | + * @subpackage models |
|
6 | + * @since $VID$ |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * EE_Extra_Join |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param null $timezone |
23 | 23 | * @return EE_Event_Message_Template|mixed |
24 | 24 | */ |
25 | - public static function new_instance( $props_n_values = array(), $timezone = NULL ) { |
|
26 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
27 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
25 | + public static function new_instance($props_n_values = array(), $timezone = NULL) { |
|
26 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
27 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param null $timezone |
35 | 35 | * @return EE_Event_Message_Template |
36 | 36 | */ |
37 | - public static function new_instance_from_db ( $props_n_values = array(), $timezone = NULL ) { |
|
38 | - return new self( $props_n_values, TRUE, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = NULL) { |
|
38 | + return new self($props_n_values, TRUE, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -21,26 +21,26 @@ |
||
21 | 21 | * @since $VID:$ |
22 | 22 | * |
23 | 23 | */ |
24 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | 25 | exit('No direct script access allowed'); |
26 | 26 | } |
27 | 27 | |
28 | -class EEM_Extra_Join extends EEM_Base{ |
|
28 | +class EEM_Extra_Join extends EEM_Base { |
|
29 | 29 | // private instance of the Extra Join object |
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | 32 | public function __construct($timezone = NULL) { |
33 | - $models_this_can_join = array_keys( EE_Registry::instance()->non_abstract_db_models ); |
|
33 | + $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
34 | 34 | $this->_tables = array( |
35 | - 'Extra_Join' => new EE_Primary_Table( 'esp_extra_join', 'EXJ_ID' ), |
|
35 | + 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
36 | 36 | ); |
37 | 37 | $this->_fields = array( |
38 | 38 | 'Extra_Join' => array( |
39 | - 'EXJ_ID' => new EE_Primary_Key_Int_Field( 'EXJ_ID', __( 'Extra Join ID', 'event_espresso' ) ), |
|
40 | - 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_first_model_ID', __( 'First Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
41 | - 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_first_model_name', __( 'First Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
42 | - 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_second_model_ID', __( 'Second Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
43 | - 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_second_model_name', __( 'Second Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
39 | + 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
40 | + 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
41 | + 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
42 | + 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
43 | + 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
44 | 44 | |
45 | 45 | ) |
46 | 46 | ); |
@@ -443,7 +443,7 @@ |
||
443 | 443 | /** |
444 | 444 | * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
445 | 445 | * |
446 | - * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the stati |
|
446 | + * @param string[] $stati_to_include If included you can restrict the statuses we return counts for by including the stati |
|
447 | 447 | * you want counts for as values in the array. An empty array returns counts for all valid |
448 | 448 | * stati. |
449 | 449 | * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. only for |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,27 +35,27 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Datetime','event_espresso'); |
|
40 | - $this->plural_item = __('Datetimes','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
40 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Datetime'=>array( |
47 | - 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')), |
|
48 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
47 | + 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
48 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
49 | 49 | 'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''), |
50 | 50 | 'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''), |
51 | - 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ), |
|
52 | - 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ), |
|
53 | - 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF), |
|
54 | - 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ), |
|
55 | - 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false), |
|
51 | + 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
54 | + 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0), |
|
55 | + 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
56 | 56 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
57 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
58 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
57 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
58 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
59 | 59 | )); |
60 | 60 | $this->_model_relations = array( |
61 | 61 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | ); |
65 | 65 | $this->_model_chain_to_wp_user = 'Event'; |
66 | 66 | //this model is generally available for reading |
67 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
71 | - parent::__construct( $timezone ); |
|
67 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
71 | + parent::__construct($timezone); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | public function create_new_blank_datetime() { |
84 | 84 | $blank_datetime = EE_Datetime::new_instance( |
85 | 85 | array( |
86 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
87 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
86 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
88 | 88 | 'DTT_order' => 1, |
89 | 89 | 'DTT_reg_limit' => EE_INF |
90 | 90 | ), |
91 | 91 | $this->_timezone |
92 | 92 | ); |
93 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
94 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
95 | - return array( $blank_datetime ); |
|
93 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
94 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
95 | + return array($blank_datetime); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param int $EVT_ID |
107 | 107 | * @return EE_Datetime[] array on success, FALSE on fail |
108 | 108 | */ |
109 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
110 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
109 | + public function get_all_event_dates($EVT_ID = 0) { |
|
110 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
111 | 111 | return $this->create_new_blank_datetime(); |
112 | 112 | } |
113 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
113 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | 114 | |
115 | - if ( empty( $results ) ) { |
|
115 | + if (empty($results)) { |
|
116 | 116 | return $this->create_new_blank_datetime(); |
117 | 117 | } |
118 | 118 | |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | * the given number |
134 | 134 | * @return EE_Datetime[] |
135 | 135 | */ |
136 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
136 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
137 | 137 | |
138 | 138 | //sanitize EVT_ID |
139 | - $EVT_ID = intval( $EVT_ID ); |
|
139 | + $EVT_ID = intval($EVT_ID); |
|
140 | 140 | |
141 | 141 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
142 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
143 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
142 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
143 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
144 | 144 | |
145 | - $query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ); |
|
145 | + $query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none'); |
|
146 | 146 | |
147 | - if( ! $include_expired){ |
|
148 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
147 | + if ( ! $include_expired) { |
|
148 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
149 | 149 | } |
150 | - if( $include_deleted){ |
|
151 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
150 | + if ($include_deleted) { |
|
151 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
152 | 152 | } |
153 | 153 | |
154 | - $result = $this->get_all( $query_params ); |
|
155 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
154 | + $result = $this->get_all($query_params); |
|
155 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
156 | 156 | return $result; |
157 | 157 | } |
158 | 158 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param int $limit |
168 | 168 | * @return EE_Datetime[] |
169 | 169 | */ |
170 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
171 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
170 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
171 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
172 | 172 | 'limit'=>$limit, |
173 | 173 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
174 | 174 | 'default_where_conditions' => 'none')); |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param boolean $include_deleted |
184 | 184 | * @return EE_Datetime |
185 | 185 | */ |
186 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
187 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | - if($results){ |
|
186 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
187 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | + if ($results) { |
|
189 | 189 | return array_shift($results); |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return NULL; |
192 | 192 | } |
193 | 193 | } |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | * @param bool $try_to_exclude_deleted |
202 | 202 | * @return \EE_Datetime |
203 | 203 | */ |
204 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
205 | - if($try_to_exclude_expired){ |
|
206 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
207 | - if($non_expired){ |
|
204 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
205 | + if ($try_to_exclude_expired) { |
|
206 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
207 | + if ($non_expired) { |
|
208 | 208 | return $non_expired; |
209 | 209 | } |
210 | 210 | } |
211 | - if($try_to_exclude_deleted){ |
|
211 | + if ($try_to_exclude_deleted) { |
|
212 | 212 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
213 | - if($expired_even){ |
|
213 | + if ($expired_even) { |
|
214 | 214 | return $expired_even; |
215 | 215 | } |
216 | 216 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * @param int $limit |
230 | 230 | * @return EE_Datetime[] |
231 | 231 | */ |
232 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
232 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
233 | 233 | //sanitize EVT_ID |
234 | - $EVT_ID = intval( $EVT_ID ); |
|
234 | + $EVT_ID = intval($EVT_ID); |
|
235 | 235 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
236 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
237 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | - if( ! $include_expired){ |
|
239 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
236 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
237 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | + if ( ! $include_expired) { |
|
239 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
240 | 240 | } |
241 | - if( $include_deleted){ |
|
242 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
241 | + if ($include_deleted) { |
|
242 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
243 | 243 | } |
244 | - if($limit){ |
|
244 | + if ($limit) { |
|
245 | 245 | $query_params['limit'] = $limit; |
246 | 246 | } |
247 | - $result = $this->get_all( $query_params ); |
|
248 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
247 | + $result = $this->get_all($query_params); |
|
248 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
249 | 249 | return $result; |
250 | 250 | } |
251 | 251 | |
@@ -258,23 +258,23 @@ discard block |
||
258 | 258 | * @param int $limit |
259 | 259 | * @return EE_Datetime[] |
260 | 260 | */ |
261 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
261 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
262 | 262 | //sanitize TKT_ID |
263 | - $TKT_ID = intval( $TKT_ID ); |
|
263 | + $TKT_ID = intval($TKT_ID); |
|
264 | 264 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
265 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
266 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | - if( ! $include_expired){ |
|
268 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
265 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
266 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | + if ( ! $include_expired) { |
|
268 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
269 | 269 | } |
270 | - if( $include_deleted){ |
|
271 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
270 | + if ($include_deleted) { |
|
271 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
272 | 272 | } |
273 | - if($limit){ |
|
273 | + if ($limit) { |
|
274 | 274 | $query_params['limit'] = $limit; |
275 | 275 | } |
276 | - $result = $this->get_all( $query_params ); |
|
277 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
276 | + $result = $this->get_all($query_params); |
|
277 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
278 | 278 | return $result; |
279 | 279 | } |
280 | 280 | |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | * that number |
291 | 291 | * @return EE_Datetime[] |
292 | 292 | */ |
293 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
293 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
294 | 294 | //sanitize id. |
295 | - $TKT_ID = intval( $TKT_ID ); |
|
295 | + $TKT_ID = intval($TKT_ID); |
|
296 | 296 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
297 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
298 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
299 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
300 | - if( ! $include_expired){ |
|
301 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
297 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
298 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
299 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
300 | + if ( ! $include_expired) { |
|
301 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
302 | 302 | } |
303 | - if( $include_deleted){ |
|
304 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
303 | + if ($include_deleted) { |
|
304 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
305 | 305 | } |
306 | - if($limit){ |
|
306 | + if ($limit) { |
|
307 | 307 | $query_params['limit'] = $limit; |
308 | 308 | } |
309 | - $result = $this->get_all( $query_params ); |
|
310 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
309 | + $result = $this->get_all($query_params); |
|
310 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
311 | 311 | return $result; |
312 | 312 | } |
313 | 313 | |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | * @param int $EVT_ID |
319 | 319 | * @return EE_Datetime |
320 | 320 | */ |
321 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
321 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
322 | 322 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
323 | - if($results){ |
|
323 | + if ($results) { |
|
324 | 324 | return array_shift($results); |
325 | - }else{ |
|
325 | + } else { |
|
326 | 326 | return null; |
327 | 327 | } |
328 | 328 | } |
@@ -341,71 +341,71 @@ discard block |
||
341 | 341 | * - inactive = Events that are either not published. |
342 | 342 | * @return wpdb results array |
343 | 343 | */ |
344 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
344 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
345 | 345 | |
346 | - switch ( $evt_active_status ) { |
|
346 | + switch ($evt_active_status) { |
|
347 | 347 | case 'upcoming' : |
348 | 348 | $where_params['Event.status'] = 'publish'; |
349 | 349 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
350 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
350 | + if (isset($where_params['DTT_EVT_start'])) { |
|
351 | 351 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
352 | 352 | } |
353 | - $where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query( 'DTT_EVT_start' ) ); |
|
353 | + $where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query('DTT_EVT_start')); |
|
354 | 354 | break; |
355 | 355 | |
356 | 356 | case 'expired' : |
357 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
357 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
358 | 358 | //get events to exclude |
359 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $this->current_time_for_query( 'DTT_EVT_end' ) ) ) ); |
|
359 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $this->current_time_for_query('DTT_EVT_end')))); |
|
360 | 360 | //first get all events that have datetimes where its not expired. |
361 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
362 | - $event_ids = array_keys( $event_ids ); |
|
361 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
362 | + $event_ids = array_keys($event_ids); |
|
363 | 363 | |
364 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
364 | + if (isset($where_params['DTT_EVT_end'])) { |
|
365 | 365 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
366 | 366 | } |
367 | - $where_params['DTT_EVT_end'] = array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); |
|
368 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
367 | + $where_params['DTT_EVT_end'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); |
|
368 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
369 | 369 | break; |
370 | 370 | |
371 | 371 | case 'active' : |
372 | 372 | $where_params['Event.status'] = 'publish'; |
373 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
373 | + if (isset($where_params['DTT_EVT_start'])) { |
|
374 | 374 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
375 | 375 | } |
376 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
376 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
377 | 377 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
378 | 378 | } |
379 | - $where_params['DTT_EVT_start'] = array('<', $this->current_time_for_query( 'DTT_EVT_start' ) ); |
|
380 | - $where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query( 'DTT_EVT_end' ) ); |
|
379 | + $where_params['DTT_EVT_start'] = array('<', $this->current_time_for_query('DTT_EVT_start')); |
|
380 | + $where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query('DTT_EVT_end')); |
|
381 | 381 | break; |
382 | 382 | |
383 | 383 | case 'inactive' : |
384 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
385 | - if ( isset( $where_params['OR'] ) ) { |
|
384 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
385 | + if (isset($where_params['OR'])) { |
|
386 | 386 | $where_params['AND']['OR'] = $where_params['OR']; |
387 | 387 | } |
388 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
388 | + if (isset($where_params['DTT_EVT_end'])) { |
|
389 | 389 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
390 | - unset( $where_params['DTT_EVT_end'] ); |
|
390 | + unset($where_params['DTT_EVT_end']); |
|
391 | 391 | } |
392 | 392 | |
393 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
393 | + if (isset($where_params['DTT_EVT_start'])) { |
|
394 | 394 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
395 | - unset( $where_params['DTT_EVT_start'] ); |
|
395 | + unset($where_params['DTT_EVT_start']); |
|
396 | 396 | } |
397 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
397 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
398 | 398 | break; |
399 | 399 | } |
400 | 400 | |
401 | 401 | $query_params[0] = $where_params; |
402 | 402 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
403 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
403 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
404 | 404 | $columns_to_select = array( |
405 | 405 | 'dtt_year' => array('YEAR(DTT_EVT_start)', '%s'), |
406 | 406 | 'dtt_month' => array('MONTHNAME(DTT_EVT_start)', '%s') |
407 | 407 | ); |
408 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
408 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * for the tickets for each datetime) |
414 | 414 | * @param EE_Datetime[] $datetimes |
415 | 415 | */ |
416 | - public function update_sold($datetimes){ |
|
417 | - foreach($datetimes as $datetime){ |
|
416 | + public function update_sold($datetimes) { |
|
417 | + foreach ($datetimes as $datetime) { |
|
418 | 418 | $datetime->update_sold(); |
419 | 419 | } |
420 | 420 | } |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | * @param array $query_params |
430 | 430 | * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO tickets attached to datetime then FALSE is returned. |
431 | 431 | */ |
432 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
433 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
434 | - if ( $datetime instanceof EE_Datetime ) { |
|
435 | - return $datetime->tickets_remaining( $query_params ); |
|
432 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
433 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
434 | + if ($datetime instanceof EE_Datetime) { |
|
435 | + return $datetime->tickets_remaining($query_params); |
|
436 | 436 | } |
437 | 437 | return 0; |
438 | 438 | } |
@@ -454,36 +454,36 @@ discard block |
||
454 | 454 | * EE_Datetime::upcoming |
455 | 455 | * EE_Datetime::expired |
456 | 456 | */ |
457 | - public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) { |
|
457 | + public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) { |
|
458 | 458 | //only accept where conditions for this query. |
459 | - $_where = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
459 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
460 | 460 | $status_query_args = array( |
461 | 461 | EE_Datetime::active => array_merge( |
462 | 462 | $_where, |
463 | - array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) ) |
|
463 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
464 | 464 | ), |
465 | 465 | EE_Datetime::upcoming => array_merge( |
466 | 466 | $_where, |
467 | - array( 'DTT_EVT_start' => array( '>', time() ) ) |
|
467 | + array('DTT_EVT_start' => array('>', time())) |
|
468 | 468 | ), |
469 | 469 | EE_Datetime::expired => array_merge( |
470 | 470 | $_where, |
471 | - array( 'DTT_EVT_end' => array('<', time() ) ) |
|
471 | + array('DTT_EVT_end' => array('<', time())) |
|
472 | 472 | ) |
473 | 473 | ); |
474 | 474 | |
475 | - if ( ! empty( $stati_to_include ) ) { |
|
476 | - foreach( array_keys( $status_query_args ) as $status ) { |
|
477 | - if ( ! in_array( $status, $stati_to_include ) ) { |
|
478 | - unset( $status_query_args[$status] ); |
|
475 | + if ( ! empty($stati_to_include)) { |
|
476 | + foreach (array_keys($status_query_args) as $status) { |
|
477 | + if ( ! in_array($status, $stati_to_include)) { |
|
478 | + unset($status_query_args[$status]); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | 483 | //loop through and query counts for each stati. |
484 | 484 | $status_query_results = array(); |
485 | - foreach( $status_query_args as $status => $status_where_conditions ) { |
|
486 | - $status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true ); |
|
485 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
486 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | return $status_query_results; |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | * @param array $query_params |
498 | 498 | * @return int |
499 | 499 | */ |
500 | - public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) { |
|
501 | - $count = $this->get_datetime_counts_by_status( array( $status ), $query_params ); |
|
502 | - return ! empty( $count[$status] ) ? $count[$status] : 0; |
|
500 | + public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) { |
|
501 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
502 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
503 | 503 | } |
504 | 504 | |
505 | 505 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * date_format and the second value is the time format |
51 | 51 | * @return EE_Event |
52 | 52 | */ |
53 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
54 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
55 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
53 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
54 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
55 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * the website will be used. |
64 | 64 | * @return EE_Event |
65 | 65 | */ |
66 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
67 | - return new self( $props_n_values, TRUE, $timezone ); |
|
66 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
67 | + return new self($props_n_values, TRUE, $timezone); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @param array $query_params like EEM_Base::get_all |
76 | 76 | * @return EE_Datetime[] |
77 | 77 | */ |
78 | - public function datetimes( $query_params = array() ) { |
|
79 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
78 | + public function datetimes($query_params = array()) { |
|
79 | + return $this->get_many_related('Datetime', $query_params); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return EE_Datetime[] |
88 | 88 | */ |
89 | 89 | public function datetimes_in_chronological_order() { |
90 | - return $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) ); |
|
90 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * @param null $limit |
104 | 104 | * @return \EE_Datetime[] |
105 | 105 | */ |
106 | - public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) { |
|
107 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted, $limit ); |
|
106 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) { |
|
107 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted, $limit); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return EE_Datetime |
115 | 115 | */ |
116 | 116 | public function first_datetime() { |
117 | - return $this->get_first_related( 'Datetime' ); |
|
117 | + return $this->get_first_related('Datetime'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * @param bool $try_to_exclude_deleted |
126 | 126 | * @return EE_Datetime |
127 | 127 | */ |
128 | - public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) { |
|
129 | - if ( !empty ( $this->_Primary_Datetime ) ) { |
|
128 | + public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) { |
|
129 | + if ( ! empty ($this->_Primary_Datetime)) { |
|
130 | 130 | return $this->_Primary_Datetime; |
131 | 131 | } |
132 | - $this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted ); |
|
132 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted); |
|
133 | 133 | return $this->_Primary_Datetime; |
134 | 134 | } |
135 | 135 | |
@@ -140,30 +140,30 @@ discard block |
||
140 | 140 | * @param array $query_params like EEM_Base::get_all |
141 | 141 | * @return EE_Ticket[] |
142 | 142 | */ |
143 | - public function tickets( $query_params = array() ) { |
|
143 | + public function tickets($query_params = array()) { |
|
144 | 144 | //first get all datetimes |
145 | 145 | $datetimes = $this->datetimes_ordered(); |
146 | - if ( ! $datetimes ) { |
|
146 | + if ( ! $datetimes) { |
|
147 | 147 | return array(); |
148 | 148 | } |
149 | 149 | |
150 | 150 | $datetime_ids = array(); |
151 | - foreach ( $datetimes as $datetime ) { |
|
151 | + foreach ($datetimes as $datetime) { |
|
152 | 152 | $datetime_ids[] = $datetime->ID(); |
153 | 153 | } |
154 | 154 | |
155 | - $where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) ); |
|
155 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
156 | 156 | |
157 | 157 | //if incoming $query_params has where conditions let's merge but not override existing. |
158 | - if ( is_array( $query_params ) && isset( $query_params[0]) ) { |
|
159 | - $where_params = array_merge( $query_params[0], $where_params ); |
|
160 | - unset( $query_params[0] ); |
|
158 | + if (is_array($query_params) && isset($query_params[0])) { |
|
159 | + $where_params = array_merge($query_params[0], $where_params); |
|
160 | + unset($query_params[0]); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | //now add $where_params to $query_params |
164 | 164 | $query_params[0] = $where_params; |
165 | 165 | |
166 | - return EEM_Ticket::instance()->get_all( $query_params ); |
|
166 | + return EEM_Ticket::instance()->get_all($query_params); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return bool |
173 | 173 | */ |
174 | 174 | function additional_limit() { |
175 | - return $this->get( 'EVT_additional_limit' ); |
|
175 | + return $this->get('EVT_additional_limit'); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return bool |
182 | 182 | */ |
183 | 183 | function allow_overflow() { |
184 | - return $this->get( 'EVT_allow_overflow' ); |
|
184 | + return $this->get('EVT_allow_overflow'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return bool |
191 | 191 | */ |
192 | 192 | function created() { |
193 | - return $this->get( 'EVT_created' ); |
|
193 | + return $this->get('EVT_created'); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return bool |
200 | 200 | */ |
201 | 201 | function description() { |
202 | - return $this->get( 'EVT_desc' ); |
|
202 | + return $this->get('EVT_desc'); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return string of html |
210 | 210 | */ |
211 | 211 | function description_filtered() { |
212 | - return $this->get_pretty( 'EVT_desc' ); |
|
212 | + return $this->get_pretty('EVT_desc'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @return bool |
219 | 219 | */ |
220 | 220 | function display_description() { |
221 | - return $this->get( 'EVT_display_desc' ); |
|
221 | + return $this->get('EVT_display_desc'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @return bool |
228 | 228 | */ |
229 | 229 | function display_ticket_selector() { |
230 | - return (bool)$this->get( 'EVT_display_ticket_selector' ); |
|
230 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @return bool |
237 | 237 | */ |
238 | 238 | function external_url() { |
239 | - return $this->get( 'EVT_external_URL' ); |
|
239 | + return $this->get('EVT_external_URL'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @return bool |
246 | 246 | */ |
247 | 247 | function member_only() { |
248 | - return $this->get( 'EVT_member_only' ); |
|
248 | + return $this->get('EVT_member_only'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @return bool |
255 | 255 | */ |
256 | 256 | function phone() { |
257 | - return $this->get( 'EVT_phone' ); |
|
257 | + return $this->get('EVT_phone'); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @return bool |
264 | 264 | */ |
265 | 265 | function modified() { |
266 | - return $this->get( 'EVT_modified' ); |
|
266 | + return $this->get('EVT_modified'); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return bool |
273 | 273 | */ |
274 | 274 | function name() { |
275 | - return $this->get( 'EVT_name' ); |
|
275 | + return $this->get('EVT_name'); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @return bool |
282 | 282 | */ |
283 | 283 | function order() { |
284 | - return $this->get( 'EVT_order' ); |
|
284 | + return $this->get('EVT_order'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @return bool|string |
291 | 291 | */ |
292 | 292 | function default_registration_status() { |
293 | - $event_default_registration_status = $this->get( 'EVT_default_registration_status' ); |
|
294 | - return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
293 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
294 | + return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | * @param bool $not_full_desc |
303 | 303 | * @return bool|string |
304 | 304 | */ |
305 | - function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) { |
|
306 | - $short_desc = $this->get( 'EVT_short_desc' ); |
|
307 | - if ( !empty( $short_desc ) || $not_full_desc ) { |
|
305 | + function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) { |
|
306 | + $short_desc = $this->get('EVT_short_desc'); |
|
307 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
308 | 308 | return $short_desc; |
309 | 309 | } |
310 | 310 | else { |
311 | - $full_desc = $this->get( 'EVT_desc' ); |
|
312 | - return wp_trim_words( $full_desc, $num_words, $more ); |
|
311 | + $full_desc = $this->get('EVT_desc'); |
|
312 | + return wp_trim_words($full_desc, $num_words, $more); |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return bool |
320 | 320 | */ |
321 | 321 | function slug() { |
322 | - return $this->get( 'EVT_slug' ); |
|
322 | + return $this->get('EVT_slug'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return bool |
329 | 329 | */ |
330 | 330 | function timezone_string() { |
331 | - return $this->get( 'EVT_timezone_string' ); |
|
331 | + return $this->get('EVT_timezone_string'); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @return bool |
338 | 338 | */ |
339 | 339 | function visible_on() { |
340 | - return $this->get( 'EVT_visible_on' ); |
|
340 | + return $this->get('EVT_visible_on'); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @return bool |
347 | 347 | */ |
348 | 348 | function wp_user() { |
349 | - return $this->get( 'EVT_wp_user' ); |
|
349 | + return $this->get('EVT_wp_user'); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return bool |
356 | 356 | */ |
357 | 357 | function donations() { |
358 | - return $this->get( 'EVT_donations' ); |
|
358 | + return $this->get('EVT_donations'); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | /** |
364 | 364 | * @param $limit |
365 | 365 | */ |
366 | - function set_additional_limit( $limit ) { |
|
367 | - $this->set( 'EVT_additional_limit', $limit ); |
|
366 | + function set_additional_limit($limit) { |
|
367 | + $this->set('EVT_additional_limit', $limit); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | /** |
373 | 373 | * @param $created |
374 | 374 | */ |
375 | - function set_created( $created ) { |
|
376 | - $this->set( 'EVT_created', $created ); |
|
375 | + function set_created($created) { |
|
376 | + $this->set('EVT_created', $created); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | /** |
382 | 382 | * @param $desc |
383 | 383 | */ |
384 | - function set_description( $desc ) { |
|
385 | - $this->set( 'EVT_desc', $desc ); |
|
384 | + function set_description($desc) { |
|
385 | + $this->set('EVT_desc', $desc); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @param $display_desc |
392 | 392 | */ |
393 | - function set_display_description( $display_desc ) { |
|
394 | - $this->set( 'EVT_display_desc', $display_desc ); |
|
393 | + function set_display_description($display_desc) { |
|
394 | + $this->set('EVT_display_desc', $display_desc); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | /** |
400 | 400 | * @param $display_ticket_selector |
401 | 401 | */ |
402 | - function set_display_ticket_selector( $display_ticket_selector ) { |
|
403 | - $this->set( 'EVT_display_ticket_selector', $display_ticket_selector ); |
|
402 | + function set_display_ticket_selector($display_ticket_selector) { |
|
403 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | /** |
409 | 409 | * @param $external_url |
410 | 410 | */ |
411 | - function set_external_url( $external_url ) { |
|
412 | - $this->set( 'EVT_external_URL', $external_url ); |
|
411 | + function set_external_url($external_url) { |
|
412 | + $this->set('EVT_external_URL', $external_url); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | /** |
418 | 418 | * @param $member_only |
419 | 419 | */ |
420 | - function set_member_only( $member_only ) { |
|
421 | - $this->set( 'EVT_member_only', $member_only ); |
|
420 | + function set_member_only($member_only) { |
|
421 | + $this->set('EVT_member_only', $member_only); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | /** |
427 | 427 | * @param $event_phone |
428 | 428 | */ |
429 | - function set_event_phone( $event_phone ) { |
|
430 | - $this->set( 'EVT_phone', $event_phone ); |
|
429 | + function set_event_phone($event_phone) { |
|
430 | + $this->set('EVT_phone', $event_phone); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | /** |
436 | 436 | * @param $modified |
437 | 437 | */ |
438 | - function set_modified( $modified ) { |
|
439 | - $this->set( 'EVT_modified', $modified ); |
|
438 | + function set_modified($modified) { |
|
439 | + $this->set('EVT_modified', $modified); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | /** |
445 | 445 | * @param $name |
446 | 446 | */ |
447 | - function set_name( $name ) { |
|
448 | - $this->set( 'EVT_name', $name ); |
|
447 | + function set_name($name) { |
|
448 | + $this->set('EVT_name', $name); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | /** |
454 | 454 | * @param $order |
455 | 455 | */ |
456 | - function set_order( $order ) { |
|
457 | - $this->set( 'EVT_order', $order ); |
|
456 | + function set_order($order) { |
|
457 | + $this->set('EVT_order', $order); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | /** |
463 | 463 | * @param $short_desc |
464 | 464 | */ |
465 | - function set_short_description( $short_desc ) { |
|
466 | - $this->set( 'EVT_short_desc', $short_desc ); |
|
465 | + function set_short_description($short_desc) { |
|
466 | + $this->set('EVT_short_desc', $short_desc); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | /** |
472 | 472 | * @param $slug |
473 | 473 | */ |
474 | - function set_slug( $slug ) { |
|
475 | - $this->set( 'EVT_slug', $slug ); |
|
474 | + function set_slug($slug) { |
|
475 | + $this->set('EVT_slug', $slug); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | /** |
481 | 481 | * @param $timezone_string |
482 | 482 | */ |
483 | - function set_timezone_string( $timezone_string ) { |
|
484 | - $this->set( 'EVT_timezone_string', $timezone_string ); |
|
483 | + function set_timezone_string($timezone_string) { |
|
484 | + $this->set('EVT_timezone_string', $timezone_string); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | /** |
490 | 490 | * @param $visible_on |
491 | 491 | */ |
492 | - function set_visible_on( $visible_on ) { |
|
493 | - $this->set( 'EVT_visible_on', $visible_on ); |
|
492 | + function set_visible_on($visible_on) { |
|
493 | + $this->set('EVT_visible_on', $visible_on); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | /** |
499 | 499 | * @param $wp_user |
500 | 500 | */ |
501 | - function set_wp_user( $wp_user ) { |
|
502 | - $this->set( 'EVT_wp_user', $wp_user ); |
|
501 | + function set_wp_user($wp_user) { |
|
502 | + $this->set('EVT_wp_user', $wp_user); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | /** |
508 | 508 | * @param $default_registration_status |
509 | 509 | */ |
510 | - function set_default_registration_status( $default_registration_status ) { |
|
511 | - $this->set( 'EVT_default_registration_status', $default_registration_status ); |
|
510 | + function set_default_registration_status($default_registration_status) { |
|
511 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | /** |
517 | 517 | * @param $donations |
518 | 518 | */ |
519 | - function set_donations( $donations ) { |
|
520 | - $this->set( 'EVT_donations', $donations ); |
|
519 | + function set_donations($donations) { |
|
520 | + $this->set('EVT_donations', $donations); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | * @param EE_Venue /int $venue_id_or_obj |
528 | 528 | * @return EE_Venue |
529 | 529 | */ |
530 | - function add_venue( $venue_id_or_obj ) { |
|
531 | - return $this->_add_relation_to( $venue_id_or_obj, 'Venue' ); |
|
530 | + function add_venue($venue_id_or_obj) { |
|
531 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | * @param EE_Venue /int $venue_id_or_obj |
539 | 539 | * @return EE_Venue |
540 | 540 | */ |
541 | - function remove_venue( $venue_id_or_obj ) { |
|
542 | - return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' ); |
|
541 | + function remove_venue($venue_id_or_obj) { |
|
542 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @param array $query_params like EEM_Base::get_all's $query_params |
550 | 550 | * @return EE_Venue[] |
551 | 551 | */ |
552 | - function venues( $query_params = array() ) { |
|
553 | - return $this->get_many_related( 'Venue', $query_params ); |
|
552 | + function venues($query_params = array()) { |
|
553 | + return $this->get_many_related('Venue', $query_params); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | */ |
563 | 563 | private function _has_ID_and_is_published() { |
564 | 564 | // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
565 | - return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE; |
|
565 | + return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE; |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
@@ -574,21 +574,21 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function is_upcoming() { |
576 | 576 | // check if event id is present and if this event is published |
577 | - if ( $this->is_inactive() ) { |
|
577 | + if ($this->is_inactive()) { |
|
578 | 578 | return FALSE; |
579 | 579 | } |
580 | 580 | // set initial value |
581 | 581 | $upcoming = FALSE; |
582 | 582 | //next let's get all datetimes and loop through them |
583 | 583 | $datetimes = $this->datetimes_in_chronological_order(); |
584 | - foreach ( $datetimes as $datetime ) { |
|
585 | - if ( $datetime instanceof EE_Datetime ) { |
|
584 | + foreach ($datetimes as $datetime) { |
|
585 | + if ($datetime instanceof EE_Datetime) { |
|
586 | 586 | //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
587 | - if ( $datetime->is_expired() ) { |
|
587 | + if ($datetime->is_expired()) { |
|
588 | 588 | continue; |
589 | 589 | } |
590 | 590 | //if this dtt is active then we return false. |
591 | - if ( $datetime->is_active() ) { |
|
591 | + if ($datetime->is_active()) { |
|
592 | 592 | return FALSE; |
593 | 593 | } |
594 | 594 | //otherwise let's check upcoming status |
@@ -605,21 +605,21 @@ discard block |
||
605 | 605 | */ |
606 | 606 | public function is_active() { |
607 | 607 | // check if event id is present and if this event is published |
608 | - if ( $this->is_inactive() ) { |
|
608 | + if ($this->is_inactive()) { |
|
609 | 609 | return FALSE; |
610 | 610 | } |
611 | 611 | // set initial value |
612 | 612 | $active = FALSE; |
613 | 613 | //next let's get all datetimes and loop through them |
614 | 614 | $datetimes = $this->datetimes_in_chronological_order(); |
615 | - foreach ( $datetimes as $datetime ) { |
|
616 | - if ( $datetime instanceof EE_Datetime ) { |
|
615 | + foreach ($datetimes as $datetime) { |
|
616 | + if ($datetime instanceof EE_Datetime) { |
|
617 | 617 | //if this dtt is expired then we continue cause one of the other datetimes might be active. |
618 | - if ( $datetime->is_expired() ) { |
|
618 | + if ($datetime->is_expired()) { |
|
619 | 619 | continue; |
620 | 620 | } |
621 | 621 | //if this dtt is upcoming then we return false. |
622 | - if ( $datetime->is_upcoming() ) { |
|
622 | + if ($datetime->is_upcoming()) { |
|
623 | 623 | return FALSE; |
624 | 624 | } |
625 | 625 | //otherwise let's check active status |
@@ -636,17 +636,17 @@ discard block |
||
636 | 636 | */ |
637 | 637 | public function is_expired() { |
638 | 638 | // check if event id is present and if this event is published |
639 | - if ( $this->is_inactive() ) { |
|
639 | + if ($this->is_inactive()) { |
|
640 | 640 | return FALSE; |
641 | 641 | } |
642 | 642 | // set initial value |
643 | 643 | $expired = FALSE; |
644 | 644 | //first let's get all datetimes and loop through them |
645 | 645 | $datetimes = $this->datetimes_in_chronological_order(); |
646 | - foreach ( $datetimes as $datetime ) { |
|
647 | - if ( $datetime instanceof EE_Datetime ) { |
|
646 | + foreach ($datetimes as $datetime) { |
|
647 | + if ($datetime instanceof EE_Datetime) { |
|
648 | 648 | //if this dtt is upcoming or active then we return false. |
649 | - if ( $datetime->is_upcoming() || $datetime->is_active() ) { |
|
649 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
650 | 650 | return FALSE; |
651 | 651 | } |
652 | 652 | //otherwise let's check active status |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | public function is_inactive() { |
665 | 665 | // check if event id is present and if this event is published |
666 | - if ( $this->_has_ID_and_is_published() ) { |
|
666 | + if ($this->_has_ID_and_is_published()) { |
|
667 | 667 | return FALSE; |
668 | 668 | } |
669 | 669 | return TRUE; |
@@ -681,26 +681,26 @@ discard block |
||
681 | 681 | */ |
682 | 682 | public function perform_sold_out_status_check() { |
683 | 683 | // get all unexpired untrashed tickets |
684 | - $tickets = $this->tickets( array( |
|
684 | + $tickets = $this->tickets(array( |
|
685 | 685 | array( |
686 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
686 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
687 | 687 | 'TKT_deleted' => false |
688 | 688 | ) |
689 | 689 | )); |
690 | 690 | // if all the tickets are just expired, then don't update the event status to sold out |
691 | - if ( empty( $tickets )) { |
|
691 | + if (empty($tickets)) { |
|
692 | 692 | return true; |
693 | 693 | } |
694 | 694 | // set initial value |
695 | 695 | $spaces_remaining = 0; |
696 | - foreach( $tickets as $ticket ) { |
|
697 | - if ( $ticket instanceof EE_Ticket ) { |
|
698 | - $spaces_remaining += $ticket->qty( 'saleable' ); |
|
696 | + foreach ($tickets as $ticket) { |
|
697 | + if ($ticket instanceof EE_Ticket) { |
|
698 | + $spaces_remaining += $ticket->qty('saleable'); |
|
699 | 699 | } |
700 | 700 | } |
701 | - if ( $spaces_remaining === 0 ) { |
|
702 | - $this->set_status( EEM_Event::sold_out ); |
|
703 | - if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) { |
|
701 | + if ($spaces_remaining === 0) { |
|
702 | + $this->set_status(EEM_Event::sold_out); |
|
703 | + if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
704 | 704 | $this->save(); |
705 | 705 | } |
706 | 706 | $sold_out = TRUE; |
@@ -728,15 +728,15 @@ discard block |
||
728 | 728 | */ |
729 | 729 | public function spaces_remaining_for_sale() { |
730 | 730 | //first get total available spaces including consideration for tickets that have already sold. |
731 | - $spaces_available = $this->total_available_spaces( true ); |
|
731 | + $spaces_available = $this->total_available_spaces(true); |
|
732 | 732 | |
733 | 733 | //if total available = 0, then exit right away because that means everything is expired. |
734 | - if ( $spaces_available === 0 ) { |
|
734 | + if ($spaces_available === 0) { |
|
735 | 735 | return 0; |
736 | 736 | } |
737 | 737 | |
738 | 738 | //subtract total approved registrations from spaces available to get how many are remaining. |
739 | - $spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
739 | + $spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
740 | 740 | $spaces_remaining = $spaces_available - $spots_taken; |
741 | 741 | |
742 | 742 | return $spaces_remaining > 0 ? $spaces_remaining : 0; |
@@ -769,29 +769,29 @@ discard block |
||
769 | 769 | * |
770 | 770 | * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
771 | 771 | */ |
772 | - public function total_available_spaces( $current_total_available = false ) { |
|
772 | + public function total_available_spaces($current_total_available = false) { |
|
773 | 773 | $spaces_available = 0; |
774 | 774 | |
775 | 775 | //first get all tickets on the event and include expired tickets |
776 | - $tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) ); |
|
776 | + $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
777 | 777 | $ticket_sums = array(); |
778 | 778 | $datetime_limits = array(); |
779 | 779 | |
780 | 780 | //loop through tickets and normalize them |
781 | - foreach ( $tickets as $ticket ) { |
|
782 | - $datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
781 | + foreach ($tickets as $ticket) { |
|
782 | + $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
783 | 783 | |
784 | - if ( empty( $datetimes ) ) { |
|
784 | + if (empty($datetimes)) { |
|
785 | 785 | continue; |
786 | 786 | } |
787 | 787 | |
788 | 788 | //first datetime should be the lowest datetime |
789 | - $least_datetime = reset( $datetimes ); |
|
789 | + $least_datetime = reset($datetimes); |
|
790 | 790 | |
791 | 791 | //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
792 | 792 | //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
793 | - if ( $current_total_available ) { |
|
794 | - if ( $ticket->is_remaining() ) { |
|
793 | + if ($current_total_available) { |
|
794 | + if ($ticket->is_remaining()) { |
|
795 | 795 | $remaining = $ticket->remaining(); |
796 | 796 | } else { |
797 | 797 | $spaces_available += $ticket->sold(); |
@@ -799,23 +799,23 @@ discard block |
||
799 | 799 | continue; |
800 | 800 | } |
801 | 801 | } else { |
802 | - $remaining = min( $ticket->qty(), $least_datetime->reg_limit() ); |
|
802 | + $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
806 | - if ( $remaining == EE_INF ) { |
|
806 | + if ($remaining == EE_INF) { |
|
807 | 807 | return EE_INF; |
808 | 808 | } |
809 | 809 | |
810 | 810 | //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
811 | 811 | //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
812 | - $ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes ); |
|
812 | + $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
813 | 813 | $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
814 | - foreach ( $datetimes as $datetime ) { |
|
815 | - if ( $datetime->reg_limit() === EE_INF ) { |
|
814 | + foreach ($datetimes as $datetime) { |
|
815 | + if ($datetime->reg_limit() === EE_INF) { |
|
816 | 816 | $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
817 | 817 | } else { |
818 | - $ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
818 | + $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
819 | 819 | } |
820 | 820 | $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
821 | 821 | } |
@@ -826,74 +826,74 @@ discard block |
||
826 | 826 | //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
827 | 827 | //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
828 | 828 | //$current_total_available ) for the datetimes on the ticket. |
829 | - usort( $ticket_sums, function( $a, $b ) { |
|
830 | - if ( $a['sum'] == $b['sum'] ) { |
|
831 | - if ( $a['datetime_sums'] == $b['datetime_sums'] ) { |
|
829 | + usort($ticket_sums, function($a, $b) { |
|
830 | + if ($a['sum'] == $b['sum']) { |
|
831 | + if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
832 | 832 | return 0; |
833 | 833 | } |
834 | 834 | |
835 | 835 | return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
836 | 836 | } |
837 | - return ( $a['sum'] < $b['sum'] ) ? -1 : 1; |
|
837 | + return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
838 | 838 | }); |
839 | 839 | |
840 | 840 | //now let's loop through the sorted tickets and simulate sellouts |
841 | - foreach ( $ticket_sums as $ticket_info ) { |
|
842 | - if ( $ticket_info['ticket'] instanceof EE_Ticket ) { |
|
841 | + foreach ($ticket_sums as $ticket_info) { |
|
842 | + if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
843 | 843 | |
844 | - $datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
844 | + $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
845 | 845 | //need to sort these $datetimes by remaining (only if $current_total_available) |
846 | 846 | //setup datetimes for simulation |
847 | 847 | $ticket_datetimes_remaining = array(); |
848 | - foreach( $datetimes as $datetime ) { |
|
848 | + foreach ($datetimes as $datetime) { |
|
849 | 849 | $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
850 | 850 | $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
851 | 851 | } |
852 | - usort( $ticket_datetimes_remaining, function( $a, $b ) { |
|
853 | - if ( $a['rem'] == $b['rem'] ) { |
|
852 | + usort($ticket_datetimes_remaining, function($a, $b) { |
|
853 | + if ($a['rem'] == $b['rem']) { |
|
854 | 854 | return 0; |
855 | 855 | } |
856 | - return ( $a['rem'] < $b['rem'] ) ? -1 : 1; |
|
856 | + return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
857 | 857 | }); |
858 | 858 | |
859 | 859 | |
860 | 860 | //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
861 | 861 | //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
862 | - $lowest_datetime = reset( $ticket_datetimes_remaining ); |
|
862 | + $lowest_datetime = reset($ticket_datetimes_remaining); |
|
863 | 863 | |
864 | 864 | //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
865 | 865 | // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
866 | 866 | // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
867 | 867 | // to the next ticket. |
868 | - if ( $current_total_available ) { |
|
869 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() ); |
|
868 | + if ($current_total_available) { |
|
869 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
870 | 870 | } else { |
871 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->qty() ); |
|
871 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
875 | 875 | //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
876 | 876 | //available. |
877 | - if ( $remaining === EE_INF ) { |
|
877 | + if ($remaining === EE_INF) { |
|
878 | 878 | $spaces_available += $ticket_info['ticket']->qty(); |
879 | 879 | continue; |
880 | 880 | } |
881 | 881 | |
882 | 882 | //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
883 | - if ( $current_total_available ) { |
|
883 | + if ($current_total_available) { |
|
884 | 884 | $spaces_available += $ticket_info['ticket']->sold(); |
885 | 885 | } |
886 | 886 | |
887 | - if ( $remaining <= 0 ) { |
|
887 | + if ($remaining <= 0) { |
|
888 | 888 | continue; |
889 | 889 | } else { |
890 | 890 | $spaces_available += $remaining; |
891 | 891 | } |
892 | 892 | |
893 | 893 | //loop through the datetimes and sell them out! |
894 | - foreach ( $ticket_datetimes_remaining as $datetime_info ) { |
|
895 | - if ( $datetime_info['datetime'] instanceof EE_Datetime ) { |
|
896 | - $datetime_limits[ $datetime_info['datetime']->ID() ] += - $remaining; |
|
894 | + foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
895 | + if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
896 | + $datetime_limits[$datetime_info['datetime']->ID()] += - $remaining; |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | } |
@@ -909,8 +909,8 @@ discard block |
||
909 | 909 | * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event |
910 | 910 | * @return boolean |
911 | 911 | */ |
912 | - public function is_sold_out( $actual = FALSE ) { |
|
913 | - if ( ! $actual ) { |
|
912 | + public function is_sold_out($actual = FALSE) { |
|
913 | + if ( ! $actual) { |
|
914 | 914 | return $this->status() == EEM_Event::sold_out; |
915 | 915 | } |
916 | 916 | else { |
@@ -955,30 +955,30 @@ discard block |
||
955 | 955 | * |
956 | 956 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
957 | 957 | */ |
958 | - public function get_active_status( $reset = false ) { |
|
958 | + public function get_active_status($reset = false) { |
|
959 | 959 | // if the active status has already been set, then just use that value (unless we are resetting it) |
960 | - if ( ! empty( $this->_active_status ) && ! $reset ) { |
|
960 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
961 | 961 | return $this->_active_status; |
962 | 962 | } |
963 | 963 | //first check if event id is present on this object |
964 | - if ( ! $this->ID() ) { |
|
964 | + if ( ! $this->ID()) { |
|
965 | 965 | return false; |
966 | 966 | } |
967 | 967 | |
968 | - $where_params_for_event = array( array( 'EVT_ID' => $this->ID() ) ); |
|
968 | + $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
969 | 969 | |
970 | 970 | //if event is published: |
971 | - if ( $this->status() === 'publish' ) { |
|
971 | + if ($this->status() === 'publish') { |
|
972 | 972 | //active? |
973 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::active, $where_params_for_event ) > 0 ) { |
|
973 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) > 0) { |
|
974 | 974 | $this->_active_status = EE_Datetime::active; |
975 | 975 | } else { |
976 | 976 | //upcoming? |
977 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::upcoming, $where_params_for_event ) > 0 ) { |
|
977 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0) { |
|
978 | 978 | $this->_active_status = EE_Datetime::upcoming; |
979 | 979 | } else { |
980 | 980 | //expired? |
981 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::expired, $where_params_for_event ) > 0 ) { |
|
981 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0) { |
|
982 | 982 | $this->_active_status = EE_Datetime::expired; |
983 | 983 | } else { |
984 | 984 | //it would be odd if things make it this far because it basically means there are no datetime's |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | } |
990 | 990 | } else { |
991 | 991 | //the event is not published, so let's just set it's active status according to its' post status |
992 | - switch ( $this->status() ) { |
|
992 | + switch ($this->status()) { |
|
993 | 993 | case EEM_Event::sold_out : |
994 | 994 | $this->_active_status = EE_Datetime::sold_out; |
995 | 995 | break; |
@@ -1015,10 +1015,10 @@ discard block |
||
1015 | 1015 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1016 | 1016 | * @return mixed void|string |
1017 | 1017 | */ |
1018 | - public function pretty_active_status( $echo = TRUE ) { |
|
1018 | + public function pretty_active_status($echo = TRUE) { |
|
1019 | 1019 | $active_status = $this->get_active_status(); |
1020 | - $status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>'; |
|
1021 | - if ( $echo ) { |
|
1020 | + $status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>'; |
|
1021 | + if ($echo) { |
|
1022 | 1022 | echo $status; |
1023 | 1023 | return ''; |
1024 | 1024 | } |
@@ -1032,12 +1032,12 @@ discard block |
||
1032 | 1032 | */ |
1033 | 1033 | public function get_number_of_tickets_sold() { |
1034 | 1034 | $tkt_sold = 0; |
1035 | - if ( !$this->ID() ) { |
|
1035 | + if ( ! $this->ID()) { |
|
1036 | 1036 | return 0; |
1037 | 1037 | } |
1038 | 1038 | $datetimes = $this->datetimes(); |
1039 | - foreach ( $datetimes as $datetime ) { |
|
1040 | - if ( $datetime instanceof EE_Datetime ) { |
|
1039 | + foreach ($datetimes as $datetime) { |
|
1040 | + if ($datetime instanceof EE_Datetime) { |
|
1041 | 1041 | $tkt_sold += $datetime->sold(); |
1042 | 1042 | } |
1043 | 1043 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | * @return int |
1053 | 1053 | */ |
1054 | 1054 | public function get_count_of_all_registrations() { |
1055 | - return EEM_Event::instance()->count_related( $this, 'Registration' ); |
|
1055 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | |
@@ -1062,9 +1062,9 @@ discard block |
||
1062 | 1062 | * @return EE_Ticket |
1063 | 1063 | */ |
1064 | 1064 | public function get_ticket_with_earliest_start_time() { |
1065 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1066 | - $query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) ); |
|
1067 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1065 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1066 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1067 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | |
@@ -1074,9 +1074,9 @@ discard block |
||
1074 | 1074 | * @return EE_Ticket |
1075 | 1075 | */ |
1076 | 1076 | public function get_ticket_with_latest_end_time() { |
1077 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1078 | - $query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) ); |
|
1079 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1077 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1078 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1079 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | |
@@ -1088,11 +1088,11 @@ discard block |
||
1088 | 1088 | public function tickets_on_sale() { |
1089 | 1089 | $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
1090 | 1090 | $latest_ticket = $this->get_ticket_with_latest_end_time(); |
1091 | - if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) { |
|
1091 | + if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
1092 | 1092 | return FALSE; |
1093 | 1093 | } |
1094 | 1094 | //check on sale for these two tickets. |
1095 | - if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) { |
|
1095 | + if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
1096 | 1096 | return TRUE; |
1097 | 1097 | } |
1098 | 1098 | return FALSE; |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | * @return string |
1107 | 1107 | */ |
1108 | 1108 | public function get_permalink() { |
1109 | - if ( $this->external_url() ) { |
|
1109 | + if ($this->external_url()) { |
|
1110 | 1110 | return $this->external_url(); |
1111 | 1111 | } |
1112 | 1112 | else { |
@@ -1121,10 +1121,10 @@ discard block |
||
1121 | 1121 | * @param array $query_params like EEM_Base::get_all |
1122 | 1122 | * @return EE_Term |
1123 | 1123 | */ |
1124 | - public function first_event_category( $query_params = array() ) { |
|
1125 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1126 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1127 | - return EEM_Term::instance()->get_one( $query_params ); |
|
1124 | + public function first_event_category($query_params = array()) { |
|
1125 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1126 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1127 | + return EEM_Term::instance()->get_one($query_params); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | |
@@ -1134,10 +1134,10 @@ discard block |
||
1134 | 1134 | * @param array $query_params |
1135 | 1135 | * @return EE_Term[] |
1136 | 1136 | */ |
1137 | - public function get_all_event_categories( $query_params = array() ) { |
|
1138 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1139 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1140 | - return EEM_Term::instance()->get_all( $query_params ); |
|
1137 | + public function get_all_event_categories($query_params = array()) { |
|
1138 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1139 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1140 | + return EEM_Term::instance()->get_all($query_params); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | /** |
@@ -1145,8 +1145,8 @@ discard block |
||
1145 | 1145 | * @param array $query_params @see EEM_Base::get_all |
1146 | 1146 | * @return EE_Question_Group[] |
1147 | 1147 | */ |
1148 | - public function question_groups($query_params = array()){ |
|
1149 | - $query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' )); |
|
1148 | + public function question_groups($query_params = array()) { |
|
1149 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1150 | 1150 | return $this->get_many_related('Question_Group', $query_params); |
1151 | 1151 | } |
1152 | 1152 | |
@@ -1186,12 +1186,12 @@ discard block |
||
1186 | 1186 | */ |
1187 | 1187 | public function get_admin_edit_link() { |
1188 | 1188 | EE_Registry::instance()->load_helper('URL'); |
1189 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1189 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1190 | 1190 | 'page' => 'espresso_events', |
1191 | 1191 | 'action' => 'edit', |
1192 | 1192 | 'post' => $this->ID() |
1193 | 1193 | ), |
1194 | - admin_url( 'admin.php' ) |
|
1194 | + admin_url('admin.php') |
|
1195 | 1195 | ); |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1204,11 +1204,11 @@ discard block |
||
1204 | 1204 | */ |
1205 | 1205 | public function get_admin_settings_link() { |
1206 | 1206 | EE_Registry::instance()->load_helper('URL'); |
1207 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1207 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1208 | 1208 | 'page' => 'espresso_events', |
1209 | 1209 | 'action' => 'default_event_settings' |
1210 | 1210 | ), |
1211 | - admin_url( 'admin.php' ) |
|
1211 | + admin_url('admin.php') |
|
1212 | 1212 | ); |
1213 | 1213 | } |
1214 | 1214 | |
@@ -1224,11 +1224,11 @@ discard block |
||
1224 | 1224 | public function get_admin_overview_link() { |
1225 | 1225 | |
1226 | 1226 | EE_Registry::instance()->load_helper('URL'); |
1227 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1227 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1228 | 1228 | 'page' => 'espresso_events', |
1229 | 1229 | 'action' => 'default' |
1230 | 1230 | ), |
1231 | - admin_url( 'admin.php' ) |
|
1231 | + admin_url('admin.php') |
|
1232 | 1232 | ); |
1233 | 1233 | } |
1234 | 1234 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Registration class |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * date_format and the second value is the time format |
42 | 42 | * @return EE_Registration |
43 | 43 | */ |
44 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
45 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
46 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
44 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
45 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
46 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * the website will be used. |
55 | 55 | * @return EE_Registration |
56 | 56 | */ |
57 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
58 | - return new self( $props_n_values, TRUE, $timezone ); |
|
57 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
58 | + return new self($props_n_values, TRUE, $timezone); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @access public |
67 | 67 | * @param int $EVT_ID Event ID |
68 | 68 | */ |
69 | - public function set_event( $EVT_ID = 0 ) { |
|
70 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
69 | + public function set_event($EVT_ID = 0) { |
|
70 | + $this->set('EVT_ID', $EVT_ID); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | * @param mixed $field_value |
79 | 79 | * @param bool $use_default |
80 | 80 | */ |
81 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
82 | - switch( $field_name ) { |
|
81 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
82 | + switch ($field_name) { |
|
83 | 83 | case 'REG_code' : |
84 | - if ( ! empty( $field_value ) && $this->reg_code() == '' ) { |
|
85 | - $this->set_reg_code( $field_value, $use_default ); |
|
84 | + if ( ! empty($field_value) && $this->reg_code() == '') { |
|
85 | + $this->set_reg_code($field_value, $use_default); |
|
86 | 86 | } |
87 | 87 | break; |
88 | 88 | case 'STS_ID' : |
89 | - $this->set_status( $field_value, $use_default ); |
|
89 | + $this->set_status($field_value, $use_default); |
|
90 | 90 | break; |
91 | 91 | default : |
92 | - parent::set( $field_name, $field_value, $use_default ); |
|
92 | + parent::set($field_name, $field_value, $use_default); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -106,30 +106,30 @@ discard block |
||
106 | 106 | * @param boolean $use_default |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
109 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
110 | 110 | // get current REG_Status |
111 | 111 | $old_STS_ID = $this->status_ID(); |
112 | 112 | // if status has changed |
113 | - if ( $old_STS_ID != $new_STS_ID ) { |
|
113 | + if ($old_STS_ID != $new_STS_ID) { |
|
114 | 114 | // TO approved |
115 | - if ( $new_STS_ID == EEM_Registration::status_id_approved ) { |
|
115 | + if ($new_STS_ID == EEM_Registration::status_id_approved) { |
|
116 | 116 | // reserve a space by incrementing ticket and datetime sold values |
117 | 117 | $this->_reserve_registration_space(); |
118 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
118 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
119 | 119 | // OR FROM approved |
120 | - } else if ( $old_STS_ID == EEM_Registration::status_id_approved ) { |
|
120 | + } else if ($old_STS_ID == EEM_Registration::status_id_approved) { |
|
121 | 121 | // release a space by decrementing ticket and datetime sold values |
122 | 122 | $this->_release_registration_space(); |
123 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
123 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
124 | 124 | } |
125 | 125 | // update status |
126 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
127 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
126 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
127 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
128 | 128 | return TRUE; |
129 | - }else{ |
|
129 | + } else { |
|
130 | 130 | //even though the old value matches the new value, it's still good to |
131 | 131 | //allow the parent set method to have a say |
132 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
132 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
133 | 133 | return TRUE; |
134 | 134 | } |
135 | 135 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @access public |
142 | 142 | */ |
143 | 143 | public function status_ID() { |
144 | - return $this->get( 'STS_ID' ); |
|
144 | + return $this->get('STS_ID'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * @param boolean $include_archived whether to include archived tickets or not. |
167 | 167 | * @return EE_Ticket |
168 | 168 | */ |
169 | - public function ticket( $include_archived = TRUE ) { |
|
169 | + public function ticket($include_archived = TRUE) { |
|
170 | 170 | $query_params = array(); |
171 | - if ( $include_archived ) { |
|
172 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
171 | + if ($include_archived) { |
|
172 | + $query_params['default_where_conditions'] = 'none'; |
|
173 | 173 | } |
174 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
174 | + return $this->get_first_related('Ticket', $query_params); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return EE_Event |
182 | 182 | */ |
183 | 183 | public function event() { |
184 | - return $this->get_first_related( 'Event' ); |
|
184 | + return $this->get_first_related('Event'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function wp_user() { |
197 | 197 | $event = $this->event(); |
198 | - if ( $event instanceof EE_Event ) { |
|
198 | + if ($event instanceof EE_Event) { |
|
199 | 199 | return $event->wp_user(); |
200 | 200 | } |
201 | 201 | return 0; |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @access public |
222 | 222 | * @param int $ATT_ID Attendee ID |
223 | 223 | */ |
224 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
225 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
224 | + public function set_attendee_id($ATT_ID = 0) { |
|
225 | + $this->set('ATT_ID', $ATT_ID); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @access public |
234 | 234 | * @param int $TXN_ID Transaction ID |
235 | 235 | */ |
236 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
237 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
236 | + public function set_transaction_id($TXN_ID = 0) { |
|
237 | + $this->set('TXN_ID', $TXN_ID); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @access public |
246 | 246 | * @param string $REG_session PHP Session ID |
247 | 247 | */ |
248 | - public function set_session( $REG_session = '' ) { |
|
249 | - $this->set( 'REG_session', $REG_session ); |
|
248 | + public function set_session($REG_session = '') { |
|
249 | + $this->set('REG_session', $REG_session); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @access public |
258 | 258 | * @param string $REG_url_link Registration URL Link |
259 | 259 | */ |
260 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
261 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
260 | + public function set_reg_url_link($REG_url_link = '') { |
|
261 | + $this->set('REG_url_link', $REG_url_link); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @access public |
270 | 270 | * @param int $REG_count Primary Attendee |
271 | 271 | */ |
272 | - public function set_count( $REG_count = 1 ) { |
|
273 | - $this->set( 'REG_count', $REG_count ); |
|
272 | + public function set_count($REG_count = 1) { |
|
273 | + $this->set('REG_count', $REG_count); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @access public |
282 | 282 | * @param boolean $REG_group_size Group Registration |
283 | 283 | */ |
284 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
285 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
284 | + public function set_group_size($REG_group_size = FALSE) { |
|
285 | + $this->set('REG_group_size', $REG_group_size); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @access public |
366 | 366 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
367 | 367 | */ |
368 | - public function set_reg_date( $REG_date = FALSE ) { |
|
369 | - $this->set( 'REG_date', $REG_date ); |
|
368 | + public function set_reg_date($REG_date = FALSE) { |
|
369 | + $this->set('REG_date', $REG_date); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * @access public |
378 | 378 | * @param float $REG_final_price |
379 | 379 | */ |
380 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
381 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
380 | + public function set_final_price($REG_final_price = 0.00) { |
|
381 | + $this->set('REG_final_price', $REG_final_price); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * @access public |
390 | 390 | * @param float $REG_paid |
391 | 391 | */ |
392 | - public function set_paid( $REG_paid = 0.00 ) { |
|
393 | - $this->set( 'REG_paid', $REG_paid ); |
|
392 | + public function set_paid($REG_paid = 0.00) { |
|
393 | + $this->set('REG_paid', $REG_paid); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | * @access public |
402 | 402 | * @param boolean $REG_att_is_going Attendee Is Going |
403 | 403 | */ |
404 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
405 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
404 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
405 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return EE_Attendee |
413 | 413 | */ |
414 | 414 | public function attendee() { |
415 | - return $this->get_first_related( 'Attendee' ); |
|
415 | + return $this->get_first_related('Attendee'); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @access public |
423 | 423 | */ |
424 | 424 | public function event_ID() { |
425 | - return $this->get( 'EVT_ID' ); |
|
425 | + return $this->get('EVT_ID'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function event_name() { |
435 | 435 | $event = $this->event_obj(); |
436 | - if ( $event ) { |
|
436 | + if ($event) { |
|
437 | 437 | return $event->name(); |
438 | 438 | } else { |
439 | 439 | return NULL; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @return EE_Event |
448 | 448 | */ |
449 | 449 | public function event_obj() { |
450 | - return $this->get_first_related( 'Event' ); |
|
450 | + return $this->get_first_related('Event'); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @access public |
458 | 458 | */ |
459 | 459 | public function attendee_ID() { |
460 | - return $this->get( 'ATT_ID' ); |
|
460 | + return $this->get('ATT_ID'); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @access public |
468 | 468 | */ |
469 | 469 | public function session_ID() { |
470 | - return $this->get( 'REG_session' ); |
|
470 | + return $this->get('REG_session'); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public function receipt_url( $messenger = 'html' ) { |
|
480 | + public function receipt_url($messenger = 'html') { |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | */ |
487 | 487 | EE_Registry::instance()->load_helper('Template'); |
488 | 488 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
489 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
489 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
490 | 490 | |
491 | - if ( $has_custom ) { |
|
492 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
491 | + if ($has_custom) { |
|
492 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
493 | 493 | } |
494 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
494 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public function invoice_url( $messenger = 'html' ) { |
|
505 | + public function invoice_url($messenger = 'html') { |
|
506 | 506 | /** |
507 | 507 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
508 | 508 | * |
@@ -510,21 +510,21 @@ discard block |
||
510 | 510 | */ |
511 | 511 | EE_Registry::instance()->load_helper('Template'); |
512 | 512 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
513 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
513 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
514 | 514 | |
515 | - if ( $has_custom ) { |
|
516 | - if ( $messenger == 'html' ) { |
|
517 | - return $this->invoice_url( 'launch' ); |
|
515 | + if ($has_custom) { |
|
516 | + if ($messenger == 'html') { |
|
517 | + return $this->invoice_url('launch'); |
|
518 | 518 | } |
519 | 519 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
520 | 520 | |
521 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
522 | - if ( $messenger == 'html' ) { |
|
521 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
522 | + if ($messenger == 'html') { |
|
523 | 523 | $query_args['html'] = TRUE; |
524 | 524 | } |
525 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
525 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
526 | 526 | } |
527 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
527 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @access public |
535 | 535 | */ |
536 | 536 | public function reg_url_link() { |
537 | - return $this->get( 'REG_url_link' ); |
|
537 | + return $this->get('REG_url_link'); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public function e_invoice_url( $type = 'launch' ) { |
|
548 | - echo $this->invoice_url( $type ); |
|
547 | + public function e_invoice_url($type = 'launch') { |
|
548 | + echo $this->invoice_url($type); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @return string |
566 | 566 | */ |
567 | 567 | public function payment_overview_url() { |
568 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
568 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @return string |
577 | 577 | */ |
578 | 578 | public function edit_attendee_information_url() { |
579 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
579 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
@@ -586,8 +586,8 @@ discard block |
||
586 | 586 | * @return string |
587 | 587 | */ |
588 | 588 | public function get_admin_edit_url() { |
589 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
590 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
589 | + EE_Registry::instance()->load_helper('URL'); |
|
590 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @access public |
598 | 598 | */ |
599 | 599 | public function is_primary_registrant() { |
600 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
600 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | * This returns the primary registration object for this registration group (which may be this object). |
607 | 607 | * @return EE_Registration |
608 | 608 | */ |
609 | - public function get_primary_registration() { |
|
610 | - if ( $this->is_primary_registrant() ) |
|
609 | + public function get_primary_registration() { |
|
610 | + if ($this->is_primary_registrant()) |
|
611 | 611 | return $this; |
612 | 612 | |
613 | 613 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
614 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
614 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
615 | 615 | return $primary_registrant; |
616 | 616 | } |
617 | 617 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @access public |
623 | 623 | */ |
624 | 624 | public function count() { |
625 | - return $this->get( 'REG_count' ); |
|
625 | + return $this->get('REG_count'); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @access public |
633 | 633 | */ |
634 | 634 | public function group_size() { |
635 | - return $this->get( 'REG_group_size' ); |
|
635 | + return $this->get('REG_group_size'); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @access public |
643 | 643 | */ |
644 | 644 | public function date() { |
645 | - return $this->get( 'REG_date' ); |
|
645 | + return $this->get('REG_date'); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $time_format |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
657 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
656 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
657 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * @return float |
668 | 668 | */ |
669 | 669 | public function final_price() { |
670 | - return $this->get( 'REG_final_price' ); |
|
670 | + return $this->get('REG_final_price'); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * @return string |
679 | 679 | */ |
680 | 680 | public function pretty_final_price() { |
681 | - return $this->get_pretty( 'REG_final_price' ); |
|
681 | + return $this->get_pretty('REG_final_price'); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | * @return float |
690 | 690 | */ |
691 | 691 | public function paid() { |
692 | - return $this->get( 'REG_paid' ); |
|
692 | + return $this->get('REG_paid'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @return float |
701 | 701 | */ |
702 | 702 | public function pretty_paid() { |
703 | - return $this->get_pretty( 'REG_paid' ); |
|
703 | + return $this->get_pretty('REG_paid'); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | * @param array $requires_payment |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
715 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
716 | 716 | // these reg statuses require payment (if event is not free) |
717 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
717 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
718 | 718 | if ( |
719 | - in_array( $this->status_ID(), $requires_payment ) && |
|
719 | + in_array($this->status_ID(), $requires_payment) && |
|
720 | 720 | $this->final_price() != 0 && |
721 | 721 | $this->final_price() != $this->paid() |
722 | 722 | ) { |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | * @param bool $show_icons |
734 | 734 | * @return void |
735 | 735 | */ |
736 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
737 | - echo $this->pretty_status( $show_icons ); |
|
736 | + public function e_pretty_status($show_icons = FALSE) { |
|
737 | + echo $this->pretty_status($show_icons); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | * @param bool $show_icons |
746 | 746 | * @return string |
747 | 747 | */ |
748 | - public function pretty_status( $show_icons = FALSE ) { |
|
749 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
748 | + public function pretty_status($show_icons = FALSE) { |
|
749 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
750 | 750 | $icon = ''; |
751 | - switch ( $this->status_ID() ) { |
|
751 | + switch ($this->status_ID()) { |
|
752 | 752 | case EEM_Registration::status_id_approved: |
753 | 753 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
754 | 754 | break; |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
769 | 769 | break; |
770 | 770 | } |
771 | - return $icon . $status[ $this->status_ID() ]; |
|
771 | + return $icon.$status[$this->status_ID()]; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @access public |
779 | 779 | */ |
780 | 780 | public function att_is_going() { |
781 | - return $this->get( 'REG_att_is_going' ); |
|
781 | + return $this->get('REG_att_is_going'); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | * @param array $query_params like EEM_Base::get_all |
789 | 789 | * @return EE_Answer[] |
790 | 790 | */ |
791 | - public function answers( $query_params = NULL ) { |
|
792 | - return $this->get_many_related( 'Answer', $query_params ); |
|
791 | + public function answers($query_params = NULL) { |
|
792 | + return $this->get_many_related('Answer', $query_params); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | * (because the answer might be an array of answer values, so passing pretty_value=true |
804 | 804 | * will convert it into some kind of string) |
805 | 805 | */ |
806 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
806 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
807 | 807 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
808 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
808 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | |
@@ -818,13 +818,13 @@ discard block |
||
818 | 818 | */ |
819 | 819 | public function question_groups() { |
820 | 820 | $question_groups = array(); |
821 | - if ( $this->event() instanceof EE_Event ) { |
|
821 | + if ($this->event() instanceof EE_Event) { |
|
822 | 822 | $question_groups = $this->event()->question_groups( |
823 | 823 | array( |
824 | 824 | array( |
825 | 825 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
826 | 826 | ), |
827 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
827 | + 'order_by' => array('QSG_order' => 'ASC') |
|
828 | 828 | ) |
829 | 829 | ); |
830 | 830 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | */ |
842 | 842 | public function count_question_groups() { |
843 | 843 | $qg_count = 0; |
844 | - if ( $this->event() instanceof EE_Event ) { |
|
844 | + if ($this->event() instanceof EE_Event) { |
|
845 | 845 | $qg_count = $this->event()->count_related( |
846 | 846 | 'Question_Group', |
847 | 847 | array( |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * @return string |
863 | 863 | */ |
864 | 864 | public function reg_date() { |
865 | - return $this->get_datetime( 'REG_date' ); |
|
865 | + return $this->get_datetime('REG_date'); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * @return EE_Datetime_Ticket |
875 | 875 | */ |
876 | 876 | public function datetime_ticket() { |
877 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
877 | + return $this->get_first_related('Datetime_Ticket'); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | |
@@ -884,15 +884,15 @@ discard block |
||
884 | 884 | * @param EE_Datetime_Ticket $datetime_ticket |
885 | 885 | * @return EE_Datetime_Ticket |
886 | 886 | */ |
887 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
888 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
887 | + public function set_datetime_ticket($datetime_ticket) { |
|
888 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
889 | 889 | } |
890 | 890 | /** |
891 | 891 | * Gets deleted |
892 | 892 | * @return boolean |
893 | 893 | */ |
894 | 894 | public function deleted() { |
895 | - return $this->get( 'REG_deleted' ); |
|
895 | + return $this->get('REG_deleted'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | * @return boolean |
902 | 902 | */ |
903 | 903 | public function set_deleted($deleted) { |
904 | - $this->set( 'REG_deleted', $deleted ); |
|
904 | + $this->set('REG_deleted', $deleted); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | * @return EE_Status |
912 | 912 | */ |
913 | 913 | public function status_obj() { |
914 | - return $this->get_first_related( 'Status' ); |
|
914 | + return $this->get_first_related('Status'); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @return int |
923 | 923 | */ |
924 | 924 | public function count_checkins() { |
925 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
925 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @return int |
933 | 933 | */ |
934 | 934 | public function count_checkins_not_checkedout() { |
935 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
935 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | |
@@ -945,20 +945,20 @@ discard block |
||
945 | 945 | * |
946 | 946 | * @return bool |
947 | 947 | */ |
948 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
949 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
948 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
949 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
950 | 950 | |
951 | 951 | //first check registration status |
952 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
952 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
953 | 953 | return false; |
954 | 954 | } |
955 | 955 | //is there a datetime ticket that matches this dtt_ID? |
956 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
956 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
957 | 957 | return false; |
958 | 958 | } |
959 | 959 | |
960 | 960 | //final check is against TKT_uses |
961 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
961 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | |
@@ -971,10 +971,10 @@ discard block |
||
971 | 971 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
972 | 972 | * @return bool true means can checkin. false means cannot checkin. |
973 | 973 | */ |
974 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
975 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
974 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
975 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
976 | 976 | |
977 | - if ( ! $DTT_ID ) { |
|
977 | + if ( ! $DTT_ID) { |
|
978 | 978 | return false; |
979 | 979 | } |
980 | 980 | |
@@ -982,23 +982,23 @@ discard block |
||
982 | 982 | |
983 | 983 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
984 | 984 | // or not. |
985 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
985 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
986 | 986 | return true; |
987 | 987 | } |
988 | 988 | |
989 | 989 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
990 | 990 | //go ahead and toggle. |
991 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
991 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
992 | 992 | return true; |
993 | 993 | } |
994 | 994 | |
995 | 995 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
996 | 996 | //disallows further check-ins. |
997 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
997 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
998 | 998 | // checkins have already reached their max number of uses |
999 | 999 | // so registrant can NOT checkin |
1000 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1001 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1000 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1001 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1002 | 1002 | return false; |
1003 | 1003 | } |
1004 | 1004 | return true; |
@@ -1019,15 +1019,15 @@ discard block |
||
1019 | 1019 | * @param bool $verify If true then can_checkin() is used to verify whether the person can be checked in or not. Otherwise this forces change in checkin status. |
1020 | 1020 | * @return int|BOOL the chk_in status toggled to OR false if nothing got changed. |
1021 | 1021 | */ |
1022 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1023 | - if ( empty( $DTT_ID ) ) { |
|
1022 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1023 | + if (empty($DTT_ID)) { |
|
1024 | 1024 | $datetime = $this->get_related_primary_datetime(); |
1025 | 1025 | $DTT_ID = $datetime->ID(); |
1026 | 1026 | // verify the registration can checkin for the given DTT_ID |
1027 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1027 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1028 | 1028 | EE_Error::add_error( |
1029 | 1029 | sprintf( |
1030 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1030 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1031 | 1031 | $this->ID(), |
1032 | 1032 | $DTT_ID |
1033 | 1033 | ), |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1042 | 1042 | ); |
1043 | 1043 | //start by getting the current status so we know what status we'll be changing to. |
1044 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1045 | - $status_to = $status_paths[ $cur_status ]; |
|
1044 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1045 | + $status_to = $status_paths[$cur_status]; |
|
1046 | 1046 | // database only records true for checked IN or false for checked OUT |
1047 | 1047 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1048 | 1048 | $new_status = $status_to == EE_Registration::checkin_status_in ? true : false; |
@@ -1050,24 +1050,24 @@ discard block |
||
1050 | 1050 | // because we are keeping track of Check-ins over time. |
1051 | 1051 | // Eventually we'll probably want to show a list table |
1052 | 1052 | // for the individual Check-ins so that they can be managed. |
1053 | - $checkin = EE_Checkin::new_instance( array( |
|
1053 | + $checkin = EE_Checkin::new_instance(array( |
|
1054 | 1054 | 'REG_ID' => $this->ID(), |
1055 | 1055 | 'DTT_ID' => $DTT_ID, |
1056 | 1056 | 'CHK_in' => $new_status |
1057 | - ) ); |
|
1057 | + )); |
|
1058 | 1058 | // if the record could not be saved then return false |
1059 | - if ( $checkin->save() === 0 ) { |
|
1060 | - if ( WP_DEBUG ) { |
|
1059 | + if ($checkin->save() === 0) { |
|
1060 | + if (WP_DEBUG) { |
|
1061 | 1061 | global $wpdb; |
1062 | 1062 | $error = sprintf( |
1063 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1063 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1064 | 1064 | '<br />', |
1065 | 1065 | $wpdb->last_error |
1066 | 1066 | ); |
1067 | 1067 | } else { |
1068 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1068 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1069 | 1069 | } |
1070 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1070 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1071 | 1071 | return false; |
1072 | 1072 | } |
1073 | 1073 | return $status_to; |
@@ -1091,19 +1091,19 @@ discard block |
||
1091 | 1091 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
1092 | 1092 | * @return int Integer representing Check-in status. |
1093 | 1093 | */ |
1094 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = NULL ) { |
|
1095 | - if ( empty( $DTT_ID ) && ! $checkin instanceof EE_Checkin ) { |
|
1094 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = NULL) { |
|
1095 | + if (empty($DTT_ID) && ! $checkin instanceof EE_Checkin) { |
|
1096 | 1096 | $datetime = $this->get_related_primary_datetime(); |
1097 | - if ( ! $datetime instanceof EE_Datetime ) { |
|
1097 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1098 | 1098 | return 0; |
1099 | 1099 | } |
1100 | 1100 | $DTT_ID = $datetime->ID(); |
1101 | 1101 | //verify the registration can checkin for the given DTT_ID |
1102 | 1102 | } |
1103 | 1103 | //get checkin object (if exists) |
1104 | - $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ), 'order_by' => array( 'CHK_timestamp' => 'DESC' ) ) ); |
|
1105 | - if ( $checkin instanceof EE_Checkin ) { |
|
1106 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1104 | + $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related('Checkin', array(array('DTT_ID' => $DTT_ID), 'order_by' => array('CHK_timestamp' => 'DESC'))); |
|
1105 | + if ($checkin instanceof EE_Checkin) { |
|
1106 | + if ($checkin->get('CHK_in')) { |
|
1107 | 1107 | return EE_Registration::checkin_status_in; //checked in |
1108 | 1108 | } else { |
1109 | 1109 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1121,28 +1121,28 @@ discard block |
||
1121 | 1121 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1122 | 1122 | * @return string internationalized message |
1123 | 1123 | */ |
1124 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1124 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1125 | 1125 | //let's get the attendee first so we can include the name of the attendee |
1126 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1127 | - if ( $attendee instanceof EE_Attendee ) { |
|
1128 | - if ( $error ) { |
|
1129 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1126 | + $attendee = $this->get_first_related('Attendee'); |
|
1127 | + if ($attendee instanceof EE_Attendee) { |
|
1128 | + if ($error) { |
|
1129 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1130 | 1130 | } |
1131 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1131 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1132 | 1132 | //what is the status message going to be? |
1133 | - switch ( $cur_status ) { |
|
1133 | + switch ($cur_status) { |
|
1134 | 1134 | case EE_Registration::checkin_status_never : |
1135 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1135 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1136 | 1136 | break; |
1137 | 1137 | case EE_Registration::checkin_status_in : |
1138 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1138 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1139 | 1139 | break; |
1140 | 1140 | case EE_Registration::checkin_status_out : |
1141 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1141 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1142 | 1142 | break; |
1143 | 1143 | } |
1144 | 1144 | } |
1145 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1145 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | * @return EE_Transaction |
1153 | 1153 | */ |
1154 | 1154 | public function transaction() { |
1155 | - return $this->get_first_related( 'Transaction' ); |
|
1155 | + return $this->get_first_related('Transaction'); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | * @access public |
1164 | 1164 | */ |
1165 | 1165 | public function reg_code() { |
1166 | - return $this->get( 'REG_code' ); |
|
1166 | + return $this->get('REG_code'); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * @access public |
1174 | 1174 | */ |
1175 | 1175 | public function transaction_ID() { |
1176 | - return $this->get( 'TXN_ID' ); |
|
1176 | + return $this->get('TXN_ID'); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | * @return int |
1183 | 1183 | */ |
1184 | 1184 | public function ticket_ID() { |
1185 | - return $this->get( 'TKT_ID' ); |
|
1185 | + return $this->get('TKT_ID'); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | |
@@ -1194,17 +1194,17 @@ discard block |
||
1194 | 1194 | * @param string $REG_code Registration Code |
1195 | 1195 | * @param boolean $use_default |
1196 | 1196 | */ |
1197 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1198 | - if ( empty( $REG_code )) { |
|
1199 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1197 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1198 | + if (empty($REG_code)) { |
|
1199 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1200 | 1200 | return; |
1201 | 1201 | } |
1202 | - if ( ! $this->reg_code() ) { |
|
1203 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1202 | + if ( ! $this->reg_code()) { |
|
1203 | + parent::set('REG_code', $REG_code, $use_default); |
|
1204 | 1204 | } else { |
1205 | 1205 | EE_Error::doing_it_wrong( |
1206 | - __CLASS__ . '::' . __FUNCTION__, |
|
1207 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1206 | + __CLASS__.'::'.__FUNCTION__, |
|
1207 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1208 | 1208 | '4.6.0' |
1209 | 1209 | ); |
1210 | 1210 | } |
@@ -1224,17 +1224,17 @@ discard block |
||
1224 | 1224 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1225 | 1225 | */ |
1226 | 1226 | public function get_all_other_registrations_in_group() { |
1227 | - if ( $this->group_size() < 2 ) { |
|
1227 | + if ($this->group_size() < 2) { |
|
1228 | 1228 | return array(); |
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | $query[0] = array( |
1232 | 1232 | 'TXN_ID' => $this->transaction_ID(), |
1233 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1233 | + 'REG_ID' => array('!=', $this->ID()), |
|
1234 | 1234 | 'TKT_ID' => $this->ticket_ID() |
1235 | 1235 | ); |
1236 | 1236 | |
1237 | - $registrations = $this->get_model()->get_all( $query ); |
|
1237 | + $registrations = $this->get_model()->get_all($query); |
|
1238 | 1238 | return $registrations; |
1239 | 1239 | } |
1240 | 1240 | |
@@ -1244,8 +1244,8 @@ discard block |
||
1244 | 1244 | * @param array $query_params |
1245 | 1245 | * @return \EE_Registration[] |
1246 | 1246 | */ |
1247 | - public function payments( $query_params = array() ) { |
|
1248 | - return $this->get_many_related( 'Payment', $query_params ); |
|
1247 | + public function payments($query_params = array()) { |
|
1248 | + return $this->get_many_related('Payment', $query_params); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | |
@@ -1254,8 +1254,8 @@ discard block |
||
1254 | 1254 | * @param array $query_params |
1255 | 1255 | * @return \EE_Registration[] |
1256 | 1256 | */ |
1257 | - public function registration_payments( $query_params = array() ) { |
|
1258 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
1257 | + public function registration_payments($query_params = array()) { |
|
1258 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | * @access public |
1267 | 1267 | */ |
1268 | 1268 | public function price_paid() { |
1269 | - EE_Error::doing_it_wrong( 'EE_Registration::price_paid()', __( 'This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1269 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1270 | 1270 | return $this->final_price(); |
1271 | 1271 | } |
1272 | 1272 | |
@@ -1278,9 +1278,9 @@ discard block |
||
1278 | 1278 | * @access public |
1279 | 1279 | * @param float $REG_final_price |
1280 | 1280 | */ |
1281 | - public function set_price_paid( $REG_final_price = 0.00 ) { |
|
1282 | - EE_Error::doing_it_wrong( 'EE_Registration::set_price_paid()', __( 'This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1283 | - $this->set_final_price( $REG_final_price ); |
|
1281 | + public function set_price_paid($REG_final_price = 0.00) { |
|
1282 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1283 | + $this->set_final_price($REG_final_price); |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | * @return string |
1292 | 1292 | */ |
1293 | 1293 | public function pretty_price_paid() { |
1294 | - EE_Error::doing_it_wrong( 'EE_Registration::pretty_price_paid()', __( 'This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1294 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1295 | 1295 | return $this->pretty_final_price(); |
1296 | 1296 | } |
1297 | 1297 |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * @return void |
29 | 29 | */ |
30 | 30 | public static function set_hooks() { |
31 | - add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) ); |
|
32 | - add_action( 'wp_ajax_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
33 | - add_action( 'wp_ajax_nopriv_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
34 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
35 | - add_action( 'wp_ajax_nopriv_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
36 | - add_action( 'wp_ajax_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) ); |
|
37 | - add_action( 'wp_ajax_nopriv_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
31 | + add_filter('FHEE__SPCO__EE_Line_Item_Filter_Collection', array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')); |
|
32 | + add_action('wp_ajax_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
33 | + add_action('wp_ajax_nopriv_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
34 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
35 | + add_action('wp_ajax_nopriv_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
36 | + add_action('wp_ajax_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')); |
|
37 | + add_action('wp_ajax_nopriv_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
38 | 38 | ); |
39 | - add_filter( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), 10, 1 ); |
|
39 | + add_filter('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * ajax switch_spco_billing_form |
46 | 46 | */ |
47 | 47 | public static function switch_spco_billing_form() { |
48 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
48 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * ajax save_payer_details |
55 | 55 | */ |
56 | 56 | public static function save_payer_details() { |
57 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
57 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * ajax get_transaction_details |
64 | 64 | */ |
65 | 65 | public static function get_transaction_details() { |
66 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
66 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @param EE_Checkout $checkout |
92 | 92 | * @return \EE_SPCO_Reg_Step_Payment_Options |
93 | 93 | */ |
94 | - public function __construct( EE_Checkout $checkout ) { |
|
94 | + public function __construct(EE_Checkout $checkout) { |
|
95 | 95 | $this->_slug = 'payment_options'; |
96 | 96 | $this->_name = __('Payment Options', 'event_espresso'); |
97 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
97 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
98 | 98 | $this->checkout = $checkout; |
99 | 99 | $this->_reset_success_message(); |
100 | - $this->set_instructions( __('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
100 | + $this->set_instructions(__('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @param null $line_item_display |
116 | 116 | */ |
117 | - public function set_line_item_display( $line_item_display ) { |
|
117 | + public function set_line_item_display($line_item_display) { |
|
118 | 118 | $this->line_item_display = $line_item_display; |
119 | 119 | } |
120 | 120 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | public function translate_js_strings() { |
128 | - EE_Registry::$i18n_js_strings['no_payment_method'] = __( 'Please select a method of payment in order to continue.', 'event_espresso' ); |
|
129 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso' ); |
|
130 | - EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __( 'Forwarding to Secure Payment Provider.', 'event_espresso' ); |
|
128 | + EE_Registry::$i18n_js_strings['no_payment_method'] = __('Please select a method of payment in order to continue.', 'event_espresso'); |
|
129 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso'); |
|
130 | + EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __('Forwarding to Secure Payment Provider.', 'event_espresso'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | // $ 0.00 transactions (no payment required) |
157 | 157 | ! $this->checkout->payment_required() |
158 | 158 | // but do NOT remove if current action being called belongs to this reg step |
159 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
159 | + && ! is_callable(array($this, $this->checkout->action)) |
|
160 | 160 | && ! $this->completed() |
161 | 161 | ) { |
162 | 162 | // and if so, then we no longer need the Payment Options step |
163 | - if ( $this->is_current_step() ) { |
|
163 | + if ($this->is_current_step()) { |
|
164 | 164 | $this->checkout->generate_reg_form = false; |
165 | 165 | } |
166 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
166 | + $this->checkout->remove_reg_step($this->_slug); |
|
167 | 167 | // DEBUG LOG |
168 | 168 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | // load EEM_Payment_Method |
172 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
172 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
173 | 173 | // get all active payment methods |
174 | 174 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
175 | 175 | $this->checkout->transaction, EEM_Payment_Method::scope_cart |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return bool |
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
186 | + EE_Registry::instance()->load_helper('HTML'); |
|
187 | 187 | // reset in case someone changes their mind |
188 | 188 | $this->_reset_selected_method_of_payment(); |
189 | 189 | // set some defaults |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | $sold_out_events = array(); |
195 | 195 | $reg_count = 0; |
196 | 196 | // loop thru registrations to gather info |
197 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
198 | - foreach ( $registrations as $registration ) { |
|
197 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
198 | + foreach ($registrations as $registration) { |
|
199 | 199 | /** @var $registration EE_Registration */ |
200 | 200 | $reg_count++; |
201 | 201 | // if returning registrant is Approved then do NOT do this |
202 | - if ( ! ( $this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved )) { |
|
203 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true )) { |
|
202 | + if ( ! ($this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved)) { |
|
203 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
204 | 204 | // add event to list of events that are sold out |
205 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
205 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
206 | 206 | do_action( |
207 | 207 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
208 | 208 | $registration->event(), |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | ); |
211 | 211 | } |
212 | 212 | // event requires admin approval |
213 | - if ( $registration->status_ID() == EEM_Registration::status_id_not_approved ) { |
|
213 | + if ($registration->status_ID() == EEM_Registration::status_id_not_approved) { |
|
214 | 214 | // add event to list of events with pre-approval reg status |
215 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
215 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
216 | 216 | do_action( |
217 | 217 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
218 | 218 | $registration->event(), |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | // are they allowed to pay now and is there monies owing? |
224 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
225 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
224 | + if ($registration->owes_monies_and_can_pay()) { |
|
225 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
226 | 226 | do_action( |
227 | 227 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
228 | 228 | $registration->event(), |
229 | 229 | $this |
230 | 230 | ); |
231 | - } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free() ) { |
|
232 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
231 | + } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) { |
|
232 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | $subsections = array(); |
236 | 236 | // now decide which template to load |
237 | - if ( ! empty( $sold_out_events )) { |
|
238 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
237 | + if ( ! empty($sold_out_events)) { |
|
238 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
239 | 239 | } |
240 | - if ( ! empty( $registrations_requiring_pre_approval )) { |
|
241 | - $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval ); |
|
240 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
241 | + $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval); |
|
242 | 242 | } |
243 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
244 | - $subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events ); |
|
243 | + if ( ! empty($registrations_for_free_events)) { |
|
244 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
245 | 245 | } |
246 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
246 | + if ( ! empty($registrations_requiring_payment)) { |
|
247 | 247 | // autoload Line_Item_Display classes |
248 | 248 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
249 | 249 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | $this->checkout->cart->get_grand_total() |
255 | 255 | ); |
256 | 256 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
257 | - if ( $this->checkout->amount_owing > 0 ) { |
|
257 | + if ($this->checkout->amount_owing > 0) { |
|
258 | 258 | EEH_Autoloader::register_line_item_display_autoloaders(); |
259 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
260 | - $subsections[ 'payment_options' ] = $this->_display_payment_options( |
|
259 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
260 | + $subsections['payment_options'] = $this->_display_payment_options( |
|
261 | 261 | $this->line_item_display->display_line_item( |
262 | 262 | $filtered_line_item_tree, |
263 | - array( 'registrations' => $registrations ) |
|
263 | + array('registrations' => $registrations) |
|
264 | 264 | ) |
265 | 265 | ); |
266 | 266 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
267 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
267 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
268 | 268 | } |
269 | 269 | } else { |
270 | 270 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
298 | 298 | * @return \EE_Line_Item_Filter_Collection |
299 | 299 | */ |
300 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
300 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
301 | 301 | $line_item_filter_collection->add( |
302 | 302 | new EE_Billable_Line_Item_Filter( |
303 | 303 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ) |
306 | 306 | ) |
307 | 307 | ); |
308 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
308 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
309 | 309 | return $line_item_filter_collection; |
310 | 310 | } |
311 | 311 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @return void |
320 | 320 | */ |
321 | 321 | protected function _hide_reg_step_submit_button_if_revisit() { |
322 | - if ( $this->checkout->revisit ) { |
|
323 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
322 | + if ($this->checkout->revisit) { |
|
323 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * @param \EE_Event[] $sold_out_events_array |
332 | 332 | * @return \EE_Form_Section_Proper |
333 | 333 | */ |
334 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
334 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
335 | 335 | // set some defaults |
336 | 336 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
337 | 337 | $sold_out_events = ''; |
338 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
339 | - $sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )); |
|
338 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
339 | + $sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')); |
|
340 | 340 | } |
341 | 341 | return new EE_Form_Section_Proper( |
342 | 342 | array( |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | ), |
349 | 349 | 'layout_strategy' => new EE_Template_Layout( |
350 | 350 | array( |
351 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template |
|
351 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template |
|
352 | 352 | 'template_args' => apply_filters( |
353 | 353 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
354 | 354 | array( |
355 | 355 | 'sold_out_events' => $sold_out_events, |
356 | 356 | 'sold_out_events_msg' => apply_filters( |
357 | 357 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
358 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ) |
|
358 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso') |
|
359 | 359 | ) |
360 | 360 | ) |
361 | 361 | ) |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | * @param array $registrations_requiring_pre_approval |
373 | 373 | * @return \EE_Form_Section_Proper |
374 | 374 | */ |
375 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) { |
|
375 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
376 | 376 | $events_requiring_pre_approval = ''; |
377 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
378 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
379 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
380 | - EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
377 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
378 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
379 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
380 | + EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
381 | 381 | ) |
382 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
382 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | } |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | ), |
392 | 392 | 'layout_strategy' => new EE_Template_Layout( |
393 | 393 | array( |
394 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template |
|
394 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template |
|
395 | 395 | 'template_args' => apply_filters( |
396 | 396 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
397 | 397 | array( |
398 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
398 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
399 | 399 | 'events_requiring_pre_approval_msg' => apply_filters( |
400 | 400 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
401 | - __( 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso' ) |
|
401 | + __('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso') |
|
402 | 402 | ) |
403 | 403 | ) |
404 | 404 | ), |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @param \EE_Event[] $registrations_for_free_events |
417 | 417 | * @return \EE_Form_Section_Proper |
418 | 418 | */ |
419 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
419 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
420 | 420 | // set some defaults |
421 | 421 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
422 | 422 | // generate no_payment_required form |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | ), |
429 | 429 | 'layout_strategy' => new EE_Template_Layout( |
430 | 430 | array( |
431 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template |
|
431 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template |
|
432 | 432 | 'template_args' => apply_filters( |
433 | 433 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
434 | 434 | array( |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'registrations' => array(), |
437 | 437 | 'ticket_count' => array(), |
438 | 438 | 'registrations_for_free_events' => $registrations_for_free_events, |
439 | - 'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' )) |
|
439 | + 'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso')) |
|
440 | 440 | ) |
441 | 441 | ), |
442 | 442 | ) |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @param string $transaction_details |
454 | 454 | * @return \EE_Form_Section_Proper |
455 | 455 | */ |
456 | - private function _display_payment_options( $transaction_details = '' ) { |
|
456 | + private function _display_payment_options($transaction_details = '') { |
|
457 | 457 | // has method_of_payment been set by no-js user? |
458 | 458 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
459 | 459 | // build payment options form |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | 'before_payment_options' => apply_filters( |
466 | 466 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
467 | 467 | new EE_Form_Section_Proper( |
468 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
468 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
469 | 469 | ) |
470 | 470 | ), |
471 | 471 | 'payment_options' => $this->_setup_payment_options(), |
472 | 472 | 'after_payment_options' => apply_filters( |
473 | 473 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
474 | 474 | new EE_Form_Section_Proper( |
475 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
475 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
479 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( FALSE ) |
|
479 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(FALSE) |
|
480 | 480 | ), |
481 | - 'layout_strategy' => new EE_Template_Layout( array( |
|
481 | + 'layout_strategy' => new EE_Template_Layout(array( |
|
482 | 482 | 'layout_template_file' => $this->_template, |
483 | 483 | 'template_args' => apply_filters( |
484 | 484 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * @param bool $no_payment_required |
503 | 503 | * @return \EE_Form_Section_Proper |
504 | 504 | */ |
505 | - private function _extra_hidden_inputs( $no_payment_required = TRUE ) { |
|
505 | + private function _extra_hidden_inputs($no_payment_required = TRUE) { |
|
506 | 506 | |
507 | 507 | return new EE_Form_Section_Proper( |
508 | 508 | array( |
509 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
509 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
510 | 510 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
511 | 511 | 'subsections' => array( |
512 | 512 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -539,16 +539,16 @@ discard block |
||
539 | 539 | * @access protected |
540 | 540 | * @return void |
541 | 541 | */ |
542 | - protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
|
542 | + protected function _apply_registration_payments_to_amount_owing($registrations) { |
|
543 | 543 | $payments = array(); |
544 | - foreach ( $registrations as $registration ) { |
|
545 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
544 | + foreach ($registrations as $registration) { |
|
545 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
546 | 546 | $payments = $payments + $registration->registration_payments(); |
547 | 547 | } |
548 | 548 | } |
549 | - if ( ! empty( $payments ) ) { |
|
550 | - foreach ( $payments as $payment ) { |
|
551 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
549 | + if ( ! empty($payments)) { |
|
550 | + foreach ($payments as $payment) { |
|
551 | + if ($payment instanceof EE_Registration_Payment) { |
|
552 | 552 | $this->checkout->amount_owing -= $payment->amount(); |
553 | 553 | } |
554 | 554 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * @param bool $force_reset |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - private function _reset_selected_method_of_payment( $force_reset = FALSE ) { |
|
567 | - $reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE )); |
|
568 | - if ( $reset_payment_method ) { |
|
566 | + private function _reset_selected_method_of_payment($force_reset = FALSE) { |
|
567 | + $reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE)); |
|
568 | + if ($reset_payment_method) { |
|
569 | 569 | $this->checkout->selected_method_of_payment = NULL; |
570 | 570 | $this->checkout->payment_method = NULL; |
571 | 571 | $this->checkout->billing_form = NULL; |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * @param string $selected_method_of_payment |
585 | 585 | * @return EE_Billing_Info_Form |
586 | 586 | */ |
587 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
588 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | - EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment )); |
|
587 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
588 | + $selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | + EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment)); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -599,40 +599,40 @@ discard block |
||
599 | 599 | // load payment method classes |
600 | 600 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
601 | 601 | // switch up header depending on number of available payment methods |
602 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
603 | - ? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' )) |
|
604 | - : apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' )); |
|
602 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
603 | + ? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso')) |
|
604 | + : apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso')); |
|
605 | 605 | $available_payment_methods = array( |
606 | 606 | // display the "Payment Method" header |
607 | 607 | 'payment_method_header' => new EE_Form_Section_HTML( |
608 | - EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' ) |
|
608 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
609 | 609 | ) |
610 | 610 | ); |
611 | 611 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
612 | 612 | $available_payment_method_options = array(); |
613 | 613 | $default_payment_method_option = array(); |
614 | 614 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
615 | - $payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' ))); |
|
615 | + $payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;'))); |
|
616 | 616 | // loop through payment methods |
617 | - foreach( $this->checkout->available_payment_methods as $payment_method ) { |
|
618 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
619 | - $payment_method_button = EEH_HTML::img( $payment_method->button_url(), $payment_method->name(), 'spco-payment-method-' . $payment_method->slug() . '-btn-img', 'spco-payment-method-btn-img' ); |
|
617 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
618 | + if ($payment_method instanceof EE_Payment_Method) { |
|
619 | + $payment_method_button = EEH_HTML::img($payment_method->button_url(), $payment_method->name(), 'spco-payment-method-'.$payment_method->slug().'-btn-img', 'spco-payment-method-btn-img'); |
|
620 | 620 | // check if any payment methods are set as default |
621 | 621 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
622 | - if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) { |
|
622 | + if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) { |
|
623 | 623 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
624 | 624 | $this->_save_selected_method_of_payment(); |
625 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
625 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
626 | 626 | } else { |
627 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
627 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
628 | 628 | } |
629 | - $payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method ); |
|
629 | + $payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method); |
|
630 | 630 | } |
631 | 631 | } |
632 | 632 | // prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs |
633 | 633 | $available_payment_method_options = $default_payment_method_option + $available_payment_method_options; |
634 | 634 | // now generate the actual form inputs |
635 | - $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options ); |
|
635 | + $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options); |
|
636 | 636 | $available_payment_methods = $available_payment_methods + $payment_methods_billing_info; |
637 | 637 | |
638 | 638 | // build the available payment methods form |
@@ -652,19 +652,19 @@ discard block |
||
652 | 652 | * @return EE_Payment_Method[] |
653 | 653 | */ |
654 | 654 | protected function _get_available_payment_methods() { |
655 | - if ( ! empty( $this->checkout->available_payment_methods )) { |
|
655 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
656 | 656 | return $this->checkout->available_payment_methods; |
657 | 657 | } |
658 | 658 | $available_payment_methods = array(); |
659 | 659 | // load EEM_Payment_Method |
660 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
660 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
661 | 661 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
662 | 662 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
663 | 663 | // get all active payment methods |
664 | - $payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart ); |
|
665 | - foreach ( $payment_methods as $payment_method ) { |
|
666 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
667 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
664 | + $payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart); |
|
665 | + foreach ($payment_methods as $payment_method) { |
|
666 | + if ($payment_method instanceof EE_Payment_Method) { |
|
667 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | return $available_payment_methods; |
@@ -680,14 +680,14 @@ discard block |
||
680 | 680 | * @param array $available_payment_method_options |
681 | 681 | * @return \EE_Form_Section_Proper |
682 | 682 | */ |
683 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
683 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
684 | 684 | // generate inputs |
685 | 685 | return new EE_Form_Section_Proper( |
686 | 686 | array( |
687 | 687 | 'html_id' => 'ee-available-payment-method-inputs', |
688 | 688 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
689 | 689 | 'subsections' => array( |
690 | - '' => new EE_Radio_Button_Input ( |
|
690 | + '' => new EE_Radio_Button_Input( |
|
691 | 691 | $available_payment_method_options, |
692 | 692 | array( |
693 | 693 | 'html_name' => 'selected_method_of_payment', |
@@ -711,36 +711,36 @@ discard block |
||
711 | 711 | * @param EE_Payment_Method $payment_method |
712 | 712 | * @return \EE_Form_Section_Proper |
713 | 713 | */ |
714 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
714 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
715 | 715 | $currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE; |
716 | 716 | // generate the billing form for payment method |
717 | - $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML(); |
|
717 | + $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML(); |
|
718 | 718 | $this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form; |
719 | 719 | // it's all in the details |
720 | - $info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' ); |
|
720 | + $info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr'); |
|
721 | 721 | // add some info regarding the step, either from what's saved in the admin, or a default string depending on whether the PM has a billing form or not |
722 | - if ( $payment_method->description() ) { |
|
722 | + if ($payment_method->description()) { |
|
723 | 723 | $payment_method_info = $payment_method->description(); |
724 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
725 | - $payment_method_info = sprintf( __( 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
724 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
725 | + $payment_method_info = sprintf(__('Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
726 | 726 | } else { |
727 | - $payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
727 | + $payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
728 | 728 | } |
729 | - $info_html .= EEH_HTML::p ( |
|
730 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ), |
|
729 | + $info_html .= EEH_HTML::p( |
|
730 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info), |
|
731 | 731 | '', |
732 | 732 | 'spco-payment-method-desc ee-attention' |
733 | 733 | ); |
734 | 734 | |
735 | 735 | return new EE_Form_Section_Proper( |
736 | 736 | array( |
737 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
737 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
738 | 738 | 'html_class' => 'spco-payment-method-info-dv', |
739 | 739 | // only display the selected or default PM |
740 | 740 | 'html_style' => $currently_selected ? '' : 'display:none;', |
741 | 741 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
742 | 742 | 'subsections' => array( |
743 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
743 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
744 | 744 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
745 | 745 | ) |
746 | 746 | ) |
@@ -758,12 +758,12 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function get_billing_form_html_for_payment_method() { |
760 | 760 | // how have they chosen to pay? |
761 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
761 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
762 | 762 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
763 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
763 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
764 | 764 | return FALSE; |
765 | 765 | } |
766 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
766 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
767 | 767 | EE_Error::add_success( |
768 | 768 | apply_filters( |
769 | 769 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -772,20 +772,20 @@ discard block |
||
772 | 772 | ); |
773 | 773 | } |
774 | 774 | // now generate billing form for selected method of payment |
775 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
775 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
776 | 776 | // fill form with attendee info if applicable |
777 | - if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
778 | - $payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
777 | + if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
778 | + $payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
779 | 779 | } |
780 | 780 | // and debug content |
781 | - if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
782 | - $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form ); |
|
781 | + if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
782 | + $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form); |
|
783 | 783 | } |
784 | 784 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : ''; |
785 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info )); |
|
785 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
786 | 786 | // localize validation rules for main form |
787 | 787 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
788 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
788 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
789 | 789 | return TRUE; |
790 | 790 | } |
791 | 791 | |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | * @param EE_Payment_Method $payment_method |
799 | 799 | * @return \EE_Billing_Info_Form |
800 | 800 | */ |
801 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
802 | - $billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) ); |
|
803 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
804 | - if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) { |
|
805 | - if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) { |
|
801 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
802 | + $billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing)); |
|
803 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
804 | + if (EE_Registry::instance()->REQ->is_set('payment_method')) { |
|
805 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
806 | 806 | EE_Error::add_success( |
807 | 807 | apply_filters( |
808 | 808 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
809 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() ) |
|
809 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name()) |
|
810 | 810 | ) |
811 | 811 | ); |
812 | 812 | } |
@@ -831,27 +831,27 @@ discard block |
||
831 | 831 | * @param string $request_param |
832 | 832 | * @return NULL|string |
833 | 833 | */ |
834 | - private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) { |
|
834 | + private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') { |
|
835 | 835 | // is selected_method_of_payment set in the request ? |
836 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE ); |
|
837 | - if ( $selected_method_of_payment ) { |
|
836 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE); |
|
837 | + if ($selected_method_of_payment) { |
|
838 | 838 | // sanitize it |
839 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment; |
|
840 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
839 | + $selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment; |
|
840 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
841 | 841 | // store it in the session so that it's available for all subsequent requests including AJAX |
842 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
842 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
843 | 843 | } else { |
844 | 844 | // or is is set in the session ? |
845 | - $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' ); |
|
845 | + $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment'); |
|
846 | 846 | } |
847 | 847 | // do ya really really gotta have it? |
848 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
848 | + if (empty($selected_method_of_payment) && $required) { |
|
849 | 849 | EE_Error::add_error( |
850 | 850 | sprintf( |
851 | - __( 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso' ), |
|
851 | + __('The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso'), |
|
852 | 852 | '<br/>', |
853 | 853 | '<br/>', |
854 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
854 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
855 | 855 | ), |
856 | 856 | __FILE__, __FUNCTION__, __LINE__ |
857 | 857 | ); |
@@ -877,37 +877,37 @@ discard block |
||
877 | 877 | * @return string |
878 | 878 | */ |
879 | 879 | public function switch_payment_method() { |
880 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
880 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
881 | 881 | return FALSE; |
882 | 882 | } |
883 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
883 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
884 | 884 | EE_Error::add_success( |
885 | 885 | apply_filters( |
886 | 886 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
887 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $this->checkout->payment_method->name() ) |
|
887 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name()) |
|
888 | 888 | ) |
889 | 889 | ); |
890 | 890 | } |
891 | 891 | // generate billing form for selected method of payment if it hasn't been done already |
892 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
893 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
892 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
893 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
894 | 894 | } |
895 | 895 | // fill form with attendee info if applicable |
896 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
897 | - $this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
896 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
897 | + $this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
898 | 898 | } |
899 | 899 | // and debug content |
900 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
901 | - $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form ); |
|
900 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
901 | + $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form); |
|
902 | 902 | } |
903 | 903 | // get html and validation rules for form |
904 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
905 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() )); |
|
904 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
905 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html())); |
|
906 | 906 | // localize validation rules for main form |
907 | - $this->checkout->billing_form->localize_validation_rules( TRUE ); |
|
908 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
907 | + $this->checkout->billing_form->localize_validation_rules(TRUE); |
|
908 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
909 | 909 | } else { |
910 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' )); |
|
910 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
911 | 911 | } |
912 | 912 | //prevents advancement to next step |
913 | 913 | $this->checkout->continue_reg = FALSE; |
@@ -922,12 +922,12 @@ discard block |
||
922 | 922 | */ |
923 | 923 | protected function _verify_payment_method_is_set() { |
924 | 924 | // generate billing form for selected method of payment if it hasn't been done already |
925 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
925 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
926 | 926 | // how have they chosen to pay? |
927 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
927 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
928 | 928 | } |
929 | 929 | // verify payment method |
930 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
930 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
931 | 931 | // get payment method for selected method of payment |
932 | 932 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
933 | 933 | } |
@@ -947,23 +947,23 @@ discard block |
||
947 | 947 | * @return void |
948 | 948 | */ |
949 | 949 | public function save_payer_details_via_ajax() { |
950 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
950 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
951 | 951 | return; |
952 | 952 | } |
953 | 953 | // generate billing form for selected method of payment if it hasn't been done already |
954 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
955 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
954 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
955 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
956 | 956 | } |
957 | 957 | // generate primary attendee from payer info if applicable |
958 | 958 | if ( ! $this->checkout->transaction_has_primary_registrant()) { |
959 | 959 | $attendee = $this->_create_attendee_from_request_data(); |
960 | - if ( $attendee instanceof EE_Attendee ) { |
|
961 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
962 | - if ( $registration->is_primary_registrant() ) { |
|
960 | + if ($attendee instanceof EE_Attendee) { |
|
961 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
962 | + if ($registration->is_primary_registrant()) { |
|
963 | 963 | $this->checkout->primary_attendee_obj = $attendee; |
964 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
965 | - $registration->set_attendee_id( $attendee->ID() ); |
|
966 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
964 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
965 | + $registration->set_attendee_id($attendee->ID()); |
|
966 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | } |
@@ -976,56 +976,56 @@ discard block |
||
976 | 976 | * uses info from alternate GET or POST data (such as AJAX) to create a new attendee |
977 | 977 | * @return \EE_Attendee |
978 | 978 | */ |
979 | - protected function _create_attendee_from_request_data(){ |
|
979 | + protected function _create_attendee_from_request_data() { |
|
980 | 980 | // get State ID |
981 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
982 | - if ( ! empty( $STA_ID )) { |
|
981 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
982 | + if ( ! empty($STA_ID)) { |
|
983 | 983 | // can we get state object from name ? |
984 | - EE_Registry::instance()->load_model( 'State' ); |
|
985 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' ); |
|
986 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
984 | + EE_Registry::instance()->load_model('State'); |
|
985 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
986 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
987 | 987 | } |
988 | 988 | // get Country ISO |
989 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
990 | - if ( ! empty( $CNT_ISO )) { |
|
989 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
990 | + if ( ! empty($CNT_ISO)) { |
|
991 | 991 | // can we get country object from name ? |
992 | - EE_Registry::instance()->load_model( 'Country' ); |
|
993 | - $country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' ); |
|
994 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
992 | + EE_Registry::instance()->load_model('Country'); |
|
993 | + $country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO'); |
|
994 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
995 | 995 | } |
996 | 996 | // grab attendee data |
997 | 997 | $attendee_data = array( |
998 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
999 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1000 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1001 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1002 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1003 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
998 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
999 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1000 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1001 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1002 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1003 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1004 | 1004 | 'STA_ID' => $STA_ID, |
1005 | 1005 | 'CNT_ISO' => $CNT_ISO, |
1006 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1007 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1006 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1007 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1008 | 1008 | ); |
1009 | 1009 | // validate the email address since it is the most important piece of info |
1010 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) { |
|
1011 | - EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1010 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) { |
|
1011 | + EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1012 | 1012 | } |
1013 | 1013 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1014 | - if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) { |
|
1015 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array( |
|
1014 | + if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) { |
|
1015 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array( |
|
1016 | 1016 | 'ATT_fname' => $attendee_data['ATT_fname'], |
1017 | 1017 | 'ATT_lname' => $attendee_data['ATT_lname'], |
1018 | 1018 | 'ATT_email' => $attendee_data['ATT_email'] |
1019 | 1019 | )); |
1020 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1020 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1021 | 1021 | return $existing_attendee; |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | // no existing attendee? kk let's create a new one |
1025 | 1025 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1026 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1026 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | + return EE_Attendee::new_instance($attendee_data); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | |
@@ -1045,22 +1045,22 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | public function process_reg_step() { |
1047 | 1047 | // how have they chosen to pay? |
1048 | - $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE ); |
|
1048 | + $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE); |
|
1049 | 1049 | // choose your own adventure based on method_of_payment |
1050 | - switch( $this->checkout->selected_method_of_payment ) { |
|
1050 | + switch ($this->checkout->selected_method_of_payment) { |
|
1051 | 1051 | |
1052 | 1052 | case 'events_sold_out' : |
1053 | 1053 | $this->checkout->redirect = TRUE; |
1054 | 1054 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1055 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1055 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1056 | 1056 | // mark this reg step as completed |
1057 | 1057 | $this->set_completed(); |
1058 | 1058 | return FALSE; |
1059 | 1059 | break; |
1060 | 1060 | |
1061 | 1061 | case 'payments_closed' : |
1062 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) { |
|
1063 | - EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1062 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) { |
|
1063 | + EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1064 | 1064 | } |
1065 | 1065 | // mark this reg step as completed |
1066 | 1066 | $this->set_completed(); |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | break; |
1069 | 1069 | |
1070 | 1070 | case 'no_payment_required' : |
1071 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) { |
|
1072 | - EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1071 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) { |
|
1072 | + EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1073 | 1073 | } |
1074 | 1074 | // mark this reg step as completed |
1075 | 1075 | $this->set_completed(); |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | default: |
1080 | 1080 | $payment_successful = $this->_process_payment(); |
1081 | - if ( $payment_successful ) { |
|
1081 | + if ($payment_successful) { |
|
1082 | 1082 | $this->checkout->continue_reg = true; |
1083 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1083 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1084 | 1084 | } else { |
1085 | 1085 | $this->checkout->continue_reg = false; |
1086 | 1086 | } |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @param \EE_Payment_Method $payment_method |
1099 | 1099 | * @return void |
1100 | 1100 | */ |
1101 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1102 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1101 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1102 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1103 | 1103 | case EE_PMT_Base::offsite : |
1104 | 1104 | break; |
1105 | 1105 | case EE_PMT_Base::onsite : |
@@ -1122,15 +1122,15 @@ discard block |
||
1122 | 1122 | public function update_reg_step() { |
1123 | 1123 | $success = TRUE; |
1124 | 1124 | // if payment required |
1125 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1126 | - do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction ); |
|
1125 | + if ($this->checkout->transaction->total() > 0) { |
|
1126 | + do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction); |
|
1127 | 1127 | // attempt payment via payment method |
1128 | 1128 | $success = $this->process_reg_step(); |
1129 | 1129 | } |
1130 | - if ( $success && ! $this->checkout->redirect ) { |
|
1131 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() ); |
|
1130 | + if ($success && ! $this->checkout->redirect) { |
|
1131 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID()); |
|
1132 | 1132 | // set return URL |
1133 | - $this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url ); |
|
1133 | + $this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url); |
|
1134 | 1134 | } |
1135 | 1135 | return $success; |
1136 | 1136 | } |
@@ -1150,24 +1150,24 @@ discard block |
||
1150 | 1150 | // clear any previous errors related to not selecting a payment method |
1151 | 1151 | // EE_Error::overwrite_errors(); |
1152 | 1152 | // ya gotta make a choice man |
1153 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
1154 | - $this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' )); |
|
1153 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1154 | + $this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso')); |
|
1155 | 1155 | return FALSE; |
1156 | 1156 | } |
1157 | 1157 | // get EE_Payment_Method object |
1158 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1158 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1159 | 1159 | return FALSE; |
1160 | 1160 | } |
1161 | 1161 | // setup billing form |
1162 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1163 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1162 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1163 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1164 | 1164 | // bad billing form ? |
1165 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1165 | + if ( ! $this->_billing_form_is_valid()) { |
|
1166 | 1166 | return FALSE; |
1167 | 1167 | } |
1168 | 1168 | } |
1169 | 1169 | // ensure primary registrant has been fully processed |
1170 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1170 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1171 | 1171 | return FALSE; |
1172 | 1172 | } |
1173 | 1173 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1175,24 +1175,24 @@ discard block |
||
1175 | 1175 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1176 | 1176 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1177 | 1177 | // attempt payment |
1178 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1178 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1179 | 1179 | // process results |
1180 | - $payment = $this->_validate_payment( $payment ); |
|
1181 | - $payment = $this->_post_payment_processing( $payment ); |
|
1180 | + $payment = $this->_validate_payment($payment); |
|
1181 | + $payment = $this->_post_payment_processing($payment); |
|
1182 | 1182 | // verify payment |
1183 | - if ( $payment instanceof EE_Payment ) { |
|
1183 | + if ($payment instanceof EE_Payment) { |
|
1184 | 1184 | // store that for later |
1185 | 1185 | $this->checkout->payment = $payment; |
1186 | 1186 | /** @type EE_Transaction_Processor $transaction_processor */ |
1187 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1187 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1188 | 1188 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1189 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1190 | - if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) { |
|
1189 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1190 | + if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) { |
|
1191 | 1191 | return true; |
1192 | 1192 | } else { |
1193 | 1193 | return false; |
1194 | 1194 | } |
1195 | - } else if ( $payment === true ) { |
|
1195 | + } else if ($payment === true) { |
|
1196 | 1196 | // please note that offline payment methods will NOT make a payment, |
1197 | 1197 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1198 | 1198 | $this->checkout->payment = $payment; |
@@ -1211,10 +1211,10 @@ discard block |
||
1211 | 1211 | * @return bool |
1212 | 1212 | */ |
1213 | 1213 | public function redirect_form() { |
1214 | - $payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() ); |
|
1214 | + $payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment()); |
|
1215 | 1215 | $html = $payment_method_billing_info->get_html_and_js(); |
1216 | 1216 | $html .= $this->checkout->redirect_form; |
1217 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1217 | + EE_Registry::instance()->REQ->add_output($html); |
|
1218 | 1218 | return TRUE; |
1219 | 1219 | } |
1220 | 1220 | |
@@ -1227,36 +1227,36 @@ discard block |
||
1227 | 1227 | * @return bool |
1228 | 1228 | */ |
1229 | 1229 | private function _billing_form_is_valid() { |
1230 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1230 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1231 | 1231 | return TRUE; |
1232 | 1232 | } |
1233 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1234 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1233 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1234 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1235 | 1235 | $this->checkout->billing_form->receive_form_submission(); |
1236 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1236 | + if ($this->checkout->billing_form->is_valid()) { |
|
1237 | 1237 | return TRUE; |
1238 | 1238 | } |
1239 | 1239 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1240 | 1240 | $error_strings = array(); |
1241 | - foreach( $validation_errors as $validation_error ){ |
|
1242 | - if( $validation_error instanceof EE_Validation_Error ){ |
|
1241 | + foreach ($validation_errors as $validation_error) { |
|
1242 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1243 | 1243 | $form_section = $validation_error->get_form_section(); |
1244 | - if( $form_section instanceof EE_Form_Input_Base ){ |
|
1244 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1245 | 1245 | $label = $form_section->html_label_text(); |
1246 | - }elseif( $form_section instanceof EE_Form_Section_Base ){ |
|
1246 | + }elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1247 | 1247 | $label = $form_section->name(); |
1248 | - }else{ |
|
1249 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1248 | + } else { |
|
1249 | + $label = __('Validation Error', 'event_espresso'); |
|
1250 | 1250 | } |
1251 | - $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1251 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1252 | 1252 | } |
1253 | 1253 | } |
1254 | - EE_Error::add_error( sprintf( __( 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso' ), '<br/>', implode( '<br/>', $error_strings ) ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1254 | + EE_Error::add_error(sprintf(__('One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso'), '<br/>', implode('<br/>', $error_strings)), __FILE__, __FUNCTION__, __LINE__); |
|
1255 | 1255 | } else { |
1256 | - EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1256 | + EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1257 | 1257 | } |
1258 | 1258 | } else { |
1259 | - EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1259 | + EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1260 | 1260 | } |
1261 | 1261 | return FALSE; |
1262 | 1262 | } |
@@ -1274,9 +1274,9 @@ discard block |
||
1274 | 1274 | */ |
1275 | 1275 | private function _setup_primary_registrant_prior_to_payment() { |
1276 | 1276 | // check if transaction has a primary registrant and that it has a related Attendee object |
1277 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1277 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1278 | 1278 | // need to at least gather some primary registrant data before attempting payment |
1279 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) { |
|
1279 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) { |
|
1280 | 1280 | return FALSE; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1284,13 +1284,13 @@ discard block |
||
1284 | 1284 | // grab the primary_registration object |
1285 | 1285 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1286 | 1286 | /** @type EE_Transaction_Processor $transaction_processor */ |
1287 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1287 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1288 | 1288 | // at this point we'll consider a TXN to not have been failed |
1289 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1289 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1290 | 1290 | // save the TXN ( which clears cached copy of primary_registration) |
1291 | 1291 | $this->checkout->transaction->save(); |
1292 | 1292 | // grab TXN ID and save it to the primary_registration |
1293 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1293 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1294 | 1294 | // save what we have so far |
1295 | 1295 | $primary_registration->save(); |
1296 | 1296 | return TRUE; |
@@ -1307,41 +1307,41 @@ discard block |
||
1307 | 1307 | private function _capture_primary_registration_data_from_billing_form() { |
1308 | 1308 | // convert billing form data into an attendee |
1309 | 1309 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1310 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1310 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1311 | 1311 | EE_Error::add_error( |
1312 | 1312 | sprintf( |
1313 | - __( 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1313 | + __('The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1314 | 1314 | '<br/>', |
1315 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1315 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1316 | 1316 | ), __FILE__, __FUNCTION__, __LINE__ |
1317 | 1317 | ); |
1318 | 1318 | return FALSE; |
1319 | 1319 | } |
1320 | 1320 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1321 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1321 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1322 | 1322 | EE_Error::add_error( |
1323 | 1323 | sprintf( |
1324 | - __( 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1324 | + __('The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1325 | 1325 | '<br/>', |
1326 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1326 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1327 | 1327 | ), __FILE__, __FUNCTION__, __LINE__ |
1328 | 1328 | ); |
1329 | 1329 | return FALSE; |
1330 | 1330 | } |
1331 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) { |
|
1331 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) { |
|
1332 | 1332 | EE_Error::add_error( |
1333 | 1333 | sprintf( |
1334 | - __( 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1334 | + __('The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1335 | 1335 | '<br/>', |
1336 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1336 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1337 | 1337 | ), __FILE__, __FUNCTION__, __LINE__ |
1338 | 1338 | ); |
1339 | 1339 | return FALSE; |
1340 | 1340 | } |
1341 | 1341 | /** @type EE_Registration_Processor $registration_processor */ |
1342 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1342 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1343 | 1343 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1344 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1344 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1345 | 1345 | |
1346 | 1346 | return TRUE; |
1347 | 1347 | } |
@@ -1357,35 +1357,35 @@ discard block |
||
1357 | 1357 | */ |
1358 | 1358 | private function _get_payment_method_for_selected_method_of_payment() { |
1359 | 1359 | // get EE_Payment_Method object |
1360 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) { |
|
1361 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1360 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1361 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1362 | 1362 | } else { |
1363 | 1363 | // load EEM_Payment_Method |
1364 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1364 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1365 | 1365 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1366 | 1366 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1367 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1367 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1368 | 1368 | } |
1369 | 1369 | // verify $payment_method |
1370 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1370 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1371 | 1371 | // not a payment |
1372 | 1372 | EE_Error::add_error( |
1373 | 1373 | sprintf( |
1374 | - __( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1374 | + __('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1375 | 1375 | '<br/>', |
1376 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1376 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1377 | 1377 | ), __FILE__, __FUNCTION__, __LINE__ |
1378 | 1378 | ); |
1379 | 1379 | return NULL; |
1380 | 1380 | } |
1381 | 1381 | // and verify it has a valid Payment_Method Type object |
1382 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1382 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1383 | 1383 | // not a payment |
1384 | 1384 | EE_Error::add_error( |
1385 | 1385 | sprintf( |
1386 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1386 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1387 | 1387 | '<br/>', |
1388 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1388 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1389 | 1389 | ), __FILE__, __FUNCTION__, __LINE__ |
1390 | 1390 | ); |
1391 | 1391 | return NULL; |
@@ -1404,30 +1404,30 @@ discard block |
||
1404 | 1404 | * @type EE_Payment_Method $payment_method |
1405 | 1405 | * @return mixed EE_Payment | boolean |
1406 | 1406 | */ |
1407 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1408 | - $payment =NULL; |
|
1407 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1408 | + $payment = NULL; |
|
1409 | 1409 | $this->checkout->transaction->save(); |
1410 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1411 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1410 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1411 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1412 | 1412 | return FALSE; |
1413 | 1413 | } |
1414 | 1414 | try { |
1415 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1415 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1416 | 1416 | // generate payment object |
1417 | 1417 | $payment = $payment_processor->process_payment( |
1418 | 1418 | $payment_method, |
1419 | 1419 | $this->checkout->transaction, |
1420 | 1420 | $this->checkout->amount_owing, |
1421 | 1421 | $this->checkout->billing_form, |
1422 | - $this->_get_return_url( $payment_method ), |
|
1422 | + $this->_get_return_url($payment_method), |
|
1423 | 1423 | 'CART', |
1424 | 1424 | $this->checkout->admin_request, |
1425 | 1425 | TRUE, |
1426 | 1426 | $this->reg_step_url() |
1427 | 1427 | ); |
1428 | 1428 | |
1429 | - } catch( Exception $e ) { |
|
1430 | - $this->_handle_payment_processor_exception( $e ); |
|
1429 | + } catch (Exception $e) { |
|
1430 | + $this->_handle_payment_processor_exception($e); |
|
1431 | 1431 | } |
1432 | 1432 | return $payment; |
1433 | 1433 | } |
@@ -1441,12 +1441,12 @@ discard block |
||
1441 | 1441 | * @param \Exception $e |
1442 | 1442 | * @return void |
1443 | 1443 | */ |
1444 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1444 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1445 | 1445 | EE_Error::add_error( |
1446 | 1446 | sprintf( |
1447 | - __( 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso' ), |
|
1447 | + __('The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso'), |
|
1448 | 1448 | '<br/>', |
1449 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1449 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1450 | 1450 | $e->getMessage(), |
1451 | 1451 | $e->getFile(), |
1452 | 1452 | $e->getLine() |
@@ -1463,9 +1463,9 @@ discard block |
||
1463 | 1463 | * @param \EE_Payment_Method $payment_method |
1464 | 1464 | * @return string |
1465 | 1465 | */ |
1466 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1466 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1467 | 1467 | $return_url = ''; |
1468 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1468 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1469 | 1469 | |
1470 | 1470 | case EE_PMT_Base::offsite : |
1471 | 1471 | $return_url = add_query_arg( |
@@ -1496,27 +1496,27 @@ discard block |
||
1496 | 1496 | * @param EE_Payment $payment |
1497 | 1497 | * @return EE_Payment | FALSE |
1498 | 1498 | */ |
1499 | - private function _validate_payment( $payment = NULL ) { |
|
1500 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1499 | + private function _validate_payment($payment = NULL) { |
|
1500 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1501 | 1501 | return TRUE; |
1502 | 1502 | } |
1503 | 1503 | // verify payment object |
1504 | - if ( $payment instanceof EE_Payment ) { |
|
1504 | + if ($payment instanceof EE_Payment) { |
|
1505 | 1505 | if ( |
1506 | 1506 | $payment->status() != EEM_Payment::status_id_approved |
1507 | 1507 | && $payment->status() != EEM_Payment::status_id_pending |
1508 | 1508 | && $payment->status() != EEM_Payment::status_id_cancelled |
1509 | 1509 | && $payment->gateway_response() != '' |
1510 | 1510 | ) { |
1511 | - EE_Error::add_error( $payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1511 | + EE_Error::add_error($payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__); |
|
1512 | 1512 | } |
1513 | 1513 | } else { |
1514 | 1514 | // not a payment |
1515 | 1515 | EE_Error::add_error( |
1516 | 1516 | sprintf( |
1517 | - __( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1517 | + __('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1518 | 1518 | '<br/>', |
1519 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1519 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1520 | 1520 | ), __FILE__, __FUNCTION__, __LINE__ |
1521 | 1521 | ); |
1522 | 1522 | return FALSE; |
@@ -1533,23 +1533,23 @@ discard block |
||
1533 | 1533 | * @param EE_Payment $payment |
1534 | 1534 | * @return bool |
1535 | 1535 | */ |
1536 | - private function _post_payment_processing( $payment = NULL ) { |
|
1536 | + private function _post_payment_processing($payment = NULL) { |
|
1537 | 1537 | // On-Site payment? |
1538 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1539 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) { |
|
1538 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1539 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1540 | 1540 | //$this->_setup_redirect_for_next_step(); |
1541 | 1541 | $this->checkout->continue_reg = false; |
1542 | 1542 | } |
1543 | 1543 | // Off-Site payment? |
1544 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1544 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1545 | 1545 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1546 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ){ |
|
1547 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1546 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1547 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1548 | 1548 | $this->checkout->redirect = TRUE; |
1549 | 1549 | $this->checkout->redirect_form = $payment->redirect_form(); |
1550 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1550 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1551 | 1551 | // set JSON response |
1552 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1552 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1553 | 1553 | // set cron job for finalizing the TXN |
1554 | 1554 | // in case the user does not return from the off-site gateway |
1555 | 1555 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1557,21 +1557,21 @@ discard block |
||
1557 | 1557 | $this->checkout->transaction->ID() |
1558 | 1558 | ); |
1559 | 1559 | // and lastly, let's bump the payment status to pending |
1560 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1560 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1561 | 1561 | $payment->save(); |
1562 | 1562 | } else { |
1563 | 1563 | // not a payment |
1564 | 1564 | $this->checkout->continue_reg = false; |
1565 | 1565 | EE_Error::add_error( |
1566 | 1566 | sprintf( |
1567 | - __( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1567 | + __('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1568 | 1568 | '<br/>', |
1569 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1569 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1570 | 1570 | ), __FILE__, __FUNCTION__, __LINE__ |
1571 | 1571 | ); |
1572 | 1572 | } |
1573 | 1573 | // Off-Line payment? |
1574 | - } else if ( $payment === TRUE ) { |
|
1574 | + } else if ($payment === TRUE) { |
|
1575 | 1575 | //$this->_setup_redirect_for_next_step(); |
1576 | 1576 | return TRUE; |
1577 | 1577 | } else { |
@@ -1607,65 +1607,65 @@ discard block |
||
1607 | 1607 | * @return bool |
1608 | 1608 | * @throws \EE_Error |
1609 | 1609 | */ |
1610 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1610 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1611 | 1611 | // off-line payment? carry on |
1612 | - if ( $payment_occurs == EE_PMT_Base::offline ) { |
|
1612 | + if ($payment_occurs == EE_PMT_Base::offline) { |
|
1613 | 1613 | return true; |
1614 | 1614 | } |
1615 | 1615 | // verify payment validity |
1616 | - if ( $payment instanceof EE_Payment ) { |
|
1617 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1616 | + if ($payment instanceof EE_Payment) { |
|
1617 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1618 | 1618 | $msg = $payment->gateway_response(); |
1619 | 1619 | // check results |
1620 | - switch ( $payment->status() ) { |
|
1620 | + switch ($payment->status()) { |
|
1621 | 1621 | |
1622 | 1622 | // good payment |
1623 | 1623 | case EEM_Payment::status_id_approved : |
1624 | - EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1624 | + EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1625 | 1625 | return TRUE; |
1626 | 1626 | break; |
1627 | 1627 | |
1628 | 1628 | // slow payment |
1629 | 1629 | case EEM_Payment::status_id_pending : |
1630 | - if ( empty( $msg )) { |
|
1631 | - $msg = __( 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso' ); |
|
1630 | + if (empty($msg)) { |
|
1631 | + $msg = __('Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso'); |
|
1632 | 1632 | } |
1633 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1633 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1634 | 1634 | return TRUE; |
1635 | 1635 | break; |
1636 | 1636 | |
1637 | 1637 | // don't wanna payment |
1638 | 1638 | case EEM_Payment::status_id_cancelled : |
1639 | - if ( empty( $msg )) { |
|
1639 | + if (empty($msg)) { |
|
1640 | 1640 | $msg = _n( |
1641 | 1641 | 'Payment cancelled. Please try again.', |
1642 | 1642 | 'Payment cancelled. Please try again or select another method of payment.', |
1643 | - count( $this->checkout->available_payment_methods ), |
|
1643 | + count($this->checkout->available_payment_methods), |
|
1644 | 1644 | 'event_espresso' |
1645 | 1645 | ); |
1646 | 1646 | } |
1647 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1647 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1648 | 1648 | return FALSE; |
1649 | 1649 | break; |
1650 | 1650 | |
1651 | 1651 | // not enough payment |
1652 | 1652 | case EEM_Payment::status_id_declined : |
1653 | - if ( empty( $msg )) { |
|
1653 | + if (empty($msg)) { |
|
1654 | 1654 | $msg = _n( |
1655 | 1655 | 'We\'re sorry but your payment was declined. Please try again.', |
1656 | 1656 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
1657 | - count( $this->checkout->available_payment_methods ), |
|
1657 | + count($this->checkout->available_payment_methods), |
|
1658 | 1658 | 'event_espresso' |
1659 | 1659 | ); |
1660 | 1660 | } |
1661 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1661 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1662 | 1662 | return FALSE; |
1663 | 1663 | break; |
1664 | 1664 | |
1665 | 1665 | // bad payment |
1666 | 1666 | case EEM_Payment::status_id_failed : |
1667 | - if ( ! empty( $msg ) ) { |
|
1668 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1667 | + if ( ! empty($msg)) { |
|
1668 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1669 | 1669 | return false; |
1670 | 1670 | } |
1671 | 1671 | // default to error below |
@@ -1675,14 +1675,14 @@ discard block |
||
1675 | 1675 | } |
1676 | 1676 | // off-site payment gateway responses are too unreliable, so let's just assume that |
1677 | 1677 | // the payment processing is just running slower than the registrant's request |
1678 | - if ( $payment_occurs == EE_PMT_Base::offsite ) { |
|
1678 | + if ($payment_occurs == EE_PMT_Base::offsite) { |
|
1679 | 1679 | return true; |
1680 | 1680 | } |
1681 | 1681 | EE_Error::add_error( |
1682 | 1682 | sprintf( |
1683 | - __( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1683 | + __('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1684 | 1684 | '<br/>', |
1685 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1685 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1686 | 1686 | ), |
1687 | 1687 | __FILE__, __FUNCTION__, __LINE__ |
1688 | 1688 | ); |
@@ -1715,13 +1715,13 @@ discard block |
||
1715 | 1715 | public function process_gateway_response() { |
1716 | 1716 | $payment = null; |
1717 | 1717 | // how have they chosen to pay? |
1718 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1718 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1719 | 1719 | // get EE_Payment_Method object |
1720 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1720 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1721 | 1721 | $this->checkout->continue_reg = false; |
1722 | 1722 | return false; |
1723 | 1723 | } |
1724 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
1724 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
1725 | 1725 | return false; |
1726 | 1726 | } |
1727 | 1727 | $this->_validate_offsite_return(); |
@@ -1735,23 +1735,23 @@ discard block |
||
1735 | 1735 | // true |
1736 | 1736 | //); |
1737 | 1737 | // verify TXN |
1738 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1738 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1739 | 1739 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
1740 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
1740 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
1741 | 1741 | $this->checkout->continue_reg = false; |
1742 | 1742 | return false; |
1743 | 1743 | } |
1744 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
1745 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
1746 | - $payment = $this->_validate_payment( $payment ); |
|
1744 | + $payment = $this->_process_off_site_payment($gateway); |
|
1745 | + $payment = $this->_process_cancelled_payments($payment); |
|
1746 | + $payment = $this->_validate_payment($payment); |
|
1747 | 1747 | // if payment was not declined by the payment gateway or cancelled by the registrant |
1748 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
1748 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
1749 | 1749 | //$this->_setup_redirect_for_next_step(); |
1750 | 1750 | // store that for later |
1751 | 1751 | $this->checkout->payment = $payment; |
1752 | 1752 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
1753 | 1753 | // because we will complete this step during the IPN processing then |
1754 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) { |
|
1754 | + if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) { |
|
1755 | 1755 | $this->set_completed(); |
1756 | 1756 | } |
1757 | 1757 | return true; |
@@ -1774,19 +1774,19 @@ discard block |
||
1774 | 1774 | * @return bool |
1775 | 1775 | */ |
1776 | 1776 | private function _validate_offsite_return() { |
1777 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
1778 | - if ( $TXN_ID != $this->checkout->transaction->ID() ) { |
|
1777 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
1778 | + if ($TXN_ID != $this->checkout->transaction->ID()) { |
|
1779 | 1779 | // Houston... we might have a problem |
1780 | 1780 | $invalid_TXN = false; |
1781 | 1781 | // first gather some info |
1782 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1782 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1783 | 1783 | $primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null; |
1784 | 1784 | // let's start by retrieving the cart for this TXN |
1785 | - $cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction ); |
|
1786 | - if ( $cart instanceof EE_Cart ) { |
|
1785 | + $cart = EE_Cart::get_cart_from_txn($this->checkout->transaction); |
|
1786 | + if ($cart instanceof EE_Cart) { |
|
1787 | 1787 | // verify that the current cart has tickets |
1788 | 1788 | $tickets = $cart->get_tickets(); |
1789 | - if ( empty( $tickets ) ) { |
|
1789 | + if (empty($tickets)) { |
|
1790 | 1790 | $invalid_TXN = true; |
1791 | 1791 | } |
1792 | 1792 | } else { |
@@ -1794,39 +1794,39 @@ discard block |
||
1794 | 1794 | } |
1795 | 1795 | $valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null; |
1796 | 1796 | // validate current Session ID and compare against valid TXN session ID |
1797 | - if ( EE_Session::instance()->id() === null ) { |
|
1797 | + if (EE_Session::instance()->id() === null) { |
|
1798 | 1798 | $invalid_TXN = true; |
1799 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
1799 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
1800 | 1800 | // WARNING !!! |
1801 | 1801 | // this could be PayPal sending back duplicate requests (ya they do that) |
1802 | 1802 | // or it **could** mean someone is simply registering AGAIN after having just done so |
1803 | 1803 | // so now we need to determine if this current TXN looks valid or not |
1804 | 1804 | /** @type EE_Transaction_Processor $transaction_processor */ |
1805 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1805 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1806 | 1806 | // has this step even been started ? |
1807 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
1807 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
1808 | 1808 | ) { |
1809 | 1809 | // really? you're half way through this reg step, but you never started it ? |
1810 | 1810 | $invalid_TXN = true; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | - if ( $invalid_TXN ) { |
|
1813 | + if ($invalid_TXN) { |
|
1814 | 1814 | // is the valid TXN completed ? |
1815 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
1815 | + if ($valid_TXN instanceof EE_Transaction) { |
|
1816 | 1816 | /** @type EE_Transaction_Processor $transaction_processor */ |
1817 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1817 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1818 | 1818 | // has this step even been started ? |
1819 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
1820 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
1819 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
1820 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
1821 | 1821 | // so it **looks** like this is a double request from PayPal |
1822 | 1822 | // so let's try to pick up where we left off |
1823 | 1823 | $this->checkout->transaction = $valid_TXN; |
1824 | - $this->checkout->refresh_all_entities( true ); |
|
1824 | + $this->checkout->refresh_all_entities(true); |
|
1825 | 1825 | return; |
1826 | 1826 | } |
1827 | 1827 | } |
1828 | 1828 | // you appear to be lost? |
1829 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
1829 | + $this->_redirect_wayward_request($primary_registrant); |
|
1830 | 1830 | } |
1831 | 1831 | } |
1832 | 1832 | } |
@@ -1840,16 +1840,16 @@ discard block |
||
1840 | 1840 | * @param \EE_Registration $primary_registrant |
1841 | 1841 | * @return bool |
1842 | 1842 | */ |
1843 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
1844 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1843 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
1844 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1845 | 1845 | // try redirecting based on the current TXN |
1846 | 1846 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null; |
1847 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1847 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1848 | 1848 | EE_Error::add_error( |
1849 | 1849 | sprintf( |
1850 | - __( 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1850 | + __('Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1851 | 1851 | '<br/>', |
1852 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1852 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1853 | 1853 | ), |
1854 | 1854 | __FILE__, __FUNCTION__, __LINE__ |
1855 | 1855 | ); |
@@ -1877,16 +1877,16 @@ discard block |
||
1877 | 1877 | * @param \EE_Offsite_Gateway $gateway |
1878 | 1878 | * @return \EE_Payment |
1879 | 1879 | */ |
1880 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
1880 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
1881 | 1881 | try { |
1882 | 1882 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
1883 | - if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) { |
|
1883 | + if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) { |
|
1884 | 1884 | $payment = $this->checkout->transaction->last_payment(); |
1885 | 1885 | //$payment_source = 'last_payment'; |
1886 | 1886 | } else { |
1887 | 1887 | // get payment details and process results |
1888 | 1888 | /** @type EE_Payment_Processor $payment_processor */ |
1889 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1889 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1890 | 1890 | $payment = $payment_processor->process_ipn( |
1891 | 1891 | $_REQUEST, |
1892 | 1892 | $this->checkout->transaction, |
@@ -1896,14 +1896,14 @@ discard block |
||
1896 | 1896 | ); |
1897 | 1897 | //$payment_source = 'process_ipn'; |
1898 | 1898 | } |
1899 | - } catch ( Exception $e ) { |
|
1899 | + } catch (Exception $e) { |
|
1900 | 1900 | // let's just eat the exception and try to move on using any previously set payment info |
1901 | 1901 | $payment = $this->checkout->transaction->last_payment(); |
1902 | 1902 | //$payment_source = 'last_payment after Exception'; |
1903 | 1903 | // but if we STILL don't have a payment object |
1904 | - if ( ! $payment instanceof EE_Payment ) { |
|
1904 | + if ( ! $payment instanceof EE_Payment) { |
|
1905 | 1905 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
1906 | - $this->_handle_payment_processor_exception( $e ); |
|
1906 | + $this->_handle_payment_processor_exception($e); |
|
1907 | 1907 | } |
1908 | 1908 | } |
1909 | 1909 | // DEBUG LOG |
@@ -1927,13 +1927,13 @@ discard block |
||
1927 | 1927 | * @param EE_Payment $payment |
1928 | 1928 | * @return EE_Payment | FALSE |
1929 | 1929 | */ |
1930 | - private function _process_cancelled_payments( $payment = NULL ) { |
|
1930 | + private function _process_cancelled_payments($payment = NULL) { |
|
1931 | 1931 | if ( |
1932 | - isset( $_REQUEST[ 'ee_cancel_payment' ] ) |
|
1932 | + isset($_REQUEST['ee_cancel_payment']) |
|
1933 | 1933 | && $payment instanceof EE_Payment |
1934 | 1934 | && $payment->status() == EEM_Payment::status_id_failed |
1935 | 1935 | ) { |
1936 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
1936 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
1937 | 1937 | } |
1938 | 1938 | return $payment; |
1939 | 1939 | } |
@@ -1950,23 +1950,23 @@ discard block |
||
1950 | 1950 | public function get_transaction_details_for_gateways() { |
1951 | 1951 | $txn_details = array(); |
1952 | 1952 | // ya gotta make a choice man |
1953 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1953 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1954 | 1954 | $txn_details = array( |
1955 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1955 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1956 | 1956 | ); |
1957 | 1957 | } |
1958 | 1958 | // get EE_Payment_Method object |
1959 | 1959 | if ( |
1960 | - empty( $txn_details ) && |
|
1960 | + empty($txn_details) && |
|
1961 | 1961 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
1962 | 1962 | ) { |
1963 | 1963 | $txn_details = array( |
1964 | 1964 | 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
1965 | - 'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' ) |
|
1965 | + 'error' => __('A valid Payment Method could not be determined.', 'event_espresso') |
|
1966 | 1966 | ); |
1967 | 1967 | } |
1968 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
1969 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
1968 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
1969 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
1970 | 1970 | $txn_details = array( |
1971 | 1971 | 'TXN_ID' => $this->checkout->transaction->ID(), |
1972 | 1972 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
1978 | 1978 | 'payment_amount' => $this->checkout->amount_owing, |
1979 | 1979 | 'return_url' => $return_url, |
1980 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
1980 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
1981 | 1981 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
1982 | 1982 | array( |
1983 | 1983 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -1986,7 +1986,7 @@ discard block |
||
1986 | 1986 | ) |
1987 | 1987 | ); |
1988 | 1988 | } |
1989 | - echo json_encode( $txn_details ); |
|
1989 | + echo json_encode($txn_details); |
|
1990 | 1990 | exit(); |
1991 | 1991 | } |
1992 | 1992 |