Completed
Branch FET-9413-questions-refactor (7aebbc)
by
unknown
86:30 queued 75:25
created
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 1 patch
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * really, you're best off copying the whole thing when 4.1 is released into this file
21 21
  * and wrapping its declaration in if( ! class_exists()){...}
22 22
  */
23
-class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{
23
+class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base {
24 24
 
25 25
 
26 26
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param TableAnalysis $table_analysis
32 32
 	 * @throws \EE_Error
33 33
 	 */
34
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
34
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
35 35
 		$this->_load_script_stages();
36 36
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso");
37 37
 		$this->_priority = 10;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			new EE_DMS_4_1_0_answers(),
55 55
 			new EE_DMS_4_1_0_checkins(),
56 56
 		);
57
-		parent::__construct( $table_manager, $table_analysis );
57
+		parent::__construct($table_manager, $table_analysis);
58 58
 	}
59 59
 
60 60
 
@@ -65,27 +65,27 @@  discard block
 block discarded – undo
65 65
 	 * @global wpdb $wpdb
66 66
 	 * @return boolean
67 67
 	 */
68
-	private function _checkin_table_exists(){
68
+	private function _checkin_table_exists() {
69 69
 		global $wpdb;
70 70
 		$results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
71
-		if($results){
71
+		if ($results) {
72 72
 			return true;
73
-		}else{
73
+		} else {
74 74
 			return false;
75 75
 		}
76 76
 	}
77 77
 
78 78
 	public function can_migrate_from_version($version_array) {
79 79
 		$version_string = $version_array['Core'];
80
-		if($version_string < '4.0.0' && $version_string > '3.1.26' ){
80
+		if ($version_string < '4.0.0' && $version_string > '3.1.26') {
81 81
 //			echo "$version_string can be migrated fro";
82 82
 			return true;
83
-		}elseif( ! $version_string ){
83
+		}elseif ( ! $version_string) {
84 84
 //			echo "no version string provided: $version_string";
85 85
 			//no version string provided... this must be pre 4.1
86 86
 			//because since 4.1 we're
87
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
88
-		}else{
87
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
88
+		} else {
89 89
 //			echo "$version_string doesnt apply";
90 90
 			return false;
91 91
 		}
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 	public function schema_changes_before_migration() {
97 97
 		//relies on 4.1's EEH_Activation::create_table
98
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
98
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
99 99
 
100
-		$table_name='esp_answer';
101
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
100
+		$table_name = 'esp_answer';
101
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
102 102
 					REG_ID INT UNSIGNED NOT NULL,
103 103
 					QST_ID INT UNSIGNED NOT NULL,
104 104
 					ANS_value TEXT NOT NULL,
105 105
 					PRIMARY KEY  (ANS_ID)";
106
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
106
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
107 107
 
108 108
 		$table_name = 'esp_attendee_meta';
109 109
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
144 144
 					  CNT_active TINYINT(1) DEFAULT '0',
145 145
 					  PRIMARY KEY  (CNT_ISO)";
146
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
146
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
147 147
 
148 148
 
149 149
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 
166 166
 
167
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
167
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
168 168
 		$table_name = 'esp_event_meta';
169 169
 		$sql = "
170 170
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -181,41 +181,41 @@  discard block
 block discarded – undo
181 181
 			EVT_external_URL VARCHAR(200) NULL,
182 182
 			EVT_donations TINYINT(1) NULL,
183 183
 			PRIMARY KEY  (EVTM_ID)";
184
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
184
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185 185
 
186 186
 
187 187
 
188
-		$table_name='esp_event_question_group';
189
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
188
+		$table_name = 'esp_event_question_group';
189
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
190 190
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
191 191
 					QSG_ID INT UNSIGNED NOT NULL,
192 192
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
193 193
 					PRIMARY KEY  (EQG_ID)";
194
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
194
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
195 195
 
196 196
 
197 197
 
198
-		$table_name='esp_event_venue';
199
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
198
+		$table_name = 'esp_event_venue';
199
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
200 200
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
201 201
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
202 202
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
203 203
 				PRIMARY KEY  (EVV_ID)";
204
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
204
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205 205
 
206 206
 
207 207
 
208
-		$table_name='esp_extra_meta';
209
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
208
+		$table_name = 'esp_extra_meta';
209
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
210 210
 				OBJ_ID INT(11) DEFAULT NULL,
211 211
 				EXM_type VARCHAR(45) DEFAULT NULL,
212 212
 				EXM_key VARCHAR(45) DEFAULT NULL,
213 213
 				EXM_value TEXT,
214 214
 				PRIMARY KEY  (EXM_ID)";
215
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
215
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216 216
 
217
-		$table_name='esp_line_item';
218
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
217
+		$table_name = 'esp_line_item';
218
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
219 219
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
220 220
 				TXN_ID INT(11) DEFAULT NULL,
221 221
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 				OBJ_ID INT(11) DEFAULT NULL,
232 232
 				OBJ_type VARCHAR(45)DEFAULT NULL,
233 233
 				PRIMARY KEY  (LIN_ID)";
234
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
234
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
235 235
 
236 236
 		$table_name = 'esp_message_template';
237 237
 		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 					PRIMARY KEY  (GRP_ID),
259 259
 					KEY EVT_ID (EVT_ID),
260 260
 					KEY MTP_user_id (MTP_user_id)";
261
-		$this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB');
261
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
262 262
 
263 263
 
264 264
 
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 
367 367
 
368 368
 
369
-		$table_name='esp_question';
370
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
369
+		$table_name = 'esp_question';
370
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
371 371
 					QST_display_text TEXT NOT NULL,
372 372
 					QST_admin_label VARCHAR(255) NOT NULL,
373 373
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
 					QST_wp_user BIGINT UNSIGNED NULL,
380 380
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
381 381
 					PRIMARY KEY  (QST_ID)';
382
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
382
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
383 383
 
384
-		$this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' );
384
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
385 385
 
386 386
 		$table_name = 'esp_question_group';
387
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
387
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
388 388
 					QSG_name VARCHAR(255) NOT NULL,
389 389
 					QSG_identifier VARCHAR(100) NOT NULL,
390 390
 					QSG_desc TEXT NULL,
@@ -395,27 +395,27 @@  discard block
 block discarded – undo
395 395
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
396 396
 					PRIMARY KEY  (QSG_ID),
397 397
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
398
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
398
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
399 399
 
400 400
 
401 401
 
402
-		$table_name='esp_question_group_question';
403
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
402
+		$table_name = 'esp_question_group_question';
403
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
404 404
 					QSG_ID INT UNSIGNED NOT NULL,
405 405
 					QST_ID INT UNSIGNED NOT NULL,
406 406
 					PRIMARY KEY  (QGQ_ID) ";
407
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
407
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
408 408
 
409 409
 
410 410
 
411
-		$table_name='esp_question_option';
412
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
411
+		$table_name = 'esp_question_option';
412
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
413 413
 					QSO_value VARCHAR(255) NOT NULL,
414 414
 					QSO_desc TEXT NOT NULL,
415 415
 					QST_ID INT UNSIGNED NOT NULL,
416 416
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
417 417
 					PRIMARY KEY  (QSO_ID)";
418
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
418
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
419 419
 
420 420
 
421 421
 
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 
449 449
 
450 450
 
451
-		$table_name='esp_checkin';
452
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
451
+		$table_name = 'esp_checkin';
452
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
453 453
 					REG_ID INT(10) UNSIGNED NOT NULL,
454 454
 					DTT_ID INT(10) UNSIGNED NOT NULL,
455 455
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
 
557 557
 		global $wpdb;
558 558
 		$state_table = $wpdb->prefix."esp_state";
559
-		if ( $this->_get_table_analysis()->tableExists( $state_table ) ) {
559
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
560 560
 
561
-			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
561
+			$SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
562 562
 			$states = $wpdb->get_var($SQL);
563
-			if ( ! $states ) {
564
-				$SQL = "INSERT INTO " . $state_table . "
563
+			if ( ! $states) {
564
+				$SQL = "INSERT INTO ".$state_table."
565 565
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
566 566
 				(1, 'US', 'AK', 'Alaska', 1),
567 567
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
 
649 649
 		global $wpdb;
650 650
 		$country_table = $wpdb->prefix."esp_country";
651
-		if ( $this->_get_table_analysis()->tableExists( $country_table ) ) {
651
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
652 652
 
653
-			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
653
+			$SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
654 654
 			$countries = $wpdb->get_var($SQL);
655
-			if ( ! $countries ) {
656
-				$SQL = "INSERT INTO " . $country_table . "
655
+			if ( ! $countries) {
656
+				$SQL = "INSERT INTO ".$country_table."
657 657
 				(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) VALUES
658 658
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
659 659
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -900,20 +900,20 @@  discard block
 block discarded – undo
900 900
 		global $wpdb;
901 901
 		$price_type_table = $wpdb->prefix."esp_price_type";
902 902
 
903
-		if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) {
903
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
904 904
 
905
-			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
906
-			$price_types_exist = $wpdb->get_var( $SQL );
905
+			$SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
906
+			$price_types_exist = $wpdb->get_var($SQL);
907 907
 
908
-			if ( ! $price_types_exist ) {
908
+			if ( ! $price_types_exist) {
909 909
 				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
910
-							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
911
-							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
912
-							(3, '" . __('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
913
-							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
914
-							(5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
915
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL );
916
-				$wpdb->query( $SQL );
910
+							(1, '".__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
911
+							(2, '" . __('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
912
+							(3, '" . __('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
913
+							(4, '" . __('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
914
+							(5, '" . __('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
915
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
916
+				$wpdb->query($SQL);
917 917
 			}
918 918
 		}
919 919
 	}
@@ -933,16 +933,16 @@  discard block
 block discarded – undo
933 933
 		global $wpdb;
934 934
 		$price_table = $wpdb->prefix."esp_price";
935 935
 
936
-		if ( $this->_get_table_analysis()->tableExists(  $price_table ) ) {
936
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
937 937
 
938
-			$SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table;
939
-			$prices_exist = $wpdb->get_var( $SQL );
938
+			$SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
939
+			$prices_exist = $wpdb->get_var($SQL);
940 940
 
941
-			if ( ! $prices_exist ) {
941
+			if ( ! $prices_exist) {
942 942
 				$SQL = "INSERT INTO $price_table
943 943
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
944 944
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);";
945
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL );
945
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
946 946
 				$wpdb->query($SQL);
947 947
 			}
948 948
 		}
@@ -959,34 +959,34 @@  discard block
 block discarded – undo
959 959
 
960 960
 		global $wpdb;
961 961
 		$ticket_table = $wpdb->prefix."esp_ticket";
962
-		if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) {
962
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
963 963
 
964
-			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
964
+			$SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
965 965
 			$tickets_exist = $wpdb->get_var($SQL);
966 966
 
967
-			if ( ! $tickets_exist ) {
967
+			if ( ! $tickets_exist) {
968 968
 				$SQL = "INSERT INTO $ticket_table
969 969
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
970
-					( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
971
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL );
970
+					( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
971
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
972 972
 				$wpdb->query($SQL);
973 973
 			}
974 974
 		}
975 975
 		$ticket_price_table = $wpdb->prefix."esp_ticket_price";
976 976
 
977
-		if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) {
977
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
978 978
 
979
-			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
979
+			$SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
980 980
 			$ticket_prc_exist = $wpdb->get_var($SQL);
981 981
 
982
-			if ( ! $ticket_prc_exist ) {
982
+			if ( ! $ticket_prc_exist) {
983 983
 
984 984
 				$SQL = "INSERT INTO $ticket_price_table
985 985
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
986 986
 				( 1, 1, 1 )
987 987
 				";
988 988
 
989
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL );
989
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
990 990
 				$wpdb->query($SQL);
991 991
 			}
992 992
 		}
@@ -999,20 +999,20 @@  discard block
 block discarded – undo
999 999
 	 * @param string $country_name
1000 1000
 	 * @return array where keys are columns, values are column values
1001 1001
 	 */
1002
-	public function get_or_create_country($country_name){
1003
-		if( ! $country_name ){
1002
+	public function get_or_create_country($country_name) {
1003
+		if ( ! $country_name) {
1004 1004
 			throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso"));
1005 1005
 		}
1006 1006
 		global $wpdb;
1007 1007
 		$country_table = $wpdb->prefix."esp_country";
1008
-		if(is_int($country_name)){
1008
+		if (is_int($country_name)) {
1009 1009
 			$country_name = $this->get_iso_from_3_1_country_id($country_name);
1010 1010
 		}
1011 1011
 		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
1012 1012
 			CNT_ISO LIKE %s OR
1013 1013
 			CNT_ISO3 LIKE %s OR
1014
-			CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A);
1015
-		if( ! $country ){
1014
+			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
1015
+		if ( ! $country) {
1016 1016
 			//insert a new one then
1017 1017
 			$cols_n_values = array(
1018 1018
 				'CNT_ISO'=> $this->_find_available_country_iso(2),
@@ -1032,26 +1032,26 @@  discard block
 block discarded – undo
1032 1032
 				'CNT_active'=>true
1033 1033
 			);
1034 1034
 			$data_types = array(
1035
-				'%s',//CNT_ISO
1036
-				'%s',//CNT_ISO3
1037
-				'%d',//RGN_ID
1038
-				'%s',//CNT_name
1039
-				'%s',//CNT_cur_code
1040
-				'%s',//CNT_cur_single
1041
-				'%s',//CNT_cur_plural
1042
-				'%s',//CNT_cur_sign
1043
-				'%d',//CNT_cur_sign_b4
1044
-				'%d',//CNT_cur_dec_plc
1045
-				'%s',//CNT_cur_dec_mrk
1046
-				'%s',//CNT_cur_thsnds
1047
-				'%s',//CNT_tel_code
1048
-				'%d',//CNT_is_EU
1049
-				'%d',//CNT_active
1035
+				'%s', //CNT_ISO
1036
+				'%s', //CNT_ISO3
1037
+				'%d', //RGN_ID
1038
+				'%s', //CNT_name
1039
+				'%s', //CNT_cur_code
1040
+				'%s', //CNT_cur_single
1041
+				'%s', //CNT_cur_plural
1042
+				'%s', //CNT_cur_sign
1043
+				'%d', //CNT_cur_sign_b4
1044
+				'%d', //CNT_cur_dec_plc
1045
+				'%s', //CNT_cur_dec_mrk
1046
+				'%s', //CNT_cur_thsnds
1047
+				'%s', //CNT_tel_code
1048
+				'%d', //CNT_is_EU
1049
+				'%d', //CNT_active
1050 1050
 			);
1051 1051
 			$success = $wpdb->insert($country_table,
1052 1052
 					$cols_n_values,
1053 1053
 					$data_types);
1054
-			if( ! $success){
1054
+			if ( ! $success) {
1055 1055
 				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('country_id'=>$country_name), $country_table, $cols_n_values, $data_types));
1056 1056
 			}
1057 1057
 			$country = $cols_n_values;
@@ -1063,13 +1063,13 @@  discard block
 block discarded – undo
1063 1063
 	 * @global type $wpdb
1064 1064
 	 * @return string
1065 1065
 	 */
1066
-	private function _find_available_country_iso($num_letters = 2){
1066
+	private function _find_available_country_iso($num_letters = 2) {
1067 1067
 		global $wpdb;
1068 1068
 		$country_table = $wpdb->prefix."esp_country";
1069
-		do{
1069
+		do {
1070 1070
 			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1071
-			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso));
1072
-		}while(intval($country_with_that_iso));
1071
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso));
1072
+		}while (intval($country_with_that_iso));
1073 1073
 		return $current_iso;
1074 1074
 	}
1075 1075
 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 	 * @param string $state_name
1081 1081
 	 * @return array where keys are columns, values are column values
1082 1082
 	 */
1083
-	public function get_or_create_state($state_name,$country_name = ''){
1084
-		if( ! $state_name ){
1083
+	public function get_or_create_state($state_name, $country_name = '') {
1084
+		if ( ! $state_name) {
1085 1085
 			throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso"));
1086 1086
 		}
1087
-		try{
1087
+		try {
1088 1088
 			$country = $this->get_or_create_country($country_name);
1089 1089
 			$country_iso = $country['CNT_ISO'];
1090
-		}catch(EE_Error $e){
1090
+		} catch (EE_Error $e) {
1091 1091
 			$country_iso = $this->get_default_country_iso();
1092 1092
 		}
1093 1093
 		global $wpdb;
@@ -1095,24 +1095,24 @@  discard block
 block discarded – undo
1095 1095
 		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1096 1096
 			(STA_abbrev LIKE %s OR
1097 1097
 			STA_name LIKE %s) AND
1098
-			CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A);
1099
-		if ( ! $state){
1098
+			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1099
+		if ( ! $state) {
1100 1100
 			//insert a new one then
1101 1101
 			$cols_n_values = array(
1102 1102
 				'CNT_ISO'=>$country_iso,
1103
-				'STA_abbrev'=>substr($state_name,0,6),
1103
+				'STA_abbrev'=>substr($state_name, 0, 6),
1104 1104
 				'STA_name'=>$state_name,
1105 1105
 				'STA_active'=>true
1106 1106
 			);
1107 1107
 			$data_types = array(
1108
-				'%s',//CNT_ISO
1109
-				'%s',//STA_abbrev
1110
-				'%s',//STA_name
1111
-				'%d',//STA_active
1108
+				'%s', //CNT_ISO
1109
+				'%s', //STA_abbrev
1110
+				'%s', //STA_name
1111
+				'%d', //STA_active
1112 1112
 			);
1113
-			$success = $wpdb->insert($state_table,$cols_n_values,$data_types);
1114
-			if ( ! $success ){
1115
-				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name,'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1113
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1114
+			if ( ! $success) {
1115
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name, 'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1116 1116
 			}
1117 1117
 			$state = $cols_n_values;
1118 1118
 			$state['STA_ID'] = $wpdb->insert_id;
@@ -1125,21 +1125,21 @@  discard block
 block discarded – undo
1125 1125
 	 * @param type $timeString
1126 1126
 	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros)
1127 1127
 	 */
1128
-	public function convertTimeFromAMPM($timeString){
1128
+	public function convertTimeFromAMPM($timeString) {
1129 1129
 		$matches = array();
1130
-		preg_match("~(\\d*):(\\d*)~",$timeString,$matches);
1131
-		if( ! $matches || count($matches)<3){
1130
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1131
+		if ( ! $matches || count($matches) < 3) {
1132 1132
 			$hour = '00';
1133 1133
 			$minutes = '00';
1134
-		}else{
1134
+		} else {
1135 1135
 			$hour = intval($matches[1]);
1136 1136
 			$minutes = $matches[2];
1137 1137
 		}
1138
-		if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){
1138
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1139 1139
 			$hour = intval($hour) + 12;
1140 1140
 		}
1141
-		$hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT);
1142
-		$minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT);
1141
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1142
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1143 1143
 		return "$hour:$minutes";
1144 1144
 	}
1145 1145
 
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 	 * @param int $country_id
1149 1149
 	 * @return string the country's ISO3 code
1150 1150
 	 */
1151
-	public function get_iso_from_3_1_country_id($country_id){
1151
+	public function get_iso_from_3_1_country_id($country_id) {
1152 1152
 		$old_countries = array(
1153 1153
 			array(64, 'United States', 'US', 'USA', 1),
1154 1154
 			array(15, 'Australia', 'AU', 'AUS', 1),
@@ -1374,9 +1374,9 @@  discard block
 block discarded – undo
1374 1374
 			array(226, 'Zimbabwe', 'ZW', 'ZWE', 1));
1375 1375
 
1376 1376
 		$country_iso = 'US';
1377
-		foreach($old_countries as $country_array){
1377
+		foreach ($old_countries as $country_array) {
1378 1378
 			//note: index 0 is the 3.1 country ID
1379
-			if($country_array[0] == $country_id){
1379
+			if ($country_array[0] == $country_id) {
1380 1380
 				//note: index 2 is the ISO
1381 1381
 				$country_iso = $country_array[2];
1382 1382
 				break;
@@ -1389,8 +1389,8 @@  discard block
 block discarded – undo
1389 1389
 	 * Gets the ISO3 for the
1390 1390
 	 * @return string
1391 1391
 	 */
1392
-	public function get_default_country_iso(){
1393
-		$old_org_options= get_option('events_organization_settings');
1392
+	public function get_default_country_iso() {
1393
+		$old_org_options = get_option('events_organization_settings');
1394 1394
 		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1395 1395
 		return $iso;
1396 1396
 	}
@@ -1402,13 +1402,13 @@  discard block
 block discarded – undo
1402 1402
 	 * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval.
1403 1403
 	 * @return string STS_ID for use in 4.1
1404 1404
 	 */
1405
-	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){
1405
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) {
1406 1406
 
1407 1407
 		//EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1408
-		if($this_thing_required_pre_approval){
1408
+		if ($this_thing_required_pre_approval) {
1409 1409
 				return 'RNA';
1410
-		}else{
1411
-				$mapping = $default_reg_stati_conversions=array(
1410
+		} else {
1411
+				$mapping = $default_reg_stati_conversions = array(
1412 1412
 			'Completed'=>'RAP',
1413 1413
 			''=>'RPP',
1414 1414
 			'Incomplete'=>'RPP',
@@ -1438,22 +1438,22 @@  discard block
 block discarded – undo
1438 1438
 	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1439 1439
 	 * @return boolean whether or not we had to do the big job of creating an image attachment
1440 1440
 	 */
1441
-	public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id,  EE_Data_Migration_Script_Stage $migration_stage){
1441
+	public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) {
1442 1442
 		$created_attachment_post = false;
1443 1443
 		$guid = $this->_get_original_guid($guid);
1444
-		if($guid){
1444
+		if ($guid) {
1445 1445
 			//check for an existing attachment post with this guid
1446 1446
 			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1447
-			if( ! $attachment_post_id){
1447
+			if ( ! $attachment_post_id) {
1448 1448
 				//post thumbnail with that GUID doesn't exist, we should create one
1449 1449
 				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1450 1450
 				$created_attachment_post = true;
1451 1451
 			}
1452 1452
 			//double-check we actually have an attachment post
1453
-			if( $attachment_post_id){
1454
-				update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id);
1455
-			}else{
1456
-				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id));
1453
+			if ($attachment_post_id) {
1454
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1455
+			} else {
1456
+				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1457 1457
 			}
1458 1458
 		}
1459 1459
 		return $created_attachment_post;
@@ -1467,13 +1467,13 @@  discard block
 block discarded – undo
1467 1467
 	 * @param string $guid_in_old_event
1468 1468
 	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1469 1469
 	 */
1470
-	private function _get_original_guid($guid_in_old_event){
1471
-		$original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1);
1470
+	private function _get_original_guid($guid_in_old_event) {
1471
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1472 1472
 		//do a head request to verify the file exists
1473 1473
 		$head_response = wp_remote_head($original_guid);
1474
-		if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){
1474
+		if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1475 1475
 			return $original_guid;
1476
-		}else{
1476
+		} else {
1477 1477
 			return $guid_in_old_event;
1478 1478
 		}
1479 1479
 	}
@@ -1485,32 +1485,32 @@  discard block
 block discarded – undo
1485 1485
 	 * @param EE_Data_Migration_Script_Stage $migration_stage
1486 1486
 	 * @return int
1487 1487
 	 */
1488
-	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){
1489
-		if ( ! $guid){
1488
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) {
1489
+		if ( ! $guid) {
1490 1490
 			$migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso")));
1491 1491
 			return 0;
1492 1492
 		}
1493
-		$wp_filetype = wp_check_filetype(basename($guid), null );
1493
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1494 1494
 		$wp_upload_dir = wp_upload_dir();
1495 1495
 		//if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1496
-		if(strpos($guid,$wp_upload_dir['url']) === FALSE){
1496
+		if (strpos($guid, $wp_upload_dir['url']) === FALSE) {
1497 1497
 			//image is located remotely. download it and place it in the uploads directory
1498
-			if( ! is_readable($guid)){
1499
-				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid));
1498
+			if ( ! is_readable($guid)) {
1499
+				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid));
1500 1500
 				return 0;
1501 1501
 			}
1502
-			$contents= file_get_contents($guid);
1503
-			if($contents === FALSE){
1504
-				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid));
1502
+			$contents = file_get_contents($guid);
1503
+			if ($contents === FALSE) {
1504
+				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid));
1505 1505
 				return false;
1506 1506
 			}
1507
-			$local_filepath  = $wp_upload_dir['path'].DS.basename($guid);
1507
+			$local_filepath = $wp_upload_dir['path'].DS.basename($guid);
1508 1508
 			$savefile = fopen($local_filepath, 'w');
1509 1509
 			fwrite($savefile, $contents);
1510 1510
 			fclose($savefile);
1511
-			$guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath);
1512
-		}else{
1513
-			$local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid);
1511
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1512
+		} else {
1513
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1514 1514
 		}
1515 1515
 
1516 1516
 		$attachment = array(
@@ -1520,24 +1520,24 @@  discard block
 block discarded – undo
1520 1520
 		   'post_content' => '',
1521 1521
 		   'post_status' => 'inherit'
1522 1522
 		);
1523
-		$attach_id = wp_insert_attachment( $attachment, $guid );
1524
-		if( ! $attach_id ){
1525
-			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"),$guid,$this->_json_encode($attachment)));
1523
+		$attach_id = wp_insert_attachment($attachment, $guid);
1524
+		if ( ! $attach_id) {
1525
+			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"), $guid, $this->_json_encode($attachment)));
1526 1526
 			return $attach_id;
1527 1527
 		}
1528 1528
 
1529 1529
 		// you must first include the image.php file
1530 1530
 		// for the function wp_generate_attachment_metadata() to work
1531
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
1531
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1532 1532
 
1533
-		$attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath );
1534
-		if( ! $attach_data){
1535
-			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"),$attach_id,$local_filepath,$guid));
1533
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1534
+		if ( ! $attach_data) {
1535
+			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"), $attach_id, $local_filepath, $guid));
1536 1536
 			return $attach_id;
1537 1537
 		}
1538
-		$metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data );
1539
-		if( ! $metadata_save_result ){
1540
-			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"),$attach_id,$this->_json_encode($attach_data)));
1538
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1539
+		if ( ! $metadata_save_result) {
1540
+			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1541 1541
 		}
1542 1542
 		return $attach_id;
1543 1543
 	}
@@ -1549,9 +1549,9 @@  discard block
 block discarded – undo
1549 1549
 	 * @param string $guid
1550 1550
 	 * @return int
1551 1551
 	 */
1552
-	private function _get_image_attachment_id_by_GUID($guid){
1552
+	private function _get_image_attachment_id_by_GUID($guid) {
1553 1553
 		global $wpdb;
1554
-		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid));
1554
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1555 1555
 		return $attachment_id;
1556 1556
 	}
1557 1557
 	/**
@@ -1563,20 +1563,20 @@  discard block
 block discarded – undo
1563 1563
 	 * @param string $timezone
1564 1564
 	 * @return string
1565 1565
 	 */
1566
-	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){
1566
+	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) {
1567 1567
 		$original_tz = $timezone;
1568
-		if( ! $timezone){
1568
+		if ( ! $timezone) {
1569 1569
 			$timezone = $this->_get_wp_timezone();
1570 1570
 		}
1571
-		if( ! $timezone){
1572
-			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data));
1571
+		if ( ! $timezone) {
1572
+			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data));
1573 1573
 			$timezone = 'UTC';
1574 1574
 		}
1575
-		try{
1576
-			$date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) );
1575
+		try {
1576
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1577 1577
 			$date_obj->setTimezone(new DateTimeZone('UTC'));
1578
-		}catch(Exception $e){
1579
-			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone));
1578
+		} catch (Exception $e) {
1579
+			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"), $DATETIME_string, $timezone));
1580 1580
 			$date_obj = new DateTime();
1581 1581
 		}
1582 1582
 
@@ -1587,14 +1587,14 @@  discard block
 block discarded – undo
1587 1587
 	 * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1588 1588
 	 * @return string
1589 1589
 	 */
1590
-	private function _get_wp_timezone(){
1591
-		$timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone;
1590
+	private function _get_wp_timezone() {
1591
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1592 1592
 
1593 1593
 		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1594
-		if ( empty( $timezone ) ) {
1594
+		if (empty($timezone)) {
1595 1595
 			//let's get a the WordPress UTC offset
1596 1596
 			$offset = get_option('gmt_offset');
1597
-			$timezone = $this->timezone_convert_to_string_from_offset( $offset );
1597
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1598 1598
 		}
1599 1599
 		return $timezone;
1600 1600
 	}
@@ -1603,11 +1603,11 @@  discard block
 block discarded – undo
1603 1603
 	 * @param int $offset
1604 1604
 	 * @return boolean
1605 1605
 	 */
1606
-	private function timezone_convert_to_string_from_offset($offset){
1606
+	private function timezone_convert_to_string_from_offset($offset) {
1607 1607
 		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1608 1608
 		$offset *= 3600; // convert hour offset to seconds
1609 1609
         $abbrarray = timezone_abbreviations_list();
1610
-        foreach ($abbrarray as $abbr){
1610
+        foreach ($abbrarray as $abbr) {
1611 1611
                 foreach ($abbr as $city)
1612 1612
                 {
1613 1613
                         if ($city['offset'] == $offset)
@@ -1621,32 +1621,32 @@  discard block
 block discarded – undo
1621 1621
         return FALSE;
1622 1622
 	}
1623 1623
 
1624
-	public function migration_page_hooks(){
1625
-		add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1626
-		add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1627
-		add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1628
-		add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1629
-		add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3);
1630
-		add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4);
1631
-		add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1632
-		add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1633
-		add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table'));
1634
-		add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1635
-		add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1624
+	public function migration_page_hooks() {
1625
+		add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1626
+		add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1627
+		add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1628
+		add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1629
+		add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3);
1630
+		add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4);
1631
+		add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1632
+		add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1633
+		add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table'));
1634
+		add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1635
+		add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1636 1636
 	}
1637 1637
 
1638
-	public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){
1639
-		return str_replace(array($current_db_state,$next_db_state,$ultimate_db_state),array(__('EE3','event_espresso'),__('EE4','event_espresso'),  __("EE4", 'event_espresso')),$old_content);
1638
+	public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) {
1639
+		return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state), array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')), $old_content);
1640 1640
 	}
1641
-	public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){
1642
-		return str_replace($next_db_state,  __("EE4", 'event_espresso'),$old_content);
1641
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) {
1642
+		return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content);
1643 1643
 	}
1644
-	public function _migration_page_hook_option_1_extra_details(){
1645
-		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso"));?></p><?php
1644
+	public function _migration_page_hook_option_1_extra_details() {
1645
+		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso")); ?></p><?php
1646 1646
 	}
1647
-	public function _migration_page_hook_after_migration_options_table(){
1647
+	public function _migration_page_hook_after_migration_options_table() {
1648 1648
 		?><p class="ee-attention">
1649
-				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso");?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso");	?>
1649
+				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso"); ?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?>
1650 1650
 			</p><?php
1651 1651
 	}
1652 1652
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @author 		Mike Nelson, Brent Christensen
17 17
  * @since       4.7.0
18 18
  */
19
-class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base{
19
+class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base {
20 20
 
21 21
 	/**
22 22
 	 * return EE_DMS_Core_4_7_0
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param TableAnalysis $table_analysis
26 26
 	 * @throws \EE_Error
27 27
 	 */
28
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
28
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
29 29
 		$this->_load_script_stages();
30 30
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.7.0.p", "event_espresso");
31 31
 		$this->_priority = 10;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 			new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
34 34
 			new EE_DMS_4_7_0_Registration_Payments(),
35 35
 		);
36
-		parent::__construct( $table_manager, $table_analysis );
36
+		parent::__construct($table_manager, $table_analysis);
37 37
 	}
38 38
 
39 39
 
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 	public function can_migrate_from_version($version_array) {
46 46
 		$version_string = $version_array['Core'];
47 47
 		if (
48
-			( $version_string <= '4.7.0' && $version_string >= '4.6.0' )
48
+			($version_string <= '4.7.0' && $version_string >= '4.6.0')
49 49
 			||
50
-			( $version_string >= '4.7.0' &&
51
-					! $this->_get_table_analysis()->tableExists( 'esp_registration_payment' ) &&
52
-					$this->_get_table_analysis()->tableExists( 'esp_registration' ) ) ) {
50
+			($version_string >= '4.7.0' &&
51
+					! $this->_get_table_analysis()->tableExists('esp_registration_payment') &&
52
+					$this->_get_table_analysis()->tableExists('esp_registration')) ) {
53 53
 			return true;
54
-		} elseif ( ! $version_string ) {
54
+		} elseif ( ! $version_string) {
55 55
 			//no version string provided... this must be pre 4.3
56
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
56
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
57 57
 		} else {
58 58
 			return false;
59 59
 		}
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function schema_changes_before_migration() {
77 77
 		//relies on 4.1's EEH_Activation::create_table
78
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
79
-		$table_name='esp_answer';
80
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
78
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
79
+		$table_name = 'esp_answer';
80
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
81 81
 					REG_ID INT UNSIGNED NOT NULL,
82 82
 					QST_ID INT UNSIGNED NOT NULL,
83 83
 					ANS_value TEXT NOT NULL,
84 84
 					PRIMARY KEY  (ANS_ID),
85 85
 					KEY REG_ID (REG_ID),
86 86
 					KEY QST_ID (QST_ID)";
87
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
87
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
88 88
 
89 89
 		$table_name = 'esp_attendee_meta';
90 90
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
125 125
 					  CNT_active TINYINT(1) DEFAULT '0',
126 126
 					  PRIMARY KEY  (CNT_ISO)";
127
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
127
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
128 128
 
129 129
 		$table_name = 'esp_currency';
130 130
 		$sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 				CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
135 135
 				CUR_active TINYINT(1) DEFAULT '0',
136 136
 				PRIMARY KEY  (CUR_code)";
137
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
137
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
138 138
 
139 139
 
140 140
 		$table_name = 'esp_currency_payment_method';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 						KEY EVT_ID (EVT_ID),
165 165
 						KEY DTT_is_primary (DTT_is_primary)";
166 166
 
167
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
167
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
168 168
 
169 169
 		$table_name = 'esp_event_meta';
170 170
 		$sql = "
@@ -183,44 +183,44 @@  discard block
 block discarded – undo
183 183
 			EVT_donations TINYINT(1) NULL,
184 184
 			PRIMARY KEY  (EVTM_ID),
185 185
 			KEY EVT_ID (EVT_ID)";
186
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
186
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
187 187
 
188 188
 
189 189
 
190
-		$table_name='esp_event_question_group';
191
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
190
+		$table_name = 'esp_event_question_group';
191
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
192 192
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
193 193
 					QSG_ID INT UNSIGNED NOT NULL,
194 194
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
195 195
 					PRIMARY KEY  (EQG_ID),
196 196
 					KEY EVT_ID (EVT_ID),
197 197
 					KEY QSG_ID (QSG_ID)";
198
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
198
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
199 199
 
200 200
 
201 201
 
202
-		$table_name='esp_event_venue';
203
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
202
+		$table_name = 'esp_event_venue';
203
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
204 204
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
205 205
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
206 206
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
207 207
 				PRIMARY KEY  (EVV_ID)";
208
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
208
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
209 209
 
210 210
 
211 211
 
212
-		$table_name='esp_extra_meta';
213
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
212
+		$table_name = 'esp_extra_meta';
213
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
214 214
 				OBJ_ID INT(11) DEFAULT NULL,
215 215
 				EXM_type VARCHAR(45) DEFAULT NULL,
216 216
 				EXM_key VARCHAR(45) DEFAULT NULL,
217 217
 				EXM_value TEXT,
218 218
 				PRIMARY KEY  (EXM_ID),
219 219
 				KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))";
220
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
220
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
221 221
 
222
-		$table_name='esp_line_item';
223
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
222
+		$table_name = 'esp_line_item';
223
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
224 224
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
225 225
 				TXN_ID INT(11) DEFAULT NULL,
226 226
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 				PRIMARY KEY  (LIN_ID),
239 239
 				KEY LIN_code (LIN_code(191)),
240 240
 				KEY TXN_ID (TXN_ID)";
241
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
241
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
242 242
 
243 243
 		$table_name = 'esp_log';
244 244
 		$sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
279 279
 					PRIMARY KEY  (GRP_ID),
280 280
 					KEY MTP_user_id (MTP_user_id)";
281
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
281
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
282 282
 
283 283
 		$table_name = 'esp_event_message_template';
284 284
 		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 					PRIMARY KEY  (EMT_ID),
288 288
 					KEY EVT_ID (EVT_ID),
289 289
 					KEY GRP_ID (GRP_ID)";
290
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291 291
 
292 292
 
293 293
 		$table_name = 'esp_payment';
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 					  PRIMARY KEY  (TTM_ID)";
361 361
 		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
362 362
 
363
-		$table_name='esp_question';
364
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
363
+		$table_name = 'esp_question';
364
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
365 365
 					QST_display_text TEXT NOT NULL,
366 366
 					QST_admin_label VARCHAR(255) NOT NULL,
367 367
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -374,22 +374,22 @@  discard block
 block discarded – undo
374 374
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
375 375
 					PRIMARY KEY  (QST_ID),
376 376
 					KEY QST_order (QST_order)';
377
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
377
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
378 378
 
379
-		$table_name='esp_question_group_question';
380
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
379
+		$table_name = 'esp_question_group_question';
380
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
381 381
 					QSG_ID INT UNSIGNED NOT NULL,
382 382
 					QST_ID INT UNSIGNED NOT NULL,
383 383
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
384 384
 					PRIMARY KEY  (QGQ_ID),
385 385
 					KEY QST_ID (QST_ID),
386 386
 					KEY QSG_ID_order (QSG_ID, QGQ_order)";
387
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
387
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388 388
 
389 389
 
390 390
 
391
-		$table_name='esp_question_option';
392
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
391
+		$table_name = 'esp_question_option';
392
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
393 393
 					QSO_value VARCHAR(255) NOT NULL,
394 394
 					QSO_desc TEXT NOT NULL,
395 395
 					QST_ID INT UNSIGNED NOT NULL,
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 					PRIMARY KEY  (QSO_ID),
399 399
 					KEY QST_ID (QST_ID),
400 400
 					KEY QSO_order (QSO_order)";
401
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
401
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
402 402
 
403 403
 
404 404
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 
445 445
 
446 446
 
447
-		$table_name='esp_checkin';
448
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
447
+		$table_name = 'esp_checkin';
448
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
449 449
 					REG_ID INT(10) UNSIGNED NOT NULL,
450 450
 					DTT_ID INT(10) UNSIGNED NOT NULL,
451 451
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
541 541
 					  PRIMARY KEY  (PRC_ID),
542 542
 					  KEY PRT_ID (PRT_ID)";
543
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
543
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
544 544
 
545 545
 		$table_name = "esp_price_type";
546 546
 		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
579 579
 					  PRIMARY KEY  (TKT_ID),
580 580
 					  KEY TKT_start_date (TKT_start_date)";
581
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
581
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
582 582
 
583 583
 		$table_name = 'esp_question_group';
584
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
584
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
585 585
 					QSG_name VARCHAR(255) NOT NULL,
586 586
 					QSG_identifier VARCHAR(100) NOT NULL,
587 587
 					QSG_desc TEXT NULL,
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 					PRIMARY KEY  (QSG_ID),
595 595
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
596 596
 					KEY QSG_order (QSG_order)';
597
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
597
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
598 598
 
599 599
 		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
600 600
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		return true;
627 627
 	}
628 628
 
629
-	public function migration_page_hooks(){
629
+	public function migration_page_hooks() {
630 630
 
631 631
 	}
632 632
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage
9 9
  * @author				Mike Nelson
10 10
  */
11
-abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{
11
+abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable {
12 12
 
13 13
 	/**
14 14
 	 * the input's name attribute
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	 *  @type EE_Validation_Strategy_Base[]  $validation_strategies
144 144
 	 * }
145 145
 	 */
146
-	public function __construct( $input_args = array() ){
147
-		$input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this );
146
+	public function __construct($input_args = array()) {
147
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
148 148
 		// the following properties must be cast as arrays
149
-		if ( isset( $input_args['validation_strategies'] ) ) {
150
-			foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) {
151
-				if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
152
-					$this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy;
149
+		if (isset($input_args['validation_strategies'])) {
150
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
151
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
152
+					$this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
153 153
 				}
154 154
 			}
155
-			unset( $input_args['validation_strategies'] );
155
+			unset($input_args['validation_strategies']);
156 156
 		}
157 157
 		// loop thru incoming options
158
-		foreach( (array)$input_args as $key => $value ) {
158
+		foreach ((array) $input_args as $key => $value) {
159 159
 			// add underscore to $key to match property names
160
-			$_key = '_' . $key;
161
-			if ( property_exists( $this, $_key )) {
160
+			$_key = '_'.$key;
161
+			if (property_exists($this, $_key)) {
162 162
 				$this->{$_key} = $value;
163 163
 			}
164 164
 		}
165 165
 		// ensure that "required" is set correctly
166 166
 		$this->set_required(
167
-			$this->_required, isset( $input_args[ 'required_validation_error_message' ] )
168
-				? $input_args[ 'required_validation_error_message' ]
167
+			$this->_required, isset($input_args['required_validation_error_message'])
168
+				? $input_args['required_validation_error_message']
169 169
 				: null
170 170
 		);
171 171
 
172 172
 		//$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
173 173
 
174 174
 		$this->_display_strategy->_construct_finalize($this);
175
-		foreach( $this->_validation_strategies as $validation_strategy ){
175
+		foreach ($this->_validation_strategies as $validation_strategy) {
176 176
 			$validation_strategy->_construct_finalize($this);
177 177
 		}
178 178
 
179
-		if( ! $this->_normalization_strategy){
179
+		if ( ! $this->_normalization_strategy) {
180 180
 			$this->_normalization_strategy = new EE_Text_Normalization();
181 181
 		}
182 182
 		$this->_normalization_strategy->_construct_finalize($this);
183 183
 
184 184
 		//at least we can use the normalization strategy to populate the default
185
-		if( isset( $input_args[ 'default' ] ) ) {
186
-			$this->set_default( $input_args[ 'default' ] );
185
+		if (isset($input_args['default'])) {
186
+			$this->set_default($input_args['default']);
187 187
 		}
188 188
 
189
-		if( ! $this->_sensitive_data_removal_strategy){
189
+		if ( ! $this->_sensitive_data_removal_strategy) {
190 190
 			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
191 191
 		}
192 192
 		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
193
-		parent::__construct( $input_args );
193
+		parent::__construct($input_args);
194 194
 	}
195 195
 
196 196
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	protected function _set_default_html_name_if_empty(){
205
-		if( ! $this->_html_name){
204
+	protected function _set_default_html_name_if_empty() {
205
+		if ( ! $this->_html_name) {
206 206
 			$this->_html_name = $this->name();
207
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){
208
-				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
207
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
208
+				$this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
209 209
 			}
210 210
 		}
211 211
 	}
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 	public function _construct_finalize($parent_form_section, $name) {
221 221
 		parent::_construct_finalize($parent_form_section, $name);
222 222
 		$this->_set_default_html_name_if_empty();
223
-		if( $this->_html_label === null && $this->_html_label_text === null ){
224
-			$this->_html_label_text = ucwords( str_replace("_"," ",$name));
223
+		if ($this->_html_label === null && $this->_html_label_text === null) {
224
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
225 225
 		}
226
-		do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name );
226
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
227 227
 	}
228 228
 
229 229
 	 /**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	  * @return EE_Display_Strategy_Base
232 232
 	  * @throws EE_Error
233 233
 	  */
234
-	protected function _get_display_strategy(){
235
-		if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){
234
+	protected function _get_display_strategy() {
235
+		if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
236 236
 			throw new EE_Error(
237 237
 				sprintf(
238 238
 					__(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else {
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Sets the display strategy.
252 252
 	 * @param EE_Display_Strategy_Base $strategy
253 253
 	 */
254
-	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){
254
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) {
255 255
 		$this->_display_strategy = $strategy;
256 256
 	}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * Sets the sanitization strategy
260 260
 	 * @param EE_Normalization_Strategy_Base $strategy
261 261
 	 */
262
-	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){
262
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) {
263 263
 		$this->_normalization_strategy = $strategy;
264 264
 	}
265 265
 
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 	 * Gets the display strategy for this input
286 286
 	 * @return EE_Display_Strategy_Base
287 287
 	 */
288
-	public function get_display_strategy(){
288
+	public function get_display_strategy() {
289 289
 		return $this->_display_strategy;
290 290
 	}
291 291
 	/**
292 292
 	 * Overwrites the display strategy
293 293
 	 * @param EE_Display_Strategy_Base $display_strategy
294 294
 	 */
295
-	public function set_display_strategy($display_strategy){
295
+	public function set_display_strategy($display_strategy) {
296 296
 		$this->_display_strategy = $display_strategy;
297 297
 		$this->_display_strategy->_construct_finalize($this);
298 298
 	}
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 	 * Gets the normalization strategy set on this input
301 301
 	 * @return EE_Normalization_Strategy_Base
302 302
 	 */
303
-	public function get_normalization_strategy(){
303
+	public function get_normalization_strategy() {
304 304
 		return $this->_normalization_strategy;
305 305
 	}
306 306
 	/**
307 307
 	 * Overwrites the normalization strategy
308 308
 	 * @param EE_Normalization_Strategy_Base $normalization_strategy
309 309
 	 */
310
-	public function set_normalization_strategy($normalization_strategy){
310
+	public function set_normalization_strategy($normalization_strategy) {
311 311
 		$this->_normalization_strategy = $normalization_strategy;
312 312
 		$this->_normalization_strategy->_construct_finalize($this);
313 313
 	}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * Returns all teh validation strategies which apply to this field, numerically indexed
317 317
 	 * @return EE_Validation_Strategy_Base[]
318 318
 	 */
319
-	public function get_validation_strategies(){
319
+	public function get_validation_strategies() {
320 320
 		return $this->_validation_strategies;
321 321
 	}
322 322
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param EE_Validation_Strategy_Base $validation_strategy
328 328
 	 * @return void
329 329
 	 */
330
-	protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){
331
-		$validation_strategy->_construct_finalize( $this );
330
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
331
+		$validation_strategy->_construct_finalize($this);
332 332
 		$this->_validation_strategies[] = $validation_strategy;
333 333
 	}
334 334
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_Validation_Strategy_Base $validation_strategy
340 340
 	 * @return void
341 341
 	 */
342
-	public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) {
343
-		$this->_add_validation_strategy( $validation_strategy );
342
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
343
+		$this->_add_validation_strategy($validation_strategy);
344 344
 	}
345 345
 
346 346
 
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param string $validation_strategy_classname
352 352
 	 */
353
-	public function remove_validation_strategy( $validation_strategy_classname ) {
354
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
355
-			if(
353
+	public function remove_validation_strategy($validation_strategy_classname) {
354
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
355
+			if (
356 356
 				$validation_strategy instanceof $validation_strategy_classname
357
-				|| is_subclass_of( $validation_strategy, $validation_strategy_classname )
357
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
358 358
 			) {
359
-				unset( $this->_validation_strategies[ $key ] );
359
+				unset($this->_validation_strategies[$key]);
360 360
 			}
361 361
 		}
362 362
 	}
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 	 * @param array $validation_strategy_classnames
370 370
 	 * @return bool
371 371
 	 */
372
-	public function has_validation_strategy( $validation_strategy_classnames ) {
373
-		$validation_strategy_classnames = is_array( $validation_strategy_classnames )
372
+	public function has_validation_strategy($validation_strategy_classnames) {
373
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
374 374
 			? $validation_strategy_classnames
375
-			: array( $validation_strategy_classnames );
376
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
377
-			if( in_array( $key, $validation_strategy_classnames ) ) {
375
+			: array($validation_strategy_classnames);
376
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
377
+			if (in_array($key, $validation_strategy_classnames)) {
378 378
 				return true;
379 379
 			}
380 380
 		}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * Gets the HTML
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_html(){
390
+	public function get_html() {
391 391
 		return $this->_parent_section->get_html_for_input($this);
392 392
 	}
393 393
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	 * @return string
402 402
 	 * @throws \EE_Error
403 403
 	 */
404
-	public function get_html_for_input(){
404
+	public function get_html_for_input() {
405 405
 		return  $this->_get_display_strategy()->display();
406 406
 	}
407 407
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	 * @return string
412 412
 	 */
413 413
 	public function html_other_attributes() {
414
-		return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : '';
414
+		return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : '';
415 415
 	}
416 416
 
417 417
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	/**
420 420
 	 * @param string $html_other_attributes
421 421
 	 */
422
-	public function set_html_other_attributes( $html_other_attributes ) {
422
+	public function set_html_other_attributes($html_other_attributes) {
423 423
 		$this->_html_other_attributes = $html_other_attributes;
424 424
 	}
425 425
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * according to the form section's layout strategy
429 429
 	 * @return string
430 430
 	 */
431
-	public function get_html_for_label(){
431
+	public function get_html_for_label() {
432 432
 		return $this->_parent_section->get_layout_strategy()->display_label($this);
433 433
 	}
434 434
 	/**
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 * according to the form section's layout strategy
437 437
 	 * @return string
438 438
 	 */
439
-	public function get_html_for_errors(){
439
+	public function get_html_for_errors() {
440 440
 		return $this->_parent_section->get_layout_strategy()->display_errors($this);
441 441
 	}
442 442
 	/**
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * according to the form section's layout strategy
445 445
 	 * @return string
446 446
 	 */
447
-	public function get_html_for_help(){
447
+	public function get_html_for_help() {
448 448
 		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
449 449
 	}
450 450
 	/**
@@ -453,18 +453,18 @@  discard block
 block discarded – undo
453 453
 	 * @return boolean
454 454
 	 */
455 455
 	protected function _validate() {
456
-		foreach($this->_validation_strategies as $validation_strategy){
457
-			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
458
-				try{
456
+		foreach ($this->_validation_strategies as $validation_strategy) {
457
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
458
+				try {
459 459
 					$validation_strategy->validate($this->normalized_value());
460
-				}catch(EE_Validation_Error $e){
460
+				} catch (EE_Validation_Error $e) {
461 461
 					$this->add_validation_error($e);
462 462
 				}
463 463
 			}
464 464
 		}
465
-		if( $this->get_validation_errors()){
465
+		if ($this->get_validation_errors()) {
466 466
 			return false;
467
-		}else{
467
+		} else {
468 468
 			return true;
469 469
 		}
470 470
 	}
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	 * @param string $value
479 479
 	 * @return null|string
480 480
 	 */
481
-	private function _sanitize( $value ) {
482
-		return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null;
481
+	private function _sanitize($value) {
482
+		return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
483 483
 	}
484 484
 
485 485
 
@@ -493,25 +493,25 @@  discard block
 block discarded – undo
493 493
 	 * @return boolean whether or not there was an error
494 494
 	 * @throws \EE_Error
495 495
 	 */
496
-	protected function _normalize( $req_data ) {
496
+	protected function _normalize($req_data) {
497 497
 		//any existing validation errors don't apply so clear them
498 498
 		$this->_validation_errors = array();
499 499
 		try {
500
-			$raw_input = $this->find_form_data_for_this_section( $req_data );
500
+			$raw_input = $this->find_form_data_for_this_section($req_data);
501 501
 			//super simple sanitization for now
502
-			if ( is_array( $raw_input )) {
502
+			if (is_array($raw_input)) {
503 503
 				$raw_value = array();
504
-				foreach( $raw_input as $key => $value ) {
505
-					$raw_value[ $key ] = $this->_sanitize( $value );
504
+				foreach ($raw_input as $key => $value) {
505
+					$raw_value[$key] = $this->_sanitize($value);
506 506
 				}
507
-				$this->_set_raw_value( $raw_value );
507
+				$this->_set_raw_value($raw_value);
508 508
 			} else {
509
-				$this->_set_raw_value( $this->_sanitize( $raw_input ) );
509
+				$this->_set_raw_value($this->_sanitize($raw_input));
510 510
 			}
511 511
 			//we want to mostly leave the input alone in case we need to re-display it to the user
512
-			$this->_set_normalized_value( $this->_normalization_strategy->normalize( $this->raw_value() ) );
513
-		} catch ( EE_Validation_Error $e ) {
514
-			$this->add_validation_error( $e );
512
+			$this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
513
+		} catch (EE_Validation_Error $e) {
514
+			$this->add_validation_error($e);
515 515
 		}
516 516
 	}
517 517
 
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	/**
521 521
 	 * @return string
522 522
 	 */
523
-	public function html_name(){
523
+	public function html_name() {
524 524
 		return $this->_html_name;
525 525
 	}
526 526
 
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 	/**
530 530
 	 * @return string
531 531
 	 */
532
-	public function html_label_id(){
533
-		return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl';
532
+	public function html_label_id() {
533
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl';
534 534
 	}
535 535
 
536 536
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	/**
539 539
 	 * @return string
540 540
 	 */
541
-	public function html_label_class(){
541
+	public function html_label_class() {
542 542
 		return $this->_html_label_class;
543 543
 	}
544 544
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	/**
548 548
 	 * @return string
549 549
 	 */
550
-	public function html_label_style(){
550
+	public function html_label_style() {
551 551
 		return $this->_html_label_style;
552 552
 	}
553 553
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	/**
557 557
 	 * @return string
558 558
 	 */
559
-	public function html_label_text(){
559
+	public function html_label_text() {
560 560
 		return $this->_html_label_text;
561 561
 	}
562 562
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	/**
566 566
 	 * @return string
567 567
 	 */
568
-	public function html_help_text(){
568
+	public function html_help_text() {
569 569
 		return $this->_html_help_text;
570 570
 	}
571 571
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	/**
575 575
 	 * @return string
576 576
 	 */
577
-	public function html_help_class(){
577
+	public function html_help_class() {
578 578
 		return $this->_html_help_class;
579 579
 	}
580 580
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 	/**
584 584
 	 * @return string
585 585
 	 */
586
-	public function html_help_style(){
586
+	public function html_help_style() {
587 587
 		return $this->_html_style;
588 588
 	}
589 589
 	/**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 * in which case, we would have stored the malicious content to our database.
597 597
 	 * @return string
598 598
 	 */
599
-	public function raw_value(){
599
+	public function raw_value() {
600 600
 		return $this->_raw_value;
601 601
 	}
602 602
 	/**
@@ -604,15 +604,15 @@  discard block
 block discarded – undo
604 604
 	 * it escapes all html entities
605 605
 	 * @return string
606 606
 	 */
607
-	public function raw_value_in_form(){
608
-		return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8');
607
+	public function raw_value_in_form() {
608
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
609 609
 	}
610 610
 	/**
611 611
 	 * returns the value after it's been sanitized, and then converted into it's proper type
612 612
 	 * in PHP. Eg, a string, an int, an array,
613 613
 	 * @return mixed
614 614
 	 */
615
-	public function normalized_value(){
615
+	public function normalized_value() {
616 616
 		return $this->_normalized_value;
617 617
 	}
618 618
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 * the best thing to display
623 623
 	 * @return string
624 624
 	 */
625
-	public function pretty_value(){
625
+	public function pretty_value() {
626 626
 		return $this->_normalized_value;
627 627
 	}
628 628
 	/**
@@ -641,19 +641,19 @@  discard block
 block discarded – undo
641 641
 		  }</code>
642 642
 	 * @return array
643 643
 	 */
644
-	public function get_jquery_validation_rules(){
644
+	public function get_jquery_validation_rules() {
645 645
 		$jquery_validation_js = array();
646 646
 		$jquery_validation_rules = array();
647
-		foreach($this->get_validation_strategies() as $validation_strategy){
647
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
648 648
 			$jquery_validation_rules = array_replace_recursive(
649 649
 				$jquery_validation_rules,
650 650
 				$validation_strategy->get_jquery_validation_rule_array()
651 651
 			);
652 652
 		}
653 653
 
654
-		if(! empty($jquery_validation_rules)){
655
-			foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) {
656
-				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
654
+		if ( ! empty($jquery_validation_rules)) {
655
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
656
+				$jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
657 657
 			}
658 658
 		}
659 659
 		return $jquery_validation_js;
@@ -665,16 +665,16 @@  discard block
 block discarded – undo
665 665
 	 * @param mixed $value
666 666
 	 * @return void
667 667
 	 */
668
-	public function set_default($value){
669
-		$this->_set_normalized_value( $value );
670
-		$this->_set_raw_value( $value );
668
+	public function set_default($value) {
669
+		$this->_set_normalized_value($value);
670
+		$this->_set_raw_value($value);
671 671
 	}
672 672
 	
673 673
 	/**
674 674
 	 * Sets the normalized value on this input
675 675
 	 * @param mixed $value
676 676
 	 */
677
-	protected function _set_normalized_value( $value ) {
677
+	protected function _set_normalized_value($value) {
678 678
 		$this->_normalized_value = $value;
679 679
 	}
680 680
 	
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 	 * Sets the raw value on this input (ie, exactly as the user submitted it)
683 683
 	 * @param mixed $value
684 684
 	 */
685
-	protected function _set_raw_value( $value ) {
686
-		$this->_raw_value = $this->_normalization_strategy->unnormalize( $value );
685
+	protected function _set_raw_value($value) {
686
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
687 687
 	}
688 688
 
689 689
 	/**
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	 * @param string $label
692 692
 	 * @return void
693 693
 	 */
694
-	public function set_html_label_text($label){
694
+	public function set_html_label_text($label) {
695 695
 		$this->_html_label_text = $label;
696 696
 	}
697 697
 
@@ -705,13 +705,13 @@  discard block
 block discarded – undo
705 705
 	 * @param boolean $required boolean
706 706
 	 * @param null    $required_text
707 707
 	 */
708
-	public function set_required($required = true, $required_text = NULL ){
709
-		$required = filter_var( $required, FILTER_VALIDATE_BOOLEAN  );
708
+	public function set_required($required = true, $required_text = NULL) {
709
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
710 710
 		//whether $required is a string or a boolean, we want to add a required validation strategy
711
-		if ( $required ) {
712
-			$this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) );
711
+		if ($required) {
712
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
713 713
 		} else {
714
-			unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] );
714
+			unset($this->_validation_strategies['EE_Required_Validation_Strategy']);
715 715
 		}
716 716
 		$this->_required = $required;
717 717
 	}
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	 * Returns whether or not this field is required
720 720
 	 * @return boolean
721 721
 	 */
722
-	public function required(){
722
+	public function required() {
723 723
 		return $this->_required;
724 724
 	}
725 725
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	/**
729 729
 	 * @param string $required_css_class
730 730
 	 */
731
-	public function set_required_css_class( $required_css_class ) {
731
+	public function set_required_css_class($required_css_class) {
732 732
 		$this->_required_css_class = $required_css_class;
733 733
 	}
734 734
 
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	 * Sets the help text, in case
748 748
 	 * @param string $text
749 749
 	 */
750
-	public function set_html_help_text($text){
750
+	public function set_html_help_text($text) {
751 751
 		$this->_html_help_text = $text;
752 752
 	}
753 753
 	/**
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
 	public function clean_sensitive_data() {
760 760
 		//if we do ANY kind of sensitive data removal on this, then just clear out the raw value
761 761
 		//if we need more logic than this we'll make a strategy for it
762
-		if( $this->_sensitive_data_removal_strategy &&
763
-				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){
764
-			$this->_set_raw_value( null );
762
+		if ($this->_sensitive_data_removal_strategy &&
763
+				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) {
764
+			$this->_set_raw_value(null);
765 765
 		}
766 766
 		//and clean the normalized value according to the appropriate strategy
767 767
 		$this->_set_normalized_value(
@@ -778,10 +778,10 @@  discard block
 block discarded – undo
778 778
 	 * @param string $button_size
779 779
 	 * @param string $other_attributes
780 780
 	 */
781
-	public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) {
781
+	public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') {
782 782
 		$button_css_attributes = 'button';
783 783
 		$button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary';
784
-		switch ( $button_size ) {
784
+		switch ($button_size) {
785 785
 			case 'xs' :
786 786
 			case 'extra-small' :
787 787
 				$button_css_attributes .= ' button-xs';
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 			default :
803 803
 				$button_css_attributes .= '';
804 804
 		}
805
-		$this->_button_css_attributes .= ! empty( $other_attributes )
806
-			? $button_css_attributes . ' ' . $other_attributes
805
+		$this->_button_css_attributes .= ! empty($other_attributes)
806
+			? $button_css_attributes.' '.$other_attributes
807 807
 			: $button_css_attributes;
808 808
 	}
809 809
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	 * @return string
814 814
 	 */
815 815
 	public function button_css_attributes() {
816
-		if ( empty( $this->_button_css_attributes )) {
816
+		if (empty($this->_button_css_attributes)) {
817 817
 			$this->set_button_css_attributes();
818 818
 		}
819 819
 		return $this->_button_css_attributes;
@@ -835,26 +835,26 @@  discard block
 block discarded – undo
835 835
 	 * @return mixed whatever the raw value of this form section is in the request data
836 836
 	 * @throws \EE_Error
837 837
 	 */
838
-	public function find_form_data_for_this_section( $req_data ){
838
+	public function find_form_data_for_this_section($req_data) {
839 839
 		// break up the html name by "[]"
840
-		if ( strpos( $this->html_name(), '[' ) !== FALSE ) {
841
-			$before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') );
840
+		if (strpos($this->html_name(), '[') !== FALSE) {
841
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
842 842
 		} else {
843 843
 			$before_any_brackets = $this->html_name();
844 844
 		}
845 845
 		// grab all of the segments
846
-		preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches);
847
-		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
848
-			$name_parts = $matches[ 1 ];
846
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
847
+		if (isset($matches[1]) && is_array($matches[1])) {
848
+			$name_parts = $matches[1];
849 849
 			array_unshift($name_parts, $before_any_brackets);
850
-		}else{
851
-			$name_parts = array( $before_any_brackets );
850
+		} else {
851
+			$name_parts = array($before_any_brackets);
852 852
 		}
853 853
 		// now get the value for the input
854 854
 		$value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data);
855 855
 		// check if this thing's name is at the TOP level of the request data
856
-		if( $value === null && isset( $req_data[ $this->name() ] ) ){
857
-			$value = $req_data[ $this->name() ];
856
+		if ($value === null && isset($req_data[$this->name()])) {
857
+			$value = $req_data[$this->name()];
858 858
 		}
859 859
 		return $value;
860 860
 	}
@@ -867,18 +867,18 @@  discard block
 block discarded – undo
867 867
 	 * @param array $req_data
868 868
 	 * @return array | NULL
869 869
 	 */
870
-	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){
871
-		$first_part_to_consider = array_shift( $html_name_parts );
872
-		if( isset( $req_data[ $first_part_to_consider ] ) ){
873
-			if( empty($html_name_parts ) ){
874
-				return $req_data[ $first_part_to_consider ];
875
-			}else{
870
+	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) {
871
+		$first_part_to_consider = array_shift($html_name_parts);
872
+		if (isset($req_data[$first_part_to_consider])) {
873
+			if (empty($html_name_parts)) {
874
+				return $req_data[$first_part_to_consider];
875
+			} else {
876 876
 				return $this->_find_form_data_for_this_section_using_name_parts(
877 877
 					$html_name_parts,
878
-					$req_data[ $first_part_to_consider ]
878
+					$req_data[$first_part_to_consider]
879 879
 				);
880 880
 			}
881
-		}else{
881
+		} else {
882 882
 			return NULL;
883 883
 		}
884 884
 	}
@@ -892,14 +892,14 @@  discard block
 block discarded – undo
892 892
 	 * @return boolean
893 893
 	 * @throws \EE_Error
894 894
 	 */
895
-	public function form_data_present_in($req_data = NULL){
896
-		if( $req_data === NULL ){
895
+	public function form_data_present_in($req_data = NULL) {
896
+		if ($req_data === NULL) {
897 897
 			$req_data = $_POST;
898 898
 		}
899
-		$checked_value = $this->find_form_data_for_this_section( $req_data );
900
-		if( $checked_value !== null ){
899
+		$checked_value = $this->find_form_data_for_this_section($req_data);
900
+		if ($checked_value !== null) {
901 901
 			return TRUE;
902
-		}else{
902
+		} else {
903 903
 			return FALSE;
904 904
 		}
905 905
 	}
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 	 * @param array $form_other_js_data
911 911
 	 * @return array
912 912
 	 */
913
-	public function get_other_js_data( $form_other_js_data = array() ) {
914
-		$form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data );
913
+	public function get_other_js_data($form_other_js_data = array()) {
914
+		$form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
915 915
 		return $form_other_js_data;
916 916
 	}
917 917
 
@@ -924,10 +924,10 @@  discard block
 block discarded – undo
924 924
 	 * @param array $form_other_js_data
925 925
 	 * @return array
926 926
 	 */
927
-	public function get_other_js_data_from_strategies( $form_other_js_data = array() ) {
928
-		$form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data );
929
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
930
-			$form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data );
927
+	public function get_other_js_data_from_strategies($form_other_js_data = array()) {
928
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
929
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
930
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
931 931
 		}
932 932
 		return $form_other_js_data;
933 933
 	}
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
937 937
 	 * @return void
938 938
 	 */
939
-	public function enqueue_js(){
939
+	public function enqueue_js() {
940 940
 		//ask our display strategy and validation strategies if they have js to enqueue
941 941
 		$this->enqueue_js_from_strategies();
942 942
 	}
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	 */
948 948
 	public function enqueue_js_from_strategies() {
949 949
 		$this->get_display_strategy()->enqueue_js();
950
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
950
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
951 951
 			$validation_strategy->enqueue_js();
952 952
 		}
953 953
 	}
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/Invoice.class.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
 			'4.9.12',
44 44
 			'5.0.0'
45 45
 		);
46
-		if ( $this->registration = EE_Registry::instance()->load_model( 'Registration' )->get_registration_for_reg_url_link( $url_link)) {
46
+		if ($this->registration = EE_Registry::instance()->load_model('Registration')->get_registration_for_reg_url_link($url_link)) {
47 47
 			$this->transaction = $this->registration->transaction();
48 48
 
49
-			$payment_settings = EE_Config::instance()->gateway->payment_settings;//get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
50
-			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' );
49
+			$payment_settings = EE_Config::instance()->gateway->payment_settings; //get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
50
+			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
51 51
 		} else {
52
-			EE_Error::add_error( __( 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
52
+			EE_Error::add_error(__('Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
53 53
 		}
54 54
 
55 55
 	}
56 56
 
57
-	public function send_invoice( $download = FALSE ) {
57
+	public function send_invoice($download = FALSE) {
58 58
 		$template_args = array();
59 59
 		$EE = EE_Registry::instance();
60 60
 
61 61
 		//allow the request to override the default theme defined in the invoice settings
62
-		$theme_requested = ( isset( $_REQUEST['theme'] ) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8 ) ? absint( $_REQUEST['theme'] ) : null;
62
+		$theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint($_REQUEST['theme']) : null;
63 63
 		$themes = array(
64 64
 										1 => "simple.css",
65 65
 										2 => "bauhaus.css",
@@ -70,26 +70,26 @@  discard block
 block discarded – undo
70 70
 										7 => "union.css"
71 71
 									);
72 72
 		//Get the CSS file
73
-		if( isset( $themes[ $theme_requested ] ) ) {
74
-			$template_args['invoice_css'] = $themes[ $theme_requested ];
75
-		}else{
76
-			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( 'legacy_invoice_css', TRUE, 'simple.css' );
73
+		if (isset($themes[$theme_requested])) {
74
+			$template_args['invoice_css'] = $themes[$theme_requested];
75
+		} else {
76
+			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta('legacy_invoice_css', TRUE, 'simple.css');
77 77
 		}
78 78
 
79
-		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
80
-			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
79
+		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) {
80
+			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/';
81 81
 		} else {
82
-			$template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
82
+			$template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/';
83 83
 		}
84 84
 		$primary_attendee = $this->transaction->primary_registration()->attendee();
85 85
 
86
-		$template_args['organization'] = $EE->CFG->organization->get_pretty( 'name' );
87
-		$template_args['street'] = empty( $EE->CFG->organization->address_2 ) ? $EE->CFG->organization->get_pretty( 'address_1' ) : $EE->CFG->organization->get_pretty( 'address_1' ) . '<br>' . $EE->CFG->organization->get_pretty( 'address_2' );
88
-		$template_args['city'] = $EE->CFG->organization->get_pretty( 'city' );
89
-		$template_args['state'] = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $EE->CFG->organization->STA_ID );
90
-		$template_args['country'] = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $EE->CFG->organization->CNT_ISO );
91
-		$template_args['zip'] = $EE->CFG->organization->get_pretty( 'zip' );
92
-		$template_args['email'] = $EE->CFG->organization->get_pretty( 'email' );
86
+		$template_args['organization'] = $EE->CFG->organization->get_pretty('name');
87
+		$template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty('address_1') : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2');
88
+		$template_args['city'] = $EE->CFG->organization->get_pretty('city');
89
+		$template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
90
+		$template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID($EE->CFG->organization->CNT_ISO);
91
+		$template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
92
+		$template_args['email'] = $EE->CFG->organization->get_pretty('email');
93 93
 
94 94
 		$template_args['registration_code'] = $this->registration->reg_code();
95 95
 		$template_args['registration_date'] = $this->registration->date();
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 		$template_args['attendee_address2'] = $primary_attendee->address2();
99 99
 		$template_args['attendee_city'] = $primary_attendee->city();
100 100
 		$attendee_state = $primary_attendee->state_obj();
101
-		if($attendee_state){
101
+		if ($attendee_state) {
102 102
 			$attendee_state_name = $attendee_state->name();
103
-		}else{
103
+		} else {
104 104
 			$attendee_state_name = '';
105 105
 		}
106 106
 		$template_args['attendee_state'] = $attendee_state_name;
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 		if ($template_args['amount_pd'] != $template_args['total_cost']) {
125 125
 			//$template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
126 126
 			$tax_items = $this->transaction->tax_items();
127
-			if(!empty($tax_items) ){
127
+			if ( ! empty($tax_items)) {
128 128
 				foreach ($tax_items as $tax) {
129
-					$template_args['net_total'] .= $this->espressoInvoiceTotals( $tax->name(), $tax->total());
129
+					$template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
130 130
 				}
131 131
 			}
132 132
 
@@ -136,30 +136,30 @@  discard block
 block discarded – undo
136 136
 			} else {
137 137
 				$text = __('Extra', 'event_espresso');
138 138
 			}
139
-			$template_args['discount'] = $this->espressoInvoiceTotals( $text, $difference );
139
+			$template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
140 140
 		}
141 141
 
142 142
 		$template_args['currency_symbol'] = $EE->CFG->currency->sign;
143
-		$template_args['template_payment_instructions'] = wpautop(stripslashes_deep(html_entity_decode($this->invoice_payment_method->get_extra_meta( 'pdf_instructions', TRUE ), ENT_QUOTES)));
144
-		$template_args['shameless_plug'] = apply_filters( 'FHEE_Invoice__send_invoice__shameless_plug',true );
145
-		if(isset($_GET['receipt'])){
143
+		$template_args['template_payment_instructions'] = wpautop(stripslashes_deep(html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', TRUE), ENT_QUOTES)));
144
+		$template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
145
+		if (isset($_GET['receipt'])) {
146 146
 			//receipt-specific stuff
147 147
 			$events_for_txn = EEM_Event::instance()->get_all(array(array('Registration.TXN_ID'=>$this->transaction->ID())));
148 148
 			$ticket_line_items_per_event = array();
149 149
 			$registrations_per_line_item = array();
150 150
 			$venues_for_events = array();
151
-			foreach($events_for_txn as $event_id => $event){
152
-				$line_items_for_this_event = EEM_Line_Item::instance()->get_all(array(array('Ticket.Datetime.EVT_ID'=>$event_id,'TXN_ID'=>$this->transaction->ID())));
151
+			foreach ($events_for_txn as $event_id => $event) {
152
+				$line_items_for_this_event = EEM_Line_Item::instance()->get_all(array(array('Ticket.Datetime.EVT_ID'=>$event_id, 'TXN_ID'=>$this->transaction->ID())));
153 153
 				$ticket_line_items_per_event[$event_id] = $line_items_for_this_event;
154
-				foreach($line_items_for_this_event as $line_item_id => $line_item){
154
+				foreach ($line_items_for_this_event as $line_item_id => $line_item) {
155 155
 					$ticket = $line_item->ticket();
156
-					$registrations_for_this_ticket = EEM_Registration::instance()->get_all(array(array('TKT_ID'=>$ticket->ID(),'TXN_ID'=>$this->transaction->ID())));
156
+					$registrations_for_this_ticket = EEM_Registration::instance()->get_all(array(array('TKT_ID'=>$ticket->ID(), 'TXN_ID'=>$this->transaction->ID())));
157 157
 					$registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket;
158 158
 				}
159 159
 				$venues_for_events = array_merge($venues_for_events, $event->venues());
160 160
 			}
161
-			$tax_total_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID'=>$this->transaction->ID(),'LIN_type'=>  EEM_Line_Item::type_tax_sub_total)));
162
-			$questions_to_skip = array(EEM_Attendee::system_question_fname,EEM_Attendee::system_question_lname,  EEM_Attendee::system_question_email);
161
+			$tax_total_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID'=>$this->transaction->ID(), 'LIN_type'=>  EEM_Line_Item::type_tax_sub_total)));
162
+			$questions_to_skip = array(EEM_Attendee::system_question_fname, EEM_Attendee::system_question_lname, EEM_Attendee::system_question_email);
163 163
 
164 164
 
165 165
 			$template_args['events_for_txn'] = $events_for_txn;
@@ -170,53 +170,53 @@  discard block
 block discarded – undo
170 170
 			$template_args['questions_to_skip'] = $questions_to_skip;
171 171
 //			d($template_args);
172 172
 			$template_args['download_link'] = $this->registration->receipt_url('download');
173
-		}else{
173
+		} else {
174 174
 			//it's just an invoice we're accessing
175 175
 			$template_args['download_link'] = $this->registration->invoice_url('download');
176 176
 		}
177 177
 
178 178
 		//Get the HTML as an object
179 179
 		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
180
-		$template_header = EEH_Template::locate_template( $templates_relative_path . 'invoice_header.template.php', $template_args, TRUE, TRUE );
181
-		if(isset($_GET['receipt'])){
182
-			$template_body = EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', $template_args, TRUE, TRUE );
183
-		}else{
184
-			$template_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', $template_args, TRUE, TRUE );
180
+		$template_header = EEH_Template::locate_template($templates_relative_path.'invoice_header.template.php', $template_args, TRUE, TRUE);
181
+		if (isset($_GET['receipt'])) {
182
+			$template_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', $template_args, TRUE, TRUE);
183
+		} else {
184
+			$template_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', $template_args, TRUE, TRUE);
185 185
 		}
186 186
 
187 187
 
188
-		$template_footer = EEH_Template::locate_template( $templates_relative_path . 'invoice_footer.template.php', $template_args, TRUE, TRUE );
188
+		$template_footer = EEH_Template::locate_template($templates_relative_path.'invoice_footer.template.php', $template_args, TRUE, TRUE);
189 189
 
190
-		$copies =  ! empty( $_REQUEST['copies'] ) ? $_REQUEST['copies'] : 1;
190
+		$copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
191 191
 
192 192
 		$content = $this->espresso_replace_invoice_shortcodes($template_header);
193
-		for( $x = 1; $x <= $copies; $x++ ) {
193
+		for ($x = 1; $x <= $copies; $x++) {
194 194
 			$content .= $this->espresso_replace_invoice_shortcodes($template_body);
195 195
 		}
196 196
 		$content .= $this->espresso_replace_invoice_shortcodes($template_footer);
197 197
 
198 198
 		//Check if debugging or mobile is set
199
-		if (!empty($_REQUEST['html'])) {
199
+		if ( ! empty($_REQUEST['html'])) {
200 200
 			echo $content;
201 201
 			exit(0);
202 202
 		}
203
-		$invoice_name = $template_args['organization'] . ' ' . __('Invoice #', 'event_espresso') . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
204
-		$invoice_name = str_replace( ' ', '_', $invoice_name );
203
+		$invoice_name = $template_args['organization'].' '.__('Invoice #', 'event_espresso').$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name'];
204
+		$invoice_name = str_replace(' ', '_', $invoice_name);
205 205
 		//Create the PDF
206
-		if(array_key_exists('html',$_GET)){
206
+		if (array_key_exists('html', $_GET)) {
207 207
 			echo $content;
208
-		}else{
208
+		} else {
209 209
 			//only load dompdf if nobody else has yet...
210
-			if( ! defined('DOMPDF_DIR')){
210
+			if ( ! defined('DOMPDF_DIR')) {
211 211
 				define('DOMPDF_ENABLE_REMOTE', TRUE);
212 212
 				define('DOMPDF_ENABLE_JAVASCRIPT', FALSE);
213 213
 				define('DOMPDF_ENABLE_CSS_FLOAT', TRUE);
214
-				require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php');
214
+				require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php');
215 215
 			}
216 216
 			$dompdf = new DOMPDF();
217 217
 			$dompdf->load_html($content);
218 218
 			$dompdf->render();
219
-			$dompdf->stream($invoice_name . ".pdf", array( 'Attachment' => $download ));
219
+			$dompdf->stream($invoice_name.".pdf", array('Attachment' => $download));
220 220
 		}
221 221
 		exit(0);
222 222
 	}
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 	 * @param EE_Line_Item $line_item
227 227
 	 * @return boolean
228 228
 	 */
229
-	function check_if_any_line_items_have_a_description(EE_Line_Item $line_item){
230
-		if($line_item->desc()){
229
+	function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) {
230
+		if ($line_item->desc()) {
231 231
 			return true;
232
-		}else{
233
-			foreach($line_item->children() as $child_line_item){
234
-				if($this->check_if_any_line_items_have_a_description($child_line_item)){
232
+		} else {
233
+			foreach ($line_item->children() as $child_line_item) {
234
+				if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
235 235
 					return true;
236 236
 				}
237 237
 			}
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 	}
242 242
 
243 243
 //Perform the shortcode replacement
244
-	function espresso_replace_invoice_shortcodes( $content ) {
244
+	function espresso_replace_invoice_shortcodes($content) {
245 245
 
246 246
 		$EE = EE_Registry::instance();
247 247
 		//Create the logo
248
-		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta('pdf_logo_image', TRUE,  $EE->CFG->organization->logo_url );
249
-		if (!empty($invoice_logo_url)) {
248
+		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta('pdf_logo_image', TRUE, $EE->CFG->organization->logo_url);
249
+		if ( ! empty($invoice_logo_url)) {
250 250
 			$image_size = getimagesize($invoice_logo_url);
251
-			$invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
251
+			$invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> ';
252 252
 		} else {
253 253
 			$invoice_logo_image = '';
254 254
 		}
@@ -270,28 +270,28 @@  discard block
 block discarded – undo
270 270
 				"[instructions]",
271 271
 		);
272 272
 		$primary_attendee = $this->transaction->primary_registration()->attendee();
273
-		$org_state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $EE->CFG->organization->STA_ID );
274
-		if($org_state){
273
+		$org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
274
+		if ($org_state) {
275 275
 			$org_state_name = $org_state->name();
276
-		}else{
276
+		} else {
277 277
 			$org_state_name = '';
278 278
 		}
279 279
 		$ReplaceValues = array(
280
-				$EE->CFG->organization->get_pretty( 'name' ),
280
+				$EE->CFG->organization->get_pretty('name'),
281 281
 				$this->registration->reg_code(),
282 282
 				$this->transaction->ID(),
283 283
 				$primary_attendee->full_name(),
284
-				(is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
285
-				$this->registration->invoice_url(),//home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
284
+				(is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' : EE_GATEWAYS_URL.'Invoice/lib/templates/',
285
+				$this->registration->invoice_url(), //home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
286 286
 				$invoice_logo_image,
287
-				empty( $EE->CFG->organization->address_2 ) ? $EE->CFG->organization->get_pretty( 'address_1' ) : $EE->CFG->organization->get_pretty( 'address_1' ) . '<br>' . $EE->CFG->organization->get_pretty( 'address_2' ),
288
-				$EE->CFG->organization->get_pretty( 'city' ),
287
+				empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty('address_1') : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2'),
288
+				$EE->CFG->organization->get_pretty('city'),
289 289
 				$org_state_name,
290
-				$EE->CFG->organization->get_pretty( 'zip' ),
291
-				$EE->CFG->organization->get_pretty( 'email' ),
290
+				$EE->CFG->organization->get_pretty('zip'),
291
+				$EE->CFG->organization->get_pretty('email'),
292 292
 				$EE->CFG->organization->vat,
293
-				$this->registration->get_i18n_datetime( 'REG_date', get_option( 'date_format' ) ),
294
-				$this->invoice_payment_method->get_extra_meta( 'pdf_instructions', TRUE ),
293
+				$this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
294
+				$this->invoice_payment_method->get_extra_meta('pdf_instructions', TRUE),
295 295
 		);
296 296
 
297 297
 		return str_replace($SearchValues, $ReplaceValues, $content);
@@ -314,12 +314,12 @@  discard block
 block discarded – undo
314 314
 		if ($total_cost < 0) {
315 315
 			$total_cost = (-1) * $total_cost;
316 316
 		}
317
-		$find = array( ' ' );
318
-		$replace = array( '-' );
319
-		$row_id = strtolower( str_replace( $find, $replace, $text ));
317
+		$find = array(' ');
318
+		$replace = array('-');
319
+		$row_id = strtolower(str_replace($find, $replace, $text));
320 320
 		$html .= '<tr id="'.$row_id.'-tr"><td colspan="4">&nbsp;</td>';
321
-		$html .= '<td class="item_r">' . $text . '</td>';
322
-		$html .= '<td class="item_r">' . $total_cost . '</td>';
321
+		$html .= '<td class="item_r">'.$text.'</td>';
322
+		$html .= '<td class="item_r">'.$total_cost.'</td>';
323 323
 		$html .= '</tr>';
324 324
 		return $html;
325 325
 	}
Please login to merge, or discard this patch.