@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Select_Input |
4 | 4 | * |
@@ -10,22 +10,22 @@ discard block |
||
10 | 10 | * @since 4.6 |
11 | 11 | * |
12 | 12 | */ |
13 | -class EE_Select_Input extends EE_Form_Input_With_Options_Base{ |
|
13 | +class EE_Select_Input extends EE_Form_Input_With_Options_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param array $answer_options |
17 | 17 | * @param array $input_settings |
18 | 18 | */ |
19 | - public function __construct( $answer_options, $input_settings = array() ) { |
|
20 | - $this->_set_display_strategy( new EE_Select_Display_Strategy( $answer_options ) ); |
|
19 | + public function __construct($answer_options, $input_settings = array()) { |
|
20 | + $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
21 | 21 | $this->_add_validation_strategy( |
22 | 22 | new EE_Enum_Validation_Strategy( |
23 | - isset( $input_settings['validation_error_message'] ) |
|
23 | + isset($input_settings['validation_error_message']) |
|
24 | 24 | ? $input_settings['validation_error_message'] |
25 | 25 | : null |
26 | 26 | ) |
27 | 27 | ); |
28 | - parent::__construct( $answer_options, $input_settings ); |
|
28 | + parent::__construct($answer_options, $input_settings); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -810,8 +810,7 @@ |
||
810 | 810 | * (If that doesn't exist, we also check for this subsection's name |
811 | 811 | * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].) |
812 | 812 | * This function finds its value in the form. |
813 | - |
|
814 | -* |
|
813 | + * |
|
815 | 814 | *@param array $req_data |
816 | 815 | * @return mixed whatever the raw value of this form section is in the request data |
817 | 816 | * @throws \EE_Error |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else{ |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -458,14 +458,14 @@ discard block |
||
458 | 458 | if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
459 | 459 | try{ |
460 | 460 | $validation_strategy->validate($this->normalized_value()); |
461 | - }catch(EE_Validation_Error $e){ |
|
461 | + } catch(EE_Validation_Error $e){ |
|
462 | 462 | $this->add_validation_error($e); |
463 | 463 | } |
464 | 464 | } |
465 | 465 | } |
466 | 466 | if( $this->get_validation_errors()){ |
467 | 467 | return false; |
468 | - }else{ |
|
468 | + } else{ |
|
469 | 469 | return true; |
470 | 470 | } |
471 | 471 | } |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
829 | 829 | $name_parts = $matches[ 1 ]; |
830 | 830 | array_unshift($name_parts, $before_any_brackets); |
831 | - }else{ |
|
831 | + } else{ |
|
832 | 832 | $name_parts = array( $before_any_brackets ); |
833 | 833 | } |
834 | 834 | // now get the value for the input |
@@ -853,13 +853,13 @@ discard block |
||
853 | 853 | if( isset( $req_data[ $first_part_to_consider ] ) ){ |
854 | 854 | if( empty($html_name_parts ) ){ |
855 | 855 | return $req_data[ $first_part_to_consider ]; |
856 | - }else{ |
|
856 | + } else{ |
|
857 | 857 | return $this->_find_form_data_for_this_section_using_name_parts( |
858 | 858 | $html_name_parts, |
859 | 859 | $req_data[ $first_part_to_consider ] |
860 | 860 | ); |
861 | 861 | } |
862 | - }else{ |
|
862 | + } else{ |
|
863 | 863 | return NULL; |
864 | 864 | } |
865 | 865 | } |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | $checked_value = $this->find_form_data_for_this_section( $req_data ); |
881 | 881 | if( $checked_value !== null ){ |
882 | 882 | return TRUE; |
883 | - }else{ |
|
883 | + } else{ |
|
884 | 884 | return FALSE; |
885 | 885 | } |
886 | 886 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
144 | 144 | * } |
145 | 145 | */ |
146 | - public function __construct( $input_args = array() ){ |
|
147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
146 | + public function __construct($input_args = array()) { |
|
147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
148 | 148 | // the following properties must be cast as arrays |
149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
149 | + if (isset($input_args['validation_strategies'])) { |
|
150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
153 | 153 | } |
154 | 154 | } |
155 | - unset( $input_args['validation_strategies'] ); |
|
155 | + unset($input_args['validation_strategies']); |
|
156 | 156 | } |
157 | 157 | // loop thru incoming options |
158 | - foreach( $input_args as $key => $value ) { |
|
158 | + foreach ($input_args as $key => $value) { |
|
159 | 159 | // add underscore to $key to match property names |
160 | - $_key = '_' . $key; |
|
161 | - if ( property_exists( $this, $_key )) { |
|
160 | + $_key = '_'.$key; |
|
161 | + if (property_exists($this, $_key)) { |
|
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | // ensure that "required" is set correctly |
166 | 166 | $this->set_required( |
167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
168 | - ? $input_args[ 'required_validation_error_message' ] |
|
167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
168 | + ? $input_args['required_validation_error_message'] |
|
169 | 169 | : null |
170 | 170 | ); |
171 | 171 | |
172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
173 | 173 | |
174 | 174 | $this->_display_strategy->_construct_finalize($this); |
175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
176 | 176 | $validation_strategy->_construct_finalize($this); |
177 | 177 | } |
178 | 178 | |
179 | - if( ! $this->_normalization_strategy){ |
|
179 | + if ( ! $this->_normalization_strategy) { |
|
180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
181 | 181 | } |
182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
183 | 183 | |
184 | 184 | //at least we can use the normalization strategy to populate the default |
185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
186 | - $this->set_default( $input_args[ 'default' ] ); |
|
185 | + if (isset($input_args['default'])) { |
|
186 | + $this->set_default($input_args['default']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
191 | 191 | } |
192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
193 | - parent::__construct( $input_args ); |
|
193 | + parent::__construct($input_args); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | - protected function _set_default_html_name_if_empty(){ |
|
205 | - if( ! $this->_html_name){ |
|
204 | + protected function _set_default_html_name_if_empty() { |
|
205 | + if ( ! $this->_html_name) { |
|
206 | 206 | $this->_html_name = $this->name(); |
207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
222 | 222 | $this->_set_default_html_name_if_empty(); |
223 | - if( ! $this->_html_label && ! $this->_html_label_text){ |
|
224 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
223 | + if ( ! $this->_html_label && ! $this->_html_label_text) { |
|
224 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
225 | 225 | } |
226 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
226 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @return EE_Display_Strategy_Base |
232 | 232 | * @throws EE_Error |
233 | 233 | */ |
234 | - protected function _get_display_strategy(){ |
|
235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
234 | + protected function _get_display_strategy() { |
|
235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
236 | 236 | throw new EE_Error( |
237 | 237 | sprintf( |
238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else { |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * Sets the display strategy. |
252 | 252 | * @param EE_Display_Strategy_Base $strategy |
253 | 253 | */ |
254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
255 | 255 | $this->_display_strategy = $strategy; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * Sets the sanitization strategy |
260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
261 | 261 | */ |
262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
263 | 263 | $this->_normalization_strategy = $strategy; |
264 | 264 | } |
265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | * Gets the display strategy for this input |
286 | 286 | * @return EE_Display_Strategy_Base |
287 | 287 | */ |
288 | - public function get_display_strategy(){ |
|
288 | + public function get_display_strategy() { |
|
289 | 289 | return $this->_display_strategy; |
290 | 290 | } |
291 | 291 | /** |
292 | 292 | * Overwrites the display strategy |
293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
294 | 294 | */ |
295 | - public function set_display_strategy($display_strategy){ |
|
295 | + public function set_display_strategy($display_strategy) { |
|
296 | 296 | $this->_display_strategy = $display_strategy; |
297 | 297 | $this->_display_strategy->_construct_finalize($this); |
298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * Gets the normalization strategy set on this input |
301 | 301 | * @return EE_Normalization_Strategy_Base |
302 | 302 | */ |
303 | - public function get_normalization_strategy(){ |
|
303 | + public function get_normalization_strategy() { |
|
304 | 304 | return $this->_normalization_strategy; |
305 | 305 | } |
306 | 306 | /** |
307 | 307 | * Overwrites the normalization strategy |
308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
309 | 309 | */ |
310 | - public function set_normalization_strategy($normalization_strategy){ |
|
310 | + public function set_normalization_strategy($normalization_strategy) { |
|
311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
317 | 317 | * @return EE_Validation_Strategy_Base[] |
318 | 318 | */ |
319 | - public function get_validation_strategies(){ |
|
319 | + public function get_validation_strategies() { |
|
320 | 320 | return $this->_validation_strategies; |
321 | 321 | } |
322 | 322 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
331 | - $validation_strategy->_construct_finalize( $this ); |
|
330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $validation_strategy->_construct_finalize($this); |
|
332 | 332 | $this->_validation_strategies[] = $validation_strategy; |
333 | 333 | } |
334 | 334 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
343 | + $this->_add_validation_strategy($validation_strategy); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @param string $validation_strategy_classname |
352 | 352 | */ |
353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
355 | - if( |
|
353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
355 | + if ( |
|
356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
358 | 358 | ) { |
359 | - unset( $this->_validation_strategies[ $key ] ); |
|
359 | + unset($this->_validation_strategies[$key]); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param array $validation_strategy_classnames |
370 | 370 | * @return bool |
371 | 371 | */ |
372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
374 | 374 | ? $validation_strategy_classnames |
375 | - : array( $validation_strategy_classnames ); |
|
376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
375 | + : array($validation_strategy_classnames); |
|
376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * Gets the HTML |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_html(){ |
|
390 | + public function get_html() { |
|
391 | 391 | return $this->_parent_section->get_html_for_input($this); |
392 | 392 | } |
393 | 393 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return string |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public function get_html_for_input(){ |
|
404 | + public function get_html_for_input() { |
|
405 | 405 | return $this->_get_display_strategy()->display(); |
406 | 406 | } |
407 | 407 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @return string |
412 | 412 | */ |
413 | 413 | public function html_other_attributes() { |
414 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
414 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | /** |
420 | 420 | * @param string $html_other_attributes |
421 | 421 | */ |
422 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
422 | + public function set_html_other_attributes($html_other_attributes) { |
|
423 | 423 | $this->_html_other_attributes = $html_other_attributes; |
424 | 424 | } |
425 | 425 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * according to the form section's layout strategy |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public function get_html_for_label(){ |
|
431 | + public function get_html_for_label() { |
|
432 | 432 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
433 | 433 | } |
434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * according to the form section's layout strategy |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - public function get_html_for_errors(){ |
|
439 | + public function get_html_for_errors() { |
|
440 | 440 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
441 | 441 | } |
442 | 442 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * according to the form section's layout strategy |
445 | 445 | * @return string |
446 | 446 | */ |
447 | - public function get_html_for_help(){ |
|
447 | + public function get_html_for_help() { |
|
448 | 448 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
449 | 449 | } |
450 | 450 | /** |
@@ -453,18 +453,18 @@ discard block |
||
453 | 453 | * @return boolean |
454 | 454 | */ |
455 | 455 | protected function _validate() { |
456 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
457 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
458 | - try{ |
|
456 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
457 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
458 | + try { |
|
459 | 459 | $validation_strategy->validate($this->normalized_value()); |
460 | - }catch(EE_Validation_Error $e){ |
|
460 | + } catch (EE_Validation_Error $e) { |
|
461 | 461 | $this->add_validation_error($e); |
462 | 462 | } |
463 | 463 | } |
464 | 464 | } |
465 | - if( $this->get_validation_errors()){ |
|
465 | + if ($this->get_validation_errors()) { |
|
466 | 466 | return false; |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | return true; |
469 | 469 | } |
470 | 470 | } |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $value |
479 | 479 | * @return null|string |
480 | 480 | */ |
481 | - private function _sanitize( $value ) { |
|
482 | - return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null; |
|
481 | + private function _sanitize($value) { |
|
482 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -493,24 +493,24 @@ discard block |
||
493 | 493 | * @return boolean whether or not there was an error |
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | - protected function _normalize( $req_data ) { |
|
496 | + protected function _normalize($req_data) { |
|
497 | 497 | //any existing validation errors don't apply so clear them |
498 | 498 | $this->_validation_errors = array(); |
499 | 499 | try { |
500 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
500 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
501 | 501 | //super simple sanitization for now |
502 | - if ( is_array( $raw_input )) { |
|
502 | + if (is_array($raw_input)) { |
|
503 | 503 | $this->_raw_value = array(); |
504 | - foreach( $raw_input as $key => $value ) { |
|
505 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
504 | + foreach ($raw_input as $key => $value) { |
|
505 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
506 | 506 | } |
507 | 507 | } else { |
508 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
508 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
509 | 509 | } |
510 | 510 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
511 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
512 | - } catch ( EE_Validation_Error $e ) { |
|
513 | - $this->add_validation_error( $e ); |
|
511 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
512 | + } catch (EE_Validation_Error $e) { |
|
513 | + $this->add_validation_error($e); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @return string |
521 | 521 | */ |
522 | - public function html_name(){ |
|
522 | + public function html_name() { |
|
523 | 523 | return $this->_html_name; |
524 | 524 | } |
525 | 525 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | /** |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public function html_label_id(){ |
|
532 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
531 | + public function html_label_id() { |
|
532 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | /** |
538 | 538 | * @return string |
539 | 539 | */ |
540 | - public function html_label_class(){ |
|
540 | + public function html_label_class() { |
|
541 | 541 | return $this->_html_label_class; |
542 | 542 | } |
543 | 543 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | /** |
547 | 547 | * @return string |
548 | 548 | */ |
549 | - public function html_label_style(){ |
|
549 | + public function html_label_style() { |
|
550 | 550 | return $this->_html_label_style; |
551 | 551 | } |
552 | 552 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | /** |
556 | 556 | * @return string |
557 | 557 | */ |
558 | - public function html_label_text(){ |
|
558 | + public function html_label_text() { |
|
559 | 559 | return $this->_html_label_text; |
560 | 560 | } |
561 | 561 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | /** |
565 | 565 | * @return string |
566 | 566 | */ |
567 | - public function html_help_text(){ |
|
567 | + public function html_help_text() { |
|
568 | 568 | return $this->_html_help_text; |
569 | 569 | } |
570 | 570 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | /** |
574 | 574 | * @return string |
575 | 575 | */ |
576 | - public function html_help_class(){ |
|
576 | + public function html_help_class() { |
|
577 | 577 | return $this->_html_help_class; |
578 | 578 | } |
579 | 579 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * @return string |
584 | 584 | */ |
585 | - public function html_help_style(){ |
|
585 | + public function html_help_style() { |
|
586 | 586 | return $this->_html_style; |
587 | 587 | } |
588 | 588 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * in which case, we would have stored the malicious content to our database. |
596 | 596 | * @return string |
597 | 597 | */ |
598 | - public function raw_value(){ |
|
598 | + public function raw_value() { |
|
599 | 599 | return $this->_raw_value; |
600 | 600 | } |
601 | 601 | /** |
@@ -603,15 +603,15 @@ discard block |
||
603 | 603 | * it escapes all html entities |
604 | 604 | * @return string |
605 | 605 | */ |
606 | - public function raw_value_in_form(){ |
|
607 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
606 | + public function raw_value_in_form() { |
|
607 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
608 | 608 | } |
609 | 609 | /** |
610 | 610 | * returns the value after it's been sanitized, and then converted into it's proper type |
611 | 611 | * in PHP. Eg, a string, an int, an array, |
612 | 612 | * @return mixed |
613 | 613 | */ |
614 | - public function normalized_value(){ |
|
614 | + public function normalized_value() { |
|
615 | 615 | return $this->_normalized_value; |
616 | 616 | } |
617 | 617 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * the best thing to display |
622 | 622 | * @return string |
623 | 623 | */ |
624 | - public function pretty_value(){ |
|
624 | + public function pretty_value() { |
|
625 | 625 | return $this->_normalized_value; |
626 | 626 | } |
627 | 627 | /** |
@@ -640,19 +640,19 @@ discard block |
||
640 | 640 | }</code> |
641 | 641 | * @return array |
642 | 642 | */ |
643 | - public function get_jquery_validation_rules(){ |
|
643 | + public function get_jquery_validation_rules() { |
|
644 | 644 | $jquery_validation_js = array(); |
645 | 645 | $jquery_validation_rules = array(); |
646 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
646 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
647 | 647 | $jquery_validation_rules = array_replace_recursive( |
648 | 648 | $jquery_validation_rules, |
649 | 649 | $validation_strategy->get_jquery_validation_rule_array() |
650 | 650 | ); |
651 | 651 | } |
652 | 652 | |
653 | - if(! empty($jquery_validation_rules)){ |
|
654 | - foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) { |
|
655 | - $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules; |
|
653 | + if ( ! empty($jquery_validation_rules)) { |
|
654 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
655 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | return $jquery_validation_js; |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | * @param mixed $value |
665 | 665 | * @return void |
666 | 666 | */ |
667 | - public function set_default($value){ |
|
667 | + public function set_default($value) { |
|
668 | 668 | $this->_normalized_value = $value; |
669 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
669 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * @param string $label |
675 | 675 | * @return void |
676 | 676 | */ |
677 | - public function set_html_label_text($label){ |
|
677 | + public function set_html_label_text($label) { |
|
678 | 678 | $this->_html_label_text = $label; |
679 | 679 | } |
680 | 680 | |
@@ -688,13 +688,13 @@ discard block |
||
688 | 688 | * @param boolean $required boolean |
689 | 689 | * @param null $required_text |
690 | 690 | */ |
691 | - public function set_required($required = true, $required_text = NULL ){ |
|
692 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
691 | + public function set_required($required = true, $required_text = NULL) { |
|
692 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
693 | 693 | //whether $required is a string or a boolean, we want to add a required validation strategy |
694 | - if ( $required ) { |
|
695 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
694 | + if ($required) { |
|
695 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
696 | 696 | } else { |
697 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
697 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
698 | 698 | } |
699 | 699 | $this->_required = $required; |
700 | 700 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * Returns whether or not this field is required |
703 | 703 | * @return boolean |
704 | 704 | */ |
705 | - public function required(){ |
|
705 | + public function required() { |
|
706 | 706 | return $this->_required; |
707 | 707 | } |
708 | 708 | |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | /** |
712 | 712 | * @param string $required_css_class |
713 | 713 | */ |
714 | - public function set_required_css_class( $required_css_class ) { |
|
714 | + public function set_required_css_class($required_css_class) { |
|
715 | 715 | $this->_required_css_class = $required_css_class; |
716 | 716 | } |
717 | 717 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * Sets the help text, in case |
731 | 731 | * @param string $text |
732 | 732 | */ |
733 | - public function set_html_help_text($text){ |
|
733 | + public function set_html_help_text($text) { |
|
734 | 734 | $this->_html_help_text = $text; |
735 | 735 | } |
736 | 736 | /** |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | public function clean_sensitive_data() { |
743 | 743 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
744 | 744 | //if we need more logic than this we'll make a strategy for it |
745 | - if( $this->_sensitive_data_removal_strategy && |
|
746 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
745 | + if ($this->_sensitive_data_removal_strategy && |
|
746 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
747 | 747 | $this->_raw_value = NULL; |
748 | 748 | } |
749 | 749 | //and clean the normalized value according to the appropriate strategy |
@@ -759,10 +759,10 @@ discard block |
||
759 | 759 | * @param string $button_size |
760 | 760 | * @param string $other_attributes |
761 | 761 | */ |
762 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
762 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
763 | 763 | $button_css_attributes = 'button'; |
764 | 764 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
765 | - switch ( $button_size ) { |
|
765 | + switch ($button_size) { |
|
766 | 766 | case 'xs' : |
767 | 767 | case 'extra-small' : |
768 | 768 | $button_css_attributes .= ' button-xs'; |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | default : |
784 | 784 | $button_css_attributes .= ''; |
785 | 785 | } |
786 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
787 | - ? $button_css_attributes . ' ' . $other_attributes |
|
786 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
787 | + ? $button_css_attributes.' '.$other_attributes |
|
788 | 788 | : $button_css_attributes; |
789 | 789 | } |
790 | 790 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * @return string |
795 | 795 | */ |
796 | 796 | public function button_css_attributes() { |
797 | - if ( empty( $this->_button_css_attributes )) { |
|
797 | + if (empty($this->_button_css_attributes)) { |
|
798 | 798 | $this->set_button_css_attributes(); |
799 | 799 | } |
800 | 800 | return $this->_button_css_attributes; |
@@ -816,26 +816,26 @@ discard block |
||
816 | 816 | * @return mixed whatever the raw value of this form section is in the request data |
817 | 817 | * @throws \EE_Error |
818 | 818 | */ |
819 | - public function find_form_data_for_this_section( $req_data ){ |
|
819 | + public function find_form_data_for_this_section($req_data) { |
|
820 | 820 | // break up the html name by "[]" |
821 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
822 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
821 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
822 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
823 | 823 | } else { |
824 | 824 | $before_any_brackets = $this->html_name(); |
825 | 825 | } |
826 | 826 | // grab all of the segments |
827 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
828 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
829 | - $name_parts = $matches[ 1 ]; |
|
827 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
828 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
829 | + $name_parts = $matches[1]; |
|
830 | 830 | array_unshift($name_parts, $before_any_brackets); |
831 | - }else{ |
|
832 | - $name_parts = array( $before_any_brackets ); |
|
831 | + } else { |
|
832 | + $name_parts = array($before_any_brackets); |
|
833 | 833 | } |
834 | 834 | // now get the value for the input |
835 | 835 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
836 | 836 | // check if this thing's name is at the TOP level of the request data |
837 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
838 | - $value = $req_data[ $this->name() ]; |
|
837 | + if ($value === null && isset($req_data[$this->name()])) { |
|
838 | + $value = $req_data[$this->name()]; |
|
839 | 839 | } |
840 | 840 | return $value; |
841 | 841 | } |
@@ -848,18 +848,18 @@ discard block |
||
848 | 848 | * @param array $req_data |
849 | 849 | * @return array | NULL |
850 | 850 | */ |
851 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
852 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
853 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
854 | - if( empty($html_name_parts ) ){ |
|
855 | - return $req_data[ $first_part_to_consider ]; |
|
856 | - }else{ |
|
851 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
852 | + $first_part_to_consider = array_shift($html_name_parts); |
|
853 | + if (isset($req_data[$first_part_to_consider])) { |
|
854 | + if (empty($html_name_parts)) { |
|
855 | + return $req_data[$first_part_to_consider]; |
|
856 | + } else { |
|
857 | 857 | return $this->_find_form_data_for_this_section_using_name_parts( |
858 | 858 | $html_name_parts, |
859 | - $req_data[ $first_part_to_consider ] |
|
859 | + $req_data[$first_part_to_consider] |
|
860 | 860 | ); |
861 | 861 | } |
862 | - }else{ |
|
862 | + } else { |
|
863 | 863 | return NULL; |
864 | 864 | } |
865 | 865 | } |
@@ -873,14 +873,14 @@ discard block |
||
873 | 873 | * @return boolean |
874 | 874 | * @throws \EE_Error |
875 | 875 | */ |
876 | - public function form_data_present_in($req_data = NULL){ |
|
877 | - if( $req_data === NULL ){ |
|
876 | + public function form_data_present_in($req_data = NULL) { |
|
877 | + if ($req_data === NULL) { |
|
878 | 878 | $req_data = $_POST; |
879 | 879 | } |
880 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
881 | - if( $checked_value !== null ){ |
|
880 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
881 | + if ($checked_value !== null) { |
|
882 | 882 | return TRUE; |
883 | - }else{ |
|
883 | + } else { |
|
884 | 884 | return FALSE; |
885 | 885 | } |
886 | 886 | } |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * @param array $form_other_js_data |
892 | 892 | * @return array |
893 | 893 | */ |
894 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
895 | - $form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data ); |
|
894 | + public function get_other_js_data($form_other_js_data = array()) { |
|
895 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
896 | 896 | return $form_other_js_data; |
897 | 897 | } |
898 | 898 | |
@@ -905,10 +905,10 @@ discard block |
||
905 | 905 | * @param array $form_other_js_data |
906 | 906 | * @return array |
907 | 907 | */ |
908 | - public function get_other_js_data_from_strategies( $form_other_js_data = array() ) { |
|
909 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data ); |
|
910 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
911 | - $form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data ); |
|
908 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) { |
|
909 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
910 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
911 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
912 | 912 | } |
913 | 913 | return $form_other_js_data; |
914 | 914 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
918 | 918 | * @return void |
919 | 919 | */ |
920 | - public function enqueue_js(){ |
|
920 | + public function enqueue_js() { |
|
921 | 921 | //ask our display strategy and validation strategies if they have js to enqueue |
922 | 922 | $this->enqueue_js_from_strategies(); |
923 | 923 | } |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | */ |
929 | 929 | public function enqueue_js_from_strategies() { |
930 | 930 | $this->get_display_strategy()->enqueue_js(); |
931 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
931 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
932 | 932 | $validation_strategy->enqueue_js(); |
933 | 933 | } |
934 | 934 | } |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Required_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
11 | +class EE_Required_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param string $validation_error_message |
17 | 17 | */ |
18 | - public function __construct( $validation_error_message = null ) { |
|
19 | - if( ! $validation_error_message ){ |
|
18 | + public function __construct($validation_error_message = null) { |
|
19 | + if ( ! $validation_error_message) { |
|
20 | 20 | $validation_error_message = __("This field is required.", "event_espresso"); |
21 | 21 | } |
22 | - parent::__construct( $validation_error_message ); |
|
22 | + parent::__construct($validation_error_message); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | * @throws \EE_Validation_Error |
35 | 35 | */ |
36 | 36 | public function validate($normalized_value) { |
37 | - if( |
|
37 | + if ( |
|
38 | 38 | $normalized_value === '' |
39 | 39 | || $normalized_value === null |
40 | 40 | || $normalized_value === array() |
41 | 41 | ) { |
42 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
43 | - }else{ |
|
42 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
43 | + } else { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return array |
52 | 52 | * @throws \EE_Error |
53 | 53 | */ |
54 | - public function get_jquery_validation_rule_array(){ |
|
54 | + public function get_jquery_validation_rule_array() { |
|
55 | 55 | return array( |
56 | 56 | 'required'=> true, |
57 | 57 | 'messages' => array( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
3 | -require_once ( EE_CLASSES . 'EE_Registration.class.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
3 | +require_once (EE_CLASSES.'EE_Registration.class.php'); |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Registration Model |
@@ -92,31 +92,31 @@ discard block |
||
92 | 92 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
93 | 93 | * @return \EEM_Registration |
94 | 94 | */ |
95 | - protected function __construct( $timezone ) { |
|
96 | - $this->singular_item = __('Registration','event_espresso'); |
|
97 | - $this->plural_item = __('Registrations','event_espresso'); |
|
95 | + protected function __construct($timezone) { |
|
96 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
97 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | $this->_tables = array( |
100 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
100 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
101 | 101 | ); |
102 | 102 | $this->_fields = array( |
103 | 103 | 'Registration'=>array( |
104 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
105 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
106 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
107 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
108 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
109 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, time(), $timezone ), |
|
111 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
112 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
113 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
114 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
115 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
116 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
117 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
118 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
119 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
104 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
105 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
106 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
107 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
108 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
109 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, time(), $timezone), |
|
111 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
112 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
113 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
114 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
115 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
116 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
117 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
118 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
119 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | $this->_model_relations = array( |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | 'Answer'=>new EE_Has_Many_Relation(), |
129 | 129 | 'Checkin'=>new EE_Has_Many_Relation(), |
130 | 130 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
131 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
132 | - 'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletes even if there are messages in the queue related |
|
131 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
132 | + 'Message' => new EE_Has_Many_Any_Relation(false) //allow deletes even if there are messages in the queue related |
|
133 | 133 | ); |
134 | 134 | $this->_model_chain_to_wp_user = 'Event'; |
135 | 135 | |
136 | - parent::__construct( $timezone ); |
|
136 | + parent::__construct($timezone); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | * @param bool $translated If true will return the values as singular localized strings |
167 | 167 | * @return array |
168 | 168 | */ |
169 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
170 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
171 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
169 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
170 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
171 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | * @param array $exclude |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - private function _get_registration_status_array( $exclude = array() ) { |
|
182 | + private function _get_registration_status_array($exclude = array()) { |
|
183 | 183 | //in the very rare circumstance that we are deleting a model's table's data |
184 | 184 | //and the table hasn't actually been created, this could have an error |
185 | 185 | /** @type WPDB $wpdb */ |
186 | 186 | global $wpdb; |
187 | - if( EEH_Activation::table_exists( $wpdb->prefix . 'esp_status' ) ){ |
|
188 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
189 | - $results = $wpdb->get_results( $SQL ); |
|
187 | + if (EEH_Activation::table_exists($wpdb->prefix.'esp_status')) { |
|
188 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
189 | + $results = $wpdb->get_results($SQL); |
|
190 | 190 | self::$_reg_status = array(); |
191 | - foreach ( $results as $status ) { |
|
192 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
193 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
191 | + foreach ($results as $status) { |
|
192 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
193 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
206 | 206 | * @return wpdb results array |
207 | 207 | */ |
208 | - public function get_reg_months_and_years( $where_params ) { |
|
208 | + public function get_reg_months_and_years($where_params) { |
|
209 | 209 | $query_params[0] = $where_params; |
210 | 210 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
211 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
211 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
212 | 212 | $columns_to_select = array( |
213 | 213 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
214 | 214 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
215 | 215 | ); |
216 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
216 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @param int $ATT_ID |
226 | 226 | * @return EE_Registration[] |
227 | 227 | */ |
228 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
229 | - if ( ! $ATT_ID ) { |
|
228 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
229 | + if ( ! $ATT_ID) { |
|
230 | 230 | return FALSE; |
231 | 231 | } |
232 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
232 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @param string $REG_url_link |
241 | 241 | * @return EE_Registration |
242 | 242 | */ |
243 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
244 | - if(!$REG_url_link){ |
|
243 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
244 | + if ( ! $REG_url_link) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | 260 | * @return mixed array on success, FALSE on fail |
261 | 261 | */ |
262 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
262 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
263 | 263 | return $this->get_one(array( |
264 | 264 | array( |
265 | 265 | 'TXN_ID'=>$TXN_ID, |
266 | 266 | 'ATT_ID'=>$ATT_ID |
267 | 267 | ), |
268 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
268 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
269 | 269 | )); |
270 | 270 | } |
271 | 271 | |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
278 | 278 | * @return stdClass[] with properties regDate and total |
279 | 279 | */ |
280 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
280 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
281 | 281 | |
282 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
283 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
282 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
283 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
284 | 284 | |
285 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
285 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
286 | 286 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
287 | 287 | } |
288 | 288 | |
289 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' ); |
|
289 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
290 | 290 | |
291 | 291 | $results = $this->_get_all_wpdb_results( |
292 | 292 | array( |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | ), |
297 | 297 | OBJECT, |
298 | 298 | array( |
299 | - 'regDate'=>array( 'DATE(' . $query_interval . ')','%s'), |
|
300 | - 'total'=>array('count(REG_ID)','%d') |
|
299 | + 'regDate'=>array('DATE('.$query_interval.')', '%s'), |
|
300 | + 'total'=>array('count(REG_ID)', '%d') |
|
301 | 301 | )); |
302 | 302 | return $results; |
303 | 303 | } |
@@ -312,22 +312,22 @@ discard block |
||
312 | 312 | * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
313 | 313 | * (i.e. RAP) |
314 | 314 | */ |
315 | - public function get_registrations_per_day_and_per_status_report( $period = '-1 month' ) { |
|
315 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') { |
|
316 | 316 | global $wpdb; |
317 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
317 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
318 | 318 | $event_table = $wpdb->posts; |
319 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
319 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
320 | 320 | |
321 | 321 | //prepare the query interval for displaying offset |
322 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'dates.REG_date' ); |
|
322 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
323 | 323 | |
324 | 324 | //inner date query |
325 | 325 | $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
326 | 326 | $inner_where = " WHERE"; |
327 | 327 | //exclude events not authored by user if permissions in effect |
328 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
328 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
329 | 329 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
330 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
330 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
331 | 331 | } |
332 | 332 | $inner_where .= " REG_date >= '$sql_date'"; |
333 | 333 | $inner_date_query .= $inner_where; |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | $select_parts = array(); |
340 | 340 | |
341 | 341 | //loop through registration stati to do parts for each status. |
342 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
343 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
342 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
343 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
344 | 344 | continue; |
345 | 345 | } |
346 | 346 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | } |
349 | 349 | |
350 | 350 | //setup the selects |
351 | - $select .= implode(', ', $select_parts ); |
|
351 | + $select .= implode(', ', $select_parts); |
|
352 | 352 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
353 | 353 | |
354 | 354 | //setup the joins |
355 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
355 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
356 | 356 | |
357 | 357 | //now let's put it all together |
358 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
358 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
359 | 359 | |
360 | 360 | //and execute it |
361 | 361 | $results = $wpdb->get_results( |
@@ -376,23 +376,23 @@ discard block |
||
376 | 376 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
377 | 377 | * @return stdClass[] each with properties event_name, reg_limit, and total |
378 | 378 | */ |
379 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
379 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
380 | 380 | |
381 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
382 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
381 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
382 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
383 | 383 | |
384 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
384 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
385 | 385 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
386 | 386 | } |
387 | 387 | $results = $this->_get_all_wpdb_results(array( |
388 | 388 | $where, |
389 | 389 | 'group_by'=>'Event.EVT_name', |
390 | 390 | 'order_by'=>'Event.EVT_name', |
391 | - 'limit'=>array(0,24)), |
|
391 | + 'limit'=>array(0, 24)), |
|
392 | 392 | OBJECT, |
393 | 393 | array( |
394 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
395 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
394 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
395 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
396 | 396 | ) |
397 | 397 | ); |
398 | 398 | |
@@ -410,19 +410,19 @@ discard block |
||
410 | 410 | * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
411 | 411 | * (i.e. RAP) |
412 | 412 | */ |
413 | - public function get_registrations_per_event_and_per_status_report( $period = '-1 month' ) { |
|
413 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') { |
|
414 | 414 | global $wpdb; |
415 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
415 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
416 | 416 | $event_table = $wpdb->posts; |
417 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
417 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
418 | 418 | |
419 | 419 | //inner date query |
420 | 420 | $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
421 | 421 | $inner_where = " WHERE"; |
422 | 422 | //exclude events not authored by user if permissions in effect |
423 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
423 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
424 | 424 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
425 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
425 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
426 | 426 | } |
427 | 427 | $inner_where .= " REG_date >= '$sql_date'"; |
428 | 428 | $inner_date_query .= $inner_where; |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | $select_parts = array(); |
435 | 435 | |
436 | 436 | //loop through registration stati to do parts for each status. |
437 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
438 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
437 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
438 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
439 | 439 | continue; |
440 | 440 | } |
441 | 441 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | //setup the selects |
446 | - $select .= implode( ', ', $select_parts ); |
|
446 | + $select .= implode(', ', $select_parts); |
|
447 | 447 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
448 | 448 | |
449 | 449 | //setup remaining joins |
450 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
450 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
451 | 451 | |
452 | 452 | //now put it all together |
453 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
453 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
454 | 454 | |
455 | 455 | //and execute |
456 | 456 | $results = $wpdb->get_results( |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * @param int $TXN_ID |
467 | 467 | * @return EE_Registration |
468 | 468 | */ |
469 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
470 | - if( ! $TXN_ID ){ |
|
469 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
470 | + if ( ! $TXN_ID) { |
|
471 | 471 | return false; |
472 | 472 | } |
473 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
473 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | * @param boolean $for_incomplete_payments |
483 | 483 | * @return int |
484 | 484 | */ |
485 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
485 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
486 | 486 | // we only count approved registrations towards registration limits |
487 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
488 | - if( $for_incomplete_payments ){ |
|
489 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
487 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
488 | + if ($for_incomplete_payments) { |
|
489 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | return $this->count($query_params); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | /** @type WPDB $wpdb */ |
503 | 503 | global $wpdb; |
504 | 504 | return $wpdb->query( |
505 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
505 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -512,17 +512,17 @@ discard block |
||
512 | 512 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
513 | 513 | * @return int |
514 | 514 | */ |
515 | - public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) { |
|
515 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) { |
|
516 | 516 | global $wpdb; |
517 | 517 | //subquery to get latest checkin |
518 | 518 | $query = $wpdb->prepare( |
519 | 519 | 'SELECT ' |
520 | 520 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
521 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
521 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
522 | 522 | . '( SELECT ' |
523 | 523 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
524 | 524 | . 'REG_ID AS REG_ID ' |
525 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
525 | + . 'FROM '.EEM_Checkin::instance()->table().' ' |
|
526 | 526 | . 'WHERE DTT_ID=%d ' |
527 | 527 | . 'GROUP BY REG_ID' |
528 | 528 | . ') AS most_recent_checkin_per_reg ' |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $DTT_ID, |
534 | 534 | $checked_in |
535 | 535 | ); |
536 | - return (int)$wpdb->get_var( $query ); |
|
536 | + return (int) $wpdb->get_var($query); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
@@ -543,18 +543,18 @@ discard block |
||
543 | 543 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
544 | 544 | * @return int |
545 | 545 | */ |
546 | - public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) { |
|
546 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) { |
|
547 | 547 | global $wpdb; |
548 | 548 | //subquery to get latest checkin |
549 | 549 | $query = $wpdb->prepare( |
550 | 550 | 'SELECT ' |
551 | 551 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
552 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
552 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
553 | 553 | . '( SELECT ' |
554 | 554 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
555 | 555 | . 'REG_ID AS REG_ID ' |
556 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
557 | - . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
556 | + . 'FROM '.EEM_Checkin::instance()->table().' AS c ' |
|
557 | + . 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d ' |
|
558 | 558 | . 'ON c.DTT_ID=d.DTT_ID ' |
559 | 559 | . 'WHERE d.EVT_ID=%d ' |
560 | 560 | . 'GROUP BY REG_ID' |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | $EVT_ID, |
567 | 567 | $checked_in |
568 | 568 | ); |
569 | - return (int)$wpdb->get_var( $query ); |
|
569 | + return (int) $wpdb->get_var($query); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
@@ -581,15 +581,15 @@ discard block |
||
581 | 581 | * @param array $attendee_ids |
582 | 582 | * @return EE_Registration[] |
583 | 583 | */ |
584 | - public function get_latest_registration_for_each_of_given_contacts( $attendee_ids = array() ) { |
|
584 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) { |
|
585 | 585 | //first do a native wp_query to get the latest REG_ID's matching these attendees. |
586 | 586 | global $wpdb; |
587 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
587 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
588 | 588 | $attendee_table = $wpdb->posts; |
589 | - $attendee_ids = is_array( $attendee_ids ) |
|
590 | - ? array_map( 'absint', $attendee_ids ) |
|
591 | - : array( (int) $attendee_ids ); |
|
592 | - $attendee_ids = implode( ',', $attendee_ids ); |
|
589 | + $attendee_ids = is_array($attendee_ids) |
|
590 | + ? array_map('absint', $attendee_ids) |
|
591 | + : array((int) $attendee_ids); |
|
592 | + $attendee_ids = implode(',', $attendee_ids); |
|
593 | 593 | |
594 | 594 | |
595 | 595 | //first we do a query to get the registration ids |
@@ -614,24 +614,24 @@ discard block |
||
614 | 614 | ARRAY_A |
615 | 615 | ); |
616 | 616 | |
617 | - if ( empty( $registration_ids ) ) { |
|
617 | + if (empty($registration_ids)) { |
|
618 | 618 | return array(); |
619 | 619 | } |
620 | 620 | |
621 | 621 | $ids_for_model_query = array(); |
622 | 622 | //let's flatten the ids so they can be used in the model query. |
623 | - foreach ( $registration_ids as $registration_id ) { |
|
624 | - if ( isset( $registration_id['registration_id'] ) ) { |
|
623 | + foreach ($registration_ids as $registration_id) { |
|
624 | + if (isset($registration_id['registration_id'])) { |
|
625 | 625 | $ids_for_model_query[] = $registration_id['registration_id']; |
626 | 626 | } |
627 | 627 | } |
628 | 628 | |
629 | 629 | //construct query |
630 | 630 | $_where = array( |
631 | - 'REG_ID' => array( 'IN', $ids_for_model_query ) |
|
631 | + 'REG_ID' => array('IN', $ids_for_model_query) |
|
632 | 632 | ); |
633 | 633 | |
634 | - return $this->get_all( array( $_where ) ); |
|
634 | + return $this->get_all(array($_where)); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Event Espresso |
4 | 4 | * |
@@ -75,37 +75,37 @@ discard block |
||
75 | 75 | $this->Request_Handler = $Request_Handler; |
76 | 76 | $this->Module_Request_Router = $Module_Request_Router; |
77 | 77 | // make sure template tags are loaded immediately so that themes don't break |
78 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'load_espresso_template_tags' ), 10 ); |
|
78 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'load_espresso_template_tags'), 10); |
|
79 | 79 | // determine how to integrate WP_Query with the EE models |
80 | - add_action( 'AHEE__EE_System__initialize', array( $this, 'employ_CPT_Strategy' )); |
|
80 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
81 | 81 | // load other resources and begin to actually run shortcodes and modules |
82 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 5 ); |
|
82 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
83 | 83 | // analyse the incoming WP request |
84 | - add_action( 'parse_request', array( $this, 'get_request' ), 1, 1 ); |
|
84 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
85 | 85 | // process any content shortcodes |
86 | - add_action( 'parse_request', array( $this, '_initialize_shortcodes' ), 5 ); |
|
86 | + add_action('parse_request', array($this, '_initialize_shortcodes'), 5); |
|
87 | 87 | // process request with module factory |
88 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 10, 1 ); |
|
88 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
89 | 89 | // before headers sent |
90 | - add_action( 'wp', array( $this, 'wp' ), 5 ); |
|
90 | + add_action('wp', array($this, 'wp'), 5); |
|
91 | 91 | // load css and js |
92 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 1 ); |
|
92 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
93 | 93 | // header |
94 | - add_action('wp_head', array( $this, 'header_meta_tag' ), 5 ); |
|
95 | - add_filter( 'template_include', array( $this, 'template_include' ), 1 ); |
|
94 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
95 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
96 | 96 | // display errors |
97 | - add_action('loop_start', array( $this, 'display_errors' ), 2 ); |
|
97 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
98 | 98 | // the content |
99 | 99 | // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
100 | 100 | //exclude our private cpt comments |
101 | - add_filter( 'comments_clauses', array( $this, 'filter_wp_comments'), 10, 1 ); |
|
101 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
102 | 102 | //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
103 | - add_filter( 'admin_url', array( $this, 'maybe_force_admin_ajax_ssl' ), 200, 1 ); |
|
103 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
104 | 104 | // action hook EE |
105 | - do_action( 'AHEE__EE_Front_Controller__construct__done',$this ); |
|
105 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
106 | 106 | // for checking that browser cookies are enabled |
107 | - if ( apply_filters( 'FHEE__EE_Front_Controller____construct__set_test_cookie', true )) { |
|
108 | - setcookie( 'ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/' ); |
|
107 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
108 | + setcookie('ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/'); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * @return void |
142 | 142 | */ |
143 | 143 | public function load_espresso_template_tags() { |
144 | - if ( is_readable( EE_PUBLIC . 'template_tags.php' )) { |
|
145 | - require_once( EE_PUBLIC . 'template_tags.php' ); |
|
144 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
145 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | * @param array $clauses array of comment clauses setup by WP_Comment_Query |
158 | 158 | * @return array array of comment clauses with modifications. |
159 | 159 | */ |
160 | - public function filter_wp_comments( $clauses ) { |
|
160 | + public function filter_wp_comments($clauses) { |
|
161 | 161 | global $wpdb; |
162 | - if ( strpos( $clauses['join'], $wpdb->posts ) !== FALSE ) { |
|
162 | + if (strpos($clauses['join'], $wpdb->posts) !== FALSE) { |
|
163 | 163 | $cpts = EE_Register_CPTs::get_private_CPTs(); |
164 | - foreach ( $cpts as $cpt => $details ) { |
|
165 | - $clauses['where'] .= $wpdb->prepare( " AND $wpdb->posts.post_type != %s", $cpt ); |
|
164 | + foreach ($cpts as $cpt => $details) { |
|
165 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | return $clauses; |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | * @return void |
180 | 180 | */ |
181 | 181 | public function employ_CPT_Strategy() { |
182 | - if ( apply_filters( 'FHEE__EE_Front_Controller__employ_CPT_Strategy',true) ){ |
|
183 | - $this->Registry->load_core( 'CPT_Strategy' ); |
|
182 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
183 | + $this->Registry->load_core('CPT_Strategy'); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @param string $url incoming url |
193 | 193 | * @return string final assembled url |
194 | 194 | */ |
195 | - public function maybe_force_admin_ajax_ssl( $url ) { |
|
196 | - if ( is_ssl() && preg_match( '/admin-ajax.php/', $url )) { |
|
197 | - $url = str_replace( 'http://', 'https://', $url ); |
|
195 | + public function maybe_force_admin_ajax_ssl($url) { |
|
196 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
197 | + $url = str_replace('http://', 'https://', $url); |
|
198 | 198 | } |
199 | 199 | return $url; |
200 | 200 | } |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @param WP $WP |
232 | 232 | * @return void |
233 | 233 | */ |
234 | - public function get_request( WP $WP ) { |
|
235 | - do_action( 'AHEE__EE_Front_Controller__get_request__start' ); |
|
236 | - $this->Request_Handler->parse_request( $WP ); |
|
237 | - do_action( 'AHEE__EE_Front_Controller__get_request__complete' ); |
|
234 | + public function get_request(WP $WP) { |
|
235 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
236 | + $this->Request_Handler->parse_request($WP); |
|
237 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -246,21 +246,21 @@ discard block |
||
246 | 246 | * @param WP $WP |
247 | 247 | * @return void |
248 | 248 | */ |
249 | - public function _initialize_shortcodes( WP $WP ) { |
|
250 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this ); |
|
251 | - $this->Request_Handler->set_request_vars( $WP ); |
|
249 | + public function _initialize_shortcodes(WP $WP) { |
|
250 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this); |
|
251 | + $this->Request_Handler->set_request_vars($WP); |
|
252 | 252 | // grab post_name from request |
253 | - $current_post = apply_filters( 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', $this->Request_Handler->get( 'post_name' )); |
|
254 | - $show_on_front = get_option( 'show_on_front' ); |
|
253 | + $current_post = apply_filters('FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', $this->Request_Handler->get('post_name')); |
|
254 | + $show_on_front = get_option('show_on_front'); |
|
255 | 255 | // if it's not set, then check if frontpage is blog |
256 | - if ( empty( $current_post ) ) { |
|
256 | + if (empty($current_post)) { |
|
257 | 257 | // yup.. this is the posts page, prepare to load all shortcode modules |
258 | 258 | $current_post = 'posts'; |
259 | 259 | // unless.. |
260 | - if ( $show_on_front === 'page' ) { |
|
260 | + if ($show_on_front === 'page') { |
|
261 | 261 | // some other page is set as the homepage |
262 | - $page_on_front = get_option( 'page_on_front' ); |
|
263 | - if ( $page_on_front ) { |
|
262 | + $page_on_front = get_option('page_on_front'); |
|
263 | + if ($page_on_front) { |
|
264 | 264 | // k now we need to find the post_name for this page |
265 | 265 | global $wpdb; |
266 | 266 | $page_on_front = $wpdb->get_var( |
@@ -277,22 +277,22 @@ discard block |
||
277 | 277 | // where are posts being displayed ? |
278 | 278 | $page_for_posts = EE_Config::get_page_for_posts(); |
279 | 279 | // in case $current_post is hierarchical like: /parent-page/current-page |
280 | - $current_post = basename( $current_post ); |
|
280 | + $current_post = basename($current_post); |
|
281 | 281 | // are we on a category page? |
282 | - $term_exists = is_array( term_exists( $current_post, 'category' )) || array_key_exists( 'category_name', $WP->query_vars ); |
|
282 | + $term_exists = is_array(term_exists($current_post, 'category')) || array_key_exists('category_name', $WP->query_vars); |
|
283 | 283 | // make sure shortcodes are set |
284 | - if ( isset( $this->Registry->CFG->core->post_shortcodes )) { |
|
285 | - if ( ! isset( $this->Registry->CFG->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
286 | - $this->Registry->CFG->core->post_shortcodes[ $page_for_posts ] = array(); |
|
284 | + if (isset($this->Registry->CFG->core->post_shortcodes)) { |
|
285 | + if ( ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts])) { |
|
286 | + $this->Registry->CFG->core->post_shortcodes[$page_for_posts] = array(); |
|
287 | 287 | } |
288 | 288 | // cycle thru all posts with shortcodes set |
289 | - foreach ( $this->Registry->CFG->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
289 | + foreach ($this->Registry->CFG->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
290 | 290 | // filter shortcodes so |
291 | - $post_shortcodes = apply_filters( 'FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes ); |
|
291 | + $post_shortcodes = apply_filters('FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes); |
|
292 | 292 | // now cycle thru shortcodes |
293 | - foreach ( $post_shortcodes as $shortcode_class => $post_id ) { |
|
293 | + foreach ($post_shortcodes as $shortcode_class => $post_id) { |
|
294 | 294 | // are we on this page, or on the blog page, or an EE CPT category page ? |
295 | - if ( $current_post === $post_name || $term_exists ) { |
|
295 | + if ($current_post === $post_name || $term_exists) { |
|
296 | 296 | // maybe init the shortcode |
297 | 297 | $this->initialize_shortcode_if_active_on_page( |
298 | 298 | $shortcode_class, |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | // but the shortcode is not being tracked for this page |
308 | 308 | } else if ( |
309 | 309 | $post_name !== $page_for_posts |
310 | - && isset( $this->Registry->CFG->core->post_shortcodes[ $page_for_posts ] ) |
|
311 | - && ! isset( $this->Registry->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) |
|
310 | + && isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts]) |
|
311 | + && ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts][$shortcode_class]) |
|
312 | 312 | ) { |
313 | 313 | // then remove the "fallback" shortcode processor |
314 | - remove_shortcode( $shortcode_class ); |
|
314 | + remove_shortcode($shortcode_class); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | } |
318 | 318 | } |
319 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__end', $this ); |
|
319 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $this); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | $WP |
339 | 339 | ) { |
340 | 340 | // verify shortcode is in list of registered shortcodes |
341 | - if ( ! isset( $this->Registry->shortcodes->{$shortcode_class} ) ) { |
|
342 | - if ( $current_post !== $page_for_posts && current_user_can( 'edit_post', $post_id ) ) { |
|
341 | + if ( ! isset($this->Registry->shortcodes->{$shortcode_class} )) { |
|
342 | + if ($current_post !== $page_for_posts && current_user_can('edit_post', $post_id)) { |
|
343 | 343 | EE_Error::add_error( |
344 | 344 | sprintf( |
345 | 345 | __( |
@@ -352,24 +352,24 @@ discard block |
||
352 | 352 | __FUNCTION__, |
353 | 353 | __LINE__ |
354 | 354 | ); |
355 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
355 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
356 | 356 | } |
357 | - add_shortcode( $shortcode_class, array( 'EES_Shortcode', 'invalid_shortcode_processor' ) ); |
|
357 | + add_shortcode($shortcode_class, array('EES_Shortcode', 'invalid_shortcode_processor')); |
|
358 | 358 | return; |
359 | 359 | } |
360 | 360 | // is this : a shortcodes set exclusively for this post, or for the home page, or a category, or a taxonomy ? |
361 | 361 | if ( |
362 | 362 | $term_exists |
363 | 363 | || $current_post === $page_for_posts |
364 | - || isset( $this->Registry->CFG->core->post_shortcodes[ $current_post ] ) |
|
364 | + || isset($this->Registry->CFG->core->post_shortcodes[$current_post]) |
|
365 | 365 | ) { |
366 | 366 | // let's pause to reflect on this... |
367 | - $sc_reflector = new ReflectionClass( 'EES_' . $shortcode_class ); |
|
367 | + $sc_reflector = new ReflectionClass('EES_'.$shortcode_class); |
|
368 | 368 | // ensure that class is actually a shortcode |
369 | 369 | if ( |
370 | - defined( 'WP_DEBUG' ) |
|
370 | + defined('WP_DEBUG') |
|
371 | 371 | && WP_DEBUG === true |
372 | - && ! $sc_reflector->isSubclassOf( 'EES_Shortcode' ) |
|
372 | + && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
373 | 373 | ) { |
374 | 374 | EE_Error::add_error( |
375 | 375 | sprintf( |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | __FUNCTION__, |
384 | 384 | __LINE__ |
385 | 385 | ); |
386 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
386 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
387 | 387 | return; |
388 | 388 | } |
389 | 389 | // and pass the request object to the run method |
390 | 390 | $this->Registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
391 | 391 | // fire the shortcode class's run method, so that it can activate resources |
392 | - $this->Registry->shortcodes->{$shortcode_class}->run( $WP ); |
|
392 | + $this->Registry->shortcodes->{$shortcode_class}->run($WP); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -402,19 +402,19 @@ discard block |
||
402 | 402 | * @param WP_Query $WP_Query |
403 | 403 | * @return void |
404 | 404 | */ |
405 | - public function pre_get_posts( $WP_Query ) { |
|
405 | + public function pre_get_posts($WP_Query) { |
|
406 | 406 | // only load Module_Request_Router if this is the main query |
407 | 407 | if ( |
408 | 408 | $this->Module_Request_Router instanceof EE_Module_Request_Router |
409 | 409 | && $WP_Query->is_main_query() |
410 | 410 | ) { |
411 | 411 | // cycle thru module routes |
412 | - while ( $route = $this->Module_Request_Router->get_route( $WP_Query )) { |
|
412 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
413 | 413 | // determine module and method for route |
414 | - $module = $this->Module_Request_Router->resolve_route( $route[0], $route[1] ); |
|
415 | - if( $module instanceof EED_Module ) { |
|
414 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
415 | + if ($module instanceof EED_Module) { |
|
416 | 416 | // get registered view for route |
417 | - $this->_template_path = $this->Module_Request_Router->get_view( $route ); |
|
417 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
418 | 418 | // grab module name |
419 | 419 | $module_name = $module->module_name(); |
420 | 420 | // map the module to the module objects |
@@ -456,29 +456,29 @@ discard block |
||
456 | 456 | public function wp_enqueue_scripts() { |
457 | 457 | |
458 | 458 | // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
459 | - if ( apply_filters( 'FHEE_load_css', TRUE ) ) { |
|
459 | + if (apply_filters('FHEE_load_css', TRUE)) { |
|
460 | 460 | |
461 | 461 | $this->Registry->CFG->template_settings->enable_default_style = TRUE; |
462 | 462 | //Load the ThemeRoller styles if enabled |
463 | - if ( isset( $this->Registry->CFG->template_settings->enable_default_style ) && $this->Registry->CFG->template_settings->enable_default_style ) { |
|
463 | + if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { |
|
464 | 464 | |
465 | 465 | //Load custom style sheet if available |
466 | - if ( isset( $this->Registry->CFG->template_settings->custom_style_sheet )) { |
|
467 | - wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION ); |
|
466 | + if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
|
467 | + wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->Registry->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION); |
|
468 | 468 | wp_enqueue_style('espresso_custom_css'); |
469 | 469 | } |
470 | 470 | |
471 | - if ( is_readable( EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css' )) { |
|
472 | - wp_register_style( 'espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
471 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')) { |
|
472 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
473 | 473 | } else { |
474 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
474 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
475 | 475 | } |
476 | 476 | wp_enqueue_style('espresso_default'); |
477 | 477 | |
478 | - if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css' )) { |
|
479 | - wp_register_style( 'espresso_style', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
478 | + if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'style.css')) { |
|
479 | + wp_register_style('espresso_style', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
480 | 480 | } else { |
481 | - wp_register_style( 'espresso_style', EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
481 | + wp_register_style('espresso_style', EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | } |
@@ -486,38 +486,38 @@ discard block |
||
486 | 486 | } |
487 | 487 | |
488 | 488 | // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
489 | - if ( apply_filters( 'FHEE_load_js', TRUE ) ) { |
|
489 | + if (apply_filters('FHEE_load_js', TRUE)) { |
|
490 | 490 | |
491 | - wp_enqueue_script( 'jquery' ); |
|
491 | + wp_enqueue_script('jquery'); |
|
492 | 492 | //let's make sure that all required scripts have been setup |
493 | - if ( function_exists( 'wp_script_is' ) && ! wp_script_is( 'jquery' )) { |
|
493 | + if (function_exists('wp_script_is') && ! wp_script_is('jquery')) { |
|
494 | 494 | $msg = sprintf( |
495 | - __( '%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso' ), |
|
495 | + __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso'), |
|
496 | 496 | '<em><br />', |
497 | 497 | '</em>' |
498 | 498 | ); |
499 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
499 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
500 | 500 | } |
501 | 501 | // load core js |
502 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
503 | - wp_enqueue_script( 'espresso_core' ); |
|
504 | - wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
502 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
503 | + wp_enqueue_script('espresso_core'); |
|
504 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
505 | 505 | |
506 | 506 | } |
507 | 507 | |
508 | 508 | //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
509 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
509 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
510 | 510 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
511 | 511 | } |
512 | 512 | |
513 | 513 | |
514 | 514 | //accounting.js library |
515 | 515 | // @link http://josscrowcroft.github.io/accounting.js/ |
516 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
517 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
518 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
519 | - wp_register_script( 'ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE ); |
|
520 | - wp_enqueue_script( 'ee-accounting' ); |
|
516 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
517 | + $acct_js = EE_THIRD_PARTY_URL.'accounting/accounting.js'; |
|
518 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | + wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE); |
|
520 | + wp_enqueue_script('ee-accounting'); |
|
521 | 521 | |
522 | 522 | $currency_config = array( |
523 | 523 | 'currency' => array( |
@@ -540,21 +540,21 @@ discard block |
||
540 | 540 | wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
541 | 541 | } |
542 | 542 | |
543 | - if ( ! function_exists( 'wp_head' )) { |
|
543 | + if ( ! function_exists('wp_head')) { |
|
544 | 544 | $msg = sprintf( |
545 | - __( '%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
545 | + __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
546 | 546 | '<em><br />', |
547 | 547 | '</em>' |
548 | 548 | ); |
549 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
549 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
550 | 550 | } |
551 | - if ( ! function_exists( 'wp_footer' )) { |
|
551 | + if ( ! function_exists('wp_footer')) { |
|
552 | 552 | $msg = sprintf( |
553 | - __( '%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
553 | + __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
554 | 554 | '<em><br />', |
555 | 555 | '</em>' |
556 | 556 | ); |
557 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
557 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | } |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @return void |
569 | 569 | */ |
570 | 570 | public function header_meta_tag() { |
571 | - print( apply_filters("FHEE__EE_Front_Controller__header_meta_tag","<meta name='generator' content='Event Espresso Version " . EVENT_ESPRESSO_VERSION . "' />")); |
|
571 | + print(apply_filters("FHEE__EE_Front_Controller__header_meta_tag", "<meta name='generator' content='Event Espresso Version ".EVENT_ESPRESSO_VERSION."' />")); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -609,10 +609,10 @@ discard block |
||
609 | 609 | */ |
610 | 610 | public function display_errors() { |
611 | 611 | static $shown_already = FALSE; |
612 | - do_action( 'AHEE__EE_Front_Controller__display_errors__begin' ); |
|
612 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
613 | 613 | if ( |
614 | 614 | ! $shown_already |
615 | - && apply_filters( 'FHEE__EE_Front_Controller__display_errors', TRUE ) |
|
615 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', TRUE) |
|
616 | 616 | && is_main_query() |
617 | 617 | && ! is_feed() |
618 | 618 | && in_the_loop() |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | ) { |
621 | 621 | echo EE_Error::get_notices(); |
622 | 622 | $shown_already = TRUE; |
623 | - EEH_Template::display_template( EE_TEMPLATES . 'espresso-ajax-notices.template.php' ); |
|
623 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
624 | 624 | } |
625 | - do_action( 'AHEE__EE_Front_Controller__display_errors__end' ); |
|
625 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | |
@@ -637,12 +637,12 @@ discard block |
||
637 | 637 | * @param string $template_include_path |
638 | 638 | * @return string |
639 | 639 | */ |
640 | - public function template_include( $template_include_path = NULL ) { |
|
641 | - if ( $this->Request_Handler->is_espresso_page() ) { |
|
642 | - $this->_template_path = ! empty( $this->_template_path ) ? basename( $this->_template_path ) : basename( $template_include_path ); |
|
643 | - $template_path = EEH_Template::locate_template( $this->_template_path, array(), false ); |
|
644 | - $this->_template_path = ! empty( $template_path ) ? $template_path : $template_include_path; |
|
645 | - $this->_template = basename( $this->_template_path ); |
|
640 | + public function template_include($template_include_path = NULL) { |
|
641 | + if ($this->Request_Handler->is_espresso_page()) { |
|
642 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
643 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
644 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
645 | + $this->_template = basename($this->_template_path); |
|
646 | 646 | return $this->_template_path; |
647 | 647 | } |
648 | 648 | return $template_include_path; |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | * @param bool $with_path |
658 | 658 | * @return string |
659 | 659 | */ |
660 | - public function get_selected_template( $with_path = FALSE ) { |
|
660 | + public function get_selected_template($with_path = FALSE) { |
|
661 | 661 | return $with_path ? $this->_template_path : $this->_template; |
662 | 662 | } |
663 | 663 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @since $VID:$ |
15 | 15 | * |
16 | 16 | */ |
17 | -abstract class EE_PMT_Base{ |
|
17 | +abstract class EE_PMT_Base { |
|
18 | 18 | |
19 | 19 | const onsite = 'on-site'; |
20 | 20 | const offsite = 'off-site'; |
@@ -95,31 +95,31 @@ discard block |
||
95 | 95 | * @return EE_PMT_Base |
96 | 96 | */ |
97 | 97 | function __construct($pm_instance = NULL) { |
98 | - if ( $pm_instance instanceof EE_Payment_Method ){ |
|
98 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
99 | 99 | $this->set_instance($pm_instance); |
100 | 100 | } |
101 | - if($this->_gateway){ |
|
102 | - $this->_gateway->set_payment_model( EEM_Payment::instance() ); |
|
103 | - $this->_gateway->set_payment_log( EEM_Change_Log::instance() ); |
|
104 | - $this->_gateway->set_template_helper( new EEH_Template() ); |
|
105 | - $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
|
106 | - $this->_gateway->set_money_helper( new EEH_Money() ); |
|
101 | + if ($this->_gateway) { |
|
102 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
103 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
104 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
105 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
106 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
107 | 107 | } |
108 | - if ( ! isset( $this->_has_billing_form ) ) { |
|
108 | + if ( ! isset($this->_has_billing_form)) { |
|
109 | 109 | // by default, On Site gateways have a billing form |
110 | - if ( $this->payment_occurs() == EE_PMT_Base::onsite ) { |
|
111 | - $this->set_has_billing_form( true ); |
|
110 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
111 | + $this->set_has_billing_form(true); |
|
112 | 112 | } else { |
113 | - $this->set_has_billing_form( false ); |
|
113 | + $this->set_has_billing_form(false); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - if( ! $this->_pretty_name){ |
|
117 | + if ( ! $this->_pretty_name) { |
|
118 | 118 | throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso"))); |
119 | 119 | } |
120 | 120 | //if the child didn't specify a default button, use the credit card one |
121 | - if( $this->_default_button_url === NULL){ |
|
122 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
121 | + if ($this->_default_button_url === NULL) { |
|
122 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * @param boolean $has_billing_form |
130 | 130 | */ |
131 | - public function set_has_billing_form( $has_billing_form ) { |
|
132 | - $this->_has_billing_form = filter_var( $has_billing_form, FILTER_VALIDATE_BOOLEAN ); |
|
131 | + public function set_has_billing_form($has_billing_form) { |
|
132 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * sets the file_folder property |
139 | 139 | */ |
140 | - protected function _set_file_folder(){ |
|
140 | + protected function _set_file_folder() { |
|
141 | 141 | $reflector = new ReflectionClass(get_class($this)); |
142 | 142 | $fn = $reflector->getFileName(); |
143 | - $this->_file_folder = dirname($fn).DS; |
|
143 | + $this->_file_folder = dirname($fn).DS; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * sets the file URL with a trailing slash for this PMT |
150 | 150 | */ |
151 | - protected function _set_file_url(){ |
|
152 | - $plugins_dir_fixed = str_replace('\\',DS,WP_PLUGIN_DIR); |
|
153 | - $file_folder_fixed = str_replace('\\',DS,$this->file_folder()); |
|
154 | - $file_path = str_replace($plugins_dir_fixed,WP_PLUGIN_URL,$file_folder_fixed); |
|
151 | + protected function _set_file_url() { |
|
152 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
153 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
154 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
155 | 155 | $this->_file_url = $file_path; |
156 | 156 | } |
157 | 157 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * Gets the default description on all payment methods of this type |
160 | 160 | * @return string |
161 | 161 | */ |
162 | - public function default_description(){ |
|
162 | + public function default_description() { |
|
163 | 163 | return $this->_default_description; |
164 | 164 | } |
165 | 165 | |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * Returns the folder containing the PMT child class, with a trailing slash |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function file_folder(){ |
|
173 | - if( ! $this->_file_folder ) { |
|
172 | + public function file_folder() { |
|
173 | + if ( ! $this->_file_folder) { |
|
174 | 174 | $this->_set_file_folder(); |
175 | 175 | } |
176 | 176 | return $this->_file_folder; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | /** |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public function file_url(){ |
|
185 | - if( ! $this->_file_url ) { |
|
184 | + public function file_url() { |
|
185 | + if ( ! $this->_file_url) { |
|
186 | 186 | $this->_set_file_url(); |
187 | 187 | } |
188 | 188 | return $this->_file_url; |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | * Its important teh payment method instance is set before |
196 | 196 | * @param EE_Payment_Method $payment_method_instance |
197 | 197 | */ |
198 | - function set_instance($payment_method_instance){ |
|
198 | + function set_instance($payment_method_instance) { |
|
199 | 199 | $this->_pm_instance = $payment_method_instance; |
200 | 200 | //if they have already requested the settings form, make sure its |
201 | 201 | //data matches this model object |
202 | - if($this->_settings_form){ |
|
202 | + if ($this->_settings_form) { |
|
203 | 203 | $this->settings_form()->populate_model_obj($payment_method_instance); |
204 | 204 | } |
205 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
205 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
206 | 206 | $this->_gateway->set_settings($payment_method_instance->settings_array()); |
207 | 207 | } |
208 | 208 | } |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | * Gets teh form for displaying to admins where they setup the payment method |
214 | 214 | * @return EE_Payment_Method_Form |
215 | 215 | */ |
216 | - function settings_form(){ |
|
217 | - if( ! $this->_settings_form){ |
|
216 | + function settings_form() { |
|
217 | + if ( ! $this->_settings_form) { |
|
218 | 218 | $this->_settings_form = $this->generate_new_settings_form(); |
219 | - $this->_settings_form->set_payment_method_type( $this ); |
|
220 | - $this->_settings_form->_construct_finalize(NULL, NULL ); |
|
219 | + $this->_settings_form->set_payment_method_type($this); |
|
220 | + $this->_settings_form->_construct_finalize(NULL, NULL); |
|
221 | 221 | //if we have already assigned a model object to this pmt, make |
222 | 222 | //sure its reflected in teh form we just generated |
223 | - if($this->_pm_instance){ |
|
223 | + if ($this->_pm_instance) { |
|
224 | 224 | $this->_settings_form->populate_model_obj($this->_pm_instance); |
225 | 225 | } |
226 | 226 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * this payment method type's settings form later in the request |
247 | 247 | * @param EE_Payment_Method_Form $form |
248 | 248 | */ |
249 | - public function set_settings_form($form){ |
|
249 | + public function set_settings_form($form) { |
|
250 | 250 | $this->_settings_form = $form; |
251 | 251 | } |
252 | 252 | |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | * @param array $extra_args |
270 | 270 | * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
271 | 271 | */ |
272 | - public function billing_form( EE_Transaction $transaction = NULL, $extra_args = array() ){ |
|
272 | + public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array()) { |
|
273 | 273 | // has billing form already been regenerated ? or overwrite cache? |
274 | - if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form ){ |
|
275 | - $this->_billing_form = $this->generate_new_billing_form( $transaction, $extra_args ); |
|
274 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
275 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
276 | 276 | } |
277 | 277 | //if we know who the attendee is, and this is a billing form |
278 | 278 | //that uses attendee info, populate it |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | $transaction instanceof EE_Transaction && |
282 | 282 | $transaction->primary_registration() instanceof EE_Registration && |
283 | 283 | $transaction->primary_registration()->attendee() instanceof EE_Attendee |
284 | - ){ |
|
285 | - $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
|
284 | + ) { |
|
285 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
286 | 286 | } |
287 | 287 | return $this->_billing_form; |
288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param \EE_Transaction $transaction |
294 | 294 | * @return \EE_Billing_Info_Form |
295 | 295 | */ |
296 | - abstract function generate_new_billing_form( EE_Transaction $transaction = NULL ); |
|
296 | + abstract function generate_new_billing_form(EE_Transaction $transaction = NULL); |
|
297 | 297 | |
298 | 298 | |
299 | 299 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param \EE_Billing_Info_Form $billing_form |
305 | 305 | * @return \EE_Billing_Info_Form |
306 | 306 | */ |
307 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
307 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
308 | 308 | return $billing_form; |
309 | 309 | } |
310 | 310 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * if you have form |
316 | 316 | * @param EE_Payment_Method $form |
317 | 317 | */ |
318 | - public function set_billing_form($form){ |
|
318 | + public function set_billing_form($form) { |
|
319 | 319 | $this->_billing_form = $form; |
320 | 320 | } |
321 | 321 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * Returns whether or not this payment method requires HTTPS to be used |
326 | 326 | * @return boolean |
327 | 327 | */ |
328 | - function requires_https(){ |
|
328 | + function requires_https() { |
|
329 | 329 | return $this->_requires_https; |
330 | 330 | } |
331 | 331 | |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | * @return EE_Payment |
344 | 344 | * @throws EE_Error |
345 | 345 | */ |
346 | - function process_payment( EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null,$fail_url = '', $method = 'CART', $by_admin = false ){ |
|
346 | + function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { |
|
347 | 347 | // @todo: add surcharge for the payment method, if any |
348 | - if ( $this->_gateway ) { |
|
348 | + if ($this->_gateway) { |
|
349 | 349 | //there is a gateway, so we're going to make a payment object |
350 | 350 | //but wait! do they already have a payment in progress that we thought was failed? |
351 | 351 | $duplicate_properties = array( |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
357 | 357 | 'PAY_gateway_response' => null, |
358 | 358 | ); |
359 | - $payment = EEM_Payment::instance()->get_one( array( $duplicate_properties )); |
|
359 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
360 | 360 | //if we didn't already have a payment in progress for the same thing, |
361 | 361 | //then we actually want to make a new payment |
362 | - if ( ! $payment instanceof EE_Payment ){ |
|
362 | + if ( ! $payment instanceof EE_Payment) { |
|
363 | 363 | $payment = EE_Payment::new_instance( |
364 | 364 | array_merge( |
365 | 365 | $duplicate_properties, |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | } |
376 | 376 | //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
377 | 377 | $payment->save(); |
378 | - $billing_values = $this->_get_billing_values_from_form( $billing_info ); |
|
378 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
379 | 379 | |
380 | 380 | // Offsite Gateway |
381 | - if( $this->_gateway instanceof EE_Offsite_Gateway ){ |
|
381 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
382 | 382 | |
383 | 383 | $payment = $this->_gateway->set_redirection_info( |
384 | 384 | $payment, |
@@ -394,17 +394,17 @@ discard block |
||
394 | 394 | ); |
395 | 395 | $payment->save(); |
396 | 396 | // Onsite Gateway |
397 | - } elseif ( $this->_gateway instanceof EE_Onsite_Gateway ) { |
|
397 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
398 | 398 | |
399 | - $payment = $this->_gateway->do_direct_payment($payment,$billing_values); |
|
399 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
400 | 400 | $payment->save(); |
401 | 401 | |
402 | 402 | } else { |
403 | 403 | throw new EE_Error( |
404 | 404 | sprintf( |
405 | - __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso' ), |
|
405 | + __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), |
|
406 | 406 | get_class($this), |
407 | - gettype( $this->_gateway ) |
|
407 | + gettype($this->_gateway) |
|
408 | 408 | ) |
409 | 409 | ); |
410 | 410 | } |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | // if there is billing info, clean it and save it now |
429 | - if( $billing_info instanceof EE_Billing_Attendee_Info_Form ){ |
|
430 | - $this->_save_billing_info_to_attendee( $billing_info, $transaction ); |
|
429 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
430 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | return $payment; |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | * @param EE_Billing_Info_Form $billing_form |
441 | 441 | * @return array |
442 | 442 | */ |
443 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
444 | - if($billing_form instanceof EE_Form_Section_Proper ){ |
|
445 | - return $billing_form->input_pretty_values( true ); |
|
446 | - }else{ |
|
443 | + protected function _get_billing_values_from_form($billing_form) { |
|
444 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
445 | + return $billing_form->input_pretty_values(true); |
|
446 | + } else { |
|
447 | 447 | return NULL; |
448 | 448 | } |
449 | 449 | } |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | * @return EE_Payment |
458 | 458 | * @throws EE_Error |
459 | 459 | */ |
460 | - public function handle_ipn($req_data,$transaction){ |
|
460 | + public function handle_ipn($req_data, $transaction) { |
|
461 | 461 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
462 | - if( ! $this->_gateway instanceof EE_Offsite_Gateway){ |
|
463 | - throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r( $this->_gateway, TRUE ))); |
|
462 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
463 | + throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE))); |
|
464 | 464 | |
465 | 465 | } |
466 | - $payment = $this->_gateway->handle_payment_update( $req_data, $transaction ); |
|
466 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
467 | 467 | return $payment; |
468 | 468 | } |
469 | 469 | |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | * @param EE_Transaction $transaction |
477 | 477 | * @return boolean success |
478 | 478 | */ |
479 | - protected function _save_billing_info_to_attendee($billing_form, $transaction){ |
|
480 | - if( ! $transaction || ! $transaction instanceof EE_Transaction){ |
|
479 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) { |
|
480 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
481 | 481 | EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
482 | 482 | return false; |
483 | 483 | } |
484 | 484 | $primary_reg = $transaction->primary_registration(); |
485 | - if( ! $primary_reg ){ |
|
485 | + if ( ! $primary_reg) { |
|
486 | 486 | EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
487 | 487 | return false; |
488 | 488 | } |
489 | 489 | $attendee = $primary_reg->attendee(); |
490 | - if( ! $attendee ){ |
|
490 | + if ( ! $attendee) { |
|
491 | 491 | EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
492 | 492 | return false; |
493 | 493 | } |
494 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method() ); |
|
494 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
495 | 495 | |
496 | 496 | } |
497 | 497 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | * @param array $req_data |
505 | 505 | * @return EE_Payment |
506 | 506 | */ |
507 | - protected function find_payment_for_ipn( EE_Transaction $transaction, $req_data = array() ){ |
|
507 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) { |
|
508 | 508 | return $transaction->last_payment(); |
509 | 509 | } |
510 | 510 | |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
522 | 522 | * @throws EE_Error |
523 | 523 | */ |
524 | - public function handle_unclaimed_ipn( $req_data = array() ){ |
|
525 | - throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this) )); |
|
524 | + public function handle_unclaimed_ipn($req_data = array()) { |
|
525 | + throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * @param EE_Transaction $transaction |
539 | 539 | * @return EE_Payment |
540 | 540 | */ |
541 | - public function finalize_payment_for($transaction){ |
|
541 | + public function finalize_payment_for($transaction) { |
|
542 | 542 | return $transaction->last_payment(); |
543 | 543 | } |
544 | 544 | |
@@ -548,10 +548,10 @@ discard block |
||
548 | 548 | * Whether or not this payment method's gateway supports sending refund requests |
549 | 549 | * @return boolean |
550 | 550 | */ |
551 | - public function supports_sending_refunds(){ |
|
552 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
551 | + public function supports_sending_refunds() { |
|
552 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
553 | 553 | return $this->_gateway->supports_sending_refunds(); |
554 | - }else{ |
|
554 | + } else { |
|
555 | 555 | return false; |
556 | 556 | } |
557 | 557 | } |
@@ -565,14 +565,14 @@ discard block |
||
565 | 565 | * @throws EE_Error |
566 | 566 | * @return EE_Payment |
567 | 567 | */ |
568 | - public function process_refund( EE_Payment $payment, $refund_info = array()){ |
|
569 | - if ( $this->_gateway && $this->_gateway instanceof EE_Gateway ) { |
|
570 | - return $this->_gateway->do_direct_refund( $payment, $refund_info ); |
|
568 | + public function process_refund(EE_Payment $payment, $refund_info = array()) { |
|
569 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
570 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
571 | 571 | } else { |
572 | 572 | throw new EE_Error( |
573 | 573 | sprintf( |
574 | - __( 'Payment Method Type "%s" does not support sending refund requests', 'event_espresso' ), |
|
575 | - get_class( $this ) |
|
574 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
575 | + get_class($this) |
|
576 | 576 | ) |
577 | 577 | ); |
578 | 578 | } |
@@ -586,15 +586,15 @@ discard block |
||
586 | 586 | * @return string |
587 | 587 | * @throws EE_Error |
588 | 588 | */ |
589 | - public function payment_occurs(){ |
|
590 | - if( ! $this->_gateway){ |
|
589 | + public function payment_occurs() { |
|
590 | + if ( ! $this->_gateway) { |
|
591 | 591 | return EE_PMT_Base::offline; |
592 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
592 | + }elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
593 | 593 | return EE_PMT_Base::onsite; |
594 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
594 | + }elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
595 | 595 | return EE_PMT_Base::offsite; |
596 | - }else{ |
|
597 | - throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
|
596 | + } else { |
|
597 | + throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this))); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | * @param EE_Payment $payment |
608 | 608 | * @return string |
609 | 609 | */ |
610 | - public function payment_overview_content(EE_Payment $payment){ |
|
611 | - return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance,'payment'=>$payment) , true); |
|
610 | + public function payment_overview_content(EE_Payment $payment) { |
|
611 | + return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance, 'payment'=>$payment), true); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @type array $template_args any arguments you want passed to the template file while rendering. |
622 | 622 | * Keys will be variable names and values with be their values. |
623 | 623 | */ |
624 | - public function help_tabs_config(){ |
|
624 | + public function help_tabs_config() { |
|
625 | 625 | return array(); |
626 | 626 | } |
627 | 627 | |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | * the payment method's table's PMT_type column) |
633 | 633 | * @return string |
634 | 634 | */ |
635 | - public function system_name(){ |
|
635 | + public function system_name() { |
|
636 | 636 | $classname = get_class($this); |
637 | - return str_replace("EE_PMT_",'',$classname); |
|
637 | + return str_replace("EE_PMT_", '', $classname); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * A pretty i18n version of the PMT name |
644 | 644 | * @return string |
645 | 645 | */ |
646 | - public function pretty_name(){ |
|
646 | + public function pretty_name() { |
|
647 | 647 | return $this->_pretty_name; |
648 | 648 | } |
649 | 649 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * Gets the default absolute URL to the payment method type's button |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function default_button_url(){ |
|
656 | + public function default_button_url() { |
|
657 | 657 | return $this->_default_button_url; |
658 | 658 | } |
659 | 659 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * Gets the gateway used by this payment method (if any) |
664 | 664 | * @return EE_Gateway |
665 | 665 | */ |
666 | - public function get_gateway(){ |
|
666 | + public function get_gateway() { |
|
667 | 667 | return $this->_gateway; |
668 | 668 | } |
669 | 669 | |
@@ -672,8 +672,8 @@ discard block |
||
672 | 672 | /** |
673 | 673 | * @return string html for the link to a help tab |
674 | 674 | */ |
675 | - public function get_help_tab_link(){ |
|
676 | - return EEH_Template::get_help_tab_link( $this->get_help_tab_name() ); |
|
675 | + public function get_help_tab_link() { |
|
676 | + return EEH_Template::get_help_tab_link($this->get_help_tab_name()); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * Returns the name of the help tab for this PMT |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public function get_help_tab_name(){ |
|
686 | - return 'ee_' . strtolower( $this->system_name() ) . '_help_tab'; |
|
685 | + public function get_help_tab_name() { |
|
686 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | * this PMT by an admin |
692 | 692 | * @return string |
693 | 693 | */ |
694 | - public function cap_name(){ |
|
695 | - return 'ee_payment_method_' . strtolower( $this->system_name() ); |
|
694 | + public function cap_name() { |
|
695 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
@@ -704,9 +704,9 @@ discard block |
||
704 | 704 | * @param EE_Payment $payment |
705 | 705 | * @return void |
706 | 706 | */ |
707 | - public function update_txn_based_on_payment( $payment ){ |
|
708 | - if( $this->_gateway instanceof EE_Gateway ){ |
|
709 | - $this->_gateway->update_txn_based_on_payment( $payment ); |
|
707 | + public function update_txn_based_on_payment($payment) { |
|
708 | + if ($this->_gateway instanceof EE_Gateway) { |
|
709 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Class EE_Payment_Method_Manager |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) { |
|
38 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Resets the instance and returns a new one |
47 | 47 | * @return EE_Payment_Method_Manager |
48 | 48 | */ |
49 | - public static function reset(){ |
|
49 | + public static function reset() { |
|
50 | 50 | self::$_instance = NULL; |
51 | 51 | return self::instance(); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * or just re-use the PMTs we found last time we checked during this request (if |
58 | 58 | * we have not yet checked during this request, then we need to check anyways) |
59 | 59 | */ |
60 | - public function maybe_register_payment_methods( $force_recheck = FALSE ){ |
|
61 | - if( ! $this->_payment_method_types || $force_recheck ){ |
|
60 | + public function maybe_register_payment_methods($force_recheck = FALSE) { |
|
61 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
62 | 62 | $this->_register_payment_methods(); |
63 | 63 | //if in admin lets ensure caps are set. |
64 | - if ( is_admin() ) { |
|
65 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) ); |
|
64 | + if (is_admin()) { |
|
65 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
66 | 66 | EE_Registry::instance()->CAP->init_caps(); |
67 | 67 | } |
68 | 68 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function _register_payment_methods() { |
77 | 77 | // grab list of installed modules |
78 | - $pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
78 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
79 | 79 | // filter list of modules to register |
80 | - $pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register ); |
|
80 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register); |
|
81 | 81 | |
82 | 82 | // loop through folders |
83 | - foreach ( $pm_to_register as $pm_path ) { |
|
84 | - $this->register_payment_method( $pm_path ); |
|
83 | + foreach ($pm_to_register as $pm_path) { |
|
84 | + $this->register_payment_method($pm_path); |
|
85 | 85 | } |
86 | - do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' ); |
|
86 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
87 | 87 | // filter list of installed modules |
88 | 88 | //keep them organized alphabetically by the payment method type's name |
89 | - ksort( $this->_payment_method_types ); |
|
90 | - return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types ); |
|
89 | + ksort($this->_payment_method_types); |
|
90 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | * @param string $payment_method_path - full path up to and including payment method folder |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function register_payment_method( $payment_method_path = '' ) { |
|
103 | - do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path ); |
|
102 | + public function register_payment_method($payment_method_path = '') { |
|
103 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
104 | 104 | $module_ext = '.pm.php'; |
105 | 105 | // make all separators match |
106 | - $payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS ); |
|
106 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
107 | 107 | // grab and sanitize module name |
108 | - $module_dir = basename( $payment_method_path ); |
|
108 | + $module_dir = basename($payment_method_path); |
|
109 | 109 | // create classname from module directory name |
110 | - $module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir )); |
|
110 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
111 | 111 | // add class prefix |
112 | - $module_class = 'EE_PMT_' . $module; |
|
112 | + $module_class = 'EE_PMT_'.$module; |
|
113 | 113 | // does the module exist ? |
114 | - if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) { |
|
115 | - $msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
116 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
114 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
115 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); } |
|
119 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); } |
|
120 | 120 | // load the module class file |
121 | - require_once( $payment_method_path . DS . $module_class . $module_ext ); |
|
122 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
121 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
122 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
123 | 123 | // verify that class exists |
124 | - if ( ! class_exists( $module_class )) { |
|
125 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
124 | + if ( ! class_exists($module_class)) { |
|
125 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
127 | 127 | return FALSE; |
128 | 128 | } |
129 | 129 | // add to array of registered modules |
130 | - $this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext; |
|
130 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
131 | 131 | return TRUE; |
132 | 132 | } |
133 | 133 | /** |
@@ -136,18 +136,18 @@ discard block |
||
136 | 136 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
137 | 137 | * @return boolean |
138 | 138 | */ |
139 | - public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){ |
|
139 | + public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) { |
|
140 | 140 | if ( |
141 | 141 | $force_recheck |
142 | - || ! is_array( $this->_payment_method_types ) |
|
143 | - || ! isset( $this->_payment_method_types[$payment_method_name] ) |
|
142 | + || ! is_array($this->_payment_method_types) |
|
143 | + || ! isset($this->_payment_method_types[$payment_method_name]) |
|
144 | 144 | ) { |
145 | 145 | $this->maybe_register_payment_methods($force_recheck); |
146 | 146 | } |
147 | - if(isset($this->_payment_method_types[$payment_method_name])){ |
|
147 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
148 | 148 | require_once($this->_payment_method_types[$payment_method_name]); |
149 | 149 | return true; |
150 | - }else{ |
|
150 | + } else { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | } |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
159 | 159 | * @return array |
160 | 160 | */ |
161 | - public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){ |
|
161 | + public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) { |
|
162 | 162 | $this->maybe_register_payment_methods($force_recheck); |
163 | - if($with_prefixes){ |
|
163 | + if ($with_prefixes) { |
|
164 | 164 | $classnames = array_keys($this->_payment_method_types); |
165 | 165 | $payment_methods = array(); |
166 | - foreach($classnames as $classname){ |
|
166 | + foreach ($classnames as $classname) { |
|
167 | 167 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
168 | 168 | } |
169 | 169 | return $payment_methods; |
170 | - }else{ |
|
170 | + } else { |
|
171 | 171 | return array_keys($this->_payment_method_types); |
172 | 172 | } |
173 | 173 | } |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
178 | 178 | * @return EE_PMT_Base[] |
179 | 179 | */ |
180 | - public function payment_method_types( $force_recheck = FALSE ){ |
|
180 | + public function payment_method_types($force_recheck = FALSE) { |
|
181 | 181 | $this->maybe_register_payment_methods($force_recheck); |
182 | 182 | $pmt_objs = array(); |
183 | - foreach($this->payment_method_type_names(true) as $classname){ |
|
183 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
184 | 184 | $pmt_objs[] = new $classname; |
185 | 185 | } |
186 | 186 | return $pmt_objs; |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param string $classname |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - public function payment_method_type_sans_class_prefix($classname){ |
|
196 | - return str_replace( "EE_PMT_", "", $classname ); |
|
195 | + public function payment_method_type_sans_class_prefix($classname) { |
|
196 | + return str_replace("EE_PMT_", "", $classname); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param string $type |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function payment_method_class_from_type($type){ |
|
204 | + public function payment_method_class_from_type($type) { |
|
205 | 205 | $this->maybe_register_payment_methods(); |
206 | 206 | return "EE_PMT_".$type; |
207 | 207 | } |
@@ -215,39 +215,39 @@ discard block |
||
215 | 215 | * @return \EE_Payment_Method |
216 | 216 | * @throws \EE_Error |
217 | 217 | */ |
218 | - public function activate_a_payment_method_of_type( $payment_method_type ){ |
|
218 | + public function activate_a_payment_method_of_type($payment_method_type) { |
|
219 | 219 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
220 | - if( ! $payment_method instanceof EE_Payment_Method ){ |
|
220 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
221 | 221 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
222 | - if(class_exists($pm_type_class)){ |
|
222 | + if (class_exists($pm_type_class)) { |
|
223 | 223 | /** @var $pm_type_obj EE_PMT_Base */ |
224 | 224 | $pm_type_obj = new $pm_type_class; |
225 | 225 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
226 | - if( ! $payment_method){ |
|
227 | - $payment_method = $this->create_payment_method_of_type( $pm_type_obj ); |
|
226 | + if ( ! $payment_method) { |
|
227 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
228 | 228 | } |
229 | - $payment_method->set_type( $payment_method_type ); |
|
230 | - $this->initialize_payment_method( $payment_method ); |
|
229 | + $payment_method->set_type($payment_method_type); |
|
230 | + $this->initialize_payment_method($payment_method); |
|
231 | 231 | } else { |
232 | 232 | throw new EE_Error( |
233 | 233 | sprintf( |
234 | - __( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
234 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
235 | 235 | $pm_type_class ) |
236 | 236 | ); |
237 | 237 | } |
238 | 238 | } |
239 | 239 | $payment_method->set_active(); |
240 | 240 | $payment_method->save(); |
241 | - $this->set_usable_currencies_on_payment_method( $payment_method ); |
|
242 | - if( $payment_method->type() === 'Invoice' ){ |
|
241 | + $this->set_usable_currencies_on_payment_method($payment_method); |
|
242 | + if ($payment_method->type() === 'Invoice') { |
|
243 | 243 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
244 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
245 | - $message_resource_manager->ensure_message_type_is_active( 'invoice', 'html' ); |
|
246 | - $message_resource_manager->ensure_messenger_is_active( 'pdf' ); |
|
244 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
245 | + $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
246 | + $message_resource_manager->ensure_messenger_is_active('pdf'); |
|
247 | 247 | EE_Error::add_attention( |
248 | 248 | sprintf( |
249 | - __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), |
|
250 | - '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', |
|
249 | + __('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), |
|
250 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
251 | 251 | '</a>' |
252 | 252 | ) |
253 | 253 | ); |
@@ -265,17 +265,17 @@ discard block |
||
265 | 265 | * @return EE_Payment_Method |
266 | 266 | * @throws \EE_Error |
267 | 267 | */ |
268 | - public function create_payment_method_of_type( $pm_type_obj ) { |
|
268 | + public function create_payment_method_of_type($pm_type_obj) { |
|
269 | 269 | global $current_user; |
270 | 270 | $payment_method = EE_Payment_Method::new_instance( |
271 | 271 | array( |
272 | 272 | 'PMD_type' => $pm_type_obj->system_name(), |
273 | 273 | 'PMD_name' => $pm_type_obj->pretty_name(), |
274 | 274 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
275 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
275 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
276 | 276 | 'PMD_wp_user' => $current_user->ID, |
277 | 277 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
278 | - array( array( 'PMD_type' => array( '!=', 'Admin_Only' ))) |
|
278 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
279 | 279 | ) * 10, |
280 | 280 | ) |
281 | 281 | ); |
@@ -291,21 +291,21 @@ discard block |
||
291 | 291 | * @return EE_Payment_Method |
292 | 292 | * @throws \EE_Error |
293 | 293 | */ |
294 | - public function initialize_payment_method( $payment_method ) { |
|
294 | + public function initialize_payment_method($payment_method) { |
|
295 | 295 | $pm_type_obj = $payment_method->type_obj(); |
296 | - $payment_method->set_description( $pm_type_obj->default_description() ); |
|
297 | - if( ! $payment_method->button_url() ){ |
|
298 | - $payment_method->set_button_url( $pm_type_obj->default_button_url() ); |
|
296 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
297 | + if ( ! $payment_method->button_url()) { |
|
298 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
299 | 299 | } |
300 | 300 | //now add setup its default extra meta properties |
301 | 301 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
302 | - if ( ! empty( $extra_metas ) ) { |
|
302 | + if ( ! empty($extra_metas)) { |
|
303 | 303 | //verify the payment method has an ID before adding extra meta |
304 | - if ( ! $payment_method->ID() ) { |
|
304 | + if ( ! $payment_method->ID()) { |
|
305 | 305 | $payment_method->save(); |
306 | 306 | } |
307 | - foreach ( $extra_metas as $meta_name => $input ) { |
|
308 | - $payment_method->update_extra_meta( $meta_name, $input->raw_value() ); |
|
307 | + foreach ($extra_metas as $meta_name => $input) { |
|
308 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | return $payment_method; |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | * @return EE_Payment_Method |
321 | 321 | * @throws \EE_Error |
322 | 322 | */ |
323 | - public function set_usable_currencies_on_payment_method( $payment_method ) { |
|
324 | - foreach($payment_method->get_all_usable_currencies() as $currency_obj){ |
|
323 | + public function set_usable_currencies_on_payment_method($payment_method) { |
|
324 | + foreach ($payment_method->get_all_usable_currencies() as $currency_obj) { |
|
325 | 325 | $payment_method->_add_relation_to($currency_obj, 'Currency'); |
326 | 326 | } |
327 | 327 | return $payment_method; |
@@ -339,19 +339,19 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return int count of rows updated. |
341 | 341 | */ |
342 | - public function deactivate_payment_method( $payment_method_slug ) { |
|
342 | + public function deactivate_payment_method($payment_method_slug) { |
|
343 | 343 | EE_Log::instance()->log( |
344 | 344 | __FILE__, |
345 | 345 | __FUNCTION__, |
346 | 346 | sprintf( |
347 | - __( 'Payment method with slug %1$s is being deactivated by site admin', 'event_espresso' ), |
|
347 | + __('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'), |
|
348 | 348 | $payment_method_slug |
349 | 349 | ), |
350 | 350 | 'payment_method_change' |
351 | 351 | ); |
352 | 352 | $count_updated = EEM_Payment_Method::instance()->update( |
353 | - array( 'PMD_scope' => array() ), |
|
354 | - array( array( 'PMD_slug' => $payment_method_slug ) ) |
|
353 | + array('PMD_scope' => array()), |
|
354 | + array(array('PMD_slug' => $payment_method_slug)) |
|
355 | 355 | ); |
356 | 356 | return $count_updated; |
357 | 357 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param array $caps capabilities being filtered |
366 | 366 | * @return array |
367 | 367 | */ |
368 | - public function add_payment_method_caps( $caps ) { |
|
368 | + public function add_payment_method_caps($caps) { |
|
369 | 369 | /* add dynamic caps from payment methods |
370 | 370 | * at the time of writing, october 20 2014, these are the caps added: |
371 | 371 | * ee_payment_method_admin_only |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * their related capability automatically added too, so long as they are |
381 | 381 | * registered properly using EE_Register_Payment_Method::register() |
382 | 382 | */ |
383 | - foreach( $this->payment_method_types() as $payment_method_type_obj ){ |
|
383 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
384 | 384 | $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
385 | 385 | } |
386 | 386 | return $caps; |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | * @since 4.6 |
11 | 11 | * |
12 | 12 | */ |
13 | -class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
13 | +class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param null $validation_error_message |
17 | 17 | */ |
18 | - public function __construct( $validation_error_message = NULL ) { |
|
19 | - if( ! $validation_error_message ){ |
|
18 | + public function __construct($validation_error_message = NULL) { |
|
19 | + if ( ! $validation_error_message) { |
|
20 | 20 | $allowedtags = $this->_get_allowed_tags(); |
21 | - $validation_error_message = sprintf( __( "Only simple HTML tags are allowed. Eg, %s", "event_espresso" ), implode( ",", array_keys( $allowedtags ) ) ); |
|
21 | + $validation_error_message = sprintf(__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), implode(",", array_keys($allowedtags))); |
|
22 | 22 | } |
23 | - parent::__construct( $validation_error_message ); |
|
23 | + parent::__construct($validation_error_message); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function get_list_of_allowed_tags() { |
45 | 45 | $allowed_tags = $this->_get_allowed_tags(); |
46 | - ksort( $allowed_tags ); |
|
47 | - return implode( ', ', array_keys( $allowed_tags ) ); |
|
46 | + ksort($allowed_tags); |
|
47 | + return implode(', ', array_keys($allowed_tags)); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function validate($normalized_value) { |
57 | 57 | $allowedtags = $this->_get_allowed_tags(); |
58 | - parent::validate( $normalized_value ); |
|
59 | - $normalized_value_sans_tags = wp_kses( "$normalized_value",$allowedtags ); |
|
60 | - if ( strlen( $normalized_value ) > strlen( $normalized_value_sans_tags ) ) { |
|
61 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'complex_html_tags' ); |
|
58 | + parent::validate($normalized_value); |
|
59 | + $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedtags); |
|
60 | + if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
61 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -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; |