Completed
Branch BUG-8511-spco-revisit-oversell... (b4a10b)
by
unknown
15:37
created
core/libraries/form_sections/inputs/EE_Phone_Input.input.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -15,18 +15,18 @@  discard block
 block discarded – undo
15 15
  * @author				Mike Nelson
16 16
  *
17 17
  */
18
-class EE_Phone_Input extends EE_Text_Input{
18
+class EE_Phone_Input extends EE_Text_Input {
19 19
 	/**
20 20
 	 * @param array $options
21 21
 	 */
22
-	function __construct($options = array()){
22
+	function __construct($options = array()) {
23 23
 		$this->_add_validation_strategy(
24 24
 			new EE_Text_Validation_Strategy(
25
-				__( 'Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso' ),
25
+				__('Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso'),
26 26
 				'~^([\d]{10})|([\d]{3}-[\d]{3}-[\d]{4})$~'
27 27
 			)
28 28
 		);
29
-		parent::__construct( $options );
29
+		parent::__construct($options);
30 30
 	}
31 31
 
32 32
 
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 1 patch
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
payment_methods/Paypal_Pro/templates/paypal_pro_debug_info.template.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 /**
6 6
  * Event Espresso
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 						<li><?php printf(
40 40
 							__('To find the sandbox account\'s credit card, go to %1$s, then "Dashboard", then under Sandbox click "Accounts", then click your account and click "Profile", then in the popup that appears click on the "Funding" tab. Your testing card is listed there.', 'event_espresso'),
41 41
 							'<a href="http://developer.paypal.com">developer.paypal.com</a>'); ?></li>
42
-						<li><?php printf(__('CVV2 should be 115 (see %s PayPal\'s documentation for other special codes %s)', 'event_espresso'),'<a href="https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions#id108HH0RJ0TS" target="_blank">','</a>'); ?></li>
42
+						<li><?php printf(__('CVV2 should be 115 (see %s PayPal\'s documentation for other special codes %s)', 'event_espresso'), '<a href="https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions#id108HH0RJ0TS" target="_blank">', '</a>'); ?></li>
43 43
 					</ul>
44 44
 
45 45
 					<p class="test-credit-cards-info-pg">
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 					<p class="test-credit-cards-info-pg">
68 68
 						<strong><?php _e('Testing Result Code Responses', 'event_espresso'); ?></strong><br/>
69
-						<span class="small-text"><?php printf(__('You can use the amount of the transaction to generate a particular result code (see %s PayPal\'s documentation%s). The table below lists the general guidelines for specifying amounts. IMPORTANT: before you attempt any of these, ensure your sandbox PayPal account has %s "Negative Testing" set to on%s. Also be aware that you can generate AVS errors by using certain strings in your address field, and CVV errors using certain CVV values. See %s this PayPal doc %s', 'event_espresso'),"<a href='https://developer.paypal.com/docs/classic/api/errorcodes/#id09C3GA00GR1' target='_blank'>","</a>", "<a href='https://docs.google.com/a/eventespresso.com/file/d/0B5P8GXTvZgfMNXNkZ2s5VUlHTUk/edit?usp=drivesdk' target='_blank'>","</a>","<a href='https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions' target='_blank'>","</a>"); ?></span>
69
+						<span class="small-text"><?php printf(__('You can use the amount of the transaction to generate a particular result code (see %s PayPal\'s documentation%s). The table below lists the general guidelines for specifying amounts. IMPORTANT: before you attempt any of these, ensure your sandbox PayPal account has %s "Negative Testing" set to on%s. Also be aware that you can generate AVS errors by using certain strings in your address field, and CVV errors using certain CVV values. See %s this PayPal doc %s', 'event_espresso'), "<a href='https://developer.paypal.com/docs/classic/api/errorcodes/#id09C3GA00GR1' target='_blank'>", "</a>", "<a href='https://docs.google.com/a/eventespresso.com/file/d/0B5P8GXTvZgfMNXNkZ2s5VUlHTUk/edit?usp=drivesdk' target='_blank'>", "</a>", "<a href='https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions' target='_blank'>", "</a>"); ?></span>
70 70
 					</p>
71 71
 
72 72
 					<div class="tbl-wrap">
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Email_Shortcodes.lib.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
 		$this->description = __('All shortcodes related to emails', 'event_espresso');
44 44
 		$this->_shortcodes = array(
45 45
 			'[SITE_ADMIN_EMAIL]' => __('Will be replaced with the admin email for the site that Event Espresso is installed on', 'event_espresso'),
46
-			'[EVENT_AUTHOR_FORMATTED_EMAIL]' => __('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'),'<strong>','</strong>',
46
+			'[EVENT_AUTHOR_FORMATTED_EMAIL]' => __('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'), '<strong>', '</strong>',
47 47
 			'[EVENT_AUTHOR_EMAIL]' => __('This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', 'event_espresso'), '[EVENT_AUTHOR_FORMATTED_EMAIL]',
48
-			'[CO_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"', 'event_espresso' ),
48
+			'[CO_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"', 'event_espresso'),
49 49
 			'[CO_EMAIL]' => __('This will parse to the email address only for the organization set in Your Organization Settings.', 'event_espresso'),
50
-			'[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"', 'event_espresso' ),
50
+			'[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"', 'event_espresso'),
51 51
 			'[ESPRESSO_ADMIN_EMAIL]' => __('This parses to the email address only for the organization set in Your Organization Settings page.', 'event_espresso')
52 52
 			);
53 53
 	}
54 54
 
55 55
 
56
-	protected function _parser( $shortcode ) {
56
+	protected function _parser($shortcode) {
57 57
 
58
-		switch ( $shortcode ) {
58
+		switch ($shortcode) {
59 59
 
60 60
 			case '[SITE_ADMIN_EMAIL]' :
61 61
 				return $this->_get_site_admin_email();
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 				break;
67 67
 
68 68
 			case '[EVENT_AUTHOR_EMAIL]' :
69
-				return $this->_get_event_admin_emails( FALSE );
69
+				return $this->_get_event_admin_emails(FALSE);
70 70
 				break;
71 71
 
72 72
 			case '[CO_FORMATTED_EMAIL]' :
73 73
 			case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' :
74
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) . '>';
74
+				return EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.EE_Registry::instance()->CFG->organization->get_pretty('email').'>';
75 75
 				break;
76 76
 
77 77
 			case '[CO_EMAIL]' :
78 78
 			case '[ESPRESSO_ADMIN_EMAIL]' :
79
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
79
+				return EE_Registry::instance()->CFG->organization->get_pretty('email');
80 80
 				break;
81 81
 
82 82
 			default :
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 
101
-	private function _get_event_admin_emails( $fancy_headers = TRUE ) {
101
+	private function _get_event_admin_emails($fancy_headers = TRUE) {
102 102
 
103
-		if ( !empty( $this->_data->admin_email ) ) {
104
-			if ( ! $fancy_headers )
103
+		if ( ! empty($this->_data->admin_email)) {
104
+			if ( ! $fancy_headers)
105 105
 				return $this->_data->admin_email;
106
-			return !empty( $this->_data->fname ) ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $this->_data->admin_email . '>';
106
+			return ! empty($this->_data->fname) ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$this->_data->admin_email.'>';
107 107
 		}
108 108
 
109 109
 		//k this shortcode has been used else where.  Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events.  We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!.
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 		$admin_email = array();
112 112
 
113 113
 		//loop through events and set the list of event_ids to retrieve so we can do ONE query.
114
-		foreach ( $this->_data->events as $event ) {
114
+		foreach ($this->_data->events as $event) {
115 115
 			$ids[] = $event['ID'];
116 116
 		}
117 117
 
118 118
 		//get all the events
119
-		$events = EE_Registry::instance()->load_model('Event')->get_all( array(array('EVT_ID' => array('IN', $ids ) ) ) );
119
+		$events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids))));
120 120
 
121 121
 		//now loop through each event and setup the details
122 122
 		$admin_details = array();
123 123
 		$cnt = 0;
124
-		foreach ( $events as $event ) {
125
-			$user = get_userdata($event->get('EVT_wp_user') );
124
+		foreach ($events as $event) {
125
+			$user = get_userdata($event->get('EVT_wp_user'));
126 126
 			$admin_details[$cnt] = new stdClass();
127 127
 			$admin_details[$cnt]->email = $user->user_email;
128 128
 			$admin_details[$cnt]->first_name = $user->user_firstname;
@@ -131,28 +131,28 @@  discard block
 block discarded – undo
131 131
 		}
132 132
 
133 133
 		//results?
134
-		if ( empty($admin_details) || !is_array($admin_details) ) {
134
+		if (empty($admin_details) || ! is_array($admin_details)) {
135 135
 			$msg[] = __('The admin details could not be retrieved from the database.', 'event_espresso');
136
-			$msg[] = sprintf( __('Query: %s', 'event_espresso'), $sql );
137
-			$msg[] = sprintf( __('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE) );
138
-			$msg[] = sprintf( __('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE) );
139
-			$msg[] = sprintf( __('Query Results: %s', 'event_espresso'), var_export($admin_details) );
140
-			do_action( 'AHEE_log', __FILE__, __FUNCTION__, implode( PHP_EOL, $msg ), 'shortcode_parser' );
136
+			$msg[] = sprintf(__('Query: %s', 'event_espresso'), $sql);
137
+			$msg[] = sprintf(__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE));
138
+			$msg[] = sprintf(__('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE));
139
+			$msg[] = sprintf(__('Query Results: %s', 'event_espresso'), var_export($admin_details));
140
+			do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser');
141 141
 		}
142 142
 
143
-		foreach ( $admin_details as $admin ) {
143
+		foreach ($admin_details as $admin) {
144 144
 			//only add an admin email if it is present.
145
-			if ( empty( $admin->email ) || $admin->email == '' ) continue;
145
+			if (empty($admin->email) || $admin->email == '') continue;
146 146
 
147
-			if ( ! $fancy_headers ) {
147
+			if ( ! $fancy_headers) {
148 148
 				$admin_email[] = $admin->email;
149 149
 				continue;
150 150
 			}
151 151
 
152
-			$admin_email[] = !empty( $admin->first_name ) ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $admin->email . '>';
152
+			$admin_email[] = ! empty($admin->first_name) ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>';
153 153
 		}
154 154
 
155
-		$admin_email = implode( ',', $admin_email );
155
+		$admin_email = implode(',', $admin_email);
156 156
 		return $admin_email;
157 157
 	}
158 158
 
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Organization_Shortcodes.lib.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -58,96 +58,96 @@  discard block
 block discarded – undo
58 58
 			'[CO_GOOGLE_URL]' => __('Link to organization Google page', 'event_espresso'),
59 59
 			'[CO_LINKEDIN_URL]' => __('Link to organization LinkedIn page', 'event_espresso'),
60 60
 			'[CO_INSTAGRAM_URL]' => __('Link to organization Instagram page', 'event_espresso'),
61
-			'[CO_TAX_NUMBER_*]' => __('This is the shortcode used for displaying any tax number for the company.  %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is.  It defaults to "VAT/Tax Number:".  To change this prefix you do the following format for this shortcode:  [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56.  Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso','<strong>','</strong>')
61
+			'[CO_TAX_NUMBER_*]' => __('This is the shortcode used for displaying any tax number for the company.  %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is.  It defaults to "VAT/Tax Number:".  To change this prefix you do the following format for this shortcode:  [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56.  Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso', '<strong>', '</strong>')
62 62
 			);
63 63
 	}
64 64
 
65 65
 
66
-	protected function _parser( $shortcode ) {
66
+	protected function _parser($shortcode) {
67 67
 
68
-		switch ( $shortcode ) {
68
+		switch ($shortcode) {
69 69
 
70 70
 			case '[COMPANY]' :
71
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
71
+				return EE_Registry::instance()->CFG->organization->get_pretty('name');
72 72
 				break;
73 73
 
74 74
 			case '[CO_ADD1]' :
75
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' );
75
+				return EE_Registry::instance()->CFG->organization->get_pretty('address_1');
76 76
 				break;
77 77
 
78 78
 			case '[CO_ADD2]' :
79
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' );
79
+				return EE_Registry::instance()->CFG->organization->get_pretty('address_2');
80 80
 				break;
81 81
 
82 82
 			case '[CO_CITY]' :
83
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'city' );
83
+				return EE_Registry::instance()->CFG->organization->get_pretty('city');
84 84
 				break;
85 85
 
86 86
 			case '[CO_STATE]' :
87
-				$state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( EE_Registry::instance()->CFG->organization->STA_ID );
87
+				$state = EE_Registry::instance()->load_model('State')->get_one_by_ID(EE_Registry::instance()->CFG->organization->STA_ID);
88 88
 				return $state->name();
89 89
 				break;
90 90
 
91 91
 			case '[CO_ZIP]' :
92
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'zip' );
92
+				return EE_Registry::instance()->CFG->organization->get_pretty('zip');
93 93
 				break;
94 94
 
95 95
 			case '[CO_EMAIL]' :
96
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
96
+				return EE_Registry::instance()->CFG->organization->get_pretty('email');
97 97
 				break;
98 98
 
99 99
 			case '[CO_PHONE]' :
100
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'phone' );
100
+				return EE_Registry::instance()->CFG->organization->get_pretty('phone');
101 101
 				break;
102 102
 
103 103
 			case '[CO_LOGO]' :
104
-				return '<img src="' . EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) . '" id="headerImage" />';
104
+				return '<img src="'.EE_Registry::instance()->CFG->organization->get_pretty('logo_url').'" id="headerImage" />';
105 105
 				break;
106 106
 
107 107
 			case '[CO_LOGO_URL]' :
108
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
108
+				return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
109 109
 				break;
110 110
 
111 111
 			case '[CO_FACEBOOK_URL]' :
112
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
112
+				return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
113 113
 				break;
114 114
 
115 115
 			case '[CO_TWITTER_URL]' :
116
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
116
+				return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
117 117
 				break;
118 118
 
119 119
 			case '[CO_PINTEREST_URL]' :
120
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
120
+				return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
121 121
 				break;
122 122
 
123 123
 			case '[CO_LINKEDIN_URL]' :
124
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
124
+				return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
125 125
 				break;
126 126
 
127 127
 			case '[CO_GOOGLE_URL]' :
128
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
128
+				return EE_Registry::instance()->CFG->organization->get_pretty('google');
129 129
 				break;
130 130
 
131 131
 			case '[CO_INSTAGRAM_URL]' :
132
-				return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
132
+				return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
133 133
 				break;
134 134
 
135 135
 		}
136 136
 
137 137
 		//also allow for parameter shortcode
138
-		if ( strpos( $shortcode, '[CO_TAX_NUMBER_*' ) !== FALSE ) {
138
+		if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== FALSE) {
139 139
 			//first see if there is any company tax number set and bail early if not
140 140
 			$tax_number = EE_Registry::instance()->CFG->organization->vat;
141
-			if ( empty( $tax_number ) ) {
141
+			if (empty($tax_number)) {
142 142
 				return '';
143 143
 			}
144 144
 
145 145
 			//see if there are any attributes.
146
-			$attrs = $this->_get_shortcode_attrs( $shortcode );
146
+			$attrs = $this->_get_shortcode_attrs($shortcode);
147 147
 
148 148
 			//set custom attrs if present (or default)
149
-			$prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso');
150
-			return $prefix . $tax_number;
149
+			$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso');
150
+			return $prefix.$tax_number;
151 151
 		}
152 152
 
153 153
 		return '';
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Checkbox_Display_Strategy.strategy.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -18,43 +18,43 @@
 block discarded – undo
18 18
 	 * @throws EE_Error
19 19
 	 * @return string of html to display the field
20 20
 	 */
21
-	public function display(){
21
+	public function display() {
22 22
 		$input = $this->get_input();
23 23
 		//d( $input );
24
-		$multi = count( $input->options() ) > 1 ? TRUE : FALSE;
24
+		$multi = count($input->options()) > 1 ? TRUE : FALSE;
25 25
 		$input->set_label_sizes();
26 26
 		$label_size_class = $input->get_label_size_class();
27 27
 		$html = '';
28
-		if ( ! is_array( $input->raw_value() ) && $input->raw_value() !== NULL ) {
28
+		if ( ! is_array($input->raw_value()) && $input->raw_value() !== NULL) {
29 29
 			EE_Error::doing_it_wrong(
30 30
 				'EE_Checkbox_Display_Strategy::display()',
31 31
 				sprintf(
32
-					__( 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'),
32
+					__('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'),
33 33
 					$input->html_id(),
34
-					var_export( $input->raw_value(), true),
35
-					$input->html_name() . '[]'
34
+					var_export($input->raw_value(), true),
35
+					$input->html_name().'[]'
36 36
 				),
37 37
 				'4.8.1'
38 38
 			);
39 39
 		}
40
-		$input_raw_value = (array)$input->raw_value();
41
-		foreach( $input->options() as $value => $display_text ){
42
-			$value = $input->get_normalization_strategy()->unnormalize_one( $value );
43
-			$html_id = $this->get_sub_input_id( $value );
44
-			$html .= EEH_HTML::nl( 0, 'checkbox' );
45
-			$html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
46
-			$html .= EEH_HTML::nl( 1, 'checkbox' );
40
+		$input_raw_value = (array) $input->raw_value();
41
+		foreach ($input->options() as $value => $display_text) {
42
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
43
+			$html_id = $this->get_sub_input_id($value);
44
+			$html .= EEH_HTML::nl(0, 'checkbox');
45
+			$html .= '<label for="'.$html_id.'" id="'.$html_id.'-lbl" class="ee-checkbox-label-after'.$label_size_class.'">';
46
+			$html .= EEH_HTML::nl(1, 'checkbox');
47 47
 			$html .= '<input type="checkbox"';
48
-			$html .= ' name="' . $input->html_name() . '[]"';
49
-			$html .= ' id="' . $html_id . '"';
50
-			$html .= ' class="' . $input->html_class() . '"';
51
-			$html .= ' style="' . $input->html_style() . '"';
52
-			$html .= ' value="' . esc_attr( $value ) . '"';
53
-			$html .= ! empty( $input_raw_value ) && in_array( $value, $input_raw_value ) ? ' checked="checked"' : '';
54
-			$html .= ' ' . $this->_input->other_html_attributes();
48
+			$html .= ' name="'.$input->html_name().'[]"';
49
+			$html .= ' id="'.$html_id.'"';
50
+			$html .= ' class="'.$input->html_class().'"';
51
+			$html .= ' style="'.$input->html_style().'"';
52
+			$html .= ' value="'.esc_attr($value).'"';
53
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : '';
54
+			$html .= ' '.$this->_input->other_html_attributes();
55 55
 			$html .= '>&nbsp;';
56 56
 			$html .= $display_text;
57
-			$html .= EEH_HTML::nl( -1, 'checkbox' ) . '</label>';
57
+			$html .= EEH_HTML::nl( -1, 'checkbox' ).'</label>';
58 58
 		}
59 59
 		return $html;
60 60
 	}
Please login to merge, or discard this patch.
libraries/form_sections/payment_methods/EE_Payment_Method_Form.form.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * Specialized form for payment methods, allowing for easy setting and retrieving of meta fields.
5 5
  * Uses EEM_Payment_Method as the model
6 6
  */
7
-class EE_Payment_Method_Form extends EE_Model_Form_Section{
7
+class EE_Payment_Method_Form extends EE_Model_Form_Section {
8 8
 
9 9
 	/**
10 10
 	 * All the subsection inputs that correspond ot extra meta rows
@@ -39,37 +39,37 @@  discard block
 block discarded – undo
39 39
 	 *	@see EE_Model_Form_Section::__construct() for more
40 40
 	 * }
41 41
 	 */
42
-	public function __construct($options_array = array()){
42
+	public function __construct($options_array = array()) {
43 43
 		$this->_model = EEM_Payment_Method::instance();
44 44
 		$this->_options_array = $options_array;
45
-		if(isset($options_array['payment_method_type'])){
45
+		if (isset($options_array['payment_method_type'])) {
46 46
 			$this->_payment_method_type = $options_array['payment_method_type'];
47 47
 		}
48 48
 		$options_array = $this->_options_array;
49
-		if(isset($options_array['extra_meta_inputs'])){
50
-			$this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs,$options_array['extra_meta_inputs']);
49
+		if (isset($options_array['extra_meta_inputs'])) {
50
+			$this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']);
51 51
 		}
52
-		if($this->_extra_meta_inputs){
53
-			$this->_subsections = array_merge($this->_subsections,$this->_extra_meta_inputs);
52
+		if ($this->_extra_meta_inputs) {
53
+			$this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs);
54 54
 		}
55 55
 		$this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input(
56
-			array( 'html_label_text'=>  __( 'Button URL', 'event_espresso' ))
56
+			array('html_label_text'=>  __('Button URL', 'event_espresso'))
57 57
 		);
58 58
 		$this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input(
59 59
 			EEM_Payment_Method::instance()->scopes(),
60
-			array( 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link( 'payment_methods_overview' ))
60
+			array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename().EEH_Template::get_help_tab_link('payment_methods_overview'))
61 61
 		);
62 62
 		//setup the currency options
63 63
 		$this->_subsections['Currency'] = new EE_Select_Multi_Model_Input(
64
-			EEM_Currency::instance()->get_all_currencies_usable_by( $this->_payment_method_type ),
64
+			EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type),
65 65
 			array(
66
-				'html_label_text'=>  __( 'Currencies Supported', 'event_espresso' ),
66
+				'html_label_text'=>  __('Currencies Supported', 'event_espresso'),
67 67
 				'required'=>TRUE
68 68
 			)
69 69
 		);
70
-		$this->_subsections['PMD_order'] = new EE_Text_Input( array(
71
-			'html_label_text' => __( 'Order', 'event_espresso' ),
72
-			'html_help_text' => __( 'Lowest numbers will be shown first', 'event_espresso' ),
70
+		$this->_subsections['PMD_order'] = new EE_Text_Input(array(
71
+			'html_label_text' => __('Order', 'event_espresso'),
72
+			'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'),
73 73
 			'normalization_strategy' => new EE_Int_Normalization(),
74 74
 			'validation_strategies' => array(
75 75
 				new EE_Int_Validation_Strategy()
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 		));
79 79
 		$this->_layout_strategy = new EE_Admin_Two_Column_Layout();
80 80
 		parent::__construct($options_array);
81
-		$debug_mode = isset( $this->_subsections[ 'PMD_debug_mode' ] ) ? $this->_subsections[ 'PMD_debug_mode' ] : null;
82
-		if( $debug_mode instanceof EE_Form_Input_Base ) {
83
-			$debug_mode->set_html_help_text( __( 'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso' ) );
81
+		$debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null;
82
+		if ($debug_mode instanceof EE_Form_Input_Base) {
83
+			$debug_mode->set_html_help_text(__('This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso'));
84 84
 		}
85 85
 	}
86 86
 
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 	 * @param string 	$name
93 93
 	 * @throws EE_Error
94 94
 	 */
95
-	public function _construct_finalize( $parent_form_section, $name ) {
96
-		if( ! $this->_payment_method_type instanceof EE_PMT_Base ){
97
-			throw new EE_Error( sprintf( __( 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso' )));
95
+	public function _construct_finalize($parent_form_section, $name) {
96
+		if ( ! $this->_payment_method_type instanceof EE_PMT_Base) {
97
+			throw new EE_Error(sprintf(__('Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso')));
98 98
 		}
99 99
 		//set the name of this form based on the payment method type
100
-		if( ! $this->_name && ! $name ){
101
-			$name = str_replace(" ","_",ucwords(str_replace("_"," ",($this->_payment_method_type->system_name()))))."_Settings_Form";
100
+		if ( ! $this->_name && ! $name) {
101
+			$name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))."_Settings_Form";
102 102
 		}
103
-		parent::_construct_finalize( $parent_form_section, $name );
103
+		parent::_construct_finalize($parent_form_section, $name);
104 104
 	}
105 105
 
106 106
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param $payment_method_type
110 110
 	 * @throws EE_Error
111 111
 	 */
112
-	public function set_payment_method_type( $payment_method_type ){
113
-		if( ! $payment_method_type instanceof EE_PMT_Base){
112
+	public function set_payment_method_type($payment_method_type) {
113
+		if ( ! $payment_method_type instanceof EE_PMT_Base) {
114 114
 			throw new EE_Error(sprintf(__("Payment Method forms MUST set a payment method type by using _set_payment_method_type", "event_espresso")));
115 115
 		}
116 116
 		$this->_payment_method_type = $payment_method_type;
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 	 * extends the model form section's save method to also save the extra meta field values
123 123
 	 * @return int ID of the payment method inserted, or true on update
124 124
 	 */
125
-	public function save(){
125
+	public function save() {
126 126
 		$parent_save_val = parent::save();
127
-		if( $this->_model_object && $this->_model_object->ID()){
128
-			foreach($this->_extra_meta_inputs as $input_name => $input){
127
+		if ($this->_model_object && $this->_model_object->ID()) {
128
+			foreach ($this->_extra_meta_inputs as $input_name => $input) {
129 129
 				$this->_model_object->update_extra_meta($input_name, $input->normalized_value());
130 130
 			}
131 131
 		}
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 		$model_obj = $this->_model->ensure_is_obj($model_obj);
143 143
 		parent::populate_model_obj($model_obj);
144 144
 		$extra_meta = $model_obj->all_extra_meta_array();
145
-		foreach($this->_extra_meta_inputs as $input_name => $extra_meta_input){
146
-			if(isset($extra_meta[$input_name])){
145
+		foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) {
146
+			if (isset($extra_meta[$input_name])) {
147 147
 				$extra_meta_input->set_default($extra_meta[$input_name]);
148 148
 			}
149 149
 		}
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	 * gets the default name of this form section if none is specified
156 156
 	 * @return string
157 157
 	 */
158
-	protected function _set_default_name_if_empty(){
159
-		if( ! $this->_name ){
160
-			$default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form";
161
-			$this->_name =  $default_name;
158
+	protected function _set_default_name_if_empty() {
159
+		if ( ! $this->_name) {
160
+			$default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form";
161
+			$this->_name = $default_name;
162 162
 		}
163 163
 	}
164 164
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * Gets all the extra meta inputs in this form
169 169
 	 * @return EE_Form_Input_Base[]
170 170
 	 */
171
-	public function extra_meta_inputs(){
171
+	public function extra_meta_inputs() {
172 172
 		return $this->_extra_meta_inputs;
173 173
 	}
174 174
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_events.dmsstage.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ),
159 159
 			));
160 160
  */
161
-class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage{
161
+class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage {
162 162
 	private $_old_table;
163 163
 	private $_old_start_end_table;
164 164
 	private $_new_table;
@@ -184,41 +184,41 @@  discard block
 block discarded – undo
184 184
 	protected function _migration_step($num_items_to_migrate = 50) {
185 185
 		global $wpdb;
186 186
 		//because the migration of each event can be a LOT more work, make each step smaller
187
-		$num_items_to_migrate = max(1,$num_items_to_migrate/5);
188
-		$events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$this->count_records_migrated(),$num_items_to_migrate),ARRAY_A);
187
+		$num_items_to_migrate = max(1, $num_items_to_migrate / 5);
188
+		$events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $this->count_records_migrated(), $num_items_to_migrate), ARRAY_A);
189 189
 		$items_migrated_this_step = 0;
190 190
 
191
-		foreach($events as $event_row){
191
+		foreach ($events as $event_row) {
192 192
 			$created_attachment_post = false;
193 193
 			//insert new 4.1 Attendee object using $wpdb
194 194
 			$post_id = $this->_insert_cpt($event_row);
195
-			if($post_id){
195
+			if ($post_id) {
196 196
 				$this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_table, $post_id);
197 197
 				$meta_id = $this->_insert_event_meta($event_row, $post_id);
198
-				if($meta_id){
198
+				if ($meta_id) {
199 199
 					$this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_meta_table, $meta_id);
200 200
 				}
201
-				$this->_convert_start_end_times($event_row,$post_id);
201
+				$this->_convert_start_end_times($event_row, $post_id);
202 202
 				$event_meta = maybe_unserialize($event_row['event_meta']);
203 203
 				$guid = isset($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : null;
204
-				$created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid,$post_id,$this);
204
+				$created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $post_id, $this);
205 205
 
206 206
 				//maybe create a venue from info on the event?
207 207
 				$new_venue_id = $this->_maybe_create_venue($event_row);
208
-				if($new_venue_id){
209
-					$this->_insert_new_venue_to_event($post_id,$new_venue_id);
208
+				if ($new_venue_id) {
209
+					$this->_insert_new_venue_to_event($post_id, $new_venue_id);
210 210
 				}
211 211
 				$this->_add_post_metas($event_row, $post_id);
212 212
 
213 213
 			}
214 214
 			$items_migrated_this_step++;
215
-			if($guid){
215
+			if ($guid) {
216 216
 				//if we had to check for an image attachment
217 217
 				//then let's call it a day (avoid timing out, because this took a long time)
218 218
 				break;
219 219
 			}
220 220
 		}
221
-		if($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()){
221
+		if ($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()) {
222 222
 			$this->set_status(EE_Data_Migration_Manager::status_completed);
223 223
 		}
224 224
 		return $items_migrated_this_step;
@@ -230,28 +230,28 @@  discard block
 block discarded – undo
230 230
 	 * @param type $post_id
231 231
 	 * @return void
232 232
 	 */
233
-	private function _add_post_metas($old_event,$post_id){
233
+	private function _add_post_metas($old_event, $post_id) {
234 234
 		$event_meta = maybe_unserialize($old_event['event_meta']);
235
-		if( ! $event_meta || ! is_array( $event_meta ) ){
235
+		if ( ! $event_meta || ! is_array($event_meta)) {
236 236
 			return;
237 237
 		}
238
-		unset($event_meta['date_submitted']);//factored into CPT
239
-		unset($event_meta['additional_attendee_reg_info']);//facotred into event meta table
240
-		unset($event_meta['default_payment_status']);//dido
241
-		unset($event_meta['event_thumbnail_url']);//used to find post featured image
242
-		foreach($event_meta as $meta_key => $meta_value){
243
-			if ($meta_key){//if th emeta key is just an empty string, ignore it
244
-				$success = add_post_meta($post_id,$meta_key,$meta_value,true);
245
-				if( ! $success ){
246
-					$this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"),$post_id,$meta_key,$meta_value,implode(",",$old_event)));
238
+		unset($event_meta['date_submitted']); //factored into CPT
239
+		unset($event_meta['additional_attendee_reg_info']); //facotred into event meta table
240
+		unset($event_meta['default_payment_status']); //dido
241
+		unset($event_meta['event_thumbnail_url']); //used to find post featured image
242
+		foreach ($event_meta as $meta_key => $meta_value) {
243
+			if ($meta_key) {//if th emeta key is just an empty string, ignore it
244
+				$success = add_post_meta($post_id, $meta_key, $meta_value, true);
245
+				if ( ! $success) {
246
+					$this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"), $post_id, $meta_key, $meta_value, implode(",", $old_event)));
247 247
 				}
248 248
 			}
249 249
 		}
250
-		if($old_event['alt_email']){
251
-			add_post_meta($post_id,'alt_email',$old_event['alt_email']);
250
+		if ($old_event['alt_email']) {
251
+			add_post_meta($post_id, 'alt_email', $old_event['alt_email']);
252 252
 		}
253
-		if($old_event['recurrence_id']){
254
-			add_post_meta($post_id,'recurrence_id',$old_event['recurrence_id']);
253
+		if ($old_event['recurrence_id']) {
254
+			add_post_meta($post_id, 'recurrence_id', $old_event['recurrence_id']);
255 255
 		}
256 256
 	}
257 257
 	/**
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
 	 * @param string $new_post_status a post status
264 264
 	 * @return string
265 265
 	 */
266
-	private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish'){
266
+	private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish') {
267 267
 		$count = 0;
268 268
 		$original_name = $event_name ? sanitize_title($event_name) : $old_identifier;
269
-		return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0 );
269
+		return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0);
270 270
 	}
271 271
 
272
-	private function _insert_cpt($old_event){
272
+	private function _insert_cpt($old_event) {
273 273
 		global $wpdb;
274 274
 		//convert 3.1 event status to 4.1 CPT status
275 275
 		//for refrence, 3.1 event stati available for setting are:
@@ -288,55 +288,55 @@  discard block
 block discarded – undo
288 288
 //		and 3 custom ones: cancelled,postponed,sold_out
289 289
 		$status_conversions = array(
290 290
 			'R'=>'draft',
291
-			'X'=>'draft',//4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved
291
+			'X'=>'draft', //4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved
292 292
 			'P'=>'pending',
293
-			'IA'=>'draft',//draft and in the past
293
+			'IA'=>'draft', //draft and in the past
294 294
 //IA=inactive in 3.1: events were switched to this when they expired. in 4.1 that's just calculated
295
-			'O'=>'publish',//@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing'
295
+			'O'=>'publish', //@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing'
296 296
 			'A'=>'publish',
297
-			'S'=>'draft',//@todo: is it ok to just mark secondary/waitlist events as DRAFTS?
297
+			'S'=>'draft', //@todo: is it ok to just mark secondary/waitlist events as DRAFTS?
298 298
 			'D'=>'trash',
299 299
 		);
300 300
 		$post_status = $status_conversions[$old_event['event_status']];
301 301
 		//check if we've sold out
302
-		if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])){
302
+		if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])) {
303 303
 			$post_status = 'sold_out';
304 304
 		}
305 305
 //		FYI postponed and cancelled don't exist in 3.1
306 306
 		$cols_n_values = array(
307
-			'post_title'=>stripslashes($old_event['event_name']),//EVT_name
308
-			'post_content'=>stripslashes($old_event['event_desc']),//EVT_desc
309
-			'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status ),//EVT_slug
310
-			'post_date'=>$old_event['submitted'],//EVT_created NOT
307
+			'post_title'=>stripslashes($old_event['event_name']), //EVT_name
308
+			'post_content'=>stripslashes($old_event['event_desc']), //EVT_desc
309
+			'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status), //EVT_slug
310
+			'post_date'=>$old_event['submitted'], //EVT_created NOT
311 311
 			'post_date_gmt'=>get_gmt_from_date($old_event['submitted']),
312
-			'post_excerpt'=>'',//EVT_short_desc
313
-			'post_modified'=>$old_event['submitted'],//EVT_modified
312
+			'post_excerpt'=>'', //EVT_short_desc
313
+			'post_modified'=>$old_event['submitted'], //EVT_modified
314 314
 			'post_modified_gmt'=>get_gmt_from_date($old_event['submitted']),
315
-			'post_author'=>$old_event['wp_user'],//EVT_wp_user
316
-			'post_parent'=>0,//parent maybe get this from some REM field?
317
-			'menu_order'=>0,//EVT_order
318
-			'post_type'=>'espresso_events',//post_type
319
-			'post_status'=>$post_status,//status
315
+			'post_author'=>$old_event['wp_user'], //EVT_wp_user
316
+			'post_parent'=>0, //parent maybe get this from some REM field?
317
+			'menu_order'=>0, //EVT_order
318
+			'post_type'=>'espresso_events', //post_type
319
+			'post_status'=>$post_status, //status
320 320
 		);
321 321
 		$datatypes = array(
322
-			'%s',//EVT_name
323
-			'%s',//EVT_desc
324
-			'%s',//EVT_slug
325
-			'%s',//EVT_created
322
+			'%s', //EVT_name
323
+			'%s', //EVT_desc
324
+			'%s', //EVT_slug
325
+			'%s', //EVT_created
326 326
 			'%s',
327
-			'%s',//EVT_short_desc
328
-			'%s',//EVT_modified
327
+			'%s', //EVT_short_desc
328
+			'%s', //EVT_modified
329 329
 			'%s',
330
-			'%s',//EVT_wp_user
331
-			'%d',//post_parent
332
-			'%d',//EVT_order
333
-			'%s',//post_type
334
-			'%s',//status
330
+			'%s', //EVT_wp_user
331
+			'%d', //post_parent
332
+			'%d', //EVT_order
333
+			'%s', //post_type
334
+			'%s', //status
335 335
 		);
336 336
 		$success = $wpdb->insert($this->_new_table,
337 337
 				$cols_n_values,
338 338
 				$datatypes);
339
-		if( ! $success ){
339
+		if ( ! $success) {
340 340
 			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes));
341 341
 			return 0;
342 342
 		}
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
 	 * @param type $event_id
350 350
 	 * @return int
351 351
 	 */
352
-	public static function count_registrations($event_id){
352
+	public static function count_registrations($event_id) {
353 353
 		global $wpdb;
354
-		$count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d",$event_id));
354
+		$count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d", $event_id));
355 355
 		return intval($count);
356 356
 	}
357 357
 
358
-	private function _insert_event_meta($old_event,$new_cpt_id){
358
+	private function _insert_event_meta($old_event, $new_cpt_id) {
359 359
 		global $wpdb;
360 360
 		$event_meta = maybe_unserialize($old_event['event_meta']);
361 361
 //		for reference, 3.1 'default_payment_status' are: $default_payment_status = array(
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 //);
367 367
 		$default_reg_status = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(isset($event_meta['default_payment_status']) ? $event_meta['default_payment_status'] : '', intval($old_event['require_pre_approval']));
368 368
 		$cols_n_values = array(
369
-			'EVT_ID'=>$new_cpt_id,//EVT_ID_fk
369
+			'EVT_ID'=>$new_cpt_id, //EVT_ID_fk
370 370
 			'EVT_display_desc'=> 'Y' == $old_event['display_desc'],
371
-			'EVT_display_ticket_selector'=> 'Y'== $old_event['display_reg_form'],
372
-			'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this,$old_event,current_time('mysql'),$old_event['timezone_string']),//don't use the old 'visible_on', as it wasnt ever used
371
+			'EVT_display_ticket_selector'=> 'Y' == $old_event['display_reg_form'],
372
+			'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this, $old_event, current_time('mysql'), $old_event['timezone_string']), //don't use the old 'visible_on', as it wasnt ever used
373 373
 			'EVT_additional_limit'=> $old_event['allow_multiple'] == 'N' ? 1 : $old_event['additional_limit'],
374 374
 			'EVT_default_registration_status' => $default_reg_status,
375 375
 			'EVT_member_only'=>$old_event['member_only'],
@@ -381,31 +381,31 @@  discard block
 block discarded – undo
381 381
 
382 382
 		);
383 383
 		$datatypes = array(
384
-			'%s',//EVT_ID
385
-			'%d',//EVT_display_desc
386
-			'%d',//EVT_display_ticket_selector
387
-			'%s',//EVT_visible_on
388
-			'%d',//EVT_additional_limit
389
-			'%s',//EVT_default_registration_status
390
-			'%d',//EVT_member_only
391
-			'%s',//EVT_phone
392
-			'%d',//EVT_allow_overflow
393
-			'%s',//EVT_timezone_string
394
-			'%s',//EVT_external_URL
395
-			'%d',//EVT_donations
384
+			'%s', //EVT_ID
385
+			'%d', //EVT_display_desc
386
+			'%d', //EVT_display_ticket_selector
387
+			'%s', //EVT_visible_on
388
+			'%d', //EVT_additional_limit
389
+			'%s', //EVT_default_registration_status
390
+			'%d', //EVT_member_only
391
+			'%s', //EVT_phone
392
+			'%d', //EVT_allow_overflow
393
+			'%s', //EVT_timezone_string
394
+			'%s', //EVT_external_URL
395
+			'%d', //EVT_donations
396 396
 		);
397 397
 		$success = $wpdb->insert($this->_new_meta_table,
398 398
 				$cols_n_values,
399 399
 				$datatypes);
400
-		if( ! $success ){
400
+		if ( ! $success) {
401 401
 			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $cols_n_values, $datatypes));
402 402
 			return 0;
403 403
 		}
404 404
 		return $wpdb->insert_id;
405 405
 	}
406 406
 
407
-	private function _maybe_create_venue($old_event){
408
-		if(		$old_event['address'] ||
407
+	private function _maybe_create_venue($old_event) {
408
+		if ($old_event['address'] ||
409 409
 				$old_event['address2'] ||
410 410
 				$old_event['city'] ||
411 411
 				$old_event['state'] ||
@@ -416,21 +416,21 @@  discard block
 block discarded – undo
416 416
 				$old_event['venue_phone'] ||
417 417
 				$old_event['virtual_url'] ||
418 418
 				$old_event['virtual_phone']
419
-				){
420
-			$old_id = $this->_duplicate_venue_exists( $old_event );
421
-			if( $old_id ){
419
+				) {
420
+			$old_id = $this->_duplicate_venue_exists($old_event);
421
+			if ($old_id) {
422 422
 				return $old_id;
423 423
 			}
424 424
 			$new_id = $this->_insert_venue_into_posts($old_event);
425
-			if( $new_id ){
425
+			if ($new_id) {
426 426
 				$this->_insert_venue_into_meta_table($new_id, $old_event);
427
-				$guid = isset($old_event['venue_image']) ? $old_event['venue_image']  : null;
428
-				$this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id,$this);
427
+				$guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null;
428
+				$this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this);
429 429
 			}
430 430
 			//we don't bother recording the conversion from old events to venues as that
431 431
 			//will complicate finding the conversion from old venues to new events
432 432
 			return $new_id;
433
-		}else{
433
+		} else {
434 434
 			return 0;
435 435
 		}
436 436
 	}
@@ -441,29 +441,29 @@  discard block
 block discarded – undo
441 441
 	 * @param array $old_event
442 442
 	 * @return int duplicate venue id
443 443
 	 */
444
-	private function _duplicate_venue_exists($old_event){
444
+	private function _duplicate_venue_exists($old_event) {
445 445
 		global $wpdb;
446 446
 		$conditions = array(
447
-			'VNU_address' => $old_event [ 'address' ],
448
-			'VNU_address2' => $old_event[ 'address2' ],
449
-			'VNU_city' => $old_event[ 'city' ],
450
-			'VNU_zip' => $old_event[ 'zip' ],
451
-			'post_title'=> $this->_get_venue_title_for_event( $old_event ),
452
-			'VNU_phone'=>$old_event['venue_phone'],//VNU_phone
453
-			'VNU_url'=>$old_event['venue_url'],//VNU_url
454
-			'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone
455
-			'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url
447
+			'VNU_address' => $old_event ['address'],
448
+			'VNU_address2' => $old_event['address2'],
449
+			'VNU_city' => $old_event['city'],
450
+			'VNU_zip' => $old_event['zip'],
451
+			'post_title'=> $this->_get_venue_title_for_event($old_event),
452
+			'VNU_phone'=>$old_event['venue_phone'], //VNU_phone
453
+			'VNU_url'=>$old_event['venue_url'], //VNU_url
454
+			'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone
455
+			'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url
456 456
 		);
457 457
 		$sql_conditions = array();
458
-		foreach($conditions as $column => $value){
458
+		foreach ($conditions as $column => $value) {
459 459
 			$sql_conditions [] = "$column = '$value'";
460 460
 		}
461 461
 		$query = "SELECT VNU_ID
462 462
 					FROM
463 463
 		{$wpdb->posts} as p INNER JOIN
464 464
 		{$wpdb->prefix}esp_venue_meta as v ON p.ID = v.VNU_ID
465
-			WHERE " . implode( " AND ",$sql_conditions ) . " LIMIT 1";
466
-		$id = $wpdb->get_var( $query );
465
+			WHERE ".implode(" AND ", $sql_conditions)." LIMIT 1";
466
+		$id = $wpdb->get_var($query);
467 467
 		return $id;
468 468
 	}
469 469
 	
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param array $event_data_array keys are events_details columns and valuesa re their values
473 473
 	 * @return string
474 474
 	 */
475
-	protected function _get_venue_title_for_event( $event_data_array ) {
476
-		return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes( sprintf( __( 'Venue of %s', 'event_espresso' ), $event_data_array['event_name']));
475
+	protected function _get_venue_title_for_event($event_data_array) {
476
+		return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes(sprintf(__('Venue of %s', 'event_espresso'), $event_data_array['event_name']));
477 477
 	}
478 478
 
479 479
 	/**
@@ -481,40 +481,40 @@  discard block
 block discarded – undo
481 481
 	 * @param array $old_venue keys are cols, values are col values
482 482
 	 * @return int
483 483
 	 */
484
-	private function _insert_venue_into_posts($old_event){
484
+	private function _insert_venue_into_posts($old_event) {
485 485
 		global $wpdb;
486 486
 		$insertion_array = array(
487
-					'post_title'=> $this->_get_venue_title_for_event( $old_event ),//VNU_name
488
-					'post_content'=>'',//VNU_desc
489
-					'post_name'=> $this->_find_unique_slug( $old_event['venue_title'], sanitize_title( 'venue-of-' . $old_event['event_name'] ) ),//VNU_identifier
490
-					'post_date'=>current_time('mysql'),//VNU_created
487
+					'post_title'=> $this->_get_venue_title_for_event($old_event), //VNU_name
488
+					'post_content'=>'', //VNU_desc
489
+					'post_name'=> $this->_find_unique_slug($old_event['venue_title'], sanitize_title('venue-of-'.$old_event['event_name'])), //VNU_identifier
490
+					'post_date'=>current_time('mysql'), //VNU_created
491 491
 					'post_date_gmt'=>get_gmt_from_date(current_time('mysql')),
492
-					'post_excerpt'=>'',//VNU_short_desc arbitraty only 50 characters
493
-					'post_modified'=>current_time('mysql'),//VNU_modified
492
+					'post_excerpt'=>'', //VNU_short_desc arbitraty only 50 characters
493
+					'post_modified'=>current_time('mysql'), //VNU_modified
494 494
 					'post_modified_gmt'=>get_gmt_from_date(current_time('mysql')),
495
-					'post_author'=>$old_event['wp_user'],//VNU_wp_user
496
-					'post_parent'=>0,//parent
497
-					'menu_order'=>0,//VNU_order
495
+					'post_author'=>$old_event['wp_user'], //VNU_wp_user
496
+					'post_parent'=>0, //parent
497
+					'menu_order'=>0, //VNU_order
498 498
 					'post_type'=>'espresso_venues'//post_type
499 499
 				);
500 500
 		$datatypes_array = array(
501
-					'%s',//VNU_name
502
-					'%s',//VNU_desc
503
-					'%s',//VNU_identifier
504
-					'%s',//VNU_created
501
+					'%s', //VNU_name
502
+					'%s', //VNU_desc
503
+					'%s', //VNU_identifier
504
+					'%s', //VNU_created
505 505
 					'%s',
506
-					'%s',//VNU_short_desc
507
-					'%s',//VNU_modified
506
+					'%s', //VNU_short_desc
507
+					'%s', //VNU_modified
508 508
 					'%s',
509
-					'%d',//VNU_wp_user
510
-					'%d',//parent
511
-					'%d',//VNU_order
512
-					'%s',//post_type
509
+					'%d', //VNU_wp_user
510
+					'%d', //parent
511
+					'%d', //VNU_order
512
+					'%s', //post_type
513 513
 				);
514 514
 		$success = $wpdb->insert($wpdb->posts,
515 515
 				$insertion_array,
516 516
 				$datatypes_array);
517
-		if( ! $success ){
517
+		if ( ! $success) {
518 518
 			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array));
519 519
 			return 0;
520 520
 		}
@@ -527,78 +527,78 @@  discard block
 block discarded – undo
527 527
 	 * @param type $old_event
528 528
 	 * @return int
529 529
 	 */
530
-	private function _insert_venue_into_meta_table($cpt_id,$old_event){
530
+	private function _insert_venue_into_meta_table($cpt_id, $old_event) {
531 531
 		global $wpdb;
532 532
 
533 533
 		//assume the country is the same as the organization's old settings
534 534
 		$country_iso = $this->get_migration_script()->get_default_country_iso();
535 535
 		//find the state from the venue, or the organization, or just guess california
536
-		if( ! $old_event['state']){
536
+		if ( ! $old_event['state']) {
537 537
 			$old_org_options = get_option('events_organization_settings');
538 538
 			$state_name = stripslashes($old_org_options['organization_state']);
539
-		}else{
539
+		} else {
540 540
 			$state_name = $old_event['state'];
541 541
 		}
542
-		if ( ! $state_name ){
542
+		if ( ! $state_name) {
543 543
 			$state_name = 'CA';
544 544
 		}
545 545
 		//get a state ID with the same name, if possible
546
-		try{
547
-			$state = $this->get_migration_script()->get_or_create_state($state_name,$country_iso);
546
+		try {
547
+			$state = $this->get_migration_script()->get_or_create_state($state_name, $country_iso);
548 548
 			$state_id = $state['STA_ID'];
549
-		}catch(EE_Error $e){
549
+		} catch (EE_Error $e) {
550 550
 			$this->add_error($e->getMessage());
551 551
 			$state_id = 0;
552 552
 		}
553 553
 		//now insert into meta table
554 554
 		$insertion_array = array(
555
-			'VNU_ID'=>$cpt_id,//VNU_ID_fk
556
-			'VNU_address'=>stripslashes($old_event['address']),//VNU_address
557
-			'VNU_address2'=>stripslashes($old_event['address2']),//VNU_address2
558
-			'VNU_city'=>stripslashes($old_event['city']),//VNU_city
559
-			'STA_ID'=>$state_id,//STA_ID
560
-			'CNT_ISO'=>$country_iso,//CNT_ISO
561
-			'VNU_zip'=>$old_event['zip'],//VNU_zip
562
-			'VNU_phone'=>$old_event['venue_phone'],//VNU_phone
563
-			'VNU_capacity'=>-1,//VNU_capacity
564
-			'VNU_url'=>$old_event['venue_url'],//VNU_url
565
-			'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone
566
-			'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url
567
-			'VNU_google_map_link'=>'',//VNU_google_map_link
555
+			'VNU_ID'=>$cpt_id, //VNU_ID_fk
556
+			'VNU_address'=>stripslashes($old_event['address']), //VNU_address
557
+			'VNU_address2'=>stripslashes($old_event['address2']), //VNU_address2
558
+			'VNU_city'=>stripslashes($old_event['city']), //VNU_city
559
+			'STA_ID'=>$state_id, //STA_ID
560
+			'CNT_ISO'=>$country_iso, //CNT_ISO
561
+			'VNU_zip'=>$old_event['zip'], //VNU_zip
562
+			'VNU_phone'=>$old_event['venue_phone'], //VNU_phone
563
+			'VNU_capacity'=>-1, //VNU_capacity
564
+			'VNU_url'=>$old_event['venue_url'], //VNU_url
565
+			'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone
566
+			'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url
567
+			'VNU_google_map_link'=>'', //VNU_google_map_link
568 568
 			'VNU_enable_for_gmap'=>true	//VNU_enable_for_gmap
569 569
 		);
570 570
 		$datatypes = array(
571
-			'%d',//VNU_ID_fk
572
-			'%s',//VNU_address
573
-			'%s',//VNU_address2
574
-			'%s',//VNU_city
575
-			'%d',//STA_ID
576
-			'%s',//CNT_ISO
577
-			'%s',//VNU_zip
578
-			'%s',//VNU_phone
579
-			'%d',//VNU_capacity
580
-			'%s',//VNU_url
581
-			'%s',//VNU_virtual_phone
582
-			'%s',//VNU_virtual_url
583
-			'%s',//VNU_google_map_link
584
-			'%d',//VNU_enable_for_gmap
571
+			'%d', //VNU_ID_fk
572
+			'%s', //VNU_address
573
+			'%s', //VNU_address2
574
+			'%s', //VNU_city
575
+			'%d', //STA_ID
576
+			'%s', //CNT_ISO
577
+			'%s', //VNU_zip
578
+			'%s', //VNU_phone
579
+			'%d', //VNU_capacity
580
+			'%s', //VNU_url
581
+			'%s', //VNU_virtual_phone
582
+			'%s', //VNU_virtual_url
583
+			'%s', //VNU_google_map_link
584
+			'%d', //VNU_enable_for_gmap
585 585
 		);
586
-		$success = $wpdb->insert($wpdb->prefix."esp_venue_meta",$insertion_array,$datatypes);
587
-		if( ! $success ){
586
+		$success = $wpdb->insert($wpdb->prefix."esp_venue_meta", $insertion_array, $datatypes);
587
+		if ( ! $success) {
588 588
 			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $insertion_array, $datatypes));
589 589
 			return 0;
590 590
 		}
591 591
 		return $wpdb->insert_id;
592 592
 	}
593 593
 
594
-	private function _insert_new_venue_to_event($new_event_id,$new_venue_id){
594
+	private function _insert_new_venue_to_event($new_event_id, $new_venue_id) {
595 595
 		global $wpdb;
596
-		if( ! $new_event_id){
597
-			$this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"),$new_event_id));
596
+		if ( ! $new_event_id) {
597
+			$this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $new_event_id));
598 598
 			return 0;
599 599
 		}
600
-		if( ! $new_venue_id){
601
-			$this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"),$new_venue_id));
600
+		if ( ! $new_venue_id) {
601
+			$this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $new_venue_id));
602 602
 			return 0;
603 603
 		}
604 604
 		$cols_n_values = array(
@@ -607,12 +607,12 @@  discard block
 block discarded – undo
607 607
 			'EVV_primary'=>true
608 608
 		);
609 609
 		$datatypes = array(
610
-			'%d',//EVT_ID
611
-			'%d',//VNU_ID
612
-			'%d',//EVT_primary
610
+			'%d', //EVT_ID
611
+			'%d', //VNU_ID
612
+			'%d', //EVT_primary
613 613
 		);
614
-		$success = $wpdb->insert($wpdb->prefix."esp_event_venue",$cols_n_values,$datatypes);
615
-		if ( ! $success){
614
+		$success = $wpdb->insert($wpdb->prefix."esp_event_venue", $cols_n_values, $datatypes);
615
+		if ( ! $success) {
616 616
 			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_venue_rel, $this->_new_table, $cols_n_values, $datatypes));
617 617
 			return 0;
618 618
 		}
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
 	 * @param int $new_cpt_id new post ID
627 627
 	 * @return void (if there are errors though, adds them to the stage's error list
628 628
 	 */
629
-	private function _convert_start_end_times($old_event,$new_cpt_id){
629
+	private function _convert_start_end_times($old_event, $new_cpt_id) {
630 630
 		$start_end_times = $this->_get_old_start_end_times($old_event['id']);
631
-		foreach($start_end_times as $start_end_time){
632
-			$datetime_id = $this->_insert_new_datetime($start_end_time,$old_event,$new_cpt_id);
633
-			if($datetime_id){
631
+		foreach ($start_end_times as $start_end_time) {
632
+			$datetime_id = $this->_insert_new_datetime($start_end_time, $old_event, $new_cpt_id);
633
+			if ($datetime_id) {
634 634
 				$this->get_migration_script()->set_mapping($this->_old_start_end_table, $start_end_time['id'], $this->_new_datetime_table, $datetime_id);
635 635
 			}
636 636
 		}
@@ -641,9 +641,9 @@  discard block
 block discarded – undo
641 641
 	 * @param type $old_event_id
642 642
 	 * @return type
643 643
 	 */
644
-	private function _get_old_start_end_times($old_event_id){
644
+	private function _get_old_start_end_times($old_event_id) {
645 645
 		global $wpdb;
646
-		return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d",$old_event_id),ARRAY_A);
646
+		return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d", $old_event_id), ARRAY_A);
647 647
 	}
648 648
 	/**
649 649
 	 * Inserts a 4.1 datetime given the 3.1 start_end db row and event_details row
@@ -652,40 +652,40 @@  discard block
 block discarded – undo
652 652
 	 * @param type $new_cpt_id
653 653
 	 * @return int ID of new datetime
654 654
 	 */
655
-	private function _insert_new_datetime($start_end_time_row,$old_event_row,$new_cpt_id){
655
+	private function _insert_new_datetime($start_end_time_row, $old_event_row, $new_cpt_id) {
656 656
 		global $wpdb;
657 657
 		$start_date = $old_event_row['start_date'];
658 658
 		$start_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['start_time']);
659 659
 		$end_date = $old_event_row['end_date'];
660 660
 		$end_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['end_time']);
661 661
 		$existing_datetimes = $this->_count_other_datetimes_exist_for_new_event($new_cpt_id);
662
-		$start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$start_date $start_time:00",$old_event_row['timezone_string']);
663
-		$end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$end_date $end_time:00",$old_event_row['timezone_string']);
662
+		$start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$start_date $start_time:00", $old_event_row['timezone_string']);
663
+		$end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$end_date $end_time:00", $old_event_row['timezone_string']);
664 664
 		$cols_n_values = array(
665
-			'EVT_ID'=>$new_cpt_id,//EVT_ID
666
-			'DTT_EVT_start'=>$start_datetime_utc,//DTT_EVT_start
667
-			'DTT_EVT_end'=> $end_datetime_utc,//DTT_EVT_end
668
-			'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'],//DTT_reg_limit
669
-			'DTT_sold'=>0,//note: we will increment this as registrations are added during the migration
665
+			'EVT_ID'=>$new_cpt_id, //EVT_ID
666
+			'DTT_EVT_start'=>$start_datetime_utc, //DTT_EVT_start
667
+			'DTT_EVT_end'=> $end_datetime_utc, //DTT_EVT_end
668
+			'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'], //DTT_reg_limit
669
+			'DTT_sold'=>0, //note: we will increment this as registrations are added during the migration
670 670
 //			'DTT_is_primary'=> 0 == $existing_datetimes ,//DTT_is_primary... if count==0, then we'll call it the 'primary'
671
-			'DTT_order'=> $existing_datetimes,//DTT_order, just give it the same order as the count of how many datetimes already exist
671
+			'DTT_order'=> $existing_datetimes, //DTT_order, just give it the same order as the count of how many datetimes already exist
672 672
 			'DTT_parent'=>0,
673 673
 			'DTT_deleted'=>false
674 674
 		);
675 675
 		$datatypes = array(
676
-			'%d',//EVT_Id
677
-			'%s',//DTT_EVT_start
678
-			'%s',//DTT_EVT_end
679
-			'%d',//DTT_reg_limit
680
-			'%d',//DTT_sold
676
+			'%d', //EVT_Id
677
+			'%s', //DTT_EVT_start
678
+			'%s', //DTT_EVT_end
679
+			'%d', //DTT_reg_limit
680
+			'%d', //DTT_sold
681 681
 //			'%d',//DTT_is_primary
682
-			'%d',//DTT_order
683
-			'%d',//DTT_parent
684
-			'%d',//DTT_deleted
682
+			'%d', //DTT_order
683
+			'%d', //DTT_parent
684
+			'%d', //DTT_deleted
685 685
 		);
686
-		$success = $wpdb->insert($this->_new_datetime_table,$cols_n_values,$datatypes);
687
-		if ( ! $success){
688
-			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row,$start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes));
686
+		$success = $wpdb->insert($this->_new_datetime_table, $cols_n_values, $datatypes);
687
+		if ( ! $success) {
688
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row, $start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes));
689 689
 			return 0;
690 690
 		}
691 691
 		return $wpdb->insert_id;
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
 	 * @param type $cpt_event_id
699 699
 	 * @return int
700 700
 	 */
701
-	private function _count_other_datetimes_exist_for_new_event($cpt_event_id){
701
+	private function _count_other_datetimes_exist_for_new_event($cpt_event_id) {
702 702
 		global $wpdb;
703
-		$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d",$cpt_event_id));
703
+		$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d", $cpt_event_id));
704 704
 		return intval($count);
705 705
 	}
706 706
 
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,32 +25,32 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEM_Currency extends EEM_Base{
28
+class EEM_Currency extends EEM_Base {
29 29
 		// private instance of the Attendee object
30 30
 	protected static $_instance = NULL;
31 31
 
32
-	protected function __construct( $timezone = NULL ) {
33
-		$this->singular_item = __('Currency','event_espresso');
34
-		$this->plural_item = __('Currencies','event_espresso');
32
+	protected function __construct($timezone = NULL) {
33
+		$this->singular_item = __('Currency', 'event_espresso');
34
+		$this->plural_item = __('Currencies', 'event_espresso');
35 35
 		$this->_tables = array(
36 36
 			'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code')
37 37
 		);
38 38
 		$this->_fields = array(
39 39
 			'Currency'=>array(
40
-				'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code','event_espresso')),
41
-				'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular','event_espresso'), false),
42
-				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural','event_espresso'), false),
43
-				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign','event_espresso'), false),
44
-				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places','event_espresso'), false, 2),
45
-				'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false,true),
40
+				'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')),
41
+				'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
42
+				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
43
+				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
44
+				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
45
+				'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true),
46 46
 			));
47 47
 		$this->_model_relations = array(
48 48
 			'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
49 49
 		);
50 50
 		//this model is generally available for reading
51
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
51
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
52 52
 
53
-		parent::__construct( $timezone );
53
+		parent::__construct($timezone);
54 54
 	}
55 55
 
56 56
 	/**
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 * @param array $query_params see EEM_Base::get_all
60 60
 	 * @return EE_Currency[]
61 61
 	 */
62
-	public function get_all_active($query_params = array()){
62
+	public function get_all_active($query_params = array()) {
63 63
 		$query_params[0]['CUR_active'] = true;
64
-		if( ! isset($query_params['order_by'])){
65
-			$query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
64
+		if ( ! isset($query_params['order_by'])) {
65
+			$query_params['order_by'] = array('CUR_code'=>'ASC', 'CUR_single'=>'ASC');
66 66
 		}
67 67
 		return $this->get_all($query_params);
68 68
 	}
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
 	 * @param EE_PMT_Base $payment_method_type
72 72
 	 * @return EE_Currency[]
73 73
 	 */
74
-	public function get_all_currencies_usable_by($payment_method_type){
75
-		if($payment_method_type instanceof EE_PMT_Base &&
76
-				$payment_method_type->get_gateway()){
74
+	public function get_all_currencies_usable_by($payment_method_type) {
75
+		if ($payment_method_type instanceof EE_PMT_Base &&
76
+				$payment_method_type->get_gateway()) {
77 77
 			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
78
-		}else{
78
+		} else {
79 79
 			$currencies_supported = EE_Gateway::all_currencies_supported;
80 80
 		}
81
-		if($currencies_supported == EE_Gateway::all_currencies_supported || empty( $currencies_supported ) ) {
81
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
82 82
 			$currencies = $this->get_all_active();
83
-		}else{
84
-			$currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
83
+		} else {
84
+			$currencies = $this->get_all_active(array(array('CUR_code'=>array('IN', $currencies_supported))));
85 85
 		}
86 86
 		return $currencies;
87 87
 	}
Please login to merge, or discard this patch.