@@ -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 |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | * @param array $request_data |
97 | 97 | * @param array $extra_data |
98 | 98 | */ |
99 | - function __construct( $job_id, $classname, $request_data, $extra_data = array() ) { |
|
100 | - $this->set_job_id( $job_id ); |
|
101 | - $this->set_classname( $classname ); |
|
102 | - $this->set_request_data( $request_data ); |
|
103 | - $this->set_extra_data( $extra_data ); |
|
104 | - $this->set_status( JobParameters::status_continue ); |
|
99 | + function __construct($job_id, $classname, $request_data, $extra_data = array()) { |
|
100 | + $this->set_job_id($job_id); |
|
101 | + $this->set_classname($classname); |
|
102 | + $this->set_request_data($request_data); |
|
103 | + $this->set_extra_data($extra_data); |
|
104 | + $this->set_status(JobParameters::status_continue); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | * @param boolean $first |
127 | 127 | * @return boolean success |
128 | 128 | */ |
129 | - function save( $first = false ) { |
|
130 | - $object_vars = wp_json_encode( get_object_vars( $this ) ); |
|
131 | - if( $first ) { |
|
132 | - return add_option( $this->option_name(), $object_vars, null, 'no' ); |
|
133 | - } else{ |
|
134 | - return update_option( $this->option_name(), $object_vars ); |
|
129 | + function save($first = false) { |
|
130 | + $object_vars = wp_json_encode(get_object_vars($this)); |
|
131 | + if ($first) { |
|
132 | + return add_option($this->option_name(), $object_vars, null, 'no'); |
|
133 | + } else { |
|
134 | + return update_option($this->option_name(), $object_vars); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return boolean |
144 | 144 | */ |
145 | 145 | function delete() { |
146 | - return delete_option( $this->option_name() ); |
|
146 | + return delete_option($this->option_name()); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -154,26 +154,26 @@ discard block |
||
154 | 154 | * @return JobParameters |
155 | 155 | * @throws BatchRequestException |
156 | 156 | */ |
157 | - static function load( $job_id ) { |
|
158 | - $job_parameter_vars = json_decode( get_option( JobParameters::wp_option_prefix . $job_id ), true ); |
|
159 | - if( |
|
160 | - ! is_array( $job_parameter_vars ) || |
|
161 | - ! isset( $job_parameter_vars[ '_classname' ] ) || |
|
162 | - ! isset( $job_parameter_vars[ '_request_data' ] ) |
|
157 | + static function load($job_id) { |
|
158 | + $job_parameter_vars = json_decode(get_option(JobParameters::wp_option_prefix.$job_id), true); |
|
159 | + if ( |
|
160 | + ! is_array($job_parameter_vars) || |
|
161 | + ! isset($job_parameter_vars['_classname']) || |
|
162 | + ! isset($job_parameter_vars['_request_data']) |
|
163 | 163 | ) { |
164 | 164 | throw new BatchRequestException( |
165 | 165 | sprintf( |
166 | 166 | __('Could not retrieve job %1$s from the Wordpress options table, and so the job could not continue. The wordpress option was %2$s', 'event_espresso'), |
167 | 167 | $job_id, |
168 | - get_option( JobParameters::wp_option_prefix . $job_id ) |
|
168 | + get_option(JobParameters::wp_option_prefix.$job_id) |
|
169 | 169 | ) |
170 | 170 | ); |
171 | 171 | } |
172 | 172 | $job_parameters = new JobParameters( |
173 | 173 | $job_id, |
174 | - $job_parameter_vars[ '_classname' ], |
|
175 | - $job_parameter_vars[ '_request_data'] ); |
|
176 | - foreach( $job_parameter_vars as $key => $value ) { |
|
174 | + $job_parameter_vars['_classname'], |
|
175 | + $job_parameter_vars['_request_data'] ); |
|
176 | + foreach ($job_parameter_vars as $key => $value) { |
|
177 | 177 | $job_parameters->$key = $value; |
178 | 178 | } |
179 | 179 | return $job_parameters; |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param string|array $default |
218 | 218 | * @return string|array |
219 | 219 | */ |
220 | - function request_datum( $key, $default = '' ) { |
|
221 | - if( isset( $this->_request_data[ $key ] ) ) { |
|
222 | - return $this->_request_data[ $key ]; |
|
220 | + function request_datum($key, $default = '') { |
|
221 | + if (isset($this->_request_data[$key])) { |
|
222 | + return $this->_request_data[$key]; |
|
223 | 223 | } else { |
224 | 224 | return $default; |
225 | 225 | } |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | * @param string|array $default |
234 | 234 | * @return string|array |
235 | 235 | */ |
236 | - function extra_datum( $key, $default = '' ) { |
|
237 | - if( isset( $this->_extra_data[ $key ] ) ) { |
|
238 | - return $this->_extra_data[ $key ]; |
|
236 | + function extra_datum($key, $default = '') { |
|
237 | + if (isset($this->_extra_data[$key])) { |
|
238 | + return $this->_extra_data[$key]; |
|
239 | 239 | } else { |
240 | 240 | return $default; |
241 | 241 | } |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $key |
249 | 249 | * @param string|int|array|null $value almost any extra data you want to store |
250 | 250 | */ |
251 | - function add_extra_data( $key, $value ) { |
|
252 | - $this->_extra_data[ $key ] = $value; |
|
251 | + function add_extra_data($key, $value) { |
|
252 | + $this->_extra_data[$key] = $value; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * Sets the job size. You decide what units to use |
279 | 279 | * @param int $size |
280 | 280 | */ |
281 | - function set_job_size( $size ) { |
|
281 | + function set_job_size($size) { |
|
282 | 282 | $this->_job_size = $size; |
283 | 283 | } |
284 | 284 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param int $newly_processed |
300 | 300 | * @return int updated units processed |
301 | 301 | */ |
302 | - function mark_processed( $newly_processed ) { |
|
302 | + function mark_processed($newly_processed) { |
|
303 | 303 | $this->_units_processed += $newly_processed; |
304 | 304 | return $this->_units_processed; |
305 | 305 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * Sets the total count of units processed. You might prefer to use mark_processed |
311 | 311 | * @param int $total_units_processed |
312 | 312 | */ |
313 | - function set_units_processed( $total_units_processed ) { |
|
313 | + function set_units_processed($total_units_processed) { |
|
314 | 314 | $this->_units_processed = $total_units_processed; |
315 | 315 | } |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * Sets the job's ID |
321 | 321 | * @param string $job_id |
322 | 322 | */ |
323 | - function set_job_id( $job_id ) { |
|
323 | + function set_job_id($job_id) { |
|
324 | 324 | $this->_job_id = $job_id; |
325 | 325 | } |
326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * sets the classname |
331 | 331 | * @param string $classname |
332 | 332 | */ |
333 | - function set_classname( $classname ) { |
|
333 | + function set_classname($classname) { |
|
334 | 334 | $this->_classname = $classname; |
335 | 335 | } |
336 | 336 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * Sets the request data |
341 | 341 | * @param array $request_data |
342 | 342 | */ |
343 | - function set_request_data( $request_data ) { |
|
343 | + function set_request_data($request_data) { |
|
344 | 344 | $this->_request_data = $request_data; |
345 | 345 | } |
346 | 346 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * Sets the array of extra data we want to store on this request |
351 | 351 | * @param array $extra_data |
352 | 352 | */ |
353 | - function set_extra_data( $extra_data ) { |
|
353 | + function set_extra_data($extra_data) { |
|
354 | 354 | $this->_extra_data = $extra_data; |
355 | 355 | } |
356 | 356 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @return string |
362 | 362 | */ |
363 | 363 | function option_name() { |
364 | - return JobParameters::wp_option_prefix . $this->job_id(); |
|
364 | + return JobParameters::wp_option_prefix.$this->job_id(); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @param string $status on eof JobParameters::valid_stati() |
382 | 382 | */ |
383 | - public function set_status( $status ) { |
|
383 | + public function set_status($status) { |
|
384 | 384 | $this->_status = $status; |
385 | 385 | } |
386 | 386 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class JobParameters |
|
5 | - * |
|
6 | - * Class for storing information about a job. Takes care of serializing the |
|
7 | - * data for storing in a wordpress option |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage batch |
|
11 | - * @author Mike Nelson |
|
12 | - * @since 4.8.26 |
|
13 | - * |
|
14 | - */ |
|
3 | + * |
|
4 | + * Class JobParameters |
|
5 | + * |
|
6 | + * Class for storing information about a job. Takes care of serializing the |
|
7 | + * data for storing in a wordpress option |
|
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 | |
17 | 17 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
@@ -214,7 +214,7 @@ |
||
214 | 214 | /** |
215 | 215 | * Gets a single item from the request data |
216 | 216 | * @param string $key |
217 | - * @param string|array $default |
|
217 | + * @param string $default |
|
218 | 218 | * @return string|array |
219 | 219 | */ |
220 | 220 | function request_datum( $key, $default = '' ) { |
@@ -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 |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | use EventEspressoBatchRequest\Helpers\JobParameters; |
18 | 18 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
19 | 19 | |
20 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
21 | - exit( 'No direct script access allowed' ); |
|
20 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | + exit('No direct script access allowed'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @throws BatchRequestException |
35 | 35 | * @return JobStepResponse |
36 | 36 | */ |
37 | - abstract public function create_job( JobParameters $job_parameters ); |
|
37 | + abstract public function create_job(JobParameters $job_parameters); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Performs another step of the job |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return JobStepResponse |
45 | 45 | * @throws BatchRequestException |
46 | 46 | */ |
47 | - abstract public function continue_job( JobParameters $job_parameters, $batch_size = 50 ); |
|
47 | + abstract public function continue_job(JobParameters $job_parameters, $batch_size = 50); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | |
@@ -55,6 +55,6 @@ discard block |
||
55 | 55 | * @return JobStepResponse |
56 | 56 | * @throws BatchRequestException |
57 | 57 | */ |
58 | - abstract public function cleanup_job( JobParameters $job_parameters ); |
|
58 | + abstract public function cleanup_job(JobParameters $job_parameters); |
|
59 | 59 | } |
60 | 60 |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | |
17 | 17 | use EventEspressoBatchRequest\Helpers\BatchRequestException; |
18 | 18 | |
19 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
20 | - exit( 'No direct script access allowed' ); |
|
19 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
20 | + exit('No direct script access allowed'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected $_file_helper = null; |
31 | 31 | const temp_folder_name = 'batch_temp_folder'; |
32 | - public function __construct( EEHI_File $file_helper = null ) { |
|
33 | - if( ! $file_helper ) { |
|
32 | + public function __construct(EEHI_File $file_helper = null) { |
|
33 | + if ( ! $file_helper) { |
|
34 | 34 | $this->_file_helper = new \EEH_File(); |
35 | 35 | } |
36 | 36 | } |
@@ -45,30 +45,30 @@ discard block |
||
45 | 45 | * @return string |
46 | 46 | * @throws BatchRequestException |
47 | 47 | */ |
48 | - public function create_file_from_job_with_name( $job_id, $filename ) { |
|
48 | + public function create_file_from_job_with_name($job_id, $filename) { |
|
49 | 49 | $filepath = ''; |
50 | - try{ |
|
50 | + try { |
|
51 | 51 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
52 | - EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name |
|
52 | + EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name |
|
53 | 53 | ); |
54 | - if ( $success ) { |
|
54 | + if ($success) { |
|
55 | 55 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
56 | - EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id |
|
56 | + EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name.DS.$job_id |
|
57 | 57 | ); |
58 | 58 | } |
59 | - if( $success ) { |
|
60 | - $filepath = EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id . DS. $filename; |
|
61 | - $success = $this->_file_helper->ensure_file_exists_and_is_writable( $filepath ); |
|
59 | + if ($success) { |
|
60 | + $filepath = EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name.DS.$job_id.DS.$filename; |
|
61 | + $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
62 | 62 | } |
63 | 63 | //those methods normally fail with an exception, but if not, let's do it |
64 | - if( ! $success ) { |
|
65 | - throw new \EE_Error( 'could_not_create_temp_file', |
|
66 | - __( 'An unknown error occurred', 'event_espresso' )); |
|
64 | + if ( ! $success) { |
|
65 | + throw new \EE_Error('could_not_create_temp_file', |
|
66 | + __('An unknown error occurred', 'event_espresso')); |
|
67 | 67 | } |
68 | - } catch( \EE_Error $e ) { |
|
68 | + } catch (\EE_Error $e) { |
|
69 | 69 | throw new BatchRequestException( |
70 | 70 | sprintf( |
71 | - __( 'Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso' ), |
|
71 | + __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
72 | 72 | $job_id, |
73 | 73 | $e->getMessage() |
74 | 74 | ), |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @param string $filepath |
85 | 85 | * @return string url to file |
86 | 86 | */ |
87 | - public function get_url_to_file( $filepath ) { |
|
88 | - return str_replace( EVENT_ESPRESSO_UPLOAD_DIR, EVENT_ESPRESSO_UPLOAD_URL, $filepath ); |
|
87 | + public function get_url_to_file($filepath) { |
|
88 | + return str_replace(EVENT_ESPRESSO_UPLOAD_DIR, EVENT_ESPRESSO_UPLOAD_URL, $filepath); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | use EventEspressoBatchRequest\Helpers\JobParameters; |
21 | 21 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
22 | 22 | |
23 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
24 | - exit( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
24 | + exit('No direct script access allowed'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @throws BatchRequestException |
36 | 36 | * @return JobStepResponse |
37 | 37 | */ |
38 | - public function create_job( JobParameters $job_parameters ); |
|
38 | + public function create_job(JobParameters $job_parameters); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Performs another step of the job |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return JobStepResponse |
45 | 45 | * @throws BatchRequestException |
46 | 46 | */ |
47 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ); |
|
47 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Performs any clean-up logic when we know the job is completed |
@@ -52,5 +52,5 @@ discard block |
||
52 | 52 | * @return JobStepResponse |
53 | 53 | * @throws BatchRequestException |
54 | 54 | */ |
55 | - public function cleanup_job( JobParameters $job_parameters ); |
|
55 | + public function cleanup_job(JobParameters $job_parameters); |
|
56 | 56 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if( ! $event_slug ) { |
76 | 76 | $event_slug = __( 'unknown', 'event_espresso' ); |
77 | 77 | } |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | $event_slug = __( 'all', 'event_espresso' ); |
80 | 80 | } |
81 | 81 | return sprintf( "registrations-for-%s.csv", $event_slug ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ); |
163 | 163 | if( $event_id ){ |
164 | 164 | $query_params[0]['EVT_ID'] = $event_id; |
165 | - }else{ |
|
165 | + } else{ |
|
166 | 166 | $query_params[ 'force_join' ][] = 'Event'; |
167 | 167 | } |
168 | 168 | $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $field = $reg_model->field_settings_for($field_name); |
192 | 192 | if($field_name == 'REG_final_price'){ |
193 | 193 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
194 | - }elseif( $field_name == 'REG_count' ){ |
|
194 | + } elseif( $field_name == 'REG_count' ){ |
|
195 | 195 | $value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
196 | - }elseif( $field_name == 'REG_date' ) { |
|
196 | + } elseif( $field_name == 'REG_date' ) { |
|
197 | 197 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
198 | - }else{ |
|
198 | + } else{ |
|
199 | 199 | $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
200 | 200 | } |
201 | 201 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | if( $reg_row[ 'Attendee_CPT.ID' ]){ |
268 | 268 | if($att_field_name == 'STA_ID'){ |
269 | 269 | $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
270 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
270 | + } elseif($att_field_name == 'CNT_ISO'){ |
|
271 | 271 | $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
272 | - }else{ |
|
272 | + } else{ |
|
273 | 273 | $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
274 | 274 | } |
275 | - }else{ |
|
275 | + } else{ |
|
276 | 276 | $value = ''; |
277 | 277 | } |
278 | 278 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * Gets the questions which are to be used for this report, so they |
92 | 92 | * can be remembered for later |
93 | 93 | * @param int|null $event_id |
94 | - * @return array of wpdb results for questions which are to be used for this report |
|
94 | + * @return \stdClass[] of wpdb results for questions which are to be used for this report |
|
95 | 95 | */ |
96 | 96 | protected function _get_questions_for_report( $event_id ) { |
97 | 97 | $question_query_params = array( |
@@ -410,7 +410,7 @@ discard block |
||
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,36 +35,36 @@ 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 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
60 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
58 | + $job_parameters->extra_datum('questions_data') ); |
|
59 | + \EE_Registry::instance()->load_helper('Export'); |
|
60 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
61 | 61 | //if we actually processed a row there, record it |
62 | - if( $job_parameters->job_size() ) { |
|
63 | - $job_parameters->mark_processed( 1 ); |
|
62 | + if ($job_parameters->job_size()) { |
|
63 | + $job_parameters->mark_processed(1); |
|
64 | 64 | } |
65 | 65 | return new JobStepResponse( |
66 | 66 | $job_parameters, |
67 | - __( 'Registrations report started successfully...', 'event_espresso' ) |
|
67 | + __('Registrations report started successfully...', 'event_espresso') |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | * @param int $event_id |
76 | 76 | * @return string |
77 | 77 | */ |
78 | - protected function get_filename_from_event( $event_id ) { |
|
79 | - if( $event_id ){ |
|
80 | - $event_slug = \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
81 | - if( ! $event_slug ) { |
|
82 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
78 | + protected function get_filename_from_event($event_id) { |
|
79 | + if ($event_id) { |
|
80 | + $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
81 | + if ( ! $event_slug) { |
|
82 | + $event_slug = __('unknown', 'event_espresso'); |
|
83 | 83 | } |
84 | - }else{ |
|
85 | - $event_slug = __( 'all', 'event_espresso' ); |
|
84 | + } else { |
|
85 | + $event_slug = __('all', 'event_espresso'); |
|
86 | 86 | } |
87 | - return sprintf( "registrations-for-%s.csv", $event_slug ); |
|
87 | + return sprintf("registrations-for-%s.csv", $event_slug); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @param int|null $event_id |
94 | 94 | * @return array of wpdb results for questions which are to be used for this report |
95 | 95 | */ |
96 | - protected function _get_questions_for_report( $event_id ) { |
|
96 | + protected function _get_questions_for_report($event_id) { |
|
97 | 97 | $question_query_params = array( |
98 | 98 | array( |
99 | - 'Answer.ANS_ID' => array( 'IS_NOT_NULL' ), |
|
99 | + 'Answer.ANS_ID' => array('IS_NOT_NULL'), |
|
100 | 100 | ), |
101 | - 'group_by' => array( 'QST_ID' ) |
|
101 | + 'group_by' => array('QST_ID') |
|
102 | 102 | ); |
103 | - if( $event_id ) { |
|
103 | + if ($event_id) { |
|
104 | 104 | $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id; |
105 | 105 | } |
106 | - return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params ); |
|
106 | + return \EEM_Question::instance()->get_all_wpdb_results($question_query_params); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -116,28 +116,28 @@ discard block |
||
116 | 116 | * @return JobStepResponse |
117 | 117 | * @throws \EE_Error |
118 | 118 | */ |
119 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) { |
|
119 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
|
120 | 120 | $csv_data = $this->get_csv_data_for( |
121 | - $job_parameters->request_datum( 'EVT_ID', '0'), |
|
121 | + $job_parameters->request_datum('EVT_ID', '0'), |
|
122 | 122 | $job_parameters->units_processed(), |
123 | 123 | $batch_size, |
124 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
125 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
126 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
127 | - $units_processed = count( $csv_data ); |
|
128 | - $job_parameters->mark_processed( $units_processed ); |
|
124 | + $job_parameters->extra_datum('questions_data') ); |
|
125 | + \EE_Registry::instance()->load_helper('Export'); |
|
126 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
127 | + $units_processed = count($csv_data); |
|
128 | + $job_parameters->mark_processed($units_processed); |
|
129 | 129 | $extra_response_data = array( |
130 | 130 | 'file_url' => '' |
131 | 131 | ); |
132 | - if( $units_processed < $batch_size ) { |
|
133 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
134 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
132 | + if ($units_processed < $batch_size) { |
|
133 | + $job_parameters->set_status(JobParameters::status_complete); |
|
134 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
135 | 135 | } |
136 | 136 | return new JobStepResponse( |
137 | 137 | $job_parameters, |
138 | 138 | sprintf( |
139 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
140 | - count( $csv_data ) ), |
|
139 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
140 | + count($csv_data) ), |
|
141 | 141 | $extra_response_data ); |
142 | 142 | } |
143 | 143 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @return array top-level keys are numeric, next-level keys are column headers |
151 | 151 | * |
152 | 152 | */ |
153 | - function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) { |
|
154 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
153 | + function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) { |
|
154 | + \EE_Registry::instance()->load_helper('Export'); |
|
155 | 155 | $reg_fields_to_include = array( |
156 | 156 | 'TXN_ID', |
157 | 157 | 'ATT_ID', |
@@ -182,165 +182,165 @@ discard block |
||
182 | 182 | array( |
183 | 183 | 'OR' => array( |
184 | 184 | //don't include registrations from failed or abandoned transactions... |
185 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
185 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
186 | 186 | //unless the registration is approved, in which case include it regardless of transaction status |
187 | 187 | 'STS_ID' => \EEM_Registration::status_id_approved |
188 | 188 | ), |
189 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
189 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
190 | 190 | ), |
191 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
192 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
193 | - 'limit' => array( $offset, $limit ), |
|
191 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
192 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
193 | + 'limit' => array($offset, $limit), |
|
194 | 194 | ), |
195 | 195 | $event_id |
196 | 196 | ); |
197 | - if( $event_id ){ |
|
198 | - $query_params[0]['EVT_ID'] = $event_id; |
|
199 | - }else{ |
|
200 | - $query_params[ 'force_join' ][] = 'Event'; |
|
197 | + if ($event_id) { |
|
198 | + $query_params[0]['EVT_ID'] = $event_id; |
|
199 | + } else { |
|
200 | + $query_params['force_join'][] = 'Event'; |
|
201 | 201 | } |
202 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
202 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
203 | 203 | //get all questions which relate to someone in this group |
204 | 204 | $registration_ids = array(); |
205 | - foreach( $registration_rows as $reg_row ) { |
|
206 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
205 | + foreach ($registration_rows as $reg_row) { |
|
206 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
207 | 207 | } |
208 | 208 | |
209 | - foreach($registration_rows as $reg_row){ |
|
210 | - if ( is_array( $reg_row ) ) { |
|
209 | + foreach ($registration_rows as $reg_row) { |
|
210 | + if (is_array($reg_row)) { |
|
211 | 211 | $reg_csv_array = array(); |
212 | - if( ! $event_id ){ |
|
212 | + if ( ! $event_id) { |
|
213 | 213 | //get the event's name and Id |
214 | - $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' ] ); |
|
214 | + $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']); |
|
215 | 215 | } |
216 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
216 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
217 | 217 | /*@var $reg_row EE_Registration */ |
218 | - foreach($reg_fields_to_include as $field_name){ |
|
218 | + foreach ($reg_fields_to_include as $field_name) { |
|
219 | 219 | $field = $reg_model->field_settings_for($field_name); |
220 | - if($field_name == 'REG_final_price'){ |
|
221 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
222 | - }elseif( $field_name == 'REG_count' ){ |
|
223 | - $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' ] ) ); |
|
224 | - }elseif( $field_name == 'REG_date' ) { |
|
225 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
226 | - }else{ |
|
227 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
220 | + if ($field_name == 'REG_final_price') { |
|
221 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
222 | + }elseif ($field_name == 'REG_count') { |
|
223 | + $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'])); |
|
224 | + }elseif ($field_name == 'REG_date') { |
|
225 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
226 | + } else { |
|
227 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
228 | 228 | } |
229 | 229 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
230 | - if($field_name == 'REG_final_price'){ |
|
230 | + if ($field_name == 'REG_final_price') { |
|
231 | 231 | //add a column named Currency after the final price |
232 | 232 | $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | //get pretty status |
236 | - $stati = \EEM_Status::instance()->localized_status( array( |
|
237 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
238 | - $reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
236 | + $stati = \EEM_Status::instance()->localized_status(array( |
|
237 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
238 | + $reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ), |
|
239 | 239 | FALSE, |
240 | - 'sentence' ); |
|
241 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
240 | + 'sentence'); |
|
241 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
242 | 242 | //get pretty transaction status |
243 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ]; |
|
244 | - $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[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00'; |
|
245 | - $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[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
243 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']]; |
|
244 | + $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['Transaction.TXN_total'], 'localized_float') : '0.00'; |
|
245 | + $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['Transaction.TXN_paid'], 'localized_float') : '0.00'; |
|
246 | 246 | $payment_methods = array(); |
247 | 247 | $gateway_txn_ids_etc = array(); |
248 | 248 | $payment_times = array(); |
249 | - if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){ |
|
249 | + if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) { |
|
250 | 250 | $payments_info = \EEM_Payment::instance()->get_all_wpdb_results( |
251 | 251 | array( |
252 | 252 | array( |
253 | - 'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ], |
|
253 | + 'TXN_ID' => $reg_row['Transaction.TXN_ID'], |
|
254 | 254 | 'STS_ID' => \EEM_Payment::status_id_approved |
255 | 255 | ), |
256 | - 'force_join' => array( 'Payment_Method' ), |
|
256 | + 'force_join' => array('Payment_Method'), |
|
257 | 257 | |
258 | 258 | ), |
259 | 259 | ARRAY_A, |
260 | 260 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
261 | 261 | |
262 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
263 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
264 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
265 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
262 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
263 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
264 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
265 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | } |
269 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
270 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
271 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
269 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
270 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
271 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
272 | 272 | |
273 | 273 | //get whether or not the user has checked in |
274 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
274 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
275 | 275 | //get ticket of registration and its price |
276 | 276 | $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
277 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
278 | - $ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
277 | + if ($reg_row['Ticket.TKT_ID']) { |
|
278 | + $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
279 | 279 | $datetimes_strings = array(); |
280 | - 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){ |
|
281 | - $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
280 | + 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) { |
|
281 | + $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | } else { |
285 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
286 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
285 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
286 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
287 | 287 | } |
288 | 288 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
289 | 289 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
290 | 290 | //get datetime(s) of registration |
291 | 291 | |
292 | 292 | //add attendee columns |
293 | - foreach($att_fields_to_include as $att_field_name){ |
|
293 | + foreach ($att_fields_to_include as $att_field_name) { |
|
294 | 294 | $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
295 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
296 | - if($att_field_name == 'STA_ID'){ |
|
297 | - $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
298 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
299 | - $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
300 | - }else{ |
|
301 | - $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
295 | + if ($reg_row['Attendee_CPT.ID']) { |
|
296 | + if ($att_field_name == 'STA_ID') { |
|
297 | + $value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
298 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
299 | + $value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
300 | + } else { |
|
301 | + $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
302 | 302 | } |
303 | - }else{ |
|
303 | + } else { |
|
304 | 304 | $value = ''; |
305 | 305 | } |
306 | 306 | |
307 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
307 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | //make sure each registration has the same questions in the same order |
311 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
312 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
313 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
311 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
312 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
313 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | $answers = \EEM_Answer::instance()->get_all_wpdb_results( |
317 | 317 | array( |
318 | - array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), |
|
319 | - 'force_join' => array( 'Question' ) |
|
318 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
319 | + 'force_join' => array('Question') |
|
320 | 320 | ) |
321 | 321 | ); |
322 | 322 | //now fill out the questions THEY answered |
323 | - foreach( $answers as $answer_row ){ |
|
324 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
323 | + foreach ($answers as $answer_row) { |
|
324 | + if ($answer_row['Question.QST_ID']) { |
|
325 | 325 | $question_label = \EEH_Export::prepare_value_from_db_for_display( |
326 | 326 | \EEM_Question::instance(), |
327 | 327 | 'QST_admin_label', |
328 | - $answer_row[ 'Question.QST_admin_label' ] |
|
328 | + $answer_row['Question.QST_admin_label'] |
|
329 | 329 | ); |
330 | 330 | } else { |
331 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
331 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
332 | 332 | } |
333 | - if ( isset( $answer_row[ 'Question.QST_type' ] ) |
|
334 | - && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state |
|
333 | + if (isset($answer_row['Question.QST_type']) |
|
334 | + && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
335 | 335 | ) { |
336 | - $reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID( |
|
337 | - $answer_row[ 'Answer.ANS_value' ] |
|
336 | + $reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID( |
|
337 | + $answer_row['Answer.ANS_value'] |
|
338 | 338 | ); |
339 | 339 | } else { |
340 | - $reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display( |
|
340 | + $reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display( |
|
341 | 341 | \EEM_Answer::instance(), |
342 | 342 | 'ANS_value', |
343 | - $answer_row[ 'Answer.ANS_value' ] |
|
343 | + $answer_row['Answer.ANS_value'] |
|
344 | 344 | ); |
345 | 345 | } |
346 | 346 | } |
@@ -351,17 +351,17 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | //if we couldn't export anything, we want to at least show the column headers |
354 | - if ( empty( $registrations_csv_ready_array ) ) { |
|
354 | + if (empty($registrations_csv_ready_array)) { |
|
355 | 355 | $reg_csv_array = array(); |
356 | 356 | $model_and_fields_to_include = array( |
357 | 357 | 'Registration' => $reg_fields_to_include, |
358 | 358 | 'Attendee' => $att_fields_to_include |
359 | 359 | ); |
360 | - foreach ( $model_and_fields_to_include as $model_name => $field_list ) { |
|
361 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
362 | - foreach ( $field_list as $field_name ) { |
|
363 | - $field = $model->field_settings_for( $field_name ); |
|
364 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null; |
|
360 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
361 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
362 | + foreach ($field_list as $field_name) { |
|
363 | + $field = $model->field_settings_for($field_name); |
|
364 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | $registrations_csv_ready_array[] = $reg_csv_array; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @param int $event_id |
378 | 378 | * @return int |
379 | 379 | */ |
380 | - public function count_units_to_process( $event_id ) { |
|
380 | + public function count_units_to_process($event_id) { |
|
381 | 381 | //use the legacy filter |
382 | 382 | $query_params = apply_filters( |
383 | 383 | 'FHEE__EE_Export__report_registration_for_event', |
@@ -385,23 +385,23 @@ discard block |
||
385 | 385 | array( |
386 | 386 | 'OR' => array( |
387 | 387 | //don't include registrations from failed or abandoned transactions... |
388 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
388 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
389 | 389 | //unless the registration is approved, in which case include it regardless of transaction status |
390 | 390 | 'STS_ID' => \EEM_Registration::status_id_approved |
391 | 391 | ), |
392 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
392 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
393 | 393 | ), |
394 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
395 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ) |
|
394 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
395 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee') |
|
396 | 396 | ), |
397 | 397 | $event_id |
398 | 398 | ); |
399 | - if( $event_id ){ |
|
400 | - $query_params[0]['EVT_ID'] = $event_id; |
|
399 | + if ($event_id) { |
|
400 | + $query_params[0]['EVT_ID'] = $event_id; |
|
401 | 401 | } else { |
402 | - $query_params[ 'force_join' ][] = 'Event'; |
|
402 | + $query_params['force_join'][] = 'Event'; |
|
403 | 403 | } |
404 | - return \EEM_Registration::instance()->count( $query_params ); |
|
404 | + return \EEM_Registration::instance()->count($query_params); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | * @param JobParameters $job_parameters |
413 | 413 | * @return boolean |
414 | 414 | */ |
415 | - public function cleanup_job( JobParameters $job_parameters ){ |
|
415 | + public function cleanup_job(JobParameters $job_parameters) { |
|
416 | 416 | $this->_file_helper->delete( |
417 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
417 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
418 | 418 | true, |
419 | 419 | 'd' |
420 | 420 | ); |
421 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
421 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 |
@@ -2,18 +2,18 @@ |
||
2 | 2 | <p> |
3 | 3 | <?php _e('The importer can be used to import event information into Event Espresso using a CSV file.', 'event_espresso'); ?> |
4 | 4 | </p> |
5 | -<h3><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso');?></h3> |
|
5 | +<h3><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso'); ?></h3> |
|
6 | 6 | <p> |
7 | 7 | <?php _e('To import Event Espresso data from another Event Espresso 4 install, export a CSV file from the admin Events overview page, or anywhere you can generate a CSV export file from. Then upload that file here (regardless of what type of information was exported).', 'event_espresso'); ?> |
8 | 8 | </p> |
9 | 9 | <p> |
10 | 10 | <?php _e('Note: its possible that data from the other site have the same IDs as data in this site. The importer recognizes that this data is from a different database and inserts new items for each item in the CSV file, regardless of whether its ID matches that of an item in this site\'s database or not. However, the importer also remembers the mapping from the old site\'s database to this site\'s database, and on subsequent CSV importers from that site, the data in this database will be updated instead of re-inserting new items.', 'event_espresso'); ?> |
11 | 11 | </p> |
12 | -<h3><?php _e("Importing from this Site", 'event_espresso');?></h3> |
|
13 | -<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso');?></p> |
|
12 | +<h3><?php _e("Importing from this Site", 'event_espresso'); ?></h3> |
|
13 | +<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso'); ?></p> |
|
14 | 14 | |
15 | - <h3><?php _e("Notes about Generating your own CSV Import Files", "event_espresso");?></h3> |
|
16 | - <p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso");?></p> |
|
17 | - <p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso");?></p> |
|
18 | - <p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso");?></p> |
|
19 | - <p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso");?></p> |
|
20 | 15 | \ No newline at end of file |
16 | + <h3><?php _e("Notes about Generating your own CSV Import Files", "event_espresso"); ?></h3> |
|
17 | + <p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso"); ?></p> |
|
18 | + <p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso"); ?></p> |
|
19 | + <p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso"); ?></p> |
|
20 | + <p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso"); ?></p> |
|
21 | 21 | \ No newline at end of file |