@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -435,8 +436,9 @@ discard block |
||
435 | 436 | //k we've got EVT_ID so let's use that to get the event we'll duplicate |
436 | 437 | $orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] ); |
437 | 438 | |
438 | - if ( ! $orig_event instanceof EE_Event ) |
|
439 | - throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'] ) ); |
|
439 | + if ( ! $orig_event instanceof EE_Event ) { |
|
440 | + throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'] ) ); |
|
441 | + } |
|
440 | 442 | |
441 | 443 | //k now let's clone the $orig_event before getting relations |
442 | 444 | $new_event = clone $orig_event; |
@@ -510,8 +512,9 @@ discard block |
||
510 | 512 | //now let's get the ticket relations setup. |
511 | 513 | foreach ( (array) $orig_tkts as $orig_tkt ) { |
512 | 514 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
513 | - if ( ! $orig_tkt instanceof EE_Ticket ) |
|
514 | - continue; |
|
515 | + if ( ! $orig_tkt instanceof EE_Ticket ) { |
|
516 | + continue; |
|
517 | + } |
|
515 | 518 | |
516 | 519 | //is this ticket archived? If it is then let's skip |
517 | 520 | if ( $orig_tkt->get( 'TKT_deleted' ) ) { |
@@ -620,9 +623,9 @@ discard block |
||
620 | 623 | protected function _events_export() { |
621 | 624 | if(isset($this->_req_data['EVT_ID'])){ |
622 | 625 | $event_ids = $this->_req_data['EVT_ID']; |
623 | - }elseif(isset($this->_req_data['EVT_IDs'])){ |
|
626 | + } elseif(isset($this->_req_data['EVT_IDs'])){ |
|
624 | 627 | $event_ids = $this->_req_data['EVT_IDs']; |
625 | - }else{ |
|
628 | + } else{ |
|
626 | 629 | $event_ids = NULL; |
627 | 630 | } |
628 | 631 | //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
@@ -811,8 +814,9 @@ discard block |
||
811 | 814 | |
812 | 815 | extract( wp_parse_args($args, $defaults), EXTR_SKIP ); |
813 | 816 | |
814 | - if ( empty($walker) || !is_a($walker, 'Walker') ) |
|
815 | - $walker = new Walker_Radio_Checklist; |
|
817 | + if ( empty($walker) || !is_a($walker, 'Walker') ) { |
|
818 | + $walker = new Walker_Radio_Checklist; |
|
819 | + } |
|
816 | 820 | |
817 | 821 | $descendants_and_self = (int) $descendants_and_self; |
818 | 822 | |
@@ -821,17 +825,19 @@ discard block |
||
821 | 825 | $tax = get_taxonomy($taxonomy); |
822 | 826 | $args['disabled'] = !current_user_can($tax->cap->assign_terms); |
823 | 827 | |
824 | - if ( is_array( $selected_cats ) ) |
|
825 | - $args['selected_cats'] = $selected_cats; |
|
826 | - elseif ( $post_id ) |
|
827 | - $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
|
828 | - else |
|
829 | - $args['selected_cats'] = array(); |
|
828 | + if ( is_array( $selected_cats ) ) { |
|
829 | + $args['selected_cats'] = $selected_cats; |
|
830 | + } elseif ( $post_id ) { |
|
831 | + $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
|
832 | + } else { |
|
833 | + $args['selected_cats'] = array(); |
|
834 | + } |
|
830 | 835 | |
831 | - if ( is_array( $popular_cats ) ) |
|
832 | - $args['popular_cats'] = $popular_cats; |
|
833 | - else |
|
834 | - $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
836 | + if ( is_array( $popular_cats ) ) { |
|
837 | + $args['popular_cats'] = $popular_cats; |
|
838 | + } else { |
|
839 | + $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
840 | + } |
|
835 | 841 | |
836 | 842 | if ( $descendants_and_self ) { |
837 | 843 | $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); |
@@ -884,8 +890,9 @@ discard block |
||
884 | 890 | $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
885 | 891 | |
886 | 892 | //active status dropdown |
887 | - if ( $status !== 'draft' ) |
|
888 | - $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
893 | + if ( $status !== 'draft' ) { |
|
894 | + $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
895 | + } |
|
889 | 896 | |
890 | 897 | //category filter |
891 | 898 | $filters[] = $this->category_dropdown(); |
@@ -1064,7 +1071,7 @@ discard block |
||
1064 | 1071 | |
1065 | 1072 | if($count){ |
1066 | 1073 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
1067 | - }else{ |
|
1074 | + } else{ |
|
1068 | 1075 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
1069 | 1076 | } |
1070 | 1077 | |
@@ -1087,11 +1094,13 @@ discard block |
||
1087 | 1094 | //cycle thru the boxes |
1088 | 1095 | while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
1089 | 1096 | if ( $trash ) { |
1090 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1091 | - $success = 0; |
|
1097 | + if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1098 | + $success = 0; |
|
1099 | + } |
|
1092 | 1100 | } else { |
1093 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1094 | - $success = 0; |
|
1101 | + if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1102 | + $success = 0; |
|
1103 | + } |
|
1095 | 1104 | } |
1096 | 1105 | } |
1097 | 1106 | } else { |
@@ -1099,11 +1108,13 @@ discard block |
||
1099 | 1108 | $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
1100 | 1109 | |
1101 | 1110 | if ( $trash ) { |
1102 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1103 | - $success = 0; |
|
1111 | + if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1112 | + $success = 0; |
|
1113 | + } |
|
1104 | 1114 | } else { |
1105 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1106 | - $success = 0; |
|
1115 | + if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1116 | + $success = 0; |
|
1117 | + } |
|
1107 | 1118 | } |
1108 | 1119 | } |
1109 | 1120 | |
@@ -1151,8 +1162,9 @@ discard block |
||
1151 | 1162 | ); |
1152 | 1163 | |
1153 | 1164 | //failsafe. If the default ticket count === 1 then we need to redirect to event overview. |
1154 | - if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) |
|
1155 | - $query_args = array(); |
|
1165 | + if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) { |
|
1166 | + $query_args = array(); |
|
1167 | + } |
|
1156 | 1168 | $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
1157 | 1169 | } |
1158 | 1170 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -30,25 +30,25 @@ discard block |
||
30 | 30 | class Extend_Events_Admin_Page extends Events_Admin_Page { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $routing = TRUE ) { |
|
34 | - parent::__construct( $routing ); |
|
35 | - define( 'EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
36 | - define( 'EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
37 | - define( 'EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
33 | + public function __construct($routing = TRUE) { |
|
34 | + parent::__construct($routing); |
|
35 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
36 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
37 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | protected function _extend_page_config() { |
42 | 42 | |
43 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
43 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
44 | 44 | $default_espresso_boxes = $this->_default_espresso_metaboxes; |
45 | 45 | |
46 | 46 | //is there a evt_id in the request? |
47 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
48 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
47 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
48 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
49 | 49 | |
50 | 50 | //tkt_id? |
51 | - $tkt_id = !empty( $this->_req_data['TKT_ID'] ) && ! is_array( $this->_req_data['TKT_ID'] ) ? $this->_req_data['TKT_ID'] : 0; |
|
51 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) ? $this->_req_data['TKT_ID'] : 0; |
|
52 | 52 | |
53 | 53 | $new_page_routes = array( |
54 | 54 | 'duplicate_event' => array( |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | 'capability' => 'ee_delete_default_ticket', |
67 | 67 | 'obj_id' => $tkt_id, |
68 | 68 | 'noheader' => TRUE, |
69 | - 'args' => array( 'trash' => TRUE ) |
|
69 | + 'args' => array('trash' => TRUE) |
|
70 | 70 | ), |
71 | 71 | 'trash_tickets' => array( |
72 | 72 | 'func' => '_trash_or_restore_ticket', |
73 | 73 | 'capability' => 'ee_delete_default_tickets', |
74 | 74 | 'noheader' => TRUE, |
75 | - 'args' => array( 'trash' => TRUE ) |
|
75 | + 'args' => array('trash' => TRUE) |
|
76 | 76 | ), |
77 | 77 | 'restore_ticket' => array( |
78 | 78 | 'func' => '_trash_or_restore_ticket', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ) |
133 | 133 | ); |
134 | 134 | |
135 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
135 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
136 | 136 | |
137 | 137 | |
138 | 138 | //partial route/config override |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
145 | 145 | |
146 | 146 | //add tickets tab but only if there are more than one default ticket! |
147 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array( array('TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ); |
|
148 | - if ( $tkt_count > 1 ) { |
|
147 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE); |
|
148 | + if ($tkt_count > 1) { |
|
149 | 149 | $new_page_config = array( |
150 | 150 | 'ticket_list_table' => array( |
151 | 151 | 'nav' => array( |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | 'label' => __('Templates'), |
165 | 165 | 'order' => 30 |
166 | 166 | ), |
167 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
167 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
168 | 168 | 'help_tabs' => array( |
169 | 169 | 'general_settings_templates_help_tab' => array( |
170 | 170 | 'title' => __('Templates', 'event_espresso'), |
171 | 171 | 'filename' => 'general_settings_templates' |
172 | 172 | ) |
173 | 173 | ), |
174 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
174 | + 'help_tour' => array('Templates_Help_Tour'), |
|
175 | 175 | 'require_nonce' => FALSE |
176 | 176 | ); |
177 | 177 | |
@@ -190,26 +190,26 @@ discard block |
||
190 | 190 | // 'metaboxes' => $default_espresso_boxes, |
191 | 191 | // 'require_nonce' => FALSE |
192 | 192 | // ); |
193 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
193 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
194 | 194 | |
195 | 195 | //add filters and actions |
196 | 196 | //modifying _views |
197 | - add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array( $this, 'add_additional_datetime_button' ), 10, 2 ); |
|
198 | - add_filter('FHEE_event_datetime_metabox_clone_button_template', array( $this, 'add_datetime_clone_button' ), 10, 2 ); |
|
199 | - add_filter('FHEE_event_datetime_metabox_timezones_template', array( $this, 'datetime_timezones_template'), 10, 2 ); |
|
197 | + add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array($this, 'add_additional_datetime_button'), 10, 2); |
|
198 | + add_filter('FHEE_event_datetime_metabox_clone_button_template', array($this, 'add_datetime_clone_button'), 10, 2); |
|
199 | + add_filter('FHEE_event_datetime_metabox_timezones_template', array($this, 'datetime_timezones_template'), 10, 2); |
|
200 | 200 | |
201 | 201 | |
202 | 202 | //filters for event list table |
203 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array( $this, 'list_table_filters'), 10, 2); |
|
204 | - add_filter('FHEE__Events_Admin_List_Table__column_actions__action_links', array( $this, 'extra_list_table_actions'), 10, 2 ); |
|
203 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
204 | + add_filter('FHEE__Events_Admin_List_Table__column_actions__action_links', array($this, 'extra_list_table_actions'), 10, 2); |
|
205 | 205 | |
206 | 206 | //legend item |
207 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array( $this, 'additional_legend_items') ); |
|
207 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
208 | 208 | |
209 | - add_action('admin_init', array( $this, 'admin_init') ); |
|
209 | + add_action('admin_init', array($this, 'admin_init')); |
|
210 | 210 | |
211 | 211 | //heartbeat stuff |
212 | - add_filter( 'heartbeat_received', array( $this, 'heartbeat_response' ), 10, 2 ); |
|
212 | + add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | EE_Registry::$i18n_js_strings = array_merge( |
223 | 223 | EE_Registry::$i18n_js_strings, |
224 | 224 | array( |
225 | - 'image_confirm' => __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ), |
|
226 | - 'event_starts_on' => __( 'Event Starts on', 'event_espresso' ), |
|
227 | - 'event_ends_on' => __( 'Event Ends on', 'event_espresso' ), |
|
228 | - 'event_datetime_actions' => __( 'Actions', 'event_espresso' ), |
|
229 | - 'event_clone_dt_msg' => __( 'Clone this Event Date and Time', 'event_espresso' ), |
|
230 | - 'remove_event_dt_msg' => __( 'Remove this Event Time', 'event_espresso' ) |
|
225 | + 'image_confirm' => __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'), |
|
226 | + 'event_starts_on' => __('Event Starts on', 'event_espresso'), |
|
227 | + 'event_ends_on' => __('Event Ends on', 'event_espresso'), |
|
228 | + 'event_datetime_actions' => __('Actions', 'event_espresso'), |
|
229 | + 'event_clone_dt_msg' => __('Clone this Event Date and Time', 'event_espresso'), |
|
230 | + 'remove_event_dt_msg' => __('Remove this Event Time', 'event_espresso') |
|
231 | 231 | ) |
232 | 232 | ); |
233 | 233 | } |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return array possibly appended response. |
244 | 244 | */ |
245 | - public function heartbeat_response( $response, $data ) { |
|
245 | + public function heartbeat_response($response, $data) { |
|
246 | 246 | /** |
247 | 247 | * check whether count of tickets is approaching the potential |
248 | 248 | * limits for the server. |
249 | 249 | */ |
250 | - if ( ! empty( $data['input_count'] ) ) { |
|
250 | + if ( ! empty($data['input_count'])) { |
|
251 | 251 | $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check($data['input_count']); |
252 | 252 | } |
253 | 253 | |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | |
263 | 263 | |
264 | 264 | |
265 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
266 | - $return = parent::extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ); |
|
265 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
266 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
267 | 267 | //make sure this is only when editing |
268 | - if ( !empty( $id ) ) { |
|
269 | - $href = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url ); |
|
268 | + if ( ! empty($id)) { |
|
269 | + $href = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url); |
|
270 | 270 | $title = esc_attr__('Duplicate Event', 'event_espresso'); |
271 | - $return .= '<a href="' . $href . '" title="' . $title . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' . $title . '</button>'; |
|
271 | + $return .= '<a href="'.$href.'" title="'.$title.'" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">'.$title.'</button>'; |
|
272 | 272 | } |
273 | 273 | return $return; |
274 | 274 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | 'label' => __('Trash', 'event_espresso'), |
292 | 292 | 'count' => 0, |
293 | 293 | 'bulk_action' => array( |
294 | - 'restore_tickets' => __('Restore from Trash' , 'event_espresso'), |
|
294 | + 'restore_tickets' => __('Restore from Trash', 'event_espresso'), |
|
295 | 295 | 'delete_tickets' => __('Delete Permanently', 'event_espresso') |
296 | 296 | ) |
297 | 297 | ) |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | |
303 | 303 | public function load_scripts_styles_edit() { |
304 | - wp_register_script( 'ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', array( 'ee_admin_js', 'heartbeat' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
304 | + wp_register_script('ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', array('ee_admin_js', 'heartbeat'), EVENT_ESPRESSO_VERSION, TRUE); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * load accounting js. |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | - public function add_additional_datetime_button( $template, $template_args ) { |
|
324 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', $template_args, TRUE); |
|
323 | + public function add_additional_datetime_button($template, $template_args) { |
|
324 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', $template_args, TRUE); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
328 | 328 | |
329 | - public function add_datetime_clone_button( $template, $template_args ) { |
|
330 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', $template_args, TRUE ); |
|
329 | + public function add_datetime_clone_button($template, $template_args) { |
|
330 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', $template_args, TRUE); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
334 | 334 | |
335 | - public function datetime_timezones_template( $template, $template_args ) { |
|
336 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', $template_args, TRUE ); |
|
335 | + public function datetime_timezones_template($template, $template_args) { |
|
336 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', $template_args, TRUE); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | protected function _set_list_table_views_default() { |
343 | 343 | parent::_set_list_table_views_default(); |
344 | 344 | $export_label = __('Export Events', 'event_espresso'); |
345 | - if ( EE_Registry::instance()->CAP->current_user_can( 'export', 'espresso_events_export' ) ) { |
|
345 | + if (EE_Registry::instance()->CAP->current_user_can('export', 'espresso_events_export')) { |
|
346 | 346 | // $this->_views['all']['bulk_action']['export_events'] = $export_label; |
347 | 347 | // $this->_views['draft']['bulk_action']['export_events'] = $export_label; |
348 | 348 | |
349 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
349 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
350 | 350 | // $this->_views['trash']['bulk_action']['export_events'] = $export_label; |
351 | 351 | } |
352 | 352 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | ) |
373 | 373 | ); |
374 | 374 | |
375 | - $this->_views = array_merge( $this->_views, $new_views); |
|
375 | + $this->_views = array_merge($this->_views, $new_views); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -386,17 +386,17 @@ discard block |
||
386 | 386 | |
387 | 387 | |
388 | 388 | |
389 | - public function extra_list_table_actions( $actionlinks, $event ) { |
|
390 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports', $event->ID() ) ) { |
|
389 | + public function extra_list_table_actions($actionlinks, $event) { |
|
390 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports', $event->ID())) { |
|
391 | 391 | $reports_query_args = array( |
392 | 392 | 'action' => 'reports', |
393 | 393 | 'EVT_ID' => $event->ID() |
394 | 394 | ); |
395 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce( $reports_query_args, REG_ADMIN_URL ); |
|
396 | - $actionlinks[] = '<a href="' . $reports_link . '" title="' . esc_attr__('View Report', 'event_espresso') . '"><div class="dashicons dashicons-chart-bar"></div></a>' . "\n\t"; |
|
395 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
396 | + $actionlinks[] = '<a href="'.$reports_link.'" title="'.esc_attr__('View Report', 'event_espresso').'"><div class="dashicons dashicons-chart-bar"></div></a>'."\n\t"; |
|
397 | 397 | } |
398 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
399 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
398 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
399 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
400 | 400 | $actionlinks[] = EEH_MSG_Template::get_message_action_link( |
401 | 401 | 'see_notifications_for', |
402 | 402 | null, |
@@ -411,15 +411,15 @@ discard block |
||
411 | 411 | |
412 | 412 | |
413 | 413 | public function additional_legend_items($items) { |
414 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports' ) ) { |
|
414 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports')) { |
|
415 | 415 | $items['reports'] = array( |
416 | 416 | 'class' => 'dashicons dashicons-chart-bar', |
417 | 417 | 'desc' => __('Event Reports', 'event_espresso') |
418 | 418 | ); |
419 | 419 | } |
420 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
421 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
422 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
420 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
421 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
422 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
423 | 423 | $items['view_related_messages'] = array( |
424 | 424 | 'class' => $related_for_icon['css_class'], |
425 | 425 | 'desc' => $related_for_icon['label'], |
@@ -444,17 +444,17 @@ discard block |
||
444 | 444 | */ |
445 | 445 | protected function _duplicate_event() { |
446 | 446 | //first make sure the ID for the event is in the request. If it isnt' then we need to bail and redirect back to overview list table (cause how did we get here?) |
447 | - if ( !isset( $this->_req_data['EVT_ID'] ) ) { |
|
448 | - EE_Error::add_error( __('In order to duplicate an event an Event ID is required. None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
449 | - $this->_redirect_after_action( FALSE, '', '', array(), TRUE ); |
|
447 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
448 | + EE_Error::add_error(__('In order to duplicate an event an Event ID is required. None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
449 | + $this->_redirect_after_action(FALSE, '', '', array(), TRUE); |
|
450 | 450 | return; |
451 | 451 | } |
452 | 452 | |
453 | 453 | //k we've got EVT_ID so let's use that to get the event we'll duplicate |
454 | - $orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] ); |
|
454 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
455 | 455 | |
456 | - if ( ! $orig_event instanceof EE_Event ) |
|
457 | - throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'] ) ); |
|
456 | + if ( ! $orig_event instanceof EE_Event) |
|
457 | + throw new EE_Error(sprintf(__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'])); |
|
458 | 458 | |
459 | 459 | //k now let's clone the $orig_event before getting relations |
460 | 460 | $new_event = clone $orig_event; |
@@ -467,43 +467,43 @@ discard block |
||
467 | 467 | |
468 | 468 | |
469 | 469 | //reset the ID and modify other details to make it clear this is a dupe |
470 | - $new_event->set( 'EVT_ID', 0 ); |
|
471 | - $new_name = $new_event->name() . ' ' . __('**DUPLICATE**', 'event_espresso'); |
|
472 | - $new_event->set( 'EVT_name', $new_name ); |
|
473 | - $new_event->set( 'EVT_slug', wp_unique_post_slug( sanitize_title( $orig_event->name() ), 0, 'publish', 'espresso_events', 0 ) ); |
|
474 | - $new_event->set( 'status', 'draft' ); |
|
470 | + $new_event->set('EVT_ID', 0); |
|
471 | + $new_name = $new_event->name().' '.__('**DUPLICATE**', 'event_espresso'); |
|
472 | + $new_event->set('EVT_name', $new_name); |
|
473 | + $new_event->set('EVT_slug', wp_unique_post_slug(sanitize_title($orig_event->name()), 0, 'publish', 'espresso_events', 0)); |
|
474 | + $new_event->set('status', 'draft'); |
|
475 | 475 | |
476 | 476 | //duplicate discussion settings |
477 | - $new_event->set( 'comment_status', $orig_event->get('comment_status') ); |
|
478 | - $new_event->set( 'ping_status', $orig_event->get( 'ping_status' ) ); |
|
477 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
478 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
479 | 479 | |
480 | 480 | //save the new event |
481 | 481 | $new_event->save(); |
482 | 482 | |
483 | 483 | //venues |
484 | - foreach( $orig_ven as $ven ) { |
|
485 | - $new_event->_add_relation_to( $ven, 'Venue' ); |
|
484 | + foreach ($orig_ven as $ven) { |
|
485 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
486 | 486 | } |
487 | 487 | $new_event->save(); |
488 | 488 | |
489 | 489 | |
490 | 490 | //now we need to get the question group relations and handle that |
491 | 491 | //first primary question groups |
492 | - $orig_primary_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 1 ) ) ); |
|
493 | - if ( !empty( $orig_primary_qgs ) ) { |
|
494 | - foreach ( $orig_primary_qgs as $id => $obj ) { |
|
495 | - if ( $obj instanceof EE_Question_Group ) { |
|
496 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 1 ) ); |
|
492 | + $orig_primary_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 1))); |
|
493 | + if ( ! empty($orig_primary_qgs)) { |
|
494 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
495 | + if ($obj instanceof EE_Question_Group) { |
|
496 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | |
501 | 501 | //next additional attendee question groups |
502 | - $orig_additional_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 0 ) ) ); |
|
503 | - if ( !empty( $orig_additional_qgs ) ) { |
|
504 | - foreach ( $orig_additional_qgs as $id => $obj ) { |
|
505 | - if ( $obj instanceof EE_Question_Group ) { |
|
506 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 0 ) ); |
|
502 | + $orig_additional_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0))); |
|
503 | + if ( ! empty($orig_additional_qgs)) { |
|
504 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
505 | + if ($obj instanceof EE_Question_Group) { |
|
506 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
516 | 516 | $cloned_tickets = array(); |
517 | - foreach ( $orig_datetimes as $orig_dtt ) { |
|
517 | + foreach ($orig_datetimes as $orig_dtt) { |
|
518 | 518 | $new_dtt = clone $orig_dtt; |
519 | 519 | $orig_tkts = $orig_dtt->tickets(); |
520 | 520 | |
@@ -522,22 +522,22 @@ discard block |
||
522 | 522 | $new_dtt->set('DTT_ID', 0); |
523 | 523 | $new_dtt->set('DTT_sold', 0); |
524 | 524 | $new_dtt->save(); |
525 | - $new_event->_add_relation_to( $new_dtt, 'Datetime'); |
|
525 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
526 | 526 | $new_event->save(); |
527 | 527 | |
528 | 528 | //now let's get the ticket relations setup. |
529 | - foreach ( (array) $orig_tkts as $orig_tkt ) { |
|
529 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
530 | 530 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
531 | - if ( ! $orig_tkt instanceof EE_Ticket ) |
|
531 | + if ( ! $orig_tkt instanceof EE_Ticket) |
|
532 | 532 | continue; |
533 | 533 | |
534 | 534 | //is this ticket archived? If it is then let's skip |
535 | - if ( $orig_tkt->get( 'TKT_deleted' ) ) { |
|
535 | + if ($orig_tkt->get('TKT_deleted')) { |
|
536 | 536 | continue; |
537 | 537 | } |
538 | 538 | |
539 | 539 | //does this original ticket already exist in the clone_tickets cache? If so we'll just use the new ticket from it. |
540 | - if ( isset( $cloned_tickets[$orig_tkt->ID()] ) ) { |
|
540 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
541 | 541 | $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
542 | 542 | } else { |
543 | 543 | $new_tkt = clone $orig_tkt; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $new_tkt->save(); //make sure new ticket has ID. |
550 | 550 | |
551 | 551 | //price relations on new ticket need to be setup. |
552 | - foreach ( $orig_prices as $orig_price ) { |
|
552 | + foreach ($orig_prices as $orig_price) { |
|
553 | 553 | $new_price = clone $orig_price; |
554 | 554 | $new_price->set('PRC_ID', 0); |
555 | 555 | $new_price->save(); |
@@ -566,39 +566,39 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | //clone taxonomy information |
569 | - $taxonomies_to_clone_with = apply_filters( 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array( 'espresso_event_categories', 'espresso_event_type', 'post_tag' ) ); |
|
569 | + $taxonomies_to_clone_with = apply_filters('FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array('espresso_event_categories', 'espresso_event_type', 'post_tag')); |
|
570 | 570 | |
571 | 571 | //get terms for original event (notice) |
572 | - $orig_terms = wp_get_object_terms( $orig_event->ID(), $taxonomies_to_clone_with ); |
|
572 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
573 | 573 | |
574 | 574 | //loop through terms and add them to new event. |
575 | - foreach ( $orig_terms as $term ) { |
|
576 | - wp_set_object_terms( $new_event->ID(), $term->term_id, $term->taxonomy, true ); |
|
575 | + foreach ($orig_terms as $term) { |
|
576 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
580 | - do_action( 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event ); |
|
580 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
581 | 581 | |
582 | 582 | //now let's redirect to the edit page for this duplicated event if we have a new event id. |
583 | - if ( $new_event->ID() ) { |
|
583 | + if ($new_event->ID()) { |
|
584 | 584 | $redirect_args = array( |
585 | 585 | 'post' => $new_event->ID(), |
586 | 586 | 'action' => 'edit' |
587 | 587 | ); |
588 | - EE_Error::add_success( __('Event successfully duplicated. Please review the details below and make any necessary edits', 'event_espresso') ); |
|
588 | + EE_Error::add_success(__('Event successfully duplicated. Please review the details below and make any necessary edits', 'event_espresso')); |
|
589 | 589 | } else { |
590 | 590 | $redirect_args = array( |
591 | 591 | 'action' => 'default' |
592 | 592 | ); |
593 | - EE_Error::add_error( __('Not able to duplicate event. Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
593 | + EE_Error::add_error(__('Not able to duplicate event. Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
594 | 594 | } |
595 | 595 | |
596 | - $this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE ); |
|
596 | + $this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | |
600 | 600 | |
601 | - protected function _import_page(){ |
|
601 | + protected function _import_page() { |
|
602 | 602 | |
603 | 603 | $title = __('Import', 'event_espresso'); |
604 | 604 | $intro = __('If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', 'event_espresso'); |
@@ -606,8 +606,8 @@ discard block |
||
606 | 606 | $action = 'import_events'; |
607 | 607 | $type = 'csv'; |
608 | 608 | $this->_template_args['form'] = EE_Import::instance()->upload_form($title, $intro, $form_url, $action, $type); |
609 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'),$this->_admin_base_url); |
|
610 | - $content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',$this->_template_args,true); |
|
609 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'), $this->_admin_base_url); |
|
610 | + $content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', $this->_template_args, true); |
|
611 | 611 | |
612 | 612 | |
613 | 613 | $this->_template_args['admin_page_content'] = $content; |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | * @return string html |
621 | 621 | */ |
622 | 622 | protected function _import_events() { |
623 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
623 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
624 | 624 | $success = EE_Import::instance()->import(); |
625 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'),true); |
|
625 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
@@ -636,23 +636,23 @@ discard block |
||
636 | 636 | * @return file |
637 | 637 | */ |
638 | 638 | protected function _events_export() { |
639 | - if(isset($this->_req_data['EVT_ID'])){ |
|
639 | + if (isset($this->_req_data['EVT_ID'])) { |
|
640 | 640 | $event_ids = $this->_req_data['EVT_ID']; |
641 | - }elseif(isset($this->_req_data['EVT_IDs'])){ |
|
641 | + }elseif (isset($this->_req_data['EVT_IDs'])) { |
|
642 | 642 | $event_ids = $this->_req_data['EVT_IDs']; |
643 | - }else{ |
|
643 | + } else { |
|
644 | 644 | $event_ids = NULL; |
645 | 645 | } |
646 | 646 | //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
647 | 647 | $new_request_args = array( |
648 | 648 | 'export' => 'report', |
649 | 649 | 'action' => 'all_event_data', |
650 | - 'EVT_ID' => $event_ids , |
|
650 | + 'EVT_ID' => $event_ids, |
|
651 | 651 | ); |
652 | 652 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
653 | 653 | |
654 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
655 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
654 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
655 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
656 | 656 | $EE_Export = EE_Export::instance($this->_req_data); |
657 | 657 | $EE_Export->export(); |
658 | 658 | } |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | 'category_ids' => $this->_req_data['EVT_CAT_ID'] |
675 | 675 | ); |
676 | 676 | |
677 | - $this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
677 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
678 | 678 | |
679 | - if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) { |
|
680 | - require_once( EE_CLASSES . 'EE_Export.class.php'); |
|
681 | - $EE_Export = EE_Export::instance( $this->_req_data ); |
|
679 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
680 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
681 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
682 | 682 | $EE_Export->export(); |
683 | 683 | } |
684 | 684 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | /** |
690 | 690 | * Creates a sample CSV file for importing |
691 | 691 | */ |
692 | - protected function _sample_export_file(){ |
|
692 | + protected function _sample_export_file() { |
|
693 | 693 | // require_once(EE_CLASSES . 'EE_Export.class.php'); |
694 | 694 | EE_Export::instance()->export_sample(); |
695 | 695 | } |
@@ -706,10 +706,10 @@ discard block |
||
706 | 706 | * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
707 | 707 | * from General_Settings_Admin_Page to here. |
708 | 708 | */ |
709 | - $this->_template_args = apply_filters( 'FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args ); |
|
710 | - $this->_set_add_edit_form_tags( 'update_template_settings' ); |
|
711 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
712 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', $this->_template_args, TRUE ); |
|
709 | + $this->_template_args = apply_filters('FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args); |
|
710 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
711 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
712 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', $this->_template_args, TRUE); |
|
713 | 713 | $this->display_admin_page_with_sidebar(); |
714 | 714 | } |
715 | 715 | |
@@ -721,24 +721,24 @@ discard block |
||
721 | 721 | * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
722 | 722 | * from General_Settings_Admin_Page to here. |
723 | 723 | */ |
724 | - EE_Registry::instance()->CFG->template_settings = apply_filters( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data ); |
|
724 | + EE_Registry::instance()->CFG->template_settings = apply_filters('FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data); |
|
725 | 725 | |
726 | 726 | |
727 | 727 | //update custom post type slugs and detect if we need to flush rewrite rules |
728 | 728 | $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
729 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty( $this->_req_data['event_cpt_slug'] ) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes( $this->_req_data['event_cpt_slug'] ); |
|
729 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
730 | 730 | |
731 | 731 | |
732 | 732 | $what = 'Template Settings'; |
733 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__ ); |
|
733 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__); |
|
734 | 734 | |
735 | 735 | |
736 | - if ( EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug ) { |
|
737 | - update_option( 'ee_flush_rewrite_rules', true ); |
|
736 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
737 | + update_option('ee_flush_rewrite_rules', true); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
741 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'template_settings' ) ); |
|
741 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
742 | 742 | |
743 | 743 | } |
744 | 744 | |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | |
757 | 757 | $this->verify_cpt_object(); |
758 | 758 | |
759 | - add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array( $this, 'registration_options_meta_box' ), $this->page_slug, 'side', 'core'); |
|
759 | + add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array($this, 'registration_options_meta_box'), $this->page_slug, 'side', 'core'); |
|
760 | 760 | //add_meta_box('espresso_event_types', __('Event Type', 'event_espresso'), array( $this, 'event_type_meta_box' ), $this->page_slug, 'side', 'default' ); //add this back in when the feature is ready. |
761 | 761 | |
762 | 762 | //todo feature in progress |
@@ -780,16 +780,16 @@ discard block |
||
780 | 780 | array('id' => true, 'text' => __('Yes', 'event_espresso')), |
781 | 781 | array('id' => false, 'text' => __('No', 'event_espresso')) |
782 | 782 | ); |
783 | - $default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete ), TRUE); |
|
783 | + $default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete), TRUE); |
|
784 | 784 | $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(FALSE); |
785 | 785 | $template_args['_event'] = $this->_cpt_model_obj; |
786 | 786 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
787 | 787 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
788 | 788 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
789 | 789 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
790 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status() ); |
|
791 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
792 | - $templatepath = EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
790 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
|
791 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
792 | + $templatepath = EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
793 | 793 | EEH_Template::display_template($templatepath, $template_args); |
794 | 794 | } |
795 | 795 | |
@@ -802,9 +802,9 @@ discard block |
||
802 | 802 | * @param array $box metabox args |
803 | 803 | * @return string metabox contents |
804 | 804 | */ |
805 | - public function event_type_meta_box( $post, $box ) { |
|
806 | - $template_args['radio_list'] = $this->wp_terms_radio($post->ID, array( 'taxonomy' => 'espresso_event_type' ) ); |
|
807 | - $template = EVENTS_CAF_TEMPLATE_PATH . 'event_type_metabox_contents.template.php'; |
|
805 | + public function event_type_meta_box($post, $box) { |
|
806 | + $template_args['radio_list'] = $this->wp_terms_radio($post->ID, array('taxonomy' => 'espresso_event_type')); |
|
807 | + $template = EVENTS_CAF_TEMPLATE_PATH.'event_type_metabox_contents.template.php'; |
|
808 | 808 | EEH_Template::display_template($template, $template_args); |
809 | 809 | } |
810 | 810 | |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | |
816 | 816 | |
817 | - public function wp_terms_radio( $post_id = 0, $args = array() ) { |
|
817 | + public function wp_terms_radio($post_id = 0, $args = array()) { |
|
818 | 818 | $defaults = array( |
819 | 819 | 'descendants_and_self' => 0, |
820 | 820 | 'selected_cats' => false, |
@@ -823,11 +823,11 @@ discard block |
||
823 | 823 | 'taxonomy' => 'category', |
824 | 824 | 'checked_ontop' => true |
825 | 825 | ); |
826 | - $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); |
|
826 | + $args = apply_filters('wp_terms_checklist_args', $args, $post_id); |
|
827 | 827 | |
828 | - extract( wp_parse_args($args, $defaults), EXTR_SKIP ); |
|
828 | + extract(wp_parse_args($args, $defaults), EXTR_SKIP); |
|
829 | 829 | |
830 | - if ( empty($walker) || !is_a($walker, 'Walker') ) |
|
830 | + if (empty($walker) || ! is_a($walker, 'Walker')) |
|
831 | 831 | $walker = new Walker_Radio_Checklist; |
832 | 832 | |
833 | 833 | $descendants_and_self = (int) $descendants_and_self; |
@@ -835,37 +835,37 @@ discard block |
||
835 | 835 | $args = array('taxonomy' => $taxonomy); |
836 | 836 | |
837 | 837 | $tax = get_taxonomy($taxonomy); |
838 | - $args['disabled'] = !current_user_can($tax->cap->assign_terms); |
|
838 | + $args['disabled'] = ! current_user_can($tax->cap->assign_terms); |
|
839 | 839 | |
840 | - if ( is_array( $selected_cats ) ) |
|
840 | + if (is_array($selected_cats)) |
|
841 | 841 | $args['selected_cats'] = $selected_cats; |
842 | - elseif ( $post_id ) |
|
842 | + elseif ($post_id) |
|
843 | 843 | $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
844 | 844 | else |
845 | 845 | $args['selected_cats'] = array(); |
846 | 846 | |
847 | - if ( is_array( $popular_cats ) ) |
|
847 | + if (is_array($popular_cats)) |
|
848 | 848 | $args['popular_cats'] = $popular_cats; |
849 | 849 | else |
850 | - $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
850 | + $args['popular_cats'] = get_terms($taxonomy, array('fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false)); |
|
851 | 851 | |
852 | - if ( $descendants_and_self ) { |
|
853 | - $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); |
|
854 | - $self = get_term( $descendants_and_self, $taxonomy ); |
|
855 | - array_unshift( $categories, $self ); |
|
852 | + if ($descendants_and_self) { |
|
853 | + $categories = (array) get_terms($taxonomy, array('child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0)); |
|
854 | + $self = get_term($descendants_and_self, $taxonomy); |
|
855 | + array_unshift($categories, $self); |
|
856 | 856 | } else { |
857 | 857 | $categories = (array) get_terms($taxonomy, array('get' => 'all')); |
858 | 858 | } |
859 | 859 | |
860 | - if ( $checked_ontop ) { |
|
860 | + if ($checked_ontop) { |
|
861 | 861 | // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) |
862 | 862 | $checked_categories = array(); |
863 | - $keys = array_keys( $categories ); |
|
863 | + $keys = array_keys($categories); |
|
864 | 864 | |
865 | - foreach( $keys as $k ) { |
|
866 | - if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { |
|
865 | + foreach ($keys as $k) { |
|
866 | + if (in_array($categories[$k]->term_id, $args['selected_cats'])) { |
|
867 | 867 | $checked_categories[] = $categories[$k]; |
868 | - unset( $categories[$k] ); |
|
868 | + unset($categories[$k]); |
|
869 | 869 | } |
870 | 870 | } |
871 | 871 | |
@@ -890,18 +890,18 @@ discard block |
||
890 | 890 | * @param array $list_table_obj the list table object |
891 | 891 | * @return array new filters |
892 | 892 | */ |
893 | - public function list_table_filters( $oldfilters, $list_table_obj ) { |
|
893 | + public function list_table_filters($oldfilters, $list_table_obj) { |
|
894 | 894 | $filters = array(); |
895 | 895 | |
896 | 896 | //first month/year filters |
897 | 897 | $filters[] = $this->espresso_event_months_dropdown(); |
898 | 898 | |
899 | 899 | |
900 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
900 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
901 | 901 | |
902 | 902 | //active status dropdown |
903 | - if ( $status !== 'draft' ) |
|
904 | - $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
903 | + if ($status !== 'draft') |
|
904 | + $filter[] = $this->active_status_dropdown(isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''); |
|
905 | 905 | |
906 | 906 | //category filter |
907 | 907 | $filters[] = $this->category_dropdown(); |
@@ -923,17 +923,17 @@ discard block |
||
923 | 923 | */ |
924 | 924 | public function espresso_event_months_dropdown() { |
925 | 925 | //what we need to do is get all PRIMARY datetimes for all events to filter on. Note we need to include any other filters that are set! |
926 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
926 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
927 | 927 | |
928 | 928 | //categories? |
929 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
929 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
930 | 930 | |
931 | 931 | //active status? |
932 | - $active_status = isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : NULL; |
|
932 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : NULL; |
|
933 | 933 | |
934 | 934 | $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
935 | 935 | |
936 | - return EEH_Form_Fields::generate_event_months_dropdown( $cur_date, $status, $category, $active_status ); |
|
936 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | |
@@ -944,12 +944,12 @@ discard block |
||
944 | 944 | * @param string $current_value whatever the ucrrent active status is |
945 | 945 | * @return string html dropdown. |
946 | 946 | */ |
947 | - public function active_status_dropdown( $current_value = '' ) { |
|
947 | + public function active_status_dropdown($current_value = '') { |
|
948 | 948 | $select_name = 'active_status'; |
949 | - $values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso') ); |
|
949 | + $values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso')); |
|
950 | 950 | $id = 'id="espresso-active-status-dropdown-filter"'; |
951 | 951 | $class = 'wide'; |
952 | - echo EEH_Form_Fields::select_input( $select_name, $values, $current_value, $id, $class ); |
|
952 | + echo EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | |
@@ -961,9 +961,9 @@ discard block |
||
961 | 961 | * @return string html |
962 | 962 | */ |
963 | 963 | public function category_dropdown() { |
964 | - $cur_cat = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1; |
|
964 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
965 | 965 | |
966 | - return EEH_Form_Fields::generate_event_category_dropdown( $cur_cat ); |
|
966 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | * @return int |
976 | 976 | */ |
977 | 977 | public function total_events_today() { |
978 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 00:00:00', 'Y-m-d H:i:s', 'UTC' ); |
|
979 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' ); |
|
978 | + $start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 00:00:00', 'Y-m-d H:i:s', 'UTC'); |
|
979 | + $end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 23:59:59', 'Y-m-d H:i:s', 'UTC'); |
|
980 | 980 | |
981 | 981 | $where = array( |
982 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) ) |
|
982 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)) |
|
983 | 983 | ); |
984 | 984 | |
985 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
985 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
986 | 986 | return $count; |
987 | 987 | } |
988 | 988 | |
@@ -997,14 +997,14 @@ discard block |
||
997 | 997 | $this_year_r = date('Y'); |
998 | 998 | $this_month_r = date('m'); |
999 | 999 | $days_this_month = date('t'); |
1000 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-01 00:00:00', 'Y-m-d H:i:s', 'UTC' ); |
|
1001 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' ); |
|
1000 | + $start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-01 00:00:00', 'Y-m-d H:i:s', 'UTC'); |
|
1001 | + $end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', 'Y-m-d H:i:s', 'UTC'); |
|
1002 | 1002 | |
1003 | 1003 | $where = array( |
1004 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) ) |
|
1004 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)) |
|
1005 | 1005 | ); |
1006 | 1006 | |
1007 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1007 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1008 | 1008 | return $count; |
1009 | 1009 | } |
1010 | 1010 | |
@@ -1021,53 +1021,53 @@ discard block |
||
1021 | 1021 | |
1022 | 1022 | |
1023 | 1023 | |
1024 | - public function get_default_tickets( $per_page = 10, $count = FALSE, $trashed = FALSE ) { |
|
1024 | + public function get_default_tickets($per_page = 10, $count = FALSE, $trashed = FALSE) { |
|
1025 | 1025 | |
1026 | - $orderby= empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1027 | - $order = empty( $this->_req_data['order'] ) ? 'ASC' : $this->_req_data['order']; |
|
1026 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1027 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1028 | 1028 | |
1029 | - switch ( $orderby ) { |
|
1029 | + switch ($orderby) { |
|
1030 | 1030 | case 'TKT_name' : |
1031 | - $orderby = array( 'TKT_name' => $order ); |
|
1031 | + $orderby = array('TKT_name' => $order); |
|
1032 | 1032 | break; |
1033 | 1033 | |
1034 | 1034 | case 'TKT_price' : |
1035 | - $orderby = array( 'TKT_price' => $order ); |
|
1035 | + $orderby = array('TKT_price' => $order); |
|
1036 | 1036 | break; |
1037 | 1037 | |
1038 | 1038 | case 'TKT_uses' : |
1039 | - $orderby = array( 'TKT_uses' => $order ); |
|
1039 | + $orderby = array('TKT_uses' => $order); |
|
1040 | 1040 | break; |
1041 | 1041 | |
1042 | 1042 | case 'TKT_min' : |
1043 | - $orderby = array( 'TKT_min' => $order ); |
|
1043 | + $orderby = array('TKT_min' => $order); |
|
1044 | 1044 | break; |
1045 | 1045 | |
1046 | 1046 | case 'TKT_max' : |
1047 | - $orderby = array( 'TKT_max' => $order ); |
|
1047 | + $orderby = array('TKT_max' => $order); |
|
1048 | 1048 | break; |
1049 | 1049 | |
1050 | 1050 | case 'TKT_qty' : |
1051 | - $orderby = array( 'TKT_qty' => $order ); |
|
1051 | + $orderby = array('TKT_qty' => $order); |
|
1052 | 1052 | break; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1056 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1055 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1056 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1057 | 1057 | |
1058 | 1058 | $_where = array( |
1059 | 1059 | 'TKT_is_default' => 1, |
1060 | 1060 | 'TKT_deleted' => $trashed |
1061 | 1061 | ); |
1062 | 1062 | |
1063 | - $offset = ($current_page-1)*$per_page; |
|
1064 | - $limit = array( $offset, $per_page ); |
|
1063 | + $offset = ($current_page - 1) * $per_page; |
|
1064 | + $limit = array($offset, $per_page); |
|
1065 | 1065 | |
1066 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1067 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1066 | + if (isset($this->_req_data['s'])) { |
|
1067 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1068 | 1068 | $_where['OR'] = array( |
1069 | - 'TKT_name' => array('LIKE',$sstr ), |
|
1070 | - 'TKT_description' => array('LIKE',$sstr ) |
|
1069 | + 'TKT_name' => array('LIKE', $sstr), |
|
1070 | + 'TKT_description' => array('LIKE', $sstr) |
|
1071 | 1071 | ); |
1072 | 1072 | } |
1073 | 1073 | |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | 'group_by'=>'TKT_ID' |
1079 | 1079 | ); |
1080 | 1080 | |
1081 | - if($count){ |
|
1081 | + if ($count) { |
|
1082 | 1082 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
1083 | - }else{ |
|
1083 | + } else { |
|
1084 | 1084 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1090,35 +1090,35 @@ discard block |
||
1090 | 1090 | |
1091 | 1091 | |
1092 | 1092 | |
1093 | - protected function _trash_or_restore_ticket( $trash = FALSE ) { |
|
1093 | + protected function _trash_or_restore_ticket($trash = FALSE) { |
|
1094 | 1094 | $success = 1; |
1095 | 1095 | |
1096 | 1096 | $TKT = EEM_Ticket::instance(); |
1097 | 1097 | |
1098 | 1098 | //checkboxes? |
1099 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1099 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1100 | 1100 | //if array has more than one element then success message should be plural |
1101 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1101 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1102 | 1102 | |
1103 | 1103 | //cycle thru the boxes |
1104 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1105 | - if ( $trash ) { |
|
1106 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1104 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1105 | + if ($trash) { |
|
1106 | + if ( ! $TKT->delete_by_ID($TKT_ID)) |
|
1107 | 1107 | $success = 0; |
1108 | 1108 | } else { |
1109 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1109 | + if ( ! $TKT->restore_by_ID($TKT_ID)) |
|
1110 | 1110 | $success = 0; |
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | } else { |
1114 | 1114 | //grab single id and trash |
1115 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1115 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1116 | 1116 | |
1117 | - if ( $trash ) { |
|
1118 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1117 | + if ($trash) { |
|
1118 | + if ( ! $TKT->delete_by_ID($TKT_ID)) |
|
1119 | 1119 | $success = 0; |
1120 | 1120 | } else { |
1121 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1121 | + if ( ! $TKT->restore_by_ID($TKT_ID)) |
|
1122 | 1122 | $success = 0; |
1123 | 1123 | } |
1124 | 1124 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | 'action' => 'ticket_list_table', |
1129 | 1129 | 'status' => $trash ? '' : 'trashed' |
1130 | 1130 | ); |
1131 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1131 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
@@ -1141,21 +1141,21 @@ discard block |
||
1141 | 1141 | $TKT = EEM_Ticket::instance(); |
1142 | 1142 | |
1143 | 1143 | //checkboxes? |
1144 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1144 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1145 | 1145 | //if array has more than one element then success message should be plural |
1146 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1146 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1147 | 1147 | |
1148 | 1148 | //cycle thru the boxes |
1149 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1149 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1150 | 1150 | //delete |
1151 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1151 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1152 | 1152 | $success = 0; |
1153 | 1153 | } |
1154 | 1154 | } |
1155 | 1155 | } else { |
1156 | 1156 | //grab single id and trash |
1157 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1158 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1157 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1158 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1159 | 1159 | $success = 0; |
1160 | 1160 | } |
1161 | 1161 | } |
@@ -1167,16 +1167,16 @@ discard block |
||
1167 | 1167 | ); |
1168 | 1168 | |
1169 | 1169 | //failsafe. If the default ticket count === 1 then we need to redirect to event overview. |
1170 | - if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) |
|
1170 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE)) |
|
1171 | 1171 | $query_args = array(); |
1172 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1172 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | |
1176 | 1176 | |
1177 | 1177 | |
1178 | - protected function _delete_the_ticket( $TKT_ID ) { |
|
1179 | - $tkt = EEM_Ticket::instance()->get_one_by_ID( $TKT_ID ); |
|
1178 | + protected function _delete_the_ticket($TKT_ID) { |
|
1179 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1180 | 1180 | $tkt->_remove_relations('Datetime'); |
1181 | 1181 | //delete all related prices first |
1182 | 1182 | $tkt->delete_related_permanently('Price'); |
@@ -87,6 +87,11 @@ |
||
87 | 87 | public function count_units_to_process() { |
88 | 88 | return \EEM_Attendee::instance()->count(); |
89 | 89 | } |
90 | + |
|
91 | + /** |
|
92 | + * @param integer $offset |
|
93 | + * @param integer $limit |
|
94 | + */ |
|
90 | 95 | public function get_csv_data( $offset, $limit ) { |
91 | 96 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
92 | 97 | array( |
@@ -99,10 +99,10 @@ |
||
99 | 99 | if( $field_name == 'STA_ID' ){ |
100 | 100 | $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
101 | 101 | $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
102 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
102 | + } elseif( $field_name == 'CNT_ISO' ){ |
|
103 | 103 | $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
104 | 104 | $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
107 | 107 | } |
108 | 108 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use EventEspressoBatchRequest\Helpers\JobParameters; |
19 | 19 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
20 | 20 | |
21 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
22 | 22 | exit('No direct script access allowed'); |
23 | 23 | } |
24 | 24 | |
@@ -27,84 +27,84 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | public function create_job(JobParameters $job_parameters) { |
30 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) { |
|
30 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) { |
|
31 | 31 | throw new BatchRequestException( |
32 | - __( 'You do not have permission to view contacts', 'event_espresso') |
|
32 | + __('You do not have permission to view contacts', 'event_espresso') |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | $filepath = $this->create_file_from_job_with_name( |
36 | 36 | $job_parameters->job_id(), |
37 | 37 | __('contact-list-report.csv', 'event_espresso') |
38 | 38 | ); |
39 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
40 | - $job_parameters->set_job_size( $this->count_units_to_process() ); |
|
39 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
40 | + $job_parameters->set_job_size($this->count_units_to_process()); |
|
41 | 41 | //we should also set the header columns |
42 | - $csv_data_for_row = $this->get_csv_data( 0, 1 ); |
|
43 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
42 | + $csv_data_for_row = $this->get_csv_data(0, 1); |
|
43 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
44 | 44 | //if we actually processed a row there, record it |
45 | - if( $job_parameters->job_size() ) { |
|
46 | - $job_parameters->mark_processed( 1 ); |
|
45 | + if ($job_parameters->job_size()) { |
|
46 | + $job_parameters->mark_processed(1); |
|
47 | 47 | } |
48 | 48 | return new JobStepResponse( |
49 | 49 | $job_parameters, |
50 | - __( 'Contacts report started successfully...', 'event_espresso' ) |
|
50 | + __('Contacts report started successfully...', 'event_espresso') |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
56 | - $csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size ); |
|
57 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
58 | - $units_processed = count( $csv_data ); |
|
59 | - $job_parameters->mark_processed( $units_processed ); |
|
56 | + $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size); |
|
57 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
58 | + $units_processed = count($csv_data); |
|
59 | + $job_parameters->mark_processed($units_processed); |
|
60 | 60 | $extra_response_data = array( |
61 | 61 | 'file_url' => '' |
62 | 62 | ); |
63 | - if( $units_processed < $batch_size ) { |
|
64 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
65 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
63 | + if ($units_processed < $batch_size) { |
|
64 | + $job_parameters->set_status(JobParameters::status_complete); |
|
65 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
66 | 66 | } |
67 | 67 | return new JobStepResponse( |
68 | 68 | $job_parameters, |
69 | 69 | sprintf( |
70 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
71 | - count( $csv_data ) ), |
|
70 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
71 | + count($csv_data) ), |
|
72 | 72 | $extra_response_data ); |
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | 76 | public function cleanup_job(JobParameters $job_parameters) { |
77 | 77 | $this->_file_helper->delete( |
78 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
78 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
79 | 79 | true, |
80 | 80 | 'd' |
81 | 81 | ); |
82 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
82 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function count_units_to_process() { |
86 | - return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin )); |
|
86 | + return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin)); |
|
87 | 87 | } |
88 | - public function get_csv_data( $offset, $limit ) { |
|
88 | + public function get_csv_data($offset, $limit) { |
|
89 | 89 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
90 | 90 | array( |
91 | - 'limit' => array( $offset, $limit ), |
|
92 | - 'force_join' => array( 'State', 'Country' ), |
|
91 | + 'limit' => array($offset, $limit), |
|
92 | + 'force_join' => array('State', 'Country'), |
|
93 | 93 | 'caps' => \EEM_Base::caps_read_admin |
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | $csv_data = array(); |
97 | - foreach( $attendee_rows as $attendee_row ){ |
|
97 | + foreach ($attendee_rows as $attendee_row) { |
|
98 | 98 | $csv_row = array(); |
99 | - foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
100 | - if( $field_name == 'STA_ID' ){ |
|
101 | - $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
102 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
103 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
104 | - $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
105 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
106 | - }else{ |
|
107 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
99 | + foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
100 | + if ($field_name == 'STA_ID') { |
|
101 | + $state_name_field = \EEM_State::instance()->field_settings_for('STA_name'); |
|
102 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
103 | + }elseif ($field_name == 'CNT_ISO') { |
|
104 | + $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name'); |
|
105 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
106 | + } else { |
|
107 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | $csv_data[] = $csv_row; |
@@ -24,15 +24,15 @@ |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | static $initialized = false; |
27 | - if ( ! $initialized ) { |
|
27 | + if ( ! $initialized) { |
|
28 | 28 | // instantiate PSR4 autoloader |
29 | - espresso_load_required( 'Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php' ); |
|
29 | + espresso_load_required('Psr4Autoloader', EE_CORE.'Psr4Autoloader.php'); |
|
30 | 30 | EE_Psr4AutoloaderInit::$psr4_loader = new \EventEspresso\Core\Psr4Autoloader(); |
31 | 31 | // register the autoloader |
32 | 32 | EE_Psr4AutoloaderInit::$psr4_loader->register(); |
33 | 33 | // register the base directories for the namespace prefix |
34 | - EE_Psr4AutoloaderInit::$psr4_loader->addNamespace( 'EventEspresso', EE_PLUGIN_DIR_PATH ); |
|
35 | - EE_Psr4AutoloaderInit::$psr4_loader->addNamespace( 'EventEspressoBatchRequest', EE_LIBRARIES . 'batch' ); |
|
34 | + EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH); |
|
35 | + EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES.'batch'); |
|
36 | 36 | $initialized = true; |
37 | 37 | } |
38 | 38 | } |
@@ -87,13 +87,13 @@ |
||
87 | 87 | |
88 | 88 | /** |
89 | 89 | * |
90 | - * Writes a row to the csv file |
|
91 | - * @param array $row - individual row of csv data |
|
92 | - * @param string $delimiter - csv delimiter |
|
93 | - * @param string $enclosure - csv enclosure |
|
94 | - * @param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value |
|
95 | - * @return string of text for teh csv file |
|
96 | - */ |
|
90 | + * Writes a row to the csv file |
|
91 | + * @param array $row - individual row of csv data |
|
92 | + * @param string $delimiter - csv delimiter |
|
93 | + * @param string $enclosure - csv enclosure |
|
94 | + * @param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value |
|
95 | + * @return string of text for teh csv file |
|
96 | + */ |
|
97 | 97 | public static function get_csv_row ( array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false ) { |
98 | 98 | //Allow user to filter the csv delimiter and enclosure for other countries csv standards |
99 | 99 | $delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter ); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param EE_Model_Field_Base $field |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public static function get_column_name_for_field(EE_Model_Field_Base $field){ |
|
33 | + public static function get_column_name_for_field(EE_Model_Field_Base $field) { |
|
34 | 34 | return $field->get_nicename()."[".$field->get_name()."]"; |
35 | 35 | } |
36 | 36 | |
@@ -52,32 +52,32 @@ discard block |
||
52 | 52 | * we consider that a success (because we wrote everything there was...nothing) |
53 | 53 | * @throws EE_Error |
54 | 54 | */ |
55 | - public static function write_data_array_to_csv( $filepath, $data, $write_column_headers = true ){ |
|
55 | + public static function write_data_array_to_csv($filepath, $data, $write_column_headers = true) { |
|
56 | 56 | EE_Registry::instance()->load_helper('Array'); |
57 | 57 | |
58 | 58 | $new_file_contents = ''; |
59 | 59 | //determine if $data is actually a 2d array |
60 | - if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){ |
|
60 | + if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) { |
|
61 | 61 | //make sure top level is numerically indexed, |
62 | 62 | |
63 | - if( EEH_Array::is_associative_array($data)){ |
|
64 | - throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s","event_espresso"),implode(",",array_keys($data)))); |
|
63 | + if (EEH_Array::is_associative_array($data)) { |
|
64 | + throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data)))); |
|
65 | 65 | } |
66 | 66 | $item_in_top_level_array = EEH_Array::get_one_item_from_array($data); |
67 | 67 | //now, is the last item in the top-level array of $data an associative or numeric array? |
68 | - if( $write_column_headers && |
|
69 | - EEH_Array::is_associative_array($item_in_top_level_array)){ |
|
68 | + if ($write_column_headers && |
|
69 | + EEH_Array::is_associative_array($item_in_top_level_array)) { |
|
70 | 70 | //its associative, so we want to output its keys as column headers |
71 | 71 | $keys = array_keys($item_in_top_level_array); |
72 | - $new_file_contents .= EEH_Export::get_csv_row( $keys ); |
|
72 | + $new_file_contents .= EEH_Export::get_csv_row($keys); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | //start writing data |
76 | - foreach($data as $data_row){ |
|
77 | - $new_file_contents .= EEH_Export::get_csv_row( $data_row); |
|
76 | + foreach ($data as $data_row) { |
|
77 | + $new_file_contents .= EEH_Export::get_csv_row($data_row); |
|
78 | 78 | } |
79 | - return EEH_File::write_to_file( $filepath, EEH_File::get_file_contents( $filepath ) . $new_file_contents ); |
|
80 | - }else{ |
|
79 | + return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath).$new_file_contents); |
|
80 | + } else { |
|
81 | 81 | //no data TO write... so we can assume that's a success |
82 | 82 | return true; |
83 | 83 | } |
@@ -94,29 +94,29 @@ discard block |
||
94 | 94 | * @param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value |
95 | 95 | * @return string of text for teh csv file |
96 | 96 | */ |
97 | - public static function get_csv_row ( array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false ) { |
|
97 | + public static function get_csv_row(array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false) { |
|
98 | 98 | //Allow user to filter the csv delimiter and enclosure for other countries csv standards |
99 | - $delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter ); |
|
100 | - $enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure ); |
|
99 | + $delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter); |
|
100 | + $enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure); |
|
101 | 101 | |
102 | 102 | $delimiter_esc = preg_quote($delimiter, '/'); |
103 | 103 | $enclosure_esc = preg_quote($enclosure, '/'); |
104 | 104 | |
105 | 105 | $output = array(); |
106 | 106 | foreach ($row as $field_value) { |
107 | - if(is_object($field_value) || is_array($field_value)){ |
|
107 | + if (is_object($field_value) || is_array($field_value)) { |
|
108 | 108 | $field_value = serialize($field_value); |
109 | 109 | } |
110 | - if ($field_value === null && $mysql_null ) { |
|
110 | + if ($field_value === null && $mysql_null) { |
|
111 | 111 | $output[] = 'NULL'; |
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ? |
116 | - ( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value; |
|
116 | + ($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value; |
|
117 | 117 | } |
118 | 118 | |
119 | - return implode($delimiter, $output) . PHP_EOL; |
|
119 | + return implode($delimiter, $output).PHP_EOL; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | |
@@ -129,19 +129,19 @@ discard block |
||
129 | 129 | * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - public static function prepare_value_from_db_for_display( $model, $field_name, $raw_db_value, $pretty_schema = true ) { |
|
133 | - $field_obj = $model->field_settings_for( $field_name ); |
|
134 | - $value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value ); |
|
135 | - if( $field_obj instanceof EE_Datetime_Field ) { |
|
136 | - $field_obj->set_date_format( EEH_Export::get_date_format_for_export( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema ); |
|
137 | - $field_obj->set_time_format( EEH_Export::get_time_format_for_export( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema ); |
|
132 | + public static function prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) { |
|
133 | + $field_obj = $model->field_settings_for($field_name); |
|
134 | + $value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value); |
|
135 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
136 | + $field_obj->set_date_format(EEH_Export::get_date_format_for_export($field_obj->get_date_format($pretty_schema)), $pretty_schema); |
|
137 | + $field_obj->set_time_format(EEH_Export::get_time_format_for_export($field_obj->get_time_format($pretty_schema)), $pretty_schema); |
|
138 | 138 | } |
139 | - if( $pretty_schema === true){ |
|
140 | - return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj ); |
|
141 | - }elseif( is_string( $pretty_schema ) ) { |
|
142 | - return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema ); |
|
143 | - }else{ |
|
144 | - return $field_obj->prepare_for_get( $value_on_model_obj ); |
|
139 | + if ($pretty_schema === true) { |
|
140 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj); |
|
141 | + }elseif (is_string($pretty_schema)) { |
|
142 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema); |
|
143 | + } else { |
|
144 | + return $field_obj->prepare_for_get($value_on_model_obj); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @param string $current_format |
153 | 153 | * @return string |
154 | 154 | */ |
155 | - public static function get_date_format_for_export( $current_format = null ) { |
|
156 | - return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format ); |
|
155 | + public static function get_date_format_for_export($current_format = null) { |
|
156 | + return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @param string $current_format |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public static function get_time_format_for_export( $current_format = null ) { |
|
167 | - return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format ); |
|
166 | + public static function get_time_format_for_export($current_format = null) { |
|
167 | + return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -77,7 +79,7 @@ discard block |
||
77 | 79 | $new_file_contents .= EEH_Export::get_csv_row( $data_row); |
78 | 80 | } |
79 | 81 | return EEH_File::write_to_file( $filepath, EEH_File::get_file_contents( $filepath ) . $new_file_contents ); |
80 | - }else{ |
|
82 | + } else{ |
|
81 | 83 | //no data TO write... so we can assume that's a success |
82 | 84 | return true; |
83 | 85 | } |
@@ -138,9 +140,9 @@ discard block |
||
138 | 140 | } |
139 | 141 | if( $pretty_schema === true){ |
140 | 142 | return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj ); |
141 | - }elseif( is_string( $pretty_schema ) ) { |
|
143 | + } elseif( is_string( $pretty_schema ) ) { |
|
142 | 144 | return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema ); |
143 | - }else{ |
|
145 | + } else{ |
|
144 | 146 | return $field_obj->prepare_for_get( $value_on_model_obj ); |
145 | 147 | } |
146 | 148 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | use EventEspressoBatchRequest\Helpers\JobParameters; |
24 | 24 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
25 | 25 | |
26 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
27 | - exit( 'No direct script access allowed' ); |
|
26 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
27 | + exit('No direct script access allowed'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -50,32 +50,32 @@ discard block |
||
50 | 50 | * @param array $request_data to be used by the batch job handler |
51 | 51 | * @return JobStepResponse |
52 | 52 | */ |
53 | - public function create_job( $batch_job_handler_class, $request_data ) { |
|
53 | + public function create_job($batch_job_handler_class, $request_data) { |
|
54 | 54 | try { |
55 | - $this->_job_id = wp_generate_password( 15, false ); |
|
56 | - $obj = $this->instantiate_batch_job_handler_from_classname( $batch_job_handler_class ); |
|
57 | - $this->_job_parameters = new JobParameters( $this->_job_id, $batch_job_handler_class, $request_data ); |
|
58 | - $response = $obj->create_job( $this->_job_parameters ); |
|
59 | - if( ! $response instanceof JobStepResponse ) { |
|
55 | + $this->_job_id = wp_generate_password(15, false); |
|
56 | + $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
|
57 | + $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
|
58 | + $response = $obj->create_job($this->_job_parameters); |
|
59 | + if ( ! $response instanceof JobStepResponse) { |
|
60 | 60 | throw new BatchRequestException( |
61 | 61 | sprintf( |
62 | - __( 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso' ), |
|
63 | - wp_json_encode( $request_data ) |
|
62 | + __('The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso'), |
|
63 | + wp_json_encode($request_data) |
|
64 | 64 | ) |
65 | 65 | ); |
66 | 66 | } |
67 | - $success = $this->_job_parameters->save( true ); |
|
68 | - if( ! $success ) { |
|
67 | + $success = $this->_job_parameters->save(true); |
|
68 | + if ( ! $success) { |
|
69 | 69 | throw new BatchRequestException( |
70 | 70 | sprintf( |
71 | 71 | __('Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', 'event_espresso'), |
72 | 72 | $this->_job_id, |
73 | - wp_json_encode( $request_data ) |
|
73 | + wp_json_encode($request_data) |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | } |
77 | - } catch( \Exception $e ) { |
|
78 | - $response = $this->_get_error_response( $e, 'create_job' ); |
|
77 | + } catch (\Exception $e) { |
|
78 | + $response = $this->_get_error_response($e, 'create_job'); |
|
79 | 79 | } |
80 | 80 | return $response; |
81 | 81 | } |
@@ -88,26 +88,26 @@ discard block |
||
88 | 88 | * @param int $batch_size |
89 | 89 | * @return JobStepResponse |
90 | 90 | */ |
91 | - public function continue_job( $job_id, $batch_size = 50 ) { |
|
91 | + public function continue_job($job_id, $batch_size = 50) { |
|
92 | 92 | try { |
93 | 93 | $this->_job_id = $job_id; |
94 | - $batch_size = defined( 'EE_BATCHRUNNER_BATCH_SIZE' ) ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
94 | + $batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
95 | 95 | //get the corresponding WordPress option for the job |
96 | - $this->_job_parameters = JobParameters::load( $this->_job_id ); |
|
97 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname( $this->_job_parameters->classname() ); |
|
96 | + $this->_job_parameters = JobParameters::load($this->_job_id); |
|
97 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
|
98 | 98 | //continue it |
99 | - $response = $handler_obj->continue_job( $this->_job_parameters, $batch_size ); |
|
100 | - if( ! $response instanceof JobStepResponse ) { |
|
99 | + $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
|
100 | + if ( ! $response instanceof JobStepResponse) { |
|
101 | 101 | throw new BatchRequestException( |
102 | 102 | sprintf( |
103 | - __( 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ), |
|
103 | + __('The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'), |
|
104 | 104 | $this->_job_id |
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | } |
108 | 108 | $this->_job_parameters->save(); |
109 | - } catch( \Exception $e ) { |
|
110 | - $response = $this->_get_error_response( $e, 'continue_job' ); |
|
109 | + } catch (\Exception $e) { |
|
110 | + $response = $this->_get_error_response($e, 'continue_job'); |
|
111 | 111 | } |
112 | 112 | return $response; |
113 | 113 | } |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return JobHandlerInterface |
123 | 123 | * @throws BatchRequestException |
124 | 124 | */ |
125 | - public function instantiate_batch_job_handler_from_classname( $classname ) { |
|
126 | - if( ! class_exists( $classname ) ) { |
|
125 | + public function instantiate_batch_job_handler_from_classname($classname) { |
|
126 | + if ( ! class_exists($classname)) { |
|
127 | 127 | throw new BatchRequestException( |
128 | 128 | sprintf( |
129 | 129 | __('The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', 'event_espresso'), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ); |
133 | 133 | } |
134 | 134 | $obj = new $classname; |
135 | - if( ! $obj instanceof JobHandlerInterface ) { |
|
135 | + if ( ! $obj instanceof JobHandlerInterface) { |
|
136 | 136 | throw new BatchRequestException( |
137 | 137 | sprintf( |
138 | 138 | __('The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', 'event_espresso'), |
@@ -152,26 +152,26 @@ discard block |
||
152 | 152 | * @return JobStepResponse |
153 | 153 | * @throws BatchRequestException |
154 | 154 | */ |
155 | - public function cleanup_job( $job_id ) { |
|
156 | - try{ |
|
155 | + public function cleanup_job($job_id) { |
|
156 | + try { |
|
157 | 157 | $this->_job_id = $job_id; |
158 | - $job_parameters = JobParameters::load( $this->_job_id ); |
|
159 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname( $job_parameters->classname() ); |
|
158 | + $job_parameters = JobParameters::load($this->_job_id); |
|
159 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
|
160 | 160 | //continue it |
161 | - $response = $handler_obj->cleanup_job( $job_parameters ); |
|
162 | - if( ! $response instanceof JobStepResponse ) { |
|
161 | + $response = $handler_obj->cleanup_job($job_parameters); |
|
162 | + if ( ! $response instanceof JobStepResponse) { |
|
163 | 163 | throw new BatchRequestException( |
164 | 164 | sprintf( |
165 | - __( 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ), |
|
165 | + __('The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'), |
|
166 | 166 | $this->_job_id |
167 | 167 | ) |
168 | 168 | ); |
169 | 169 | } |
170 | - $job_parameters->set_status( JobParameters::status_cleaned_up ); |
|
170 | + $job_parameters->set_status(JobParameters::status_cleaned_up); |
|
171 | 171 | $job_parameters->delete(); |
172 | 172 | return $response; |
173 | - } catch( \Exception $e ) { |
|
174 | - $response = $this->_get_error_response( $e, 'cleanup_job' ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + $response = $this->_get_error_response($e, 'cleanup_job'); |
|
175 | 175 | } |
176 | 176 | return $response; |
177 | 177 | } |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | * @param string $method_name |
185 | 185 | * @return JobStepResponse |
186 | 186 | */ |
187 | - protected function _get_error_response( \Exception $exception, $method_name ) { |
|
188 | - if( ! $this->_job_parameters instanceof JobParameters ) { |
|
189 | - $this->_job_parameters = new JobParameters( $this->_job_id, __( '__Unknown__', 'event_espresso' ), array() ); |
|
187 | + protected function _get_error_response(\Exception $exception, $method_name) { |
|
188 | + if ( ! $this->_job_parameters instanceof JobParameters) { |
|
189 | + $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
|
190 | 190 | } |
191 | - $this->_job_parameters->set_status( JobParameters::status_error ); |
|
191 | + $this->_job_parameters->set_status(JobParameters::status_error); |
|
192 | 192 | return new JobStepResponse( |
193 | 193 | $this->_job_parameters, |
194 | 194 | sprintf( |
195 | 195 | __('An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', 'event_espresso'), |
196 | - get_class( $exception ), |
|
197 | - 'BatchRunner::' . $method_name . '()', |
|
196 | + get_class($exception), |
|
197 | + 'BatchRunner::'.$method_name.'()', |
|
198 | 198 | $exception->getMessage(), |
199 | 199 | $exception->getTraceAsString() |
200 | 200 | ) |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class BatchRequetProcessor |
|
3 | + * |
|
4 | + * Class BatchRequetProcessor |
|
5 | 5 | * |
6 | - * Responsible for receiving a request to start a job and assign it a job Id. |
|
7 | - * Then when subsequent requests come in to continue that job, dispatches |
|
8 | - * the request to the appropriate JobHandler, which processes a step of the batch, |
|
9 | - * and then returns the job's new status. |
|
10 | - * This class is used by controller code, and the controller code is sent HTTP |
|
11 | - * requests from the batch_runner.js library |
|
12 | - * |
|
13 | - * @package Event Espresso |
|
14 | - * @subpackage batch |
|
15 | - * @author Mike Nelson |
|
16 | - * @since 4.8.26 |
|
17 | - * |
|
18 | - */ |
|
6 | + * Responsible for receiving a request to start a job and assign it a job Id. |
|
7 | + * Then when subsequent requests come in to continue that job, dispatches |
|
8 | + * the request to the appropriate JobHandler, which processes a step of the batch, |
|
9 | + * and then returns the job's new status. |
|
10 | + * This class is used by controller code, and the controller code is sent HTTP |
|
11 | + * requests from the batch_runner.js library |
|
12 | + * |
|
13 | + * @package Event Espresso |
|
14 | + * @subpackage batch |
|
15 | + * @author Mike Nelson |
|
16 | + * @since 4.8.26 |
|
17 | + * |
|
18 | + */ |
|
19 | 19 | namespace EventEspressoBatchRequest; |
20 | 20 | |
21 | 21 | use EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerInterface; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | namespace EventEspressoBatchRequest\Helpers; |
16 | 16 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
17 | 17 | |
18 | -class BatchRequestException extends \Exception{ |
|
18 | +class BatchRequestException extends \Exception { |
|
19 | 19 | //so far the same as exception |
20 | 20 | } |
21 | 21 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class BatchRequestException |
|
5 | - * |
|
6 | - * Exception class for whenever we have trouble running start, continuing, or finishing |
|
7 | - * a batch job. |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage batch |
|
11 | - * @author Mike Nelson |
|
12 | - * @since 4.8.26 |
|
13 | - * |
|
14 | - */ |
|
3 | + * |
|
4 | + * Class BatchRequestException |
|
5 | + * |
|
6 | + * Exception class for whenever we have trouble running start, continuing, or finishing |
|
7 | + * a batch job. |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage batch |
|
11 | + * @author Mike Nelson |
|
12 | + * @since 4.8.26 |
|
13 | + * |
|
14 | + */ |
|
15 | 15 | namespace EventEspressoBatchRequest\Helpers; |
16 | 16 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
17 | 17 |
@@ -43,10 +43,10 @@ |
||
43 | 43 | * @param string $update_text |
44 | 44 | * @param array $extra_data |
45 | 45 | */ |
46 | - public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array() ) { |
|
47 | - $this->_job_parameters = $job_parameters; |
|
46 | + public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array()) { |
|
47 | + $this->_job_parameters = $job_parameters; |
|
48 | 48 | $this->_update_text = $update_text; |
49 | - $this->_extra_data = (array)$extra_data; |
|
49 | + $this->_extra_data = (array) $extra_data; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | use EventEspressoBatchRequest\Helpers\JobParameters; |
21 | 21 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
22 | 22 | |
23 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
24 | - exit( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
24 | + exit('No direct script access allowed'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @throws BatchRequestException |
36 | 36 | * @return JobStepResponse |
37 | 37 | */ |
38 | - public function create_job( JobParameters $job_parameters ); |
|
38 | + public function create_job(JobParameters $job_parameters); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Performs another step of the job |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return JobStepResponse |
45 | 45 | * @throws BatchRequestException |
46 | 46 | */ |
47 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ); |
|
47 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Performs any clean-up logic when we know the job is completed |
@@ -52,5 +52,5 @@ discard block |
||
52 | 52 | * @return JobStepResponse |
53 | 53 | * @throws BatchRequestException |
54 | 54 | */ |
55 | - public function cleanup_job( JobParameters $job_parameters ); |
|
55 | + public function cleanup_job(JobParameters $job_parameters); |
|
56 | 56 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if( ! $event_slug ) { |
76 | 76 | $event_slug = __( 'unknown', 'event_espresso' ); |
77 | 77 | } |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | $event_slug = __( 'all', 'event_espresso' ); |
80 | 80 | } |
81 | 81 | return sprintf( "registrations-for-%s.csv", $event_slug ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ); |
163 | 163 | if( $event_id ){ |
164 | 164 | $query_params[0]['EVT_ID'] = $event_id; |
165 | - }else{ |
|
165 | + } else{ |
|
166 | 166 | $query_params[ 'force_join' ][] = 'Event'; |
167 | 167 | } |
168 | 168 | $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $field = $reg_model->field_settings_for($field_name); |
192 | 192 | if($field_name == 'REG_final_price'){ |
193 | 193 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
194 | - }elseif( $field_name == 'REG_count' ){ |
|
194 | + } elseif( $field_name == 'REG_count' ){ |
|
195 | 195 | $value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
196 | - }elseif( $field_name == 'REG_date' ) { |
|
196 | + } elseif( $field_name == 'REG_date' ) { |
|
197 | 197 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
198 | - }else{ |
|
198 | + } else{ |
|
199 | 199 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
200 | 200 | } |
201 | 201 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | if( $reg_row[ 'Attendee_CPT.ID' ]){ |
268 | 268 | if($att_field_name == 'STA_ID'){ |
269 | 269 | $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
270 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
270 | + } elseif($att_field_name == 'CNT_ISO'){ |
|
271 | 271 | $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
272 | - }else{ |
|
272 | + } else{ |
|
273 | 273 | $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
274 | 274 | } |
275 | - }else{ |
|
275 | + } else{ |
|
276 | 276 | $value = ''; |
277 | 277 | } |
278 | 278 |
@@ -410,7 +410,7 @@ |
||
410 | 410 | * Performs any clean-up logic when we know the job is completed. |
411 | 411 | * In this case, we delete the temporary file |
412 | 412 | * @param JobParameters $job_parameters |
413 | - * @return boolean |
|
413 | + * @return JobStepResponse |
|
414 | 414 | */ |
415 | 415 | public function cleanup_job( JobParameters $job_parameters ){ |
416 | 416 | $this->_file_helper->delete( |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | use EventEspressoBatchRequest\Helpers\JobParameters; |
20 | 20 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
21 | 21 | |
22 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
23 | - exit( 'No direct script access allowed' ); |
|
22 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
23 | + exit('No direct script access allowed'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @throws BatchRequestException |
36 | 36 | * @return JobStepResponse |
37 | 37 | */ |
38 | - public function create_job( JobParameters $job_parameters ) { |
|
39 | - $event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) ); |
|
40 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) { |
|
38 | + public function create_job(JobParameters $job_parameters) { |
|
39 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
40 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
41 | 41 | throw new BatchRequestException( |
42 | - __( 'You do not have permission to view registrations', 'event_espresso') |
|
42 | + __('You do not have permission to view registrations', 'event_espresso') |
|
43 | 43 | ); |
44 | 44 | } |
45 | 45 | $filepath = $this->create_file_from_job_with_name( |
46 | 46 | $job_parameters->job_id(), |
47 | - $this->get_filename_from_event( $event_id ) |
|
47 | + $this->get_filename_from_event($event_id) |
|
48 | 48 | ); |
49 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
50 | - $question_data_for_columns = $this->_get_questions_for_report( $event_id ); |
|
51 | - $job_parameters->add_extra_data( 'questions_data', $question_data_for_columns ); |
|
52 | - $job_parameters->set_job_size( $this->count_units_to_process( $event_id ) ); |
|
49 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
50 | + $question_data_for_columns = $this->_get_questions_for_report($event_id); |
|
51 | + $job_parameters->add_extra_data('questions_data', $question_data_for_columns); |
|
52 | + $job_parameters->set_job_size($this->count_units_to_process($event_id)); |
|
53 | 53 | //we should also set the header columns |
54 | 54 | $csv_data_for_row = $this->get_csv_data_for( |
55 | 55 | $event_id, |
56 | 56 | 0, |
57 | 57 | 1, |
58 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
59 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
58 | + $job_parameters->extra_datum('questions_data') ); |
|
59 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
60 | 60 | //if we actually processed a row there, record it |
61 | - if( $job_parameters->job_size() ) { |
|
62 | - $job_parameters->mark_processed( 1 ); |
|
61 | + if ($job_parameters->job_size()) { |
|
62 | + $job_parameters->mark_processed(1); |
|
63 | 63 | } |
64 | 64 | return new JobStepResponse( |
65 | 65 | $job_parameters, |
66 | - __( 'Registrations report started successfully...', 'event_espresso' ) |
|
66 | + __('Registrations report started successfully...', 'event_espresso') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | * @param int $event_id |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - protected function get_filename_from_event( $event_id ) { |
|
78 | - if( $event_id ){ |
|
79 | - $event_slug = \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
80 | - if( ! $event_slug ) { |
|
81 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
77 | + protected function get_filename_from_event($event_id) { |
|
78 | + if ($event_id) { |
|
79 | + $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
80 | + if ( ! $event_slug) { |
|
81 | + $event_slug = __('unknown', 'event_espresso'); |
|
82 | 82 | } |
83 | - }else{ |
|
84 | - $event_slug = __( 'all', 'event_espresso' ); |
|
83 | + } else { |
|
84 | + $event_slug = __('all', 'event_espresso'); |
|
85 | 85 | } |
86 | - return sprintf( "registrations-for-%s.csv", $event_slug ); |
|
86 | + return sprintf("registrations-for-%s.csv", $event_slug); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | * @param int|null $event_id |
93 | 93 | * @return array of wpdb results for questions which are to be used for this report |
94 | 94 | */ |
95 | - protected function _get_questions_for_report( $event_id ) { |
|
95 | + protected function _get_questions_for_report($event_id) { |
|
96 | 96 | $question_query_params = array( |
97 | 97 | array( |
98 | - 'Answer.ANS_ID' => array( 'IS_NOT_NULL' ), |
|
98 | + 'Answer.ANS_ID' => array('IS_NOT_NULL'), |
|
99 | 99 | ), |
100 | - 'group_by' => array( 'QST_ID' ) |
|
100 | + 'group_by' => array('QST_ID') |
|
101 | 101 | ); |
102 | - if( $event_id ) { |
|
102 | + if ($event_id) { |
|
103 | 103 | $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id; |
104 | 104 | } |
105 | - return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params ); |
|
105 | + return \EEM_Question::instance()->get_all_wpdb_results($question_query_params); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -115,27 +115,27 @@ discard block |
||
115 | 115 | * @return JobStepResponse |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) { |
|
118 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
|
119 | 119 | $csv_data = $this->get_csv_data_for( |
120 | - $job_parameters->request_datum( 'EVT_ID', '0'), |
|
120 | + $job_parameters->request_datum('EVT_ID', '0'), |
|
121 | 121 | $job_parameters->units_processed(), |
122 | 122 | $batch_size, |
123 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
124 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
125 | - $units_processed = count( $csv_data ); |
|
126 | - $job_parameters->mark_processed( $units_processed ); |
|
123 | + $job_parameters->extra_datum('questions_data') ); |
|
124 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
125 | + $units_processed = count($csv_data); |
|
126 | + $job_parameters->mark_processed($units_processed); |
|
127 | 127 | $extra_response_data = array( |
128 | 128 | 'file_url' => '' |
129 | 129 | ); |
130 | - if( $units_processed < $batch_size ) { |
|
131 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
132 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
130 | + if ($units_processed < $batch_size) { |
|
131 | + $job_parameters->set_status(JobParameters::status_complete); |
|
132 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
133 | 133 | } |
134 | 134 | return new JobStepResponse( |
135 | 135 | $job_parameters, |
136 | 136 | sprintf( |
137 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
138 | - count( $csv_data ) ), |
|
137 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
138 | + count($csv_data) ), |
|
139 | 139 | $extra_response_data ); |
140 | 140 | } |
141 | 141 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return array top-level keys are numeric, next-level keys are column headers |
149 | 149 | * |
150 | 150 | */ |
151 | - function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) { |
|
151 | + function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) { |
|
152 | 152 | $reg_fields_to_include = array( |
153 | 153 | 'TXN_ID', |
154 | 154 | 'ATT_ID', |
@@ -179,166 +179,166 @@ discard block |
||
179 | 179 | array( |
180 | 180 | 'OR' => array( |
181 | 181 | //don't include registrations from failed or abandoned transactions... |
182 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
182 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
183 | 183 | //unless the registration is approved, in which case include it regardless of transaction status |
184 | 184 | 'STS_ID' => \EEM_Registration::status_id_approved |
185 | 185 | ), |
186 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
186 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
187 | 187 | ), |
188 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
189 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
190 | - 'limit' => array( $offset, $limit ), |
|
188 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
189 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
190 | + 'limit' => array($offset, $limit), |
|
191 | 191 | 'caps' => \EEM_Base::caps_read_admin |
192 | 192 | ), |
193 | 193 | $event_id |
194 | 194 | ); |
195 | - if( $event_id ){ |
|
196 | - $query_params[0]['EVT_ID'] = $event_id; |
|
197 | - }else{ |
|
198 | - $query_params[ 'force_join' ][] = 'Event'; |
|
195 | + if ($event_id) { |
|
196 | + $query_params[0]['EVT_ID'] = $event_id; |
|
197 | + } else { |
|
198 | + $query_params['force_join'][] = 'Event'; |
|
199 | 199 | } |
200 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
200 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
201 | 201 | //get all questions which relate to someone in this group |
202 | 202 | $registration_ids = array(); |
203 | - foreach( $registration_rows as $reg_row ) { |
|
204 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
203 | + foreach ($registration_rows as $reg_row) { |
|
204 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
205 | 205 | } |
206 | 206 | |
207 | - foreach($registration_rows as $reg_row){ |
|
208 | - if ( is_array( $reg_row ) ) { |
|
207 | + foreach ($registration_rows as $reg_row) { |
|
208 | + if (is_array($reg_row)) { |
|
209 | 209 | $reg_csv_array = array(); |
210 | - if( ! $event_id ){ |
|
210 | + if ( ! $event_id) { |
|
211 | 211 | //get the event's name and Id |
212 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
212 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
213 | 213 | } |
214 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
214 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
215 | 215 | /*@var $reg_row EE_Registration */ |
216 | - foreach($reg_fields_to_include as $field_name){ |
|
216 | + foreach ($reg_fields_to_include as $field_name) { |
|
217 | 217 | $field = $reg_model->field_settings_for($field_name); |
218 | - if($field_name == 'REG_final_price'){ |
|
219 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
220 | - }elseif( $field_name == 'REG_count' ){ |
|
221 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
222 | - }elseif( $field_name == 'REG_date' ) { |
|
223 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
224 | - }else{ |
|
225 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
218 | + if ($field_name == 'REG_final_price') { |
|
219 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
220 | + }elseif ($field_name == 'REG_count') { |
|
221 | + $value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
222 | + }elseif ($field_name == 'REG_date') { |
|
223 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
224 | + } else { |
|
225 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
226 | 226 | } |
227 | 227 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
228 | - if($field_name == 'REG_final_price'){ |
|
228 | + if ($field_name == 'REG_final_price') { |
|
229 | 229 | //add a column named Currency after the final price |
230 | 230 | $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | //get pretty status |
234 | - $stati = \EEM_Status::instance()->localized_status( array( |
|
235 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
236 | - $reg_row[ 'TransactionTable.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
234 | + $stati = \EEM_Status::instance()->localized_status(array( |
|
235 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
236 | + $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso') ), |
|
237 | 237 | FALSE, |
238 | - 'sentence' ); |
|
239 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
238 | + 'sentence'); |
|
239 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
240 | 240 | //get pretty transaction status |
241 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'TransactionTable.STS_ID' ] ]; |
|
242 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'TransactionTable.TXN_total' ], 'localized_float' ) : '0.00'; |
|
243 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'TransactionTable.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
241 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
242 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
243 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
244 | 244 | $payment_methods = array(); |
245 | 245 | $gateway_txn_ids_etc = array(); |
246 | 246 | $payment_times = array(); |
247 | - if( $is_primary_reg && $reg_row[ 'TransactionTable.TXN_ID' ] ){ |
|
247 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
248 | 248 | $payments_info = \EEM_Payment::instance()->get_all_wpdb_results( |
249 | 249 | array( |
250 | 250 | array( |
251 | - 'TXN_ID' => $reg_row[ 'TransactionTable.TXN_ID' ], |
|
251 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
252 | 252 | 'STS_ID' => \EEM_Payment::status_id_approved |
253 | 253 | ), |
254 | - 'force_join' => array( 'Payment_Method' ), |
|
254 | + 'force_join' => array('Payment_Method'), |
|
255 | 255 | |
256 | 256 | ), |
257 | 257 | ARRAY_A, |
258 | 258 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
259 | 259 | |
260 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
261 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
262 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
263 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
260 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
261 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
262 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
263 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | } |
267 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
268 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
269 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
267 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
268 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
269 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
270 | 270 | |
271 | 271 | //get whether or not the user has checked in |
272 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
272 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
273 | 273 | //get ticket of registration and its price |
274 | 274 | $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
275 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
276 | - $ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
275 | + if ($reg_row['Ticket.TKT_ID']) { |
|
276 | + $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
277 | 277 | $datetimes_strings = array(); |
278 | - foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){ |
|
279 | - $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
278 | + foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) { |
|
279 | + $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | } else { |
283 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
284 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
283 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
284 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
285 | 285 | } |
286 | 286 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
287 | 287 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
288 | 288 | //get datetime(s) of registration |
289 | 289 | |
290 | 290 | //add attendee columns |
291 | - foreach($att_fields_to_include as $att_field_name){ |
|
291 | + foreach ($att_fields_to_include as $att_field_name) { |
|
292 | 292 | $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
293 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
294 | - if($att_field_name == 'STA_ID'){ |
|
295 | - $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
296 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
297 | - $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
298 | - }else{ |
|
299 | - $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
293 | + if ($reg_row['Attendee_CPT.ID']) { |
|
294 | + if ($att_field_name == 'STA_ID') { |
|
295 | + $value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
296 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
297 | + $value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
298 | + } else { |
|
299 | + $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
300 | 300 | } |
301 | - }else{ |
|
301 | + } else { |
|
302 | 302 | $value = ''; |
303 | 303 | } |
304 | 304 | |
305 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
305 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | //make sure each registration has the same questions in the same order |
309 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
310 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
311 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
309 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
310 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
311 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | $answers = \EEM_Answer::instance()->get_all_wpdb_results( |
315 | 315 | array( |
316 | - array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), |
|
317 | - 'force_join' => array( 'Question' ) |
|
316 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
317 | + 'force_join' => array('Question') |
|
318 | 318 | ) |
319 | 319 | ); |
320 | 320 | //now fill out the questions THEY answered |
321 | - foreach( $answers as $answer_row ){ |
|
322 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
321 | + foreach ($answers as $answer_row) { |
|
322 | + if ($answer_row['Question.QST_ID']) { |
|
323 | 323 | $question_label = \EEH_Export::prepare_value_from_db_for_display( |
324 | 324 | \EEM_Question::instance(), |
325 | 325 | 'QST_admin_label', |
326 | - $answer_row[ 'Question.QST_admin_label' ] |
|
326 | + $answer_row['Question.QST_admin_label'] |
|
327 | 327 | ); |
328 | 328 | } else { |
329 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
329 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
330 | 330 | } |
331 | - if ( isset( $answer_row[ 'Question.QST_type' ] ) |
|
332 | - && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state |
|
331 | + if (isset($answer_row['Question.QST_type']) |
|
332 | + && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
333 | 333 | ) { |
334 | - $reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID( |
|
335 | - $answer_row[ 'Answer.ANS_value' ] |
|
334 | + $reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID( |
|
335 | + $answer_row['Answer.ANS_value'] |
|
336 | 336 | ); |
337 | 337 | } else { |
338 | - $reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display( |
|
338 | + $reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display( |
|
339 | 339 | \EEM_Answer::instance(), |
340 | 340 | 'ANS_value', |
341 | - $answer_row[ 'Answer.ANS_value' ] |
|
341 | + $answer_row['Answer.ANS_value'] |
|
342 | 342 | ); |
343 | 343 | } |
344 | 344 | } |
@@ -349,17 +349,17 @@ discard block |
||
349 | 349 | } |
350 | 350 | } |
351 | 351 | //if we couldn't export anything, we want to at least show the column headers |
352 | - if ( empty( $registrations_csv_ready_array ) ) { |
|
352 | + if (empty($registrations_csv_ready_array)) { |
|
353 | 353 | $reg_csv_array = array(); |
354 | 354 | $model_and_fields_to_include = array( |
355 | 355 | 'Registration' => $reg_fields_to_include, |
356 | 356 | 'Attendee' => $att_fields_to_include |
357 | 357 | ); |
358 | - foreach ( $model_and_fields_to_include as $model_name => $field_list ) { |
|
359 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
360 | - foreach ( $field_list as $field_name ) { |
|
361 | - $field = $model->field_settings_for( $field_name ); |
|
362 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null; |
|
358 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
359 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
360 | + foreach ($field_list as $field_name) { |
|
361 | + $field = $model->field_settings_for($field_name); |
|
362 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | $registrations_csv_ready_array[] = $reg_csv_array; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param int $event_id |
376 | 376 | * @return int |
377 | 377 | */ |
378 | - public function count_units_to_process( $event_id ) { |
|
378 | + public function count_units_to_process($event_id) { |
|
379 | 379 | //use the legacy filter |
380 | 380 | $query_params = apply_filters( |
381 | 381 | 'FHEE__EE_Export__report_registration_for_event', |
@@ -383,24 +383,24 @@ discard block |
||
383 | 383 | array( |
384 | 384 | 'OR' => array( |
385 | 385 | //don't include registrations from failed or abandoned transactions... |
386 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
386 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
387 | 387 | //unless the registration is approved, in which case include it regardless of transaction status |
388 | 388 | 'STS_ID' => \EEM_Registration::status_id_approved |
389 | 389 | ), |
390 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
390 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
391 | 391 | ), |
392 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
393 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
392 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
393 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
394 | 394 | 'caps' => \EEM_Base::caps_read_admin |
395 | 395 | ), |
396 | 396 | $event_id |
397 | 397 | ); |
398 | - if( $event_id ){ |
|
399 | - $query_params[0]['EVT_ID'] = $event_id; |
|
398 | + if ($event_id) { |
|
399 | + $query_params[0]['EVT_ID'] = $event_id; |
|
400 | 400 | } else { |
401 | - $query_params[ 'force_join' ][] = 'Event'; |
|
401 | + $query_params['force_join'][] = 'Event'; |
|
402 | 402 | } |
403 | - return \EEM_Registration::instance()->count( $query_params ); |
|
403 | + return \EEM_Registration::instance()->count($query_params); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | * @param JobParameters $job_parameters |
412 | 412 | * @return boolean |
413 | 413 | */ |
414 | - public function cleanup_job( JobParameters $job_parameters ){ |
|
414 | + public function cleanup_job(JobParameters $job_parameters) { |
|
415 | 415 | $this->_file_helper->delete( |
416 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
416 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
417 | 417 | true, |
418 | 418 | 'd' |
419 | 419 | ); |
420 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
420 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 |