@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
3 | 3 | /** |
4 | 4 | * EE_Export class |
5 | 5 | * |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * @access private |
40 | 40 | * @param array $request_data |
41 | 41 | */ |
42 | - private function __construct( $request_data = array() ) { |
|
42 | + private function __construct($request_data = array()) { |
|
43 | 43 | $this->_req_data = $request_data; |
44 | - $this->today = date("Y-m-d",time()); |
|
45 | - require_once( EE_CLASSES . 'EE_CSV.class.php' ); |
|
46 | - $this->EE_CSV= EE_CSV::instance(); |
|
44 | + $this->today = date("Y-m-d", time()); |
|
45 | + require_once(EE_CLASSES.'EE_CSV.class.php'); |
|
46 | + $this->EE_CSV = EE_CSV::instance(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * @param array $request_data |
56 | 56 | * @return \EE_Export |
57 | 57 | */ |
58 | - public static function instance( $request_data = array() ) { |
|
58 | + public static function instance($request_data = array()) { |
|
59 | 59 | // check if class object is instantiated |
60 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Export )) { |
|
61 | - self::$_instance = new self( $request_data ); |
|
60 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Export)) { |
|
61 | + self::$_instance = new self($request_data); |
|
62 | 62 | } |
63 | 63 | return self::$_instance; |
64 | 64 | } |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | public function export() { |
73 | 73 | |
74 | 74 | // in case of bulk exports, the "actual" action will be in action2, but first check regular action for "export" keyword |
75 | - if ( isset( $this->_req_data['action'] ) && strpos( $this->_req_data['action'], 'export' ) === FALSE ) { |
|
75 | + if (isset($this->_req_data['action']) && strpos($this->_req_data['action'], 'export') === FALSE) { |
|
76 | 76 | // check if action2 has export action |
77 | - if ( isset( $this->_req_data['action2'] ) && strpos( $this->_req_data['action2'], 'export' ) !== FALSE ) { |
|
77 | + if (isset($this->_req_data['action2']) && strpos($this->_req_data['action2'], 'export') !== FALSE) { |
|
78 | 78 | // whoop! there it is! |
79 | 79 | $this->_req_data['action'] = $this->_req_data['action2']; |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - $this->_req_data['export'] = isset( $this->_req_data['export'] ) ? $this->_req_data['export'] : ''; |
|
83 | + $this->_req_data['export'] = isset($this->_req_data['export']) ? $this->_req_data['export'] : ''; |
|
84 | 84 | |
85 | 85 | switch ($this->_req_data['export']) { |
86 | 86 | case 'report': |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case 'registrations_report_for_event': |
97 | - $this->report_registrations_for_event( $this->_req_data['EVT_ID'] ); |
|
97 | + $this->report_registrations_for_event($this->_req_data['EVT_ID']); |
|
98 | 98 | break; |
99 | 99 | |
100 | 100 | case 'attendees': |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | break; |
107 | 107 | |
108 | 108 | default: |
109 | - EE_Error::add_error(__('An error occurred! The requested export report could not be found.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ) ; |
|
109 | + EE_Error::add_error(__('An error occurred! The requested export report could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | return FALSE; |
111 | 111 | break; |
112 | 112 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * Downloads a CSV file with all the columns, but no data. This should be used for importing |
125 | 125 | * @return null kills execution |
126 | 126 | */ |
127 | - function export_sample(){ |
|
127 | + function export_sample() { |
|
128 | 128 | $event = EEM_Event::instance()->get_one(); |
129 | 129 | $this->_req_data['EVT_ID'] = $event->ID(); |
130 | 130 | $this->export_all_event_data(); |
@@ -150,23 +150,23 @@ discard block |
||
150 | 150 | $state_country_query_params = array(); |
151 | 151 | $question_group_query_params = array(); |
152 | 152 | $question_query_params = array(); |
153 | - if ( isset( $this->_req_data['EVT_ID'] )) { |
|
153 | + if (isset($this->_req_data['EVT_ID'])) { |
|
154 | 154 | // do we have an array of IDs ? |
155 | 155 | |
156 | - if ( is_array( $this->_req_data['EVT_ID'] )) { |
|
157 | - $EVT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_ID'] ); |
|
158 | - $value_to_equal = array('IN',$EVT_IDs); |
|
156 | + if (is_array($this->_req_data['EVT_ID'])) { |
|
157 | + $EVT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_ID']); |
|
158 | + $value_to_equal = array('IN', $EVT_IDs); |
|
159 | 159 | $filename = 'events'; |
160 | 160 | } else { |
161 | 161 | // generate regular where = clause |
162 | - $EVT_ID = absint( $this->_req_data['EVT_ID'] ); |
|
162 | + $EVT_ID = absint($this->_req_data['EVT_ID']); |
|
163 | 163 | $value_to_equal = $EVT_ID; |
164 | 164 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($EVT_ID); |
165 | 165 | |
166 | - $filename = 'event-' . ( $event instanceof EE_Event ? $event->slug() : __( 'unknown', 'event_espresso' ) ); |
|
166 | + $filename = 'event-'.($event instanceof EE_Event ? $event->slug() : __('unknown', 'event_espresso')); |
|
167 | 167 | |
168 | 168 | } |
169 | - $event_query_params[0]['EVT_ID'] =$value_to_equal; |
|
169 | + $event_query_params[0]['EVT_ID'] = $value_to_equal; |
|
170 | 170 | $related_models_query_params[0]['Event.EVT_ID'] = $value_to_equal; |
171 | 171 | $related_through_reg_query_params[0]['Registration.EVT_ID'] = $value_to_equal; |
172 | 172 | $datetime_ticket_query_params[0]['Datetime.EVT_ID'] = $value_to_equal; |
@@ -210,42 +210,42 @@ discard block |
||
210 | 210 | |
211 | 211 | ); |
212 | 212 | |
213 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
213 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
214 | 214 | |
215 | - $filename = $this->generate_filename ( $filename ); |
|
215 | + $filename = $this->generate_filename($filename); |
|
216 | 216 | |
217 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) { |
|
218 | - EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
217 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) { |
|
218 | + EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - function report_attendees(){ |
|
222 | + function report_attendees() { |
|
223 | 223 | $attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( |
224 | 224 | array( |
225 | - 'force_join' => array( 'State', 'Country' ), |
|
225 | + 'force_join' => array('State', 'Country'), |
|
226 | 226 | 'caps' => EEM_Base::caps_read_admin |
227 | 227 | ) |
228 | 228 | ); |
229 | 229 | $csv_data = array(); |
230 | - foreach( $attendee_rows as $attendee_row ){ |
|
230 | + foreach ($attendee_rows as $attendee_row) { |
|
231 | 231 | $csv_row = array(); |
232 | - foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
233 | - if( $field_name == 'STA_ID' ){ |
|
234 | - $state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
235 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
236 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
237 | - $country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
238 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
239 | - }else{ |
|
240 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
232 | + foreach (EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
233 | + if ($field_name == 'STA_ID') { |
|
234 | + $state_name_field = EEM_State::instance()->field_settings_for('STA_name'); |
|
235 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
236 | + }elseif ($field_name == 'CNT_ISO') { |
|
237 | + $country_name_field = EEM_Country::instance()->field_settings_for('CNT_name'); |
|
238 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
239 | + } else { |
|
240 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | $csv_data[] = $csv_row; |
244 | 244 | } |
245 | 245 | |
246 | - $filename = $this->generate_filename ( 'contact-list-report' ); |
|
246 | + $filename = $this->generate_filename('contact-list-report'); |
|
247 | 247 | |
248 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
248 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
249 | 249 | $this->EE_CSV->write_data_array_to_csv($handle, $csv_data); |
250 | 250 | $this->EE_CSV->end_sending_csv($handle); |
251 | 251 | } |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | $countries_that_have_an_attendee = EEM_Country::instance()->get_all(array(0=>array('Attendee.ATT_ID'=>array('IS NOT NULL')))); |
263 | 263 | // $states_to_export_query_params |
264 | 264 | $models_to_export = array( |
265 | - 'Country'=>array(array('CNT_ISO'=>array('IN',array_keys($countries_that_have_an_attendee)))), |
|
266 | - 'State'=>array(array('STA_ID'=>array('IN',array_keys($states_that_have_an_attendee)))), |
|
265 | + 'Country'=>array(array('CNT_ISO'=>array('IN', array_keys($countries_that_have_an_attendee)))), |
|
266 | + 'State'=>array(array('STA_ID'=>array('IN', array_keys($states_that_have_an_attendee)))), |
|
267 | 267 | 'Attendee'=>array(), |
268 | 268 | ); |
269 | 269 | |
270 | 270 | |
271 | 271 | |
272 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
273 | - $filename = $this->generate_filename ( 'all-attendees' ); |
|
272 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
273 | + $filename = $this->generate_filename('all-attendees'); |
|
274 | 274 | |
275 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) { |
|
276 | - EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
275 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) { |
|
276 | + EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - protected function _prepare_value_from_db_for_display( $model, $field_name, $raw_db_value, $pretty_schema = true ) { |
|
289 | - $field_obj = $model->field_settings_for( $field_name ); |
|
290 | - $value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value ); |
|
291 | - if( $field_obj instanceof EE_Datetime_Field ) { |
|
292 | - $field_obj->set_date_format( EE_CSV::instance()->get_date_format_for_csv( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema ); |
|
293 | - $field_obj->set_time_format( EE_CSV::instance()->get_time_format_for_csv( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema ); |
|
288 | + protected function _prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) { |
|
289 | + $field_obj = $model->field_settings_for($field_name); |
|
290 | + $value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value); |
|
291 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
292 | + $field_obj->set_date_format(EE_CSV::instance()->get_date_format_for_csv($field_obj->get_date_format($pretty_schema)), $pretty_schema); |
|
293 | + $field_obj->set_time_format(EE_CSV::instance()->get_time_format_for_csv($field_obj->get_time_format($pretty_schema)), $pretty_schema); |
|
294 | 294 | } |
295 | - if( $pretty_schema === true){ |
|
296 | - return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj ); |
|
297 | - }elseif( is_string( $pretty_schema ) ) { |
|
298 | - return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema ); |
|
299 | - }else{ |
|
300 | - return $field_obj->prepare_for_get( $value_on_model_obj ); |
|
295 | + if ($pretty_schema === true) { |
|
296 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj); |
|
297 | + }elseif (is_string($pretty_schema)) { |
|
298 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema); |
|
299 | + } else { |
|
300 | + return $field_obj->prepare_for_get($value_on_model_obj); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * and the questions associated with the registrations |
307 | 307 | * @param int $event_id |
308 | 308 | */ |
309 | - function report_registrations_for_event( $event_id = NULL ){ |
|
309 | + function report_registrations_for_event($event_id = NULL) { |
|
310 | 310 | $reg_fields_to_include = array( |
311 | 311 | 'TXN_ID', |
312 | 312 | 'ATT_ID', |
@@ -338,126 +338,126 @@ discard block |
||
338 | 338 | array( |
339 | 339 | 'OR' => array( |
340 | 340 | //don't include registrations from failed or abandoned transactions... |
341 | - 'Transaction.STS_ID' => array( 'NOT IN', array( EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code ) ), |
|
341 | + 'Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)), |
|
342 | 342 | //unless the registration is approved, in which case include it regardless of transaction status |
343 | 343 | 'STS_ID' => EEM_Registration::status_id_approved |
344 | 344 | ), |
345 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
345 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
346 | 346 | ), |
347 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
348 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
347 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
348 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
349 | 349 | 'caps' => EEM_Base::caps_read_admin |
350 | 350 | ), |
351 | 351 | $event_id |
352 | 352 | ); |
353 | - if( $event_id ){ |
|
354 | - $query_params[0]['EVT_ID'] = $event_id; |
|
355 | - }else{ |
|
356 | - $query_params[ 'force_join' ][] = 'Event'; |
|
353 | + if ($event_id) { |
|
354 | + $query_params[0]['EVT_ID'] = $event_id; |
|
355 | + } else { |
|
356 | + $query_params['force_join'][] = 'Event'; |
|
357 | 357 | } |
358 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
358 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
359 | 359 | //get all questions which relate to someone in this group |
360 | 360 | $registration_ids = array(); |
361 | - foreach( $registration_rows as $reg_row ) { |
|
362 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
361 | + foreach ($registration_rows as $reg_row) { |
|
362 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
363 | 363 | } |
364 | 364 | // EEM_Question::instance()->show_next_x_db_queries(); |
365 | - $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN',$registration_ids)))); |
|
366 | - foreach($registration_rows as $reg_row){ |
|
367 | - if ( is_array( $reg_row ) ) { |
|
365 | + $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN', $registration_ids)))); |
|
366 | + foreach ($registration_rows as $reg_row) { |
|
367 | + if (is_array($reg_row)) { |
|
368 | 368 | $reg_csv_array = array(); |
369 | - if( ! $event_id ){ |
|
369 | + if ( ! $event_id) { |
|
370 | 370 | //get the event's name and Id |
371 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), $this->_prepare_value_from_db_for_display( EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
371 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
372 | 372 | } |
373 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
373 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
374 | 374 | /*@var $reg_row EE_Registration */ |
375 | - foreach($reg_fields_to_include as $field_name){ |
|
375 | + foreach ($reg_fields_to_include as $field_name) { |
|
376 | 376 | $field = $reg_model->field_settings_for($field_name); |
377 | - if($field_name == 'REG_final_price'){ |
|
378 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
379 | - }elseif( $field_name == 'REG_count' ){ |
|
380 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
381 | - }elseif( $field_name == 'REG_date' ) { |
|
382 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
383 | - }else{ |
|
384 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
377 | + if ($field_name == 'REG_final_price') { |
|
378 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
379 | + }elseif ($field_name == 'REG_count') { |
|
380 | + $value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
381 | + }elseif ($field_name == 'REG_date') { |
|
382 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
383 | + } else { |
|
384 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
385 | 385 | } |
386 | 386 | $reg_csv_array[$this->_get_column_name_for_field($field)] = $value; |
387 | - if($field_name == 'REG_final_price'){ |
|
387 | + if ($field_name == 'REG_final_price') { |
|
388 | 388 | //add a column named Currency after the final price |
389 | 389 | $reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code; |
390 | 390 | } |
391 | 391 | } |
392 | 392 | //get pretty status |
393 | - $stati = EEM_Status::instance()->localized_status( array( |
|
394 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
395 | - $reg_row[ 'TransactionTable.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
393 | + $stati = EEM_Status::instance()->localized_status(array( |
|
394 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
395 | + $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso') ), |
|
396 | 396 | FALSE, |
397 | - 'sentence' ); |
|
398 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
397 | + 'sentence'); |
|
398 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
399 | 399 | //get pretty trnasaction status |
400 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'TransactionTable.STS_ID' ] ]; |
|
401 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'TransactionTable.TXN_total' ], 'localized_float' ) : '0.00'; |
|
402 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'TransactionTable.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
400 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
401 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
402 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
403 | 403 | $payment_methods = array(); |
404 | 404 | $gateway_txn_ids_etc = array(); |
405 | 405 | $payment_times = array(); |
406 | - if( $is_primary_reg && $reg_row[ 'TransactionTable.TXN_ID' ] ){ |
|
406 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
407 | 407 | $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
408 | 408 | array( |
409 | 409 | array( |
410 | - 'TXN_ID' => $reg_row[ 'TransactionTable.TXN_ID' ], |
|
410 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
411 | 411 | 'STS_ID' => EEM_Payment::status_id_approved |
412 | 412 | ), |
413 | - 'force_join' => array( 'Payment_Method' ), |
|
413 | + 'force_join' => array('Payment_Method'), |
|
414 | 414 | |
415 | 415 | ), |
416 | 416 | ARRAY_A, |
417 | 417 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
418 | 418 | |
419 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
420 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
421 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
422 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
419 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
420 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
421 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
422 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | } |
426 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
427 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
428 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
426 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
427 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
428 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
429 | 429 | |
430 | 430 | //get whether or not the user has checked in |
431 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
431 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
432 | 432 | //get ticket of registration and its price |
433 | 433 | $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
434 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
435 | - $ticket_name = $this->_prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
434 | + if ($reg_row['Ticket.TKT_ID']) { |
|
435 | + $ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
436 | 436 | $datetimes_strings = array(); |
437 | - 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){ |
|
438 | - $datetimes_strings[] = $this->_prepare_value_from_db_for_display( EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
437 | + 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) { |
|
438 | + $datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | } else { |
442 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
443 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
442 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
443 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
444 | 444 | } |
445 | 445 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
446 | 446 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
447 | 447 | //get datetime(s) of registration |
448 | 448 | |
449 | 449 | //add attendee columns |
450 | - foreach($att_fields_to_include as $att_field_name){ |
|
450 | + foreach ($att_fields_to_include as $att_field_name) { |
|
451 | 451 | $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
452 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
453 | - if($att_field_name == 'STA_ID'){ |
|
454 | - $value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
455 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
456 | - $value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
457 | - }else{ |
|
458 | - $value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
452 | + if ($reg_row['Attendee_CPT.ID']) { |
|
453 | + if ($att_field_name == 'STA_ID') { |
|
454 | + $value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
455 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
456 | + $value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
457 | + } else { |
|
458 | + $value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
459 | 459 | } |
460 | - }else{ |
|
460 | + } else { |
|
461 | 461 | $value = ''; |
462 | 462 | } |
463 | 463 | |
@@ -465,56 +465,56 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | //make sure each registration has the same questions in the same order |
468 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
469 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
470 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
468 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
469 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
470 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | //now fill out the questions THEY answered |
474 | - foreach( EEM_Answer::instance()->get_all_wpdb_results( array( array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), 'force_join' => array( 'Question' ) ) ) as $answer_row){ |
|
474 | + foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) { |
|
475 | 475 | /* @var $answer EE_Answer */ |
476 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
477 | - $question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] ); |
|
478 | - }else{ |
|
479 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
476 | + if ($answer_row['Question.QST_ID']) { |
|
477 | + $question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
478 | + } else { |
|
479 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
480 | 480 | } |
481 | - if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) { |
|
482 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] ); |
|
481 | + if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) { |
|
482 | + $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
483 | 483 | } else { |
484 | - $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] ); |
|
484 | + $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']); |
|
485 | 485 | } |
486 | 486 | } |
487 | - $registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row ); |
|
487 | + $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | 491 | //if we couldn't export anything, we want to at least show the column headers |
492 | - if(empty($registrations_csv_ready_array)){ |
|
492 | + if (empty($registrations_csv_ready_array)) { |
|
493 | 493 | $reg_csv_array = array(); |
494 | 494 | $model_and_fields_to_include = array( |
495 | 495 | 'Registration' => $reg_fields_to_include, |
496 | 496 | 'Attendee' => $att_fields_to_include |
497 | 497 | ); |
498 | - foreach($model_and_fields_to_include as $model_name => $field_list){ |
|
498 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
499 | 499 | $model = EE_Registry::instance()->load_model($model_name); |
500 | - foreach($field_list as $field_name){ |
|
500 | + foreach ($field_list as $field_name) { |
|
501 | 501 | $field = $model->field_settings_for($field_name); |
502 | - $reg_csv_array[$this->_get_column_name_for_field($field)] = null;//$registration->get($field->get_name()); |
|
502 | + $reg_csv_array[$this->_get_column_name_for_field($field)] = null; //$registration->get($field->get_name()); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | $registrations_csv_ready_array [] = $reg_csv_array; |
506 | 506 | } |
507 | - if( $event_id ){ |
|
508 | - $event_slug = EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
509 | - if( ! $event_slug ) { |
|
510 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
507 | + if ($event_id) { |
|
508 | + $event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
509 | + if ( ! $event_slug) { |
|
510 | + $event_slug = __('unknown', 'event_espresso'); |
|
511 | 511 | } |
512 | - }else{ |
|
513 | - $event_slug = __( 'all', 'event_espresso' ); |
|
512 | + } else { |
|
513 | + $event_slug = __('all', 'event_espresso'); |
|
514 | 514 | } |
515 | - $filename = sprintf( "registrations-for-%s", $event_slug ); |
|
515 | + $filename = sprintf("registrations-for-%s", $event_slug); |
|
516 | 516 | |
517 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
517 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
518 | 518 | $this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array); |
519 | 519 | $this->EE_CSV->end_sending_csv($handle); |
520 | 520 | } |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | * @param EE_Model_Field_Base $field |
525 | 525 | * @return string |
526 | 526 | */ |
527 | - protected function _get_column_name_for_field(EE_Model_Field_Base $field){ |
|
527 | + protected function _get_column_name_for_field(EE_Model_Field_Base $field) { |
|
528 | 528 | return $field->get_nicename()."[".$field->get_name()."]"; |
529 | 529 | } |
530 | 530 | |
@@ -537,17 +537,17 @@ discard block |
||
537 | 537 | function export_categories() { |
538 | 538 | // are any Event IDs set? |
539 | 539 | $query_params = array(); |
540 | - if ( isset( $this->_req_data['EVT_CAT_ID'] )) { |
|
540 | + if (isset($this->_req_data['EVT_CAT_ID'])) { |
|
541 | 541 | // do we have an array of IDs ? |
542 | - if ( is_array( $this->_req_data['EVT_CAT_ID'] )) { |
|
542 | + if (is_array($this->_req_data['EVT_CAT_ID'])) { |
|
543 | 543 | // generate an "IN (CSV)" where clause |
544 | - $EVT_CAT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_CAT_ID'] ); |
|
544 | + $EVT_CAT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_CAT_ID']); |
|
545 | 545 | $filename = 'event-categories'; |
546 | - $query_params[0]['term_taxonomy_id'] = array('IN',$EVT_CAT_IDs); |
|
546 | + $query_params[0]['term_taxonomy_id'] = array('IN', $EVT_CAT_IDs); |
|
547 | 547 | } else { |
548 | 548 | // generate regular where = clause |
549 | - $EVT_CAT_ID = absint( $this->_req_data['EVT_CAT_ID'] ); |
|
550 | - $filename = 'event-category#' . $EVT_CAT_ID; |
|
549 | + $EVT_CAT_ID = absint($this->_req_data['EVT_CAT_ID']); |
|
550 | + $filename = 'event-category#'.$EVT_CAT_ID; |
|
551 | 551 | $query_params[0]['term_taxonomy_id'] = $EVT_CAT_ID; |
552 | 552 | } |
553 | 553 | } else { |
@@ -559,11 +559,11 @@ discard block |
||
559 | 559 | 'Term_Taxonomy' => $query_params |
560 | 560 | ); |
561 | 561 | |
562 | - $table_data = $this->_get_export_data_for_models( $tables_to_export ); |
|
563 | - $filename = $this->generate_filename ( $filename ); |
|
562 | + $table_data = $this->_get_export_data_for_models($tables_to_export); |
|
563 | + $filename = $this->generate_filename($filename); |
|
564 | 564 | |
565 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $table_data )) { |
|
566 | - EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
565 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $table_data)) { |
|
566 | + EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
@@ -574,13 +574,13 @@ discard block |
||
574 | 574 | * @param string - export_name |
575 | 575 | * @return string on success, FALSE on fail |
576 | 576 | */ |
577 | - private function generate_filename ( $export_name = '' ) { |
|
578 | - if ( $export_name != '' ) { |
|
579 | - $filename = get_bloginfo('name') . '-' . $export_name; |
|
580 | - $filename = sanitize_key( $filename ) . '-' . $this->today; |
|
577 | + private function generate_filename($export_name = '') { |
|
578 | + if ($export_name != '') { |
|
579 | + $filename = get_bloginfo('name').'-'.$export_name; |
|
580 | + $filename = sanitize_key($filename).'-'.$this->today; |
|
581 | 581 | return $filename; |
582 | - } else { |
|
583 | - EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
582 | + } else { |
|
583 | + EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
584 | 584 | } |
585 | 585 | return false; |
586 | 586 | } |
@@ -593,12 +593,12 @@ discard block |
||
593 | 593 | * @param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all |
594 | 594 | * @return array on success, FALSE on fail |
595 | 595 | */ |
596 | - private function _get_export_data_for_models( $models_to_export = array() ) { |
|
596 | + private function _get_export_data_for_models($models_to_export = array()) { |
|
597 | 597 | $table_data = FALSE; |
598 | - if ( is_array( $models_to_export ) ) { |
|
599 | - foreach ( $models_to_export as $model_name => $query_params ) { |
|
598 | + if (is_array($models_to_export)) { |
|
599 | + foreach ($models_to_export as $model_name => $query_params) { |
|
600 | 600 | //check for a numerically-indexed array. in that case, $model_name is the value!! |
601 | - if(is_int($model_name)){ |
|
601 | + if (is_int($model_name)) { |
|
602 | 602 | $model_name = $query_params; |
603 | 603 | $query_params = array(); |
604 | 604 | } |
@@ -606,17 +606,17 @@ discard block |
||
606 | 606 | $model_objects = $model->get_all($query_params); |
607 | 607 | |
608 | 608 | $table_data[$model_name] = array(); |
609 | - foreach($model_objects as $model_object){ |
|
609 | + foreach ($model_objects as $model_object) { |
|
610 | 610 | $model_data_array = array(); |
611 | 611 | $fields = $model->field_settings(); |
612 | - foreach($fields as $field){ |
|
612 | + foreach ($fields as $field) { |
|
613 | 613 | $column_name = $field->get_nicename()."[".$field->get_name()."]"; |
614 | - if($field instanceof EE_Datetime_Field){ |
|
614 | + if ($field instanceof EE_Datetime_Field) { |
|
615 | 615 | // $field->set_date_format('Y-m-d'); |
616 | 616 | // $field->set_time_format('H:i:s'); |
617 | - $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s'); |
|
617 | + $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(), 'Y-m-d', 'H:i:s'); |
|
618 | 618 | } |
619 | - else{ |
|
619 | + else { |
|
620 | 620 | $model_data_array[$column_name] = $model_object->get($field->get_name()); |
621 | 621 | } |
622 | 622 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public static function instance() { |
80 | 80 | // check if class object is instantiated |
81 | - if ( ! self::$_instance instanceof EE_CPT_Strategy ) { |
|
81 | + if ( ! self::$_instance instanceof EE_CPT_Strategy) { |
|
82 | 82 | self::$_instance = new self(); |
83 | 83 | } |
84 | 84 | return self::$_instance; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // d( $this->_CPT_endpoints ); |
102 | 102 | // d( $this->_CPT_taxonomies ); |
103 | 103 | |
104 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 5 ); |
|
104 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 5); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | private function _set_CPT_endpoints() { |
116 | 116 | $_CPT_endpoints = array(); |
117 | - if ( is_array( $this->_CPTs )) { |
|
118 | - foreach ( $this->_CPTs as $CPT_type => $CPT ) { |
|
119 | - $_CPT_endpoints [ $CPT['plural_slug'] ] = $CPT_type; |
|
117 | + if (is_array($this->_CPTs)) { |
|
118 | + foreach ($this->_CPTs as $CPT_type => $CPT) { |
|
119 | + $_CPT_endpoints [$CPT['plural_slug']] = $CPT_type; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $_CPT_endpoints; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param WP_Query $WP_Query |
132 | 132 | * @return void |
133 | 133 | */ |
134 | - private function _set_EE_tags_on_WP_Query( WP_Query $WP_Query) { |
|
134 | + private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query) { |
|
135 | 135 | $WP_Query->is_espresso_event_single = FALSE; |
136 | 136 | $WP_Query->is_espresso_event_archive = FALSE; |
137 | 137 | $WP_Query->is_espresso_event_taxonomy = FALSE; |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | */ |
159 | 159 | private function _set_CPT_taxonomies() { |
160 | 160 | // check if taxonomies have already been set |
161 | - if ( empty( $this->_CPT_taxonomies )) { |
|
161 | + if (empty($this->_CPT_taxonomies)) { |
|
162 | 162 | // and that this CPT has taxonomies registered for it |
163 | - if ( isset( $this->CPT['args'] ) && isset( $this->CPT['args']['taxonomies'] )) { |
|
163 | + if (isset($this->CPT['args']) && isset($this->CPT['args']['taxonomies'])) { |
|
164 | 164 | // if so then grab them, but we want the taxonomy name as the key |
165 | - $taxonomies = array_flip( $this->CPT['args']['taxonomies'] ); |
|
165 | + $taxonomies = array_flip($this->CPT['args']['taxonomies']); |
|
166 | 166 | // then grab the list of ALL taxonomies |
167 | 167 | $all_taxonomies = EE_Register_CPTs::get_taxonomies(); |
168 | - foreach ( $taxonomies as $taxonomy => $details ) { |
|
168 | + foreach ($taxonomies as $taxonomy => $details) { |
|
169 | 169 | // add details to our taxonomies if they exist |
170 | - $taxonomies[ $taxonomy ] = isset( $all_taxonomies[ $taxonomy ] ) ? $all_taxonomies[ $taxonomy ] : NULL; |
|
170 | + $taxonomies[$taxonomy] = isset($all_taxonomies[$taxonomy]) ? $all_taxonomies[$taxonomy] : NULL; |
|
171 | 171 | } |
172 | 172 | $this->_CPT_taxonomies = $taxonomies; |
173 | 173 | } |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | * @return void |
193 | 193 | */ |
194 | 194 | private function _set_CPT_terms() { |
195 | - if ( empty( $this->_CPT_terms )) { |
|
195 | + if (empty($this->_CPT_terms)) { |
|
196 | 196 | $terms = EEM_Term::instance()->get_all_CPT_post_tags(); |
197 | - foreach ( $terms as $term ) { |
|
198 | - if ( $term instanceof EE_Term ) { |
|
199 | - $this->_CPT_terms[ $term->slug() ] = $term; |
|
197 | + foreach ($terms as $term) { |
|
198 | + if ($term instanceof EE_Term) { |
|
199 | + $this->_CPT_terms[$term->slug()] = $term; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -211,24 +211,24 @@ discard block |
||
211 | 211 | * @param $WP_Query |
212 | 212 | * @return void |
213 | 213 | */ |
214 | - private function _set_post_type_for_terms( WP_Query $WP_Query ) { |
|
214 | + private function _set_post_type_for_terms(WP_Query $WP_Query) { |
|
215 | 215 | // is a tag set ? |
216 | - if ( isset( $WP_Query->query['tag'] )) { |
|
216 | + if (isset($WP_Query->query['tag'])) { |
|
217 | 217 | // set post_tags |
218 | 218 | $this->_set_CPT_terms(); |
219 | 219 | // is this tag archive term in the list of terms used by our CPTs ? |
220 | - $term = isset ( $this->_CPT_terms[ $WP_Query->query['tag'] ] ) ? $this->_CPT_terms[ $WP_Query->query['tag'] ] : NULL; |
|
220 | + $term = isset ($this->_CPT_terms[$WP_Query->query['tag']]) ? $this->_CPT_terms[$WP_Query->query['tag']] : NULL; |
|
221 | 221 | // verify the term |
222 | - if ( $term instanceof EE_Term ) { |
|
223 | - $term->post_type = array_merge( array( 'post', 'page' ), (array)$term->post_type ); |
|
224 | - $term->post_type = apply_filters( 'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term ); |
|
222 | + if ($term instanceof EE_Term) { |
|
223 | + $term->post_type = array_merge(array('post', 'page'), (array) $term->post_type); |
|
224 | + $term->post_type = apply_filters('FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term); |
|
225 | 225 | // if a post type is already set |
226 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
226 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
227 | 227 | // add to existing array |
228 | - $term->post_type = array_merge ( (array)$WP_Query->query_vars['post_type'], $term->post_type ); |
|
228 | + $term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type); |
|
229 | 229 | } |
230 | 230 | // just set post_type to our CPT |
231 | - $WP_Query->set( 'post_type', $term->post_type ); |
|
231 | + $WP_Query->set('post_type', $term->post_type); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | * in order for is_archive() and is_single() methods to work properly. |
244 | 244 | * @return void |
245 | 245 | */ |
246 | - public function _possibly_set_ee_request_var(){ |
|
246 | + public function _possibly_set_ee_request_var() { |
|
247 | 247 | // check if ee action var has been set |
248 | - if ( ! EE_Registry::instance()->REQ->is_set( 'ee' )) { |
|
248 | + if ( ! EE_Registry::instance()->REQ->is_set('ee')) { |
|
249 | 249 | // check that route exists for CPT archive slug |
250 | - if ( is_archive() && EE_Config::get_route( $this->CPT['plural_slug'] )) { |
|
250 | + if (is_archive() && EE_Config::get_route($this->CPT['plural_slug'])) { |
|
251 | 251 | // ie: set "ee" to "events" |
252 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['plural_slug'] ); |
|
252 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['plural_slug']); |
|
253 | 253 | // or does it match a single page CPT like /event/ |
254 | - } else if ( is_single() && EE_Config::get_route( $this->CPT['singular_slug'] )) { |
|
254 | + } else if (is_single() && EE_Config::get_route($this->CPT['singular_slug'])) { |
|
255 | 255 | // ie: set "ee" to "event" |
256 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
256 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | * @param WP_Query $WP_Query |
268 | 268 | * @return void |
269 | 269 | */ |
270 | - public function _set_paging( $WP_Query ) { |
|
271 | - if ( $WP_Query->is_main_query() && apply_filters( 'FHEE__EE_CPT_Strategy___set_paging', TRUE )) { |
|
272 | - $page = ( get_query_var('page') ) ? get_query_var('page') : NULL; |
|
273 | - $paged = ( get_query_var('paged') ) ? get_query_var('paged') : $page; |
|
274 | - $WP_Query->set( 'paged', $paged ); |
|
270 | + public function _set_paging($WP_Query) { |
|
271 | + if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', TRUE)) { |
|
272 | + $page = (get_query_var('page')) ? get_query_var('page') : NULL; |
|
273 | + $paged = (get_query_var('paged')) ? get_query_var('paged') : $page; |
|
274 | + $WP_Query->set('paged', $paged); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -288,35 +288,35 @@ discard block |
||
288 | 288 | * @param WP_Query $WP_Query |
289 | 289 | * @return void |
290 | 290 | */ |
291 | - public function pre_get_posts( $WP_Query ) { |
|
291 | + public function pre_get_posts($WP_Query) { |
|
292 | 292 | // check that post-type is set |
293 | - if ( ! $WP_Query instanceof WP_Query ) { |
|
293 | + if ( ! $WP_Query instanceof WP_Query) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // add our conditionals |
298 | - $this->_set_EE_tags_on_WP_Query( $WP_Query ); |
|
298 | + $this->_set_EE_tags_on_WP_Query($WP_Query); |
|
299 | 299 | // check for terms |
300 | - $this->_set_post_type_for_terms( $WP_Query ); |
|
300 | + $this->_set_post_type_for_terms($WP_Query); |
|
301 | 301 | // make sure paging is always set |
302 | - $this->_set_paging( $WP_Query ); |
|
302 | + $this->_set_paging($WP_Query); |
|
303 | 303 | |
304 | 304 | // is a taxonomy set ? |
305 | - if ( $WP_Query->is_tax ) { |
|
305 | + if ($WP_Query->is_tax) { |
|
306 | 306 | // loop thru our taxonomies |
307 | - foreach ( $this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details ) { |
|
307 | + foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) { |
|
308 | 308 | // check if one of our taxonomies is set as a query var |
309 | - if ( isset( $WP_Query->query[ $CPT_taxonomy ] )) { |
|
309 | + if (isset($WP_Query->query[$CPT_taxonomy])) { |
|
310 | 310 | // but which CPT does that correspond to??? hmmm... guess we gotta go looping |
311 | - foreach ( $this->_CPTs as $post_type => $CPT ) { |
|
311 | + foreach ($this->_CPTs as $post_type => $CPT) { |
|
312 | 312 | // verify our CPT has args, is public and has taxonomies set |
313 | - if ( isset( $CPT['args'] ) && $CPT['args']['public'] && ! empty( $CPT['args']['taxonomies'] )) { |
|
313 | + if (isset($CPT['args']) && $CPT['args']['public'] && ! empty($CPT['args']['taxonomies'])) { |
|
314 | 314 | // does the captured taxonomy belong to this CPT ? |
315 | - if ( in_array( $CPT_taxonomy, $CPT['args']['taxonomies'] )) { |
|
315 | + if (in_array($CPT_taxonomy, $CPT['args']['taxonomies'])) { |
|
316 | 316 | // if so, then add this CPT post_type to the current query's array of post_types' |
317 | - $WP_Query->query_vars['post_type'] = isset( $WP_Query->query_vars['post_type'] ) ? (array)$WP_Query->query_vars['post_type'] : array(); |
|
317 | + $WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type']) ? (array) $WP_Query->query_vars['post_type'] : array(); |
|
318 | 318 | $WP_Query->query_vars['post_type'][] = $post_type; |
319 | - switch( $post_type ) { |
|
319 | + switch ($post_type) { |
|
320 | 320 | case 'espresso_events' : |
321 | 321 | $WP_Query->is_espresso_event_taxonomy = TRUE; |
322 | 322 | break; |
@@ -337,27 +337,27 @@ discard block |
||
337 | 337 | // d( $CPT_taxonomy ); |
338 | 338 | // d( $WP_Query ); |
339 | 339 | |
340 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
340 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
341 | 341 | // loop thru post_types as array |
342 | - foreach ( (array)$WP_Query->query_vars['post_type'] as $post_type ) { |
|
342 | + foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) { |
|
343 | 343 | |
344 | 344 | // is current query for an EE CPT ? |
345 | - if ( isset( $this->_CPTs[ $post_type ] )) { |
|
345 | + if (isset($this->_CPTs[$post_type])) { |
|
346 | 346 | // is EE on or off ? |
347 | - if ( EE_Maintenance_Mode::instance()->level() ) { |
|
347 | + if (EE_Maintenance_Mode::instance()->level()) { |
|
348 | 348 | // reroute CPT template view to maintenance_mode.template.php |
349 | - if( ! has_filter( 'template_include',array( 'EE_Maintenance_Mode', 'template_include' ))){ |
|
350 | - add_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ), 99999 ); |
|
349 | + if ( ! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) { |
|
350 | + add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999); |
|
351 | 351 | } |
352 | - if( has_filter( 'the_content',array( EE_Maintenance_Mode::instance(), 'the_content' ) ) ) { |
|
353 | - add_filter( 'the_content', array( $this, 'inject_EE_shortcode_placeholder' ), 1 ); |
|
352 | + if (has_filter('the_content', array(EE_Maintenance_Mode::instance(), 'the_content'))) { |
|
353 | + add_filter('the_content', array($this, 'inject_EE_shortcode_placeholder'), 1); |
|
354 | 354 | } |
355 | 355 | return; |
356 | 356 | } |
357 | 357 | // load EE_Request_Handler (this was added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/9037 |
358 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
358 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
359 | 359 | // grab details for the CPT the current query is for |
360 | - $this->CPT = $this->_CPTs[ $post_type ]; |
|
360 | + $this->CPT = $this->_CPTs[$post_type]; |
|
361 | 361 | // set post type |
362 | 362 | $this->CPT['post_type'] = $post_type; |
363 | 363 | // set taxonomies |
@@ -365,27 +365,27 @@ discard block |
||
365 | 365 | // the post or category or term that is triggering EE |
366 | 366 | $this->CPT['espresso_page'] = EE_Registry::instance()->REQ->is_espresso_page(); |
367 | 367 | // requested post name |
368 | - $this->CPT['post_name'] = EE_Registry::instance()->REQ->get( 'post_name' ); |
|
368 | + $this->CPT['post_name'] = EE_Registry::instance()->REQ->get('post_name'); |
|
369 | 369 | //d( $this->CPT ); |
370 | 370 | // add support for viewing 'private', 'draft', or 'pending' posts |
371 | - if ( is_user_logged_in() && isset( $WP_Query->query_vars['p'] ) && $WP_Query->query_vars['p'] != 0 && current_user_can( 'edit_post', $WP_Query->query_vars['p'] )) { |
|
371 | + if (is_user_logged_in() && isset($WP_Query->query_vars['p']) && $WP_Query->query_vars['p'] != 0 && current_user_can('edit_post', $WP_Query->query_vars['p'])) { |
|
372 | 372 | // we can just inject directly into the WP_Query object |
373 | - $WP_Query->query['post_status'] = array( 'publish', 'private', 'draft', 'pending' ); |
|
373 | + $WP_Query->query['post_status'] = array('publish', 'private', 'draft', 'pending'); |
|
374 | 374 | // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s) |
375 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
375 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
376 | 376 | } |
377 | 377 | $this->_possibly_set_ee_request_var(); |
378 | 378 | // convert post_type to model name |
379 | - $model_name = str_replace( 'EE_', '', $this->CPT['class_name'] ); |
|
379 | + $model_name = str_replace('EE_', '', $this->CPT['class_name']); |
|
380 | 380 | // get CPT table data via CPT Model |
381 | - $this->CPT_model = EE_Registry::instance()->load_model( $model_name ); |
|
381 | + $this->CPT_model = EE_Registry::instance()->load_model($model_name); |
|
382 | 382 | $this->CPT['tables'] = $this->CPT_model->get_tables(); |
383 | 383 | // is there a Meta Table for this CPT? |
384 | - $this->CPT['meta_table'] = isset( $this->CPT['tables'][ $model_name . '_Meta' ] ) ? $this->CPT['tables'][ $model_name . '_Meta' ] : FALSE; |
|
384 | + $this->CPT['meta_table'] = isset($this->CPT['tables'][$model_name.'_Meta']) ? $this->CPT['tables'][$model_name.'_Meta'] : FALSE; |
|
385 | 385 | // creates classname like: CPT_Event_Strategy |
386 | - $CPT_Strategy_class_name = 'CPT_' . $model_name . '_Strategy'; |
|
386 | + $CPT_Strategy_class_name = 'CPT_'.$model_name.'_Strategy'; |
|
387 | 387 | // load and instantiate |
388 | - $CPT_Strategy = EE_Registry::instance()->load_core ( $CPT_Strategy_class_name, array( 'WP_Query' => $WP_Query, 'CPT' => $this->CPT )); |
|
388 | + $CPT_Strategy = EE_Registry::instance()->load_core($CPT_Strategy_class_name, array('WP_Query' => $WP_Query, 'CPT' => $this->CPT)); |
|
389 | 389 | |
390 | 390 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
391 | 391 | // here's the list of available filters in the WP_Query object |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | // 'post_limits' |
398 | 398 | // 'posts_fields' |
399 | 399 | // 'posts_join' |
400 | - add_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
401 | - add_filter( 'posts_join', array( $this, 'posts_join' )); |
|
402 | - add_filter( 'get_' . $this->CPT['post_type'] . '_metadata', array( $CPT_Strategy, 'get_EE_post_type_metadata' ), 1, 4 ); |
|
403 | - add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 1 ); |
|
404 | - add_filter( 'get_edit_post_link', array( $this, 'get_edit_post_link' ), 10, 2 ); |
|
400 | + add_filter('posts_fields', array($this, 'posts_fields')); |
|
401 | + add_filter('posts_join', array($this, 'posts_join')); |
|
402 | + add_filter('get_'.$this->CPT['post_type'].'_metadata', array($CPT_Strategy, 'get_EE_post_type_metadata'), 1, 4); |
|
403 | + add_filter('the_posts', array($this, 'the_posts'), 1, 1); |
|
404 | + add_filter('get_edit_post_link', array($this, 'get_edit_post_link'), 10, 2); |
|
405 | 405 | |
406 | - $this->_do_template_filters( $WP_Query ); |
|
406 | + $this->_do_template_filters($WP_Query); |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | } |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | * @param $SQL |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - public function posts_fields( $SQL ) { |
|
421 | + public function posts_fields($SQL) { |
|
422 | 422 | // does this CPT have a meta table ? |
423 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
423 | + if ( ! empty($this->CPT['meta_table'])) { |
|
424 | 424 | // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement |
425 | - $SQL .= ', ' . $this->CPT['meta_table']->get_table_name() . '.* ' ; |
|
425 | + $SQL .= ', '.$this->CPT['meta_table']->get_table_name().'.* '; |
|
426 | 426 | } |
427 | - remove_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
427 | + remove_filter('posts_fields', array($this, 'posts_fields')); |
|
428 | 428 | return $SQL; |
429 | 429 | } |
430 | 430 | |
@@ -452,14 +452,14 @@ discard block |
||
452 | 452 | * @param $SQL |
453 | 453 | * @return string |
454 | 454 | */ |
455 | - public function posts_join( $SQL ) { |
|
455 | + public function posts_join($SQL) { |
|
456 | 456 | // does this CPT have a meta table ? |
457 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
457 | + if ( ! empty($this->CPT['meta_table'])) { |
|
458 | 458 | global $wpdb; |
459 | 459 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
460 | - $SQL .= ' LEFT JOIN ' . $this->CPT['meta_table']->get_table_name() . ' ON ( ' . $this->CPT['meta_table']->get_table_name() . '.' . $this->CPT['meta_table']->get_fk_on_table() . ' = ' . $wpdb->posts . '.ID ) '; |
|
460 | + $SQL .= ' LEFT JOIN '.$this->CPT['meta_table']->get_table_name().' ON ( '.$this->CPT['meta_table']->get_table_name().'.'.$this->CPT['meta_table']->get_fk_on_table().' = '.$wpdb->posts.'.ID ) '; |
|
461 | 461 | } |
462 | - remove_filter( 'posts_join', array( $this, 'posts_join' )); |
|
462 | + remove_filter('posts_join', array($this, 'posts_join')); |
|
463 | 463 | return $SQL; |
464 | 464 | } |
465 | 465 | |
@@ -472,18 +472,18 @@ discard block |
||
472 | 472 | * @param \WP_Post[] $posts |
473 | 473 | * @return \WP_Post[] |
474 | 474 | */ |
475 | - public function the_posts( $posts ) { |
|
475 | + public function the_posts($posts) { |
|
476 | 476 | // d( $posts ); |
477 | 477 | $CPT_class = $this->CPT['class_name']; |
478 | 478 | // loop thru posts |
479 | - if ( is_array( $posts )) { |
|
480 | - foreach( $posts as $key => $post ) { |
|
481 | - if ( isset( $this->_CPTs[ $post->post_type ] )) { |
|
482 | - $post->{$CPT_class} = $this->CPT_model->instantiate_class_from_post_object( $post ); |
|
479 | + if (is_array($posts)) { |
|
480 | + foreach ($posts as $key => $post) { |
|
481 | + if (isset($this->_CPTs[$post->post_type])) { |
|
482 | + $post->{$CPT_class} = $this->CPT_model->instantiate_class_from_post_object($post); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | - remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 ); |
|
486 | + remove_filter('the_posts', array($this, 'the_posts'), 1); |
|
487 | 487 | return $posts; |
488 | 488 | } |
489 | 489 | |
@@ -494,17 +494,17 @@ discard block |
||
494 | 494 | * @param $ID |
495 | 495 | * @return string |
496 | 496 | */ |
497 | - function get_edit_post_link( $url, $ID ) { |
|
497 | + function get_edit_post_link($url, $ID) { |
|
498 | 498 | //need to make sure we only edit links if our cpt |
499 | 499 | global $post; |
500 | - if ( ! isset( $this->_CPTs[ $post->post_type ] )) { |
|
500 | + if ( ! isset($this->_CPTs[$post->post_type])) { |
|
501 | 501 | return $url; |
502 | 502 | } |
503 | 503 | //k made it here so all is good. |
504 | 504 | $scheme = is_ssl() ? 'https' : 'http'; |
505 | - $url = get_admin_url( EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme ); |
|
505 | + $url = get_admin_url(EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme); |
|
506 | 506 | // http://example.com/wp-admin/admin.php?page=espresso_events&action=edit&post=205&edit_nonce=0d403530d6 |
507 | - return wp_nonce_url( add_query_arg( array( 'page' => $post->post_type, 'post' =>$ID, 'action' =>'edit' ), $url ), 'edit', 'edit_nonce' ); |
|
507 | + return wp_nonce_url(add_query_arg(array('page' => $post->post_type, 'post' =>$ID, 'action' =>'edit'), $url), 'edit', 'edit_nonce'); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -518,11 +518,11 @@ discard block |
||
518 | 518 | * @param WP_Query $WP_Query |
519 | 519 | * @return void |
520 | 520 | */ |
521 | - protected function _do_template_filters( WP_Query $WP_Query ) { |
|
521 | + protected function _do_template_filters(WP_Query $WP_Query) { |
|
522 | 522 | // if it's the main query and requested cpt supports page_templates, |
523 | - if ( $WP_Query->is_main_query() && ! empty( $this->CPT['args']['page_templates'] ) ) { |
|
523 | + if ($WP_Query->is_main_query() && ! empty($this->CPT['args']['page_templates'])) { |
|
524 | 524 | // then let's hook into the appropriate query_template hook |
525 | - add_filter( 'single_template', array( $this, 'single_cpt_template' ) ); |
|
525 | + add_filter('single_template', array($this, 'single_cpt_template')); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
@@ -536,17 +536,17 @@ discard block |
||
536 | 536 | * @param string $current_template Existing default template path derived for this page call. |
537 | 537 | * @return string the path to the full template file. |
538 | 538 | */ |
539 | - public function single_cpt_template( $current_template ) { |
|
539 | + public function single_cpt_template($current_template) { |
|
540 | 540 | $object = get_queried_object(); |
541 | 541 | //does this called object HAVE a page template set that is something other than the default. |
542 | - $template = get_post_meta( $object->ID, '_wp_page_template', true ); |
|
542 | + $template = get_post_meta($object->ID, '_wp_page_template', true); |
|
543 | 543 | |
544 | 544 | //exit early if default or not set or invalid path (accounts for theme changes) |
545 | - if ( $template == 'default' || empty( $template ) || ! is_readable( get_stylesheet_directory() . '/' . $template ) ) { |
|
545 | + if ($template == 'default' || empty($template) || ! is_readable(get_stylesheet_directory().'/'.$template)) { |
|
546 | 546 | return $current_template; |
547 | 547 | } |
548 | 548 | //made it here so we SHOULD be able to just locate the template and then return it. |
549 | - $template = locate_template( array($template) ); |
|
549 | + $template = locate_template(array($template)); |
|
550 | 550 | |
551 | 551 | return $template; |
552 | 552 | } |
@@ -594,9 +594,9 @@ discard block |
||
594 | 594 | * @param array $arguments |
595 | 595 | * @return \EE_CPT_Default_Strategy |
596 | 596 | */ |
597 | - public function __construct( $arguments = array() ) { |
|
598 | - $this->CPT = isset( $arguments['CPT'] ) ? $arguments['CPT'] : NULL; |
|
599 | - $WP_Query = isset( $arguments['WP_Query'] ) ? $arguments['WP_Query'] : NULL; |
|
597 | + public function __construct($arguments = array()) { |
|
598 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : NULL; |
|
599 | + $WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : NULL; |
|
600 | 600 | //EEH_Debug_Tools::printr( $this->CPT, '$this->CPT <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
601 | 601 | // add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), 999 ); |
602 | 602 | // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | * @param \WP_Query $WP_Query |
612 | 612 | * @return \WP_Query |
613 | 613 | */ |
614 | - public function pre_get_posts( WP_Query $WP_Query ) { |
|
614 | + public function pre_get_posts(WP_Query $WP_Query) { |
|
615 | 615 | //EEH_Debug_Tools::printr( $WP_Query, '$WP_Query <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
616 | - if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive() ) { |
|
616 | + if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
617 | 617 | return $WP_Query; |
618 | 618 | } |
619 | 619 | // $WP_Query->set( 'post_type', array( $this->CPT['post_type'] )); |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * @param \WP_Query $WP_Query |
632 | 632 | * @return \WP_Post[] |
633 | 633 | */ |
634 | - public function the_posts( $posts, WP_Query $WP_Query ) { |
|
634 | + public function the_posts($posts, WP_Query $WP_Query) { |
|
635 | 635 | return $posts; |
636 | 636 | } |
637 | 637 | |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | * @param string $single |
648 | 648 | * @return mixed |
649 | 649 | */ |
650 | - public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) { |
|
650 | + public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) { |
|
651 | 651 | return $meta_value; |
652 | 652 | } |
653 | 653 |
@@ -42,21 +42,21 @@ discard block |
||
42 | 42 | * @param EE_Checkout $checkout |
43 | 43 | * @return \EE_SPCO_Reg_Step_Attendee_Information |
44 | 44 | */ |
45 | - public function __construct( EE_Checkout $checkout ) { |
|
45 | + public function __construct(EE_Checkout $checkout) { |
|
46 | 46 | $this->_slug = 'attendee_information'; |
47 | 47 | $this->_name = __('Attendee Information', 'event_espresso'); |
48 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
48 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php'; |
|
49 | 49 | $this->checkout = $checkout; |
50 | 50 | $this->_reset_success_message(); |
51 | 51 | $this->set_instructions( |
52 | - __( 'Please answer the following registration questions before proceeding.', 'event_espresso' ) |
|
52 | + __('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | 58 | public function translate_js_strings() { |
59 | - EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' ); |
|
59 | + EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso'); |
|
60 | 60 | EE_Registry::$i18n_js_strings['required_multi_field'] = __( |
61 | 61 | ' is a required question. Please enter a value for at least one of the options.', |
62 | 62 | 'event_espresso' |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | // calculate taxes |
117 | 117 | $Line_Item_Display->display_line_item( |
118 | 118 | $this->checkout->cart->get_grand_total(), |
119 | - array( 'set_tax_rate' => true ) |
|
119 | + array('set_tax_rate' => true) |
|
120 | 120 | ); |
121 | 121 | /** @var $subsections EE_Form_Section_Proper[] */ |
122 | 122 | $subsections = array( |
@@ -128,51 +128,51 @@ discard block |
||
128 | 128 | 'ticket_count' => array() |
129 | 129 | ); |
130 | 130 | // grab the saved registrations from the transaction |
131 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
132 | - if ( $registrations ) { |
|
133 | - foreach ( $registrations as $registration ) { |
|
131 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
132 | + if ($registrations) { |
|
133 | + foreach ($registrations as $registration) { |
|
134 | 134 | // can this registration be processed during this visit ? |
135 | 135 | if ( |
136 | 136 | $registration instanceof EE_Registration |
137 | - && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
|
137 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
138 | 138 | ) { |
139 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration ); |
|
140 | - if ( ! $this->checkout->admin_request ) { |
|
141 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
142 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
143 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
139 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
140 | + if ( ! $this->checkout->admin_request) { |
|
141 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
142 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
143 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
144 | 144 | ) |
145 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
145 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
146 | 146 | : 1; |
147 | 147 | $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
148 | 148 | $this->checkout->cart->get_grand_total(), |
149 | 149 | 'Ticket', |
150 | - array( $registration->ticket()->ID() ) |
|
150 | + array($registration->ticket()->ID()) |
|
151 | 151 | ); |
152 | - $ticket_line_item = is_array( $ticket_line_item ) |
|
153 | - ? reset( $ticket_line_item ) |
|
152 | + $ticket_line_item = is_array($ticket_line_item) |
|
153 | + ? reset($ticket_line_item) |
|
154 | 154 | : $ticket_line_item; |
155 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item( |
|
155 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item( |
|
156 | 156 | $ticket_line_item |
157 | 157 | ); |
158 | 158 | } |
159 | - if ( $registration->is_primary_registrant() ) { |
|
159 | + if ($registration->is_primary_registrant()) { |
|
160 | 160 | $primary_registrant = $registration->reg_url_link(); |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | // print_copy_info ? |
165 | - if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) { |
|
165 | + if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
166 | 166 | // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info |
167 | 167 | $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
168 | 168 | ? $this->_copy_attendee_info_form() |
169 | 169 | : $this->_auto_copy_attendee_info(); |
170 | 170 | // generate hidden input |
171 | 171 | if ( |
172 | - isset( $subsections[ $primary_registrant ] ) |
|
173 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
172 | + isset($subsections[$primary_registrant]) |
|
173 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
174 | 174 | ) { |
175 | - $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
|
175 | + $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -184,8 +184,7 @@ discard block |
||
184 | 184 | 'html_id' => $this->reg_form_name(), |
185 | 185 | 'subsections' => $subsections, |
186 | 186 | 'layout_strategy' => $this->checkout->admin_request ? |
187 | - new EE_Div_Per_Section_Layout() : |
|
188 | - new EE_Template_Layout( |
|
187 | + new EE_Div_Per_Section_Layout() : new EE_Template_Layout( |
|
189 | 188 | array( |
190 | 189 | 'layout_template_file' => $this->_template, // layout_template |
191 | 190 | 'template_args' => $template_args |
@@ -203,11 +202,11 @@ discard block |
||
203 | 202 | * @return EE_Form_Section_Proper |
204 | 203 | * @throws \EE_Error |
205 | 204 | */ |
206 | - private function _registrations_reg_form( EE_Registration $registration ) { |
|
205 | + private function _registrations_reg_form(EE_Registration $registration) { |
|
207 | 206 | static $attendee_nmbr = 1; |
208 | 207 | // array of params to pass to parent constructor |
209 | 208 | $form_args = array( |
210 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
209 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
211 | 210 | 'html_class' => 'ee-reg-form-attendee-dv', |
212 | 211 | 'html_style' => $this->checkout->admin_request |
213 | 212 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -216,24 +215,24 @@ discard block |
||
216 | 215 | 'layout_strategy' => new EE_Fieldset_Section_Layout( |
217 | 216 | array( |
218 | 217 | 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
219 | - 'legend_text' => sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr ) |
|
218 | + 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
220 | 219 | ) |
221 | 220 | ) |
222 | 221 | ); |
223 | 222 | // verify that registration has valid event |
224 | - if ( $registration->event() instanceof EE_Event ) { |
|
223 | + if ($registration->event() instanceof EE_Event) { |
|
225 | 224 | $query_params = array( |
226 | 225 | array( |
227 | 226 | 'Event.EVT_ID' => $registration->event()->ID(), |
228 | 227 | 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
229 | 228 | ), |
230 | - 'order_by'=>array( 'QSG_order'=>'ASC' ) |
|
229 | + 'order_by'=>array('QSG_order'=>'ASC') |
|
231 | 230 | ); |
232 | - $question_groups = $registration->event()->question_groups( $query_params ); |
|
233 | - if ( $question_groups ) { |
|
234 | - foreach ( $question_groups as $question_group ) { |
|
235 | - if ( $question_group instanceof EE_Question_Group ) { |
|
236 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
231 | + $question_groups = $registration->event()->question_groups($query_params); |
|
232 | + if ($question_groups) { |
|
233 | + foreach ($question_groups as $question_group) { |
|
234 | + if ($question_group instanceof EE_Question_Group) { |
|
235 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
237 | 236 | $registration, |
238 | 237 | $question_group |
239 | 238 | ); |
@@ -246,10 +245,10 @@ discard block |
||
246 | 245 | // if we have question groups for additional attendees, then display the copy options |
247 | 246 | $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info; |
248 | 247 | } else { |
249 | - $form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link( |
|
250 | - ) ] = new EE_Form_Section_HTML( |
|
248 | + $form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link( |
|
249 | + )] = new EE_Form_Section_HTML( |
|
251 | 250 | EEH_Template::locate_template( |
252 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php', |
|
251 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php', |
|
253 | 252 | apply_filters( |
254 | 253 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args', |
255 | 254 | array() |
@@ -265,12 +264,12 @@ discard block |
||
265 | 264 | ); |
266 | 265 | } |
267 | 266 | } |
268 | - if ( $registration->is_primary_registrant() ) { |
|
267 | + if ($registration->is_primary_registrant()) { |
|
269 | 268 | // generate hidden input |
270 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration ); |
|
269 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
271 | 270 | } |
272 | 271 | $attendee_nmbr++; |
273 | - return new EE_Form_Section_Proper( $form_args ); |
|
272 | + return new EE_Form_Section_Proper($form_args); |
|
274 | 273 | } |
275 | 274 | |
276 | 275 | |
@@ -291,7 +290,7 @@ discard block |
||
291 | 290 | // generate hidden input |
292 | 291 | return new EE_Hidden_Input( |
293 | 292 | array( |
294 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
293 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
295 | 294 | 'default' => $additional_attendee_reg_info |
296 | 295 | ) |
297 | 296 | ); |
@@ -305,26 +304,26 @@ discard block |
||
305 | 304 | * @return EE_Form_Section_Proper |
306 | 305 | * @throws \EE_Error |
307 | 306 | */ |
308 | - private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){ |
|
307 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) { |
|
309 | 308 | // array of params to pass to parent constructor |
310 | 309 | $form_args = array( |
311 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier(), |
|
310 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier(), |
|
312 | 311 | 'html_class' => $this->checkout->admin_request |
313 | 312 | ? 'form-table ee-reg-form-qstn-grp-dv' |
314 | 313 | : 'ee-reg-form-qstn-grp-dv', |
315 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl', |
|
314 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl', |
|
316 | 315 | 'subsections' => array( |
317 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group ) |
|
316 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group) |
|
318 | 317 | ), |
319 | 318 | 'layout_strategy' => $this->checkout->admin_request |
320 | 319 | ? new EE_Admin_Two_Column_Layout() |
321 | 320 | : new EE_Div_Per_Section_Layout() |
322 | 321 | ); |
323 | 322 | // where params |
324 | - $query_params = array( 'QST_deleted' => 0 ); |
|
323 | + $query_params = array('QST_deleted' => 0); |
|
325 | 324 | // don't load admin only questions on the frontend |
326 | - if ( ! $this->checkout->admin_request ) { |
|
327 | - $query_params['QST_admin_only'] = array( '!=', true ); |
|
325 | + if ( ! $this->checkout->admin_request) { |
|
326 | + $query_params['QST_admin_only'] = array('!=', true); |
|
328 | 327 | } |
329 | 328 | $questions = $question_group->get_many_related( |
330 | 329 | 'Question', |
@@ -346,10 +345,10 @@ discard block |
||
346 | 345 | ) |
347 | 346 | ); |
348 | 347 | // loop thru questions |
349 | - foreach ( $questions as $question ) { |
|
350 | - if( $question instanceof EE_Question ){ |
|
348 | + foreach ($questions as $question) { |
|
349 | + if ($question instanceof EE_Question) { |
|
351 | 350 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
352 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question ); |
|
351 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
353 | 352 | } |
354 | 353 | } |
355 | 354 | $form_args['subsections'] = apply_filters( |
@@ -370,7 +369,7 @@ discard block |
||
370 | 369 | ) |
371 | 370 | ); |
372 | 371 | // d( $form_args ); |
373 | - $question_group_reg_form = new EE_Form_Section_Proper( $form_args ); |
|
372 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
374 | 373 | return apply_filters( |
375 | 374 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
376 | 375 | $question_group_reg_form, |
@@ -387,11 +386,11 @@ discard block |
||
387 | 386 | * @param EE_Question_Group $question_group |
388 | 387 | * @return EE_Form_Section_HTML |
389 | 388 | */ |
390 | - private function _question_group_header( EE_Question_Group $question_group ){ |
|
389 | + private function _question_group_header(EE_Question_Group $question_group) { |
|
391 | 390 | $html = ''; |
392 | 391 | // group_name |
393 | - if ( $question_group->show_group_name() && $question_group->name() !== '' ) { |
|
394 | - if ( $this->checkout->admin_request ) { |
|
392 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
393 | + if ($this->checkout->admin_request) { |
|
395 | 394 | $html .= EEH_HTML::br(); |
396 | 395 | $html .= EEH_HTML::h3( |
397 | 396 | $question_group->name(), |
@@ -405,7 +404,7 @@ discard block |
||
405 | 404 | } |
406 | 405 | } |
407 | 406 | // group_desc |
408 | - if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) { |
|
407 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
409 | 408 | $html .= EEH_HTML::p( |
410 | 409 | $question_group->desc(), |
411 | 410 | '', |
@@ -415,7 +414,7 @@ discard block |
||
415 | 414 | ); |
416 | 415 | |
417 | 416 | } |
418 | - return new EE_Form_Section_HTML( $html ); |
|
417 | + return new EE_Form_Section_HTML($html); |
|
419 | 418 | } |
420 | 419 | |
421 | 420 | |
@@ -425,7 +424,7 @@ discard block |
||
425 | 424 | * @return EE_Form_Section_Proper |
426 | 425 | * @throws \EE_Error |
427 | 426 | */ |
428 | - private function _copy_attendee_info_form(){ |
|
427 | + private function _copy_attendee_info_form() { |
|
429 | 428 | // array of params to pass to parent constructor |
430 | 429 | return new EE_Form_Section_Proper( |
431 | 430 | array( |
@@ -454,7 +453,7 @@ discard block |
||
454 | 453 | private function _auto_copy_attendee_info() { |
455 | 454 | return new EE_Form_Section_HTML( |
456 | 455 | EEH_Template::locate_template( |
457 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
456 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php', |
|
458 | 457 | apply_filters( |
459 | 458 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
460 | 459 | array() |
@@ -478,32 +477,32 @@ discard block |
||
478 | 477 | $copy_attendee_info_inputs = array(); |
479 | 478 | $prev_ticket = NULL; |
480 | 479 | // grab the saved registrations from the transaction |
481 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
482 | - foreach ( $registrations as $registration ) { |
|
480 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
481 | + foreach ($registrations as $registration) { |
|
483 | 482 | // for all attendees other than the primary attendee |
484 | - if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) { |
|
483 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
485 | 484 | // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
486 | - if ( $registration->ticket()->ID() !== $prev_ticket ) { |
|
485 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
487 | 486 | $item_name = $registration->ticket()->name(); |
488 | 487 | $item_name .= $registration->ticket()->description() !== '' |
489 | - ? ' - ' . $registration->ticket()->description() |
|
488 | + ? ' - '.$registration->ticket()->description() |
|
490 | 489 | : ''; |
491 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML( |
|
492 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
490 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML( |
|
491 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
493 | 492 | ); |
494 | 493 | $prev_ticket = $registration->ticket()->ID(); |
495 | 494 | } |
496 | 495 | |
497 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new |
|
496 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new |
|
498 | 497 | EE_Checkbox_Multi_Input( |
499 | 498 | array( |
500 | 499 | $registration->ID() => sprintf( |
501 | - __( 'Attendee #%s', 'event_espresso' ), |
|
500 | + __('Attendee #%s', 'event_espresso'), |
|
502 | 501 | $registration->count() |
503 | 502 | ) |
504 | 503 | ), |
505 | 504 | array( |
506 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
505 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
507 | 506 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
508 | 507 | 'display_html_label_text' => false |
509 | 508 | ) |
@@ -523,7 +522,7 @@ discard block |
||
523 | 522 | * @return EE_Form_Input_Base |
524 | 523 | * @throws \EE_Error |
525 | 524 | */ |
526 | - private function _additional_primary_registrant_inputs( EE_Registration $registration ){ |
|
525 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) { |
|
527 | 526 | // generate hidden input |
528 | 527 | return new EE_Hidden_Input( |
529 | 528 | array( |
@@ -542,7 +541,7 @@ discard block |
||
542 | 541 | * @return EE_Form_Input_Base |
543 | 542 | * @throws \EE_Error |
544 | 543 | */ |
545 | - public function reg_form_question( EE_Registration $registration, EE_Question $question ){ |
|
544 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) { |
|
546 | 545 | |
547 | 546 | // if this question was for an attendee detail, then check for that answer |
548 | 547 | $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
@@ -551,32 +550,32 @@ discard block |
||
551 | 550 | ); |
552 | 551 | $answer = $answer_value === null |
553 | 552 | ? EEM_Answer::instance()->get_one( |
554 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
553 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
555 | 554 | ) |
556 | 555 | : null; |
557 | 556 | // if NOT returning to edit an existing registration |
558 | 557 | // OR if this question is for an attendee property |
559 | 558 | // OR we still don't have an EE_Answer object |
560 | - if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) { |
|
559 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
561 | 560 | // create an EE_Answer object for storing everything in |
562 | - $answer = EE_Answer::new_instance ( array( |
|
561 | + $answer = EE_Answer::new_instance(array( |
|
563 | 562 | 'QST_ID'=> $question->ID(), |
564 | 563 | 'REG_ID'=> $registration->ID() |
565 | 564 | )); |
566 | 565 | } |
567 | 566 | // verify instance |
568 | - if( $answer instanceof EE_Answer ){ |
|
569 | - if ( ! empty( $answer_value )) { |
|
570 | - $answer->set( 'ANS_value', $answer_value ); |
|
567 | + if ($answer instanceof EE_Answer) { |
|
568 | + if ( ! empty($answer_value)) { |
|
569 | + $answer->set('ANS_value', $answer_value); |
|
571 | 570 | } |
572 | - $answer->cache( 'Question', $question ); |
|
571 | + $answer->cache('Question', $question); |
|
573 | 572 | //remember system ID had a bug where sometimes it could be null |
574 | - $answer_cache_id =$question->is_system_question() |
|
575 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
576 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
577 | - $registration->cache( 'Answer', $answer, $answer_cache_id ); |
|
573 | + $answer_cache_id = $question->is_system_question() |
|
574 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
575 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
576 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
578 | 577 | } |
579 | - return $this->_generate_question_input( $registration, $question, $answer ); |
|
578 | + return $this->_generate_question_input($registration, $question, $answer); |
|
580 | 579 | |
581 | 580 | } |
582 | 581 | |
@@ -589,46 +588,46 @@ discard block |
||
589 | 588 | * @return EE_Form_Input_Base |
590 | 589 | * @throws \EE_Error |
591 | 590 | */ |
592 | - private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){ |
|
591 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) { |
|
593 | 592 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
594 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
593 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
595 | 594 | add_filter( |
596 | 595 | 'FHEE__EE_Question__generate_form_input__country_options', |
597 | - array( $this, 'use_cached_countries_for_form_input' ), |
|
596 | + array($this, 'use_cached_countries_for_form_input'), |
|
598 | 597 | 10, |
599 | 598 | 4 |
600 | 599 | ); |
601 | 600 | add_filter( |
602 | 601 | 'FHEE__EE_Question__generate_form_input__state_options', |
603 | - array( $this, 'use_cached_states_for_form_input' ), |
|
602 | + array($this, 'use_cached_states_for_form_input'), |
|
604 | 603 | 10, |
605 | 604 | 4 |
606 | 605 | ); |
607 | 606 | $input_constructor_args = array( |
608 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
609 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
610 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
611 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
607 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
608 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
609 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
610 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
612 | 611 | 'html_label_class' => 'ee-reg-qstn', |
613 | 612 | ); |
614 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
615 | - if ( $answer instanceof EE_Answer && $answer->ID() ) { |
|
616 | - $input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']'; |
|
617 | - $input_constructor_args[ 'html_id' ] .= '-' . $answer->ID(); |
|
618 | - $input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID(); |
|
613 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
614 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
615 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
616 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
617 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
619 | 618 | } |
620 | - $form_input = $question->generate_form_input( |
|
619 | + $form_input = $question->generate_form_input( |
|
621 | 620 | $registration, |
622 | 621 | $answer, |
623 | 622 | $input_constructor_args |
624 | 623 | ); |
625 | 624 | remove_filter( |
626 | 625 | 'FHEE__EE_Question__generate_form_input__country_options', |
627 | - array( $this, 'use_cached_countries_for_form_input' ) |
|
626 | + array($this, 'use_cached_countries_for_form_input') |
|
628 | 627 | ); |
629 | 628 | remove_filter( |
630 | 629 | 'FHEE__EE_Question__generate_form_input__state_options', |
631 | - array( $this, 'use_cached_states_for_form_input' ) |
|
630 | + array($this, 'use_cached_states_for_form_input') |
|
632 | 631 | ); |
633 | 632 | return $form_input; |
634 | 633 | } |
@@ -642,23 +641,23 @@ discard block |
||
642 | 641 | * @return array 2d keys are country IDs, values are their names |
643 | 642 | * @throws \EE_Error |
644 | 643 | */ |
645 | - public function use_cached_countries_for_form_input( $countries_list, $question, $registration, $answer ) { |
|
646 | - $country_options = array( '' => '' ); |
|
644 | + public function use_cached_countries_for_form_input($countries_list, $question, $registration, $answer) { |
|
645 | + $country_options = array('' => ''); |
|
647 | 646 | // get possibly cached list of countries |
648 | 647 | $countries = $this->checkout->action === 'process_reg_step' |
649 | 648 | ? EEM_Country::instance()->get_all_countries() |
650 | 649 | : EEM_Country::instance()->get_all_active_countries(); |
651 | - if ( ! empty( $countries )) { |
|
652 | - foreach( $countries as $country ){ |
|
653 | - if ( $country instanceof EE_Country ) { |
|
654 | - $country_options[ $country->ID() ] = $country->name(); |
|
650 | + if ( ! empty($countries)) { |
|
651 | + foreach ($countries as $country) { |
|
652 | + if ($country instanceof EE_Country) { |
|
653 | + $country_options[$country->ID()] = $country->name(); |
|
655 | 654 | } |
656 | 655 | } |
657 | 656 | } |
658 | - if( $question instanceof EE_Question |
|
659 | - && $registration instanceof EE_Registration ) { |
|
657 | + if ($question instanceof EE_Question |
|
658 | + && $registration instanceof EE_Registration) { |
|
660 | 659 | $answer = EEM_Answer::instance()->get_one( |
661 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
660 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
662 | 661 | ); |
663 | 662 | } else { |
664 | 663 | $answer = EE_Answer::new_instance(); |
@@ -685,15 +684,15 @@ discard block |
||
685 | 684 | * @return array 2d keys are state IDs, values are their names |
686 | 685 | * @throws \EE_Error |
687 | 686 | */ |
688 | - public function use_cached_states_for_form_input( $states_list, $question, $registration, $answer ) { |
|
689 | - $state_options = array( '' => array( '' => '')); |
|
687 | + public function use_cached_states_for_form_input($states_list, $question, $registration, $answer) { |
|
688 | + $state_options = array('' => array('' => '')); |
|
690 | 689 | $states = $this->checkout->action === 'process_reg_step' |
691 | 690 | ? EEM_State::instance()->get_all_states() |
692 | 691 | : EEM_State::instance()->get_all_active_states(); |
693 | - if ( ! empty( $states )) { |
|
694 | - foreach( $states as $state ){ |
|
695 | - if ( $state instanceof EE_State ) { |
|
696 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
692 | + if ( ! empty($states)) { |
|
693 | + foreach ($states as $state) { |
|
694 | + if ($state instanceof EE_State) { |
|
695 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
697 | 696 | } |
698 | 697 | } |
699 | 698 | } |
@@ -721,24 +720,24 @@ discard block |
||
721 | 720 | * @throws \EE_Error |
722 | 721 | */ |
723 | 722 | public function process_reg_step() { |
724 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
723 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
725 | 724 | // grab validated data from form |
726 | 725 | $valid_data = $this->checkout->current_step->valid_data(); |
727 | 726 | // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
728 | 727 | // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
729 | 728 | // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
730 | - if ( empty( $valid_data )) { |
|
729 | + if (empty($valid_data)) { |
|
731 | 730 | EE_Error::add_error( |
732 | - __( 'No valid question responses were received.', 'event_espresso' ), |
|
731 | + __('No valid question responses were received.', 'event_espresso'), |
|
733 | 732 | __FILE__, |
734 | 733 | __FUNCTION__, |
735 | 734 | __LINE__ |
736 | 735 | ); |
737 | 736 | return false; |
738 | 737 | } |
739 | - if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) { |
|
738 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
740 | 739 | EE_Error::add_error( |
741 | - __( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ), |
|
740 | + __('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), |
|
742 | 741 | __FILE__, |
743 | 742 | __FUNCTION__, |
744 | 743 | __LINE__ |
@@ -746,11 +745,11 @@ discard block |
||
746 | 745 | return false; |
747 | 746 | } |
748 | 747 | // get cached registrations |
749 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
748 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
750 | 749 | // verify we got the goods |
751 | - if ( empty( $registrations )) { |
|
750 | + if (empty($registrations)) { |
|
752 | 751 | EE_Error::add_error( |
753 | - __( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ), |
|
752 | + __('Your form data could not be applied to any valid registrations.', 'event_espresso'), |
|
754 | 753 | __FILE__, |
755 | 754 | __FUNCTION__, |
756 | 755 | __LINE__ |
@@ -758,15 +757,15 @@ discard block |
||
758 | 757 | return false; |
759 | 758 | } |
760 | 759 | // extract attendee info from form data and save to model objects |
761 | - $registrations_processed = $this->_process_registrations( $registrations, $valid_data ); |
|
760 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
762 | 761 | // if first pass thru SPCO, |
763 | 762 | // then let's check processed registrations against the total number of tickets in the cart |
764 | - if ( $registrations_processed === false ) { |
|
763 | + if ($registrations_processed === false) { |
|
765 | 764 | // but return immediately if the previous step exited early due to errors |
766 | 765 | return false; |
767 | - } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) { |
|
766 | + } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
768 | 767 | // generate a correctly translated string for all possible singular/plural combinations |
769 | - if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) { |
|
768 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
770 | 769 | $error_msg = sprintf( |
771 | 770 | __( |
772 | 771 | 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
@@ -775,7 +774,7 @@ discard block |
||
775 | 774 | $this->checkout->total_ticket_count, |
776 | 775 | $registrations_processed |
777 | 776 | ); |
778 | - } else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) { |
|
777 | + } else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
779 | 778 | $error_msg = sprintf( |
780 | 779 | __( |
781 | 780 | 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
@@ -794,17 +793,17 @@ discard block |
||
794 | 793 | $registrations_processed |
795 | 794 | ); |
796 | 795 | } |
797 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
796 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
798 | 797 | return false; |
799 | 798 | } |
800 | 799 | // mark this reg step as completed |
801 | 800 | $this->set_completed(); |
802 | 801 | $this->_set_success_message( |
803 | - __( 'The Attendee Information Step has been successfully completed.', 'event_espresso' ) |
|
802 | + __('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
804 | 803 | ); |
805 | 804 | //do action in case a plugin wants to do something with the data submitted in step 1. |
806 | 805 | //passes EE_Single_Page_Checkout, and it's posted data |
807 | - do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data ); |
|
806 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
808 | 807 | return true; |
809 | 808 | } |
810 | 809 | |
@@ -818,9 +817,9 @@ discard block |
||
818 | 817 | * @return boolean | int |
819 | 818 | * @throws \EE_Error |
820 | 819 | */ |
821 | - private function _process_registrations( $registrations = array(), $valid_data = array() ) { |
|
820 | + private function _process_registrations($registrations = array(), $valid_data = array()) { |
|
822 | 821 | // load resources and set some defaults |
823 | - EE_Registry::instance()->load_model( 'Attendee' ); |
|
822 | + EE_Registry::instance()->load_model('Attendee'); |
|
824 | 823 | // holder for primary registrant attendee object |
825 | 824 | $this->checkout->primary_attendee_obj = NULL; |
826 | 825 | // array for tracking reg form data for the primary registrant |
@@ -837,9 +836,9 @@ discard block |
||
837 | 836 | // attendee counter |
838 | 837 | $att_nmbr = 0; |
839 | 838 | // grab the saved registrations from the transaction |
840 | - foreach ( $registrations as $registration ) { |
|
839 | + foreach ($registrations as $registration) { |
|
841 | 840 | // verify EE_Registration object |
842 | - if ( ! $registration instanceof EE_Registration ) { |
|
841 | + if ( ! $registration instanceof EE_Registration) { |
|
843 | 842 | EE_Error::add_error( |
844 | 843 | __( |
845 | 844 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -854,12 +853,12 @@ discard block |
||
854 | 853 | /** @var string $reg_url_link */ |
855 | 854 | $reg_url_link = $registration->reg_url_link(); |
856 | 855 | // reg_url_link exists ? |
857 | - if ( ! empty( $reg_url_link ) ) { |
|
856 | + if ( ! empty($reg_url_link)) { |
|
858 | 857 | // should this registration be processed during this visit ? |
859 | - if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) { |
|
858 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
860 | 859 | // if NOT revisiting, then let's save the registration now, |
861 | 860 | // so that we have a REG_ID to use when generating other objects |
862 | - if ( ! $this->checkout->revisit ) { |
|
861 | + if ( ! $this->checkout->revisit) { |
|
863 | 862 | $registration->save(); |
864 | 863 | } |
865 | 864 | /** |
@@ -869,7 +868,7 @@ discard block |
||
869 | 868 | * @var bool if true is returned by the plugin then the |
870 | 869 | * registration processing is halted. |
871 | 870 | */ |
872 | - if ( apply_filters( |
|
871 | + if (apply_filters( |
|
873 | 872 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
874 | 873 | false, |
875 | 874 | $att_nmbr, |
@@ -877,38 +876,38 @@ discard block |
||
877 | 876 | $registrations, |
878 | 877 | $valid_data, |
879 | 878 | $this |
880 | - ) ) { |
|
879 | + )) { |
|
881 | 880 | return false; |
882 | 881 | } |
883 | 882 | |
884 | 883 | // Houston, we have a registration! |
885 | 884 | $att_nmbr++; |
886 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
885 | + $this->_attendee_data[$reg_url_link] = array(); |
|
887 | 886 | // grab any existing related answer objects |
888 | 887 | $this->_registration_answers = $registration->answers(); |
889 | 888 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
890 | - if ( isset( $valid_data[ $reg_url_link ] ) ) { |
|
889 | + if (isset($valid_data[$reg_url_link])) { |
|
891 | 890 | // do we need to copy basic info from primary attendee ? |
892 | - $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
|
893 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
891 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
892 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0 |
|
894 | 893 | ? true |
895 | 894 | : false; |
896 | 895 | // filter form input data for this registration |
897 | - $valid_data[ $reg_url_link ] = (array)apply_filters( |
|
896 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
898 | 897 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
899 | - $valid_data[ $reg_url_link ] |
|
898 | + $valid_data[$reg_url_link] |
|
900 | 899 | ); |
901 | 900 | // EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ ); |
902 | - if ( isset( $valid_data['primary_attendee'] )) { |
|
903 | - $primary_registrant['line_item_id'] = ! empty( $valid_data['primary_attendee'] ) |
|
901 | + if (isset($valid_data['primary_attendee'])) { |
|
902 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
904 | 903 | ? $valid_data['primary_attendee'] |
905 | 904 | : false; |
906 | - unset( $valid_data['primary_attendee'] ); |
|
905 | + unset($valid_data['primary_attendee']); |
|
907 | 906 | } |
908 | 907 | // now loop through our array of valid post data && process attendee reg forms |
909 | - foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) { |
|
910 | - if ( ! in_array( $form_section, $non_input_form_sections )) { |
|
911 | - foreach ( $form_inputs as $form_input => $input_value ) { |
|
908 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
909 | + if ( ! in_array($form_section, $non_input_form_sections)) { |
|
910 | + foreach ($form_inputs as $form_input => $input_value) { |
|
912 | 911 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
913 | 912 | // check for critical inputs |
914 | 913 | if ( |
@@ -922,16 +921,16 @@ discard block |
||
922 | 921 | // store a bit of data about the primary attendee |
923 | 922 | if ( |
924 | 923 | $att_nmbr === 1 |
925 | - && ! empty( $input_value ) |
|
924 | + && ! empty($input_value) |
|
926 | 925 | && $reg_url_link === $primary_registrant['line_item_id'] |
927 | 926 | ) { |
928 | - $primary_registrant[ $form_input ] = $input_value; |
|
927 | + $primary_registrant[$form_input] = $input_value; |
|
929 | 928 | } else if ( |
930 | 929 | $copy_primary |
931 | 930 | && $input_value === null |
932 | - && isset( $primary_registrant[ $form_input ] ) |
|
931 | + && isset($primary_registrant[$form_input]) |
|
933 | 932 | ) { |
934 | - $input_value = $primary_registrant[ $form_input ]; |
|
933 | + $input_value = $primary_registrant[$form_input]; |
|
935 | 934 | } |
936 | 935 | // now attempt to save the input data |
937 | 936 | if ( |
@@ -973,57 +972,57 @@ discard block |
||
973 | 972 | // have we met before? |
974 | 973 | $attendee = $this->_find_existing_attendee( |
975 | 974 | $registration, |
976 | - $this->_attendee_data[ $reg_url_link ] |
|
975 | + $this->_attendee_data[$reg_url_link] |
|
977 | 976 | ); |
978 | 977 | // did we find an already existing record for this attendee ? |
979 | - if ( $attendee instanceof EE_Attendee ) { |
|
978 | + if ($attendee instanceof EE_Attendee) { |
|
980 | 979 | $attendee = $this->_update_existing_attendee_data( |
981 | 980 | $attendee, |
982 | - $this->_attendee_data[ $reg_url_link ] |
|
981 | + $this->_attendee_data[$reg_url_link] |
|
983 | 982 | ); |
984 | 983 | } else { |
985 | 984 | // ensure critical details are set for additional attendees |
986 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
985 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
987 | 986 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
988 | - $this->_attendee_data[ $reg_url_link ] |
|
987 | + $this->_attendee_data[$reg_url_link] |
|
989 | 988 | ) |
990 | - : $this->_attendee_data[ $reg_url_link ]; |
|
989 | + : $this->_attendee_data[$reg_url_link]; |
|
991 | 990 | $attendee = $this->_create_new_attendee( |
992 | 991 | $registration, |
993 | - $this->_attendee_data[ $reg_url_link ] |
|
992 | + $this->_attendee_data[$reg_url_link] |
|
994 | 993 | ); |
995 | 994 | } |
996 | 995 | // who's #1 ? |
997 | - if ( $att_nmbr === 1 ) { |
|
996 | + if ($att_nmbr === 1) { |
|
998 | 997 | $this->checkout->primary_attendee_obj = $attendee; |
999 | 998 | } |
1000 | 999 | } |
1001 | 1000 | // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
1002 | 1001 | // add relation to registration, set attendee ID, and cache attendee |
1003 | - $this->_associate_attendee_with_registration( $registration, $attendee ); |
|
1002 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
1004 | 1003 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
1005 | - if ( ! $registration->attendee() instanceof EE_Attendee ) { |
|
1006 | - EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1004 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
1005 | + EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__); |
|
1007 | 1006 | return false; |
1008 | 1007 | } |
1009 | 1008 | /** @type EE_Registration_Processor $registration_processor */ |
1010 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1009 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1011 | 1010 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1012 | - $registration_processor->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
1011 | + $registration_processor->toggle_incomplete_registration_status_to_default($registration, false); |
|
1013 | 1012 | /** @type EE_Transaction_Processor $transaction_processor */ |
1014 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1013 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1015 | 1014 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1016 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1015 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1017 | 1016 | // if we've gotten this far, then let's save what we have |
1018 | 1017 | $registration->save(); |
1019 | 1018 | // add relation between TXN and registration |
1020 | - $this->_associate_registration_with_transaction( $registration ); |
|
1019 | + $this->_associate_registration_with_transaction($registration); |
|
1021 | 1020 | } // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) { |
1022 | 1021 | |
1023 | - } else { |
|
1024 | - EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1022 | + } else { |
|
1023 | + EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1025 | 1024 | // remove malformed data |
1026 | - unset( $valid_data[ $reg_url_link ] ); |
|
1025 | + unset($valid_data[$reg_url_link]); |
|
1027 | 1026 | return false; |
1028 | 1027 | } |
1029 | 1028 | |
@@ -1052,26 +1051,26 @@ discard block |
||
1052 | 1051 | // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
1053 | 1052 | // allow for plugins to hook in and do their own processing of the form input. |
1054 | 1053 | // For plugins to bypass normal processing here, they just need to return a boolean value. |
1055 | - if ( apply_filters( |
|
1054 | + if (apply_filters( |
|
1056 | 1055 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
1057 | 1056 | false, |
1058 | 1057 | $registration, |
1059 | 1058 | $form_input, |
1060 | 1059 | $input_value, |
1061 | 1060 | $this |
1062 | - ) ) { |
|
1061 | + )) { |
|
1063 | 1062 | return true; |
1064 | 1063 | } |
1065 | 1064 | // $answer_cache_id is the key used to find the EE_Answer we want |
1066 | 1065 | $answer_cache_id = $this->checkout->reg_url_link |
1067 | 1066 | ? $form_input |
1068 | - : $form_input . '-' . $registration->reg_url_link(); |
|
1069 | - $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
|
1070 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1067 | + : $form_input.'-'.$registration->reg_url_link(); |
|
1068 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
1069 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer |
|
1071 | 1070 | ? true |
1072 | 1071 | : false; |
1073 | 1072 | //rename form_inputs if they are EE_Attendee properties |
1074 | - switch( (string)$form_input ) { |
|
1073 | + switch ((string) $form_input) { |
|
1075 | 1074 | |
1076 | 1075 | case 'state' : |
1077 | 1076 | case 'STA_ID' : |
@@ -1086,32 +1085,32 @@ discard block |
||
1086 | 1085 | break; |
1087 | 1086 | |
1088 | 1087 | default : |
1089 | - $ATT_input = 'ATT_' . $form_input; |
|
1088 | + $ATT_input = 'ATT_'.$form_input; |
|
1090 | 1089 | //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
1091 | - $attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false; |
|
1092 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1090 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1091 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
1093 | 1092 | } |
1094 | 1093 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
1095 | 1094 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
1096 | 1095 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
1097 | 1096 | // if this form input has a corresponding attendee property |
1098 | - if ( $attendee_property ) { |
|
1099 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1100 | - if ( $answer_is_obj ) { |
|
1097 | + if ($attendee_property) { |
|
1098 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
1099 | + if ($answer_is_obj) { |
|
1101 | 1100 | // and delete the corresponding answer since we won't be storing this data in that object |
1102 | - $registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' ); |
|
1103 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1101 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
1102 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
1104 | 1103 | } |
1105 | 1104 | return true; |
1106 | - } elseif ( $answer_is_obj ) { |
|
1105 | + } elseif ($answer_is_obj) { |
|
1107 | 1106 | // save this data to the answer object |
1108 | - $this->_registration_answers[ $answer_cache_id ]->set_value( $input_value ); |
|
1109 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1107 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
1108 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
1110 | 1109 | return $result !== false ? true : false; |
1111 | 1110 | } else { |
1112 | - foreach ( $this->_registration_answers as $answer ) { |
|
1113 | - if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) { |
|
1114 | - $answer->set_value( $input_value ); |
|
1111 | + foreach ($this->_registration_answers as $answer) { |
|
1112 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1113 | + $answer->set_value($input_value); |
|
1115 | 1114 | $result = $answer->save(); |
1116 | 1115 | return $result !== false ? true : false; |
1117 | 1116 | } |
@@ -1133,15 +1132,15 @@ discard block |
||
1133 | 1132 | $form_input = '', |
1134 | 1133 | $input_value = '' |
1135 | 1134 | ) { |
1136 | - if ( empty( $input_value ) ) { |
|
1135 | + if (empty($input_value)) { |
|
1137 | 1136 | // if the form input isn't marked as being required, then just return |
1138 | - if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) { |
|
1137 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
1139 | 1138 | return true; |
1140 | 1139 | } |
1141 | - switch ( $form_input ) { |
|
1140 | + switch ($form_input) { |
|
1142 | 1141 | case 'fname' : |
1143 | 1142 | EE_Error::add_error( |
1144 | - __( 'First Name is a required value.', 'event_espresso' ), |
|
1143 | + __('First Name is a required value.', 'event_espresso'), |
|
1145 | 1144 | __FILE__, |
1146 | 1145 | __FUNCTION__, |
1147 | 1146 | __LINE__ |
@@ -1150,7 +1149,7 @@ discard block |
||
1150 | 1149 | break; |
1151 | 1150 | case 'lname' : |
1152 | 1151 | EE_Error::add_error( |
1153 | - __( 'Last Name is a required value.', 'event_espresso' ), |
|
1152 | + __('Last Name is a required value.', 'event_espresso'), |
|
1154 | 1153 | __FILE__, |
1155 | 1154 | __FUNCTION__, |
1156 | 1155 | __LINE__ |
@@ -1159,7 +1158,7 @@ discard block |
||
1159 | 1158 | break; |
1160 | 1159 | case 'email' : |
1161 | 1160 | EE_Error::add_error( |
1162 | - __( 'Please enter a valid email address.', 'event_espresso' ), |
|
1161 | + __('Please enter a valid email address.', 'event_espresso'), |
|
1163 | 1162 | __FILE__, |
1164 | 1163 | __FUNCTION__, |
1165 | 1164 | __LINE__ |
@@ -1192,21 +1191,21 @@ discard block |
||
1192 | 1191 | * @param array $attendee_data |
1193 | 1192 | * @return boolean |
1194 | 1193 | */ |
1195 | - private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) { |
|
1194 | + private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) { |
|
1196 | 1195 | $existing_attendee = null; |
1197 | 1196 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1198 | - $ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] ) |
|
1197 | + $ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname']) |
|
1199 | 1198 | ? $attendee_data['ATT_fname'] |
1200 | 1199 | : ''; |
1201 | - $ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] ) |
|
1200 | + $ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname']) |
|
1202 | 1201 | ? $attendee_data['ATT_lname'] |
1203 | 1202 | : ''; |
1204 | - $ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] ) |
|
1203 | + $ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email']) |
|
1205 | 1204 | ? $attendee_data['ATT_email'] |
1206 | 1205 | : ''; |
1207 | 1206 | // but only if those have values |
1208 | - if ( $ATT_fname && $ATT_lname && $ATT_email ) { |
|
1209 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array( |
|
1207 | + if ($ATT_fname && $ATT_lname && $ATT_email) { |
|
1208 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array( |
|
1210 | 1209 | 'ATT_fname' => $ATT_fname, |
1211 | 1210 | 'ATT_lname' => $ATT_lname, |
1212 | 1211 | 'ATT_email' => $ATT_email |
@@ -1230,13 +1229,13 @@ discard block |
||
1230 | 1229 | * @return \EE_Attendee |
1231 | 1230 | * @throws \EE_Error |
1232 | 1231 | */ |
1233 | - private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) { |
|
1232 | + private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) { |
|
1234 | 1233 | // first remove fname, lname, and email from attendee data |
1235 | - $dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1234 | + $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1236 | 1235 | // now loop thru what's left and add to attendee CPT |
1237 | - foreach ( $attendee_data as $property_name => $property_value ) { |
|
1238 | - if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) { |
|
1239 | - $existing_attendee->set( $property_name, $property_value ); |
|
1236 | + foreach ($attendee_data as $property_name => $property_value) { |
|
1237 | + if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) { |
|
1238 | + $existing_attendee->set($property_name, $property_value); |
|
1240 | 1239 | } |
1241 | 1240 | } |
1242 | 1241 | // better save that now |
@@ -1254,11 +1253,11 @@ discard block |
||
1254 | 1253 | * @return void |
1255 | 1254 | * @throws \EE_Error |
1256 | 1255 | */ |
1257 | - private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) { |
|
1256 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) { |
|
1258 | 1257 | // add relation to attendee |
1259 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1260 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1261 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1258 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1259 | + $registration->set_attendee_id($attendee->ID()); |
|
1260 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1262 | 1261 | } |
1263 | 1262 | |
1264 | 1263 | |
@@ -1270,10 +1269,10 @@ discard block |
||
1270 | 1269 | * @return void |
1271 | 1270 | * @throws \EE_Error |
1272 | 1271 | */ |
1273 | - private function _associate_registration_with_transaction( EE_Registration $registration ) { |
|
1272 | + private function _associate_registration_with_transaction(EE_Registration $registration) { |
|
1274 | 1273 | // add relation to attendee |
1275 | - $this->checkout->transaction->_add_relation_to( $registration, 'Registration' ); |
|
1276 | - $this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration ); |
|
1274 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1275 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1277 | 1276 | } |
1278 | 1277 | |
1279 | 1278 | |
@@ -1286,14 +1285,14 @@ discard block |
||
1286 | 1285 | * @return array |
1287 | 1286 | * @throws \EE_Error |
1288 | 1287 | */ |
1289 | - private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) { |
|
1288 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) { |
|
1290 | 1289 | // bare minimum critical details include first name, last name, email address |
1291 | - $critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1290 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1292 | 1291 | // add address info to critical details? |
1293 | - if ( apply_filters( |
|
1292 | + if (apply_filters( |
|
1294 | 1293 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
1295 | 1294 | false |
1296 | - ) ) { |
|
1295 | + )) { |
|
1297 | 1296 | $address_details = array( |
1298 | 1297 | 'ATT_address', |
1299 | 1298 | 'ATT_address2', |
@@ -1303,13 +1302,13 @@ discard block |
||
1303 | 1302 | 'ATT_zip', |
1304 | 1303 | 'ATT_phone' |
1305 | 1304 | ); |
1306 | - $critical_attendee_details = array_merge( $critical_attendee_details, $address_details ); |
|
1305 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1307 | 1306 | } |
1308 | - foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
|
1309 | - if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
|
1310 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1307 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1308 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
1309 | + || empty($attendee_data[$critical_attendee_detail]) |
|
1311 | 1310 | ) { |
1312 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1311 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
1313 | 1312 | $critical_attendee_detail |
1314 | 1313 | ); |
1315 | 1314 | } |
@@ -1327,11 +1326,11 @@ discard block |
||
1327 | 1326 | * @return \EE_Attendee |
1328 | 1327 | * @throws \EE_Error |
1329 | 1328 | */ |
1330 | - private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) { |
|
1329 | + private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) { |
|
1331 | 1330 | // create new attendee object |
1332 | - $new_attendee = EE_Attendee::new_instance( $attendee_data ); |
|
1331 | + $new_attendee = EE_Attendee::new_instance($attendee_data); |
|
1333 | 1332 | // set author to event creator |
1334 | - $new_attendee->set( 'ATT_author', $registration->event()->wp_user() ); |
|
1333 | + $new_attendee->set('ATT_author', $registration->event()->wp_user()); |
|
1335 | 1334 | $new_attendee->save(); |
1336 | 1335 | return $new_attendee; |
1337 | 1336 | } |
@@ -1348,7 +1347,7 @@ discard block |
||
1348 | 1347 | */ |
1349 | 1348 | public function update_reg_step() { |
1350 | 1349 | // save everything |
1351 | - if ( $this->process_reg_step() ) { |
|
1350 | + if ($this->process_reg_step()) { |
|
1352 | 1351 | $this->checkout->redirect = true; |
1353 | 1352 | $this->checkout->redirect_url = add_query_arg( |
1354 | 1353 | array( |
@@ -1357,7 +1356,7 @@ discard block |
||
1357 | 1356 | ), |
1358 | 1357 | $this->checkout->thank_you_page_url |
1359 | 1358 | ); |
1360 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1359 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1361 | 1360 | return true; |
1362 | 1361 | } |
1363 | 1362 | return false; |
@@ -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 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Transaction Model |
@@ -67,36 +67,36 @@ discard block |
||
67 | 67 | * @return EEM_Transaction |
68 | 68 | * @throws \EE_Error |
69 | 69 | */ |
70 | - protected function __construct( $timezone ) { |
|
71 | - $this->singular_item = __('Transaction','event_espresso'); |
|
72 | - $this->plural_item = __('Transactions','event_espresso'); |
|
70 | + protected function __construct($timezone) { |
|
71 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
72 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
73 | 73 | |
74 | 74 | $this->_tables = array( |
75 | - 'TransactionTable'=>new EE_Primary_Table('esp_transaction','TXN_ID') |
|
75 | + 'TransactionTable'=>new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
76 | 76 | ); |
77 | 77 | $this->_fields = array( |
78 | 78 | 'TransactionTable'=>array( |
79 | - 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')), |
|
80 | - 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, time(), $timezone ), |
|
81 | - 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0), |
|
82 | - 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0), |
|
83 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
84 | - 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''), |
|
85 | - 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''), |
|
79 | + 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
80 | + 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone), |
|
81 | + 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0), |
|
82 | + 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
83 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
84 | + 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''), |
|
85 | + 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
86 | 86 | 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'), |
87 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ), |
|
87 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()), |
|
88 | 88 | ) |
89 | 89 | ); |
90 | 90 | $this->_model_relations = array( |
91 | 91 | 'Registration'=>new EE_Has_Many_Relation(), |
92 | 92 | 'Payment'=>new EE_Has_Many_Relation(), |
93 | 93 | 'Status'=>new EE_Belongs_To_Relation(), |
94 | - 'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items |
|
94 | + 'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items |
|
95 | 95 | 'Payment_Method'=>new EE_Belongs_To_Relation(), |
96 | 96 | 'Message' => new EE_Has_Many_Relation() |
97 | 97 | ); |
98 | 98 | $this->_model_chain_to_wp_user = 'Registration.Event'; |
99 | - parent::__construct( $timezone ); |
|
99 | + parent::__construct($timezone); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -107,22 +107,22 @@ discard block |
||
107 | 107 | * @param string $period |
108 | 108 | * @return \stdClass[] |
109 | 109 | */ |
110 | - public function get_revenue_per_day_report( $period = '-1 month' ) { |
|
111 | - $sql_date = $this->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', strtotime( $period ) ), 'Y-m-d H:i:s', 'UTC' ); |
|
110 | + public function get_revenue_per_day_report($period = '-1 month') { |
|
111 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
112 | 112 | |
113 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'TXN_timestamp' ); |
|
113 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
114 | 114 | return $this->_get_all_wpdb_results( |
115 | 115 | array( |
116 | 116 | array( |
117 | - 'TXN_timestamp' => array( '>=', $sql_date ) |
|
117 | + 'TXN_timestamp' => array('>=', $sql_date) |
|
118 | 118 | ), |
119 | 119 | 'group_by' => 'txnDate', |
120 | - 'order_by' => array( 'TXN_timestamp' => 'ASC' ) |
|
120 | + 'order_by' => array('TXN_timestamp' => 'ASC') |
|
121 | 121 | ), |
122 | 122 | OBJECT, |
123 | 123 | array( |
124 | - 'txnDate' => array( 'DATE(' . $query_interval . ')', '%s' ), |
|
125 | - 'revenue' => array( 'SUM(TransactionTable.TXN_paid)', '%d' ) |
|
124 | + 'txnDate' => array('DATE('.$query_interval.')', '%s'), |
|
125 | + 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
126 | 126 | ) |
127 | 127 | ); |
128 | 128 | } |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | * @throws \EE_Error |
138 | 138 | * @return mixed |
139 | 139 | */ |
140 | - public function get_revenue_per_event_report( $period = '-1 month' ) { |
|
140 | + public function get_revenue_per_event_report($period = '-1 month') { |
|
141 | 141 | global $wpdb; |
142 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
143 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
142 | + $transaction_table = $wpdb->prefix.'esp_transaction'; |
|
143 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
144 | 144 | $event_table = $wpdb->posts; |
145 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
146 | - $sql_date = date( 'Y-m-d H:i:s', strtotime( $period ) ); |
|
145 | + $payment_table = $wpdb->prefix.'esp_payment'; |
|
146 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
147 | 147 | $approved_payment_status = EEM_Payment::status_id_approved; |
148 | 148 | $extra_event_on_join = ''; |
149 | 149 | //exclude events not authored by user if permissions in effect |
150 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
151 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
150 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
151 | + $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id(); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | return $wpdb->get_results( |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | * @param string $reg_url_link |
189 | 189 | * @return EE_Transaction |
190 | 190 | */ |
191 | - public function get_transaction_from_reg_url_link( $reg_url_link = '' ){ |
|
192 | - return $this->get_one( array( |
|
191 | + public function get_transaction_from_reg_url_link($reg_url_link = '') { |
|
192 | + return $this->get_one(array( |
|
193 | 193 | array( |
194 | - 'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) |
|
194 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '') |
|
195 | 195 | ) |
196 | 196 | )); |
197 | 197 | } |
@@ -208,16 +208,16 @@ discard block |
||
208 | 208 | * @return boolean |
209 | 209 | * @throws \EE_Error |
210 | 210 | */ |
211 | - public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){ |
|
211 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) { |
|
212 | 212 | EE_Error::doing_it_wrong( |
213 | - __CLASS__ . '::' . __FUNCTION__, |
|
214 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
213 | + __CLASS__.'::'.__FUNCTION__, |
|
214 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
215 | 215 | '4.6.0' |
216 | 216 | ); |
217 | 217 | /** @type EE_Transaction_Processor $transaction_processor */ |
218 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
218 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
219 | 219 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
220 | - $this->ensure_is_obj( $transaction_obj_or_id ) |
|
220 | + $this->ensure_is_obj($transaction_obj_or_id) |
|
221 | 221 | ); |
222 | 222 | } |
223 | 223 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | array( |
250 | 250 | 0 => array( |
251 | 251 | 'STS_ID' => EEM_Transaction::failed_status_code, |
252 | - 'TXN_timestamp' => array( '<', time() - $time_to_leave_alone ) |
|
252 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
253 | 253 | ) |
254 | 254 | ), |
255 | 255 | $time_to_leave_alone |
@@ -262,29 +262,29 @@ discard block |
||
262 | 262 | */ |
263 | 263 | $txn_ids = apply_filters( |
264 | 264 | 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
265 | - EEM_Transaction::instance()->get_col( $ids_query, 'TXN_ID' ), |
|
265 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
266 | 266 | $time_to_leave_alone |
267 | 267 | ); |
268 | 268 | //now that we have the ids to delete |
269 | - if ( ! empty( $txn_ids ) && is_array( $txn_ids ) ) { |
|
269 | + if ( ! empty($txn_ids) && is_array($txn_ids)) { |
|
270 | 270 | // first, make sure these TXN's are removed the "ee_locked_transactions" array |
271 | - EEM_Transaction::unset_locked_transactions( $txn_ids ); |
|
271 | + EEM_Transaction::unset_locked_transactions($txn_ids); |
|
272 | 272 | // let's get deletin'... |
273 | 273 | // Why no wpdb->prepare? Because the data is trusted. |
274 | 274 | // We got the ids from the original query to get them FROM |
275 | 275 | // the db (which is sanitized) so no need to prepare them again. |
276 | - $query = ' |
|
276 | + $query = ' |
|
277 | 277 | DELETE |
278 | - FROM ' . $this->table() . ' |
|
278 | + FROM ' . $this->table().' |
|
279 | 279 | WHERE |
280 | - TXN_ID IN ( ' . implode( ",", $txn_ids ) . ')'; |
|
281 | - $deleted = $wpdb->query( $query ); |
|
280 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
281 | + $deleted = $wpdb->query($query); |
|
282 | 282 | } |
283 | - if ( $deleted ) { |
|
283 | + if ($deleted) { |
|
284 | 284 | /** |
285 | 285 | * Allows code to do something after the transactions have been deleted. |
286 | 286 | */ |
287 | - do_action( 'AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids ); |
|
287 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
288 | 288 | } |
289 | 289 | return $deleted; |
290 | 290 | } |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | * @param array $transaction_IDs |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | - public static function unset_locked_transactions( array $transaction_IDs ) { |
|
299 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
298 | + public static function unset_locked_transactions(array $transaction_IDs) { |
|
299 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
300 | 300 | $update = false; |
301 | - foreach ( $transaction_IDs as $TXN_ID ) { |
|
302 | - if ( isset( $locked_transactions[ $TXN_ID ] ) ) { |
|
303 | - unset( $locked_transactions[ $TXN_ID ] ); |
|
301 | + foreach ($transaction_IDs as $TXN_ID) { |
|
302 | + if (isset($locked_transactions[$TXN_ID])) { |
|
303 | + unset($locked_transactions[$TXN_ID]); |
|
304 | 304 | $update = true; |
305 | 305 | } |
306 | 306 | } |
307 | - if ( $update ) { |
|
308 | - update_option( 'ee_locked_transactions', $locked_transactions ); |
|
307 | + if ($update) { |
|
308 | + update_option('ee_locked_transactions', $locked_transactions); |
|
309 | 309 | } |
310 | 310 | return $update; |
311 | 311 | } |