Completed
Branch BUG-8698-ticket-sellouts (4c4ee4)
by
unknown
113:37 queued 98:36
created
core/db_classes/EE_Question.class.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 	 *                             		    date_format and the second value is the time format
38 38
 	 * @return EE_Question
39 39
 	 */
40
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
41
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
42
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
40
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
41
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
42
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
43 43
 	}
44 44
 
45 45
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 *                          		the website will be used.
51 51
 	 * @return EE_Question
52 52
 	 */
53
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
54
-		return new self( $props_n_values, TRUE, $timezone );
53
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
54
+		return new self($props_n_values, TRUE, $timezone);
55 55
 	}
56 56
 
57 57
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 * @access        public
63 63
 	 * @param string $QST_display_text
64 64
 	 */
65
-	public function set_display_text( $QST_display_text = '' ) {
66
-		$this->set( 'QST_display_text', $QST_display_text );
65
+	public function set_display_text($QST_display_text = '') {
66
+		$this->set('QST_display_text', $QST_display_text);
67 67
 	}
68 68
 
69 69
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @access        public
75 75
 	 * @param        string $QST_admin_label
76 76
 	 */
77
-	public function set_admin_label( $QST_admin_label = '' ) {
78
-		$this->set( 'QST_admin_label', $QST_admin_label );
77
+	public function set_admin_label($QST_admin_label = '') {
78
+		$this->set('QST_admin_label', $QST_admin_label);
79 79
 	}
80 80
 
81 81
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @access        public
87 87
 	 * @param        mixed $QST_system
88 88
 	 */
89
-	public function set_system_ID( $QST_system = '' ) {
90
-		$this->set( 'QST_system', $QST_system );
89
+	public function set_system_ID($QST_system = '') {
90
+		$this->set('QST_system', $QST_system);
91 91
 	}
92 92
 
93 93
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @access        public
99 99
 	 * @param        string $QST_type
100 100
 	 */
101
-	public function set_question_type( $QST_type = '' ) {
102
-		$this->set( 'QST_type', $QST_type );
101
+	public function set_question_type($QST_type = '') {
102
+		$this->set('QST_type', $QST_type);
103 103
 	}
104 104
 
105 105
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @access        public
111 111
 	 * @param        bool $QST_required
112 112
 	 */
113
-	public function set_required( $QST_required = FALSE ) {
114
-		$this->set( 'QST_required', $QST_required );
113
+	public function set_required($QST_required = FALSE) {
114
+		$this->set('QST_required', $QST_required);
115 115
 	}
116 116
 
117 117
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @access        public
123 123
 	 * @param        string $QST_required_text
124 124
 	 */
125
-	public function set_required_text( $QST_required_text = '' ) {
126
-		$this->set( 'QST_required_text', $QST_required_text );
125
+	public function set_required_text($QST_required_text = '') {
126
+		$this->set('QST_required_text', $QST_required_text);
127 127
 	}
128 128
 
129 129
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @access        public
135 135
 	 * @param        int $QST_order
136 136
 	 */
137
-	public function set_order( $QST_order = 0 ) {
138
-		$this->set( 'QST_order', $QST_order );
137
+	public function set_order($QST_order = 0) {
138
+		$this->set('QST_order', $QST_order);
139 139
 	}
140 140
 
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @access        public
147 147
 	 * @param        bool $QST_admin_only
148 148
 	 */
149
-	public function set_admin_only( $QST_admin_only = FALSE ) {
150
-		$this->set( 'QST_admin_only', $QST_admin_only );
149
+	public function set_admin_only($QST_admin_only = FALSE) {
150
+		$this->set('QST_admin_only', $QST_admin_only);
151 151
 	}
152 152
 
153 153
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @access        public
159 159
 	 * @param        int $QST_wp_user
160 160
 	 */
161
-	public function set_wp_user( $QST_wp_user = 1 ) {
162
-		$this->set( 'QST_wp_user', $QST_wp_user );
161
+	public function set_wp_user($QST_wp_user = 1) {
162
+		$this->set('QST_wp_user', $QST_wp_user);
163 163
 	}
164 164
 
165 165
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @access        public
176 176
 	 * @param 	bool $QST_deleted
177 177
 	 */
178
-	public function set_deleted( $QST_deleted = FALSE ) {
179
-		$this->set( 'QST_deleted', $QST_deleted );
178
+	public function set_deleted($QST_deleted = FALSE) {
179
+		$this->set('QST_deleted', $QST_deleted);
180 180
 	}
181 181
 
182 182
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	public function display_text() {
190
-		return $this->get( 'QST_display_text' );
190
+		return $this->get('QST_display_text');
191 191
 	}
192 192
 
193 193
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return string
199 199
 	 */
200 200
 	public function admin_label() {
201
-		return $this->get( 'QST_admin_label' );
201
+		return $this->get('QST_admin_label');
202 202
 	}
203 203
 
204 204
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string
210 210
 	 */
211 211
 	public function system_ID() {
212
-		return $this->get( 'QST_system' );
212
+		return $this->get('QST_system');
213 213
 	}
214 214
 
215 215
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return boolean
221 221
 	 */
222 222
 	public function required() {
223
-		return $this->get( 'QST_required' );
223
+		return $this->get('QST_required');
224 224
 	}
225 225
 
226 226
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @return string
233 233
 	 */
234 234
 	public function required_text() {
235
-		return $this->get( 'QST_required_text' );
235
+		return $this->get('QST_required_text');
236 236
 	}
237 237
 
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return string
244 244
 	 */
245 245
 	public function type() {
246
-		return $this->get( 'QST_type' );
246
+		return $this->get('QST_type');
247 247
 	}
248 248
 
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 * @return int
256 256
 	 */
257 257
 	public function order() {
258
-		return $this->get( 'QST_order' );
258
+		return $this->get('QST_order');
259 259
 	}
260 260
 
261 261
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return boolean
268 268
 	 */
269 269
 	public function admin_only() {
270
-		return $this->get( 'QST_admin_only' );
270
+		return $this->get('QST_admin_only');
271 271
 	}
272 272
 
273 273
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @return int
279 279
 	 */
280 280
 	public function wp_user() {
281
-		return $this->get( 'QST_wp_user' );
281
+		return $this->get('QST_wp_user');
282 282
 	}
283 283
 
284 284
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @return boolean
290 290
 	 */
291 291
 	public function deleted() {
292
-		return $this->get( 'QST_deleted' );
292
+		return $this->get('QST_deleted');
293 293
 	}
294 294
 
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return EE_Answer[]
300 300
 	 */
301 301
 	public function answers() {
302
-		return $this->get_many_related( 'Answer' );
302
+		return $this->get_many_related('Answer');
303 303
 	}
304 304
 
305 305
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @return boolean true = has answers, false = no answers.
310 310
 	 */
311 311
 	public function has_answers() {
312
-		return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE;
312
+		return $this->count_related('Answer') > 0 ? TRUE : FALSE;
313 313
 	}
314 314
 
315 315
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return EE_Question_Group[]
320 320
 	 */
321 321
 	public function question_groups() {
322
-		return $this->get_many_related( 'Question_Group' );
322
+		return $this->get_many_related('Question_Group');
323 323
 	}
324 324
 
325 325
 
@@ -333,24 +333,24 @@  discard block
 block discarded – undo
333 333
 	 *                                                       whether it was trashed or not.
334 334
 	 * @return EE_Question_Option[]
335 335
 	 */
336
-	public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) {
337
-		if ( ! $this->ID() ) {
336
+	public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) {
337
+		if ( ! $this->ID()) {
338 338
 			return array();
339 339
 		}
340 340
 		$query_params = array();
341
-		if ( $selected_value_to_always_include ) {
342
-			if ( is_array( $selected_value_to_always_include ) ) {
343
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include );
341
+		if ($selected_value_to_always_include) {
342
+			if (is_array($selected_value_to_always_include)) {
343
+				$query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
344 344
 			} else {
345
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include;
345
+				$query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
346 346
 			}
347 347
 		}
348
-		if ( $notDeletedOptionsOnly ) {
349
-			$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE;
348
+		if ($notDeletedOptionsOnly) {
349
+			$query_params[0]['OR*options-query']['QSO_deleted'] = FALSE;
350 350
 		}
351 351
 		//order by QSO_order
352
-		$query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' );
353
-		return $this->get_many_related( 'Question_Option', $query_params );
352
+		$query_params['order_by'] = array('QSO_order' => 'ASC');
353
+		return $this->get_many_related('Question_Option', $query_params);
354 354
 	}
355 355
 
356 356
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return \EE_Question_Option[]
361 361
 	 */
362 362
 	public function temp_options() {
363
-		return $this->_model_relations[ 'Question_Option' ];
363
+		return $this->_model_relations['Question_Option'];
364 364
 	}
365 365
 
366 366
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param EE_Question_Option $option
372 372
 	 * @return boolean success
373 373
 	 */
374
-	public function add_option( EE_Question_Option $option ) {
375
-		return $this->_add_relation_to( $option, 'Question_Option' );
374
+	public function add_option(EE_Question_Option $option) {
375
+		return $this->_add_relation_to($option, 'Question_Option');
376 376
 	}
377 377
 
378 378
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param EE_Question_Option $option
383 383
 	 * @return boolean success
384 384
 	 */
385
-	public function add_temp_option( EE_Question_Option $option ) {
386
-		$this->_model_relations[ 'Question_Option' ][ ] = $option;
385
+	public function add_temp_option(EE_Question_Option $option) {
386
+		$this->_model_relations['Question_Option'][] = $option;
387 387
 		return TRUE;
388 388
 	}
389 389
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param EE_Question_Option $option
395 395
 	 * @return boolean success
396 396
 	 */
397
-	public function remove_option( EE_Question_Option $option ) {
398
-		return $this->_remove_relation_to( $option, 'Question_Option' );
397
+	public function remove_option(EE_Question_Option $option) {
398
+		return $this->_remove_relation_to($option, 'Question_Option');
399 399
 	}
400 400
 
401 401
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @return bool
405 405
 	 */
406 406
 	public function is_system_question() {
407
-		$system_ID = $this->get( 'QST_system' );
408
-		return ! empty( $system_ID ) ? TRUE : FALSE;
407
+		$system_ID = $this->get('QST_system');
408
+		return ! empty($system_ID) ? TRUE : FALSE;
409 409
 	}
410 410
 
411 411
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	public function set_order_to_latest() {
420 420
 		$latest_order = $this->get_model()->get_latest_question_order();
421
-		$latest_order ++;
422
-		$this->set( 'QST_order', $latest_order );
421
+		$latest_order++;
422
+		$this->set('QST_order', $latest_order);
423 423
 	}
424 424
 
425 425
 
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
 	 * Duplicates this question and its question options
439 439
 	 * @return \EE_Question
440 440
 	 */
441
-	public function duplicate( $options = array() ) {
441
+	public function duplicate($options = array()) {
442 442
 		$new_question = clone $this;
443
-		$new_question->set( 'QST_ID', null );
444
-		$new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) );
445
-		$new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) );
446
-		$new_question->set_system_ID( null );
447
-		$new_question->set_wp_user( get_current_user_id() );
443
+		$new_question->set('QST_ID', null);
444
+		$new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
445
+		$new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
446
+		$new_question->set_system_ID(null);
447
+		$new_question->set_wp_user(get_current_user_id());
448 448
                 //if we're duplicating a trashed question, assume we don't want the new one to be trashed
449
-                $new_question->set_deleted( false );
449
+                $new_question->set_deleted(false);
450 450
 		$success = $new_question->save();
451
-		if( $success ) {
451
+		if ($success) {
452 452
 			//we don't totally want to duplicate the question options, because we want them to be for the NEW question
453
-			foreach( $this->options() as $question_option ) {
454
-				$question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) );
453
+			foreach ($this->options() as $question_option) {
454
+				$question_option->duplicate(array('QST_ID' => $new_question->ID()));
455 455
 			}
456 456
 			return $new_question;
457 457
 		} else {
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @return int|float
465 465
 	 */
466 466
 	public function max() {
467
-		return $this->get( 'QST_max' );
467
+		return $this->get('QST_max');
468 468
 	}
469 469
 
470 470
 	/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param int|float $new_max
473 473
 	 * @return void
474 474
 	 */
475
-	public function set_max( $new_max ) {
476
-		$this->set( 'QST_max', $new_max );
475
+	public function set_max($new_max) {
476
+		$this->set('QST_max', $new_max);
477 477
 	}
478 478
 
479 479
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 * @param array $input_constructor_args
486 486
 	 * @return EE_Form_Input_Base
487 487
 	 */
488
-	public function generate_form_input( $registration = null, $answer = null, $input_constructor_args = array() ) {
488
+	public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) {
489 489
 		$identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
490 490
 
491 491
 		$input_constructor_args = array_merge(
@@ -496,27 +496,27 @@  discard block
 block discarded – undo
496 496
 				),
497 497
 				$input_constructor_args
498 498
 			);
499
-		if( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration ) {
500
-			$answer = EEM_Answer::instance()->get_registration_question_answer_object( $registration, $this->ID() );
499
+		if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
500
+			$answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
501 501
 		}
502 502
 		// has this question been answered ?
503
-		if ( $answer instanceof EE_Answer ) {
503
+		if ($answer instanceof EE_Answer) {
504 504
 			//answer gets htmlspecialchars called on it, undo that please
505 505
 			//because the form input's display strategy may call esc_attr too
506 506
 			//which also does html special characters
507 507
 			$values_with_html_special_chars = $answer->value();
508
-			if( is_array( $values_with_html_special_chars ) ) {
509
-				$default_value = array_map( 'htmlspecialchars_decode', $values_with_html_special_chars );
508
+			if (is_array($values_with_html_special_chars)) {
509
+				$default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
510 510
 			} else {
511
-				$default_value = htmlspecialchars_decode( $values_with_html_special_chars );
511
+				$default_value = htmlspecialchars_decode($values_with_html_special_chars);
512 512
 			}
513 513
 			$input_constructor_args['default'] = $default_value;
514 514
 		}
515
-		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $this->system_ID() );
516
-		if( EEM_Question::instance()->question_type_is_in_category(  $this->type(), 'text' ) ) {
517
-			$input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy(
515
+		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
516
+		if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) {
517
+			$input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
518 518
 				null,
519
-				min( $max_max_for_question, $this->max() )
519
+				min($max_max_for_question, $this->max())
520 520
 			);
521 521
 		}
522 522
 		$input_constructor_args = apply_filters(
@@ -528,26 +528,26 @@  discard block
 block discarded – undo
528 528
 		);
529 529
 
530 530
 		$result = null;
531
-		switch ( $this->type() ) {
531
+		switch ($this->type()) {
532 532
 			// Text
533 533
 			case EEM_Question::QST_type_text :
534
-				if( $identifier == 'email' ){
535
-					$result = new EE_Email_Input( $input_constructor_args );
536
-				}else{
537
-					$result = new EE_Text_Input( $input_constructor_args );
534
+				if ($identifier == 'email') {
535
+					$result = new EE_Email_Input($input_constructor_args);
536
+				} else {
537
+					$result = new EE_Text_Input($input_constructor_args);
538 538
 				}
539 539
 				break;
540 540
 			// Textarea
541 541
 			case EEM_Question::QST_type_textarea :
542
-				$result = new EE_Text_Area_Input( $input_constructor_args );
542
+				$result = new EE_Text_Area_Input($input_constructor_args);
543 543
 				break;
544 544
 			// Radio Buttons
545 545
 			case EEM_Question::QST_type_radio :
546
-				$result = new EE_Radio_Button_Input( $this->options(), $input_constructor_args );
546
+				$result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
547 547
 				break;
548 548
 			// Dropdown
549 549
 			case EEM_Question::QST_type_dropdown :
550
-				$result = new EE_Select_Input( $this->options(), $input_constructor_args );
550
+				$result = new EE_Select_Input($this->options(), $input_constructor_args);
551 551
 				break;
552 552
 			// State Dropdown
553 553
 			case EEM_Question::QST_type_state :
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 					$this,
558 558
 					$registration,
559 559
 					$answer
560
-				);				$result = new EE_State_Select_Input( $state_options, $input_constructor_args );
560
+				); $result = new EE_State_Select_Input($state_options, $input_constructor_args);
561 561
 				break;
562 562
 			// Country Dropdown
563 563
 			case EEM_Question::QST_type_country :
@@ -568,19 +568,19 @@  discard block
 block discarded – undo
568 568
 					$registration,
569 569
 					$answer
570 570
 				);
571
-				$result = new EE_Country_Select_Input( $country_options, $input_constructor_args );
571
+				$result = new EE_Country_Select_Input($country_options, $input_constructor_args);
572 572
 				break;
573 573
 			// Checkboxes
574 574
 			case EEM_Question::QST_type_checkbox :
575
-				$result = new EE_Checkbox_Multi_Input( $this->options(), $input_constructor_args );
575
+				$result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
576 576
 				break;
577 577
 			// Date
578 578
 			case EEM_Question::QST_type_date :
579
-				$result = new EE_Datepicker_Input( $input_constructor_args );
579
+				$result = new EE_Datepicker_Input($input_constructor_args);
580 580
 				break;
581 581
 			case EEM_Question::QST_type_html_textarea :
582
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy();
583
-				$input =  new EE_Text_Area_Input( $input_constructor_args );
582
+				$input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
583
+				$input = new EE_Text_Area_Input($input_constructor_args);
584 584
 				$result = $input;
585 585
 				break;
586 586
 			// fallback
@@ -592,12 +592,12 @@  discard block
 block discarded – undo
592 592
 					$this,
593 593
 					$input_constructor_args
594 594
 				);
595
-				if( ! $default_input ){
596
-					$default_input = new EE_Text_Input( $input_constructor_args );
595
+				if ( ! $default_input) {
596
+					$default_input = new EE_Text_Input($input_constructor_args);
597 597
 				}
598 598
 				$result = $default_input;
599 599
 		}
600
-		return apply_filters( 'FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer );
600
+		return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
601 601
 	}
602 602
 
603 603
 
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Text_Area_Input.input.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  * This input has a default validation strategy of plaintext (which can be removed after construction)
10 10
  */
11
-class EE_Text_Area_Input extends EE_Form_Input_Base{
11
+class EE_Text_Area_Input extends EE_Form_Input_Base {
12 12
 
13 13
 
14 14
 	protected $_rows = 2;
@@ -18,28 +18,28 @@  discard block
 block discarded – undo
18 18
 	 * sets the rows property on this input
19 19
 	 * @param int $rows
20 20
 	 */
21
-	public function set_rows( $rows ) {
21
+	public function set_rows($rows) {
22 22
 		$this->_rows = $rows;
23 23
 	}
24 24
 	/**
25 25
 	 * sets the cols html property on this input
26 26
 	 * @param int $cols
27 27
 	 */
28
-	public function set_cols( $cols ) {
28
+	public function set_cols($cols) {
29 29
 		$this->_cols = $cols;
30 30
 	}
31 31
 	/**
32 32
 	 *
33 33
 	 * @return int
34 34
 	 */
35
-	public function get_rows(){
35
+	public function get_rows() {
36 36
 		return $this->_rows;
37 37
 	}
38 38
 	/**
39 39
 	 *
40 40
 	 * @return int
41 41
 	 */
42
-	public function get_cols(){
42
+	public function get_cols() {
43 43
 		return $this->_cols;
44 44
 	}
45 45
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		
58 58
 		//if the input hasn't specifically mentioned a more lenient validation strategy, 
59 59
 		//apply plaintext validation strategy
60
-		if( ! $this->has_validation_strategy( 
60
+		if ( ! $this->has_validation_strategy( 
61 61
 				array(
62 62
 					'EE_Full_HTML_Validation_Strategy',
63 63
 					'EE_Simple_HTML_Validation_Strategy'
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		) {
67 67
 			//by default we use the plaintext validation. If you want something else,
68 68
 			//just remove it after the input is constructed :P using EE_Form_Input_Base::remove_validation_strategy()
69
-			$this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy() );
69
+			$this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
70 70
 		}
71 71
 	}
72 72
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Text_Input.input.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@  discard block
 block discarded – undo
8 8
  *
9 9
  * This input has a default validation strategy of plaintext (which can be removed after construction)
10 10
  */
11
-class EE_Text_Input extends EE_Form_Input_Base{
11
+class EE_Text_Input extends EE_Form_Input_Base {
12 12
 
13 13
 
14 14
 	/**
15 15
 	 * @param array $options
16 16
 	 */
17
-	function __construct($options = array()){
17
+	function __construct($options = array()) {
18 18
 		$this->_set_display_strategy(new EE_Text_Input_Display_Strategy());
19 19
 		$this->_set_normalization_strategy(new EE_Text_Normalization());
20 20
 		parent::__construct($options);
21 21
 		//if the input hasn't specifically mentioned a more lenient validation strategy, 
22 22
 		//apply plaintext validation strategy
23
-		if( ! $this->has_validation_strategy( 
23
+		if ( ! $this->has_validation_strategy( 
24 24
 				array(
25 25
 					'EE_Full_HTML_Validation_Strategy',
26 26
 					'EE_Simple_HTML_Validation_Strategy'
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		) {
30 30
 			//by default we use the plaintext validation. If you want something else,
31 31
 			//just remove it after the input is constructed :P using EE_Form_Input_Base::remove_validation_strategy()
32
-			$this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy() );
32
+			$this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
33 33
 		}
34 34
 	}
35 35
 
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 1 patch
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts).
8 8
  * However, you may output the form (usually by calling get_html_and_js) anywhere you like.
9 9
  */
10
-class EE_Form_Section_Proper extends EE_Form_Section_Validatable{
10
+class EE_Form_Section_Proper extends EE_Form_Section_Validatable {
11 11
 
12 12
 	/**
13 13
 	 * Subsections
@@ -68,38 +68,38 @@  discard block
 block discarded – undo
68 68
 	 * } @see EE_Form_Section_Validatable::__construct()
69 69
 	 *
70 70
 	 */
71
-	public function __construct( $options_array = array() ){
71
+	public function __construct($options_array = array()) {
72 72
 		EE_Registry::instance()->load_helper('Formatter');
73
-		$options_array = apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this );
73
+		$options_array = apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this);
74 74
 		//call parent first, as it may be setting the name
75 75
 		parent::__construct($options_array);
76 76
 		//if they've included subsections in the constructor, add them now
77
-		if( isset( $options_array['include'] )){
77
+		if (isset($options_array['include'])) {
78 78
 			//we are going to make sure we ONLY have those subsections to include
79 79
 			//AND we are going to make sure they're in that specified order
80 80
 			$reordered_subsections = array();
81
-			foreach($options_array['include'] as $input_name){
82
-				if(isset($this->_subsections[$input_name])){
81
+			foreach ($options_array['include'] as $input_name) {
82
+				if (isset($this->_subsections[$input_name])) {
83 83
 					$reordered_subsections[$input_name] = $this->_subsections[$input_name];
84 84
 				}
85 85
 			}
86 86
 			$this->_subsections = $reordered_subsections;
87 87
 		}
88
-		if(isset($options_array['exclude'])){
88
+		if (isset($options_array['exclude'])) {
89 89
 			$exclude = $options_array['exclude'];
90 90
 			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
91 91
 		}
92
-		if(isset($options_array['layout_strategy'])){
92
+		if (isset($options_array['layout_strategy'])) {
93 93
 			$this->_layout_strategy = $options_array['layout_strategy'];
94 94
 		}
95
-		if( ! $this->_layout_strategy){
95
+		if ( ! $this->_layout_strategy) {
96 96
 			$this->_layout_strategy = new EE_Two_Column_Layout();
97 97
 		}
98 98
 		$this->_layout_strategy->_construct_finalize($this);
99 99
 
100
-		add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
101
-		add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
102
-		add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 );
100
+		add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
101
+		add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
102
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
103 103
 	}
104 104
 
105 105
 
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
 	 * @param string                 $name
112 112
 	 * @throws \EE_Error
113 113
 	 */
114
-	public function _construct_finalize( $parent_form_section, $name ) {
114
+	public function _construct_finalize($parent_form_section, $name) {
115 115
 		parent::_construct_finalize($parent_form_section, $name);
116 116
 		$this->_set_default_name_if_empty();
117 117
 		$this->_set_default_html_id_if_empty();
118
-		foreach( $this->_subsections as $subsection_name => $subsection ){
119
-			if ( $subsection instanceof EE_Form_Section_Base ) {
120
-				$subsection->_construct_finalize( $this, $subsection_name );
118
+		foreach ($this->_subsections as $subsection_name => $subsection) {
119
+			if ($subsection instanceof EE_Form_Section_Base) {
120
+				$subsection->_construct_finalize($this, $subsection_name);
121 121
 			} else {
122 122
 				throw new EE_Error(
123 123
 					sprintf(
124
-						__( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ),
124
+						__('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'),
125 125
 						$subsection_name,
126 126
 						get_class($this),
127
-						$subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' )
127
+						$subsection ? get_class($subsection) : __('NULL', 'event_espresso')
128 128
 					)
129 129
 				);
130 130
 			}
131 131
 		}
132
-		do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name );
132
+		do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name);
133 133
 	}
134 134
 
135 135
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * Gets the layout strategy for this form section
139 139
 	 * @return EE_Form_Section_Layout_Base
140 140
 	 */
141
-	public function get_layout_strategy(){
141
+	public function get_layout_strategy() {
142 142
 		return $this->_layout_strategy;
143 143
 	}
144 144
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param EE_Form_Input_Base $input
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_html_for_input($input){
153
+	public function get_html_for_input($input) {
154 154
 		return $this->_layout_strategy->layout_input($input);
155 155
 	}
156 156
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param null $form_data
164 164
 	 * @return boolean
165 165
 	 */
166
-	public function was_submitted($form_data = NULL){
166
+	public function was_submitted($form_data = NULL) {
167 167
 		return $this->form_data_present_in($form_data);
168 168
 	}
169 169
 
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 	 *                          (eg you validated the data then stored it in the DB) you may want to skip this step.
189 189
 	 * @return void
190 190
 	 */
191
-	public function receive_form_submission($req_data = NULL, $validate = TRUE){
192
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate );
193
-		if( $req_data === NULL){
194
-			$req_data = array_merge( $_GET, $_POST );
191
+	public function receive_form_submission($req_data = NULL, $validate = TRUE) {
192
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate);
193
+		if ($req_data === NULL) {
194
+			$req_data = array_merge($_GET, $_POST);
195 195
 		}
196 196
 		$this->_normalize($req_data);
197
-		if( $validate ){
197
+		if ($validate) {
198 198
 			$this->_validate();
199 199
 		}
200
-		do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate );
200
+		do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate);
201 201
 	}
202 202
 
203 203
 
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
 	 * the value being an array formatted in teh same way
211 211
 	 * @param array $default_data
212 212
 	 */
213
-	public function populate_defaults($default_data){
214
-		foreach($this->subsections() as $subsection_name => $subsection){
215
-			if(isset($default_data[$subsection_name])){
216
-				if($subsection instanceof EE_Form_Input_Base){
213
+	public function populate_defaults($default_data) {
214
+		foreach ($this->subsections() as $subsection_name => $subsection) {
215
+			if (isset($default_data[$subsection_name])) {
216
+				if ($subsection instanceof EE_Form_Input_Base) {
217 217
 					$subsection->set_default($default_data[$subsection_name]);
218
-				}elseif($subsection instanceof EE_Form_Section_Proper){
218
+				}elseif ($subsection instanceof EE_Form_Section_Proper) {
219 219
 					$subsection->populate_defaults($default_data[$subsection_name]);
220 220
 				}
221 221
 			}
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 	 * (realizing that the subsections' html names might not be set yet, etc.)
234 234
 	 * @return EE_Form_Section_Base
235 235
 	 */
236
-	public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){
237
-		if( $require_construction_to_be_finalized ){
236
+	public function get_subsection($name, $require_construction_to_be_finalized = TRUE) {
237
+		if ($require_construction_to_be_finalized) {
238 238
 			$this->ensure_construct_finalized_called();
239 239
 		}
240 240
 		return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL;
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 	 * Gets all the validatable subsections of this form section
247 247
 	 * @return EE_Form_Section_Validatable[]
248 248
 	 */
249
-	public function get_validatable_subsections(){
249
+	public function get_validatable_subsections() {
250 250
 		$validatable_subsections = array();
251
-		foreach($this->subsections() as $name=>$obj){
252
-			if($obj instanceof EE_Form_Section_Validatable){
251
+		foreach ($this->subsections() as $name=>$obj) {
252
+			if ($obj instanceof EE_Form_Section_Validatable) {
253 253
 				$validatable_subsections[$name] = $obj;
254 254
 			}
255 255
 		}
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 	 * @return EE_Form_Input_Base
270 270
 	 * @throws EE_Error
271 271
 	 */
272
-	public function get_input($name, $require_construction_to_be_finalized = TRUE ){
272
+	public function get_input($name, $require_construction_to_be_finalized = TRUE) {
273 273
 		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
274
-		if( ! $subsection instanceof EE_Form_Input_Base){
275
-			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
274
+		if ( ! $subsection instanceof EE_Form_Input_Base) {
275
+			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
276 276
 		}
277 277
 		return $subsection;
278 278
 	}
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 * @return EE_Form_Section_Proper
291 291
 	 * @throws EE_Error
292 292
 	 */
293
-	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){
294
-		$subsection = $this->get_subsection( $name, $require_construction_to_be_finalized );
295
-		if( ! $subsection instanceof EE_Form_Section_Proper){
296
-			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this)));
293
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) {
294
+		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
295
+		if ( ! $subsection instanceof EE_Form_Section_Proper) {
296
+			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this)));
297 297
 		}
298 298
 		return $subsection;
299 299
 	}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @param string $name
307 307
 	 * @return mixed depending on the input's type and its normalization strategy
308 308
 	 */
309
-	public function get_input_value($name){
309
+	public function get_input_value($name) {
310 310
 		$input = $this->get_input($name);
311 311
 		return $input->normalized_value();
312 312
 	}
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
 	 * @return boolean
320 320
 	 */
321 321
 	public function is_valid() {
322
-		if( ! $this->has_received_submission()){
322
+		if ( ! $this->has_received_submission()) {
323 323
 			throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso")));
324 324
 		}
325
-		if( ! parent::is_valid()){
325
+		if ( ! parent::is_valid()) {
326 326
 			return false;
327 327
 		}
328 328
 		//ok so no errors general to this entire form section. so let's check the subsections
329
-		foreach( $this->get_validatable_subsections() as $subsection ){
330
-			if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){
331
-				$this->set_submission_error_message( $subsection->get_validation_error_string() );
329
+		foreach ($this->get_validatable_subsections() as $subsection) {
330
+			if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') {
331
+				$this->set_submission_error_message($subsection->get_validation_error_string());
332 332
 				return false;
333 333
 			}
334 334
 		}
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
 	 * gets teh default name of this form section if none is specified
342 342
 	 * @return string
343 343
 	 */
344
-	protected function _set_default_name_if_empty(){
345
-		if( ! $this->_name ){
344
+	protected function _set_default_name_if_empty() {
345
+		if ( ! $this->_name) {
346 346
 			$classname = get_class($this);
347 347
 			$default_name = str_replace("EE_", "", $classname);
348
-			$this->_name =  $default_name;
348
+			$this->_name = $default_name;
349 349
 		}
350 350
 	}
351 351
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * Also returns the HTML for the form, except for the form opening and closing tags
357 357
 	 * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button.
358 358
 	 */
359
-	public function get_html_and_js(){
359
+	public function get_html_and_js() {
360 360
 		$this->enqueue_js();
361 361
 		return $this->get_html();
362 362
 	}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
368 368
 	 * @return string
369 369
 	 */
370
-	public function get_html(){
370
+	public function get_html() {
371 371
 		$this->ensure_construct_finalized_called();
372 372
 		return $this->_layout_strategy->layout_form();
373 373
 	}
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * enqueues JS for the form
379 379
 	 * @return string
380 380
 	 */
381
-	public function enqueue_js(){
381
+	public function enqueue_js() {
382 382
 		$this->_enqueue_and_localize_form_js();
383 383
 	}
384 384
 
@@ -394,10 +394,10 @@  discard block
 block discarded – undo
394 394
 	 * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not
395 395
 	 * @return void
396 396
 	 */
397
-	public static function wp_enqueue_scripts( $init_form_validation_automatically = false ){
398
-		add_filter( 'FHEE_load_jquery_validate', '__return_true' );
399
-		wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE );
400
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ) );
397
+	public static function wp_enqueue_scripts($init_form_validation_automatically = false) {
398
+		add_filter('FHEE_load_jquery_validate', '__return_true');
399
+		wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE);
400
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically));
401 401
 	}
402 402
 
403 403
 
@@ -407,14 +407,14 @@  discard block
 block discarded – undo
407 407
 	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
408 408
 	 * but before the wordpress hook wp_loaded
409 409
 	 */
410
-	public function _enqueue_and_localize_form_js(){
410
+	public function _enqueue_and_localize_form_js() {
411 411
 		$this->ensure_construct_finalized_called();
412 412
 		//actually, we don't want to localize just yet. There may be other forms on the page.
413 413
 		//so we need to add our form section data to a static variable accessible by all form sections
414 414
 		//and localize it just before the footer
415 415
 		$this->localize_validation_rules();
416
-		add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 );
417
-		add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) );
416
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
417
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
418 418
 	}
419 419
 
420 420
 
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 	 * @param bool $return_for_subsection
425 425
 	 * @return void
426 426
 	 */
427
-	public function localize_validation_rules( $return_for_subsection = FALSE ){
427
+	public function localize_validation_rules($return_for_subsection = FALSE) {
428 428
 		// we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog
429
-		if ( ! $this->parent_section() || $return_for_subsection ) {
430
-			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
431
-				'form_section_id'=> $this->html_id( TRUE ),
429
+		if ( ! $this->parent_section() || $return_for_subsection) {
430
+			EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
431
+				'form_section_id'=> $this->html_id(TRUE),
432 432
 				'validation_rules'=> $this->get_jquery_validation_rules(),
433 433
 				'errors'=> $this->subsection_validation_errors_by_html_name()
434 434
 			);
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
 	 * Keys are their form names, and values are the inputs themselves
444 444
 	 * @return EE_Form_Input_Base
445 445
 	 */
446
-	public function inputs_in_subsections(){
446
+	public function inputs_in_subsections() {
447 447
 		$inputs = array();
448
-		foreach($this->subsections() as $subsection){
449
-			if( $subsection instanceof EE_Form_Input_Base ){
450
-				$inputs[ $subsection->html_name() ] = $subsection;
451
-			}elseif($subsection instanceof EE_Form_Section_Proper ){
448
+		foreach ($this->subsections() as $subsection) {
449
+			if ($subsection instanceof EE_Form_Input_Base) {
450
+				$inputs[$subsection->html_name()] = $subsection;
451
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
452 452
 				$inputs += $subsection->inputs_in_subsections();
453 453
 			}
454 454
 		}
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
 	 * and values are a string of all their validation errors
462 462
 	 * @return string[]
463 463
 	 */
464
-	public function subsection_validation_errors_by_html_name(){
464
+	public function subsection_validation_errors_by_html_name() {
465 465
 		$inputs = $this->inputs();
466 466
 		$errors = array();
467
-		foreach( $inputs as $form_input ){
468
-			if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){
469
-				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
467
+		foreach ($inputs as $form_input) {
468
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
469
+				$errors[$form_input->html_name()] = $form_input->get_validation_error_string();
470 470
 			}
471 471
 		}
472 472
 		return $errors;
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
479 479
 	 * Should be setup by each form during the _enqueues_and_localize_form_js
480 480
 	 */
481
-	public static function localize_script_for_all_forms(){
481
+	public static function localize_script_for_all_forms() {
482 482
 		//allow inputs and stuff to hook in their JS and stuff here
483 483
 		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
484 484
 		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
485
-		$email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level )
485
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
486 486
 			? EE_Registry::instance()->CFG->registration->email_validation_level
487 487
 			: 'wp_default';
488 488
 		EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
489
-		wp_enqueue_script( 'ee_form_section_validation' );
490
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization );
489
+		wp_enqueue_script('ee_form_section_validation');
490
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization);
491 491
 	}
492 492
 
493 493
 
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 	/**
496 496
 	 * ensure_scripts_localized
497 497
 	 */
498
-	public function ensure_scripts_localized(){
499
-		if ( ! EE_Form_Section_Proper::$_scripts_localized ) {
498
+	public function ensure_scripts_localized() {
499
+		if ( ! EE_Form_Section_Proper::$_scripts_localized) {
500 500
 			$this->_enqueue_and_localize_form_js();
501 501
 		}
502 502
 	}
@@ -508,10 +508,10 @@  discard block
 block discarded – undo
508 508
 	 * is that the key here should be the same as the custom validation rule put in the JS file
509 509
 	 * @return array keys are custom validation rules, and values are internationalized strings
510 510
 	 */
511
-	private static function _get_localized_error_messages(){
511
+	private static function _get_localized_error_messages() {
512 512
 		return array(
513 513
 			'validUrl'=>  __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"),
514
-			'regex' => __( 'Please check your input', 'event_espresso' ),
514
+			'regex' => __('Please check your input', 'event_espresso'),
515 515
 		);
516 516
 	}
517 517
 
@@ -539,10 +539,10 @@  discard block
 block discarded – undo
539 539
 	 * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more...
540 540
 	 * @return array
541 541
 	 */
542
-	function get_jquery_validation_rules(){
542
+	function get_jquery_validation_rules() {
543 543
 		$jquery_validation_rules = array();
544
-		foreach($this->get_validatable_subsections() as $subsection){
545
-			$jquery_validation_rules = array_merge( $jquery_validation_rules,  $subsection->get_jquery_validation_rules() );
544
+		foreach ($this->get_validatable_subsections() as $subsection) {
545
+			$jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules());
546 546
 		}
547 547
 		return $jquery_validation_rules;
548 548
 	}
@@ -557,11 +557,11 @@  discard block
 block discarded – undo
557 557
 	protected function _normalize($req_data) {
558 558
 		$this->_received_submission = TRUE;
559 559
 		$this->_validation_errors = array();
560
-		foreach($this->get_validatable_subsections() as $subsection){
561
-			try{
560
+		foreach ($this->get_validatable_subsections() as $subsection) {
561
+			try {
562 562
 				$subsection->_normalize($req_data);
563
-			}catch( EE_Validation_Error $e ){
564
-				$subsection->add_validation_error( $e );
563
+			} catch (EE_Validation_Error $e) {
564
+				$subsection->add_validation_error($e);
565 565
 			}
566 566
 		}
567 567
 	}
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
 	 * calling parent::_validate() first.
576 576
 	 */
577 577
 	protected function _validate() {
578
-		foreach($this->get_validatable_subsections() as $subsection_name => $subsection){
579
-			if(method_exists($this,'_validate_'.$subsection_name)){
580
-				call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
578
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
579
+			if (method_exists($this, '_validate_'.$subsection_name)) {
580
+				call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
581 581
 			}
582 582
 			$subsection->_validate();
583 583
 		}
@@ -589,13 +589,13 @@  discard block
 block discarded – undo
589 589
 	 * Gets all the validated inputs for the form section
590 590
 	 * @return array
591 591
 	 */
592
-	public function valid_data(){
592
+	public function valid_data() {
593 593
 		$inputs = array();
594
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
595
-			if ( $subsection instanceof EE_Form_Section_Proper ) {
596
-				$inputs[ $subsection_name ] = $subsection->valid_data();
597
-			} else if ( $subsection instanceof EE_Form_Input_Base ){
598
-				$inputs[ $subsection_name ] = $subsection->normalized_value();
594
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
595
+			if ($subsection instanceof EE_Form_Section_Proper) {
596
+				$inputs[$subsection_name] = $subsection->valid_data();
597
+			} else if ($subsection instanceof EE_Form_Input_Base) {
598
+				$inputs[$subsection_name] = $subsection->normalized_value();
599 599
 			}
600 600
 		}
601 601
 		return $inputs;
@@ -607,11 +607,11 @@  discard block
 block discarded – undo
607 607
 	 * Gets all the inputs on this form section
608 608
 	 * @return EE_Form_Input_Base[]
609 609
 	 */
610
-	public function inputs(){
610
+	public function inputs() {
611 611
 		$inputs = array();
612
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
613
-			if ( $subsection instanceof EE_Form_Input_Base ){
614
-				$inputs[ $subsection_name ] = $subsection;
612
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
613
+			if ($subsection instanceof EE_Form_Input_Base) {
614
+				$inputs[$subsection_name] = $subsection;
615 615
 			}
616 616
 		}
617 617
 		return $inputs;
@@ -623,10 +623,10 @@  discard block
 block discarded – undo
623 623
 	 * Gets all the subsections which are a proper form
624 624
 	 * @return EE_Form_Section_Proper[]
625 625
 	 */
626
-	public function subforms(){
626
+	public function subforms() {
627 627
 		$form_sections = array();
628
-		foreach($this->subsections() as $name=>$obj){
629
-			if($obj instanceof EE_Form_Section_Proper){
628
+		foreach ($this->subsections() as $name=>$obj) {
629
+			if ($obj instanceof EE_Form_Section_Proper) {
630 630
 				$form_sections[$name] = $obj;
631 631
 			}
632 632
 		}
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	 * if you only want form inputs or proper form sections.
642 642
 	 * @return EE_Form_Section_Proper[]
643 643
 	 */
644
-	public function subsections(){
644
+	public function subsections() {
645 645
 		$this->ensure_construct_finalized_called();
646 646
 		return $this->_subsections;
647 647
 	}
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
660 660
 	 * input's normalized value, or an array like the top-level array
661 661
 	 */
662
-	public function input_values( $include_subform_inputs = false, $flatten = false ){
663
-		return $this->_input_values( false, $include_subform_inputs, $flatten );
662
+	public function input_values($include_subform_inputs = false, $flatten = false) {
663
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
664 664
 	}
665 665
 
666 666
 	/**
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
677 677
 	 * input's normalized value, or an array like the top-level array
678 678
 	 */
679
-	public function input_pretty_values(  $include_subform_inputs = false, $flatten = false ){
680
-		return $this->_input_values( true, $include_subform_inputs, $flatten );
679
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false) {
680
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
681 681
 	}
682 682
 
683 683
 	/**
@@ -690,17 +690,17 @@  discard block
 block discarded – undo
690 690
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
691 691
 	 * input's normalized value, or an array like the top-level array
692 692
 	 */
693
-	public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) {
693
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) {
694 694
 		$input_values = array();
695
-		foreach( $this->subsections() as $subsection_name => $subsection ) {
696
-			if( $subsection instanceof EE_Form_Input_Base ) {
697
-				$input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
698
-			} else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) {
699
-				$subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten );
700
-				if( $flatten ) {
701
-					$input_values = array_merge( $input_values, $subform_input_values );
695
+		foreach ($this->subsections() as $subsection_name => $subsection) {
696
+			if ($subsection instanceof EE_Form_Input_Base) {
697
+				$input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
698
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
699
+				$subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten);
700
+				if ($flatten) {
701
+					$input_values = array_merge($input_values, $subform_input_values);
702 702
 				} else {
703
-					$input_values[ $subsection_name ] = $subform_input_values;
703
+					$input_values[$subsection_name] = $subform_input_values;
704 704
 				}
705 705
 			}
706 706
 		}
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 	 * (ie, had receive_form_submission called on it yet)
715 715
 	 * @return boolean
716 716
 	 */
717
-	public function has_received_submission(){
717
+	public function has_received_submission() {
718 718
 		$this->ensure_construct_finalized_called();
719 719
 		return $this->_received_submission;
720 720
 	}
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 	 * @param array $inputs_to_exclude values are the input names
728 728
 	 * @return void
729 729
 	 */
730
-	public function exclude($inputs_to_exclude = array()){
731
-		foreach($inputs_to_exclude as $input_to_exclude_name){
730
+	public function exclude($inputs_to_exclude = array()) {
731
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
732 732
 			unset($this->_subsections[$input_to_exclude_name]);
733 733
 		}
734 734
 	}
@@ -738,8 +738,8 @@  discard block
 block discarded – undo
738 738
 	/**
739 739
 	 * @param array $inputs_to_hide
740 740
 	 */
741
-	public function hide($inputs_to_hide= array()){
742
-		foreach($inputs_to_hide as $input_to_hide){
741
+	public function hide($inputs_to_hide = array()) {
742
+		foreach ($inputs_to_hide as $input_to_hide) {
743 743
 			$input = $this->get_input($input_to_hide);
744 744
 
745 745
 			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
@@ -764,13 +764,13 @@  discard block
 block discarded – undo
764 764
 	 * 																								or if $subsection_name_to_target is null, before or after entire subsections array
765 765
 	 * @return void
766 766
 	 */
767
-	public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){
768
-		foreach($new_subsections as $subsection_name => $subsection){
769
-			if( ! $subsection instanceof EE_Form_Section_Base){
767
+	public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) {
768
+		foreach ($new_subsections as $subsection_name => $subsection) {
769
+			if ( ! $subsection instanceof EE_Form_Section_Base) {
770 770
 				EE_Error::add_error(
771 771
 					sprintf(
772 772
 						__("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"),
773
-						get_class( $subsection ),
773
+						get_class($subsection),
774 774
 						$subsection_name,
775 775
 						$this->name()
776 776
 					)
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
 			}
780 780
 		}
781 781
 
782
-		EE_Registry::instance()->load_helper( 'Array' );
783
-		$this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before );
782
+		EE_Registry::instance()->load_helper('Array');
783
+		$this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before);
784 784
 
785 785
 		/*$subsections_before = array();
786 786
 		if( $subsection_name_to_target ){
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 				$this->_subsections = $new_subsections;
812 812
 			}
813 813
 		}*/
814
-		if( $this->_construction_finalized ){
815
-			foreach($this->_subsections as $name => $subsection){
814
+		if ($this->_construction_finalized) {
815
+			foreach ($this->_subsections as $name => $subsection) {
816 816
 				$subsection->_construct_finalize($this, $name);
817 817
 			}
818 818
 		}
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
 	/**
824 824
 	 * Just gets all validatable subsections to clean their sensitive data
825 825
 	 */
826
-	public function clean_sensitive_data(){
827
-		foreach($this->get_validatable_subsections() as $subsection){
826
+	public function clean_sensitive_data() {
827
+		foreach ($this->get_validatable_subsections() as $subsection) {
828 828
 			$subsection->clean_sensitive_data();
829 829
 		}
830 830
 	}
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
 	/**
835 835
 	 * @param string $form_submission_error_message
836 836
 	 */
837
-	public function set_submission_error_message( $form_submission_error_message = '' ) {
838
-		$this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' );
837
+	public function set_submission_error_message($form_submission_error_message = '') {
838
+		$this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso');
839 839
 	}
840 840
 
841 841
 
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 	/**
853 853
 	 * @param string $form_submission_success_message
854 854
 	 */
855
-	public function set_submission_success_message( $form_submission_success_message ) {
856
-		$this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' );
855
+	public function set_submission_success_message($form_submission_success_message) {
856
+		$this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso');
857 857
 	}
858 858
 
859 859
 
@@ -875,10 +875,10 @@  discard block
 block discarded – undo
875 875
 	 * EE_Form_Input_Base::_set_default_html_name_if_empty
876 876
 	 * @return string
877 877
 	 */
878
-	public function html_name_prefix(){
879
-		if( $this->parent_section() instanceof EE_Form_Section_Proper ){
880
-			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
881
-		}else{
878
+	public function html_name_prefix() {
879
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
880
+			return $this->parent_section()->html_name_prefix().'['.$this->name().']';
881
+		} else {
882 882
 			return $this->name();
883 883
 		}
884 884
 	}
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 	 * was set, which is probably nothing, or the classname)
890 890
 	 * @return string
891 891
 	 */
892
-	public function name(){
892
+	public function name() {
893 893
 		$this->ensure_construct_finalized_called();
894 894
 		return parent::name();
895 895
 	}
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 	 *
899 899
 	 * @return EE_Form_Section_Proper
900 900
 	 */
901
-	public function parent_section(){
901
+	public function parent_section() {
902 902
 		$this->ensure_construct_finalized_called();
903 903
 		return parent::parent_section();
904 904
 	}
@@ -907,9 +907,9 @@  discard block
 block discarded – undo
907 907
 	 * make sure construction finalized was called, otherwise children might not be ready
908 908
 	 * @return void
909 909
 	 */
910
-	public function ensure_construct_finalized_called(){
911
-		if( ! $this->_construction_finalized ){
912
-			$this->_construct_finalize($this->_parent_section, $this->_name );
910
+	public function ensure_construct_finalized_called() {
911
+		if ( ! $this->_construction_finalized) {
912
+			$this->_construct_finalize($this->_parent_section, $this->_name);
913 913
 		}
914 914
 	}
915 915
 
@@ -921,17 +921,17 @@  discard block
 block discarded – undo
921 921
 	 * @param array $req_data
922 922
 	 * @return boolean
923 923
 	 */
924
-	public function form_data_present_in( $req_data = NULL ) {
925
-		if( $req_data === NULL){
924
+	public function form_data_present_in($req_data = NULL) {
925
+		if ($req_data === NULL) {
926 926
 			$req_data = $_POST;
927 927
 		}
928
-		foreach( $this->subsections() as $subsection ) {
929
-			if($subsection instanceof EE_Form_Input_Base ) {
930
-				if( $subsection->form_data_present_in( $req_data ) ) {
928
+		foreach ($this->subsections() as $subsection) {
929
+			if ($subsection instanceof EE_Form_Input_Base) {
930
+				if ($subsection->form_data_present_in($req_data)) {
931 931
 					return TRUE;
932 932
 				}
933
-			}elseif( $subsection instanceof EE_Form_Section_Proper ) {
934
-				if( $subsection->form_data_present_in( $req_data ) ) {
933
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
934
+				if ($subsection->form_data_present_in($req_data)) {
935 935
 					return TRUE;
936 936
 				}
937 937
 			}
@@ -948,14 +948,14 @@  discard block
 block discarded – undo
948 948
 	 */
949 949
 	public function get_validation_errors_accumulated() {
950 950
 		$validation_errors = $this->get_validation_errors();
951
-		foreach($this->get_validatable_subsections() as $subsection ) {
952
-			if( $subsection instanceof EE_Form_Section_Proper ) {
951
+		foreach ($this->get_validatable_subsections() as $subsection) {
952
+			if ($subsection instanceof EE_Form_Section_Proper) {
953 953
 				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
954 954
 			} else {
955
-				$validation_errors_on_this_subsection =  $subsection->get_validation_errors();
955
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
956 956
 			}
957
-			if( $validation_errors_on_this_subsection ){
958
-				$validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection );
957
+			if ($validation_errors_on_this_subsection) {
958
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
959 959
 			}
960 960
 		}
961 961
 		return $validation_errors;
Please login to merge, or discard this patch.
strategies/validation/EE_Email_Validation_Strategy.strategy.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@  discard block
 block discarded – undo
8 8
  * @since 				4.6
9 9
  *
10 10
  */
11
-class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy{
11
+class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy {
12 12
 
13 13
 	/**
14 14
      * @param null $validation_error_message
15 15
      */
16
-   public function __construct( $validation_error_message = NULL ) {
17
-	   if( ! $validation_error_message ){
16
+   public function __construct($validation_error_message = NULL) {
17
+	   if ( ! $validation_error_message) {
18 18
 			$validation_error_message = __("Please enter a valid email address.", "event_espresso");
19 19
 		}
20
-		parent::__construct( $validation_error_message );
20
+		parent::__construct($validation_error_message);
21 21
 	}
22 22
 
23 23
 
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
     * @return bool
30 30
     * @throws \EE_Validation_Error
31 31
     */
32
-	public function validate( $normalized_value ) {
33
-		if( $normalized_value && ! $this->_validate_email( $normalized_value ) ){
34
-			throw new EE_Validation_Error( $this->get_validation_error_message(), 'required');
32
+	public function validate($normalized_value) {
33
+		if ($normalized_value && ! $this->_validate_email($normalized_value)) {
34
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
35 35
 		}
36 36
 	}
37 37
 
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
      * @return array
42 42
      */
43
-	public function get_jquery_validation_rule_array(){
44
-	   return array( 'email'=>true, 'messages' => array( 'email' => $this->get_validation_error_message() ) );
43
+	public function get_jquery_validation_rule_array() {
44
+	   return array('email'=>true, 'messages' => array('email' => $this->get_validation_error_message()));
45 45
 	}
46 46
 
47 47
 
@@ -54,38 +54,38 @@  discard block
 block discarded – undo
54 54
 	 * @return bool of whether the email is valid or not
55 55
 	 * @throws \EE_Validation_Error
56 56
 	 */
57
-	private function _validate_email( $email ) {
58
-		$validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level )
57
+	private function _validate_email($email) {
58
+		$validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
59 59
 			? EE_Registry::instance()->CFG->registration->email_validation_level
60 60
 			: 'wp_default';
61
-		if ( ! preg_match( '/^.+\@\S+$/', $email ) ) { // \.\S+
61
+		if ( ! preg_match('/^.+\@\S+$/', $email)) { // \.\S+
62 62
 			// email not in correct {string}@{string} format
63 63
 			return false;
64 64
 		} else {
65
-			$atIndex = strrpos( $email, "@" );
66
-			$domain = substr( $email, $atIndex + 1 );
67
-			$local = substr( $email, 0, $atIndex );
68
-			$localLen = strlen( $local );
69
-			$domainLen = strlen( $domain );
70
-			if ( $localLen < 1 || $localLen > 64 ) {
65
+			$atIndex = strrpos($email, "@");
66
+			$domain = substr($email, $atIndex + 1);
67
+			$local = substr($email, 0, $atIndex);
68
+			$localLen = strlen($local);
69
+			$domainLen = strlen($domain);
70
+			if ($localLen < 1 || $localLen > 64) {
71 71
 				// local part length exceeded
72 72
 				return false;
73
-			} else if ( $domainLen < 1 || $domainLen > 255 ) {
73
+			} else if ($domainLen < 1 || $domainLen > 255) {
74 74
 				// domain part length exceeded
75 75
 				return false;
76
-			} else if ( $local[ 0 ] === '.' || $local[ $localLen - 1 ] === '.' ) {
76
+			} else if ($local[0] === '.' || $local[$localLen - 1] === '.') {
77 77
 				// local part starts or ends with '.'
78 78
 				return false;
79
-			} else if ( preg_match( '/\\.\\./', $local ) ) {
79
+			} else if (preg_match('/\\.\\./', $local)) {
80 80
 				// local part has two consecutive dots
81 81
 				return false;
82
-			} else if ( preg_match( '/\\.\\./', $domain ) ) {
82
+			} else if (preg_match('/\\.\\./', $domain)) {
83 83
 				// domain part has two consecutive dots
84 84
 				return false;
85
-			} else if ( $validation_level === 'wp_default' ) {
86
-				return is_email( $email );
85
+			} else if ($validation_level === 'wp_default') {
86
+				return is_email($email);
87 87
 			} else if (
88
-				( $validation_level === 'i18n' || $validation_level === 'i18n_dns' )
88
+				($validation_level === 'i18n' || $validation_level === 'i18n_dns')
89 89
 				// plz see http://stackoverflow.com/a/24817336 re: the following regex
90 90
 				&& ! preg_match(
91 91
 					'/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 			) {
95 95
 				return false;
96 96
 			}
97
-			if ( $validation_level === 'i18n_dns' ) {
98
-				if ( ! checkdnsrr( $domain, "MX" ) ) {
97
+			if ($validation_level === 'i18n_dns') {
98
+				if ( ! checkdnsrr($domain, "MX")) {
99 99
 					// domain not found in MX records
100 100
 					throw new EE_Validation_Error(
101 101
 						__(
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 							'event_espresso'
104 104
 						)
105 105
 					);
106
-				} else if ( ! checkdnsrr( $domain, "A" ) ) {
106
+				} else if ( ! checkdnsrr($domain, "A")) {
107 107
 					// domain not found in A records
108 108
 					throw new EE_Validation_Error(
109 109
 						__(
Please login to merge, or discard this patch.
core/db_classes/EE_Export.class.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3 3
 /**
4 4
  * EE_Export class
5 5
  * 
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	  * @access private
40 40
 	  * @param array $request_data
41 41
 	  */
42
- 	private function __construct( $request_data = array() ) {
42
+ 	private function __construct($request_data = array()) {
43 43
 		$this->_req_data = $request_data;
44
-		$this->today = date("Y-m-d",time());
45
-		require_once( EE_CLASSES . 'EE_CSV.class.php' );
46
-		$this->EE_CSV= EE_CSV::instance();
44
+		$this->today = date("Y-m-d", time());
45
+		require_once(EE_CLASSES.'EE_CSV.class.php');
46
+		$this->EE_CSV = EE_CSV::instance();
47 47
 	}
48 48
 
49 49
 
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	  * @param array $request_data
56 56
 	  * @return \EE_Export
57 57
 	  */
58
-	public static function instance( $request_data = array() ) {
58
+	public static function instance($request_data = array()) {
59 59
 		// check if class object is instantiated
60
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Export )) {
61
-			self::$_instance = new self( $request_data );
60
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Export)) {
61
+			self::$_instance = new self($request_data);
62 62
 		}
63 63
 		return self::$_instance;
64 64
 	}
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 	public function export() {
73 73
 
74 74
 		// in case of bulk exports, the "actual" action will be in action2, but first check regular action for "export" keyword
75
-		if ( isset( $this->_req_data['action'] ) && strpos( $this->_req_data['action'], 'export' ) === FALSE ) {
75
+		if (isset($this->_req_data['action']) && strpos($this->_req_data['action'], 'export') === FALSE) {
76 76
 			// check if action2 has export action
77
-			if ( isset( $this->_req_data['action2'] ) && strpos( $this->_req_data['action2'], 'export' ) !== FALSE ) {
77
+			if (isset($this->_req_data['action2']) && strpos($this->_req_data['action2'], 'export') !== FALSE) {
78 78
 				// whoop! there it is!
79 79
 				$this->_req_data['action'] = $this->_req_data['action2'];
80 80
 			}
81 81
 		}
82 82
 
83
-		$this->_req_data['export'] = isset( $this->_req_data['export'] ) ? $this->_req_data['export'] : '';
83
+		$this->_req_data['export'] = isset($this->_req_data['export']) ? $this->_req_data['export'] : '';
84 84
 
85 85
 		switch ($this->_req_data['export']) {
86 86
 			case 'report':
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 					break;
95 95
 
96 96
 					case 'registrations_report_for_event':
97
-						$this->report_registrations_for_event( $this->_req_data['EVT_ID'] );
97
+						$this->report_registrations_for_event($this->_req_data['EVT_ID']);
98 98
 					break;
99 99
 
100 100
 					case 'attendees':
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 					break;
107 107
 
108 108
 					default:
109
-						EE_Error::add_error(__('An error occurred! The requested export report could not be found.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ) ;
109
+						EE_Error::add_error(__('An error occurred! The requested export report could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
110 110
 						return FALSE;
111 111
 					break;
112 112
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * Downloads a CSV file with all the columns, but no data. This should be used for importing
125 125
 	 * @return null kills execution
126 126
 	 */
127
-	function export_sample(){
127
+	function export_sample() {
128 128
 		$event = EEM_Event::instance()->get_one();
129 129
 		$this->_req_data['EVT_ID'] = $event->ID();
130 130
 		$this->export_all_event_data();
@@ -150,23 +150,23 @@  discard block
 block discarded – undo
150 150
 		$state_country_query_params = array();
151 151
 		$question_group_query_params = array();
152 152
 		$question_query_params = array();
153
-		if ( isset( $this->_req_data['EVT_ID'] )) {
153
+		if (isset($this->_req_data['EVT_ID'])) {
154 154
 			// do we have an array of IDs ?
155 155
 
156
-			if ( is_array( $this->_req_data['EVT_ID'] )) {
157
-				$EVT_IDs =  array_map( 'sanitize_text_field', $this->_req_data['EVT_ID'] );
158
-				$value_to_equal = array('IN',$EVT_IDs);
156
+			if (is_array($this->_req_data['EVT_ID'])) {
157
+				$EVT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_ID']);
158
+				$value_to_equal = array('IN', $EVT_IDs);
159 159
 				$filename = 'events';
160 160
 			} else {
161 161
 				// generate regular where = clause
162
-				$EVT_ID = absint( $this->_req_data['EVT_ID'] );
162
+				$EVT_ID = absint($this->_req_data['EVT_ID']);
163 163
 				$value_to_equal = $EVT_ID;
164 164
 				$event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($EVT_ID);
165 165
 
166
-				$filename = 'event-' . ( $event instanceof EE_Event ? $event->slug() : __( 'unknown', 'event_espresso' ) );
166
+				$filename = 'event-'.($event instanceof EE_Event ? $event->slug() : __('unknown', 'event_espresso'));
167 167
 
168 168
 			}
169
-			$event_query_params[0]['EVT_ID'] =$value_to_equal;
169
+			$event_query_params[0]['EVT_ID'] = $value_to_equal;
170 170
 			$related_models_query_params[0]['Event.EVT_ID'] = $value_to_equal;
171 171
 			$related_through_reg_query_params[0]['Registration.EVT_ID'] = $value_to_equal;
172 172
 			$datetime_ticket_query_params[0]['Datetime.EVT_ID'] = $value_to_equal;
@@ -210,42 +210,42 @@  discard block
 block discarded – undo
210 210
 
211 211
 			);
212 212
 
213
-		$model_data = $this->_get_export_data_for_models( $models_to_export );
213
+		$model_data = $this->_get_export_data_for_models($models_to_export);
214 214
 
215
-		$filename = $this->generate_filename ( $filename );
215
+		$filename = $this->generate_filename($filename);
216 216
 
217
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) {
218
-			EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ );
217
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) {
218
+			EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
219 219
 		}
220 220
 	}
221 221
 
222
-	function report_attendees(){
222
+	function report_attendees() {
223 223
 		$attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( 
224 224
 			array( 
225
-				'force_join' => array( 'State', 'Country' ), 
225
+				'force_join' => array('State', 'Country'), 
226 226
 				'caps' => EEM_Base::caps_read_admin 
227 227
 			) 
228 228
 		);
229 229
 		$csv_data = array();
230
-		foreach( $attendee_rows as $attendee_row ){
230
+		foreach ($attendee_rows as $attendee_row) {
231 231
 			$csv_row = array();
232
-			foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){
233
-				if( $field_name == 'STA_ID' ){
234
-					$state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' );
235
-					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
236
-				}elseif( $field_name == 'CNT_ISO' ){
237
-					$country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' );
238
-					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
239
-				}else{
240
-					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
232
+			foreach (EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
233
+				if ($field_name == 'STA_ID') {
234
+					$state_name_field = EEM_State::instance()->field_settings_for('STA_name');
235
+					$csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()];
236
+				}elseif ($field_name == 'CNT_ISO') {
237
+					$country_name_field = EEM_Country::instance()->field_settings_for('CNT_name');
238
+					$csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()];
239
+				} else {
240
+					$csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()];
241 241
 				}
242 242
 			}
243 243
 			$csv_data[] = $csv_row;
244 244
 		}
245 245
 
246
-		$filename = $this->generate_filename ( 'contact-list-report' );
246
+		$filename = $this->generate_filename('contact-list-report');
247 247
 
248
-		$handle = $this->EE_CSV->begin_sending_csv( $filename);
248
+		$handle = $this->EE_CSV->begin_sending_csv($filename);
249 249
 		$this->EE_CSV->write_data_array_to_csv($handle, $csv_data);
250 250
 		$this->EE_CSV->end_sending_csv($handle);
251 251
 	}
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
 		$countries_that_have_an_attendee = EEM_Country::instance()->get_all(array(0=>array('Attendee.ATT_ID'=>array('IS NOT NULL'))));
263 263
 //		$states_to_export_query_params
264 264
 		$models_to_export = array(
265
-			'Country'=>array(array('CNT_ISO'=>array('IN',array_keys($countries_that_have_an_attendee)))),
266
-			'State'=>array(array('STA_ID'=>array('IN',array_keys($states_that_have_an_attendee)))),
265
+			'Country'=>array(array('CNT_ISO'=>array('IN', array_keys($countries_that_have_an_attendee)))),
266
+			'State'=>array(array('STA_ID'=>array('IN', array_keys($states_that_have_an_attendee)))),
267 267
 			'Attendee'=>array(),
268 268
 		);
269 269
 
270 270
 
271 271
 
272
-		$model_data = $this->_get_export_data_for_models( $models_to_export );
273
-		$filename = $this->generate_filename ( 'all-attendees' );
272
+		$model_data = $this->_get_export_data_for_models($models_to_export);
273
+		$filename = $this->generate_filename('all-attendees');
274 274
 
275
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) {
276
-			EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
275
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) {
276
+			EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
277 277
 		}
278 278
 	}
279 279
 
@@ -285,19 +285,19 @@  discard block
 block discarded – undo
285 285
 	 * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty
286 286
 	 * @return string
287 287
 	 */
288
-	protected function _prepare_value_from_db_for_display( $model, $field_name,  $raw_db_value, $pretty_schema = true ) {
289
-		$field_obj = $model->field_settings_for( $field_name );
290
-		$value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value );
291
-		if( $field_obj instanceof EE_Datetime_Field ) {
292
-			$field_obj->set_date_format( EE_CSV::instance()->get_date_format_for_csv( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema );
293
-			$field_obj->set_time_format( EE_CSV::instance()->get_time_format_for_csv( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema );
288
+	protected function _prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) {
289
+		$field_obj = $model->field_settings_for($field_name);
290
+		$value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value);
291
+		if ($field_obj instanceof EE_Datetime_Field) {
292
+			$field_obj->set_date_format(EE_CSV::instance()->get_date_format_for_csv($field_obj->get_date_format($pretty_schema)), $pretty_schema);
293
+			$field_obj->set_time_format(EE_CSV::instance()->get_time_format_for_csv($field_obj->get_time_format($pretty_schema)), $pretty_schema);
294 294
 		}
295
-		if( $pretty_schema === true){
296
-			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
297
-		}elseif( is_string( $pretty_schema ) ) {
298
-			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
299
-		}else{
300
-			return $field_obj->prepare_for_get( $value_on_model_obj );
295
+		if ($pretty_schema === true) {
296
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj);
297
+		}elseif (is_string($pretty_schema)) {
298
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema);
299
+		} else {
300
+			return $field_obj->prepare_for_get($value_on_model_obj);
301 301
 		}
302 302
 	}
303 303
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * and the questions associated with the registrations
307 307
 	 * @param int $event_id
308 308
 	 */
309
-	function report_registrations_for_event( $event_id = NULL ){
309
+	function report_registrations_for_event($event_id = NULL) {
310 310
 		$reg_fields_to_include = array(
311 311
 				'TXN_ID',
312 312
 				'ATT_ID',
@@ -338,126 +338,126 @@  discard block
 block discarded – undo
338 338
 				array(
339 339
 					'OR' => array(
340 340
 						//don't include registrations from failed or abandoned transactions...
341
-						'Transaction.STS_ID' => array( 'NOT IN', array( EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code ) ),
341
+						'Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)),
342 342
 						//unless the registration is approved, in which case include it regardless of transaction status
343 343
 						'STS_ID' => EEM_Registration::status_id_approved
344 344
 						),
345
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
345
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
346 346
 					),
347
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
348
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
347
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
348
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
349 349
 				'caps' => EEM_Base::caps_read_admin
350 350
 			),
351 351
 			$event_id
352 352
 		);
353
-		if( $event_id ){
354
-			$query_params[0]['EVT_ID'] =  $event_id;
355
-		}else{
356
-			$query_params[ 'force_join' ][] = 'Event';
353
+		if ($event_id) {
354
+			$query_params[0]['EVT_ID'] = $event_id;
355
+		} else {
356
+			$query_params['force_join'][] = 'Event';
357 357
 		}
358
-		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
358
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
359 359
 		//get all questions which relate to someone in this group
360 360
 		$registration_ids = array();
361
-		foreach( $registration_rows as $reg_row ) {
362
-			$registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] );
361
+		foreach ($registration_rows as $reg_row) {
362
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
363 363
 		}
364 364
 //		EEM_Question::instance()->show_next_x_db_queries();
365
-		$questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN',$registration_ids))));
366
-		foreach($registration_rows as $reg_row){
367
-			if ( is_array( $reg_row ) ) {
365
+		$questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN', $registration_ids))));
366
+		foreach ($registration_rows as $reg_row) {
367
+			if (is_array($reg_row)) {
368 368
 				$reg_csv_array = array();
369
-				if( ! $event_id ){
369
+				if ( ! $event_id) {
370 370
 					//get the event's name and Id
371
-					$reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), $this->_prepare_value_from_db_for_display( EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] );
371
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
372 372
 				}
373
-				$is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false;
373
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
374 374
 				/*@var $reg_row EE_Registration */
375
-				foreach($reg_fields_to_include as $field_name){
375
+				foreach ($reg_fields_to_include as $field_name) {
376 376
 					$field = $reg_model->field_settings_for($field_name);
377
-					if($field_name == 'REG_final_price'){
378
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
379
-					}elseif( $field_name == 'REG_count' ){
380
-						$value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
381
-					}elseif( $field_name == 'REG_date' ) {
382
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
383
-					}else{
384
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
377
+					if ($field_name == 'REG_final_price') {
378
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
379
+					}elseif ($field_name == 'REG_count') {
380
+						$value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
381
+					}elseif ($field_name == 'REG_date') {
382
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
383
+					} else {
384
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
385 385
 					}
386 386
 					$reg_csv_array[$this->_get_column_name_for_field($field)] = $value;
387
-					if($field_name == 'REG_final_price'){
387
+					if ($field_name == 'REG_final_price') {
388 388
 						//add a column named Currency after the final price
389 389
 						$reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code;
390 390
 					}
391 391
 				}
392 392
 				//get pretty status
393
-				$stati = EEM_Status::instance()->localized_status( array(
394
-					$reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ),
395
-					$reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ),
393
+				$stati = EEM_Status::instance()->localized_status(array(
394
+					$reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'),
395
+					$reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ),
396 396
 						FALSE,
397
-						'sentence' );
398
-				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ];
397
+						'sentence');
398
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
399 399
 				//get pretty trnasaction status
400
-				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ];
401
-				$reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00';
402
-				$reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00';
400
+				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']];
401
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00';
402
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00';
403 403
 				$payment_methods = array();
404 404
 				$gateway_txn_ids_etc = array();
405 405
 				$payment_times = array();
406
-				if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){
406
+				if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) {
407 407
 					$payments_info = EEM_Payment::instance()->get_all_wpdb_results(
408 408
 							array(
409 409
 								array(
410
-									'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ],
410
+									'TXN_ID' => $reg_row['Transaction.TXN_ID'],
411 411
 									'STS_ID' => EEM_Payment::status_id_approved
412 412
 								),
413
-								'force_join' => array( 'Payment_Method' ),
413
+								'force_join' => array('Payment_Method'),
414 414
 
415 415
 							),
416 416
 							ARRAY_A,
417 417
 							'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' );
418 418
 
419
-					foreach( $payments_info as $payment_method_and_gateway_txn_id ){
420
-						$payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' );
421
-						$gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : '';
422
-						$payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : '';
419
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
420
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
421
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
422
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
423 423
 					}
424 424
 
425 425
 				}
426
-				$reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times );
427
-				$reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods );
428
-				$reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc );
426
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
427
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
428
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
429 429
 
430 430
 				//get whether or not the user has checked in
431
-				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' );
431
+				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
432 432
 				//get ticket of registration and its price
433 433
 				$ticket_model = EE_Registry::instance()->load_model('Ticket');
434
-				if( $reg_row[ 'Ticket.TKT_ID'] ) {
435
-					$ticket_name = $this->_prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] );
434
+				if ($reg_row['Ticket.TKT_ID']) {
435
+					$ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
436 436
 					$datetimes_strings = array();
437
-					foreach( EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){
438
-						$datetimes_strings[] = $this->_prepare_value_from_db_for_display( EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] );
437
+					foreach (EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
438
+						$datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
439 439
 					}
440 440
 
441 441
 				} else {
442
-					$ticket_name = __( 'Unknown', 'event_espresso' );
443
-					$datetimes_strings = array( __( 'Unknown', 'event_espresso' ) );
442
+					$ticket_name = __('Unknown', 'event_espresso');
443
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
444 444
 				}
445 445
 				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
446 446
 				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
447 447
 				//get datetime(s) of registration
448 448
 
449 449
 				//add attendee columns
450
-				foreach($att_fields_to_include as $att_field_name){
450
+				foreach ($att_fields_to_include as $att_field_name) {
451 451
 					$field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
452
-					if( $reg_row[ 'Attendee_CPT.ID' ]){
453
-						if($att_field_name == 'STA_ID'){
454
-							$value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
455
-						}elseif($att_field_name == 'CNT_ISO'){
456
-							$value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
457
-						}else{
458
-							$value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
452
+					if ($reg_row['Attendee_CPT.ID']) {
453
+						if ($att_field_name == 'STA_ID') {
454
+							$value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
455
+						}elseif ($att_field_name == 'CNT_ISO') {
456
+							$value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
457
+						} else {
458
+							$value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
459 459
 						}
460
-					}else{
460
+					} else {
461 461
 						$value = '';
462 462
 					}
463 463
 
@@ -465,56 +465,56 @@  discard block
 block discarded – undo
465 465
 				}
466 466
 
467 467
 				//make sure each registration has the same questions in the same order
468
-				foreach($questions_for_these_regs_rows as $question_row){
469
-					if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){
470
-						$reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null;
468
+				foreach ($questions_for_these_regs_rows as $question_row) {
469
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
470
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
471 471
 					}
472 472
 				}
473 473
 				//now fill out the questions THEY answered
474
-				foreach( EEM_Answer::instance()->get_all_wpdb_results( array( array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), 'force_join' => array( 'Question' ) ) ) as $answer_row){
474
+				foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) {
475 475
 					/* @var $answer EE_Answer */
476
-					if( $answer_row[ 'Question.QST_ID' ] ){
477
-						$question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] );
478
-					}else{
479
-						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
476
+					if ($answer_row['Question.QST_ID']) {
477
+						$question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']);
478
+					} else {
479
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
480 480
 					}
481
-                                        if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) {
482
-                                            $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] );
481
+                                        if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) {
482
+                                            $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']);
483 483
                                         } else {
484
-                                            $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] );
484
+                                            $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']);
485 485
                                         }
486 486
 				}
487
-				$registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row );
487
+				$registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row);
488 488
 			}
489 489
 		}
490 490
 
491 491
 		//if we couldn't export anything, we want to at least show the column headers
492
-		if(empty($registrations_csv_ready_array)){
492
+		if (empty($registrations_csv_ready_array)) {
493 493
 			$reg_csv_array = array();
494 494
 			$model_and_fields_to_include = array(
495 495
 				'Registration' => $reg_fields_to_include,
496 496
 				'Attendee' => $att_fields_to_include
497 497
 			);
498
-			foreach($model_and_fields_to_include as $model_name => $field_list){
498
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
499 499
 				$model = EE_Registry::instance()->load_model($model_name);
500
-				foreach($field_list as $field_name){
500
+				foreach ($field_list as $field_name) {
501 501
 					$field = $model->field_settings_for($field_name);
502
-					$reg_csv_array[$this->_get_column_name_for_field($field)] = null;//$registration->get($field->get_name());
502
+					$reg_csv_array[$this->_get_column_name_for_field($field)] = null; //$registration->get($field->get_name());
503 503
 				}
504 504
 			}
505 505
 			$registrations_csv_ready_array [] = $reg_csv_array;
506 506
 		}
507
-		if( $event_id ){
508
-			$event_slug =  EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' );
509
-			if( ! $event_slug ) {
510
-				$event_slug = __( 'unknown', 'event_espresso' );
507
+		if ($event_id) {
508
+			$event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
509
+			if ( ! $event_slug) {
510
+				$event_slug = __('unknown', 'event_espresso');
511 511
 			}
512
-		}else{
513
-			$event_slug = __( 'all', 'event_espresso' );
512
+		} else {
513
+			$event_slug = __('all', 'event_espresso');
514 514
 		}
515
-		$filename = sprintf( "registrations-for-%s", $event_slug );
515
+		$filename = sprintf("registrations-for-%s", $event_slug);
516 516
 
517
-		$handle = $this->EE_CSV->begin_sending_csv( $filename);
517
+		$handle = $this->EE_CSV->begin_sending_csv($filename);
518 518
 		$this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array);
519 519
 		$this->EE_CSV->end_sending_csv($handle);
520 520
 	}
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 * @param EE_Model_Field_Base $field
525 525
 	 * @return string
526 526
 	 */
527
-	protected function _get_column_name_for_field(EE_Model_Field_Base $field){
527
+	protected function _get_column_name_for_field(EE_Model_Field_Base $field) {
528 528
 		return $field->get_nicename()."[".$field->get_name()."]";
529 529
 	}
530 530
 
@@ -537,17 +537,17 @@  discard block
 block discarded – undo
537 537
 	function export_categories() {
538 538
 		// are any Event IDs set?
539 539
 		$query_params = array();
540
-		if ( isset( $this->_req_data['EVT_CAT_ID'] )) {
540
+		if (isset($this->_req_data['EVT_CAT_ID'])) {
541 541
 			// do we have an array of IDs ?
542
-			if ( is_array( $this->_req_data['EVT_CAT_ID'] )) {
542
+			if (is_array($this->_req_data['EVT_CAT_ID'])) {
543 543
 				// generate an "IN (CSV)" where clause
544
-				$EVT_CAT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_CAT_ID'] );
544
+				$EVT_CAT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_CAT_ID']);
545 545
 				$filename = 'event-categories';
546
-				$query_params[0]['term_taxonomy_id'] = array('IN',$EVT_CAT_IDs);
546
+				$query_params[0]['term_taxonomy_id'] = array('IN', $EVT_CAT_IDs);
547 547
 			} else {
548 548
 				// generate regular where = clause
549
-				$EVT_CAT_ID = absint( $this->_req_data['EVT_CAT_ID'] );
550
-				$filename = 'event-category#' . $EVT_CAT_ID;
549
+				$EVT_CAT_ID = absint($this->_req_data['EVT_CAT_ID']);
550
+				$filename = 'event-category#'.$EVT_CAT_ID;
551 551
 				$query_params[0]['term_taxonomy_id'] = $EVT_CAT_ID;
552 552
 			}
553 553
 		} else {
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 				'Term_Taxonomy' => $query_params
560 560
 			);
561 561
 
562
-		$table_data = $this->_get_export_data_for_models( $tables_to_export );
563
-		$filename = $this->generate_filename ( $filename );
562
+		$table_data = $this->_get_export_data_for_models($tables_to_export);
563
+		$filename = $this->generate_filename($filename);
564 564
 
565
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $table_data )) {
566
-			EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
565
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $table_data)) {
566
+			EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
567 567
 		}
568 568
 	}
569 569
 
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 	 *		  @param string - export_name
575 575
 	 *			@return string on success, FALSE on fail
576 576
 	 */
577
-	private function generate_filename ( $export_name = '' ) {
578
-		if ( $export_name != '' ) {
579
-			$filename = get_bloginfo('name') . '-' . $export_name;
580
-			$filename = sanitize_key( $filename ) . '-' . $this->today;
577
+	private function generate_filename($export_name = '') {
578
+		if ($export_name != '') {
579
+			$filename = get_bloginfo('name').'-'.$export_name;
580
+			$filename = sanitize_key($filename).'-'.$this->today;
581 581
 			return $filename;
582
-		}	 else {
583
-			EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ );
582
+		} else {
583
+			EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
584 584
 		}
585 585
 		return false;
586 586
 	}
@@ -593,12 +593,12 @@  discard block
 block discarded – undo
593 593
 	 *	@param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all
594 594
 	 *	@return array on success, FALSE on fail
595 595
 	 */
596
-	private function _get_export_data_for_models( $models_to_export = array() ) {
596
+	private function _get_export_data_for_models($models_to_export = array()) {
597 597
 		$table_data = FALSE;
598
-		if ( is_array( $models_to_export ) ) {
599
-			foreach ( $models_to_export as $model_name => $query_params ) {
598
+		if (is_array($models_to_export)) {
599
+			foreach ($models_to_export as $model_name => $query_params) {
600 600
 				//check for a numerically-indexed array. in that case, $model_name is the value!!
601
-				if(is_int($model_name)){
601
+				if (is_int($model_name)) {
602 602
 					$model_name = $query_params;
603 603
 					$query_params = array();
604 604
 				}
@@ -606,17 +606,17 @@  discard block
 block discarded – undo
606 606
 				$model_objects = $model->get_all($query_params);
607 607
 
608 608
 				$table_data[$model_name] = array();
609
-				foreach($model_objects as $model_object){
609
+				foreach ($model_objects as $model_object) {
610 610
 					$model_data_array = array();
611 611
 					$fields = $model->field_settings();
612
-					foreach($fields as $field){
612
+					foreach ($fields as $field) {
613 613
 						$column_name = $field->get_nicename()."[".$field->get_name()."]";
614
-						if($field instanceof EE_Datetime_Field){
614
+						if ($field instanceof EE_Datetime_Field) {
615 615
 //							$field->set_date_format('Y-m-d');
616 616
 //							$field->set_time_format('H:i:s');
617
-							$model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s');
617
+							$model_data_array[$column_name] = $model_object->get_datetime($field->get_name(), 'Y-m-d', 'H:i:s');
618 618
 						}
619
-						else{
619
+						else {
620 620
 							$model_data_array[$column_name] = $model_object->get($field->get_name());
621 621
 						}
622 622
 					}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 //(all other times it gets resurrected from a wordpress option)
14 14
 $stages = glob(EE_CORE.'data_migration_scripts/4_8_0_stages/*');
15 15
 $class_to_filepath = array();
16
-foreach($stages as $filepath){
16
+foreach ($stages as $filepath) {
17 17
 	$matches = array();
18
-	preg_match('~4_8_0_stages/(.*).dmsstage.php~',$filepath,$matches);
18
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19 19
 	$class_to_filepath[$matches[1]] = $filepath;
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages',$class_to_filepath);
22
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
23 23
 EEH_Autoloader::register_autoloader($class_to_filepath);
24 24
 
25 25
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  * @since                4.6.0
36 36
  *
37 37
  */
38
-class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base{
38
+class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base {
39 39
 
40 40
 	/**
41 41
 	 * return EE_DMS_Core_4_8_0
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function can_migrate_from_version($version_array) {
64 64
 		$version_string = $version_array['Core'];
65
-		if( $version_string <= '4.8.0' && $version_string >= '4.7.0' ){
65
+		if ($version_string <= '4.8.0' && $version_string >= '4.7.0') {
66 66
 //			echo "$version_string can be migrated from";
67 67
 			return true;
68
-		}elseif( ! $version_string ){
68
+		}elseif ( ! $version_string) {
69 69
 //			echo "no version string provided: $version_string";
70 70
 			//no version string provided... this must be pre 4.3
71
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
72
-		}else{
71
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
72
+		} else {
73 73
 //			echo "$version_string doesnt apply";
74 74
 			return false;
75 75
 		}
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
 	 * @return bool
91 91
 	 */
92 92
 	public function schema_changes_before_migration() {
93
-		$now_in_mysql = current_time( 'mysql', true );
93
+		$now_in_mysql = current_time('mysql', true);
94 94
 
95
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
96
-		$table_name='esp_answer';
97
-		$sql=" ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
95
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
96
+		$table_name = 'esp_answer';
97
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 98
 					REG_ID int(10) unsigned NOT NULL,
99 99
 					QST_ID int(10) unsigned NOT NULL,
100 100
 					ANS_value text NOT NULL,
101 101
 					PRIMARY KEY  (ANS_ID),
102 102
 					KEY REG_ID (REG_ID),
103 103
 					KEY QST_ID (QST_ID)";
104
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
104
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
105 105
 
106 106
 		$table_name = 'esp_attendee_meta';
107 107
 		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 					  CNT_is_EU tinyint(1) DEFAULT '0',
142 142
 					  CNT_active tinyint(1) DEFAULT '0',
143 143
 					  PRIMARY KEY  (CNT_ISO)";
144
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
144
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
145 145
 
146 146
 		$table_name = 'esp_currency';
147 147
 		$sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 				CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2',
152 152
 				CUR_active tinyint(1) DEFAULT '0',
153 153
 				PRIMARY KEY  (CUR_code)";
154
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
154
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
155 155
 
156 156
 
157 157
 		$table_name = 'esp_currency_payment_method';
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 						KEY EVT_ID (EVT_ID),
182 182
 						KEY DTT_is_primary (DTT_is_primary)";
183 183
 
184
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
184
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185 185
 
186 186
 		$table_name = 'esp_event_meta';
187 187
 		$sql = "
@@ -200,41 +200,41 @@  discard block
 block discarded – undo
200 200
 			EVT_donations tinyint(1) NULL,
201 201
 			PRIMARY KEY  (EVTM_ID),
202 202
 			KEY EVT_ID (EVT_ID)";
203
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
203
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
204 204
 
205 205
 
206 206
 
207
-		$table_name='esp_event_question_group';
208
-		$sql="EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
207
+		$table_name = 'esp_event_question_group';
208
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
209 209
 					EVT_ID bigint(20) unsigned NOT NULL,
210 210
 					QSG_ID int(10) unsigned NOT NULL,
211 211
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
212 212
 					PRIMARY KEY  (EQG_ID),
213 213
 					KEY EVT_ID (EVT_ID),
214 214
 					KEY QSG_ID (QSG_ID)";
215
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
215
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216 216
 
217 217
 
218 218
 
219
-		$table_name='esp_event_venue';
220
-		$sql="EVV_ID int(11) NOT NULL AUTO_INCREMENT,
219
+		$table_name = 'esp_event_venue';
220
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
221 221
 				EVT_ID bigint(20) unsigned NOT NULL,
222 222
 				VNU_ID bigint(20) unsigned NOT NULL,
223 223
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
224 224
 				PRIMARY KEY  (EVV_ID)";
225
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
225
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
226 226
 
227 227
 
228 228
 
229
-		$table_name='esp_extra_meta';
230
-		$sql="EXM_ID int(11) NOT NULL AUTO_INCREMENT,
229
+		$table_name = 'esp_extra_meta';
230
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
231 231
 				OBJ_ID int(11) DEFAULT NULL,
232 232
 				EXM_type varchar(45) DEFAULT NULL,
233 233
 				EXM_key varchar(45) DEFAULT NULL,
234 234
 				EXM_value text,
235 235
 				PRIMARY KEY  (EXM_ID),
236 236
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
237
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
237
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238 238
 
239 239
 		$table_name = 'esp_extra_join';
240 240
 		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
248 248
 		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
249 249
 
250
-		$table_name='esp_line_item';
251
-		$sql="LIN_ID int(11) NOT NULL AUTO_INCREMENT,
250
+		$table_name = 'esp_line_item';
251
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
252 252
 				LIN_code varchar(245) NOT NULL DEFAULT '',
253 253
 				TXN_ID int(11) DEFAULT NULL,
254 254
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 				PRIMARY KEY  (LIN_ID),
268 268
 				KEY LIN_code (LIN_code(191)),
269 269
 				KEY TXN_ID (TXN_ID)";
270
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
270
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
271 271
 
272 272
 		$table_name = 'esp_log';
273 273
 		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
307 307
 					PRIMARY KEY  (GRP_ID),
308 308
 					KEY MTP_user_id (MTP_user_id)";
309
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
309
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
310 310
 
311 311
 		$table_name = 'esp_event_message_template';
312 312
 		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 					PRIMARY KEY  (EMT_ID),
316 316
 					KEY EVT_ID (EVT_ID),
317 317
 					KEY GRP_ID (GRP_ID)";
318
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
318
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
319 319
 
320 320
 
321 321
 		$table_name = 'esp_payment';
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 					  PRIMARY KEY  (TTM_ID)";
389 389
 		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
390 390
 
391
-		$table_name='esp_question';
392
-		$sql='QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
391
+		$table_name = 'esp_question';
392
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
393 393
 					QST_display_text text NOT NULL,
394 394
 					QST_admin_label varchar(255) NOT NULL,
395 395
 					QST_system varchar(25) DEFAULT NULL,
@@ -403,22 +403,22 @@  discard block
 block discarded – undo
403 403
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
404 404
 					PRIMARY KEY  (QST_ID),
405 405
 					KEY QST_order (QST_order)';
406
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
406
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
407 407
 
408
-		$table_name='esp_question_group_question';
409
-		$sql="QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
408
+		$table_name = 'esp_question_group_question';
409
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
410 410
 					QSG_ID int(10) unsigned NOT NULL,
411 411
 					QST_ID int(10) unsigned NOT NULL,
412 412
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
413 413
 					PRIMARY KEY  (QGQ_ID),
414 414
 					KEY QST_ID (QST_ID),
415 415
 					KEY QSG_ID_order (QSG_ID,QGQ_order)";
416
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
416
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417 417
 
418 418
 
419 419
 
420
-		$table_name='esp_question_option';
421
-		$sql="QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
420
+		$table_name = 'esp_question_option';
421
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
422 422
 					QSO_value varchar(255) NOT NULL,
423 423
 					QSO_desc text NOT NULL,
424 424
 					QST_ID int(10) unsigned NOT NULL,
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 					PRIMARY KEY  (QSO_ID),
429 429
 					KEY QST_ID (QST_ID),
430 430
 					KEY QSO_order (QSO_order)";
431
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
431
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
432 432
 
433 433
 
434 434
 
@@ -474,8 +474,8 @@  discard block
 block discarded – undo
474 474
 
475 475
 
476 476
 
477
-		$table_name='esp_checkin';
478
-		$sql="CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
477
+		$table_name = 'esp_checkin';
478
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
479 479
 					REG_ID int(10) unsigned NOT NULL,
480 480
 					DTT_ID int(10) unsigned NOT NULL,
481 481
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 					  PRC_parent int(10) unsigned DEFAULT 0,
571 571
 					  PRIMARY KEY  (PRC_ID),
572 572
 					  KEY PRT_ID (PRT_ID)";
573
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
573
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
574 574
 
575 575
 		$table_name = "esp_price_type";
576 576
 		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
@@ -608,10 +608,10 @@  discard block
 block discarded – undo
608 608
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
609 609
 					  PRIMARY KEY  (TKT_ID),
610 610
 					  KEY TKT_start_date (TKT_start_date)";
611
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
611
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
612 612
 
613 613
 		$table_name = 'esp_question_group';
614
-		$sql='QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
614
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
615 615
 					QSG_name varchar(255) NOT NULL,
616 616
 					QSG_identifier varchar(100) NOT NULL,
617 617
 					QSG_desc text NULL,
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 					PRIMARY KEY  (QSG_ID),
625 625
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
626 626
 					KEY QSG_order (QSG_order)';
627
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
627
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
628 628
 
629 629
 		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
630 630
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 		return $script_4_7_defaults->schema_changes_after_migration();
661 661
 	}
662 662
 
663
-	public function migration_page_hooks(){
663
+	public function migration_page_hooks() {
664 664
 
665 665
 	}
666 666
 	
@@ -674,19 +674,19 @@  discard block
 block discarded – undo
674 674
 		//CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
675 675
 		//('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
676 676
 		$newer_countries = array(
677
-			array( 'AX', 'ALA', 0, 'Alan Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0 ),
678
-			array( 'BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0 ),
679
-			array( 'CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0 ),
680
-			array( 'GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0 ),
681
-			array( 'IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2,  '+44', 0, 0  ),
682
-			array( 'JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0 ),
683
-			array( 'MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0 ),
684
-			array( 'MN', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1,  2, '+382', 0, 0 ),
685
-			array( 'RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+941', 1, 0 ),
686
-			array( 'SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0 ),
687
-			array( 'SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0 ),
688
-			array( 'XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+381', 0, 0 ),
689
-			array( 'YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0 ),
677
+			array('AX', 'ALA', 0, 'Alan Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
678
+			array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
679
+			array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
680
+			array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
681
+			array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
682
+			array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
683
+			array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
684
+			array('MN', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
685
+			array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+941', 1, 0),
686
+			array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
687
+			array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
688
+			array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+381', 0, 0),
689
+			array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
690 690
 		);
691 691
 		global $wpdb;
692 692
 		$country_table = $wpdb->prefix."esp_country";
@@ -705,14 +705,14 @@  discard block
 block discarded – undo
705 705
 							"CNT_is_EU" => '%d',
706 706
 							"CNT_active" => '%d',
707 707
 						);
708
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $country_table . "'") == $country_table ) {
709
-			foreach( $newer_countries as $country ) {
710
-				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1" ;
708
+		if ($wpdb->get_var("SHOW TABLES LIKE '".$country_table."'") == $country_table) {
709
+			foreach ($newer_countries as $country) {
710
+				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
711 711
 				$countries = $wpdb->get_var($SQL);
712
-				if ( ! $countries ) {
712
+				if ( ! $countries) {
713 713
 
714
-					$wpdb->insert( $country_table,
715
-							array_combine( array_keys( $country_format), $country ),
714
+					$wpdb->insert($country_table,
715
+							array_combine(array_keys($country_format), $country),
716 716
 							$country_format
717 717
 							);
718 718
 				}
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 		// CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
731 731
 		//( 'EUR',  'Euro',  'Euros',  '€',  2,1),
732 732
 		$newer_currencies = array(
733
-			array( 'RSD', 'Dinar', 'Dinars', '', 3, 1 ),
733
+			array('RSD', 'Dinar', 'Dinars', '', 3, 1),
734 734
 		);
735 735
 		global $wpdb;
736 736
 		$currency_table = $wpdb->prefix."esp_currency";
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
 							"CUR_dec_plc" => '%d',
743 743
 							"CUR_active" => '%d',
744 744
 						);
745
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $currency_table . "'") == $currency_table ) {
746
-			foreach( $newer_currencies as $currency ) {
747
-				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1" ;
745
+		if ($wpdb->get_var("SHOW TABLES LIKE '".$currency_table."'") == $currency_table) {
746
+			foreach ($newer_currencies as $currency) {
747
+				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
748 748
 				$countries = $wpdb->get_var($SQL);
749
-				if ( ! $countries ) {
749
+				if ( ! $countries) {
750 750
 
751
-					$wpdb->insert( $currency_table,
752
-							array_combine( array_keys( $currency_format), $currency ),
751
+					$wpdb->insert($currency_table,
752
+							array_combine(array_keys($currency_format), $currency),
753 753
 							$currency_format
754 754
 							);
755 755
 				}
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
 	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
762 762
 	 * we should be able to stop doing this in 4.9
763 763
 	 */
764
-	public function fix_non_default_taxes(){
764
+	public function fix_non_default_taxes() {
765 765
 		global $wpdb;
766
-		$query = $wpdb->prepare( "UPDATE
766
+		$query = $wpdb->prepare("UPDATE
767 767
 				{$wpdb->prefix}esp_price p INNER JOIN
768 768
 				{$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID
769 769
 			SET
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
 			WHERE
772 772
 				p.PRC_is_default = 0 AND
773 773
 				pt.PBT_ID = %d
774
-					", EEM_Price_Type::base_type_tax );
775
-		$wpdb->query( $query );
774
+					", EEM_Price_Type::base_type_tax);
775
+		$wpdb->query($query);
776 776
 	}
777 777
 }
778 778
 
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/AttendeesReport.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use EventEspressoBatchRequest\Helpers\JobParameters;
19 19
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
20 20
 
21
-if (!defined('EVENT_ESPRESSO_VERSION')) {
21
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
22 22
 	exit('No direct script access allowed');
23 23
 }
24 24
 
@@ -27,86 +27,86 @@  discard block
 block discarded – undo
27 27
 	
28 28
 	
29 29
 	public function create_job(JobParameters $job_parameters) {
30
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) {
30
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) {
31 31
 			throw new BatchRequestException(
32
-				__( 'You do not have permission to view contacts', 'event_espresso')
32
+				__('You do not have permission to view contacts', 'event_espresso')
33 33
 			);
34 34
 		}
35 35
 		$filepath = $this->create_file_from_job_with_name(
36 36
 			$job_parameters->job_id(),
37 37
 			__('contact-list-report.csv', 'event_espresso')
38 38
 		);
39
-		$job_parameters->add_extra_data( 'filepath', $filepath );
40
-		$job_parameters->set_job_size( $this->count_units_to_process() );
39
+		$job_parameters->add_extra_data('filepath', $filepath);
40
+		$job_parameters->set_job_size($this->count_units_to_process());
41 41
 		//we should also set the header columns
42
-		$csv_data_for_row = $this->get_csv_data( 0, 1 );
43
-		\EE_Registry::instance()->load_helper( 'Export' );
44
-		\EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true );
42
+		$csv_data_for_row = $this->get_csv_data(0, 1);
43
+		\EE_Registry::instance()->load_helper('Export');
44
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
45 45
 		//if we actually processed a row there, record it
46
-		if( $job_parameters->job_size() ) {
47
-			$job_parameters->mark_processed( 1 );
46
+		if ($job_parameters->job_size()) {
47
+			$job_parameters->mark_processed(1);
48 48
 		}
49 49
 		return new JobStepResponse(
50 50
 			$job_parameters,
51
-			__( 'Contacts report started successfully...', 'event_espresso' )
51
+			__('Contacts report started successfully...', 'event_espresso')
52 52
 		);
53 53
 	}
54 54
 	
55 55
 
56 56
 	public function continue_job(JobParameters $job_parameters, $batch_size = 50) {
57
-		$csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size );
58
-		\EE_Registry::instance()->load_helper( 'Export' );
59
-		\EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false );
60
-		$units_processed = count( $csv_data );
61
-		$job_parameters->mark_processed( $units_processed );
57
+		$csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size);
58
+		\EE_Registry::instance()->load_helper('Export');
59
+		\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
60
+		$units_processed = count($csv_data);
61
+		$job_parameters->mark_processed($units_processed);
62 62
 		$extra_response_data = array(
63 63
 			'file_url' => ''
64 64
 		);
65
-		if( $units_processed < $batch_size ) {
66
-			$job_parameters->set_status( JobParameters::status_complete );
67
-			$extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) );
65
+		if ($units_processed < $batch_size) {
66
+			$job_parameters->set_status(JobParameters::status_complete);
67
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
68 68
 		}
69 69
 		return new JobStepResponse(
70 70
 				$job_parameters,
71 71
 				sprintf(
72
-					__( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ),
73
-					count( $csv_data ) ),
72
+					__('Wrote %1$s rows to report CSV file...', 'event_espresso'),
73
+					count($csv_data) ),
74 74
 				$extra_response_data );
75 75
 	}
76 76
 
77 77
 	
78 78
 	public function cleanup_job(JobParameters $job_parameters) {
79 79
 		$this->_file_helper->delete(
80
-			\EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ),
80
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
81 81
 			true,
82 82
 			'd'
83 83
 		);
84
-		return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) );
84
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
85 85
 	}
86 86
 	
87 87
 	public function count_units_to_process() {
88
-		return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin ));
88
+		return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin));
89 89
 	}
90
-	public function get_csv_data( $offset, $limit ) {
90
+	public function get_csv_data($offset, $limit) {
91 91
 		$attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( 
92 92
 			array( 
93
-				'limit' => array( $offset, $limit ),
94
-				'force_join' => array( 'State', 'Country' ),
93
+				'limit' => array($offset, $limit),
94
+				'force_join' => array('State', 'Country'),
95 95
 				'caps' => \EEM_Base::caps_read_admin
96 96
 			) 
97 97
 		);
98 98
 		$csv_data = array();
99
-		foreach( $attendee_rows as $attendee_row ){
99
+		foreach ($attendee_rows as $attendee_row) {
100 100
 			$csv_row = array();
101
-			foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){
102
-				if( $field_name == 'STA_ID' ){
103
-					$state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' );
104
-					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
105
-				}elseif( $field_name == 'CNT_ISO' ){
106
-					$country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' );
107
-					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
108
-				}else{
109
-					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
101
+			foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
102
+				if ($field_name == 'STA_ID') {
103
+					$state_name_field = \EEM_State::instance()->field_settings_for('STA_name');
104
+					$csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()];
105
+				}elseif ($field_name == 'CNT_ISO') {
106
+					$country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name');
107
+					$csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()];
108
+				} else {
109
+					$csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()];
110 110
 				}
111 111
 			}
112 112
 			$csv_data[] = $csv_row;
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 use EventEspressoBatchRequest\Helpers\JobParameters;
20 20
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
21 21
 
22
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
23
-	exit( 'No direct script access allowed' );
22
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
23
+	exit('No direct script access allowed');
24 24
 }
25 25
 
26 26
 
@@ -35,36 +35,36 @@  discard block
 block discarded – undo
35 35
 	 * @throws BatchRequestException
36 36
 	 * @return JobStepResponse
37 37
 	 */
38
-	public function create_job( JobParameters $job_parameters ) {
39
-		$event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) );
40
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) {
38
+	public function create_job(JobParameters $job_parameters) {
39
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41 41
 			throw new BatchRequestException(
42
-				__( 'You do not have permission to view registrations', 'event_espresso')
42
+				__('You do not have permission to view registrations', 'event_espresso')
43 43
 			);
44 44
 		}
45 45
 		$filepath = $this->create_file_from_job_with_name(
46 46
 			$job_parameters->job_id(),
47
-			$this->get_filename_from_event( $event_id )
47
+			$this->get_filename_from_event($event_id)
48 48
 		);
49
-		$job_parameters->add_extra_data( 'filepath', $filepath );
50
-		$question_data_for_columns = $this->_get_questions_for_report( $event_id );
51
-		$job_parameters->add_extra_data( 'questions_data', $question_data_for_columns );
52
-		$job_parameters->set_job_size( $this->count_units_to_process( $event_id ) );
49
+		$job_parameters->add_extra_data('filepath', $filepath);
50
+		$question_data_for_columns = $this->_get_questions_for_report($event_id);
51
+		$job_parameters->add_extra_data('questions_data', $question_data_for_columns);
52
+		$job_parameters->set_job_size($this->count_units_to_process($event_id));
53 53
 		//we should also set the header columns
54 54
 		$csv_data_for_row = $this->get_csv_data_for(
55 55
 			$event_id,
56 56
 			0,
57 57
 			1,
58
-			$job_parameters->extra_datum( 'questions_data' ) );
59
-		\EE_Registry::instance()->load_helper( 'Export' );
60
-		\EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true );
58
+			$job_parameters->extra_datum('questions_data') );
59
+		\EE_Registry::instance()->load_helper('Export');
60
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
61 61
 		//if we actually processed a row there, record it
62
-		if( $job_parameters->job_size() ) {
63
-			$job_parameters->mark_processed( 1 );
62
+		if ($job_parameters->job_size()) {
63
+			$job_parameters->mark_processed(1);
64 64
 		}
65 65
 		return new JobStepResponse(
66 66
 			$job_parameters,
67
-			__( 'Registrations report started successfully...', 'event_espresso' )
67
+			__('Registrations report started successfully...', 'event_espresso')
68 68
 		);
69 69
 	}
70 70
 
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 	 * @param int $event_id
76 76
 	 * @return string
77 77
 	 */
78
-	protected function get_filename_from_event( $event_id ) {
79
-		if( $event_id ){
80
-			$event_slug =  \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' );
81
-			if( ! $event_slug ) {
82
-				$event_slug = __( 'unknown', 'event_espresso' );
78
+	protected function get_filename_from_event($event_id) {
79
+		if ($event_id) {
80
+			$event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
81
+			if ( ! $event_slug) {
82
+				$event_slug = __('unknown', 'event_espresso');
83 83
 			}
84
-		}else{
85
-			$event_slug = __( 'all', 'event_espresso' );
84
+		} else {
85
+			$event_slug = __('all', 'event_espresso');
86 86
 		}
87
-		return sprintf( "registrations-for-%s.csv", $event_slug );
87
+		return sprintf("registrations-for-%s.csv", $event_slug);
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * @param int|null $event_id
94 94
 	 * @return array of wpdb results for questions which are to be used for this report
95 95
 	 */
96
-	protected function _get_questions_for_report( $event_id ) {
96
+	protected function _get_questions_for_report($event_id) {
97 97
 		$question_query_params = array(
98 98
 			array(
99
-				'Answer.ANS_ID' => array( 'IS_NOT_NULL' ),
99
+				'Answer.ANS_ID' => array('IS_NOT_NULL'),
100 100
 			),
101
-			'group_by' => array( 'QST_ID' )
101
+			'group_by' => array('QST_ID')
102 102
 		);
103
-		if( $event_id ) {
103
+		if ($event_id) {
104 104
 			$question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id;
105 105
 		}
106
-		return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params );
106
+		return \EEM_Question::instance()->get_all_wpdb_results($question_query_params);
107 107
 	}
108 108
 
109 109
 
@@ -116,28 +116,28 @@  discard block
 block discarded – undo
116 116
 	 * @return JobStepResponse
117 117
 	 * @throws \EE_Error
118 118
 	 */
119
-	public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) {
119
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50) {
120 120
 		$csv_data = $this->get_csv_data_for(
121
-			$job_parameters->request_datum( 'EVT_ID', '0'),
121
+			$job_parameters->request_datum('EVT_ID', '0'),
122 122
 			$job_parameters->units_processed(),
123 123
 			$batch_size,
124
-			$job_parameters->extra_datum( 'questions_data' ) );
125
-		\EE_Registry::instance()->load_helper( 'Export' );
126
-		\EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false );
127
-		$units_processed = count( $csv_data );
128
-		$job_parameters->mark_processed( $units_processed );
124
+			$job_parameters->extra_datum('questions_data') );
125
+		\EE_Registry::instance()->load_helper('Export');
126
+		\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
127
+		$units_processed = count($csv_data);
128
+		$job_parameters->mark_processed($units_processed);
129 129
 		$extra_response_data = array(
130 130
 			'file_url' => ''
131 131
 		);
132
-		if( $units_processed < $batch_size ) {
133
-			$job_parameters->set_status( JobParameters::status_complete );
134
-			$extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) );
132
+		if ($units_processed < $batch_size) {
133
+			$job_parameters->set_status(JobParameters::status_complete);
134
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
135 135
 		}
136 136
 		return new JobStepResponse(
137 137
 				$job_parameters,
138 138
 				sprintf(
139
-					__( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ),
140
-					count( $csv_data ) ),
139
+					__('Wrote %1$s rows to report CSV file...', 'event_espresso'),
140
+					count($csv_data) ),
141 141
 				$extra_response_data );
142 142
 	}
143 143
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @return array top-level keys are numeric, next-level keys are column headers
151 151
 	 *
152 152
 	 */
153
-	function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) {
154
-		\EE_Registry::instance()->load_helper( 'Export' );
153
+	function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) {
154
+		\EE_Registry::instance()->load_helper('Export');
155 155
 		$reg_fields_to_include = array(
156 156
 			'TXN_ID',
157 157
 			'ATT_ID',
@@ -182,166 +182,166 @@  discard block
 block discarded – undo
182 182
 				array(
183 183
 					'OR' => array(
184 184
 						//don't include registrations from failed or abandoned transactions...
185
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
185
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
186 186
 						//unless the registration is approved, in which case include it regardless of transaction status
187 187
 						'STS_ID' => \EEM_Registration::status_id_approved
188 188
 						),
189
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
189
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
190 190
 					),
191
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
192
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
193
-				'limit' => array( $offset, $limit ),
191
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
192
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
193
+				'limit' => array($offset, $limit),
194 194
 				'caps' => \EEM_Base::caps_read_admin
195 195
 			),
196 196
 			$event_id
197 197
 		);
198
-		if( $event_id ){
199
-			$query_params[0]['EVT_ID'] =  $event_id;
200
-		}else{
201
-			$query_params[ 'force_join' ][] = 'Event';
198
+		if ($event_id) {
199
+			$query_params[0]['EVT_ID'] = $event_id;
200
+		} else {
201
+			$query_params['force_join'][] = 'Event';
202 202
 		}
203
-		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
203
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
204 204
 		//get all questions which relate to someone in this group
205 205
 		$registration_ids = array();
206
-		foreach( $registration_rows as $reg_row ) {
207
-			$registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] );
206
+		foreach ($registration_rows as $reg_row) {
207
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
208 208
 		}
209 209
 
210
-		foreach($registration_rows as $reg_row){
211
-			if ( is_array( $reg_row ) ) {
210
+		foreach ($registration_rows as $reg_row) {
211
+			if (is_array($reg_row)) {
212 212
 				$reg_csv_array = array();
213
-				if( ! $event_id ){
213
+				if ( ! $event_id) {
214 214
 					//get the event's name and Id
215
-					$reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] );
215
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
216 216
 				}
217
-				$is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false;
217
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
218 218
 				/*@var $reg_row EE_Registration */
219
-				foreach($reg_fields_to_include as $field_name){
219
+				foreach ($reg_fields_to_include as $field_name) {
220 220
 					$field = $reg_model->field_settings_for($field_name);
221
-					if($field_name == 'REG_final_price'){
222
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
223
-					}elseif( $field_name == 'REG_count' ){
224
-						$value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
225
-					}elseif( $field_name == 'REG_date' ) {
226
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
227
-					}else{
228
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
221
+					if ($field_name == 'REG_final_price') {
222
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
223
+					}elseif ($field_name == 'REG_count') {
224
+						$value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
225
+					}elseif ($field_name == 'REG_date') {
226
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
227
+					} else {
228
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
229 229
 					}
230 230
 					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
231
-					if($field_name == 'REG_final_price'){
231
+					if ($field_name == 'REG_final_price') {
232 232
 						//add a column named Currency after the final price
233 233
 						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
234 234
 					}
235 235
 				}
236 236
 				//get pretty status
237
-				$stati = \EEM_Status::instance()->localized_status( array(
238
-					$reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ),
239
-					$reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ),
237
+				$stati = \EEM_Status::instance()->localized_status(array(
238
+					$reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'),
239
+					$reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ),
240 240
 						FALSE,
241
-						'sentence' );
242
-				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ];
241
+						'sentence');
242
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
243 243
 				//get pretty transaction status
244
-				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ];
245
-				$reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00';
246
-				$reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00';
244
+				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']];
245
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00';
246
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00';
247 247
 				$payment_methods = array();
248 248
 				$gateway_txn_ids_etc = array();
249 249
 				$payment_times = array();
250
-				if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){
250
+				if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) {
251 251
 					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(
252 252
 							array(
253 253
 								array(
254
-									'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ],
254
+									'TXN_ID' => $reg_row['Transaction.TXN_ID'],
255 255
 									'STS_ID' => \EEM_Payment::status_id_approved
256 256
 								),
257
-								'force_join' => array( 'Payment_Method' ),
257
+								'force_join' => array('Payment_Method'),
258 258
 
259 259
 							),
260 260
 							ARRAY_A,
261 261
 							'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' );
262 262
 
263
-					foreach( $payments_info as $payment_method_and_gateway_txn_id ){
264
-						$payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' );
265
-						$gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : '';
266
-						$payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : '';
263
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
264
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
265
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
266
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
267 267
 					}
268 268
 
269 269
 				}
270
-				$reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times );
271
-				$reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods );
272
-				$reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc );
270
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
271
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
272
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
273 273
 
274 274
 				//get whether or not the user has checked in
275
-				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' );
275
+				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
276 276
 				//get ticket of registration and its price
277 277
 				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
278
-				if( $reg_row[ 'Ticket.TKT_ID'] ) {
279
-					$ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] );
278
+				if ($reg_row['Ticket.TKT_ID']) {
279
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
280 280
 					$datetimes_strings = array();
281
-					foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){
282
-						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] );
281
+					foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
282
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
283 283
 					}
284 284
 
285 285
 				} else {
286
-					$ticket_name = __( 'Unknown', 'event_espresso' );
287
-					$datetimes_strings = array( __( 'Unknown', 'event_espresso' ) );
286
+					$ticket_name = __('Unknown', 'event_espresso');
287
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
288 288
 				}
289 289
 				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
290 290
 				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
291 291
 				//get datetime(s) of registration
292 292
 
293 293
 				//add attendee columns
294
-				foreach($att_fields_to_include as $att_field_name){
294
+				foreach ($att_fields_to_include as $att_field_name) {
295 295
 					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
296
-					if( $reg_row[ 'Attendee_CPT.ID' ]){
297
-						if($att_field_name == 'STA_ID'){
298
-							$value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
299
-						}elseif($att_field_name == 'CNT_ISO'){
300
-							$value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
301
-						}else{
302
-							$value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
296
+					if ($reg_row['Attendee_CPT.ID']) {
297
+						if ($att_field_name == 'STA_ID') {
298
+							$value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
299
+						}elseif ($att_field_name == 'CNT_ISO') {
300
+							$value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
301
+						} else {
302
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
303 303
 						}
304
-					}else{
304
+					} else {
305 305
 						$value = '';
306 306
 					}
307 307
 
308
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value;
308
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
309 309
 				}
310 310
 
311 311
 				//make sure each registration has the same questions in the same order
312
-				foreach($questions_for_these_regs_rows as $question_row){
313
-					if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){
314
-						$reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null;
312
+				foreach ($questions_for_these_regs_rows as $question_row) {
313
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
314
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
315 315
 					}
316 316
 				}
317 317
 				$answers = \EEM_Answer::instance()->get_all_wpdb_results(
318 318
 					array(
319
-						array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ),
320
-						'force_join' => array( 'Question' )
319
+						array('REG_ID' => $reg_row['Registration.REG_ID']),
320
+						'force_join' => array('Question')
321 321
 					)
322 322
 				);
323 323
 				//now fill out the questions THEY answered
324
-				foreach( $answers as $answer_row ){
325
-					if( $answer_row[ 'Question.QST_ID' ] ){
324
+				foreach ($answers as $answer_row) {
325
+					if ($answer_row['Question.QST_ID']) {
326 326
 						$question_label = \EEH_Export::prepare_value_from_db_for_display(
327 327
 							\EEM_Question::instance(),
328 328
 							'QST_admin_label',
329
-							$answer_row[ 'Question.QST_admin_label' ]
329
+							$answer_row['Question.QST_admin_label']
330 330
 						);
331 331
 					} else {
332
-						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
332
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
333 333
 					}
334
-					if ( isset( $answer_row[ 'Question.QST_type' ] )
335
-						 && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state
334
+					if (isset($answer_row['Question.QST_type'])
335
+						 && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
336 336
 					) {
337
-						$reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID(
338
-							$answer_row[ 'Answer.ANS_value' ]
337
+						$reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID(
338
+							$answer_row['Answer.ANS_value']
339 339
 						);
340 340
 					} else {
341
-						$reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display(
341
+						$reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display(
342 342
 							\EEM_Answer::instance(),
343 343
 							'ANS_value',
344
-							$answer_row[ 'Answer.ANS_value' ]
344
+							$answer_row['Answer.ANS_value']
345 345
 						);
346 346
 					}
347 347
 				}
@@ -352,17 +352,17 @@  discard block
 block discarded – undo
352 352
 			}
353 353
 		}
354 354
 		//if we couldn't export anything, we want to at least show the column headers
355
-		if ( empty( $registrations_csv_ready_array ) ) {
355
+		if (empty($registrations_csv_ready_array)) {
356 356
 			$reg_csv_array = array();
357 357
 			$model_and_fields_to_include = array(
358 358
 				'Registration' => $reg_fields_to_include,
359 359
 				'Attendee'     => $att_fields_to_include
360 360
 			);
361
-			foreach ( $model_and_fields_to_include as $model_name => $field_list ) {
362
-				$model = \EE_Registry::instance()->load_model( $model_name );
363
-				foreach ( $field_list as $field_name ) {
364
-					$field = $model->field_settings_for( $field_name );
365
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null;
361
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
362
+				$model = \EE_Registry::instance()->load_model($model_name);
363
+				foreach ($field_list as $field_name) {
364
+					$field = $model->field_settings_for($field_name);
365
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
366 366
 				}
367 367
 			}
368 368
 			$registrations_csv_ready_array[] = $reg_csv_array;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * @param int $event_id
379 379
 	 * @return int
380 380
 	 */
381
-	public function count_units_to_process( $event_id ) {
381
+	public function count_units_to_process($event_id) {
382 382
 		//use the legacy filter
383 383
 		$query_params = apply_filters(
384 384
 			'FHEE__EE_Export__report_registration_for_event',
@@ -386,24 +386,24 @@  discard block
 block discarded – undo
386 386
 				array(
387 387
 					'OR' => array(
388 388
 						//don't include registrations from failed or abandoned transactions...
389
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
389
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
390 390
 						//unless the registration is approved, in which case include it regardless of transaction status
391 391
 						'STS_ID' => \EEM_Registration::status_id_approved
392 392
 						),
393
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
393
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
394 394
 					),
395
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
396
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
395
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
396
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
397 397
 				'caps' => \EEM_Base::caps_read_admin
398 398
 			),
399 399
 			$event_id
400 400
 		);
401
-		if( $event_id ){
402
-			$query_params[0]['EVT_ID'] =  $event_id;
401
+		if ($event_id) {
402
+			$query_params[0]['EVT_ID'] = $event_id;
403 403
 		} else {
404
-			$query_params[ 'force_join' ][] = 'Event';
404
+			$query_params['force_join'][] = 'Event';
405 405
 		}
406
-		return \EEM_Registration::instance()->count( $query_params );
406
+		return \EEM_Registration::instance()->count($query_params);
407 407
 	}
408 408
 
409 409
 
@@ -414,13 +414,13 @@  discard block
 block discarded – undo
414 414
 	 * @param JobParameters $job_parameters
415 415
 	 * @return boolean
416 416
 	 */
417
-	public function cleanup_job( JobParameters $job_parameters ){
417
+	public function cleanup_job(JobParameters $job_parameters) {
418 418
 		$this->_file_helper->delete(
419
-			\EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ),
419
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
420 420
 			true,
421 421
 			'd'
422 422
 		);
423
-		return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) );
423
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
424 424
 	}
425 425
 }
426 426
 
Please login to merge, or discard this patch.