@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | use EventEspressoBatchRequest\Helpers\JobParameters; |
24 | 24 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
25 | 25 | |
26 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
27 | - exit( 'No direct script access allowed' ); |
|
26 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
27 | + exit('No direct script access allowed'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -50,32 +50,32 @@ discard block |
||
50 | 50 | * @param array $request_data to be used by the batch job handler |
51 | 51 | * @return JobStepResponse |
52 | 52 | */ |
53 | - public function create_job( $batch_job_handler_class, $request_data ) { |
|
53 | + public function create_job($batch_job_handler_class, $request_data) { |
|
54 | 54 | try { |
55 | - $this->_job_id = wp_generate_password( 15, false ); |
|
56 | - $obj = $this->instantiate_batch_job_handler_from_classname( $batch_job_handler_class ); |
|
57 | - $this->_job_parameters = new JobParameters( $this->_job_id, $batch_job_handler_class, $request_data ); |
|
58 | - $response = $obj->create_job( $this->_job_parameters ); |
|
59 | - if( ! $response instanceof JobStepResponse ) { |
|
55 | + $this->_job_id = wp_generate_password(15, false); |
|
56 | + $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
|
57 | + $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
|
58 | + $response = $obj->create_job($this->_job_parameters); |
|
59 | + if ( ! $response instanceof JobStepResponse) { |
|
60 | 60 | throw new BatchRequestException( |
61 | 61 | sprintf( |
62 | - __( 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso' ), |
|
63 | - wp_json_encode( $request_data ) |
|
62 | + __('The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso'), |
|
63 | + wp_json_encode($request_data) |
|
64 | 64 | ) |
65 | 65 | ); |
66 | 66 | } |
67 | - $success = $this->_job_parameters->save( true ); |
|
68 | - if( ! $success ) { |
|
67 | + $success = $this->_job_parameters->save(true); |
|
68 | + if ( ! $success) { |
|
69 | 69 | throw new BatchRequestException( |
70 | 70 | sprintf( |
71 | 71 | __('Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', 'event_espresso'), |
72 | 72 | $this->_job_id, |
73 | - wp_json_encode( $request_data ) |
|
73 | + wp_json_encode($request_data) |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | } |
77 | - } catch( \Exception $e ) { |
|
78 | - $response = $this->_get_error_response( $e, 'create_job' ); |
|
77 | + } catch (\Exception $e) { |
|
78 | + $response = $this->_get_error_response($e, 'create_job'); |
|
79 | 79 | } |
80 | 80 | return $response; |
81 | 81 | } |
@@ -88,26 +88,26 @@ discard block |
||
88 | 88 | * @param int $batch_size |
89 | 89 | * @return JobStepResponse |
90 | 90 | */ |
91 | - public function continue_job( $job_id, $batch_size = 50 ) { |
|
91 | + public function continue_job($job_id, $batch_size = 50) { |
|
92 | 92 | try { |
93 | 93 | $this->_job_id = $job_id; |
94 | - $batch_size = defined( 'EE_BATCHRUNNER_BATCH_SIZE' ) ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
94 | + $batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
95 | 95 | //get the corresponding WordPress option for the job |
96 | - $this->_job_parameters = JobParameters::load( $this->_job_id ); |
|
97 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname( $this->_job_parameters->classname() ); |
|
96 | + $this->_job_parameters = JobParameters::load($this->_job_id); |
|
97 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
|
98 | 98 | //continue it |
99 | - $response = $handler_obj->continue_job( $this->_job_parameters, $batch_size ); |
|
100 | - if( ! $response instanceof JobStepResponse ) { |
|
99 | + $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
|
100 | + if ( ! $response instanceof JobStepResponse) { |
|
101 | 101 | throw new BatchRequestException( |
102 | 102 | sprintf( |
103 | - __( 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ), |
|
103 | + __('The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'), |
|
104 | 104 | $this->_job_id |
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | } |
108 | 108 | $this->_job_parameters->save(); |
109 | - } catch( \Exception $e ) { |
|
110 | - $response = $this->_get_error_response( $e, 'continue_job' ); |
|
109 | + } catch (\Exception $e) { |
|
110 | + $response = $this->_get_error_response($e, 'continue_job'); |
|
111 | 111 | } |
112 | 112 | return $response; |
113 | 113 | } |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return JobHandlerInterface |
123 | 123 | * @throws BatchRequestException |
124 | 124 | */ |
125 | - public function instantiate_batch_job_handler_from_classname( $classname ) { |
|
126 | - if( ! class_exists( $classname ) ) { |
|
125 | + public function instantiate_batch_job_handler_from_classname($classname) { |
|
126 | + if ( ! class_exists($classname)) { |
|
127 | 127 | throw new BatchRequestException( |
128 | 128 | sprintf( |
129 | 129 | __('The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', 'event_espresso'), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ); |
133 | 133 | } |
134 | 134 | $obj = new $classname; |
135 | - if( ! $obj instanceof JobHandlerInterface ) { |
|
135 | + if ( ! $obj instanceof JobHandlerInterface) { |
|
136 | 136 | throw new BatchRequestException( |
137 | 137 | sprintf( |
138 | 138 | __('The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', 'event_espresso'), |
@@ -152,26 +152,26 @@ discard block |
||
152 | 152 | * @return JobStepResponse |
153 | 153 | * @throws BatchRequestException |
154 | 154 | */ |
155 | - public function cleanup_job( $job_id ) { |
|
156 | - try{ |
|
155 | + public function cleanup_job($job_id) { |
|
156 | + try { |
|
157 | 157 | $this->_job_id = $job_id; |
158 | - $job_parameters = JobParameters::load( $this->_job_id ); |
|
159 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname( $job_parameters->classname() ); |
|
158 | + $job_parameters = JobParameters::load($this->_job_id); |
|
159 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
|
160 | 160 | //continue it |
161 | - $response = $handler_obj->cleanup_job( $job_parameters ); |
|
162 | - if( ! $response instanceof JobStepResponse ) { |
|
161 | + $response = $handler_obj->cleanup_job($job_parameters); |
|
162 | + if ( ! $response instanceof JobStepResponse) { |
|
163 | 163 | throw new BatchRequestException( |
164 | 164 | sprintf( |
165 | - __( 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ), |
|
165 | + __('The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'), |
|
166 | 166 | $this->_job_id |
167 | 167 | ) |
168 | 168 | ); |
169 | 169 | } |
170 | - $job_parameters->set_status( JobParameters::status_cleaned_up ); |
|
170 | + $job_parameters->set_status(JobParameters::status_cleaned_up); |
|
171 | 171 | $job_parameters->delete(); |
172 | 172 | return $response; |
173 | - } catch( \Exception $e ) { |
|
174 | - $response = $this->_get_error_response( $e, 'cleanup_job' ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + $response = $this->_get_error_response($e, 'cleanup_job'); |
|
175 | 175 | } |
176 | 176 | return $response; |
177 | 177 | } |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | * @param string $method_name |
185 | 185 | * @return JobStepResponse |
186 | 186 | */ |
187 | - protected function _get_error_response( \Exception $exception, $method_name ) { |
|
188 | - if( ! $this->_job_parameters instanceof JobParameters ) { |
|
189 | - $this->_job_parameters = new JobParameters( $this->_job_id, __( '__Unknown__', 'event_espresso' ), array() ); |
|
187 | + protected function _get_error_response(\Exception $exception, $method_name) { |
|
188 | + if ( ! $this->_job_parameters instanceof JobParameters) { |
|
189 | + $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
|
190 | 190 | } |
191 | - $this->_job_parameters->set_status( JobParameters::status_error ); |
|
191 | + $this->_job_parameters->set_status(JobParameters::status_error); |
|
192 | 192 | return new JobStepResponse( |
193 | 193 | $this->_job_parameters, |
194 | 194 | sprintf( |
195 | 195 | __('An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', 'event_espresso'), |
196 | - get_class( $exception ), |
|
197 | - 'BatchRunner::' . $method_name . '()', |
|
196 | + get_class($exception), |
|
197 | + 'BatchRunner::'.$method_name.'()', |
|
198 | 198 | $exception->getMessage(), |
199 | 199 | $exception->getTraceAsString() |
200 | 200 | ) |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class BatchRequetProcessor |
|
3 | + * |
|
4 | + * Class BatchRequetProcessor |
|
5 | 5 | * |
6 | - * Responsible for receiving a request to start a job and assign it a job Id. |
|
7 | - * Then when subsequent requests come in to continue that job, dispatches |
|
8 | - * the request to the appropriate JobHandler, which processes a step of the batch, |
|
9 | - * and then returns the job's new status. |
|
10 | - * This class is used by controller code, and the controller code is sent HTTP |
|
11 | - * requests from the batch_runner.js library |
|
12 | - * |
|
13 | - * @package Event Espresso |
|
14 | - * @subpackage batch |
|
15 | - * @author Mike Nelson |
|
16 | - * @since 4.8.26 |
|
17 | - * |
|
18 | - */ |
|
6 | + * Responsible for receiving a request to start a job and assign it a job Id. |
|
7 | + * Then when subsequent requests come in to continue that job, dispatches |
|
8 | + * the request to the appropriate JobHandler, which processes a step of the batch, |
|
9 | + * and then returns the job's new status. |
|
10 | + * This class is used by controller code, and the controller code is sent HTTP |
|
11 | + * requests from the batch_runner.js library |
|
12 | + * |
|
13 | + * @package Event Espresso |
|
14 | + * @subpackage batch |
|
15 | + * @author Mike Nelson |
|
16 | + * @since 4.8.26 |
|
17 | + * |
|
18 | + */ |
|
19 | 19 | namespace EventEspressoBatchRequest; |
20 | 20 | |
21 | 21 | use EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerInterface; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | namespace EventEspressoBatchRequest\Helpers; |
16 | 16 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
17 | 17 | |
18 | -class BatchRequestException extends \Exception{ |
|
18 | +class BatchRequestException extends \Exception { |
|
19 | 19 | //so far the same as exception |
20 | 20 | } |
21 | 21 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class BatchRequestException |
|
5 | - * |
|
6 | - * Exception class for whenever we have trouble running start, continuing, or finishing |
|
7 | - * a batch job. |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage batch |
|
11 | - * @author Mike Nelson |
|
12 | - * @since 4.8.26 |
|
13 | - * |
|
14 | - */ |
|
3 | + * |
|
4 | + * Class BatchRequestException |
|
5 | + * |
|
6 | + * Exception class for whenever we have trouble running start, continuing, or finishing |
|
7 | + * a batch job. |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage batch |
|
11 | + * @author Mike Nelson |
|
12 | + * @since 4.8.26 |
|
13 | + * |
|
14 | + */ |
|
15 | 15 | namespace EventEspressoBatchRequest\Helpers; |
16 | 16 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
17 | 17 |
@@ -43,10 +43,10 @@ |
||
43 | 43 | * @param string $update_text |
44 | 44 | * @param array $extra_data |
45 | 45 | */ |
46 | - public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array() ) { |
|
47 | - $this->_job_parameters = $job_parameters; |
|
46 | + public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array()) { |
|
47 | + $this->_job_parameters = $job_parameters; |
|
48 | 48 | $this->_update_text = $update_text; |
49 | - $this->_extra_data = (array)$extra_data; |
|
49 | + $this->_extra_data = (array) $extra_data; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | use EventEspressoBatchRequest\Helpers\JobParameters; |
21 | 21 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
22 | 22 | |
23 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
24 | - exit( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
24 | + exit('No direct script access allowed'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @throws BatchRequestException |
36 | 36 | * @return JobStepResponse |
37 | 37 | */ |
38 | - public function create_job( JobParameters $job_parameters ); |
|
38 | + public function create_job(JobParameters $job_parameters); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Performs another step of the job |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return JobStepResponse |
45 | 45 | * @throws BatchRequestException |
46 | 46 | */ |
47 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ); |
|
47 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Performs any clean-up logic when we know the job is completed |
@@ -52,5 +52,5 @@ discard block |
||
52 | 52 | * @return JobStepResponse |
53 | 53 | * @throws BatchRequestException |
54 | 54 | */ |
55 | - public function cleanup_job( JobParameters $job_parameters ); |
|
55 | + public function cleanup_job(JobParameters $job_parameters); |
|
56 | 56 | } |
@@ -99,10 +99,10 @@ |
||
99 | 99 | if( $field_name == 'STA_ID' ){ |
100 | 100 | $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
101 | 101 | $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
102 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
102 | + } elseif( $field_name == 'CNT_ISO' ){ |
|
103 | 103 | $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
104 | 104 | $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
107 | 107 | } |
108 | 108 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use EventEspressoBatchRequest\Helpers\JobParameters; |
19 | 19 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
20 | 20 | |
21 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
22 | 22 | exit('No direct script access allowed'); |
23 | 23 | } |
24 | 24 | |
@@ -27,84 +27,84 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | public function create_job(JobParameters $job_parameters) { |
30 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) { |
|
30 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) { |
|
31 | 31 | throw new BatchRequestException( |
32 | - __( 'You do not have permission to view contacts', 'event_espresso') |
|
32 | + __('You do not have permission to view contacts', 'event_espresso') |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | $filepath = $this->create_file_from_job_with_name( |
36 | 36 | $job_parameters->job_id(), |
37 | 37 | __('contact-list-report.csv', 'event_espresso') |
38 | 38 | ); |
39 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
40 | - $job_parameters->set_job_size( $this->count_units_to_process() ); |
|
39 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
40 | + $job_parameters->set_job_size($this->count_units_to_process()); |
|
41 | 41 | //we should also set the header columns |
42 | - $csv_data_for_row = $this->get_csv_data( 0, 1 ); |
|
43 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
42 | + $csv_data_for_row = $this->get_csv_data(0, 1); |
|
43 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
44 | 44 | //if we actually processed a row there, record it |
45 | - if( $job_parameters->job_size() ) { |
|
46 | - $job_parameters->mark_processed( 1 ); |
|
45 | + if ($job_parameters->job_size()) { |
|
46 | + $job_parameters->mark_processed(1); |
|
47 | 47 | } |
48 | 48 | return new JobStepResponse( |
49 | 49 | $job_parameters, |
50 | - __( 'Contacts report started successfully...', 'event_espresso' ) |
|
50 | + __('Contacts report started successfully...', 'event_espresso') |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
56 | - $csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size ); |
|
57 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
58 | - $units_processed = count( $csv_data ); |
|
59 | - $job_parameters->mark_processed( $units_processed ); |
|
56 | + $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size); |
|
57 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
58 | + $units_processed = count($csv_data); |
|
59 | + $job_parameters->mark_processed($units_processed); |
|
60 | 60 | $extra_response_data = array( |
61 | 61 | 'file_url' => '' |
62 | 62 | ); |
63 | - if( $units_processed < $batch_size ) { |
|
64 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
65 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
63 | + if ($units_processed < $batch_size) { |
|
64 | + $job_parameters->set_status(JobParameters::status_complete); |
|
65 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
66 | 66 | } |
67 | 67 | return new JobStepResponse( |
68 | 68 | $job_parameters, |
69 | 69 | sprintf( |
70 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
71 | - count( $csv_data ) ), |
|
70 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
71 | + count($csv_data) ), |
|
72 | 72 | $extra_response_data ); |
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | 76 | public function cleanup_job(JobParameters $job_parameters) { |
77 | 77 | $this->_file_helper->delete( |
78 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
78 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
79 | 79 | true, |
80 | 80 | 'd' |
81 | 81 | ); |
82 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
82 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function count_units_to_process() { |
86 | - return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin )); |
|
86 | + return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin)); |
|
87 | 87 | } |
88 | - public function get_csv_data( $offset, $limit ) { |
|
88 | + public function get_csv_data($offset, $limit) { |
|
89 | 89 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
90 | 90 | array( |
91 | - 'limit' => array( $offset, $limit ), |
|
92 | - 'force_join' => array( 'State', 'Country' ), |
|
91 | + 'limit' => array($offset, $limit), |
|
92 | + 'force_join' => array('State', 'Country'), |
|
93 | 93 | 'caps' => \EEM_Base::caps_read_admin |
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | $csv_data = array(); |
97 | - foreach( $attendee_rows as $attendee_row ){ |
|
97 | + foreach ($attendee_rows as $attendee_row) { |
|
98 | 98 | $csv_row = array(); |
99 | - foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
100 | - if( $field_name == 'STA_ID' ){ |
|
101 | - $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
102 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
103 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
104 | - $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
105 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
106 | - }else{ |
|
107 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
99 | + foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
100 | + if ($field_name == 'STA_ID') { |
|
101 | + $state_name_field = \EEM_State::instance()->field_settings_for('STA_name'); |
|
102 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
103 | + }elseif ($field_name == 'CNT_ISO') { |
|
104 | + $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name'); |
|
105 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
106 | + } else { |
|
107 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | $csv_data[] = $csv_row; |
@@ -85,6 +85,11 @@ |
||
85 | 85 | public function count_units_to_process() { |
86 | 86 | return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin )); |
87 | 87 | } |
88 | + |
|
89 | + /** |
|
90 | + * @param integer $offset |
|
91 | + * @param integer $limit |
|
92 | + */ |
|
88 | 93 | public function get_csv_data( $offset, $limit ) { |
89 | 94 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
90 | 95 | array( |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if( ! $event_slug ) { |
76 | 76 | $event_slug = __( 'unknown', 'event_espresso' ); |
77 | 77 | } |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | $event_slug = __( 'all', 'event_espresso' ); |
80 | 80 | } |
81 | 81 | return sprintf( "registrations-for-%s.csv", $event_slug ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ); |
163 | 163 | if( $event_id ){ |
164 | 164 | $query_params[0]['EVT_ID'] = $event_id; |
165 | - }else{ |
|
165 | + } else{ |
|
166 | 166 | $query_params[ 'force_join' ][] = 'Event'; |
167 | 167 | } |
168 | 168 | $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $field = $reg_model->field_settings_for($field_name); |
192 | 192 | if($field_name == 'REG_final_price'){ |
193 | 193 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
194 | - }elseif( $field_name == 'REG_count' ){ |
|
194 | + } elseif( $field_name == 'REG_count' ){ |
|
195 | 195 | $value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
196 | - }elseif( $field_name == 'REG_date' ) { |
|
196 | + } elseif( $field_name == 'REG_date' ) { |
|
197 | 197 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
198 | - }else{ |
|
198 | + } else{ |
|
199 | 199 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
200 | 200 | } |
201 | 201 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | if( $reg_row[ 'Attendee_CPT.ID' ]){ |
268 | 268 | if($att_field_name == 'STA_ID'){ |
269 | 269 | $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
270 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
270 | + } elseif($att_field_name == 'CNT_ISO'){ |
|
271 | 271 | $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
272 | - }else{ |
|
272 | + } else{ |
|
273 | 273 | $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
274 | 274 | } |
275 | - }else{ |
|
275 | + } else{ |
|
276 | 276 | $value = ''; |
277 | 277 | } |
278 | 278 |
@@ -410,7 +410,7 @@ |
||
410 | 410 | * Performs any clean-up logic when we know the job is completed. |
411 | 411 | * In this case, we delete the temporary file |
412 | 412 | * @param JobParameters $job_parameters |
413 | - * @return boolean |
|
413 | + * @return JobStepResponse |
|
414 | 414 | */ |
415 | 415 | public function cleanup_job( JobParameters $job_parameters ){ |
416 | 416 | $this->_file_helper->delete( |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | use EventEspressoBatchRequest\Helpers\JobParameters; |
20 | 20 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
21 | 21 | |
22 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
23 | - exit( 'No direct script access allowed' ); |
|
22 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
23 | + exit('No direct script access allowed'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @throws BatchRequestException |
36 | 36 | * @return JobStepResponse |
37 | 37 | */ |
38 | - public function create_job( JobParameters $job_parameters ) { |
|
39 | - $event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) ); |
|
40 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) { |
|
38 | + public function create_job(JobParameters $job_parameters) { |
|
39 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
40 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
41 | 41 | throw new BatchRequestException( |
42 | - __( 'You do not have permission to view registrations', 'event_espresso') |
|
42 | + __('You do not have permission to view registrations', 'event_espresso') |
|
43 | 43 | ); |
44 | 44 | } |
45 | 45 | $filepath = $this->create_file_from_job_with_name( |
46 | 46 | $job_parameters->job_id(), |
47 | - $this->get_filename_from_event( $event_id ) |
|
47 | + $this->get_filename_from_event($event_id) |
|
48 | 48 | ); |
49 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
50 | - $question_data_for_columns = $this->_get_questions_for_report( $event_id ); |
|
51 | - $job_parameters->add_extra_data( 'questions_data', $question_data_for_columns ); |
|
52 | - $job_parameters->set_job_size( $this->count_units_to_process( $event_id ) ); |
|
49 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
50 | + $question_data_for_columns = $this->_get_questions_for_report($event_id); |
|
51 | + $job_parameters->add_extra_data('questions_data', $question_data_for_columns); |
|
52 | + $job_parameters->set_job_size($this->count_units_to_process($event_id)); |
|
53 | 53 | //we should also set the header columns |
54 | 54 | $csv_data_for_row = $this->get_csv_data_for( |
55 | 55 | $event_id, |
56 | 56 | 0, |
57 | 57 | 1, |
58 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
59 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
58 | + $job_parameters->extra_datum('questions_data') ); |
|
59 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
60 | 60 | //if we actually processed a row there, record it |
61 | - if( $job_parameters->job_size() ) { |
|
62 | - $job_parameters->mark_processed( 1 ); |
|
61 | + if ($job_parameters->job_size()) { |
|
62 | + $job_parameters->mark_processed(1); |
|
63 | 63 | } |
64 | 64 | return new JobStepResponse( |
65 | 65 | $job_parameters, |
66 | - __( 'Registrations report started successfully...', 'event_espresso' ) |
|
66 | + __('Registrations report started successfully...', 'event_espresso') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | * @param int $event_id |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - protected function get_filename_from_event( $event_id ) { |
|
78 | - if( $event_id ){ |
|
79 | - $event_slug = \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
80 | - if( ! $event_slug ) { |
|
81 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
77 | + protected function get_filename_from_event($event_id) { |
|
78 | + if ($event_id) { |
|
79 | + $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
80 | + if ( ! $event_slug) { |
|
81 | + $event_slug = __('unknown', 'event_espresso'); |
|
82 | 82 | } |
83 | - }else{ |
|
84 | - $event_slug = __( 'all', 'event_espresso' ); |
|
83 | + } else { |
|
84 | + $event_slug = __('all', 'event_espresso'); |
|
85 | 85 | } |
86 | - return sprintf( "registrations-for-%s.csv", $event_slug ); |
|
86 | + return sprintf("registrations-for-%s.csv", $event_slug); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | * @param int|null $event_id |
93 | 93 | * @return array of wpdb results for questions which are to be used for this report |
94 | 94 | */ |
95 | - protected function _get_questions_for_report( $event_id ) { |
|
95 | + protected function _get_questions_for_report($event_id) { |
|
96 | 96 | $question_query_params = array( |
97 | 97 | array( |
98 | - 'Answer.ANS_ID' => array( 'IS_NOT_NULL' ), |
|
98 | + 'Answer.ANS_ID' => array('IS_NOT_NULL'), |
|
99 | 99 | ), |
100 | - 'group_by' => array( 'QST_ID' ) |
|
100 | + 'group_by' => array('QST_ID') |
|
101 | 101 | ); |
102 | - if( $event_id ) { |
|
102 | + if ($event_id) { |
|
103 | 103 | $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id; |
104 | 104 | } |
105 | - return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params ); |
|
105 | + return \EEM_Question::instance()->get_all_wpdb_results($question_query_params); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -115,27 +115,27 @@ discard block |
||
115 | 115 | * @return JobStepResponse |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) { |
|
118 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
|
119 | 119 | $csv_data = $this->get_csv_data_for( |
120 | - $job_parameters->request_datum( 'EVT_ID', '0'), |
|
120 | + $job_parameters->request_datum('EVT_ID', '0'), |
|
121 | 121 | $job_parameters->units_processed(), |
122 | 122 | $batch_size, |
123 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
124 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
125 | - $units_processed = count( $csv_data ); |
|
126 | - $job_parameters->mark_processed( $units_processed ); |
|
123 | + $job_parameters->extra_datum('questions_data') ); |
|
124 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
125 | + $units_processed = count($csv_data); |
|
126 | + $job_parameters->mark_processed($units_processed); |
|
127 | 127 | $extra_response_data = array( |
128 | 128 | 'file_url' => '' |
129 | 129 | ); |
130 | - if( $units_processed < $batch_size ) { |
|
131 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
132 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
130 | + if ($units_processed < $batch_size) { |
|
131 | + $job_parameters->set_status(JobParameters::status_complete); |
|
132 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
133 | 133 | } |
134 | 134 | return new JobStepResponse( |
135 | 135 | $job_parameters, |
136 | 136 | sprintf( |
137 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
138 | - count( $csv_data ) ), |
|
137 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
138 | + count($csv_data) ), |
|
139 | 139 | $extra_response_data ); |
140 | 140 | } |
141 | 141 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return array top-level keys are numeric, next-level keys are column headers |
149 | 149 | * |
150 | 150 | */ |
151 | - function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) { |
|
151 | + function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) { |
|
152 | 152 | $reg_fields_to_include = array( |
153 | 153 | 'TXN_ID', |
154 | 154 | 'ATT_ID', |
@@ -179,166 +179,166 @@ discard block |
||
179 | 179 | array( |
180 | 180 | 'OR' => array( |
181 | 181 | //don't include registrations from failed or abandoned transactions... |
182 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
182 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
183 | 183 | //unless the registration is approved, in which case include it regardless of transaction status |
184 | 184 | 'STS_ID' => \EEM_Registration::status_id_approved |
185 | 185 | ), |
186 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
186 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
187 | 187 | ), |
188 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
189 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
190 | - 'limit' => array( $offset, $limit ), |
|
188 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
189 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
190 | + 'limit' => array($offset, $limit), |
|
191 | 191 | 'caps' => \EEM_Base::caps_read_admin |
192 | 192 | ), |
193 | 193 | $event_id |
194 | 194 | ); |
195 | - if( $event_id ){ |
|
196 | - $query_params[0]['EVT_ID'] = $event_id; |
|
197 | - }else{ |
|
198 | - $query_params[ 'force_join' ][] = 'Event'; |
|
195 | + if ($event_id) { |
|
196 | + $query_params[0]['EVT_ID'] = $event_id; |
|
197 | + } else { |
|
198 | + $query_params['force_join'][] = 'Event'; |
|
199 | 199 | } |
200 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
200 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
201 | 201 | //get all questions which relate to someone in this group |
202 | 202 | $registration_ids = array(); |
203 | - foreach( $registration_rows as $reg_row ) { |
|
204 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
203 | + foreach ($registration_rows as $reg_row) { |
|
204 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
205 | 205 | } |
206 | 206 | |
207 | - foreach($registration_rows as $reg_row){ |
|
208 | - if ( is_array( $reg_row ) ) { |
|
207 | + foreach ($registration_rows as $reg_row) { |
|
208 | + if (is_array($reg_row)) { |
|
209 | 209 | $reg_csv_array = array(); |
210 | - if( ! $event_id ){ |
|
210 | + if ( ! $event_id) { |
|
211 | 211 | //get the event's name and Id |
212 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
212 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
213 | 213 | } |
214 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
214 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
215 | 215 | /*@var $reg_row EE_Registration */ |
216 | - foreach($reg_fields_to_include as $field_name){ |
|
216 | + foreach ($reg_fields_to_include as $field_name) { |
|
217 | 217 | $field = $reg_model->field_settings_for($field_name); |
218 | - if($field_name == 'REG_final_price'){ |
|
219 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
220 | - }elseif( $field_name == 'REG_count' ){ |
|
221 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
222 | - }elseif( $field_name == 'REG_date' ) { |
|
223 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
224 | - }else{ |
|
225 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
218 | + if ($field_name == 'REG_final_price') { |
|
219 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
220 | + }elseif ($field_name == 'REG_count') { |
|
221 | + $value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
222 | + }elseif ($field_name == 'REG_date') { |
|
223 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
224 | + } else { |
|
225 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
226 | 226 | } |
227 | 227 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
228 | - if($field_name == 'REG_final_price'){ |
|
228 | + if ($field_name == 'REG_final_price') { |
|
229 | 229 | //add a column named Currency after the final price |
230 | 230 | $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | //get pretty status |
234 | - $stati = \EEM_Status::instance()->localized_status( array( |
|
235 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
236 | - $reg_row[ 'TransactionTable.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
234 | + $stati = \EEM_Status::instance()->localized_status(array( |
|
235 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
236 | + $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso') ), |
|
237 | 237 | FALSE, |
238 | - 'sentence' ); |
|
239 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
238 | + 'sentence'); |
|
239 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
240 | 240 | //get pretty transaction status |
241 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'TransactionTable.STS_ID' ] ]; |
|
242 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'TransactionTable.TXN_total' ], 'localized_float' ) : '0.00'; |
|
243 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'TransactionTable.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
241 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
242 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
243 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
244 | 244 | $payment_methods = array(); |
245 | 245 | $gateway_txn_ids_etc = array(); |
246 | 246 | $payment_times = array(); |
247 | - if( $is_primary_reg && $reg_row[ 'TransactionTable.TXN_ID' ] ){ |
|
247 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
248 | 248 | $payments_info = \EEM_Payment::instance()->get_all_wpdb_results( |
249 | 249 | array( |
250 | 250 | array( |
251 | - 'TXN_ID' => $reg_row[ 'TransactionTable.TXN_ID' ], |
|
251 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
252 | 252 | 'STS_ID' => \EEM_Payment::status_id_approved |
253 | 253 | ), |
254 | - 'force_join' => array( 'Payment_Method' ), |
|
254 | + 'force_join' => array('Payment_Method'), |
|
255 | 255 | |
256 | 256 | ), |
257 | 257 | ARRAY_A, |
258 | 258 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
259 | 259 | |
260 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
261 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
262 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
263 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
260 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
261 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
262 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
263 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | } |
267 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
268 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
269 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
267 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
268 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
269 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
270 | 270 | |
271 | 271 | //get whether or not the user has checked in |
272 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
272 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
273 | 273 | //get ticket of registration and its price |
274 | 274 | $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
275 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
276 | - $ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
275 | + if ($reg_row['Ticket.TKT_ID']) { |
|
276 | + $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
277 | 277 | $datetimes_strings = array(); |
278 | - foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){ |
|
279 | - $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
278 | + foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) { |
|
279 | + $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | } else { |
283 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
284 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
283 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
284 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
285 | 285 | } |
286 | 286 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
287 | 287 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
288 | 288 | //get datetime(s) of registration |
289 | 289 | |
290 | 290 | //add attendee columns |
291 | - foreach($att_fields_to_include as $att_field_name){ |
|
291 | + foreach ($att_fields_to_include as $att_field_name) { |
|
292 | 292 | $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
293 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
294 | - if($att_field_name == 'STA_ID'){ |
|
295 | - $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
296 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
297 | - $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
298 | - }else{ |
|
299 | - $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
293 | + if ($reg_row['Attendee_CPT.ID']) { |
|
294 | + if ($att_field_name == 'STA_ID') { |
|
295 | + $value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
296 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
297 | + $value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
298 | + } else { |
|
299 | + $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
300 | 300 | } |
301 | - }else{ |
|
301 | + } else { |
|
302 | 302 | $value = ''; |
303 | 303 | } |
304 | 304 | |
305 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
305 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | //make sure each registration has the same questions in the same order |
309 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
310 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
311 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
309 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
310 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
311 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | $answers = \EEM_Answer::instance()->get_all_wpdb_results( |
315 | 315 | array( |
316 | - array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), |
|
317 | - 'force_join' => array( 'Question' ) |
|
316 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
317 | + 'force_join' => array('Question') |
|
318 | 318 | ) |
319 | 319 | ); |
320 | 320 | //now fill out the questions THEY answered |
321 | - foreach( $answers as $answer_row ){ |
|
322 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
321 | + foreach ($answers as $answer_row) { |
|
322 | + if ($answer_row['Question.QST_ID']) { |
|
323 | 323 | $question_label = \EEH_Export::prepare_value_from_db_for_display( |
324 | 324 | \EEM_Question::instance(), |
325 | 325 | 'QST_admin_label', |
326 | - $answer_row[ 'Question.QST_admin_label' ] |
|
326 | + $answer_row['Question.QST_admin_label'] |
|
327 | 327 | ); |
328 | 328 | } else { |
329 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
329 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
330 | 330 | } |
331 | - if ( isset( $answer_row[ 'Question.QST_type' ] ) |
|
332 | - && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state |
|
331 | + if (isset($answer_row['Question.QST_type']) |
|
332 | + && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
333 | 333 | ) { |
334 | - $reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID( |
|
335 | - $answer_row[ 'Answer.ANS_value' ] |
|
334 | + $reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID( |
|
335 | + $answer_row['Answer.ANS_value'] |
|
336 | 336 | ); |
337 | 337 | } else { |
338 | - $reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display( |
|
338 | + $reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display( |
|
339 | 339 | \EEM_Answer::instance(), |
340 | 340 | 'ANS_value', |
341 | - $answer_row[ 'Answer.ANS_value' ] |
|
341 | + $answer_row['Answer.ANS_value'] |
|
342 | 342 | ); |
343 | 343 | } |
344 | 344 | } |
@@ -349,17 +349,17 @@ discard block |
||
349 | 349 | } |
350 | 350 | } |
351 | 351 | //if we couldn't export anything, we want to at least show the column headers |
352 | - if ( empty( $registrations_csv_ready_array ) ) { |
|
352 | + if (empty($registrations_csv_ready_array)) { |
|
353 | 353 | $reg_csv_array = array(); |
354 | 354 | $model_and_fields_to_include = array( |
355 | 355 | 'Registration' => $reg_fields_to_include, |
356 | 356 | 'Attendee' => $att_fields_to_include |
357 | 357 | ); |
358 | - foreach ( $model_and_fields_to_include as $model_name => $field_list ) { |
|
359 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
360 | - foreach ( $field_list as $field_name ) { |
|
361 | - $field = $model->field_settings_for( $field_name ); |
|
362 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null; |
|
358 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
359 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
360 | + foreach ($field_list as $field_name) { |
|
361 | + $field = $model->field_settings_for($field_name); |
|
362 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | $registrations_csv_ready_array[] = $reg_csv_array; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param int $event_id |
376 | 376 | * @return int |
377 | 377 | */ |
378 | - public function count_units_to_process( $event_id ) { |
|
378 | + public function count_units_to_process($event_id) { |
|
379 | 379 | //use the legacy filter |
380 | 380 | $query_params = apply_filters( |
381 | 381 | 'FHEE__EE_Export__report_registration_for_event', |
@@ -383,24 +383,24 @@ discard block |
||
383 | 383 | array( |
384 | 384 | 'OR' => array( |
385 | 385 | //don't include registrations from failed or abandoned transactions... |
386 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
386 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
387 | 387 | //unless the registration is approved, in which case include it regardless of transaction status |
388 | 388 | 'STS_ID' => \EEM_Registration::status_id_approved |
389 | 389 | ), |
390 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
390 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
391 | 391 | ), |
392 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
393 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
392 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
393 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
394 | 394 | 'caps' => \EEM_Base::caps_read_admin |
395 | 395 | ), |
396 | 396 | $event_id |
397 | 397 | ); |
398 | - if( $event_id ){ |
|
399 | - $query_params[0]['EVT_ID'] = $event_id; |
|
398 | + if ($event_id) { |
|
399 | + $query_params[0]['EVT_ID'] = $event_id; |
|
400 | 400 | } else { |
401 | - $query_params[ 'force_join' ][] = 'Event'; |
|
401 | + $query_params['force_join'][] = 'Event'; |
|
402 | 402 | } |
403 | - return \EEM_Registration::instance()->count( $query_params ); |
|
403 | + return \EEM_Registration::instance()->count($query_params); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | * @param JobParameters $job_parameters |
412 | 412 | * @return boolean |
413 | 413 | */ |
414 | - public function cleanup_job( JobParameters $job_parameters ){ |
|
414 | + public function cleanup_job(JobParameters $job_parameters) { |
|
415 | 415 | $this->_file_helper->delete( |
416 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
416 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
417 | 417 | true, |
418 | 418 | 'd' |
419 | 419 | ); |
420 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
420 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @return string the assembled html string containing the tabbed content for display. |
47 | 47 | * @throws \EE_Error |
48 | 48 | */ |
49 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
49 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
50 | 50 | |
51 | 51 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
52 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
53 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
52 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
53 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we've got incoming data setup properly |
57 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
58 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
57 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
58 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
59 | 59 | |
60 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
60 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
61 | 61 | $all_tabs_content = ''; |
62 | 62 | |
63 | 63 | $index = 0; |
64 | - foreach ( $tabs as $tab ) { |
|
64 | + foreach ($tabs as $tab) { |
|
65 | 65 | $active = $index === 0 ? true : false; |
66 | 66 | $all_tabs .= self::tab($tab, $active); |
67 | 67 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
80 | 80 | |
81 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
81 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @throws \EE_Error |
103 | 103 | */ |
104 | 104 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
105 | - if ( empty($nav_tabs) ) |
|
106 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
105 | + if (empty($nav_tabs)) |
|
106 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
107 | 107 | |
108 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
109 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
108 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
109 | + foreach ($nav_tabs as $slug => $tab) { |
|
110 | 110 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
111 | 111 | } |
112 | 112 | $all_tabs .= '</h2>'; |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @param bool|string $css If string given then the generated tab will include that as the class. |
123 | 123 | * @return string html for tab |
124 | 124 | */ |
125 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
125 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
126 | 126 | $name = str_replace(' ', '-', $name); |
127 | 127 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
128 | - $class = $css ? $class . ' ' . $css : $class; |
|
129 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
130 | - $url = $url ? $url : '#' . $name; |
|
131 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
128 | + $class = $css ? $class.' '.$css : $class; |
|
129 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
130 | + $url = $url ? $url : '#'.$name; |
|
131 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
132 | 132 | return $tab; |
133 | 133 | } |
134 | 134 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | */ |
145 | 145 | private static function tab_content($name, $tab_content, $active = false) { |
146 | 146 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
147 | - $name = str_replace( ' ', '-', $name); |
|
148 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
149 | - $content .= "\t" . $tab_content . "\n"; |
|
147 | + $name = str_replace(' ', '-', $name); |
|
148 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
149 | + $content .= "\t".$tab_content."\n"; |
|
150 | 150 | $content .= '<div style="clear:both"></div></div>'; |
151 | 151 | return $content; |
152 | 152 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
173 | 173 | * @return string a html snippet of of all the formatted link elements. |
174 | 174 | */ |
175 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
176 | - $item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class ); |
|
177 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
175 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
176 | + $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
|
177 | + if ( ! is_array($item_array) || empty($item_array)) |
|
178 | 178 | return false; //get out we don't have even the basic thing we need! |
179 | 179 | |
180 | 180 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
186 | 186 | 'slug' => 'item_slug' |
187 | 187 | ); |
188 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
189 | - $list = '<ul class="' . $container_class . '">'; |
|
188 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
189 | + $list = '<ul class="'.$container_class.'">'; |
|
190 | 190 | |
191 | 191 | $ci = 1; |
192 | - foreach ( $item_array as $item ) { |
|
193 | - $item = wp_parse_args( $item, $defaults ); |
|
194 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
192 | + foreach ($item_array as $item) { |
|
193 | + $item = wp_parse_args($item, $defaults); |
|
194 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
195 | 195 | $list .= self::_text_link_item($item); |
196 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
196 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
197 | 197 | $list .= self::_text_link_item($sep); |
198 | 198 | $ci++; |
199 | 199 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | |
207 | - private static function _text_link_item( $item ) { |
|
207 | + private static function _text_link_item($item) { |
|
208 | 208 | //if this isn't an array then we're doing a separator |
209 | - if ( !is_array( $item ) ) { |
|
209 | + if ( ! is_array($item)) { |
|
210 | 210 | $label = $item; |
211 | 211 | $class = 'ee-text-link-sep'; |
212 | 212 | $href = ''; |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | extract($item); |
216 | 216 | } |
217 | 217 | |
218 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
218 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
219 | 219 | |
220 | - $content = '<li ' . $class . '>'; |
|
221 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
220 | + $content = '<li '.$class.'>'; |
|
221 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
222 | 222 | $content .= $label; |
223 | - $content .= !empty($href) ? '</a>' : ''; |
|
223 | + $content .= ! empty($href) ? '</a>' : ''; |
|
224 | 224 | $content .= '</li>'; |
225 | 225 | return $content; |
226 | 226 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | * @throws \EE_Error |
103 | 104 | */ |
104 | 105 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
105 | - if ( empty($nav_tabs) ) |
|
106 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
106 | + if ( empty($nav_tabs) ) { |
|
107 | + throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
108 | + } |
|
107 | 109 | |
108 | 110 | $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
109 | 111 | foreach ( $nav_tabs as $slug => $tab ) { |
@@ -174,8 +176,10 @@ discard block |
||
174 | 176 | */ |
175 | 177 | public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
176 | 178 | $item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class ); |
177 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
178 | - return false; //get out we don't have even the basic thing we need! |
|
179 | + if ( !is_array($item_array) || empty( $item_array ) ) { |
|
180 | + return false; |
|
181 | + } |
|
182 | + //get out we don't have even the basic thing we need! |
|
179 | 183 | |
180 | 184 | |
181 | 185 | $defaults = array( |
@@ -193,8 +197,9 @@ discard block |
||
193 | 197 | $item = wp_parse_args( $item, $defaults ); |
194 | 198 | $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
195 | 199 | $list .= self::_text_link_item($item); |
196 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
197 | - $list .= self::_text_link_item($sep); |
|
200 | + if ( !empty($sep) && $ci != count($item_array) ) { |
|
201 | + $list .= self::_text_link_item($sep); |
|
202 | + } |
|
198 | 203 | $ci++; |
199 | 204 | } |
200 | 205 |
@@ -34,37 +34,37 @@ |
||
34 | 34 | */ |
35 | 35 | class Post implements RequestMethod |
36 | 36 | { |
37 | - /** |
|
38 | - * URL to which requests are POSTed. |
|
39 | - * @const string |
|
40 | - */ |
|
41 | - const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
37 | + /** |
|
38 | + * URL to which requests are POSTed. |
|
39 | + * @const string |
|
40 | + */ |
|
41 | + const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Submit the POST request with the specified parameters. |
|
45 | - * |
|
46 | - * @param RequestParameters $params Request parameters |
|
47 | - * @return string Body of the reCAPTCHA response |
|
48 | - */ |
|
49 | - public function submit(RequestParameters $params) |
|
50 | - { |
|
51 | - /** |
|
52 | - * PHP 5.6.0 changed the way you specify the peer name for SSL context options. |
|
53 | - * Using "CN_name" will still work, but it will raise deprecated errors. |
|
54 | - */ |
|
55 | - $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name'; |
|
56 | - $options = array( |
|
57 | - 'http' => array( |
|
58 | - 'header' => "Content-type: application/x-www-form-urlencoded\r\n", |
|
59 | - 'method' => 'POST', |
|
60 | - 'content' => $params->toQueryString(), |
|
61 | - // Force the peer to validate (not needed in 5.6.0+, but still works |
|
62 | - 'verify_peer' => true, |
|
63 | - // Force the peer validation to use www.google.com |
|
64 | - $peer_key => 'www.google.com', |
|
65 | - ), |
|
66 | - ); |
|
67 | - $context = stream_context_create($options); |
|
68 | - return file_get_contents(self::SITE_VERIFY_URL, false, $context); |
|
69 | - } |
|
43 | + /** |
|
44 | + * Submit the POST request with the specified parameters. |
|
45 | + * |
|
46 | + * @param RequestParameters $params Request parameters |
|
47 | + * @return string Body of the reCAPTCHA response |
|
48 | + */ |
|
49 | + public function submit(RequestParameters $params) |
|
50 | + { |
|
51 | + /** |
|
52 | + * PHP 5.6.0 changed the way you specify the peer name for SSL context options. |
|
53 | + * Using "CN_name" will still work, but it will raise deprecated errors. |
|
54 | + */ |
|
55 | + $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name'; |
|
56 | + $options = array( |
|
57 | + 'http' => array( |
|
58 | + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", |
|
59 | + 'method' => 'POST', |
|
60 | + 'content' => $params->toQueryString(), |
|
61 | + // Force the peer to validate (not needed in 5.6.0+, but still works |
|
62 | + 'verify_peer' => true, |
|
63 | + // Force the peer validation to use www.google.com |
|
64 | + $peer_key => 'www.google.com', |
|
65 | + ), |
|
66 | + ); |
|
67 | + $context = stream_context_create($options); |
|
68 | + return file_get_contents(self::SITE_VERIFY_URL, false, $context); |
|
69 | + } |
|
70 | 70 | } |
@@ -5,42 +5,42 @@ |
||
5 | 5 | <table class="admin-primary-mbox-tbl"> |
6 | 6 | <thead> |
7 | 7 | <tr> |
8 | - <th class="jst-left"><?php esc_html_e( 'Event Name', 'event_espresso' );?></th> |
|
9 | - <th class="jst-left"><?php esc_html_e( 'REG ID', 'event_espresso' );?></th> |
|
10 | - <th class="jst-left"><?php esc_html_e( 'TXN ID', 'event_espresso' );?></th> |
|
11 | - <th class="jst-left"><?php esc_html_e( 'Reg Code', 'event_espresso' );?></th> |
|
12 | - <th class="jst-rght"><?php esc_html_e( 'Ticket Price', 'event_espresso' );?></th> |
|
8 | + <th class="jst-left"><?php esc_html_e('Event Name', 'event_espresso'); ?></th> |
|
9 | + <th class="jst-left"><?php esc_html_e('REG ID', 'event_espresso'); ?></th> |
|
10 | + <th class="jst-left"><?php esc_html_e('TXN ID', 'event_espresso'); ?></th> |
|
11 | + <th class="jst-left"><?php esc_html_e('Reg Code', 'event_espresso'); ?></th> |
|
12 | + <th class="jst-rght"><?php esc_html_e('Ticket Price', 'event_espresso'); ?></th> |
|
13 | 13 | </tr> |
14 | 14 | </thead> |
15 | 15 | <tbody> |
16 | - <?php foreach( $registrations as $registration ) : ?> |
|
16 | + <?php foreach ($registrations as $registration) : ?> |
|
17 | 17 | <tr> |
18 | 18 | <td class="jst-left"> |
19 | 19 | <?php |
20 | - $event_url = add_query_arg( array( 'action' => 'edit', 'post' => $registration->event_ID() ), admin_url( 'admin.php?page=espresso_events' )); |
|
21 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $registration->event_ID() ) ? '<a href="'. $event_url .'" title="'. esc_attr__( 'Edit Event', 'event_espresso' ) .'">' . $registration->event_name() . '</a>' : $registration->event_name(); |
|
20 | + $event_url = add_query_arg(array('action' => 'edit', 'post' => $registration->event_ID()), admin_url('admin.php?page=espresso_events')); |
|
21 | + echo EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $registration->event_ID()) ? '<a href="'.$event_url.'" title="'.esc_attr__('Edit Event', 'event_espresso').'">'.$registration->event_name().'</a>' : $registration->event_name(); |
|
22 | 22 | ?> |
23 | 23 | </td> |
24 | 24 | <td class="jst-left"> |
25 | 25 | <?php |
26 | - $reg_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
|
27 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $registration->ID() ) ? ' |
|
28 | - <a href="'.$reg_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . |
|
29 | - esc_html__( 'View Registration', 'event_espresso' ) . |
|
26 | + $reg_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL); |
|
27 | + echo EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? ' |
|
28 | + <a href="'.$reg_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'. |
|
29 | + esc_html__('View Registration', 'event_espresso'). |
|
30 | 30 | '</a>' : $registration->ID(); |
31 | 31 | ?> |
32 | 32 | </td> |
33 | 33 | <td class="jst-left"> |
34 | 34 | <?php |
35 | - $txn_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID() ), TXN_ADMIN_URL ); |
|
36 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ? ' |
|
37 | - <a href="'.$txn_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '">' . |
|
38 | - sprintf( esc_html__('View Transaction %d', 'event_espresso'), $registration->transaction_ID() ) . |
|
35 | + $txn_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID()), TXN_ADMIN_URL); |
|
36 | + echo EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? ' |
|
37 | + <a href="'.$txn_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'">'. |
|
38 | + sprintf(esc_html__('View Transaction %d', 'event_espresso'), $registration->transaction_ID()). |
|
39 | 39 | '</a>' : $registration->transaction_ID(); |
40 | 40 | ?> |
41 | 41 | </td> |
42 | - <td class="jst-left"><?php echo $registration->reg_code();?></td> |
|
43 | - <td class="jst-rght"><?php echo EEH_Template::format_currency( $registration->final_price() );?></td> |
|
42 | + <td class="jst-left"><?php echo $registration->reg_code(); ?></td> |
|
43 | + <td class="jst-rght"><?php echo EEH_Template::format_currency($registration->final_price()); ?></td> |
|
44 | 44 | </tr> |
45 | 45 | <?php endforeach; ?> |
46 | 46 | </tbody> |