Completed
Branch BUG/escape-localized-variables (bce518)
by
unknown
17:46 queued 09:13
created
core/data_migration_scripts/EE_DMS_Core_4_5_0.dms.php 2 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 $stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*');
17 17
 $class_to_filepath = array();
18 18
 foreach ($stages as $filepath) {
19
-    $matches = array();
20
-    preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-    $class_to_filepath[ $matches[1] ] = $filepath;
19
+	$matches = array();
20
+	preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
+	$class_to_filepath[ $matches[1] ] = $filepath;
22 22
 }
23 23
 // give addons a chance to autoload their stages too
24 24
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath);
@@ -31,59 +31,59 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * EE_DMS_Core_4_5_0 constructor.
36
-     *
37
-     * @param TableManager  $table_manager
38
-     * @param TableAnalysis $table_analysis
39
-     */
40
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
-    {
42
-        $this->_pretty_name = __("Data Update to Event Espresso 4.5.0", "event_espresso");
43
-        $this->_priority = 10;
44
-        $this->_migration_stages = array(
45
-            new EE_DMS_4_5_0_update_wp_user_for_tickets(),
46
-            new EE_DMS_4_5_0_update_wp_user_for_prices(),
47
-            new EE_DMS_4_5_0_update_wp_user_for_price_types(),
48
-            new EE_DMS_4_5_0_update_wp_user_for_question_groups(),
49
-            new EE_DMS_4_5_0_invoice_settings(),
50
-        );
51
-        parent::__construct($table_manager, $table_analysis);
52
-    }
34
+	/**
35
+	 * EE_DMS_Core_4_5_0 constructor.
36
+	 *
37
+	 * @param TableManager  $table_manager
38
+	 * @param TableAnalysis $table_analysis
39
+	 */
40
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
+	{
42
+		$this->_pretty_name = __("Data Update to Event Espresso 4.5.0", "event_espresso");
43
+		$this->_priority = 10;
44
+		$this->_migration_stages = array(
45
+			new EE_DMS_4_5_0_update_wp_user_for_tickets(),
46
+			new EE_DMS_4_5_0_update_wp_user_for_prices(),
47
+			new EE_DMS_4_5_0_update_wp_user_for_price_types(),
48
+			new EE_DMS_4_5_0_update_wp_user_for_question_groups(),
49
+			new EE_DMS_4_5_0_invoice_settings(),
50
+		);
51
+		parent::__construct($table_manager, $table_analysis);
52
+	}
53 53
 
54 54
 
55 55
 
56
-    public function can_migrate_from_version($version_array)
57
-    {
58
-        $version_string = $version_array['Core'];
59
-        if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) {
56
+	public function can_migrate_from_version($version_array)
57
+	{
58
+		$version_string = $version_array['Core'];
59
+		if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) {
60 60
 //          echo "$version_string can be migrated from";
61
-            return true;
62
-        } elseif (! $version_string) {
61
+			return true;
62
+		} elseif (! $version_string) {
63 63
 //          echo "no version string provided: $version_string";
64
-            // no version string provided... this must be pre 4.3
65
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
66
-        } else {
64
+			// no version string provided... this must be pre 4.3
65
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
66
+		} else {
67 67
 //          echo "$version_string doesnt apply";
68
-            return false;
69
-        }
70
-    }
68
+			return false;
69
+		}
70
+	}
71 71
 
72 72
 
73 73
 
74
-    public function schema_changes_before_migration()
75
-    {
76
-        // relies on 4.1's EEH_Activation::create_table
77
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
78
-        $table_name = 'esp_answer';
79
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
74
+	public function schema_changes_before_migration()
75
+	{
76
+		// relies on 4.1's EEH_Activation::create_table
77
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
78
+		$table_name = 'esp_answer';
79
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
80 80
 					REG_ID int(10) unsigned NOT NULL,
81 81
 					QST_ID int(10) unsigned NOT NULL,
82 82
 					ANS_value text NOT NULL,
83 83
 					PRIMARY KEY  (ANS_ID)";
84
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
85
-        $table_name = 'esp_attendee_meta';
86
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
84
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
85
+		$table_name = 'esp_attendee_meta';
86
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
87 87
 						ATT_ID bigint(20) unsigned NOT NULL,
88 88
 						ATT_fname varchar(45) NOT NULL,
89 89
 						ATT_lname varchar(45) NOT	NULL,
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 								KEY ATT_fname (ATT_fname),
100 100
 								KEY ATT_lname (ATT_lname),
101 101
 								KEY ATT_email (ATT_email(191))";
102
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
103
-        $table_name = 'esp_country';
104
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
102
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
103
+		$table_name = 'esp_country';
104
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
105 105
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
106 106
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
107 107
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 					  CNT_is_EU tinyint(1) DEFAULT '0',
118 118
 					  CNT_active tinyint(1) DEFAULT '0',
119 119
 					  PRIMARY KEY  (CNT_ISO)";
120
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
121
-        $table_name = 'esp_datetime';
122
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
120
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
121
+		$table_name = 'esp_datetime';
122
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
123 123
 				  EVT_ID bigint(20) unsigned NOT NULL,
124 124
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
125 125
 				  DTT_description text NOT NULL,
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 						PRIMARY KEY  (DTT_ID),
135 135
 						KEY EVT_ID (EVT_ID),
136 136
 						KEY DTT_is_primary (DTT_is_primary)";
137
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
138
-        $table_name = 'esp_event_meta';
139
-        $sql = "
137
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
138
+		$table_name = 'esp_event_meta';
139
+		$sql = "
140 140
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
141 141
 			EVT_ID bigint(20) unsigned NOT NULL,
142 142
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -151,31 +151,31 @@  discard block
 block discarded – undo
151 151
 			EVT_external_URL varchar(200) NULL,
152 152
 			EVT_donations tinyint(1) NULL,
153 153
 			PRIMARY KEY  (EVTM_ID)";
154
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
155
-        $table_name = 'esp_event_question_group';
156
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
155
+		$table_name = 'esp_event_question_group';
156
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
157 157
 					EVT_ID bigint(20) unsigned NOT NULL,
158 158
 					QSG_ID int(10) unsigned NOT NULL,
159 159
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
160 160
 					PRIMARY KEY  (EQG_ID)";
161
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
162
-        $table_name = 'esp_event_venue';
163
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
161
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
162
+		$table_name = 'esp_event_venue';
163
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
164 164
 				EVT_ID bigint(20) unsigned NOT NULL,
165 165
 				VNU_ID bigint(20) unsigned NOT NULL,
166 166
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
167 167
 				PRIMARY KEY  (EVV_ID)";
168
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
169
-        $table_name = 'esp_extra_meta';
170
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
168
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
169
+		$table_name = 'esp_extra_meta';
170
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
171 171
 				OBJ_ID int(11) DEFAULT NULL,
172 172
 				EXM_type varchar(45) DEFAULT NULL,
173 173
 				EXM_key varchar(45) DEFAULT NULL,
174 174
 				EXM_value text,
175 175
 				PRIMARY KEY  (EXM_ID)";
176
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
177
-        $table_name = 'esp_line_item';
178
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
176
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
177
+		$table_name = 'esp_line_item';
178
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
179 179
 				LIN_code varchar(245) NOT NULL DEFAULT '',
180 180
 				TXN_ID int(11) DEFAULT NULL,
181 181
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 				OBJ_ID int(11) DEFAULT NULL,
192 192
 				OBJ_type varchar(45)DEFAULT NULL,
193 193
 				PRIMARY KEY  (LIN_ID)";
194
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
195
-        $table_name = 'esp_message_template';
196
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
194
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
195
+		$table_name = 'esp_message_template';
196
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
197 197
 					GRP_ID int(10) unsigned NOT NULL,
198 198
 					MTP_context varchar(50) NOT NULL,
199 199
 					MTP_template_field varchar(30) NOT NULL,
200 200
 					MTP_content text NOT NULL,
201 201
 					PRIMARY KEY  (MTP_ID),
202 202
 					KEY GRP_ID (GRP_ID)";
203
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
204
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
205
-        $table_name = 'esp_message_template_group';
206
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
203
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
204
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
205
+		$table_name = 'esp_message_template_group';
206
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
207 207
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
208 208
 					MTP_name varchar(245) NOT NULL DEFAULT '',
209 209
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
216 216
 					PRIMARY KEY  (GRP_ID),
217 217
 					KEY MTP_user_id (MTP_user_id)";
218
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
219
-        $table_name = 'esp_event_message_template';
220
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
218
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
219
+		$table_name = 'esp_event_message_template';
220
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
221 221
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
222 222
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
223 223
 					PRIMARY KEY  (EMT_ID),
224 224
 					KEY EVT_ID (EVT_ID),
225 225
 					KEY GRP_ID (GRP_ID)";
226
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
227
-        $table_name = 'esp_payment';
228
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
226
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
227
+		$table_name = 'esp_payment';
228
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
229 229
 					TXN_ID int(10) unsigned DEFAULT NULL,
230 230
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
231 231
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -241,28 +241,28 @@  discard block
 block discarded – undo
241 241
 					PRIMARY KEY  (PAY_ID),
242 242
 					KEY TXN_ID (TXN_ID),
243 243
 					KEY PAY_timestamp (PAY_timestamp)";
244
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
245
-        $table_name = "esp_ticket_price";
246
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
244
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
245
+		$table_name = "esp_ticket_price";
246
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
247 247
 					  TKT_ID int(10) unsigned NOT NULL,
248 248
 					  PRC_ID int(10) unsigned NOT NULL,
249 249
 					  PRIMARY KEY  (TKP_ID)";
250
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
251
-        $table_name = "esp_datetime_ticket";
252
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
250
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
251
+		$table_name = "esp_datetime_ticket";
252
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
253 253
 					  DTT_ID int(10) unsigned NOT NULL,
254 254
 					  TKT_ID int(10) unsigned NOT NULL,
255 255
 					  PRIMARY KEY  (DTK_ID)";
256
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
257
-        $table_name = "esp_ticket_template";
258
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
256
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
257
+		$table_name = "esp_ticket_template";
258
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259 259
 					  TTM_name varchar(45) NOT NULL,
260 260
 					  TTM_description text,
261 261
 					  TTM_file varchar(45),
262 262
 					  PRIMARY KEY  (TTM_ID)";
263
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
-        $table_name = 'esp_question';
265
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
263
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
+		$table_name = 'esp_question';
265
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
266 266
 					QST_display_text text NOT NULL,
267 267
 					QST_admin_label varchar(255) NOT NULL,
268 268
 					QST_system varchar(25) DEFAULT NULL,
@@ -274,25 +274,25 @@  discard block
 block discarded – undo
274 274
 					QST_wp_user bigint(20) unsigned NULL,
275 275
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
276 276
 					PRIMARY KEY  (QST_ID)';
277
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
278
-        $table_name = 'esp_question_group_question';
279
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
277
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
278
+		$table_name = 'esp_question_group_question';
279
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
280 280
 					QSG_ID int(10) unsigned NOT NULL,
281 281
 					QST_ID int(10) unsigned NOT NULL,
282 282
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
283 283
 					PRIMARY KEY  (QGQ_ID) ";
284
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
285
-        $table_name = 'esp_question_option';
286
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
284
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
285
+		$table_name = 'esp_question_option';
286
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
287 287
 					QSO_value varchar(255) NOT NULL,
288 288
 					QSO_desc text NOT NULL,
289 289
 					QST_ID int(10) unsigned NOT NULL,
290 290
 					QSO_order int(10) unsigned NOT NULL DEFAULT 0,
291 291
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
292 292
 					PRIMARY KEY  (QSO_ID)";
293
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
294
-        $table_name = 'esp_registration';
295
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
293
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
294
+		$table_name = 'esp_registration';
295
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
296 296
 					  EVT_ID bigint(20) unsigned NOT NULL,
297 297
 					  ATT_ID bigint(20) unsigned NOT NULL,
298 298
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -315,25 +315,25 @@  discard block
 block discarded – undo
315 315
 					  KEY STS_ID (STS_ID),
316 316
 					  KEY REG_url_link (REG_url_link),
317 317
 					  KEY REG_code (REG_code)";
318
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
319
-        $table_name = 'esp_checkin';
320
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
318
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
319
+		$table_name = 'esp_checkin';
320
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
321 321
 					REG_ID int(10) unsigned NOT NULL,
322 322
 					DTT_ID int(10) unsigned NOT NULL,
323 323
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
324 324
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
325 325
 					PRIMARY KEY  (CHK_ID)";
326
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
327
-        $table_name = 'esp_state';
328
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
326
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
327
+		$table_name = 'esp_state';
328
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
329 329
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
330 330
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
331 331
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
332 332
 					  STA_active tinyint(1) DEFAULT '1',
333 333
 					  PRIMARY KEY  (STA_ID)";
334
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
-        $table_name = 'esp_status';
336
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
334
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
+		$table_name = 'esp_status';
336
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
337 337
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
338 338
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
339 339
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
342 342
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
343 343
 					  KEY STS_type (STS_type)";
344
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
345
-        $table_name = 'esp_transaction';
346
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
344
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
345
+		$table_name = 'esp_transaction';
346
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
347 347
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
348 348
 					  TXN_total decimal(10,3) DEFAULT '0.00',
349 349
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 					  PRIMARY KEY  (TXN_ID),
355 355
 					  KEY TXN_timestamp (TXN_timestamp),
356 356
 					  KEY STS_ID (STS_ID)";
357
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
358
-        $table_name = 'esp_venue_meta';
359
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
357
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
358
+		$table_name = 'esp_venue_meta';
359
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
360 360
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
361 361
 			VNU_address varchar(255) DEFAULT NULL,
362 362
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 			PRIMARY KEY  (VNUM_ID),
375 375
 			KEY STA_ID (STA_ID),
376 376
 			KEY CNT_ISO (CNT_ISO)";
377
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
378
-        // modified tables
379
-        $table_name = "esp_price";
380
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
377
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
378
+		// modified tables
379
+		$table_name = "esp_price";
380
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
381 381
 					  PRT_ID tinyint(3) unsigned NOT NULL,
382 382
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
383 383
 					  PRC_name varchar(245) NOT NULL,
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
 					  PRC_wp_user bigint(20) unsigned NULL,
390 390
 					  PRC_parent int(10) unsigned DEFAULT 0,
391 391
 					  PRIMARY KEY  (PRC_ID)";
392
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
393
-        $table_name = "esp_price_type";
394
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
392
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
393
+		$table_name = "esp_price_type";
394
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
395 395
 				  PRT_name varchar(45) NOT NULL,
396 396
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
397 397
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
401 401
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
402 402
 				  PRIMARY KEY  (PRT_ID)";
403
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
404
-        $table_name = "esp_ticket";
405
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
403
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
404
+		$table_name = "esp_ticket";
405
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
406 406
 					  TTM_ID int(10) unsigned NOT NULL,
407 407
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
408 408
 					  TKT_description text NOT NULL,
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 					  TKT_parent int(10) unsigned DEFAULT '0',
424 424
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
425 425
 					  PRIMARY KEY  (TKT_ID)";
426
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
427
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
428
-        $table_name = 'esp_question_group';
429
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
426
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
427
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
428
+		$table_name = 'esp_question_group';
429
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
430 430
 					QSG_name varchar(255) NOT NULL,
431 431
 					QSG_identifier varchar(100) NOT NULL,
432 432
 					QSG_desc text NULL,
@@ -438,133 +438,133 @@  discard block
 block discarded – undo
438 438
 					QSG_wp_user bigint(20) unsigned NULL,
439 439
 					PRIMARY KEY  (QSG_ID),
440 440
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
441
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
442
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
443
-        // (because many need to convert old string states to foreign keys into the states table)
444
-        $script_4_1_defaults->insert_default_states();
445
-        $script_4_1_defaults->insert_default_countries();
446
-        // schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later.
447
-        $this->insert_default_price_types();
448
-        $this->insert_default_prices();
449
-        $this->insert_default_tickets();
450
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
451
-        EE_Config::instance()->update_espresso_config(false, true);
452
-        return true;
453
-    }
441
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
442
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
443
+		// (because many need to convert old string states to foreign keys into the states table)
444
+		$script_4_1_defaults->insert_default_states();
445
+		$script_4_1_defaults->insert_default_countries();
446
+		// schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later.
447
+		$this->insert_default_price_types();
448
+		$this->insert_default_prices();
449
+		$this->insert_default_tickets();
450
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
451
+		EE_Config::instance()->update_espresso_config(false, true);
452
+		return true;
453
+	}
454 454
 
455 455
 
456 456
 
457
-    /**
458
-     * @return boolean
459
-     */
460
-    public function schema_changes_after_migration()
461
-    {
462
-        return true;
463
-    }
457
+	/**
458
+	 * @return boolean
459
+	 */
460
+	public function schema_changes_after_migration()
461
+	{
462
+		return true;
463
+	}
464 464
 
465 465
 
466 466
 
467
-    public function migration_page_hooks()
468
-    {
469
-    }
467
+	public function migration_page_hooks()
468
+	{
469
+	}
470 470
 
471 471
 
472 472
 
473
-    /**
474
-     * insert_default_price_types
475
-     *
476
-     * @since 4.5.0
477
-     * @return void
478
-     */
479
-    public function insert_default_price_types()
480
-    {
481
-        global $wpdb;
482
-        $price_type_table = $wpdb->prefix . "esp_price_type";
483
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
484
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
485
-            $price_types_exist = $wpdb->get_var($SQL);
486
-            if (! $price_types_exist) {
487
-                $user_id = EEH_Activation::get_default_creator_id();
488
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES
473
+	/**
474
+	 * insert_default_price_types
475
+	 *
476
+	 * @since 4.5.0
477
+	 * @return void
478
+	 */
479
+	public function insert_default_price_types()
480
+	{
481
+		global $wpdb;
482
+		$price_type_table = $wpdb->prefix . "esp_price_type";
483
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
484
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
485
+			$price_types_exist = $wpdb->get_var($SQL);
486
+			if (! $price_types_exist) {
487
+				$user_id = EEH_Activation::get_default_creator_id();
488
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES
489 489
 							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, $user_id, 0),
490 490
 							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, $user_id, 0),
491 491
 							(3, '" . __('Dollar Discount', 'event_espresso') . "', 2,  0, 30, $user_id, 0),
492 492
 							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, $user_id,  0),
493 493
 							(5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3,  0, 50, $user_id, 0);";
494
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL);
495
-                $wpdb->query($SQL);
496
-            }
497
-        }
498
-    }
494
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL);
495
+				$wpdb->query($SQL);
496
+			}
497
+		}
498
+	}
499 499
 
500 500
 
501 501
 
502
-    /**
503
-     * insert DEFAULT prices.
504
-     *  If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices
505
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
506
-     * EE_Brewing_regular
507
-     *
508
-     * @since 4.5.0
509
-     * @return void
510
-     */
511
-    public function insert_default_prices()
512
-    {
513
-        global $wpdb;
514
-        $price_table = $wpdb->prefix . "esp_price";
515
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
516
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
517
-            $prices_exist = $wpdb->get_var($SQL);
518
-            if (! $prices_exist) {
519
-                $user_id = EEH_Activation::get_default_creator_id();
520
-                $SQL = "INSERT INTO $price_table
502
+	/**
503
+	 * insert DEFAULT prices.
504
+	 *  If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices
505
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
506
+	 * EE_Brewing_regular
507
+	 *
508
+	 * @since 4.5.0
509
+	 * @return void
510
+	 */
511
+	public function insert_default_prices()
512
+	{
513
+		global $wpdb;
514
+		$price_table = $wpdb->prefix . "esp_price";
515
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
516
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
517
+			$prices_exist = $wpdb->get_var($SQL);
518
+			if (! $prices_exist) {
519
+				$user_id = EEH_Activation::get_default_creator_id();
520
+				$SQL = "INSERT INTO $price_table
521 521
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES
522 522
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, $user_id, 0, 0, 0);";
523
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL);
524
-                $wpdb->query($SQL);
525
-            }
526
-        }
527
-    }
523
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL);
524
+				$wpdb->query($SQL);
525
+			}
526
+		}
527
+	}
528 528
 
529 529
 
530 530
 
531
-    /**
532
-     * insert DEFAULT ticket
533
-     * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field
534
-     *
535
-     * @since 4.5.0
536
-     * @return void
537
-     */
538
-    public function insert_default_tickets()
539
-    {
540
-        global $wpdb;
541
-        $ticket_table = $wpdb->prefix . "esp_ticket";
542
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
543
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
544
-            $tickets_exist = $wpdb->get_var($SQL);
545
-            if (! $tickets_exist) {
546
-                $user_id = EEH_Activation::get_default_creator_id();
547
-                $SQL = "INSERT INTO $ticket_table
531
+	/**
532
+	 * insert DEFAULT ticket
533
+	 * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field
534
+	 *
535
+	 * @since 4.5.0
536
+	 * @return void
537
+	 */
538
+	public function insert_default_tickets()
539
+	{
540
+		global $wpdb;
541
+		$ticket_table = $wpdb->prefix . "esp_ticket";
542
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
543
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
544
+			$tickets_exist = $wpdb->get_var($SQL);
545
+			if (! $tickets_exist) {
546
+				$user_id = EEH_Activation::get_default_creator_id();
547
+				$SQL = "INSERT INTO $ticket_table
548 548
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES
549 549
 					( 1, 0, '"
550
-                       . __("Free Ticket", "event_espresso")
551
-                       . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);";
552
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL);
553
-                $wpdb->query($SQL);
554
-            }
555
-        }
556
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
557
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
558
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
559
-            $ticket_prc_exist = $wpdb->get_var($SQL);
560
-            if (! $ticket_prc_exist) {
561
-                $SQL = "INSERT INTO $ticket_price_table
550
+					   . __("Free Ticket", "event_espresso")
551
+					   . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);";
552
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL);
553
+				$wpdb->query($SQL);
554
+			}
555
+		}
556
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
557
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
558
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
559
+			$ticket_prc_exist = $wpdb->get_var($SQL);
560
+			if (! $ticket_prc_exist) {
561
+				$SQL = "INSERT INTO $ticket_price_table
562 562
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
563 563
 				( 1, 1, 1 )
564 564
 				";
565
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL);
566
-                $wpdb->query($SQL);
567
-            }
568
-        }
569
-    }
565
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL);
566
+				$wpdb->query($SQL);
567
+			}
568
+		}
569
+	}
570 570
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
 // unfortunately, this needs to be done upon INCLUSION of this file,
14 14
 // instead of construction, because it only gets constructed on first page load
15 15
 // (all other times it gets resurrected from a wordpress option)
16
-$stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*');
16
+$stages = glob(EE_CORE.'data_migration_scripts/4_5_0_stages/*');
17 17
 $class_to_filepath = array();
18 18
 foreach ($stages as $filepath) {
19 19
     $matches = array();
20 20
     preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-    $class_to_filepath[ $matches[1] ] = $filepath;
21
+    $class_to_filepath[$matches[1]] = $filepath;
22 22
 }
23 23
 // give addons a chance to autoload their stages too
24 24
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath);
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
         if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) {
60 60
 //          echo "$version_string can be migrated from";
61 61
             return true;
62
-        } elseif (! $version_string) {
62
+        } elseif ( ! $version_string) {
63 63
 //          echo "no version string provided: $version_string";
64 64
             // no version string provided... this must be pre 4.3
65
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
66 66
         } else {
67 67
 //          echo "$version_string doesnt apply";
68 68
             return false;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     public function schema_changes_before_migration()
75 75
     {
76 76
         // relies on 4.1's EEH_Activation::create_table
77
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
78 78
         $table_name = 'esp_answer';
79 79
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
80 80
 					REG_ID int(10) unsigned NOT NULL,
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
     public function insert_default_price_types()
480 480
     {
481 481
         global $wpdb;
482
-        $price_type_table = $wpdb->prefix . "esp_price_type";
482
+        $price_type_table = $wpdb->prefix."esp_price_type";
483 483
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
484
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
484
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
485 485
             $price_types_exist = $wpdb->get_var($SQL);
486
-            if (! $price_types_exist) {
486
+            if ( ! $price_types_exist) {
487 487
                 $user_id = EEH_Activation::get_default_creator_id();
488 488
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES
489
-							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, $user_id, 0),
490
-							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, $user_id, 0),
491
-							(3, '" . __('Dollar Discount', 'event_espresso') . "', 2,  0, 30, $user_id, 0),
492
-							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, $user_id,  0),
493
-							(5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3,  0, 50, $user_id, 0);";
489
+							(1, '".__('Base Price', 'event_espresso')."', 1,  0, 0, $user_id, 0),
490
+							(2, '".__('Percent Discount', 'event_espresso')."', 2,  1, 20, $user_id, 0),
491
+							(3, '".__('Dollar Discount', 'event_espresso')."', 2,  0, 30, $user_id, 0),
492
+							(4, '".__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, $user_id,  0),
493
+							(5, '".__('Dollar Surcharge', 'event_espresso')."', 3,  0, 50, $user_id, 0);";
494 494
                 $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL);
495 495
                 $wpdb->query($SQL);
496 496
             }
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
     public function insert_default_prices()
512 512
     {
513 513
         global $wpdb;
514
-        $price_table = $wpdb->prefix . "esp_price";
514
+        $price_table = $wpdb->prefix."esp_price";
515 515
         if ($this->_get_table_analysis()->tableExists($price_table)) {
516
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
516
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
517 517
             $prices_exist = $wpdb->get_var($SQL);
518
-            if (! $prices_exist) {
518
+            if ( ! $prices_exist) {
519 519
                 $user_id = EEH_Activation::get_default_creator_id();
520 520
                 $SQL = "INSERT INTO $price_table
521 521
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     public function insert_default_tickets()
539 539
     {
540 540
         global $wpdb;
541
-        $ticket_table = $wpdb->prefix . "esp_ticket";
541
+        $ticket_table = $wpdb->prefix."esp_ticket";
542 542
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
543
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
543
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
544 544
             $tickets_exist = $wpdb->get_var($SQL);
545
-            if (! $tickets_exist) {
545
+            if ( ! $tickets_exist) {
546 546
                 $user_id = EEH_Activation::get_default_creator_id();
547 547
                 $SQL = "INSERT INTO $ticket_table
548 548
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
                 $wpdb->query($SQL);
554 554
             }
555 555
         }
556
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
556
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
557 557
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
558
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
558
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
559 559
             $ticket_prc_exist = $wpdb->get_var($SQL);
560
-            if (! $ticket_prc_exist) {
560
+            if ( ! $ticket_prc_exist) {
561 561
                 $SQL = "INSERT INTO $ticket_price_table
562 562
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
563 563
 				( 1, 1, 1 )
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 2 patches
Indentation   +1178 added lines, -1178 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 $stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 if (! empty($stages)) {
15
-    foreach ($stages as $filepath) {
16
-        $matches = array();
17
-        preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
-        $class_to_filepath[ $matches[1] ] = $filepath;
19
-    }
15
+	foreach ($stages as $filepath) {
16
+		$matches = array();
17
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
+		$class_to_filepath[ $matches[1] ] = $filepath;
19
+	}
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
@@ -44,91 +44,91 @@  discard block
 block discarded – undo
44 44
 
45 45
 
46 46
 
47
-    /**
48
-     * EE_DMS_Core_4_1_0 constructor.
49
-     *
50
-     * @param TableManager  $table_manager
51
-     * @param TableAnalysis $table_analysis
52
-     */
53
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
-    {
55
-        $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
56
-        $this->_priority = 10;
57
-        $this->_migration_stages = array(
58
-                new EE_DMS_4_1_0_org_options(),
59
-                new EE_DMS_4_1_0_shortcodes(),
60
-                new EE_DMS_4_1_0_gateways(),
61
-                new EE_DMS_4_1_0_events(),
62
-                new EE_DMS_4_1_0_prices(),
63
-                new EE_DMS_4_1_0_category_details(),
64
-                new EE_DMS_4_1_0_event_category(),
65
-                new EE_DMS_4_1_0_venues(),
66
-                new EE_DMS_4_1_0_event_venue(),
67
-                new EE_DMS_4_1_0_question_groups(),
68
-                new EE_DMS_4_1_0_questions(),
69
-                new EE_DMS_4_1_0_question_group_question(),
70
-                new EE_DMS_4_1_0_event_question_group(),
71
-                new EE_DMS_4_1_0_attendees(),
72
-                new EE_DMS_4_1_0_line_items(),
73
-                new EE_DMS_4_1_0_answers(),
74
-                new EE_DMS_4_1_0_checkins(),
75
-        );
76
-        parent::__construct($table_manager, $table_analysis);
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
-     *
84
-     * @global wpdb $wpdb
85
-     * @return boolean
86
-     */
87
-    private function _checkin_table_exists()
88
-    {
89
-        global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
-        if ($results) {
92
-            return true;
93
-        } else {
94
-            return false;
95
-        }
96
-    }
97
-
98
-
99
-
100
-    public function can_migrate_from_version($version_array)
101
-    {
102
-        $version_string = $version_array['Core'];
103
-        if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
47
+	/**
48
+	 * EE_DMS_Core_4_1_0 constructor.
49
+	 *
50
+	 * @param TableManager  $table_manager
51
+	 * @param TableAnalysis $table_analysis
52
+	 */
53
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
+	{
55
+		$this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
56
+		$this->_priority = 10;
57
+		$this->_migration_stages = array(
58
+				new EE_DMS_4_1_0_org_options(),
59
+				new EE_DMS_4_1_0_shortcodes(),
60
+				new EE_DMS_4_1_0_gateways(),
61
+				new EE_DMS_4_1_0_events(),
62
+				new EE_DMS_4_1_0_prices(),
63
+				new EE_DMS_4_1_0_category_details(),
64
+				new EE_DMS_4_1_0_event_category(),
65
+				new EE_DMS_4_1_0_venues(),
66
+				new EE_DMS_4_1_0_event_venue(),
67
+				new EE_DMS_4_1_0_question_groups(),
68
+				new EE_DMS_4_1_0_questions(),
69
+				new EE_DMS_4_1_0_question_group_question(),
70
+				new EE_DMS_4_1_0_event_question_group(),
71
+				new EE_DMS_4_1_0_attendees(),
72
+				new EE_DMS_4_1_0_line_items(),
73
+				new EE_DMS_4_1_0_answers(),
74
+				new EE_DMS_4_1_0_checkins(),
75
+		);
76
+		parent::__construct($table_manager, $table_analysis);
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
+	 *
84
+	 * @global wpdb $wpdb
85
+	 * @return boolean
86
+	 */
87
+	private function _checkin_table_exists()
88
+	{
89
+		global $wpdb;
90
+		$results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
+		if ($results) {
92
+			return true;
93
+		} else {
94
+			return false;
95
+		}
96
+	}
97
+
98
+
99
+
100
+	public function can_migrate_from_version($version_array)
101
+	{
102
+		$version_string = $version_array['Core'];
103
+		if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
104 104
 //          echo "$version_string can be migrated fro";
105
-            return true;
106
-        } elseif (! $version_string) {
105
+			return true;
106
+		} elseif (! $version_string) {
107 107
 //          echo "no version string provided: $version_string";
108
-            // no version string provided... this must be pre 4.1
109
-            // because since 4.1 we're
110
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
111
-        } else {
108
+			// no version string provided... this must be pre 4.1
109
+			// because since 4.1 we're
110
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
111
+		} else {
112 112
 //          echo "$version_string doesnt apply";
113
-            return false;
114
-        }
115
-    }
113
+			return false;
114
+		}
115
+	}
116 116
 
117 117
 
118 118
 
119
-    public function schema_changes_before_migration()
120
-    {
121
-        // relies on 4.1's EEH_Activation::create_table
122
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
123
-        $table_name = 'esp_answer';
124
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
119
+	public function schema_changes_before_migration()
120
+	{
121
+		// relies on 4.1's EEH_Activation::create_table
122
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
123
+		$table_name = 'esp_answer';
124
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
125 125
 					REG_ID int(10) unsigned NOT NULL,
126 126
 					QST_ID int(10) unsigned NOT NULL,
127 127
 					ANS_value text NOT NULL,
128 128
 					PRIMARY KEY  (ANS_ID)";
129
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
130
-        $table_name = 'esp_attendee_meta';
131
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
129
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
130
+		$table_name = 'esp_attendee_meta';
131
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
132 132
 						ATT_ID bigint(20) unsigned NOT NULL,
133 133
 						ATT_fname varchar(45) NOT NULL,
134 134
 						ATT_lname varchar(45) NOT NULL,
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 								KEY ATT_fname (ATT_fname),
145 145
 								KEY ATT_lname (ATT_lname),
146 146
 								KEY ATT_email (ATT_email(191))";
147
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
148
-        $table_name = 'esp_country';
149
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
147
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
148
+		$table_name = 'esp_country';
149
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
150 150
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
151 151
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
152 152
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 					  CNT_is_EU tinyint(1) DEFAULT '0',
163 163
 					  CNT_active tinyint(1) DEFAULT '0',
164 164
 					  PRIMARY KEY  (CNT_ISO)";
165
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
166
-        $table_name = 'esp_datetime';
167
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
165
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
166
+		$table_name = 'esp_datetime';
167
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
168 168
 				  EVT_ID bigint(20) unsigned NOT NULL,
169 169
 				  DTT_EVT_start datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
170 170
 				  DTT_EVT_end datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 						PRIMARY KEY  (DTT_ID),
178 178
 						KEY EVT_ID (EVT_ID),
179 179
 						KEY DTT_is_primary (DTT_is_primary)";
180
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
181
-        $table_name = 'esp_event_meta';
182
-        $sql = "
180
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
181
+		$table_name = 'esp_event_meta';
182
+		$sql = "
183 183
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
184 184
 			EVT_ID bigint(20) unsigned NOT NULL,
185 185
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 			EVT_external_URL varchar(200) NULL,
195 195
 			EVT_donations tinyint(1) NULL,
196 196
 			PRIMARY KEY  (EVTM_ID)";
197
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_event_question_group';
199
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
197
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_event_question_group';
199
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
200 200
 					EVT_ID bigint(20) unsigned NOT NULL,
201 201
 					QSG_ID int(10) unsigned NOT NULL,
202 202
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
203 203
 					PRIMARY KEY  (EQG_ID)";
204
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
-        $table_name = 'esp_event_venue';
206
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
204
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
+		$table_name = 'esp_event_venue';
206
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
207 207
 				EVT_ID bigint(20) unsigned NOT NULL,
208 208
 				VNU_ID bigint(20) unsigned NOT NULL,
209 209
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
210 210
 				PRIMARY KEY  (EVV_ID)";
211
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
212
-        $table_name = 'esp_extra_meta';
213
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
211
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
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
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
-        $table_name = 'esp_line_item';
221
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
219
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
+		$table_name = 'esp_line_item';
221
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
222 222
 				LIN_code varchar(245) NOT NULL DEFAULT '',
223 223
 				TXN_ID int(11) DEFAULT NULL,
224 224
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 				OBJ_ID int(11) DEFAULT NULL,
235 235
 				OBJ_type varchar(45)DEFAULT NULL,
236 236
 				PRIMARY KEY  (LIN_ID)";
237
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
-        $table_name = 'esp_message_template';
239
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
237
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
+		$table_name = 'esp_message_template';
239
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
240 240
 					GRP_ID int(10) unsigned NOT NULL,
241 241
 					MTP_context varchar(50) NOT NULL,
242 242
 					MTP_template_field varchar(30) NOT NULL,
243 243
 					MTP_content text NOT NULL,
244 244
 					PRIMARY KEY  (MTP_ID),
245 245
 					KEY GRP_ID (GRP_ID)";
246
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
-        $table_name = 'esp_message_template_group';
248
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
246
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
+		$table_name = 'esp_message_template_group';
248
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
249 249
 					EVT_ID bigint(20) unsigned DEFAULT NULL,
250 250
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
251 251
 					MTP_messenger varchar(30) NOT NULL,
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 					PRIMARY KEY  (GRP_ID),
258 258
 					KEY EVT_ID (EVT_ID),
259 259
 					KEY MTP_user_id (MTP_user_id)";
260
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
261
-        $table_name = 'esp_payment';
262
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
260
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
261
+		$table_name = 'esp_payment';
262
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
263 263
 					TXN_ID int(10) unsigned DEFAULT NULL,
264 264
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
265 265
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 					PRIMARY KEY  (PAY_ID),
276 276
 					KEY TXN_ID (TXN_ID),
277 277
 					KEY PAY_timestamp (PAY_timestamp)";
278
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
279
-        $table_name = "esp_ticket";
280
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
278
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
279
+		$table_name = "esp_ticket";
280
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
281 281
 					  TTM_ID int(10) unsigned NOT NULL,
282 282
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
283 283
 					  TKT_description text NOT NULL,
@@ -296,28 +296,28 @@  discard block
 block discarded – undo
296 296
 					  TKT_parent int(10) unsigned DEFAULT '0',
297 297
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
298 298
 					  PRIMARY KEY  (TKT_ID)";
299
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
300
-        $table_name = "esp_ticket_price";
301
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
299
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
300
+		$table_name = "esp_ticket_price";
301
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
302 302
 					  TKT_ID int(10) unsigned NOT NULL,
303 303
 					  PRC_ID int(10) unsigned NOT NULL,
304 304
 					  PRIMARY KEY  (TKP_ID)";
305
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
306
-        $table_name = "esp_datetime_ticket";
307
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
305
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
306
+		$table_name = "esp_datetime_ticket";
307
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
308 308
 					  DTT_ID int(10) unsigned NOT NULL,
309 309
 					  TKT_ID int(10) unsigned NOT NULL,
310 310
 					  PRIMARY KEY  (DTK_ID)";
311
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
312
-        $table_name = "esp_ticket_template";
313
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
311
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
312
+		$table_name = "esp_ticket_template";
313
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
314 314
 					  TTM_name varchar(45) NOT NULL,
315 315
 					  TTM_description text,
316 316
 					  TTM_file varchar(45),
317 317
 					  PRIMARY KEY  (TTM_ID)";
318
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
-        $table_name = "esp_price";
320
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
318
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
+		$table_name = "esp_price";
320
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
321 321
 					  PRT_ID tinyint(3) unsigned NOT NULL,
322 322
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
323 323
 					  PRC_name varchar(245) NOT NULL,
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
329 329
 					  PRC_parent int(10) unsigned DEFAULT 0,
330 330
 					  PRIMARY KEY  (PRC_ID)";
331
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
332
-        $table_name = "esp_price_type";
333
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
331
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
332
+		$table_name = "esp_price_type";
333
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
334 334
 				  PRT_name varchar(45) NOT NULL,
335 335
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
336 336
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
339 339
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
340 340
 				  PRIMARY KEY  (PRT_ID)";
341
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
342
-        $table_name = 'esp_question';
343
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question';
343
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
344 344
 					QST_display_text text NOT NULL,
345 345
 					QST_admin_label varchar(255) NOT NULL,
346 346
 					QST_system varchar(25) DEFAULT NULL,
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 					QST_wp_user bigint(20) unsigned NULL,
353 353
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
354 354
 					PRIMARY KEY  (QST_ID)';
355
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
357
-        $table_name = 'esp_question_group';
358
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
355
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
357
+		$table_name = 'esp_question_group';
358
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
359 359
 					QSG_name varchar(255) NOT NULL,
360 360
 					QSG_identifier varchar(100) NOT NULL,
361 361
 					QSG_desc text NULL,
@@ -366,23 +366,23 @@  discard block
 block discarded – undo
366 366
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
367 367
 					PRIMARY KEY  (QSG_ID),
368 368
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
369
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
370
-        $table_name = 'esp_question_group_question';
371
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
370
+		$table_name = 'esp_question_group_question';
371
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
372 372
 					QSG_ID int(10) unsigned NOT NULL,
373 373
 					QST_ID int(10) unsigned NOT NULL,
374 374
 					PRIMARY KEY  (QGQ_ID) ";
375
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
-        $table_name = 'esp_question_option';
377
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
+		$table_name = 'esp_question_option';
377
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					QSO_value varchar(255) NOT NULL,
379 379
 					QSO_desc text NOT NULL,
380 380
 					QST_ID int(10) unsigned NOT NULL,
381 381
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
382 382
 					PRIMARY KEY  (QSO_ID)";
383
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
384
-        $table_name = 'esp_registration';
385
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
383
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
384
+		$table_name = 'esp_registration';
385
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
386 386
 					  EVT_ID bigint(20) unsigned NOT NULL,
387 387
 					  ATT_ID bigint(20) unsigned NOT NULL,
388 388
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -405,25 +405,25 @@  discard block
 block discarded – undo
405 405
 					  KEY STS_ID (STS_ID),
406 406
 					  KEY REG_url_link (REG_url_link),
407 407
 					  KEY REG_code (REG_code)";
408
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
409
-        $table_name = 'esp_checkin';
410
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
408
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
409
+		$table_name = 'esp_checkin';
410
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
411 411
 					REG_ID int(10) unsigned NOT NULL,
412 412
 					DTT_ID int(10) unsigned NOT NULL,
413 413
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
414 414
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
415 415
 					PRIMARY KEY  (CHK_ID)";
416
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417
-        $table_name = 'esp_state';
418
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
416
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417
+		$table_name = 'esp_state';
418
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
419 419
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
420 420
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
421 421
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
422 422
 					  STA_active tinyint(1) DEFAULT '1',
423 423
 					  PRIMARY KEY  (STA_ID)";
424
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
425
-        $table_name = 'esp_status';
426
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
424
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
425
+		$table_name = 'esp_status';
426
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
427 427
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
428 428
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
429 429
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
432 432
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
433 433
 					  KEY STS_type (STS_type)";
434
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
435
-        $table_name = 'esp_transaction';
436
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
434
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
435
+		$table_name = 'esp_transaction';
436
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
437 437
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
438 438
 					  TXN_total decimal(10,3) DEFAULT '0.00',
439 439
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 					  PRIMARY KEY  (TXN_ID),
444 444
 					  KEY TXN_timestamp (TXN_timestamp),
445 445
 					  KEY STS_ID (STS_ID)";
446
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
447
-        $table_name = 'esp_venue_meta';
448
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
446
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
447
+		$table_name = 'esp_venue_meta';
448
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
449 449
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
450 450
 			VNU_address varchar(255) DEFAULT NULL,
451 451
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -463,52 +463,52 @@  discard block
 block discarded – undo
463 463
 			PRIMARY KEY  (VNUM_ID),
464 464
 			KEY STA_ID (STA_ID),
465 465
 			KEY CNT_ISO (CNT_ISO)";
466
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
-        // setting up the default stats and countries is also essential for the data migrations to run
468
-        // (because many need to convert old string states to foreign keys into the states table)
469
-        $this->insert_default_states();
470
-        $this->insert_default_countries();
471
-        // setting up default prices, price types, and tickets is also essential for the price migrations
472
-        $this->insert_default_price_types();
473
-        $this->insert_default_prices();
474
-        $this->insert_default_tickets();
475
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
476
-        EE_Config::instance()->update_espresso_config(false, true);
477
-        return true;
478
-    }
479
-
480
-
481
-
482
-    /**
483
-     * Yes we could have cleaned up the ee3 tables here. But just in case someone
484
-     * didn't backup their DB, and decides they want ot keep using EE3, we'll
485
-     * leave them for now. Mayeb remove them in 4.5 or something.
486
-     *
487
-     * @return boolean
488
-     */
489
-    public function schema_changes_after_migration()
490
-    {
491
-        return true;
492
-    }
493
-
494
-
495
-
496
-    /**
497
-     * insert_default_states
498
-     *
499
-     * @access public
500
-     * @static
501
-     * @return void
502
-     */
503
-    public function insert_default_states()
504
-    {
505
-        global $wpdb;
506
-        $state_table = $wpdb->prefix . "esp_state";
507
-        if ($this->_get_table_analysis()->tableExists($state_table)) {
508
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
509
-            $states = $wpdb->get_var($SQL);
510
-            if (! $states) {
511
-                $SQL = "INSERT INTO " . $state_table . "
466
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
+		// setting up the default stats and countries is also essential for the data migrations to run
468
+		// (because many need to convert old string states to foreign keys into the states table)
469
+		$this->insert_default_states();
470
+		$this->insert_default_countries();
471
+		// setting up default prices, price types, and tickets is also essential for the price migrations
472
+		$this->insert_default_price_types();
473
+		$this->insert_default_prices();
474
+		$this->insert_default_tickets();
475
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
476
+		EE_Config::instance()->update_espresso_config(false, true);
477
+		return true;
478
+	}
479
+
480
+
481
+
482
+	/**
483
+	 * Yes we could have cleaned up the ee3 tables here. But just in case someone
484
+	 * didn't backup their DB, and decides they want ot keep using EE3, we'll
485
+	 * leave them for now. Mayeb remove them in 4.5 or something.
486
+	 *
487
+	 * @return boolean
488
+	 */
489
+	public function schema_changes_after_migration()
490
+	{
491
+		return true;
492
+	}
493
+
494
+
495
+
496
+	/**
497
+	 * insert_default_states
498
+	 *
499
+	 * @access public
500
+	 * @static
501
+	 * @return void
502
+	 */
503
+	public function insert_default_states()
504
+	{
505
+		global $wpdb;
506
+		$state_table = $wpdb->prefix . "esp_state";
507
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
508
+			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
509
+			$states = $wpdb->get_var($SQL);
510
+			if (! $states) {
511
+				$SQL = "INSERT INTO " . $state_table . "
512 512
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
513 513
 				(1, 'US', 'AK', 'Alaska', 1),
514 514
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -579,29 +579,29 @@  discard block
 block discarded – undo
579 579
 				(67, 'CA', 'PE', 'Prince Edward Island', 1),
580 580
 				(68, 'CA', 'QC', 'Quebec', 1),
581 581
 				(69, 'CA', 'SK', 'Saskatchewan', 1);";
582
-                $wpdb->query($SQL);
583
-            }
584
-        }
585
-    }
586
-
587
-
588
-
589
-    /**
590
-     * insert_default_countries
591
-     *
592
-     * @access public
593
-     * @static
594
-     * @return void
595
-     */
596
-    public function insert_default_countries()
597
-    {
598
-        global $wpdb;
599
-        $country_table = $wpdb->prefix . "esp_country";
600
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
601
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
602
-            $countries = $wpdb->get_var($SQL);
603
-            if (! $countries) {
604
-                $SQL = "INSERT INTO " . $country_table . "
582
+				$wpdb->query($SQL);
583
+			}
584
+		}
585
+	}
586
+
587
+
588
+
589
+	/**
590
+	 * insert_default_countries
591
+	 *
592
+	 * @access public
593
+	 * @static
594
+	 * @return void
595
+	 */
596
+	public function insert_default_countries()
597
+	{
598
+		global $wpdb;
599
+		$country_table = $wpdb->prefix . "esp_country";
600
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
601
+			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
602
+			$countries = $wpdb->get_var($SQL);
603
+			if (! $countries) {
604
+				$SQL = "INSERT INTO " . $country_table . "
605 605
 				(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
606 606
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
607 607
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -829,984 +829,984 @@  discard block
 block discarded – undo
829 829
 				('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0),
830 830
 				('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0),
831 831
 				('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);";
832
-                $wpdb->query($SQL);
833
-            }
834
-        }
835
-    }
836
-
837
-
838
-
839
-    /**
840
-     * insert_default_price_types
841
-     *
842
-     * @access public
843
-     * @static
844
-     * @return void
845
-     */
846
-    public function insert_default_price_types()
847
-    {
848
-        global $wpdb;
849
-        $price_type_table = $wpdb->prefix . "esp_price_type";
850
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
852
-            $price_types_exist = $wpdb->get_var($SQL);
853
-            if (! $price_types_exist) {
854
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
832
+				$wpdb->query($SQL);
833
+			}
834
+		}
835
+	}
836
+
837
+
838
+
839
+	/**
840
+	 * insert_default_price_types
841
+	 *
842
+	 * @access public
843
+	 * @static
844
+	 * @return void
845
+	 */
846
+	public function insert_default_price_types()
847
+	{
848
+		global $wpdb;
849
+		$price_type_table = $wpdb->prefix . "esp_price_type";
850
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
852
+			$price_types_exist = $wpdb->get_var($SQL);
853
+			if (! $price_types_exist) {
854
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
855 855
 							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
856 856
 							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
857 857
 							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
858 858
 							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
859 859
 							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
860
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861
-                $wpdb->query($SQL);
862
-            }
863
-        }
864
-    }
865
-
866
-
867
-
868
-    /**
869
-     * insert_default_prices. We assume we're upgrading to regular here.
870
-     * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
871
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
872
-     * EE_BRewing_regular
873
-     *
874
-     * @access public
875
-     * @static
876
-     * @return void
877
-     */
878
-    public function insert_default_prices()
879
-    {
880
-        global $wpdb;
881
-        $price_table = $wpdb->prefix . "esp_price";
882
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
883
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
884
-            $prices_exist = $wpdb->get_var($SQL);
885
-            if (! $prices_exist) {
886
-                $SQL = "INSERT INTO $price_table
860
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861
+				$wpdb->query($SQL);
862
+			}
863
+		}
864
+	}
865
+
866
+
867
+
868
+	/**
869
+	 * insert_default_prices. We assume we're upgrading to regular here.
870
+	 * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
871
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
872
+	 * EE_BRewing_regular
873
+	 *
874
+	 * @access public
875
+	 * @static
876
+	 * @return void
877
+	 */
878
+	public function insert_default_prices()
879
+	{
880
+		global $wpdb;
881
+		$price_table = $wpdb->prefix . "esp_price";
882
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
883
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
884
+			$prices_exist = $wpdb->get_var($SQL);
885
+			if (! $prices_exist) {
886
+				$SQL = "INSERT INTO $price_table
887 887
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
888 888
 							(1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);";
889
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
890
-                $wpdb->query($SQL);
891
-            }
892
-        }
893
-    }
894
-
895
-
896
-
897
-    /**
898
-     * insert default ticket
899
-     *
900
-     * @access public
901
-     * @static
902
-     * @return void
903
-     */
904
-    public function insert_default_tickets()
905
-    {
906
-        global $wpdb;
907
-        $ticket_table = $wpdb->prefix . "esp_ticket";
908
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
910
-            $tickets_exist = $wpdb->get_var($SQL);
911
-            if (! $tickets_exist) {
912
-                $SQL = "INSERT INTO $ticket_table
889
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
890
+				$wpdb->query($SQL);
891
+			}
892
+		}
893
+	}
894
+
895
+
896
+
897
+	/**
898
+	 * insert default ticket
899
+	 *
900
+	 * @access public
901
+	 * @static
902
+	 * @return void
903
+	 */
904
+	public function insert_default_tickets()
905
+	{
906
+		global $wpdb;
907
+		$ticket_table = $wpdb->prefix . "esp_ticket";
908
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
910
+			$tickets_exist = $wpdb->get_var($SQL);
911
+			if (! $tickets_exist) {
912
+				$SQL = "INSERT INTO $ticket_table
913 913
 					( 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
914 914
 					( 1, 0, '"
915
-                       . esc_html__("Free Ticket", "event_espresso")
916
-                       . "', '', 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);";
917
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
918
-                $wpdb->query($SQL);
919
-            }
920
-        }
921
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
922
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
924
-            $ticket_prc_exist = $wpdb->get_var($SQL);
925
-            if (! $ticket_prc_exist) {
926
-                $SQL = "INSERT INTO $ticket_price_table
915
+					   . esc_html__("Free Ticket", "event_espresso")
916
+					   . "', '', 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);";
917
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
918
+				$wpdb->query($SQL);
919
+			}
920
+		}
921
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
922
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
924
+			$ticket_prc_exist = $wpdb->get_var($SQL);
925
+			if (! $ticket_prc_exist) {
926
+				$SQL = "INSERT INTO $ticket_price_table
927 927
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
928 928
 				( 1, 1, 1 )
929 929
 				";
930
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
931
-                $wpdb->query($SQL);
932
-            }
933
-        }
934
-    }
935
-
936
-
937
-
938
-    /**
939
-     * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
940
-     * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
941
-     * country ID (int), a 2-letter ISO, 3-letter ISO, or name
942
-     *
943
-     * @global type  $wpdb
944
-     * @param string $country_name
945
-     * @return array where keys are columns, values are column values
946
-     */
947
-    public function get_or_create_country($country_name)
948
-    {
949
-        if (! $country_name) {
950
-            throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951
-        }
952
-        global $wpdb;
953
-        $country_table = $wpdb->prefix . "esp_country";
954
-        if (is_int($country_name)) {
955
-            $country_name = $this->get_iso_from_3_1_country_id($country_name);
956
-        }
957
-        $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
930
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
931
+				$wpdb->query($SQL);
932
+			}
933
+		}
934
+	}
935
+
936
+
937
+
938
+	/**
939
+	 * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
940
+	 * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
941
+	 * country ID (int), a 2-letter ISO, 3-letter ISO, or name
942
+	 *
943
+	 * @global type  $wpdb
944
+	 * @param string $country_name
945
+	 * @return array where keys are columns, values are column values
946
+	 */
947
+	public function get_or_create_country($country_name)
948
+	{
949
+		if (! $country_name) {
950
+			throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951
+		}
952
+		global $wpdb;
953
+		$country_table = $wpdb->prefix . "esp_country";
954
+		if (is_int($country_name)) {
955
+			$country_name = $this->get_iso_from_3_1_country_id($country_name);
956
+		}
957
+		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
958 958
 			CNT_ISO LIKE %s OR
959 959
 			CNT_ISO3 LIKE %s OR
960 960
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
961
-        if (! $country) {
962
-            // insert a new one then
963
-            $cols_n_values = array(
964
-                    'CNT_ISO'         => $this->_find_available_country_iso(2),
965
-                    'CNT_ISO3'        => $this->_find_available_country_iso(3),
966
-                    'RGN_ID'          => 0,
967
-                    'CNT_name'        => $country_name,
968
-                    'CNT_cur_code'    => 'USD',
969
-                    'CNT_cur_single'  => 'Dollar',
970
-                    'CNT_cur_plural'  => 'Dollars',
971
-                    'CNT_cur_sign'    => '&#36;',
972
-                    'CNT_cur_sign_b4' => true,
973
-                    'CNT_cur_dec_plc' => 2,
974
-                    'CNT_cur_dec_mrk' => '.',
975
-                    'CNT_cur_thsnds'  => ',',
976
-                    'CNT_tel_code'    => '+1',
977
-                    'CNT_is_EU'       => false,
978
-                    'CNT_active'      => true,
979
-            );
980
-            $data_types = array(
981
-                    '%s',// CNT_ISO
982
-                    '%s',// CNT_ISO3
983
-                    '%d',// RGN_ID
984
-                    '%s',// CNT_name
985
-                    '%s',// CNT_cur_code
986
-                    '%s',// CNT_cur_single
987
-                    '%s',// CNT_cur_plural
988
-                    '%s',// CNT_cur_sign
989
-                    '%d',// CNT_cur_sign_b4
990
-                    '%d',// CNT_cur_dec_plc
991
-                    '%s',// CNT_cur_dec_mrk
992
-                    '%s',// CNT_cur_thsnds
993
-                    '%s',// CNT_tel_code
994
-                    '%d',// CNT_is_EU
995
-                    '%d',// CNT_active
996
-            );
997
-            $success = $wpdb->insert(
998
-                $country_table,
999
-                $cols_n_values,
1000
-                $data_types
1001
-            );
1002
-            if (! $success) {
1003
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1004
-                    'N/A',
1005
-                    array('country_id' => $country_name),
1006
-                    $country_table,
1007
-                    $cols_n_values,
1008
-                    $data_types
1009
-                ));
1010
-            }
1011
-            $country = $cols_n_values;
1012
-        }
1013
-        return $country;
1014
-    }
1015
-
1016
-
1017
-
1018
-    /**
1019
-     * finds a country iso which hasnt been used yet
1020
-     *
1021
-     * @global type $wpdb
1022
-     * @return string
1023
-     */
1024
-    private function _find_available_country_iso($num_letters = 2)
1025
-    {
1026
-        global $wpdb;
1027
-        $country_table = $wpdb->prefix . "esp_country";
1028
-        $attempts = 0;
1029
-        do {
1030
-            $current_iso = strtoupper(wp_generate_password($num_letters, false));
1031
-            $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1032
-                                                                   . $country_table
1033
-                                                                   . " WHERE CNT_ISO=%s", $current_iso));
1034
-            $attempts++;
1035
-            // keep going until we find an available country code, or we arbitrarily
1036
-            // decide we've tried this enough. Somehow they have way too many countries
1037
-            // (probably because they're mis-using the EE3 country_id like a custom question)
1038
-        } while (intval($country_with_that_iso) && $attempts < 200);
1039
-        return $current_iso;
1040
-    }
1041
-
1042
-
1043
-
1044
-    /**
1045
-     * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1046
-     * is independent of outside code which can change in future versions of EE
1047
-     *
1048
-     * @global type  $wpdb
1049
-     * @param string $state_name
1050
-     * @return array where keys are columns, values are column values
1051
-     */
1052
-    public function get_or_create_state($state_name, $country_name = '')
1053
-    {
1054
-        if (! $state_name) {
1055
-            throw new EE_Error(esc_html__(
1056
-                "Could not get-or-create state because no state name was provided",
1057
-                "event_espresso"
1058
-            ));
1059
-        }
1060
-        try {
1061
-            $country = $this->get_or_create_country($country_name);
1062
-            $country_iso = $country['CNT_ISO'];
1063
-        } catch (EE_Error $e) {
1064
-            $country_iso = $this->get_default_country_iso();
1065
-        }
1066
-        global $wpdb;
1067
-        $state_table = $wpdb->prefix . "esp_state";
1068
-        $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
961
+		if (! $country) {
962
+			// insert a new one then
963
+			$cols_n_values = array(
964
+					'CNT_ISO'         => $this->_find_available_country_iso(2),
965
+					'CNT_ISO3'        => $this->_find_available_country_iso(3),
966
+					'RGN_ID'          => 0,
967
+					'CNT_name'        => $country_name,
968
+					'CNT_cur_code'    => 'USD',
969
+					'CNT_cur_single'  => 'Dollar',
970
+					'CNT_cur_plural'  => 'Dollars',
971
+					'CNT_cur_sign'    => '&#36;',
972
+					'CNT_cur_sign_b4' => true,
973
+					'CNT_cur_dec_plc' => 2,
974
+					'CNT_cur_dec_mrk' => '.',
975
+					'CNT_cur_thsnds'  => ',',
976
+					'CNT_tel_code'    => '+1',
977
+					'CNT_is_EU'       => false,
978
+					'CNT_active'      => true,
979
+			);
980
+			$data_types = array(
981
+					'%s',// CNT_ISO
982
+					'%s',// CNT_ISO3
983
+					'%d',// RGN_ID
984
+					'%s',// CNT_name
985
+					'%s',// CNT_cur_code
986
+					'%s',// CNT_cur_single
987
+					'%s',// CNT_cur_plural
988
+					'%s',// CNT_cur_sign
989
+					'%d',// CNT_cur_sign_b4
990
+					'%d',// CNT_cur_dec_plc
991
+					'%s',// CNT_cur_dec_mrk
992
+					'%s',// CNT_cur_thsnds
993
+					'%s',// CNT_tel_code
994
+					'%d',// CNT_is_EU
995
+					'%d',// CNT_active
996
+			);
997
+			$success = $wpdb->insert(
998
+				$country_table,
999
+				$cols_n_values,
1000
+				$data_types
1001
+			);
1002
+			if (! $success) {
1003
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1004
+					'N/A',
1005
+					array('country_id' => $country_name),
1006
+					$country_table,
1007
+					$cols_n_values,
1008
+					$data_types
1009
+				));
1010
+			}
1011
+			$country = $cols_n_values;
1012
+		}
1013
+		return $country;
1014
+	}
1015
+
1016
+
1017
+
1018
+	/**
1019
+	 * finds a country iso which hasnt been used yet
1020
+	 *
1021
+	 * @global type $wpdb
1022
+	 * @return string
1023
+	 */
1024
+	private function _find_available_country_iso($num_letters = 2)
1025
+	{
1026
+		global $wpdb;
1027
+		$country_table = $wpdb->prefix . "esp_country";
1028
+		$attempts = 0;
1029
+		do {
1030
+			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1031
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1032
+																   . $country_table
1033
+																   . " WHERE CNT_ISO=%s", $current_iso));
1034
+			$attempts++;
1035
+			// keep going until we find an available country code, or we arbitrarily
1036
+			// decide we've tried this enough. Somehow they have way too many countries
1037
+			// (probably because they're mis-using the EE3 country_id like a custom question)
1038
+		} while (intval($country_with_that_iso) && $attempts < 200);
1039
+		return $current_iso;
1040
+	}
1041
+
1042
+
1043
+
1044
+	/**
1045
+	 * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1046
+	 * is independent of outside code which can change in future versions of EE
1047
+	 *
1048
+	 * @global type  $wpdb
1049
+	 * @param string $state_name
1050
+	 * @return array where keys are columns, values are column values
1051
+	 */
1052
+	public function get_or_create_state($state_name, $country_name = '')
1053
+	{
1054
+		if (! $state_name) {
1055
+			throw new EE_Error(esc_html__(
1056
+				"Could not get-or-create state because no state name was provided",
1057
+				"event_espresso"
1058
+			));
1059
+		}
1060
+		try {
1061
+			$country = $this->get_or_create_country($country_name);
1062
+			$country_iso = $country['CNT_ISO'];
1063
+		} catch (EE_Error $e) {
1064
+			$country_iso = $this->get_default_country_iso();
1065
+		}
1066
+		global $wpdb;
1067
+		$state_table = $wpdb->prefix . "esp_state";
1068
+		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1069 1069
 			(STA_abbrev LIKE %s OR
1070 1070
 			STA_name LIKE %s) AND
1071 1071
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1072
-        if (! $state) {
1073
-            // insert a new one then
1074
-            $cols_n_values = array(
1075
-                    'CNT_ISO'    => $country_iso,
1076
-                    'STA_abbrev' => substr($state_name, 0, 6),
1077
-                    'STA_name'   => $state_name,
1078
-                    'STA_active' => true,
1079
-            );
1080
-            $data_types = array(
1081
-                    '%s',// CNT_ISO
1082
-                    '%s',// STA_abbrev
1083
-                    '%s',// STA_name
1084
-                    '%d',// STA_active
1085
-            );
1086
-            $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1087
-            if (! $success) {
1088
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1089
-                    'N/A',
1090
-                    array('state' => $state_name, 'country_id' => $country_name),
1091
-                    $state_table,
1092
-                    $cols_n_values,
1093
-                    $data_types
1094
-                ));
1095
-            }
1096
-            $state = $cols_n_values;
1097
-            $state['STA_ID'] = $wpdb->insert_id;
1098
-        }
1099
-        return $state;
1100
-    }
1101
-
1102
-
1103
-
1104
-    /**
1105
-     * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1106
-     * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1107
-     *
1108
-     * @param type $timeString
1109
-     * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1110
-     *                with leading zeros)
1111
-     */
1112
-    public function convertTimeFromAMPM($timeString)
1113
-    {
1114
-        $matches = array();
1115
-        preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1116
-        if (! $matches || count($matches) < 3) {
1117
-            $hour = '00';
1118
-            $minutes = '00';
1119
-        } else {
1120
-            $hour = intval($matches[1]);
1121
-            $minutes = $matches[2];
1122
-        }
1123
-        if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1124
-            $hour = intval($hour) + 12;
1125
-        }
1126
-        $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1127
-        $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1128
-        return "$hour:$minutes";
1129
-    }
1130
-
1131
-
1132
-
1133
-    /**
1134
-     * Gets the ISO3 fora country given its 3.1 country ID.
1135
-     *
1136
-     * @param int $country_id
1137
-     * @return string the country's ISO3 code
1138
-     */
1139
-    public function get_iso_from_3_1_country_id($country_id)
1140
-    {
1141
-        $old_countries = array(
1142
-                array(64, 'United States', 'US', 'USA', 1),
1143
-                array(15, 'Australia', 'AU', 'AUS', 1),
1144
-                array(39, 'Canada', 'CA', 'CAN', 1),
1145
-                array(171, 'United Kingdom', 'GB', 'GBR', 1),
1146
-                array(70, 'France', 'FR', 'FRA', 2),
1147
-                array(111, 'Italy', 'IT', 'ITA', 2),
1148
-                array(63, 'Spain', 'ES', 'ESP', 2),
1149
-                array(1, 'Afghanistan', 'AF', 'AFG', 1),
1150
-                array(2, 'Albania', 'AL', 'ALB', 1),
1151
-                array(3, 'Germany', 'DE', 'DEU', 2),
1152
-                array(198, 'Switzerland', 'CH', 'CHE', 1),
1153
-                array(87, 'Netherlands', 'NL', 'NLD', 2),
1154
-                array(197, 'Sweden', 'SE', 'SWE', 1),
1155
-                array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1156
-                array(4, 'Andorra', 'AD', 'AND', 2),
1157
-                array(5, 'Angola', 'AO', 'AGO', 1),
1158
-                array(6, 'Anguilla', 'AI', 'AIA', 1),
1159
-                array(7, 'Antarctica', 'AQ', 'ATA', 1),
1160
-                array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1161
-                array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1162
-                array(11, 'Algeria', 'DZ', 'DZA', 1),
1163
-                array(12, 'Argentina', 'AR', 'ARG', 1),
1164
-                array(13, 'Armenia', 'AM', 'ARM', 1),
1165
-                array(14, 'Aruba', 'AW', 'ABW', 1),
1166
-                array(16, 'Austria', 'AT', 'AUT', 2),
1167
-                array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1168
-                array(18, 'Bahamas', 'BS', 'BHS', 1),
1169
-                array(19, 'Bahrain', 'BH', 'BHR', 1),
1170
-                array(20, 'Bangladesh', 'BD', 'BGD', 1),
1171
-                array(21, 'Barbados', 'BB', 'BRB', 1),
1172
-                array(22, 'Belgium ', 'BE', 'BEL', 2),
1173
-                array(23, 'Belize', 'BZ', 'BLZ', 1),
1174
-                array(24, 'Benin', 'BJ', 'BEN', 1),
1175
-                array(25, 'Bermudas', 'BM', 'BMU', 1),
1176
-                array(26, 'Belarus', 'BY', 'BLR', 1),
1177
-                array(27, 'Bolivia', 'BO', 'BOL', 1),
1178
-                array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1179
-                array(29, 'Botswana', 'BW', 'BWA', 1),
1180
-                array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1181
-                array(30, 'Brazil', 'BR', 'BRA', 1),
1182
-                array(31, 'Brunei', 'BN', 'BRN', 1),
1183
-                array(32, 'Bulgaria', 'BG', 'BGR', 1),
1184
-                array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1185
-                array(34, 'Burundi', 'BI', 'BDI', 1),
1186
-                array(35, 'Bhutan', 'BT', 'BTN', 1),
1187
-                array(36, 'Cape Verde', 'CV', 'CPV', 1),
1188
-                array(37, 'Cambodia', 'KH', 'KHM', 1),
1189
-                array(38, 'Cameroon', 'CM', 'CMR', 1),
1190
-                array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1191
-                array(172, 'Central African Republic', 'CF', 'CAF', 1),
1192
-                array(40, 'Chad', 'TD', 'TCD', 1),
1193
-                array(41, 'Chile', 'CL', 'CHL', 1),
1194
-                array(42, 'China', 'CN', 'CHN', 1),
1195
-                array(105, 'Christmas Island', 'CX', 'CXR', 1),
1196
-                array(43, 'Cyprus', 'CY', 'CYP', 2),
1197
-                array(99, 'Cocos Island', 'CC', 'CCK', 1),
1198
-                array(100, 'Cook Islands', 'CK', 'COK', 1),
1199
-                array(44, 'Colombia', 'CO', 'COL', 1),
1200
-                array(45, 'Comoros', 'KM', 'COM', 1),
1201
-                array(46, 'Congo', 'CG', 'COG', 1),
1202
-                array(47, 'North Korea', 'KP', 'PRK', 1),
1203
-                array(50, 'Costa Rica', 'CR', 'CRI', 1),
1204
-                array(51, 'Croatia', 'HR', 'HRV', 1),
1205
-                array(52, 'Cuba', 'CU', 'CUB', 1),
1206
-                array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1207
-                array(53, 'Denmark', 'DK', 'DNK', 1),
1208
-                array(54, 'Djibouti', 'DJ', 'DJI', 1),
1209
-                array(55, 'Dominica', 'DM', 'DMA', 1),
1210
-                array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1211
-                array(56, 'Ecuador', 'EC', 'ECU', 1),
1212
-                array(57, 'Egypt', 'EG', 'EGY', 1),
1213
-                array(58, 'El Salvador', 'SV', 'SLV', 1),
1214
-                array(60, 'Eritrea', 'ER', 'ERI', 1),
1215
-                array(61, 'Slovakia', 'SK', 'SVK', 2),
1216
-                array(62, 'Slovenia', 'SI', 'SVN', 2),
1217
-                array(65, 'Estonia', 'EE', 'EST', 2),
1218
-                array(66, 'Ethiopia', 'ET', 'ETH', 1),
1219
-                array(102, 'Faroe islands', 'FO', 'FRO', 1),
1220
-                array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1221
-                array(67, 'Fiji', 'FJ', 'FJI', 1),
1222
-                array(69, 'Finland', 'FI', 'FIN', 2),
1223
-                array(71, 'Gabon', 'GA', 'GAB', 1),
1224
-                array(72, 'Gambia', 'GM', 'GMB', 1),
1225
-                array(73, 'Georgia', 'GE', 'GEO', 1),
1226
-                array(74, 'Ghana', 'GH', 'GHA', 1),
1227
-                array(75, 'Gibraltar', 'GI', 'GIB', 1),
1228
-                array(76, 'Greece', 'GR', 'GRC', 2),
1229
-                array(77, 'Grenada', 'GD', 'GRD', 1),
1230
-                array(78, 'Greenland', 'GL', 'GRL', 1),
1231
-                array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1232
-                array(80, 'Guam', 'GU', 'GUM', 1),
1233
-                array(81, 'Guatemala', 'GT', 'GTM', 1),
1234
-                array(82, 'Guinea', 'GN', 'GIN', 1),
1235
-                array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1236
-                array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1237
-                array(85, 'Guyana', 'GY', 'GUY', 1),
1238
-                array(86, 'Haiti', 'HT', 'HTI', 1),
1239
-                array(88, 'Honduras', 'HN', 'HND', 1),
1240
-                array(89, 'Hong Kong', 'HK', 'HKG', 1),
1241
-                array(90, 'Hungary', 'HU', 'HUN', 1),
1242
-                array(91, 'India', 'IN', 'IND', 1),
1243
-                array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1244
-                array(92, 'Indonesia', 'ID', 'IDN', 1),
1245
-                array(93, 'Iraq', 'IQ', 'IRQ', 1),
1246
-                array(94, 'Iran', 'IR', 'IRN', 1),
1247
-                array(95, 'Ireland', 'IE', 'IRL', 2),
1248
-                array(97, 'Iceland', 'IS', 'ISL', 1),
1249
-                array(110, 'Israel', 'IL', 'ISR', 1),
1250
-                array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1251
-                array(112, 'Jamaica', 'JM', 'JAM', 1),
1252
-                array(113, 'Japan', 'JP', 'JPN', 1),
1253
-                array(114, 'Jordan', 'JO', 'JOR', 1),
1254
-                array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1255
-                array(116, 'Kenya', 'KE', 'KEN', 1),
1256
-                array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1257
-                array(118, 'Kiribati', 'KI', 'KIR', 1),
1258
-                array(48, 'South Korea', 'KR', 'KOR', 1),
1259
-                array(228, 'Kosovo', 'XK', 'XKV', 2),
1260
-                // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1261
-                array(119, 'Kuwait', 'KW', 'KWT', 1),
1262
-                array(120, 'Laos', 'LA', 'LAO', 1),
1263
-                array(121, 'Latvia', 'LV', 'LVA', 2),
1264
-                array(122, 'Lesotho', 'LS', 'LSO', 1),
1265
-                array(123, 'Lebanon', 'LB', 'LBN', 1),
1266
-                array(124, 'Liberia', 'LR', 'LBR', 1),
1267
-                array(125, 'Libya', 'LY', 'LBY', 1),
1268
-                array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1269
-                array(127, 'Lithuania', 'LT', 'LTU', 2),
1270
-                array(128, 'Luxemburg', 'LU', 'LUX', 2),
1271
-                array(129, 'Macao', 'MO', 'MAC', 1),
1272
-                array(130, 'Macedonia', 'MK', 'MKD', 1),
1273
-                array(131, 'Madagascar', 'MG', 'MDG', 1),
1274
-                array(132, 'Malaysia', 'MY', 'MYS', 1),
1275
-                array(133, 'Malawi', 'MW', 'MWI', 1),
1276
-                array(134, 'Maldivas', 'MV', 'MDV', 1),
1277
-                array(135, 'Mali', 'ML', 'MLI', 1),
1278
-                array(136, 'Malta', 'MT', 'MLT', 2),
1279
-                array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1280
-                array(137, 'Morocco', 'MA', 'MAR', 1),
1281
-                array(104, 'Marshall islands', 'MH', 'MHL', 1),
1282
-                array(138, 'Martinique', 'MQ', 'MTQ', 1),
1283
-                array(139, 'Mauritius', 'MU', 'MUS', 1),
1284
-                array(140, 'Mauritania', 'MR', 'MRT', 1),
1285
-                array(141, 'Mayote', 'YT', 'MYT', 2),
1286
-                array(142, 'Mexico', 'MX', 'MEX', 1),
1287
-                array(143, 'Micronesia', 'FM', 'FSM', 1),
1288
-                array(144, 'Moldova', 'MD', 'MDA', 1),
1289
-                array(145, 'Monaco', 'MC', 'MCO', 2),
1290
-                array(146, 'Mongolia', 'MN', 'MNG', 1),
1291
-                array(147, 'Montserrat', 'MS', 'MSR', 1),
1292
-                array(227, 'Montenegro', 'ME', 'MNE', 2),
1293
-                array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1294
-                array(149, 'Myanmar', 'MM', 'MMR', 1),
1295
-                array(150, 'Namibia', 'NA', 'NAM', 1),
1296
-                array(151, 'Nauru', 'NR', 'NRU', 1),
1297
-                array(152, 'Nepal', 'NP', 'NPL', 1),
1298
-                array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1299
-                array(153, 'Nicaragua', 'NI', 'NIC', 1),
1300
-                array(154, 'Niger', 'NE', 'NER', 1),
1301
-                array(155, 'Nigeria', 'NG', 'NGA', 1),
1302
-                array(156, 'Niue', 'NU', 'NIU', 1),
1303
-                array(157, 'Norway', 'NO', 'NOR', 1),
1304
-                array(158, 'New Caledonia', 'NC', 'NCL', 1),
1305
-                array(159, 'New Zealand', 'NZ', 'NZL', 1),
1306
-                array(160, 'Oman', 'OM', 'OMN', 1),
1307
-                array(161, 'Pakistan', 'PK', 'PAK', 1),
1308
-                array(162, 'Palau', 'PW', 'PLW', 1),
1309
-                array(163, 'Panama', 'PA', 'PAN', 1),
1310
-                array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1311
-                array(165, 'Paraguay', 'PY', 'PRY', 1),
1312
-                array(166, 'Peru', 'PE', 'PER', 1),
1313
-                array(68, 'Philippines', 'PH', 'PHL', 1),
1314
-                array(167, 'Poland', 'PL', 'POL', 1),
1315
-                array(168, 'Portugal', 'PT', 'PRT', 2),
1316
-                array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1317
-                array(170, 'Qatar', 'QA', 'QAT', 1),
1318
-                array(176, 'Rwanda', 'RW', 'RWA', 1),
1319
-                array(177, 'Romania', 'RO', 'ROM', 2),
1320
-                array(178, 'Russia', 'RU', 'RUS', 1),
1321
-                array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1322
-                array(180, 'Samoa', 'WS', 'WSM', 1),
1323
-                array(181, 'American Samoa', 'AS', 'ASM', 1),
1324
-                array(183, 'San Marino', 'SM', 'SMR', 2),
1325
-                array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1326
-                array(185, 'Saint Helena', 'SH', 'SHN', 1),
1327
-                array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1328
-                array(188, 'Senegal', 'SN', 'SEN', 1),
1329
-                array(189, 'Seychelles', 'SC', 'SYC', 1),
1330
-                array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1331
-                array(191, 'Singapore', 'SG', 'SGP', 1),
1332
-                array(192, 'Syria', 'SY', 'SYR', 1),
1333
-                array(193, 'Somalia', 'SO', 'SOM', 1),
1334
-                array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1335
-                array(195, 'South Africa', 'ZA', 'ZAF', 1),
1336
-                array(196, 'Sudan', 'SD', 'SDN', 1),
1337
-                array(199, 'Suriname', 'SR', 'SUR', 1),
1338
-                array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1339
-                array(201, 'Thailand', 'TH', 'THA', 1),
1340
-                array(202, 'Taiwan', 'TW', 'TWN', 1),
1341
-                array(203, 'Tanzania', 'TZ', 'TZA', 1),
1342
-                array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1343
-                array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1344
-                array(207, 'Togo', 'TG', 'TGO', 1),
1345
-                array(208, 'Tokelau', 'TK', 'TKL', 1),
1346
-                array(209, 'Tonga', 'TO', 'TON', 1),
1347
-                array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1348
-                array(211, 'Tunisia', 'TN', 'TUN', 1),
1349
-                array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1350
-                array(213, 'Turkey', 'TR', 'TUR', 1),
1351
-                array(214, 'Tuvalu', 'TV', 'TUV', 1),
1352
-                array(215, 'Ukraine', 'UA', 'UKR', 1),
1353
-                array(216, 'Uganda', 'UG', 'UGA', 1),
1354
-                array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1355
-                array(217, 'Uruguay', 'UY', 'URY', 1),
1356
-                array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1357
-                array(219, 'Vanuatu', 'VU', 'VUT', 1),
1358
-                array(220, 'Vatican City', 'VA', 'VAT', 2),
1359
-                array(221, 'Venezuela', 'VE', 'VEN', 1),
1360
-                array(222, 'Vietnam', 'VN', 'VNM', 1),
1361
-                array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1362
-                array(223, 'Yemen', 'YE', 'YEM', 1),
1363
-                array(225, 'Zambia', 'ZM', 'ZMB', 1),
1364
-                array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1365
-        );
1366
-        $country_iso = 'US';
1367
-        foreach ($old_countries as $country_array) {
1368
-            // note: index 0 is the 3.1 country ID
1369
-            if ($country_array[0] == $country_id) {
1370
-                // note: index 2 is the ISO
1371
-                $country_iso = $country_array[2];
1372
-                break;
1373
-            }
1374
-        }
1375
-        return $country_iso;
1376
-    }
1377
-
1378
-
1379
-
1380
-    /**
1381
-     * Gets the ISO3 for the
1382
-     *
1383
-     * @return string
1384
-     */
1385
-    public function get_default_country_iso()
1386
-    {
1387
-        $old_org_options = get_option('events_organization_settings');
1388
-        $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1389
-        return $iso;
1390
-    }
1391
-
1392
-
1393
-
1394
-    /**
1395
-     * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1396
-     *
1397
-     * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1398
-     * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1399
-     *                                                  default payment status, the event's default payment status, or
1400
-     *                                                  the attendee's payment status) required pre-approval.
1401
-     * @return string STS_ID for use in 4.1
1402
-     */
1403
-    public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1404
-    {
1405
-        // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1406
-        if ($this_thing_required_pre_approval) {
1407
-            return 'RNA';
1408
-        } else {
1409
-            $mapping = $default_reg_stati_conversions = array(
1410
-                    'Completed'        => 'RAP',
1411
-                    ''                 => 'RPP',
1412
-                    'Incomplete'       => 'RPP',
1413
-                    'Pending'          => 'RAP',
1414
-                    // stati that only occurred on 3.1 attendees:
1415
-                    'Payment Declined' => 'RPP',
1416
-                    'Not Completed'    => 'RPP',
1417
-                    'Cancelled'        => 'RPP',
1418
-                    'Declined'         => 'RPP',
1419
-            );
1420
-        }
1421
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1428
-     * and sets it as the featured image on the CPT event
1429
-     *
1430
-     * @param type                            $old_event
1431
-     * @param type                            $new_cpt_id
1432
-     * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1433
-     * @return boolean whether or not we had to do the big job of creating an image attachment
1434
-     */
1435
-    public function convert_image_url_to_attachment_and_attach_to_post(
1436
-        $guid,
1437
-        $new_cpt_id,
1438
-        EE_Data_Migration_Script_Stage $migration_stage
1439
-    ) {
1440
-        $created_attachment_post = false;
1441
-        $guid = $this->_get_original_guid($guid);
1442
-        if ($guid) {
1443
-            // check for an existing attachment post with this guid
1444
-            $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1445
-            if (! $attachment_post_id) {
1446
-                // post thumbnail with that GUID doesn't exist, we should create one
1447
-                $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1448
-                $created_attachment_post = true;
1449
-            }
1450
-            // double-check we actually have an attachment post
1451
-            if ($attachment_post_id) {
1452
-                update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1453
-            } else {
1454
-                $migration_stage->add_error(sprintf(esc_html__(
1455
-                    "Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1456
-                    "event_espresso"
1457
-                ), $guid, $new_cpt_id, $attachment_post_id));
1458
-            }
1459
-        }
1460
-        return $created_attachment_post;
1461
-    }
1462
-
1463
-
1464
-
1465
-    /**
1466
-     * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1467
-     * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1468
-     * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1469
-     * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1470
-     * exists
1471
-     *
1472
-     * @param string $guid_in_old_event
1473
-     * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1474
-     */
1475
-    private function _get_original_guid($guid_in_old_event)
1476
-    {
1477
-        $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1478
-        // do a head request to verify the file exists
1479
-        $head_response = wp_remote_head($original_guid);
1480
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1481
-            return $original_guid;
1482
-        } else {
1483
-            return $guid_in_old_event;
1484
-        }
1485
-    }
1486
-
1487
-
1488
-
1489
-    /**
1490
-     * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1491
-     * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1492
-     * thumbnails)
1493
-     *
1494
-     * @param type                           $guid
1495
-     * @param EE_Data_Migration_Script_Stage $migration_stage
1496
-     * @return int
1497
-     */
1498
-    private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1499
-    {
1500
-        if (! $guid) {
1501
-            $migration_stage->add_error(sprintf(esc_html__(
1502
-                "Cannot create image attachment for a blank GUID!",
1503
-                "event_espresso"
1504
-            )));
1505
-            return 0;
1506
-        }
1507
-        $wp_filetype = wp_check_filetype(basename($guid), null);
1508
-        $wp_upload_dir = wp_upload_dir();
1509
-        // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1510
-        if (strpos($guid, $wp_upload_dir['url']) === false) {
1511
-            // image is located remotely. download it and place it in the uploads directory
1512
-            if (! is_readable($guid)) {
1513
-                $migration_stage->add_error(sprintf(esc_html__(
1514
-                    "Could not create image attachment from non-existent file: %s",
1515
-                    "event_espresso"
1516
-                ), $guid));
1517
-                return 0;
1518
-            }
1519
-            $contents = file_get_contents($guid);
1520
-            if ($contents === false) {
1521
-                $migration_stage->add_error(sprintf(esc_html__(
1522
-                    "Could not read image at %s, and therefore couldnt create an attachment post for it.",
1523
-                    "event_espresso"
1524
-                ), $guid));
1525
-                return false;
1526
-            }
1527
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1528
-            $savefile = fopen($local_filepath, 'w');
1529
-            fwrite($savefile, $contents);
1530
-            fclose($savefile);
1531
-            $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1532
-        } else {
1533
-            $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1534
-        }
1535
-        $attachment = array(
1536
-                'guid'           => $guid,
1537
-                'post_mime_type' => $wp_filetype['type'],
1538
-                'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1539
-                'post_content'   => '',
1540
-                'post_status'    => 'inherit',
1541
-        );
1542
-        $attach_id = wp_insert_attachment($attachment, $guid);
1543
-        if (! $attach_id) {
1544
-            $migration_stage->add_error(sprintf(esc_html__(
1545
-                "Could not create image attachment post from image '%s'. Attachment data was %s.",
1546
-                "event_espresso"
1547
-            ), $guid, $this->_json_encode($attachment)));
1548
-            return $attach_id;
1549
-        }
1550
-        // you must first include the image.php file
1551
-        // for the function wp_generate_attachment_metadata() to work
1552
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1553
-        $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1554
-        if (! $attach_data) {
1555
-            $migration_stage->add_error(sprintf(esc_html__(
1556
-                "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1557
-                "event_espresso"
1558
-            ), $attach_id, $local_filepath, $guid));
1559
-            return $attach_id;
1560
-        }
1561
-        $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1562
-        if (! $metadata_save_result) {
1563
-            $migration_stage->add_error(sprintf(esc_html__(
1564
-                "Could not update attachment metadata for attachment %d with data %s",
1565
-                "event_espresso"
1566
-            ), $attach_id, $this->_json_encode($attach_data)));
1567
-        }
1568
-        return $attach_id;
1569
-    }
1570
-
1571
-
1572
-
1573
-    /**
1574
-     * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1575
-     * and returns its ID.
1576
-     *
1577
-     * @global type  $wpdb
1578
-     * @param string $guid
1579
-     * @return int
1580
-     */
1581
-    private function _get_image_attachment_id_by_GUID($guid)
1582
-    {
1583
-        global $wpdb;
1584
-        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1585
-        return $attachment_id;
1586
-    }
1587
-
1588
-
1589
-
1590
-    /**
1591
-     * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1592
-     * (and optionally a timezone; if none is given, the wp default is used)
1593
-     *
1594
-     * @param EE_Data_Migration_Script_base $stage
1595
-     * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1596
-     *                                                   UTC time for
1597
-     * @param string                        $DATETIME_string
1598
-     * @param string                        $timezone
1599
-     * @return string
1600
-     */
1601
-    public function convert_date_string_to_utc(
1602
-        EE_Data_Migration_Script_Stage $stage,
1603
-        $row_of_data,
1604
-        $DATETIME_string,
1605
-        $timezone = null
1606
-    ) {
1607
-        $original_tz = $timezone;
1608
-        if (! $timezone) {
1609
-            $timezone = $this->_get_wp_timezone();
1610
-        }
1611
-        if (! $timezone) {
1612
-            $stage->add_error(sprintf(
1613
-                esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1614
-                $original_tz,
1615
-                $row_of_data
1616
-            ));
1617
-            $timezone = 'UTC';
1618
-        }
1619
-        try {
1620
-            $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1621
-            EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1622
-        } catch (Exception $e) {
1623
-            $stage->add_error(sprintf(esc_html__(
1624
-                "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1625
-                "event_espresso"
1626
-            ), $DATETIME_string, $timezone));
1627
-            $date_obj = new DateTime();
1628
-        }
1629
-        return $date_obj->format('Y-m-d H:i:s');
1630
-    }
1631
-
1632
-
1633
-
1634
-    /**
1635
-     * Gets the default timezone string from wordpress (even if they set a gmt offset)
1636
-     *
1637
-     * @return string
1638
-     */
1639
-    private function _get_wp_timezone()
1640
-    {
1641
-        $timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1642
-        // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1643
-        if (empty($timezone)) {
1644
-            // let's get a the WordPress UTC offset
1645
-            $offset = get_option('gmt_offset');
1646
-            $timezone = $this->timezone_convert_to_string_from_offset($offset);
1647
-        }
1648
-        return $timezone;
1649
-    }
1650
-
1651
-
1652
-
1653
-    /**
1654
-     * Gets the wordpress timezone string from a UTC offset
1655
-     *
1656
-     * @param int $offset
1657
-     * @return boolean
1658
-     */
1659
-    private function timezone_convert_to_string_from_offset($offset)
1660
-    {
1661
-        // 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
1662
-        $offset *= 3600; // convert hour offset to seconds
1663
-        $abbrarray = timezone_abbreviations_list();
1664
-        foreach ($abbrarray as $abbr) {
1665
-            foreach ($abbr as $city) {
1666
-                if ($city['offset'] == $offset) {
1667
-                    return $city['timezone_id'];
1668
-                }
1669
-            }
1670
-        }
1671
-        return false;
1672
-    }
1673
-
1674
-
1675
-
1676
-    public function migration_page_hooks()
1677
-    {
1678
-        add_filter(
1679
-            'FHEE__ee_migration_page__header',
1680
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1681
-            10,
1682
-            3
1683
-        );
1684
-        add_filter(
1685
-            'FHEE__ee_migration_page__p_after_header',
1686
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1687
-            10,
1688
-            2
1689
-        );
1690
-        add_filter(
1691
-            'FHEE__ee_migration_page__option_1_main',
1692
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1693
-            10,
1694
-            3
1695
-        );
1696
-        add_filter(
1697
-            'FHEE__ee_migration_page__option_1_button_text',
1698
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1699
-            10,
1700
-            3
1701
-        );
1702
-        add_action(
1703
-            'AHEE__ee_migration_page__option_1_extra_details',
1704
-            array($this, '_migration_page_hook_option_1_extra_details'),
1705
-            10,
1706
-            3
1707
-        );
1708
-        add_filter(
1709
-            'FHEE__ee_migration_page__option_2_main',
1710
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1711
-            10,
1712
-            4
1713
-        );
1714
-        add_filter(
1715
-            'FHEE__ee_migration_page__option_2_button_text',
1716
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1717
-            10,
1718
-            2
1719
-        );
1720
-        add_filter(
1721
-            'FHEE__ee_migration_page__option_2_details',
1722
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1723
-            10,
1724
-            2
1725
-        );
1726
-        add_action(
1727
-            'AHEE__ee_migration_page__after_migration_options_table',
1728
-            array($this, '_migration_page_hook_after_migration_options_table')
1729
-        );
1730
-        add_filter(
1731
-            'FHEE__ee_migration_page__done_migration_header',
1732
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1733
-            10,
1734
-            2
1735
-        );
1736
-        add_filter(
1737
-            'FHEE__ee_migration_page__p_after_done_migration_header',
1738
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1739
-            10,
1740
-            2
1741
-        );
1742
-        add_filter(
1743
-            'FHEE__ee_migration_page__migration_options_template',
1744
-            array($this,'use_migration_options_from_ee3_template')
1745
-        );
1746
-    }
1747
-
1748
-
1749
-
1750
-    public function _migrate_page_hook_simplify_version_strings(
1751
-        $old_content,
1752
-        $current_db_state,
1753
-        $next_db_state,
1754
-        $ultimate_db_state = null
1755
-    ) {
1756
-        return str_replace(
1757
-            array($current_db_state, $next_db_state, $ultimate_db_state),
1758
-            array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1759
-            $old_content
1760
-        );
1761
-    }
1762
-
1763
-
1764
-
1765
-    public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1766
-    {
1767
-        return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1768
-    }
1769
-
1770
-
1771
-
1772
-    public function _migration_page_hook_option_1_extra_details()
1773
-    {
1774
-        ?>
1072
+		if (! $state) {
1073
+			// insert a new one then
1074
+			$cols_n_values = array(
1075
+					'CNT_ISO'    => $country_iso,
1076
+					'STA_abbrev' => substr($state_name, 0, 6),
1077
+					'STA_name'   => $state_name,
1078
+					'STA_active' => true,
1079
+			);
1080
+			$data_types = array(
1081
+					'%s',// CNT_ISO
1082
+					'%s',// STA_abbrev
1083
+					'%s',// STA_name
1084
+					'%d',// STA_active
1085
+			);
1086
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1087
+			if (! $success) {
1088
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1089
+					'N/A',
1090
+					array('state' => $state_name, 'country_id' => $country_name),
1091
+					$state_table,
1092
+					$cols_n_values,
1093
+					$data_types
1094
+				));
1095
+			}
1096
+			$state = $cols_n_values;
1097
+			$state['STA_ID'] = $wpdb->insert_id;
1098
+		}
1099
+		return $state;
1100
+	}
1101
+
1102
+
1103
+
1104
+	/**
1105
+	 * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1106
+	 * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1107
+	 *
1108
+	 * @param type $timeString
1109
+	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1110
+	 *                with leading zeros)
1111
+	 */
1112
+	public function convertTimeFromAMPM($timeString)
1113
+	{
1114
+		$matches = array();
1115
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1116
+		if (! $matches || count($matches) < 3) {
1117
+			$hour = '00';
1118
+			$minutes = '00';
1119
+		} else {
1120
+			$hour = intval($matches[1]);
1121
+			$minutes = $matches[2];
1122
+		}
1123
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1124
+			$hour = intval($hour) + 12;
1125
+		}
1126
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1127
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1128
+		return "$hour:$minutes";
1129
+	}
1130
+
1131
+
1132
+
1133
+	/**
1134
+	 * Gets the ISO3 fora country given its 3.1 country ID.
1135
+	 *
1136
+	 * @param int $country_id
1137
+	 * @return string the country's ISO3 code
1138
+	 */
1139
+	public function get_iso_from_3_1_country_id($country_id)
1140
+	{
1141
+		$old_countries = array(
1142
+				array(64, 'United States', 'US', 'USA', 1),
1143
+				array(15, 'Australia', 'AU', 'AUS', 1),
1144
+				array(39, 'Canada', 'CA', 'CAN', 1),
1145
+				array(171, 'United Kingdom', 'GB', 'GBR', 1),
1146
+				array(70, 'France', 'FR', 'FRA', 2),
1147
+				array(111, 'Italy', 'IT', 'ITA', 2),
1148
+				array(63, 'Spain', 'ES', 'ESP', 2),
1149
+				array(1, 'Afghanistan', 'AF', 'AFG', 1),
1150
+				array(2, 'Albania', 'AL', 'ALB', 1),
1151
+				array(3, 'Germany', 'DE', 'DEU', 2),
1152
+				array(198, 'Switzerland', 'CH', 'CHE', 1),
1153
+				array(87, 'Netherlands', 'NL', 'NLD', 2),
1154
+				array(197, 'Sweden', 'SE', 'SWE', 1),
1155
+				array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1156
+				array(4, 'Andorra', 'AD', 'AND', 2),
1157
+				array(5, 'Angola', 'AO', 'AGO', 1),
1158
+				array(6, 'Anguilla', 'AI', 'AIA', 1),
1159
+				array(7, 'Antarctica', 'AQ', 'ATA', 1),
1160
+				array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1161
+				array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1162
+				array(11, 'Algeria', 'DZ', 'DZA', 1),
1163
+				array(12, 'Argentina', 'AR', 'ARG', 1),
1164
+				array(13, 'Armenia', 'AM', 'ARM', 1),
1165
+				array(14, 'Aruba', 'AW', 'ABW', 1),
1166
+				array(16, 'Austria', 'AT', 'AUT', 2),
1167
+				array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1168
+				array(18, 'Bahamas', 'BS', 'BHS', 1),
1169
+				array(19, 'Bahrain', 'BH', 'BHR', 1),
1170
+				array(20, 'Bangladesh', 'BD', 'BGD', 1),
1171
+				array(21, 'Barbados', 'BB', 'BRB', 1),
1172
+				array(22, 'Belgium ', 'BE', 'BEL', 2),
1173
+				array(23, 'Belize', 'BZ', 'BLZ', 1),
1174
+				array(24, 'Benin', 'BJ', 'BEN', 1),
1175
+				array(25, 'Bermudas', 'BM', 'BMU', 1),
1176
+				array(26, 'Belarus', 'BY', 'BLR', 1),
1177
+				array(27, 'Bolivia', 'BO', 'BOL', 1),
1178
+				array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1179
+				array(29, 'Botswana', 'BW', 'BWA', 1),
1180
+				array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1181
+				array(30, 'Brazil', 'BR', 'BRA', 1),
1182
+				array(31, 'Brunei', 'BN', 'BRN', 1),
1183
+				array(32, 'Bulgaria', 'BG', 'BGR', 1),
1184
+				array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1185
+				array(34, 'Burundi', 'BI', 'BDI', 1),
1186
+				array(35, 'Bhutan', 'BT', 'BTN', 1),
1187
+				array(36, 'Cape Verde', 'CV', 'CPV', 1),
1188
+				array(37, 'Cambodia', 'KH', 'KHM', 1),
1189
+				array(38, 'Cameroon', 'CM', 'CMR', 1),
1190
+				array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1191
+				array(172, 'Central African Republic', 'CF', 'CAF', 1),
1192
+				array(40, 'Chad', 'TD', 'TCD', 1),
1193
+				array(41, 'Chile', 'CL', 'CHL', 1),
1194
+				array(42, 'China', 'CN', 'CHN', 1),
1195
+				array(105, 'Christmas Island', 'CX', 'CXR', 1),
1196
+				array(43, 'Cyprus', 'CY', 'CYP', 2),
1197
+				array(99, 'Cocos Island', 'CC', 'CCK', 1),
1198
+				array(100, 'Cook Islands', 'CK', 'COK', 1),
1199
+				array(44, 'Colombia', 'CO', 'COL', 1),
1200
+				array(45, 'Comoros', 'KM', 'COM', 1),
1201
+				array(46, 'Congo', 'CG', 'COG', 1),
1202
+				array(47, 'North Korea', 'KP', 'PRK', 1),
1203
+				array(50, 'Costa Rica', 'CR', 'CRI', 1),
1204
+				array(51, 'Croatia', 'HR', 'HRV', 1),
1205
+				array(52, 'Cuba', 'CU', 'CUB', 1),
1206
+				array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1207
+				array(53, 'Denmark', 'DK', 'DNK', 1),
1208
+				array(54, 'Djibouti', 'DJ', 'DJI', 1),
1209
+				array(55, 'Dominica', 'DM', 'DMA', 1),
1210
+				array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1211
+				array(56, 'Ecuador', 'EC', 'ECU', 1),
1212
+				array(57, 'Egypt', 'EG', 'EGY', 1),
1213
+				array(58, 'El Salvador', 'SV', 'SLV', 1),
1214
+				array(60, 'Eritrea', 'ER', 'ERI', 1),
1215
+				array(61, 'Slovakia', 'SK', 'SVK', 2),
1216
+				array(62, 'Slovenia', 'SI', 'SVN', 2),
1217
+				array(65, 'Estonia', 'EE', 'EST', 2),
1218
+				array(66, 'Ethiopia', 'ET', 'ETH', 1),
1219
+				array(102, 'Faroe islands', 'FO', 'FRO', 1),
1220
+				array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1221
+				array(67, 'Fiji', 'FJ', 'FJI', 1),
1222
+				array(69, 'Finland', 'FI', 'FIN', 2),
1223
+				array(71, 'Gabon', 'GA', 'GAB', 1),
1224
+				array(72, 'Gambia', 'GM', 'GMB', 1),
1225
+				array(73, 'Georgia', 'GE', 'GEO', 1),
1226
+				array(74, 'Ghana', 'GH', 'GHA', 1),
1227
+				array(75, 'Gibraltar', 'GI', 'GIB', 1),
1228
+				array(76, 'Greece', 'GR', 'GRC', 2),
1229
+				array(77, 'Grenada', 'GD', 'GRD', 1),
1230
+				array(78, 'Greenland', 'GL', 'GRL', 1),
1231
+				array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1232
+				array(80, 'Guam', 'GU', 'GUM', 1),
1233
+				array(81, 'Guatemala', 'GT', 'GTM', 1),
1234
+				array(82, 'Guinea', 'GN', 'GIN', 1),
1235
+				array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1236
+				array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1237
+				array(85, 'Guyana', 'GY', 'GUY', 1),
1238
+				array(86, 'Haiti', 'HT', 'HTI', 1),
1239
+				array(88, 'Honduras', 'HN', 'HND', 1),
1240
+				array(89, 'Hong Kong', 'HK', 'HKG', 1),
1241
+				array(90, 'Hungary', 'HU', 'HUN', 1),
1242
+				array(91, 'India', 'IN', 'IND', 1),
1243
+				array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1244
+				array(92, 'Indonesia', 'ID', 'IDN', 1),
1245
+				array(93, 'Iraq', 'IQ', 'IRQ', 1),
1246
+				array(94, 'Iran', 'IR', 'IRN', 1),
1247
+				array(95, 'Ireland', 'IE', 'IRL', 2),
1248
+				array(97, 'Iceland', 'IS', 'ISL', 1),
1249
+				array(110, 'Israel', 'IL', 'ISR', 1),
1250
+				array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1251
+				array(112, 'Jamaica', 'JM', 'JAM', 1),
1252
+				array(113, 'Japan', 'JP', 'JPN', 1),
1253
+				array(114, 'Jordan', 'JO', 'JOR', 1),
1254
+				array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1255
+				array(116, 'Kenya', 'KE', 'KEN', 1),
1256
+				array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1257
+				array(118, 'Kiribati', 'KI', 'KIR', 1),
1258
+				array(48, 'South Korea', 'KR', 'KOR', 1),
1259
+				array(228, 'Kosovo', 'XK', 'XKV', 2),
1260
+				// there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1261
+				array(119, 'Kuwait', 'KW', 'KWT', 1),
1262
+				array(120, 'Laos', 'LA', 'LAO', 1),
1263
+				array(121, 'Latvia', 'LV', 'LVA', 2),
1264
+				array(122, 'Lesotho', 'LS', 'LSO', 1),
1265
+				array(123, 'Lebanon', 'LB', 'LBN', 1),
1266
+				array(124, 'Liberia', 'LR', 'LBR', 1),
1267
+				array(125, 'Libya', 'LY', 'LBY', 1),
1268
+				array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1269
+				array(127, 'Lithuania', 'LT', 'LTU', 2),
1270
+				array(128, 'Luxemburg', 'LU', 'LUX', 2),
1271
+				array(129, 'Macao', 'MO', 'MAC', 1),
1272
+				array(130, 'Macedonia', 'MK', 'MKD', 1),
1273
+				array(131, 'Madagascar', 'MG', 'MDG', 1),
1274
+				array(132, 'Malaysia', 'MY', 'MYS', 1),
1275
+				array(133, 'Malawi', 'MW', 'MWI', 1),
1276
+				array(134, 'Maldivas', 'MV', 'MDV', 1),
1277
+				array(135, 'Mali', 'ML', 'MLI', 1),
1278
+				array(136, 'Malta', 'MT', 'MLT', 2),
1279
+				array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1280
+				array(137, 'Morocco', 'MA', 'MAR', 1),
1281
+				array(104, 'Marshall islands', 'MH', 'MHL', 1),
1282
+				array(138, 'Martinique', 'MQ', 'MTQ', 1),
1283
+				array(139, 'Mauritius', 'MU', 'MUS', 1),
1284
+				array(140, 'Mauritania', 'MR', 'MRT', 1),
1285
+				array(141, 'Mayote', 'YT', 'MYT', 2),
1286
+				array(142, 'Mexico', 'MX', 'MEX', 1),
1287
+				array(143, 'Micronesia', 'FM', 'FSM', 1),
1288
+				array(144, 'Moldova', 'MD', 'MDA', 1),
1289
+				array(145, 'Monaco', 'MC', 'MCO', 2),
1290
+				array(146, 'Mongolia', 'MN', 'MNG', 1),
1291
+				array(147, 'Montserrat', 'MS', 'MSR', 1),
1292
+				array(227, 'Montenegro', 'ME', 'MNE', 2),
1293
+				array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1294
+				array(149, 'Myanmar', 'MM', 'MMR', 1),
1295
+				array(150, 'Namibia', 'NA', 'NAM', 1),
1296
+				array(151, 'Nauru', 'NR', 'NRU', 1),
1297
+				array(152, 'Nepal', 'NP', 'NPL', 1),
1298
+				array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1299
+				array(153, 'Nicaragua', 'NI', 'NIC', 1),
1300
+				array(154, 'Niger', 'NE', 'NER', 1),
1301
+				array(155, 'Nigeria', 'NG', 'NGA', 1),
1302
+				array(156, 'Niue', 'NU', 'NIU', 1),
1303
+				array(157, 'Norway', 'NO', 'NOR', 1),
1304
+				array(158, 'New Caledonia', 'NC', 'NCL', 1),
1305
+				array(159, 'New Zealand', 'NZ', 'NZL', 1),
1306
+				array(160, 'Oman', 'OM', 'OMN', 1),
1307
+				array(161, 'Pakistan', 'PK', 'PAK', 1),
1308
+				array(162, 'Palau', 'PW', 'PLW', 1),
1309
+				array(163, 'Panama', 'PA', 'PAN', 1),
1310
+				array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1311
+				array(165, 'Paraguay', 'PY', 'PRY', 1),
1312
+				array(166, 'Peru', 'PE', 'PER', 1),
1313
+				array(68, 'Philippines', 'PH', 'PHL', 1),
1314
+				array(167, 'Poland', 'PL', 'POL', 1),
1315
+				array(168, 'Portugal', 'PT', 'PRT', 2),
1316
+				array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1317
+				array(170, 'Qatar', 'QA', 'QAT', 1),
1318
+				array(176, 'Rwanda', 'RW', 'RWA', 1),
1319
+				array(177, 'Romania', 'RO', 'ROM', 2),
1320
+				array(178, 'Russia', 'RU', 'RUS', 1),
1321
+				array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1322
+				array(180, 'Samoa', 'WS', 'WSM', 1),
1323
+				array(181, 'American Samoa', 'AS', 'ASM', 1),
1324
+				array(183, 'San Marino', 'SM', 'SMR', 2),
1325
+				array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1326
+				array(185, 'Saint Helena', 'SH', 'SHN', 1),
1327
+				array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1328
+				array(188, 'Senegal', 'SN', 'SEN', 1),
1329
+				array(189, 'Seychelles', 'SC', 'SYC', 1),
1330
+				array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1331
+				array(191, 'Singapore', 'SG', 'SGP', 1),
1332
+				array(192, 'Syria', 'SY', 'SYR', 1),
1333
+				array(193, 'Somalia', 'SO', 'SOM', 1),
1334
+				array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1335
+				array(195, 'South Africa', 'ZA', 'ZAF', 1),
1336
+				array(196, 'Sudan', 'SD', 'SDN', 1),
1337
+				array(199, 'Suriname', 'SR', 'SUR', 1),
1338
+				array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1339
+				array(201, 'Thailand', 'TH', 'THA', 1),
1340
+				array(202, 'Taiwan', 'TW', 'TWN', 1),
1341
+				array(203, 'Tanzania', 'TZ', 'TZA', 1),
1342
+				array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1343
+				array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1344
+				array(207, 'Togo', 'TG', 'TGO', 1),
1345
+				array(208, 'Tokelau', 'TK', 'TKL', 1),
1346
+				array(209, 'Tonga', 'TO', 'TON', 1),
1347
+				array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1348
+				array(211, 'Tunisia', 'TN', 'TUN', 1),
1349
+				array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1350
+				array(213, 'Turkey', 'TR', 'TUR', 1),
1351
+				array(214, 'Tuvalu', 'TV', 'TUV', 1),
1352
+				array(215, 'Ukraine', 'UA', 'UKR', 1),
1353
+				array(216, 'Uganda', 'UG', 'UGA', 1),
1354
+				array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1355
+				array(217, 'Uruguay', 'UY', 'URY', 1),
1356
+				array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1357
+				array(219, 'Vanuatu', 'VU', 'VUT', 1),
1358
+				array(220, 'Vatican City', 'VA', 'VAT', 2),
1359
+				array(221, 'Venezuela', 'VE', 'VEN', 1),
1360
+				array(222, 'Vietnam', 'VN', 'VNM', 1),
1361
+				array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1362
+				array(223, 'Yemen', 'YE', 'YEM', 1),
1363
+				array(225, 'Zambia', 'ZM', 'ZMB', 1),
1364
+				array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1365
+		);
1366
+		$country_iso = 'US';
1367
+		foreach ($old_countries as $country_array) {
1368
+			// note: index 0 is the 3.1 country ID
1369
+			if ($country_array[0] == $country_id) {
1370
+				// note: index 2 is the ISO
1371
+				$country_iso = $country_array[2];
1372
+				break;
1373
+			}
1374
+		}
1375
+		return $country_iso;
1376
+	}
1377
+
1378
+
1379
+
1380
+	/**
1381
+	 * Gets the ISO3 for the
1382
+	 *
1383
+	 * @return string
1384
+	 */
1385
+	public function get_default_country_iso()
1386
+	{
1387
+		$old_org_options = get_option('events_organization_settings');
1388
+		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1389
+		return $iso;
1390
+	}
1391
+
1392
+
1393
+
1394
+	/**
1395
+	 * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1396
+	 *
1397
+	 * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1398
+	 * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1399
+	 *                                                  default payment status, the event's default payment status, or
1400
+	 *                                                  the attendee's payment status) required pre-approval.
1401
+	 * @return string STS_ID for use in 4.1
1402
+	 */
1403
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1404
+	{
1405
+		// EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1406
+		if ($this_thing_required_pre_approval) {
1407
+			return 'RNA';
1408
+		} else {
1409
+			$mapping = $default_reg_stati_conversions = array(
1410
+					'Completed'        => 'RAP',
1411
+					''                 => 'RPP',
1412
+					'Incomplete'       => 'RPP',
1413
+					'Pending'          => 'RAP',
1414
+					// stati that only occurred on 3.1 attendees:
1415
+					'Payment Declined' => 'RPP',
1416
+					'Not Completed'    => 'RPP',
1417
+					'Cancelled'        => 'RPP',
1418
+					'Declined'         => 'RPP',
1419
+			);
1420
+		}
1421
+		return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1428
+	 * and sets it as the featured image on the CPT event
1429
+	 *
1430
+	 * @param type                            $old_event
1431
+	 * @param type                            $new_cpt_id
1432
+	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1433
+	 * @return boolean whether or not we had to do the big job of creating an image attachment
1434
+	 */
1435
+	public function convert_image_url_to_attachment_and_attach_to_post(
1436
+		$guid,
1437
+		$new_cpt_id,
1438
+		EE_Data_Migration_Script_Stage $migration_stage
1439
+	) {
1440
+		$created_attachment_post = false;
1441
+		$guid = $this->_get_original_guid($guid);
1442
+		if ($guid) {
1443
+			// check for an existing attachment post with this guid
1444
+			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1445
+			if (! $attachment_post_id) {
1446
+				// post thumbnail with that GUID doesn't exist, we should create one
1447
+				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1448
+				$created_attachment_post = true;
1449
+			}
1450
+			// double-check we actually have an attachment post
1451
+			if ($attachment_post_id) {
1452
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1453
+			} else {
1454
+				$migration_stage->add_error(sprintf(esc_html__(
1455
+					"Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1456
+					"event_espresso"
1457
+				), $guid, $new_cpt_id, $attachment_post_id));
1458
+			}
1459
+		}
1460
+		return $created_attachment_post;
1461
+	}
1462
+
1463
+
1464
+
1465
+	/**
1466
+	 * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1467
+	 * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1468
+	 * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1469
+	 * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1470
+	 * exists
1471
+	 *
1472
+	 * @param string $guid_in_old_event
1473
+	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1474
+	 */
1475
+	private function _get_original_guid($guid_in_old_event)
1476
+	{
1477
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1478
+		// do a head request to verify the file exists
1479
+		$head_response = wp_remote_head($original_guid);
1480
+		if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1481
+			return $original_guid;
1482
+		} else {
1483
+			return $guid_in_old_event;
1484
+		}
1485
+	}
1486
+
1487
+
1488
+
1489
+	/**
1490
+	 * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1491
+	 * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1492
+	 * thumbnails)
1493
+	 *
1494
+	 * @param type                           $guid
1495
+	 * @param EE_Data_Migration_Script_Stage $migration_stage
1496
+	 * @return int
1497
+	 */
1498
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1499
+	{
1500
+		if (! $guid) {
1501
+			$migration_stage->add_error(sprintf(esc_html__(
1502
+				"Cannot create image attachment for a blank GUID!",
1503
+				"event_espresso"
1504
+			)));
1505
+			return 0;
1506
+		}
1507
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1508
+		$wp_upload_dir = wp_upload_dir();
1509
+		// if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1510
+		if (strpos($guid, $wp_upload_dir['url']) === false) {
1511
+			// image is located remotely. download it and place it in the uploads directory
1512
+			if (! is_readable($guid)) {
1513
+				$migration_stage->add_error(sprintf(esc_html__(
1514
+					"Could not create image attachment from non-existent file: %s",
1515
+					"event_espresso"
1516
+				), $guid));
1517
+				return 0;
1518
+			}
1519
+			$contents = file_get_contents($guid);
1520
+			if ($contents === false) {
1521
+				$migration_stage->add_error(sprintf(esc_html__(
1522
+					"Could not read image at %s, and therefore couldnt create an attachment post for it.",
1523
+					"event_espresso"
1524
+				), $guid));
1525
+				return false;
1526
+			}
1527
+			$local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1528
+			$savefile = fopen($local_filepath, 'w');
1529
+			fwrite($savefile, $contents);
1530
+			fclose($savefile);
1531
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1532
+		} else {
1533
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1534
+		}
1535
+		$attachment = array(
1536
+				'guid'           => $guid,
1537
+				'post_mime_type' => $wp_filetype['type'],
1538
+				'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1539
+				'post_content'   => '',
1540
+				'post_status'    => 'inherit',
1541
+		);
1542
+		$attach_id = wp_insert_attachment($attachment, $guid);
1543
+		if (! $attach_id) {
1544
+			$migration_stage->add_error(sprintf(esc_html__(
1545
+				"Could not create image attachment post from image '%s'. Attachment data was %s.",
1546
+				"event_espresso"
1547
+			), $guid, $this->_json_encode($attachment)));
1548
+			return $attach_id;
1549
+		}
1550
+		// you must first include the image.php file
1551
+		// for the function wp_generate_attachment_metadata() to work
1552
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1553
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1554
+		if (! $attach_data) {
1555
+			$migration_stage->add_error(sprintf(esc_html__(
1556
+				"Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1557
+				"event_espresso"
1558
+			), $attach_id, $local_filepath, $guid));
1559
+			return $attach_id;
1560
+		}
1561
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1562
+		if (! $metadata_save_result) {
1563
+			$migration_stage->add_error(sprintf(esc_html__(
1564
+				"Could not update attachment metadata for attachment %d with data %s",
1565
+				"event_espresso"
1566
+			), $attach_id, $this->_json_encode($attach_data)));
1567
+		}
1568
+		return $attach_id;
1569
+	}
1570
+
1571
+
1572
+
1573
+	/**
1574
+	 * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1575
+	 * and returns its ID.
1576
+	 *
1577
+	 * @global type  $wpdb
1578
+	 * @param string $guid
1579
+	 * @return int
1580
+	 */
1581
+	private function _get_image_attachment_id_by_GUID($guid)
1582
+	{
1583
+		global $wpdb;
1584
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1585
+		return $attachment_id;
1586
+	}
1587
+
1588
+
1589
+
1590
+	/**
1591
+	 * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1592
+	 * (and optionally a timezone; if none is given, the wp default is used)
1593
+	 *
1594
+	 * @param EE_Data_Migration_Script_base $stage
1595
+	 * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1596
+	 *                                                   UTC time for
1597
+	 * @param string                        $DATETIME_string
1598
+	 * @param string                        $timezone
1599
+	 * @return string
1600
+	 */
1601
+	public function convert_date_string_to_utc(
1602
+		EE_Data_Migration_Script_Stage $stage,
1603
+		$row_of_data,
1604
+		$DATETIME_string,
1605
+		$timezone = null
1606
+	) {
1607
+		$original_tz = $timezone;
1608
+		if (! $timezone) {
1609
+			$timezone = $this->_get_wp_timezone();
1610
+		}
1611
+		if (! $timezone) {
1612
+			$stage->add_error(sprintf(
1613
+				esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1614
+				$original_tz,
1615
+				$row_of_data
1616
+			));
1617
+			$timezone = 'UTC';
1618
+		}
1619
+		try {
1620
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1621
+			EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1622
+		} catch (Exception $e) {
1623
+			$stage->add_error(sprintf(esc_html__(
1624
+				"Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1625
+				"event_espresso"
1626
+			), $DATETIME_string, $timezone));
1627
+			$date_obj = new DateTime();
1628
+		}
1629
+		return $date_obj->format('Y-m-d H:i:s');
1630
+	}
1631
+
1632
+
1633
+
1634
+	/**
1635
+	 * Gets the default timezone string from wordpress (even if they set a gmt offset)
1636
+	 *
1637
+	 * @return string
1638
+	 */
1639
+	private function _get_wp_timezone()
1640
+	{
1641
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1642
+		// if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1643
+		if (empty($timezone)) {
1644
+			// let's get a the WordPress UTC offset
1645
+			$offset = get_option('gmt_offset');
1646
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1647
+		}
1648
+		return $timezone;
1649
+	}
1650
+
1651
+
1652
+
1653
+	/**
1654
+	 * Gets the wordpress timezone string from a UTC offset
1655
+	 *
1656
+	 * @param int $offset
1657
+	 * @return boolean
1658
+	 */
1659
+	private function timezone_convert_to_string_from_offset($offset)
1660
+	{
1661
+		// 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
1662
+		$offset *= 3600; // convert hour offset to seconds
1663
+		$abbrarray = timezone_abbreviations_list();
1664
+		foreach ($abbrarray as $abbr) {
1665
+			foreach ($abbr as $city) {
1666
+				if ($city['offset'] == $offset) {
1667
+					return $city['timezone_id'];
1668
+				}
1669
+			}
1670
+		}
1671
+		return false;
1672
+	}
1673
+
1674
+
1675
+
1676
+	public function migration_page_hooks()
1677
+	{
1678
+		add_filter(
1679
+			'FHEE__ee_migration_page__header',
1680
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1681
+			10,
1682
+			3
1683
+		);
1684
+		add_filter(
1685
+			'FHEE__ee_migration_page__p_after_header',
1686
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1687
+			10,
1688
+			2
1689
+		);
1690
+		add_filter(
1691
+			'FHEE__ee_migration_page__option_1_main',
1692
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1693
+			10,
1694
+			3
1695
+		);
1696
+		add_filter(
1697
+			'FHEE__ee_migration_page__option_1_button_text',
1698
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1699
+			10,
1700
+			3
1701
+		);
1702
+		add_action(
1703
+			'AHEE__ee_migration_page__option_1_extra_details',
1704
+			array($this, '_migration_page_hook_option_1_extra_details'),
1705
+			10,
1706
+			3
1707
+		);
1708
+		add_filter(
1709
+			'FHEE__ee_migration_page__option_2_main',
1710
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1711
+			10,
1712
+			4
1713
+		);
1714
+		add_filter(
1715
+			'FHEE__ee_migration_page__option_2_button_text',
1716
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1717
+			10,
1718
+			2
1719
+		);
1720
+		add_filter(
1721
+			'FHEE__ee_migration_page__option_2_details',
1722
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1723
+			10,
1724
+			2
1725
+		);
1726
+		add_action(
1727
+			'AHEE__ee_migration_page__after_migration_options_table',
1728
+			array($this, '_migration_page_hook_after_migration_options_table')
1729
+		);
1730
+		add_filter(
1731
+			'FHEE__ee_migration_page__done_migration_header',
1732
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1733
+			10,
1734
+			2
1735
+		);
1736
+		add_filter(
1737
+			'FHEE__ee_migration_page__p_after_done_migration_header',
1738
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1739
+			10,
1740
+			2
1741
+		);
1742
+		add_filter(
1743
+			'FHEE__ee_migration_page__migration_options_template',
1744
+			array($this,'use_migration_options_from_ee3_template')
1745
+		);
1746
+	}
1747
+
1748
+
1749
+
1750
+	public function _migrate_page_hook_simplify_version_strings(
1751
+		$old_content,
1752
+		$current_db_state,
1753
+		$next_db_state,
1754
+		$ultimate_db_state = null
1755
+	) {
1756
+		return str_replace(
1757
+			array($current_db_state, $next_db_state, $ultimate_db_state),
1758
+			array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1759
+			$old_content
1760
+		);
1761
+	}
1762
+
1763
+
1764
+
1765
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1766
+	{
1767
+		return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1768
+	}
1769
+
1770
+
1771
+
1772
+	public function _migration_page_hook_option_1_extra_details()
1773
+	{
1774
+		?>
1775 1775
         <p><?php printf(esc_html__(
1776
-            "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",
1777
-            "event_espresso"
1778
-        )); ?></p><?php
1779
-    }
1776
+			"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",
1777
+			"event_espresso"
1778
+		)); ?></p><?php
1779
+	}
1780 1780
 
1781 1781
 
1782 1782
 
1783
-    public function _migration_page_hook_after_migration_options_table()
1784
-    {
1785
-        ?><p class="ee-attention">
1783
+	public function _migration_page_hook_after_migration_options_table()
1784
+	{
1785
+		?><p class="ee-attention">
1786 1786
         <strong><span class="reminder-spn">
1787 1787
                 <?php _e(
1788
-                    "Important note to those using Event Espresso 3 addons: ",
1789
-                    "event_espresso"
1790
-                ); ?></span></strong>
1788
+					"Important note to those using Event Espresso 3 addons: ",
1789
+					"event_espresso"
1790
+				); ?></span></strong>
1791 1791
         <br/>
1792 1792
         <?php _e(
1793
-            "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.",
1794
-            "event_espresso"
1795
-        ); ?>
1793
+			"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.",
1794
+			"event_espresso"
1795
+		); ?>
1796 1796
         </p><?php
1797
-    }
1797
+	}
1798 1798
 
1799 1799
 
1800 1800
 
1801
-    /**
1802
-     * When showing the migration options, show more options and info than normal (ie, give folks the option
1803
-     * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1804
-     * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1805
-     * @param $template_filepath
1806
-     * @return string
1807
-     */
1808
-    public function use_migration_options_from_ee3_template($template_filepath)
1809
-    {
1810
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1811
-    }
1801
+	/**
1802
+	 * When showing the migration options, show more options and info than normal (ie, give folks the option
1803
+	 * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1804
+	 * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1805
+	 * @param $template_filepath
1806
+	 * @return string
1807
+	 */
1808
+	public function use_migration_options_from_ee3_template($template_filepath)
1809
+	{
1810
+		return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1811
+	}
1812 1812
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
 // unfortunately, this needs to be done upon INCLUSION of this file,
10 10
 // instead of construction, because it only gets constructed on first page load
11 11
 // (all other times it gets resurrected from a wordpress option)
12
-$stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
12
+$stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14
-if (! empty($stages)) {
14
+if ( ! empty($stages)) {
15 15
     foreach ($stages as $filepath) {
16 16
         $matches = array();
17 17
         preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
-        $class_to_filepath[ $matches[1] ] = $filepath;
18
+        $class_to_filepath[$matches[1]] = $filepath;
19 19
     }
20 20
 }
21 21
 // give addons a chance to autoload their stages too
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     private function _checkin_table_exists()
88 88
     {
89 89
         global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
90
+        $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
91 91
         if ($results) {
92 92
             return true;
93 93
         } else {
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
         if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
104 104
 //          echo "$version_string can be migrated fro";
105 105
             return true;
106
-        } elseif (! $version_string) {
106
+        } elseif ( ! $version_string) {
107 107
 //          echo "no version string provided: $version_string";
108 108
             // no version string provided... this must be pre 4.1
109 109
             // because since 4.1 we're
110
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
110
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
111 111
         } else {
112 112
 //          echo "$version_string doesnt apply";
113 113
             return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function schema_changes_before_migration()
120 120
     {
121 121
         // relies on 4.1's EEH_Activation::create_table
122
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
122
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
123 123
         $table_name = 'esp_answer';
124 124
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
125 125
 					REG_ID int(10) unsigned NOT NULL,
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
     public function insert_default_states()
504 504
     {
505 505
         global $wpdb;
506
-        $state_table = $wpdb->prefix . "esp_state";
506
+        $state_table = $wpdb->prefix."esp_state";
507 507
         if ($this->_get_table_analysis()->tableExists($state_table)) {
508
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
508
+            $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
509 509
             $states = $wpdb->get_var($SQL);
510
-            if (! $states) {
511
-                $SQL = "INSERT INTO " . $state_table . "
510
+            if ( ! $states) {
511
+                $SQL = "INSERT INTO ".$state_table."
512 512
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
513 513
 				(1, 'US', 'AK', 'Alaska', 1),
514 514
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
     public function insert_default_countries()
597 597
     {
598 598
         global $wpdb;
599
-        $country_table = $wpdb->prefix . "esp_country";
599
+        $country_table = $wpdb->prefix."esp_country";
600 600
         if ($this->_get_table_analysis()->tableExists($country_table)) {
601
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
601
+            $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
602 602
             $countries = $wpdb->get_var($SQL);
603
-            if (! $countries) {
604
-                $SQL = "INSERT INTO " . $country_table . "
603
+            if ( ! $countries) {
604
+                $SQL = "INSERT INTO ".$country_table."
605 605
 				(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
606 606
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
607 607
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -846,17 +846,17 @@  discard block
 block discarded – undo
846 846
     public function insert_default_price_types()
847 847
     {
848 848
         global $wpdb;
849
-        $price_type_table = $wpdb->prefix . "esp_price_type";
849
+        $price_type_table = $wpdb->prefix."esp_price_type";
850 850
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
851
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
852 852
             $price_types_exist = $wpdb->get_var($SQL);
853
-            if (! $price_types_exist) {
853
+            if ( ! $price_types_exist) {
854 854
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
855
-							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
856
-							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
857
-							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
858
-							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
859
-							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
855
+							(1, '".esc_html__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
856
+							(2, '" . esc_html__('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
857
+							(3, '" . esc_html__('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
858
+							(4, '" . esc_html__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
859
+							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
860 860
                 $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861 861
                 $wpdb->query($SQL);
862 862
             }
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
     public function insert_default_prices()
879 879
     {
880 880
         global $wpdb;
881
-        $price_table = $wpdb->prefix . "esp_price";
881
+        $price_table = $wpdb->prefix."esp_price";
882 882
         if ($this->_get_table_analysis()->tableExists($price_table)) {
883
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
883
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
884 884
             $prices_exist = $wpdb->get_var($SQL);
885
-            if (! $prices_exist) {
885
+            if ( ! $prices_exist) {
886 886
                 $SQL = "INSERT INTO $price_table
887 887
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
888 888
 							(1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);";
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
     public function insert_default_tickets()
905 905
     {
906 906
         global $wpdb;
907
-        $ticket_table = $wpdb->prefix . "esp_ticket";
907
+        $ticket_table = $wpdb->prefix."esp_ticket";
908 908
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
909
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
910 910
             $tickets_exist = $wpdb->get_var($SQL);
911
-            if (! $tickets_exist) {
911
+            if ( ! $tickets_exist) {
912 912
                 $SQL = "INSERT INTO $ticket_table
913 913
 					( 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
914 914
 					( 1, 0, '"
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
                 $wpdb->query($SQL);
919 919
             }
920 920
         }
921
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
921
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
922 922
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
923
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
924 924
             $ticket_prc_exist = $wpdb->get_var($SQL);
925
-            if (! $ticket_prc_exist) {
925
+            if ( ! $ticket_prc_exist) {
926 926
                 $SQL = "INSERT INTO $ticket_price_table
927 927
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
928 928
 				( 1, 1, 1 )
@@ -946,11 +946,11 @@  discard block
 block discarded – undo
946 946
      */
947 947
     public function get_or_create_country($country_name)
948 948
     {
949
-        if (! $country_name) {
949
+        if ( ! $country_name) {
950 950
             throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951 951
         }
952 952
         global $wpdb;
953
-        $country_table = $wpdb->prefix . "esp_country";
953
+        $country_table = $wpdb->prefix."esp_country";
954 954
         if (is_int($country_name)) {
955 955
             $country_name = $this->get_iso_from_3_1_country_id($country_name);
956 956
         }
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			CNT_ISO LIKE %s OR
959 959
 			CNT_ISO3 LIKE %s OR
960 960
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
961
-        if (! $country) {
961
+        if ( ! $country) {
962 962
             // insert a new one then
963 963
             $cols_n_values = array(
964 964
                     'CNT_ISO'         => $this->_find_available_country_iso(2),
@@ -978,28 +978,28 @@  discard block
 block discarded – undo
978 978
                     'CNT_active'      => true,
979 979
             );
980 980
             $data_types = array(
981
-                    '%s',// CNT_ISO
982
-                    '%s',// CNT_ISO3
983
-                    '%d',// RGN_ID
984
-                    '%s',// CNT_name
985
-                    '%s',// CNT_cur_code
986
-                    '%s',// CNT_cur_single
987
-                    '%s',// CNT_cur_plural
988
-                    '%s',// CNT_cur_sign
989
-                    '%d',// CNT_cur_sign_b4
990
-                    '%d',// CNT_cur_dec_plc
991
-                    '%s',// CNT_cur_dec_mrk
992
-                    '%s',// CNT_cur_thsnds
993
-                    '%s',// CNT_tel_code
994
-                    '%d',// CNT_is_EU
995
-                    '%d',// CNT_active
981
+                    '%s', // CNT_ISO
982
+                    '%s', // CNT_ISO3
983
+                    '%d', // RGN_ID
984
+                    '%s', // CNT_name
985
+                    '%s', // CNT_cur_code
986
+                    '%s', // CNT_cur_single
987
+                    '%s', // CNT_cur_plural
988
+                    '%s', // CNT_cur_sign
989
+                    '%d', // CNT_cur_sign_b4
990
+                    '%d', // CNT_cur_dec_plc
991
+                    '%s', // CNT_cur_dec_mrk
992
+                    '%s', // CNT_cur_thsnds
993
+                    '%s', // CNT_tel_code
994
+                    '%d', // CNT_is_EU
995
+                    '%d', // CNT_active
996 996
             );
997 997
             $success = $wpdb->insert(
998 998
                 $country_table,
999 999
                 $cols_n_values,
1000 1000
                 $data_types
1001 1001
             );
1002
-            if (! $success) {
1002
+            if ( ! $success) {
1003 1003
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1004 1004
                     'N/A',
1005 1005
                     array('country_id' => $country_name),
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
     private function _find_available_country_iso($num_letters = 2)
1025 1025
     {
1026 1026
         global $wpdb;
1027
-        $country_table = $wpdb->prefix . "esp_country";
1027
+        $country_table = $wpdb->prefix."esp_country";
1028 1028
         $attempts = 0;
1029 1029
         do {
1030 1030
             $current_iso = strtoupper(wp_generate_password($num_letters, false));
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
             // keep going until we find an available country code, or we arbitrarily
1036 1036
             // decide we've tried this enough. Somehow they have way too many countries
1037 1037
             // (probably because they're mis-using the EE3 country_id like a custom question)
1038
-        } while (intval($country_with_that_iso) && $attempts < 200);
1038
+        }while (intval($country_with_that_iso) && $attempts < 200);
1039 1039
         return $current_iso;
1040 1040
     }
1041 1041
 
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
      */
1052 1052
     public function get_or_create_state($state_name, $country_name = '')
1053 1053
     {
1054
-        if (! $state_name) {
1054
+        if ( ! $state_name) {
1055 1055
             throw new EE_Error(esc_html__(
1056 1056
                 "Could not get-or-create state because no state name was provided",
1057 1057
                 "event_espresso"
@@ -1064,12 +1064,12 @@  discard block
 block discarded – undo
1064 1064
             $country_iso = $this->get_default_country_iso();
1065 1065
         }
1066 1066
         global $wpdb;
1067
-        $state_table = $wpdb->prefix . "esp_state";
1067
+        $state_table = $wpdb->prefix."esp_state";
1068 1068
         $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1069 1069
 			(STA_abbrev LIKE %s OR
1070 1070
 			STA_name LIKE %s) AND
1071 1071
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1072
-        if (! $state) {
1072
+        if ( ! $state) {
1073 1073
             // insert a new one then
1074 1074
             $cols_n_values = array(
1075 1075
                     'CNT_ISO'    => $country_iso,
@@ -1078,13 +1078,13 @@  discard block
 block discarded – undo
1078 1078
                     'STA_active' => true,
1079 1079
             );
1080 1080
             $data_types = array(
1081
-                    '%s',// CNT_ISO
1082
-                    '%s',// STA_abbrev
1083
-                    '%s',// STA_name
1084
-                    '%d',// STA_active
1081
+                    '%s', // CNT_ISO
1082
+                    '%s', // STA_abbrev
1083
+                    '%s', // STA_name
1084
+                    '%d', // STA_active
1085 1085
             );
1086 1086
             $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1087
-            if (! $success) {
1087
+            if ( ! $success) {
1088 1088
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1089 1089
                     'N/A',
1090 1090
                     array('state' => $state_name, 'country_id' => $country_name),
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
     {
1114 1114
         $matches = array();
1115 1115
         preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1116
-        if (! $matches || count($matches) < 3) {
1116
+        if ( ! $matches || count($matches) < 3) {
1117 1117
             $hour = '00';
1118 1118
             $minutes = '00';
1119 1119
         } else {
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
                     'Declined'         => 'RPP',
1419 1419
             );
1420 1420
         }
1421
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1421
+        return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1422 1422
     }
1423 1423
 
1424 1424
 
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
         if ($guid) {
1443 1443
             // check for an existing attachment post with this guid
1444 1444
             $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1445
-            if (! $attachment_post_id) {
1445
+            if ( ! $attachment_post_id) {
1446 1446
                 // post thumbnail with that GUID doesn't exist, we should create one
1447 1447
                 $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1448 1448
                 $created_attachment_post = true;
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
         $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1478 1478
         // do a head request to verify the file exists
1479 1479
         $head_response = wp_remote_head($original_guid);
1480
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1480
+        if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1481 1481
             return $original_guid;
1482 1482
         } else {
1483 1483
             return $guid_in_old_event;
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
      */
1498 1498
     private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1499 1499
     {
1500
-        if (! $guid) {
1500
+        if ( ! $guid) {
1501 1501
             $migration_stage->add_error(sprintf(esc_html__(
1502 1502
                 "Cannot create image attachment for a blank GUID!",
1503 1503
                 "event_espresso"
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
         // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1510 1510
         if (strpos($guid, $wp_upload_dir['url']) === false) {
1511 1511
             // image is located remotely. download it and place it in the uploads directory
1512
-            if (! is_readable($guid)) {
1512
+            if ( ! is_readable($guid)) {
1513 1513
                 $migration_stage->add_error(sprintf(esc_html__(
1514 1514
                     "Could not create image attachment from non-existent file: %s",
1515 1515
                     "event_espresso"
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
                 ), $guid));
1525 1525
                 return false;
1526 1526
             }
1527
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1527
+            $local_filepath = $wp_upload_dir['path'].'/'.basename($guid);
1528 1528
             $savefile = fopen($local_filepath, 'w');
1529 1529
             fwrite($savefile, $contents);
1530 1530
             fclose($savefile);
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
                 'post_status'    => 'inherit',
1541 1541
         );
1542 1542
         $attach_id = wp_insert_attachment($attachment, $guid);
1543
-        if (! $attach_id) {
1543
+        if ( ! $attach_id) {
1544 1544
             $migration_stage->add_error(sprintf(esc_html__(
1545 1545
                 "Could not create image attachment post from image '%s'. Attachment data was %s.",
1546 1546
                 "event_espresso"
@@ -1549,9 +1549,9 @@  discard block
 block discarded – undo
1549 1549
         }
1550 1550
         // you must first include the image.php file
1551 1551
         // for the function wp_generate_attachment_metadata() to work
1552
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1552
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1553 1553
         $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1554
-        if (! $attach_data) {
1554
+        if ( ! $attach_data) {
1555 1555
             $migration_stage->add_error(sprintf(esc_html__(
1556 1556
                 "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1557 1557
                 "event_espresso"
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
             return $attach_id;
1560 1560
         }
1561 1561
         $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1562
-        if (! $metadata_save_result) {
1562
+        if ( ! $metadata_save_result) {
1563 1563
             $migration_stage->add_error(sprintf(esc_html__(
1564 1564
                 "Could not update attachment metadata for attachment %d with data %s",
1565 1565
                 "event_espresso"
@@ -1605,10 +1605,10 @@  discard block
 block discarded – undo
1605 1605
         $timezone = null
1606 1606
     ) {
1607 1607
         $original_tz = $timezone;
1608
-        if (! $timezone) {
1608
+        if ( ! $timezone) {
1609 1609
             $timezone = $this->_get_wp_timezone();
1610 1610
         }
1611
-        if (! $timezone) {
1611
+        if ( ! $timezone) {
1612 1612
             $stage->add_error(sprintf(
1613 1613
                 esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1614 1614
                 $original_tz,
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
         );
1742 1742
         add_filter(
1743 1743
             'FHEE__ee_migration_page__migration_options_template',
1744
-            array($this,'use_migration_options_from_ee3_template')
1744
+            array($this, 'use_migration_options_from_ee3_template')
1745 1745
         );
1746 1746
     }
1747 1747
 
@@ -1807,6 +1807,6 @@  discard block
 block discarded – undo
1807 1807
      */
1808 1808
     public function use_migration_options_from_ee3_template($template_filepath)
1809 1809
     {
1810
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1810
+        return EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee3.template.php';
1811 1811
     }
1812 1812
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_9_0.dms.php 2 patches
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
16 16
 $class_to_filepath = array();
17 17
 foreach ($stages as $filepath) {
18
-    $matches = array();
19
-    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-    $class_to_filepath[ $matches[1] ] = $filepath;
18
+	$matches = array();
19
+	preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+	$class_to_filepath[ $matches[1] ] = $filepath;
21 21
 }
22 22
 // give addons a chance to autoload their stages too
23 23
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -36,68 +36,68 @@  discard block
 block discarded – undo
36 36
 class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
37 37
 {
38 38
 
39
-    /**
40
-     * return EE_DMS_Core_4_9_0
41
-     *
42
-     * @param TableManager  $table_manager
43
-     * @param TableAnalysis $table_analysis
44
-     */
45
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
46
-    {
47
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
48
-        $this->_priority = 10;
49
-        $this->_migration_stages = array(
50
-            new EE_DMS_4_9_0_Email_System_Question(),
51
-            new EE_DMS_4_9_0_Answers_With_No_Registration(),
52
-        );
53
-        parent::__construct($table_manager, $table_analysis);
54
-    }
39
+	/**
40
+	 * return EE_DMS_Core_4_9_0
41
+	 *
42
+	 * @param TableManager  $table_manager
43
+	 * @param TableAnalysis $table_analysis
44
+	 */
45
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
46
+	{
47
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
48
+		$this->_priority = 10;
49
+		$this->_migration_stages = array(
50
+			new EE_DMS_4_9_0_Email_System_Question(),
51
+			new EE_DMS_4_9_0_Answers_With_No_Registration(),
52
+		);
53
+		parent::__construct($table_manager, $table_analysis);
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     * Whether to migrate or not.
60
-     *
61
-     * @param array $version_array
62
-     * @return bool
63
-     */
64
-    public function can_migrate_from_version($version_array)
65
-    {
66
-        $version_string = $version_array['Core'];
67
-        if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) {
68
-            //          echo "$version_string can be migrated from";
69
-            return true;
70
-        } elseif (! $version_string) {
71
-            //          echo "no version string provided: $version_string";
72
-            // no version string provided... this must be pre 4.3
73
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
-        } else {
75
-            //          echo "$version_string doesnt apply";
76
-            return false;
77
-        }
78
-    }
58
+	/**
59
+	 * Whether to migrate or not.
60
+	 *
61
+	 * @param array $version_array
62
+	 * @return bool
63
+	 */
64
+	public function can_migrate_from_version($version_array)
65
+	{
66
+		$version_string = $version_array['Core'];
67
+		if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) {
68
+			//          echo "$version_string can be migrated from";
69
+			return true;
70
+		} elseif (! $version_string) {
71
+			//          echo "no version string provided: $version_string";
72
+			// no version string provided... this must be pre 4.3
73
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
+		} else {
75
+			//          echo "$version_string doesnt apply";
76
+			return false;
77
+		}
78
+	}
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * @return bool
84
-     */
85
-    public function schema_changes_before_migration()
86
-    {
87
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
88
-        $now_in_mysql = current_time('mysql', true);
89
-        $table_name = 'esp_answer';
90
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
82
+	/**
83
+	 * @return bool
84
+	 */
85
+	public function schema_changes_before_migration()
86
+	{
87
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
88
+		$now_in_mysql = current_time('mysql', true);
89
+		$table_name = 'esp_answer';
90
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
91 91
 					REG_ID int(10) unsigned NOT NULL,
92 92
 					QST_ID int(10) unsigned NOT NULL,
93 93
 					ANS_value text NOT NULL,
94 94
 					PRIMARY KEY  (ANS_ID),
95 95
 					KEY REG_ID (REG_ID),
96 96
 					KEY QST_ID (QST_ID)";
97
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
98
-        $table_name = 'esp_attendee_meta';
99
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
100
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
98
+		$table_name = 'esp_attendee_meta';
99
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
100
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
101 101
 				ATT_ID bigint(20) unsigned NOT NULL,
102 102
 				ATT_fname varchar(45) NOT NULL,
103 103
 				ATT_lname varchar(45) NOT NULL,
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 				KEY ATT_email (ATT_email(191)),
115 115
 				KEY ATT_lname (ATT_lname),
116 116
 				KEY ATT_fname (ATT_fname)";
117
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
118
-        $table_name = 'esp_checkin';
119
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
118
+		$table_name = 'esp_checkin';
119
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
120 120
 				REG_ID int(10) unsigned NOT NULL,
121 121
 				DTT_ID int(10) unsigned NOT NULL,
122 122
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				PRIMARY KEY  (CHK_ID),
125 125
 				KEY REG_ID (REG_ID),
126 126
 				KEY DTT_ID (DTT_ID)";
127
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
128
-        $table_name = 'esp_country';
129
-        $sql = "CNT_ISO varchar(2) NOT NULL,
127
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
128
+		$table_name = 'esp_country';
129
+		$sql = "CNT_ISO varchar(2) NOT NULL,
130 130
 				CNT_ISO3 varchar(3) NOT NULL,
131 131
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
132 132
 				CNT_name varchar(45) NOT NULL,
@@ -142,29 +142,29 @@  discard block
 block discarded – undo
142 142
 				CNT_is_EU tinyint(1) DEFAULT '0',
143 143
 				CNT_active tinyint(1) DEFAULT '0',
144 144
 				PRIMARY KEY  (CNT_ISO)";
145
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
146
-        $table_name = 'esp_currency';
147
-        $sql = "CUR_code varchar(6) NOT NULL,
145
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
146
+		$table_name = 'esp_currency';
147
+		$sql = "CUR_code varchar(6) NOT NULL,
148 148
 				CUR_single varchar(45) DEFAULT 'dollar',
149 149
 				CUR_plural varchar(45) DEFAULT 'dollars',
150 150
 				CUR_sign varchar(45) DEFAULT '$',
151 151
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
152 152
 				CUR_active tinyint(1) DEFAULT '0',
153 153
 				PRIMARY KEY  (CUR_code)";
154
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
155
-        // note: although this table is no longer in use,
156
-        // it hasn't been removed because then queries to the model will have errors.
157
-        // but you should expect this table and its corresponding model to be removed in
158
-        // the next few months
159
-        $table_name = 'esp_currency_payment_method';
160
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
154
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
155
+		// note: although this table is no longer in use,
156
+		// it hasn't been removed because then queries to the model will have errors.
157
+		// but you should expect this table and its corresponding model to be removed in
158
+		// the next few months
159
+		$table_name = 'esp_currency_payment_method';
160
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
161 161
 				CUR_code varchar(6) NOT NULL,
162 162
 				PMD_ID int(11) NOT NULL,
163 163
 				PRIMARY KEY  (CPM_ID),
164 164
 				KEY PMD_ID (PMD_ID)";
165
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
166
-        $table_name = 'esp_datetime';
167
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
165
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
166
+		$table_name = 'esp_datetime';
167
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
168 168
 				EVT_ID bigint(20) unsigned NOT NULL,
169 169
 				DTT_name varchar(255) NOT NULL DEFAULT '',
170 170
 				DTT_description text NOT NULL,
@@ -181,25 +181,25 @@  discard block
 block discarded – undo
181 181
 				KEY DTT_EVT_start (DTT_EVT_start),
182 182
 				KEY EVT_ID (EVT_ID),
183 183
 				KEY DTT_is_primary (DTT_is_primary)";
184
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185
-        $table_name = "esp_datetime_ticket";
186
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
184
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185
+		$table_name = "esp_datetime_ticket";
186
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
187 187
 				DTT_ID int(10) unsigned NOT NULL,
188 188
 				TKT_ID int(10) unsigned NOT NULL,
189 189
 				PRIMARY KEY  (DTK_ID),
190 190
 				KEY DTT_ID (DTT_ID),
191 191
 				KEY TKT_ID (TKT_ID)";
192
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
193
-        $table_name = 'esp_event_message_template';
194
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
192
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
193
+		$table_name = 'esp_event_message_template';
194
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
195 195
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
196 196
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
197 197
 				PRIMARY KEY  (EMT_ID),
198 198
 				KEY EVT_ID (EVT_ID),
199 199
 				KEY GRP_ID (GRP_ID)";
200
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
201
-        $table_name = 'esp_event_meta';
202
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
200
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
201
+		$table_name = 'esp_event_meta';
202
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
203 203
 				EVT_ID bigint(20) unsigned NOT NULL,
204 204
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
205 205
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -214,34 +214,34 @@  discard block
 block discarded – undo
214 214
 				EVT_donations tinyint(1) NULL,
215 215
 				PRIMARY KEY  (EVTM_ID),
216 216
 				KEY EVT_ID (EVT_ID)";
217
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
218
-        $table_name = 'esp_event_question_group';
219
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
217
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
218
+		$table_name = 'esp_event_question_group';
219
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
220 220
 				EVT_ID bigint(20) unsigned NOT NULL,
221 221
 				QSG_ID int(10) unsigned NOT NULL,
222 222
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
223 223
 				PRIMARY KEY  (EQG_ID),
224 224
 				KEY EVT_ID (EVT_ID),
225 225
 				KEY QSG_ID (QSG_ID)";
226
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
-        $table_name = 'esp_event_venue';
228
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
226
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
+		$table_name = 'esp_event_venue';
228
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
229 229
 				EVT_ID bigint(20) unsigned NOT NULL,
230 230
 				VNU_ID bigint(20) unsigned NOT NULL,
231 231
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
232 232
 				PRIMARY KEY  (EVV_ID)";
233
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
234
-        $table_name = 'esp_extra_meta';
235
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
233
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
234
+		$table_name = 'esp_extra_meta';
235
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
236 236
 				OBJ_ID int(11) DEFAULT NULL,
237 237
 				EXM_type varchar(45) DEFAULT NULL,
238 238
 				EXM_key varchar(45) DEFAULT NULL,
239 239
 				EXM_value text,
240 240
 				PRIMARY KEY  (EXM_ID),
241 241
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
242
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
243
-        $table_name = 'esp_extra_join';
244
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
242
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
243
+		$table_name = 'esp_extra_join';
244
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
245 245
 				EXJ_first_model_id varchar(6) NOT NULL,
246 246
 				EXJ_first_model_name varchar(20) NOT NULL,
247 247
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 				PRIMARY KEY  (EXJ_ID),
250 250
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
251 251
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
252
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
253
-        $table_name = 'esp_line_item';
254
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
252
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
253
+		$table_name = 'esp_line_item';
254
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
255 255
 				LIN_code varchar(245) NOT NULL DEFAULT '',
256 256
 				TXN_ID int(11) DEFAULT NULL,
257 257
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
273 273
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
274 274
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
275
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
276
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
277
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
278
-        $table_name = 'esp_log';
279
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
275
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
276
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
277
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
278
+		$table_name = 'esp_log';
279
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
280 280
 				LOG_time datetime DEFAULT NULL,
281 281
 				OBJ_ID varchar(45) DEFAULT NULL,
282 282
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 				KEY LOG_time (LOG_time),
288 288
 				KEY OBJ (OBJ_type,OBJ_ID),
289 289
 				KEY LOG_type (LOG_type)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
-        $table_name = 'esp_message';
292
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
293
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
294
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
295
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
+		$table_name = 'esp_message';
292
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
293
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
294
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
295
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
296 296
 				GRP_ID int(10) unsigned NULL,
297 297
 				MSG_token varchar(255) NULL,
298 298
 				TXN_ID int(10) unsigned NULL,
@@ -324,18 +324,18 @@  discard block
 block discarded – undo
324 324
 				KEY STS_ID (STS_ID),
325 325
 				KEY MSG_created (MSG_created),
326 326
 				KEY MSG_modified (MSG_modified)";
327
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
-        $table_name = 'esp_message_template';
329
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
+		$table_name = 'esp_message_template';
329
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 330
 				GRP_ID int(10) unsigned NOT NULL,
331 331
 				MTP_context varchar(50) NOT NULL,
332 332
 				MTP_template_field varchar(30) NOT NULL,
333 333
 				MTP_content text NOT NULL,
334 334
 				PRIMARY KEY  (MTP_ID),
335 335
 				KEY GRP_ID (GRP_ID)";
336
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
-        $table_name = 'esp_message_template_group';
338
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
336
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
+		$table_name = 'esp_message_template_group';
338
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
339 339
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
340 340
 				MTP_name varchar(245) NOT NULL DEFAULT '',
341 341
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
348 348
 				PRIMARY KEY  (GRP_ID),
349 349
 				KEY MTP_user_id (MTP_user_id)";
350
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_payment';
352
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_payment';
352
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 				TXN_ID int(10) unsigned DEFAULT NULL,
354 354
 				STS_ID varchar(3) DEFAULT NULL,
355 355
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 				PRIMARY KEY  (PAY_ID),
367 367
 				KEY PAY_timestamp (PAY_timestamp),
368 368
 				KEY TXN_ID (TXN_ID)";
369
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
370
-        $table_name = 'esp_payment_method';
371
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
369
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
370
+		$table_name = 'esp_payment_method';
371
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
372 372
 				PMD_type varchar(124) DEFAULT NULL,
373 373
 				PMD_name varchar(255) DEFAULT NULL,
374 374
 				PMD_desc text,
@@ -384,24 +384,24 @@  discard block
 block discarded – undo
384 384
 				PRIMARY KEY  (PMD_ID),
385 385
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
386 386
 				KEY PMD_type (PMD_type)";
387
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
388
-        $table_name = "esp_ticket_price";
389
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
388
+		$table_name = "esp_ticket_price";
389
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
390 390
 				TKT_ID int(10) unsigned NOT NULL,
391 391
 				PRC_ID int(10) unsigned NOT NULL,
392 392
 				PRIMARY KEY  (TKP_ID),
393 393
 				KEY TKT_ID (TKT_ID),
394 394
 				KEY PRC_ID (PRC_ID)";
395
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
-        $table_name = "esp_ticket_template";
397
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
395
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
+		$table_name = "esp_ticket_template";
397
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
398 398
 				TTM_name varchar(45) NOT NULL,
399 399
 				TTM_description text,
400 400
 				TTM_file varchar(45),
401 401
 				PRIMARY KEY  (TTM_ID)";
402
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
403
-        $table_name = 'esp_question';
404
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
403
+		$table_name = 'esp_question';
404
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
405 405
 				QST_display_text text NOT NULL,
406 406
 				QST_admin_label varchar(255) NOT NULL,
407 407
 				QST_system varchar(25) DEFAULT NULL,
@@ -415,18 +415,18 @@  discard block
 block discarded – undo
415 415
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
416 416
 				PRIMARY KEY  (QST_ID),
417 417
 				KEY QST_order (QST_order)';
418
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
419
-        $table_name = 'esp_question_group_question';
420
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
418
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
419
+		$table_name = 'esp_question_group_question';
420
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
421 421
 				QSG_ID int(10) unsigned NOT NULL,
422 422
 				QST_ID int(10) unsigned NOT NULL,
423 423
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
424 424
 				PRIMARY KEY  (QGQ_ID),
425 425
 				KEY QST_ID (QST_ID),
426 426
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
427
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
428
-        $table_name = 'esp_question_option';
429
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
427
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
428
+		$table_name = 'esp_question_option';
429
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
430 430
 				QSO_value varchar(255) NOT NULL,
431 431
 				QSO_desc text NOT NULL,
432 432
 				QST_ID int(10) unsigned NOT NULL,
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 				PRIMARY KEY  (QSO_ID),
437 437
 				KEY QST_ID (QST_ID),
438 438
 				KEY QSO_order (QSO_order)";
439
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
440
-        $table_name = 'esp_registration';
441
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
440
+		$table_name = 'esp_registration';
441
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
442 442
 				EVT_ID bigint(20) unsigned NOT NULL,
443 443
 				ATT_ID bigint(20) unsigned NOT NULL,
444 444
 				TXN_ID int(10) unsigned NOT NULL,
@@ -462,18 +462,18 @@  discard block
 block discarded – undo
462 462
 				KEY TKT_ID (TKT_ID),
463 463
 				KEY EVT_ID (EVT_ID),
464 464
 				KEY STS_ID (STS_ID)";
465
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
466
-        $table_name = 'esp_registration_payment';
467
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
465
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
466
+		$table_name = 'esp_registration_payment';
467
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
468 468
 					  REG_ID int(10) unsigned NOT NULL,
469 469
 					  PAY_ID int(10) unsigned NULL,
470 470
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
471 471
 					  PRIMARY KEY  (RPY_ID),
472 472
 					  KEY REG_ID (REG_ID),
473 473
 					  KEY PAY_ID (PAY_ID)";
474
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
475
-        $table_name = 'esp_state';
476
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
474
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
475
+		$table_name = 'esp_state';
476
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
477 477
 				CNT_ISO varchar(2) NOT NULL,
478 478
 				STA_abbrev varchar(24) NOT NULL,
479 479
 				STA_name varchar(100) NOT NULL,
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
 				PRIMARY KEY  (STA_ID),
482 482
 				KEY STA_abbrev (STA_abbrev),
483 483
 				KEY CNT_ISO (CNT_ISO)";
484
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
485
-        $table_name = 'esp_status';
486
-        $sql = "STS_ID varchar(3) NOT NULL,
484
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
485
+		$table_name = 'esp_status';
486
+		$sql = "STS_ID varchar(3) NOT NULL,
487 487
 				STS_code varchar(45) NOT NULL,
488 488
 				STS_type varchar(45) NOT NULL,
489 489
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
492 492
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
493 493
 				KEY STS_type (STS_type)";
494
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
495
-        $table_name = 'esp_transaction';
496
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
494
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
495
+		$table_name = 'esp_transaction';
496
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
497 497
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
498 498
 				TXN_total decimal(12,3) DEFAULT '0.00',
499 499
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
 				PRIMARY KEY  (TXN_ID),
506 506
 				KEY TXN_timestamp (TXN_timestamp),
507 507
 				KEY STS_ID (STS_ID)";
508
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
509
-        $table_name = 'esp_venue_meta';
510
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
508
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
509
+		$table_name = 'esp_venue_meta';
510
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
511 511
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
512 512
 			VNU_address varchar(255) DEFAULT NULL,
513 513
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 			KEY VNU_ID (VNU_ID),
527 527
 			KEY STA_ID (STA_ID),
528 528
 			KEY CNT_ISO (CNT_ISO)";
529
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
530
-        // modified tables
531
-        $table_name = "esp_price";
532
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
529
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
530
+		// modified tables
531
+		$table_name = "esp_price";
532
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
533 533
 				PRT_ID tinyint(3) unsigned NOT NULL,
534 534
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
535 535
 				PRC_name varchar(245) NOT NULL,
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 				PRC_parent int(10) unsigned DEFAULT 0,
543 543
 				PRIMARY KEY  (PRC_ID),
544 544
 				KEY PRT_ID (PRT_ID)";
545
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
546
-        $table_name = "esp_price_type";
547
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
545
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
546
+		$table_name = "esp_price_type";
547
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
548 548
 				PRT_name varchar(45) NOT NULL,
549 549
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
550 550
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
554 554
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
555 555
 				PRIMARY KEY  (PRT_ID)";
556
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
557
-        $table_name = "esp_ticket";
558
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
556
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
557
+		$table_name = "esp_ticket";
558
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
559 559
 				TTM_ID int(10) unsigned NOT NULL,
560 560
 				TKT_name varchar(245) NOT NULL DEFAULT '',
561 561
 				TKT_description text NOT NULL,
@@ -578,9 +578,9 @@  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');
582
-        $table_name = 'esp_question_group';
583
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
581
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
582
+		$table_name = 'esp_question_group';
583
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
584 584
 				QSG_name varchar(255) NOT NULL,
585 585
 				QSG_identifier varchar(100) NOT NULL,
586 586
 				QSG_desc text NULL,
@@ -593,159 +593,159 @@  discard block
 block discarded – undo
593 593
 				PRIMARY KEY  (QSG_ID),
594 594
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
595 595
 				KEY QSG_order (QSG_order)';
596
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
597
-        $this->insert_default_data();
598
-        return true;
599
-    }
596
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
597
+		$this->insert_default_data();
598
+		return true;
599
+	}
600 600
 
601
-    /**
602
-     * Inserts default data after parent was called.
603
-     * @since 4.10.0.p
604
-     * @throws EE_Error
605
-     * @throws InvalidArgumentException
606
-     * @throws ReflectionException
607
-     * @throws InvalidDataTypeException
608
-     * @throws InvalidInterfaceException
609
-     */
610
-    public function insert_default_data()
611
-    {
612
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
613
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
614
-        // (because many need to convert old string states to foreign keys into the states table)
615
-        $script_4_1_defaults->insert_default_states();
616
-        $script_4_1_defaults->insert_default_countries();
617
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
618
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
619
-        $script_4_5_defaults->insert_default_price_types();
620
-        $script_4_5_defaults->insert_default_prices();
621
-        $script_4_5_defaults->insert_default_tickets();
622
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
623
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
624
-        $script_4_6_defaults->add_default_admin_only_payments();
625
-        $script_4_6_defaults->insert_default_currencies();
626
-        /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
627
-        $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
628
-        $script_4_8_defaults->verify_new_countries();
629
-        $script_4_8_defaults->verify_new_currencies();
630
-        $this->verify_db_collations();
631
-        $this->verify_db_collations_again();
632
-    }
601
+	/**
602
+	 * Inserts default data after parent was called.
603
+	 * @since 4.10.0.p
604
+	 * @throws EE_Error
605
+	 * @throws InvalidArgumentException
606
+	 * @throws ReflectionException
607
+	 * @throws InvalidDataTypeException
608
+	 * @throws InvalidInterfaceException
609
+	 */
610
+	public function insert_default_data()
611
+	{
612
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
613
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
614
+		// (because many need to convert old string states to foreign keys into the states table)
615
+		$script_4_1_defaults->insert_default_states();
616
+		$script_4_1_defaults->insert_default_countries();
617
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
618
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
619
+		$script_4_5_defaults->insert_default_price_types();
620
+		$script_4_5_defaults->insert_default_prices();
621
+		$script_4_5_defaults->insert_default_tickets();
622
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
623
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
624
+		$script_4_6_defaults->add_default_admin_only_payments();
625
+		$script_4_6_defaults->insert_default_currencies();
626
+		/** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
627
+		$script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
628
+		$script_4_8_defaults->verify_new_countries();
629
+		$script_4_8_defaults->verify_new_currencies();
630
+		$this->verify_db_collations();
631
+		$this->verify_db_collations_again();
632
+	}
633 633
 
634 634
 
635 635
 
636
-    /**
637
-     * @return boolean
638
-     */
639
-    public function schema_changes_after_migration()
640
-    {
641
-        return true;
642
-    }
636
+	/**
637
+	 * @return boolean
638
+	 */
639
+	public function schema_changes_after_migration()
640
+	{
641
+		return true;
642
+	}
643 643
 
644 644
 
645 645
 
646
-    public function migration_page_hooks()
647
-    {
648
-    }
646
+	public function migration_page_hooks()
647
+	{
648
+	}
649 649
 
650 650
 
651 651
 
652
-    /**
653
-     * Verify all EE4 models' tables use utf8mb4 collation
654
-     *
655
-     * @return void
656
-     */
657
-    public function verify_db_collations()
658
-    {
659
-        global $wpdb;
660
-        // double-check we haven't already done it or that that the DB doesn't support utf8mb4
661
-        if ('utf8mb4' !== $wpdb->charset
662
-            || get_option('ee_verified_db_collations', false)) {
663
-            return;
664
-        }
665
-        // grab tables from each model
666
-        $tables_to_check = array();
667
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
668
-            if (method_exists($model_name, 'instance')) {
669
-                $model_obj = call_user_func(array($model_name, 'instance'));
670
-                if ($model_obj instanceof EEM_Base) {
671
-                    foreach ($model_obj->get_tables() as $table) {
672
-                        if (strpos($table->get_table_name(), 'esp_')
673
-                            && (is_main_site()// for main tables, verify global tables
674
-                                || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
675
-                            )
676
-                            && function_exists('maybe_convert_table_to_utf8mb4')
677
-                        ) {
678
-                            $tables_to_check[] = $table->get_table_name();
679
-                        }
680
-                    }
681
-                }
682
-            }
683
-        }
684
-        // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
685
-        // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
686
-        // of hard-coding this
687
-        $addon_tables = array(
688
-            // mailchimp
689
-            'esp_event_mailchimp_list_group',
690
-            'esp_event_question_mailchimp_field',
691
-            // multisite
692
-            'esp_blog_meta',
693
-            // people
694
-            'esp_people_to_post',
695
-            // promotions
696
-            'esp_promotion',
697
-            'esp_promotion_object',
698
-        );
699
-        foreach ($addon_tables as $table_name) {
700
-                $tables_to_check[] = $table_name;
701
-        }
702
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
703
-        // ok and now let's remember this was done (without needing to check the db schemas all over again)
704
-        add_option('ee_verified_db_collations', true, null, 'no');
705
-        // seeing how this ran with the fix from 10435, no need to check again
706
-        add_option('ee_verified_db_collations_again', true, null, 'no');
707
-    }
652
+	/**
653
+	 * Verify all EE4 models' tables use utf8mb4 collation
654
+	 *
655
+	 * @return void
656
+	 */
657
+	public function verify_db_collations()
658
+	{
659
+		global $wpdb;
660
+		// double-check we haven't already done it or that that the DB doesn't support utf8mb4
661
+		if ('utf8mb4' !== $wpdb->charset
662
+			|| get_option('ee_verified_db_collations', false)) {
663
+			return;
664
+		}
665
+		// grab tables from each model
666
+		$tables_to_check = array();
667
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
668
+			if (method_exists($model_name, 'instance')) {
669
+				$model_obj = call_user_func(array($model_name, 'instance'));
670
+				if ($model_obj instanceof EEM_Base) {
671
+					foreach ($model_obj->get_tables() as $table) {
672
+						if (strpos($table->get_table_name(), 'esp_')
673
+							&& (is_main_site()// for main tables, verify global tables
674
+								|| ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
675
+							)
676
+							&& function_exists('maybe_convert_table_to_utf8mb4')
677
+						) {
678
+							$tables_to_check[] = $table->get_table_name();
679
+						}
680
+					}
681
+				}
682
+			}
683
+		}
684
+		// and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
685
+		// when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
686
+		// of hard-coding this
687
+		$addon_tables = array(
688
+			// mailchimp
689
+			'esp_event_mailchimp_list_group',
690
+			'esp_event_question_mailchimp_field',
691
+			// multisite
692
+			'esp_blog_meta',
693
+			// people
694
+			'esp_people_to_post',
695
+			// promotions
696
+			'esp_promotion',
697
+			'esp_promotion_object',
698
+		);
699
+		foreach ($addon_tables as $table_name) {
700
+				$tables_to_check[] = $table_name;
701
+		}
702
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
703
+		// ok and now let's remember this was done (without needing to check the db schemas all over again)
704
+		add_option('ee_verified_db_collations', true, null, 'no');
705
+		// seeing how this ran with the fix from 10435, no need to check again
706
+		add_option('ee_verified_db_collations_again', true, null, 'no');
707
+	}
708 708
 
709 709
 
710 710
 
711
-    /**
712
-     * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
713
-     * which meant some DB collations might not have been updated
714
-     * @return void
715
-     */
716
-    public function verify_db_collations_again()
717
-    {
718
-        global $wpdb;
719
-        // double-check we haven't already done this or that the DB doesn't support it
720
-        // compare to how WordPress' upgrade_430() function does this check
721
-        if ('utf8mb4' !== $wpdb->charset
722
-            || get_option('ee_verified_db_collations_again', false)) {
723
-            return;
724
-        }
725
-        $tables_to_check = array(
726
-            'esp_attendee_meta',
727
-            'esp_message'
728
-        );
729
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
730
-        add_option('ee_verified_db_collations_again', true, null, 'no');
731
-    }
711
+	/**
712
+	 * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
713
+	 * which meant some DB collations might not have been updated
714
+	 * @return void
715
+	 */
716
+	public function verify_db_collations_again()
717
+	{
718
+		global $wpdb;
719
+		// double-check we haven't already done this or that the DB doesn't support it
720
+		// compare to how WordPress' upgrade_430() function does this check
721
+		if ('utf8mb4' !== $wpdb->charset
722
+			|| get_option('ee_verified_db_collations_again', false)) {
723
+			return;
724
+		}
725
+		$tables_to_check = array(
726
+			'esp_attendee_meta',
727
+			'esp_message'
728
+		);
729
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
730
+		add_option('ee_verified_db_collations_again', true, null, 'no');
731
+	}
732 732
 
733 733
 
734 734
 
735
-    /**
736
-     * Runs maybe_convert_table_to_utf8mb4 on the specified tables
737
-     * @param $tables_to_check
738
-     * @return boolean true if logic ran, false if it didn't
739
-     */
740
-    protected function _verify_db_collations_for_tables($tables_to_check)
741
-    {
742
-        foreach ($tables_to_check as $table_name) {
743
-            $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
744
-            if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
745
-                && $this->_get_table_analysis()->tableExists($table_name)
746
-            ) {
747
-                maybe_convert_table_to_utf8mb4($table_name);
748
-            }
749
-        }
750
-    }
735
+	/**
736
+	 * Runs maybe_convert_table_to_utf8mb4 on the specified tables
737
+	 * @param $tables_to_check
738
+	 * @return boolean true if logic ran, false if it didn't
739
+	 */
740
+	protected function _verify_db_collations_for_tables($tables_to_check)
741
+	{
742
+		foreach ($tables_to_check as $table_name) {
743
+			$table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
744
+			if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
745
+				&& $this->_get_table_analysis()->tableExists($table_name)
746
+			) {
747
+				maybe_convert_table_to_utf8mb4($table_name);
748
+			}
749
+		}
750
+	}
751 751
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 // unfortunately, this needs to be done upon INCLUSION of this file,
13 13
 // instead of construction, because it only gets constructed on first page load
14 14
 // (all other times it gets resurrected from a wordpress option)
15
-$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
15
+$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*');
16 16
 $class_to_filepath = array();
17 17
 foreach ($stages as $filepath) {
18 18
     $matches = array();
19 19
     preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+    $class_to_filepath[$matches[1]] = $filepath;
21 21
 }
22 22
 // give addons a chance to autoload their stages too
23 23
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
         if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) {
68 68
             //          echo "$version_string can be migrated from";
69 69
             return true;
70
-        } elseif (! $version_string) {
70
+        } elseif ( ! $version_string) {
71 71
             //          echo "no version string provided: $version_string";
72 72
             // no version string provided... this must be pre 4.3
73
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
73
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
74 74
         } else {
75 75
             //          echo "$version_string doesnt apply";
76 76
             return false;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function schema_changes_before_migration()
86 86
     {
87
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
87
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
88 88
         $now_in_mysql = current_time('mysql', true);
89 89
         $table_name = 'esp_answer';
90 90
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
     {
742 742
         foreach ($tables_to_check as $table_name) {
743 743
             $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
744
-            if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
744
+            if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
745 745
                 && $this->_get_table_analysis()->tableExists($table_name)
746 746
             ) {
747 747
                 maybe_convert_table_to_utf8mb4($table_name);
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_3_0.dms.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 if (! empty($stages)) {
17
-    foreach ($stages as $filepath) {
18
-        $matches = array();
19
-        preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-        $class_to_filepath[ $matches[1] ] = $filepath;
21
-    }
17
+	foreach ($stages as $filepath) {
18
+		$matches = array();
19
+		preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+		$class_to_filepath[ $matches[1] ] = $filepath;
21
+	}
22 22
 }
23 23
 // give addons a chance to autoload their stages too
24 24
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath);
@@ -31,56 +31,56 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * EE_DMS_Core_4_3_0 constructor.
36
-     *
37
-     * @param TableManager  $table_manager
38
-     * @param TableAnalysis $table_analysis
39
-     */
40
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
-    {
42
-        $this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso");
43
-        $this->_priority = 10;
44
-        $this->_migration_stages = array(
45
-            new EE_DMS_4_3_0_question_option_order(),
46
-            new EE_DMS_4_3_0_event_message_templates(),
47
-        );
48
-        parent::__construct($table_manager, $table_analysis);
49
-    }
34
+	/**
35
+	 * EE_DMS_Core_4_3_0 constructor.
36
+	 *
37
+	 * @param TableManager  $table_manager
38
+	 * @param TableAnalysis $table_analysis
39
+	 */
40
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
+	{
42
+		$this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso");
43
+		$this->_priority = 10;
44
+		$this->_migration_stages = array(
45
+			new EE_DMS_4_3_0_question_option_order(),
46
+			new EE_DMS_4_3_0_event_message_templates(),
47
+		);
48
+		parent::__construct($table_manager, $table_analysis);
49
+	}
50 50
 
51 51
 
52 52
 
53
-    public function can_migrate_from_version($version_array)
54
-    {
55
-        $version_string = $version_array['Core'];
56
-        if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) {
53
+	public function can_migrate_from_version($version_array)
54
+	{
55
+		$version_string = $version_array['Core'];
56
+		if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) {
57 57
 //          echo "$version_string can be migrated fro";
58
-            return true;
59
-        } elseif (! $version_string) {
58
+			return true;
59
+		} elseif (! $version_string) {
60 60
 //          echo "no version string provided: $version_string";
61
-            // no version string provided... this must be pre 4.2
62
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
63
-        } else {
61
+			// no version string provided... this must be pre 4.2
62
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
63
+		} else {
64 64
 //          echo "$version_string doesnt apply";
65
-            return false;
66
-        }
67
-    }
65
+			return false;
66
+		}
67
+	}
68 68
 
69 69
 
70 70
 
71
-    public function schema_changes_before_migration()
72
-    {
73
-        // relies on 4.1's EEH_Activation::create_table
74
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
75
-        $table_name = 'esp_answer';
76
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
71
+	public function schema_changes_before_migration()
72
+	{
73
+		// relies on 4.1's EEH_Activation::create_table
74
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
75
+		$table_name = 'esp_answer';
76
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
77 77
 					REG_ID int(10) unsigned NOT NULL,
78 78
 					QST_ID int(10) unsigned NOT NULL,
79 79
 					ANS_value text NOT NULL,
80 80
 					PRIMARY KEY  (ANS_ID)";
81
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
82
-        $table_name = 'esp_attendee_meta';
83
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
81
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
82
+		$table_name = 'esp_attendee_meta';
83
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
84 84
 						ATT_ID bigint(20) unsigned NOT NULL,
85 85
 						ATT_fname varchar(45) NOT NULL,
86 86
 						ATT_lname varchar(45) NOT	NULL,
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 								KEY ATT_fname (ATT_fname),
97 97
 								KEY ATT_lname (ATT_lname),
98 98
 								KEY ATT_email (ATT_email(191))";
99
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
100
-        $table_name = 'esp_country';
101
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
99
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
100
+		$table_name = 'esp_country';
101
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
102 102
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
103 103
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
104 104
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 					  CNT_is_EU tinyint(1) DEFAULT '0',
115 115
 					  CNT_active tinyint(1) DEFAULT '0',
116 116
 					  PRIMARY KEY  (CNT_ISO)";
117
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
118
-        $table_name = 'esp_datetime';
119
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
118
+		$table_name = 'esp_datetime';
119
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
120 120
 				  EVT_ID bigint(20) unsigned NOT NULL,
121 121
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
122 122
 				  DTT_description text NOT NULL,
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 						PRIMARY KEY  (DTT_ID),
132 132
 						KEY EVT_ID (EVT_ID),
133 133
 						KEY DTT_is_primary (DTT_is_primary)";
134
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_event_meta';
136
-        $sql = "
134
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_event_meta';
136
+		$sql = "
137 137
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
138 138
 			EVT_ID bigint(20) unsigned NOT NULL,
139 139
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -148,31 +148,31 @@  discard block
 block discarded – undo
148 148
 			EVT_external_URL varchar(200) NULL,
149 149
 			EVT_donations tinyint(1) NULL,
150 150
 			PRIMARY KEY  (EVTM_ID)";
151
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
152
-        $table_name = 'esp_event_question_group';
153
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
151
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
152
+		$table_name = 'esp_event_question_group';
153
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154 154
 					EVT_ID bigint(20) unsigned NOT NULL,
155 155
 					QSG_ID int(10) unsigned NOT NULL,
156 156
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
157 157
 					PRIMARY KEY  (EQG_ID)";
158
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
159
-        $table_name = 'esp_event_venue';
160
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
158
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
159
+		$table_name = 'esp_event_venue';
160
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
161 161
 				EVT_ID bigint(20) unsigned NOT NULL,
162 162
 				VNU_ID bigint(20) unsigned NOT NULL,
163 163
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
164 164
 				PRIMARY KEY  (EVV_ID)";
165
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
166
-        $table_name = 'esp_extra_meta';
167
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
165
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
166
+		$table_name = 'esp_extra_meta';
167
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
168 168
 				OBJ_ID int(11) DEFAULT NULL,
169 169
 				EXM_type varchar(45) DEFAULT NULL,
170 170
 				EXM_key varchar(45) DEFAULT NULL,
171 171
 				EXM_value text,
172 172
 				PRIMARY KEY  (EXM_ID)";
173
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
174
-        $table_name = 'esp_line_item';
175
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
173
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
174
+		$table_name = 'esp_line_item';
175
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
176 176
 				LIN_code varchar(245) NOT NULL DEFAULT '',
177 177
 				TXN_ID int(11) DEFAULT NULL,
178 178
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
 				OBJ_ID int(11) DEFAULT NULL,
189 189
 				OBJ_type varchar(45)DEFAULT NULL,
190 190
 				PRIMARY KEY  (LIN_ID)";
191
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
192
-        $table_name = 'esp_message_template';
193
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
191
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
192
+		$table_name = 'esp_message_template';
193
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
194 194
 					GRP_ID int(10) unsigned NOT NULL,
195 195
 					MTP_context varchar(50) NOT NULL,
196 196
 					MTP_template_field varchar(30) NOT NULL,
197 197
 					MTP_content text NOT NULL,
198 198
 					PRIMARY KEY  (MTP_ID),
199 199
 					KEY GRP_ID (GRP_ID)";
200
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
201
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
202
-        $table_name = 'esp_message_template_group';
203
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
200
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
201
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
202
+		$table_name = 'esp_message_template_group';
203
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
204 204
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
205 205
 					MTP_name varchar(245) NOT NULL DEFAULT '',
206 206
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
213 213
 					PRIMARY KEY  (GRP_ID),
214 214
 					KEY MTP_user_id (MTP_user_id)";
215
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_event_message_template';
217
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
215
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_event_message_template';
217
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
218 218
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
219 219
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
220 220
 					PRIMARY KEY  (EMT_ID),
221 221
 					KEY EVT_ID (EVT_ID),
222 222
 					KEY GRP_ID (GRP_ID)";
223
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_payment';
225
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
223
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_payment';
225
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
226 226
 					TXN_ID int(10) unsigned DEFAULT NULL,
227 227
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
228 228
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 					PRIMARY KEY  (PAY_ID),
239 239
 					KEY TXN_ID (TXN_ID),
240 240
 					KEY PAY_timestamp (PAY_timestamp)";
241
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
242
-        $table_name = "esp_ticket";
243
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
241
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
242
+		$table_name = "esp_ticket";
243
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
244 244
 					  TTM_ID int(10) unsigned NOT NULL,
245 245
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
246 246
 					  TKT_description text NOT NULL,
@@ -260,28 +260,28 @@  discard block
 block discarded – undo
260 260
 					  TKT_parent int(10) unsigned DEFAULT '0',
261 261
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
262 262
 					  PRIMARY KEY  (TKT_ID)";
263
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
-        $table_name = "esp_ticket_price";
265
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
263
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
+		$table_name = "esp_ticket_price";
265
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
266 266
 					  TKT_ID int(10) unsigned NOT NULL,
267 267
 					  PRC_ID int(10) unsigned NOT NULL,
268 268
 					  PRIMARY KEY  (TKP_ID)";
269
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
270
-        $table_name = "esp_datetime_ticket";
271
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
269
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
270
+		$table_name = "esp_datetime_ticket";
271
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
272 272
 					  DTT_ID int(10) unsigned NOT NULL,
273 273
 					  TKT_ID int(10) unsigned NOT NULL,
274 274
 					  PRIMARY KEY  (DTK_ID)";
275
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
276
-        $table_name = "esp_ticket_template";
277
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
275
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
276
+		$table_name = "esp_ticket_template";
277
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
278 278
 					  TTM_name varchar(45) NOT NULL,
279 279
 					  TTM_description text,
280 280
 					  TTM_file varchar(45),
281 281
 					  PRIMARY KEY  (TTM_ID)";
282
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = "esp_price";
284
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
282
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
283
+		$table_name = "esp_price";
284
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
285 285
 					  PRT_ID tinyint(3) unsigned NOT NULL,
286 286
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
287 287
 					  PRC_name varchar(245) NOT NULL,
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
293 293
 					  PRC_parent int(10) unsigned DEFAULT 0,
294 294
 					  PRIMARY KEY  (PRC_ID)";
295
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
296
-        $table_name = "esp_price_type";
297
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
295
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
296
+		$table_name = "esp_price_type";
297
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
298 298
 				  PRT_name varchar(45) NOT NULL,
299 299
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
300 300
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
303 303
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
304 304
 				  PRIMARY KEY  (PRT_ID)";
305
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
306
-        $table_name = 'esp_question';
307
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
305
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
306
+		$table_name = 'esp_question';
307
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
308 308
 					QST_display_text text NOT NULL,
309 309
 					QST_admin_label varchar(255) NOT NULL,
310 310
 					QST_system varchar(25) DEFAULT NULL,
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 					QST_wp_user bigint(20) unsigned NULL,
317 317
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
318 318
 					PRIMARY KEY  (QST_ID)';
319
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
320
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
321
-        $table_name = 'esp_question_group';
322
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
319
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
320
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
321
+		$table_name = 'esp_question_group';
322
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
323 323
 					QSG_name varchar(255) NOT NULL,
324 324
 					QSG_identifier varchar(100) NOT NULL,
325 325
 					QSG_desc text NULL,
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
331 331
 					PRIMARY KEY  (QSG_ID),
332 332
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
333
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
-        $table_name = 'esp_question_group_question';
335
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
333
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
+		$table_name = 'esp_question_group_question';
335
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
336 336
 					QSG_ID int(10) unsigned NOT NULL,
337 337
 					QST_ID int(10) unsigned NOT NULL,
338 338
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
339 339
 					PRIMARY KEY  (QGQ_ID) ";
340
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
-        $table_name = 'esp_question_option';
342
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
340
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
+		$table_name = 'esp_question_option';
342
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343 343
 					QSO_value varchar(255) NOT NULL,
344 344
 					QSO_desc text NOT NULL,
345 345
 					QST_ID int(10) unsigned NOT NULL,
346 346
 					QSO_order int(10) unsigned NOT NULL DEFAULT 0,
347 347
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
348 348
 					PRIMARY KEY  (QSO_ID)";
349
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
350
-        $table_name = 'esp_registration';
351
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
349
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
350
+		$table_name = 'esp_registration';
351
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
352 352
 					  EVT_ID bigint(20) unsigned NOT NULL,
353 353
 					  ATT_ID bigint(20) unsigned NOT NULL,
354 354
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 					  KEY STS_ID (STS_ID),
372 372
 					  KEY REG_url_link (REG_url_link),
373 373
 					  KEY REG_code (REG_code)";
374
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
375
-        $table_name = 'esp_checkin';
376
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
374
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
375
+		$table_name = 'esp_checkin';
376
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
377 377
 					REG_ID int(10) unsigned NOT NULL,
378 378
 					DTT_ID int(10) unsigned NOT NULL,
379 379
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
380 380
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
381 381
 					PRIMARY KEY  (CHK_ID)";
382
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
383
-        $table_name = 'esp_state';
384
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
382
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
383
+		$table_name = 'esp_state';
384
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
385 385
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
386 386
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
387 387
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
388 388
 					  STA_active tinyint(1) DEFAULT '1',
389 389
 					  PRIMARY KEY  (STA_ID)";
390
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
391
-        $table_name = 'esp_status';
392
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
390
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
391
+		$table_name = 'esp_status';
392
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
393 393
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
394 394
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
395 395
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
398 398
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
399 399
 					  KEY STS_type (STS_type)";
400
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
401
-        $table_name = 'esp_transaction';
402
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
400
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
401
+		$table_name = 'esp_transaction';
402
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
403 403
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
404 404
 					  TXN_total decimal(10,3) DEFAULT '0.00',
405 405
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 					  PRIMARY KEY  (TXN_ID),
410 410
 					  KEY TXN_timestamp (TXN_timestamp),
411 411
 					  KEY STS_ID (STS_ID)";
412
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
413
-        $table_name = 'esp_venue_meta';
414
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
412
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
413
+		$table_name = 'esp_venue_meta';
414
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
415 415
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
416 416
 			VNU_address varchar(255) DEFAULT NULL,
417 417
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -429,77 +429,77 @@  discard block
 block discarded – undo
429 429
 			PRIMARY KEY  (VNUM_ID),
430 430
 			KEY STA_ID (STA_ID),
431 431
 			KEY CNT_ISO (CNT_ISO)";
432
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
433
-        $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
434
-        // setting up the DEFAULT stats and countries is also essential for the data migrations to run
435
-        // (because many need to convert old string states to foreign keys into the states table)
436
-        $script_with_defaults->insert_default_states();
437
-        $script_with_defaults->insert_default_countries();
438
-        // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
439
-        $script_with_defaults->insert_default_price_types();
440
-        $script_with_defaults->insert_default_prices();
441
-        // but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's
442
-        $this->insert_default_tickets();
443
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
444
-        EE_Config::instance()->update_espresso_config(false, true);
445
-        return true;
446
-    }
432
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
433
+		$script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
434
+		// setting up the DEFAULT stats and countries is also essential for the data migrations to run
435
+		// (because many need to convert old string states to foreign keys into the states table)
436
+		$script_with_defaults->insert_default_states();
437
+		$script_with_defaults->insert_default_countries();
438
+		// setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
439
+		$script_with_defaults->insert_default_price_types();
440
+		$script_with_defaults->insert_default_prices();
441
+		// but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's
442
+		$this->insert_default_tickets();
443
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
444
+		EE_Config::instance()->update_espresso_config(false, true);
445
+		return true;
446
+	}
447 447
 
448 448
 
449 449
 
450
-    /**
451
-     * @return boolean
452
-     */
453
-    public function schema_changes_after_migration()
454
-    {
455
-        return true;
456
-    }
450
+	/**
451
+	 * @return boolean
452
+	 */
453
+	public function schema_changes_after_migration()
454
+	{
455
+		return true;
456
+	}
457 457
 
458 458
 
459 459
 
460
-    public function migration_page_hooks()
461
-    {
462
-    }
460
+	public function migration_page_hooks()
461
+	{
462
+	}
463 463
 
464 464
 
465 465
 
466
-    /**
467
-     * insert DEFAULT ticket
468
-     * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field
469
-     *
470
-     * @access public
471
-     * @static
472
-     * @return void
473
-     */
474
-    public function insert_default_tickets()
475
-    {
476
-        global $wpdb;
477
-        $ticket_table = $wpdb->prefix . "esp_ticket";
478
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
480
-            $tickets_exist = $wpdb->get_var($SQL);
481
-            if (! $tickets_exist) {
482
-                $SQL = "INSERT INTO $ticket_table
466
+	/**
467
+	 * insert DEFAULT ticket
468
+	 * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field
469
+	 *
470
+	 * @access public
471
+	 * @static
472
+	 * @return void
473
+	 */
474
+	public function insert_default_tickets()
475
+	{
476
+		global $wpdb;
477
+		$ticket_table = $wpdb->prefix . "esp_ticket";
478
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
480
+			$tickets_exist = $wpdb->get_var($SQL);
481
+			if (! $tickets_exist) {
482
+				$SQL = "INSERT INTO $ticket_table
483 483
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, 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
484 484
 					( 1, 0, '"
485
-                       . __("Free Ticket", "event_espresso")
486
-                       . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
487
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
488
-                $wpdb->query($SQL);
489
-            }
490
-        }
491
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
492
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
494
-            $ticket_prc_exist = $wpdb->get_var($SQL);
495
-            if (! $ticket_prc_exist) {
496
-                $SQL = "INSERT INTO $ticket_price_table
485
+					   . __("Free Ticket", "event_espresso")
486
+					   . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
487
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
488
+				$wpdb->query($SQL);
489
+			}
490
+		}
491
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
492
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
494
+			$ticket_prc_exist = $wpdb->get_var($SQL);
495
+			if (! $ticket_prc_exist) {
496
+				$SQL = "INSERT INTO $ticket_price_table
497 497
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
498 498
 				( 1, 1, 1 )
499 499
 				";
500
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
501
-                $wpdb->query($SQL);
502
-            }
503
-        }
504
-    }
500
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
501
+				$wpdb->query($SQL);
502
+			}
503
+		}
504
+	}
505 505
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 // unfortunately, this needs to be done upon INCLUSION of this file,
12 12
 // instead of construction, because it only gets constructed on first page load
13 13
 // (all other times it gets resurrected from a wordpress option)
14
-$stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*');
14
+$stages = glob(EE_CORE.'data_migration_scripts/4_3_0_stages/*');
15 15
 $class_to_filepath = array();
16
-if (! empty($stages)) {
16
+if ( ! empty($stages)) {
17 17
     foreach ($stages as $filepath) {
18 18
         $matches = array();
19 19
         preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-        $class_to_filepath[ $matches[1] ] = $filepath;
20
+        $class_to_filepath[$matches[1]] = $filepath;
21 21
     }
22 22
 }
23 23
 // give addons a chance to autoload their stages too
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
         if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) {
57 57
 //          echo "$version_string can be migrated fro";
58 58
             return true;
59
-        } elseif (! $version_string) {
59
+        } elseif ( ! $version_string) {
60 60
 //          echo "no version string provided: $version_string";
61 61
             // no version string provided... this must be pre 4.2
62
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
62
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
63 63
         } else {
64 64
 //          echo "$version_string doesnt apply";
65 65
             return false;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public function schema_changes_before_migration()
72 72
     {
73 73
         // relies on 4.1's EEH_Activation::create_table
74
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
74
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
75 75
         $table_name = 'esp_answer';
76 76
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
77 77
 					REG_ID int(10) unsigned NOT NULL,
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
     public function insert_default_tickets()
475 475
     {
476 476
         global $wpdb;
477
-        $ticket_table = $wpdb->prefix . "esp_ticket";
477
+        $ticket_table = $wpdb->prefix."esp_ticket";
478 478
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
479
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
480 480
             $tickets_exist = $wpdb->get_var($SQL);
481
-            if (! $tickets_exist) {
481
+            if ( ! $tickets_exist) {
482 482
                 $SQL = "INSERT INTO $ticket_table
483 483
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, 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
484 484
 					( 1, 0, '"
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
                 $wpdb->query($SQL);
489 489
             }
490 490
         }
491
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
491
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
492 492
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
493
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
494 494
             $ticket_prc_exist = $wpdb->get_var($SQL);
495
-            if (! $ticket_prc_exist) {
495
+            if ( ! $ticket_prc_exist) {
496 496
                 $SQL = "INSERT INTO $ticket_price_table
497 497
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
498 498
 				( 1, 1, 1 )
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_6_0.dms.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 foreach ($stages as $filepath) {
17
-    $matches = array();
18
-    preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
-    $class_to_filepath[ $matches[1] ] = $filepath;
17
+	$matches = array();
18
+	preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
+	$class_to_filepath[ $matches[1] ] = $filepath;
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
@@ -35,69 +35,69 @@  discard block
 block discarded – undo
35 35
 class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base
36 36
 {
37 37
 
38
-    /**
39
-     * return EE_DMS_Core_4_6_0
40
-     *
41
-     * @param TableManager  $table_manager
42
-     * @param TableAnalysis $table_analysis
43
-     */
44
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
-    {
46
-        $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
-        $this->_priority = 10;
48
-        $this->_migration_stages = array(
49
-            new EE_DMS_4_6_0_gateways(),
50
-            new EE_DMS_4_6_0_question_types(),
51
-            new EE_DMS_4_6_0_country_system_question(),
52
-            new EE_DMS_4_6_0_state_system_question(),
53
-            new EE_DMS_4_6_0_billing_info(),
54
-            new EE_DMS_4_6_0_transactions(),
55
-            new EE_DMS_4_6_0_payments(),
56
-            new EE_DMS_4_6_0_invoice_settings(),
57
-        );
58
-        parent::__construct($table_manager, $table_analysis);
59
-    }
38
+	/**
39
+	 * return EE_DMS_Core_4_6_0
40
+	 *
41
+	 * @param TableManager  $table_manager
42
+	 * @param TableAnalysis $table_analysis
43
+	 */
44
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
+	{
46
+		$this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
+		$this->_priority = 10;
48
+		$this->_migration_stages = array(
49
+			new EE_DMS_4_6_0_gateways(),
50
+			new EE_DMS_4_6_0_question_types(),
51
+			new EE_DMS_4_6_0_country_system_question(),
52
+			new EE_DMS_4_6_0_state_system_question(),
53
+			new EE_DMS_4_6_0_billing_info(),
54
+			new EE_DMS_4_6_0_transactions(),
55
+			new EE_DMS_4_6_0_payments(),
56
+			new EE_DMS_4_6_0_invoice_settings(),
57
+		);
58
+		parent::__construct($table_manager, $table_analysis);
59
+	}
60 60
 
61 61
 
62 62
 
63
-    /**
64
-     * @param array $version_array
65
-     * @return bool
66
-     */
67
-    public function can_migrate_from_version($version_array)
68
-    {
69
-        $version_string = $version_array['Core'];
70
-        if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) {
63
+	/**
64
+	 * @param array $version_array
65
+	 * @return bool
66
+	 */
67
+	public function can_migrate_from_version($version_array)
68
+	{
69
+		$version_string = $version_array['Core'];
70
+		if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) {
71 71
 //          echo "$version_string can be migrated from";
72
-            return true;
73
-        } elseif (! $version_string) {
72
+			return true;
73
+		} elseif (! $version_string) {
74 74
 //          echo "no version string provided: $version_string";
75
-            // no version string provided... this must be pre 4.3
76
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
-        } else {
75
+			// no version string provided... this must be pre 4.3
76
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
+		} else {
78 78
 //          echo "$version_string doesnt apply";
79
-            return false;
80
-        }
81
-    }
79
+			return false;
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * @return bool
87
-     */
88
-    public function schema_changes_before_migration()
89
-    {
90
-        // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
-        $table_name = 'esp_answer';
93
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
85
+	/**
86
+	 * @return bool
87
+	 */
88
+	public function schema_changes_before_migration()
89
+	{
90
+		// relies on 4.1's EEH_Activation::create_table
91
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+		$table_name = 'esp_answer';
93
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID int(10) unsigned NOT NULL,
95 95
 					QST_ID int(10) unsigned NOT NULL,
96 96
 					ANS_value text NOT NULL,
97 97
 					PRIMARY KEY  (ANS_ID)";
98
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
-        $table_name = 'esp_attendee_meta';
100
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
98
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
+		$table_name = 'esp_attendee_meta';
100
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
101 101
 						ATT_ID bigint(20) unsigned NOT NULL,
102 102
 						ATT_fname varchar(45) NOT NULL,
103 103
 						ATT_lname varchar(45) NOT	NULL,
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 								KEY ATT_fname (ATT_fname),
114 114
 								KEY ATT_lname (ATT_lname),
115 115
 								KEY ATT_email (ATT_email(191))";
116
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
-        $table_name = 'esp_country';
118
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
116
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
+		$table_name = 'esp_country';
118
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
119 119
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
120 120
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
121 121
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 					  CNT_is_EU tinyint(1) DEFAULT '0',
132 132
 					  CNT_active tinyint(1) DEFAULT '0',
133 133
 					  PRIMARY KEY  (CNT_ISO)";
134
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_currency';
136
-        $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
134
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_currency';
136
+		$sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
137 137
 				CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar',
138 138
 				CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars',
139 139
 				CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$',
140 140
 				CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
141 141
 				CUR_active tinyint(1) DEFAULT '0',
142 142
 				PRIMARY KEY  (CUR_code)";
143
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
-        $table_name = 'esp_currency_payment_method';
145
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
143
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
+		$table_name = 'esp_currency_payment_method';
145
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
146 146
 				CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
147 147
 				PMD_ID int(11) NOT NULL,
148 148
 				PRIMARY KEY  (CPM_ID)";
149
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
-        $table_name = 'esp_datetime';
151
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
149
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
+		$table_name = 'esp_datetime';
151
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
152 152
 				  EVT_ID bigint(20) unsigned NOT NULL,
153 153
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
154 154
 				  DTT_description text NOT NULL,
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 						PRIMARY KEY  (DTT_ID),
164 164
 						KEY EVT_ID (EVT_ID),
165 165
 						KEY DTT_is_primary (DTT_is_primary)";
166
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
-        $table_name = 'esp_event_meta';
168
-        $sql = "
166
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
+		$table_name = 'esp_event_meta';
168
+		$sql = "
169 169
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
170 170
 			EVT_ID bigint(20) unsigned NOT NULL,
171 171
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
 			EVT_external_URL varchar(200) NULL,
181 181
 			EVT_donations tinyint(1) NULL,
182 182
 			PRIMARY KEY  (EVTM_ID)";
183
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
-        $table_name = 'esp_event_question_group';
185
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
183
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
+		$table_name = 'esp_event_question_group';
185
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
186 186
 					EVT_ID bigint(20) unsigned NOT NULL,
187 187
 					QSG_ID int(10) unsigned NOT NULL,
188 188
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
189 189
 					PRIMARY KEY  (EQG_ID)";
190
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_venue';
192
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
190
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_venue';
192
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
193 193
 				EVT_ID bigint(20) unsigned NOT NULL,
194 194
 				VNU_ID bigint(20) unsigned NOT NULL,
195 195
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
196 196
 				PRIMARY KEY  (EVV_ID)";
197
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_extra_meta';
199
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
197
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_extra_meta';
199
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
200 200
 				OBJ_ID int(11) DEFAULT NULL,
201 201
 				EXM_type varchar(45) DEFAULT NULL,
202 202
 				EXM_key varchar(45) DEFAULT NULL,
203 203
 				EXM_value text,
204 204
 				PRIMARY KEY  (EXM_ID)";
205
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
-        $table_name = 'esp_line_item';
207
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
205
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
+		$table_name = 'esp_line_item';
207
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
208 208
 				LIN_code varchar(245) NOT NULL DEFAULT '',
209 209
 				TXN_ID int(11) DEFAULT NULL,
210 210
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 				OBJ_ID int(11) DEFAULT NULL,
221 221
 				OBJ_type varchar(45)DEFAULT NULL,
222 222
 				PRIMARY KEY  (LIN_ID)";
223
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_log';
225
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
223
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_log';
225
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
226 226
 				LOG_time datetime DEFAULT NULL,
227 227
 				OBJ_ID varchar(45) DEFAULT NULL,
228 228
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -230,19 +230,19 @@  discard block
 block discarded – undo
230 230
 				LOG_message text,
231 231
 				LOG_wp_user int(11) DEFAULT NULL,
232 232
 				PRIMARY KEY  (LOG_ID)";
233
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
-        $table_name = 'esp_message_template';
235
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
233
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
+		$table_name = 'esp_message_template';
235
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
236 236
 					GRP_ID int(10) unsigned NOT NULL,
237 237
 					MTP_context varchar(50) NOT NULL,
238 238
 					MTP_template_field varchar(30) NOT NULL,
239 239
 					MTP_content text NOT NULL,
240 240
 					PRIMARY KEY  (MTP_ID),
241 241
 					KEY GRP_ID (GRP_ID)";
242
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
-        $table_name = 'esp_message_template_group';
245
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
242
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
+		$table_name = 'esp_message_template_group';
245
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
246 246
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
247 247
 					MTP_name varchar(245) NOT NULL DEFAULT '',
248 248
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
255 255
 					PRIMARY KEY  (GRP_ID),
256 256
 					KEY MTP_user_id (MTP_user_id)";
257
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
-        $table_name = 'esp_event_message_template';
259
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
257
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
+		$table_name = 'esp_event_message_template';
259
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
260 260
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
261 261
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
262 262
 					PRIMARY KEY  (EMT_ID),
263 263
 					KEY EVT_ID (EVT_ID),
264 264
 					KEY GRP_ID (GRP_ID)";
265
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
-        $table_name = 'esp_payment';
267
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
265
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
+		$table_name = 'esp_payment';
267
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
268 268
 					TXN_ID int(10) unsigned DEFAULT NULL,
269 269
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
270 270
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 					PRIMARY KEY  (PAY_ID),
282 282
 					KEY TXN_ID (TXN_ID),
283 283
 					KEY PAY_timestamp (PAY_timestamp)";
284
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
-        $table_name = 'esp_payment_method';
286
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
284
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
+		$table_name = 'esp_payment_method';
286
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
287 287
 				PMD_type varchar(124) DEFAULT NULL,
288 288
 				PMD_name varchar(255) DEFAULT NULL,
289 289
 				PMD_desc text,
@@ -298,28 +298,28 @@  discard block
 block discarded – undo
298 298
 				PMD_scope varchar(255) NULL DEFAULT 'frontend',
299 299
 				PRIMARY KEY  (PMD_ID),
300 300
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)";
301
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
-        $table_name = "esp_ticket_price";
303
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
301
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
+		$table_name = "esp_ticket_price";
303
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
304 304
 					  TKT_ID int(10) unsigned NOT NULL,
305 305
 					  PRC_ID int(10) unsigned NOT NULL,
306 306
 					  PRIMARY KEY  (TKP_ID)";
307
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
-        $table_name = "esp_datetime_ticket";
309
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
307
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
+		$table_name = "esp_datetime_ticket";
309
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
310 310
 					  DTT_ID int(10) unsigned NOT NULL,
311 311
 					  TKT_ID int(10) unsigned NOT NULL,
312 312
 					  PRIMARY KEY  (DTK_ID)";
313
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
-        $table_name = "esp_ticket_template";
315
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
313
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
+		$table_name = "esp_ticket_template";
315
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316 316
 					  TTM_name varchar(45) NOT NULL,
317 317
 					  TTM_description text,
318 318
 					  TTM_file varchar(45),
319 319
 					  PRIMARY KEY  (TTM_ID)";
320
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
-        $table_name = 'esp_question';
322
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
320
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
+		$table_name = 'esp_question';
322
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
323 323
 					QST_display_text text NOT NULL,
324 324
 					QST_admin_label varchar(255) NOT NULL,
325 325
 					QST_system varchar(25) DEFAULT NULL,
@@ -331,25 +331,25 @@  discard block
 block discarded – undo
331 331
 					QST_wp_user bigint(20) unsigned NULL,
332 332
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
333 333
 					PRIMARY KEY  (QST_ID)';
334
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
-        $table_name = 'esp_question_group_question';
336
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
334
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
+		$table_name = 'esp_question_group_question';
336
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
337 337
 					QSG_ID int(10) unsigned NOT NULL,
338 338
 					QST_ID int(10) unsigned NOT NULL,
339 339
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
340 340
 					PRIMARY KEY  (QGQ_ID) ";
341
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
-        $table_name = 'esp_question_option';
343
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question_option';
343
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
344 344
 					QSO_value varchar(255) NOT NULL,
345 345
 					QSO_desc text NOT NULL,
346 346
 					QST_ID int(10) unsigned NOT NULL,
347 347
 					QSO_order int(10) unsigned NOT NULL DEFAULT 0,
348 348
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
349 349
 					PRIMARY KEY  (QSO_ID)";
350
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_registration';
352
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_registration';
352
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 					  EVT_ID bigint(20) unsigned NOT NULL,
354 354
 					  ATT_ID bigint(20) unsigned NOT NULL,
355 355
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
 					  KEY STS_ID (STS_ID),
373 373
 					  KEY REG_url_link (REG_url_link),
374 374
 					  KEY REG_code (REG_code)";
375
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
-        $table_name = 'esp_checkin';
377
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
+		$table_name = 'esp_checkin';
377
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					REG_ID int(10) unsigned NOT NULL,
379 379
 					DTT_ID int(10) unsigned NOT NULL,
380 380
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
381 381
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
382 382
 					PRIMARY KEY  (CHK_ID)";
383
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
-        $table_name = 'esp_state';
385
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
383
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
+		$table_name = 'esp_state';
385
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
386 386
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
387 387
 					  STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL,
388 388
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
389 389
 					  STA_active tinyint(1) DEFAULT '1',
390 390
 					  PRIMARY KEY  (STA_ID)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_status';
393
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_status';
393
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
394 394
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
395 395
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
396 396
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
399 399
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
400 400
 					  KEY STS_type (STS_type)";
401
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
-        $table_name = 'esp_transaction';
403
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
401
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
+		$table_name = 'esp_transaction';
403
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
404 404
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
405 405
 					  TXN_total decimal(10,3) DEFAULT '0.00',
406 406
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 					  PRIMARY KEY  (TXN_ID),
413 413
 					  KEY TXN_timestamp (TXN_timestamp),
414 414
 					  KEY STS_ID (STS_ID)";
415
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
-        $table_name = 'esp_venue_meta';
417
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
415
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
+		$table_name = 'esp_venue_meta';
417
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
418 418
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
419 419
 			VNU_address varchar(255) DEFAULT NULL,
420 420
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 			PRIMARY KEY  (VNUM_ID),
433 433
 			KEY STA_ID (STA_ID),
434 434
 			KEY CNT_ISO (CNT_ISO)";
435
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
-        // modified tables
437
-        $table_name = "esp_price";
438
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
435
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
+		// modified tables
437
+		$table_name = "esp_price";
438
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439 439
 					  PRT_ID tinyint(3) unsigned NOT NULL,
440 440
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
441 441
 					  PRC_name varchar(245) NOT NULL,
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 					  PRC_wp_user bigint(20) unsigned NULL,
448 448
 					  PRC_parent int(10) unsigned DEFAULT 0,
449 449
 					  PRIMARY KEY  (PRC_ID)";
450
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
-        $table_name = "esp_price_type";
452
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
450
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
+		$table_name = "esp_price_type";
452
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
453 453
 				  PRT_name varchar(45) NOT NULL,
454 454
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
455 455
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
459 459
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
460 460
 				  PRIMARY KEY  (PRT_ID)";
461
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
-        $table_name = "esp_ticket";
463
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
461
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
+		$table_name = "esp_ticket";
463
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
464 464
 					  TTM_ID int(10) unsigned NOT NULL,
465 465
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
466 466
 					  TKT_description text NOT NULL,
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 					  TKT_parent int(10) unsigned DEFAULT '0',
482 482
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
483 483
 					  PRIMARY KEY  (TKT_ID)";
484
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
-        $table_name = 'esp_question_group';
487
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
484
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
+		$table_name = 'esp_question_group';
487
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
488 488
 					QSG_name varchar(255) NOT NULL,
489 489
 					QSG_identifier varchar(100) NOT NULL,
490 490
 					QSG_desc text NULL,
@@ -496,124 +496,124 @@  discard block
 block discarded – undo
496 496
 					QSG_wp_user bigint(20) unsigned NULL,
497 497
 					PRIMARY KEY  (QSG_ID),
498 498
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
499
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
-        // (because many need to convert old string states to foreign keys into the states table)
503
-        $script_4_1_defaults->insert_default_states();
504
-        $script_4_1_defaults->insert_default_countries();
505
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
-        $script_4_5_defaults->insert_default_price_types();
508
-        $script_4_5_defaults->insert_default_prices();
509
-        $script_4_5_defaults->insert_default_tickets();
510
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
-        EE_Config::instance()->update_espresso_config(false, true);
512
-        $this->add_default_admin_only_payments();
513
-        $this->insert_default_currencies();
514
-        return true;
515
-    }
499
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
+		// (because many need to convert old string states to foreign keys into the states table)
503
+		$script_4_1_defaults->insert_default_states();
504
+		$script_4_1_defaults->insert_default_countries();
505
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
+		$script_4_5_defaults->insert_default_price_types();
508
+		$script_4_5_defaults->insert_default_prices();
509
+		$script_4_5_defaults->insert_default_tickets();
510
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
+		EE_Config::instance()->update_espresso_config(false, true);
512
+		$this->add_default_admin_only_payments();
513
+		$this->insert_default_currencies();
514
+		return true;
515
+	}
516 516
 
517 517
 
518 518
 
519
-    /**
520
-     * @return boolean
521
-     */
522
-    public function schema_changes_after_migration()
523
-    {
524
-        return true;
525
-    }
519
+	/**
520
+	 * @return boolean
521
+	 */
522
+	public function schema_changes_after_migration()
523
+	{
524
+		return true;
525
+	}
526 526
 
527 527
 
528 528
 
529
-    public function migration_page_hooks()
530
-    {
531
-    }
529
+	public function migration_page_hooks()
530
+	{
531
+	}
532 532
 
533 533
 
534 534
 
535
-    public function add_default_admin_only_payments()
536
-    {
537
-        global $wpdb;
538
-        $table_name = $wpdb->prefix . "esp_payment_method";
539
-        $user_id = EEH_Activation::get_default_creator_id();
540
-        if ($this->_get_table_analysis()->tableExists($table_name)) {
541
-            $SQL = "SELECT COUNT( * ) FROM $table_name";
542
-            $existing_payment_methods = $wpdb->get_var($SQL);
543
-            $default_admin_only_payment_methods = apply_filters(
544
-                'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
-                array(
546
-                    (string) __("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
-                    (string) __("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
-                    (string) __("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
-                    (string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
-                    (string) __("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
-                    (string) __("Invoice", 'event_espresso')     => __(
552
-                        "Invoice received with monies included",
553
-                        'event_espresso'
554
-                    ),
555
-                    (string) __("Money Order", 'event_espresso') => '',
556
-                    (string) __("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
-                    (string) __('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
-                )
559
-            );
560
-            // make sure we hae payment method records for the following
561
-            // so admins can record payments for them from the admin page
562
-            foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
-                $slug = sanitize_key($nicename);
564
-                // check that such a payment method exists
565
-                $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
-                if (! $exists) {
567
-                    $values = array(
568
-                        'PMD_type'       => 'Admin_Only',
569
-                        'PMD_name'       => $nicename,
570
-                        'PMD_admin_name' => $nicename,
571
-                        'PMD_admin_desc' => $description,
572
-                        'PMD_slug'       => $slug,
573
-                        'PMD_wp_user'    => $user_id,
574
-                        'PMD_scope'      => serialize(array('ADMIN')),
575
-                    );
576
-                    $success = $wpdb->insert(
577
-                        $table_name,
578
-                        $values,
579
-                        array(
580
-                            '%s',// PMD_type
581
-                            '%s',// PMD_name
582
-                            '%s',// PMD_admin_name
583
-                            '%s',// PMD_admin_desc
584
-                            '%s',// PMD_slug
585
-                            '%d',// PMD_wp_user
586
-                            '%s',// PMD_scope
587
-                        )
588
-                    );
589
-                    if (! $success) {
590
-                        $this->add_error(sprintf(__(
591
-                            "Could not insert new admin-only payment method with values %s during migration",
592
-                            "event_espresso"
593
-                        ), $this->_json_encode($values)));
594
-                    }
595
-                }
596
-            }
597
-        }
598
-    }
535
+	public function add_default_admin_only_payments()
536
+	{
537
+		global $wpdb;
538
+		$table_name = $wpdb->prefix . "esp_payment_method";
539
+		$user_id = EEH_Activation::get_default_creator_id();
540
+		if ($this->_get_table_analysis()->tableExists($table_name)) {
541
+			$SQL = "SELECT COUNT( * ) FROM $table_name";
542
+			$existing_payment_methods = $wpdb->get_var($SQL);
543
+			$default_admin_only_payment_methods = apply_filters(
544
+				'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
+				array(
546
+					(string) __("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
+					(string) __("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
+					(string) __("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
+					(string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
+					(string) __("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
+					(string) __("Invoice", 'event_espresso')     => __(
552
+						"Invoice received with monies included",
553
+						'event_espresso'
554
+					),
555
+					(string) __("Money Order", 'event_espresso') => '',
556
+					(string) __("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
+					(string) __('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
+				)
559
+			);
560
+			// make sure we hae payment method records for the following
561
+			// so admins can record payments for them from the admin page
562
+			foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
+				$slug = sanitize_key($nicename);
564
+				// check that such a payment method exists
565
+				$exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
+				if (! $exists) {
567
+					$values = array(
568
+						'PMD_type'       => 'Admin_Only',
569
+						'PMD_name'       => $nicename,
570
+						'PMD_admin_name' => $nicename,
571
+						'PMD_admin_desc' => $description,
572
+						'PMD_slug'       => $slug,
573
+						'PMD_wp_user'    => $user_id,
574
+						'PMD_scope'      => serialize(array('ADMIN')),
575
+					);
576
+					$success = $wpdb->insert(
577
+						$table_name,
578
+						$values,
579
+						array(
580
+							'%s',// PMD_type
581
+							'%s',// PMD_name
582
+							'%s',// PMD_admin_name
583
+							'%s',// PMD_admin_desc
584
+							'%s',// PMD_slug
585
+							'%d',// PMD_wp_user
586
+							'%s',// PMD_scope
587
+						)
588
+					);
589
+					if (! $success) {
590
+						$this->add_error(sprintf(__(
591
+							"Could not insert new admin-only payment method with values %s during migration",
592
+							"event_espresso"
593
+						), $this->_json_encode($values)));
594
+					}
595
+				}
596
+			}
597
+		}
598
+	}
599 599
 
600 600
 
601 601
 
602
-    /**
603
-     * insert_default_countries
604
-     *
605
-     * @static
606
-     * @return void
607
-     */
608
-    public function insert_default_currencies()
609
-    {
610
-        global $wpdb;
611
-        $currency_table = $wpdb->prefix . "esp_currency";
612
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
-            $SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
-            $countries = $wpdb->get_var($SQL);
615
-            if (! $countries) {
616
-                $SQL = "INSERT INTO $currency_table
602
+	/**
603
+	 * insert_default_countries
604
+	 *
605
+	 * @static
606
+	 * @return void
607
+	 */
608
+	public function insert_default_currencies()
609
+	{
610
+		global $wpdb;
611
+		$currency_table = $wpdb->prefix . "esp_currency";
612
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
+			$SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
+			$countries = $wpdb->get_var($SQL);
615
+			if (! $countries) {
616
+				$SQL = "INSERT INTO $currency_table
617 617
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
618 618
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
619 619
 				( 'AED',  'Dirham',  'Dirhams', 'د.إ',2,1),
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 				( 'ZAR',  'Rand',  'Rands',  'R',  2,1),
768 768
 				( 'ZMK',  'Kwacha',  'Kwachas',  '',  2,1),
769 769
 				( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);";
770
-                $wpdb->query($SQL);
771
-            }
772
-        }
773
-    }
770
+				$wpdb->query($SQL);
771
+			}
772
+		}
773
+	}
774 774
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 // unfortunately, this needs to be done upon INCLUSION of this file,
12 12
 // instead of construction, because it only gets constructed on first page load
13 13
 // (all other times it gets resurrected from a wordpress option)
14
-$stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*');
14
+$stages = glob(EE_CORE.'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 foreach ($stages as $filepath) {
17 17
     $matches = array();
18 18
     preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
-    $class_to_filepath[ $matches[1] ] = $filepath;
19
+    $class_to_filepath[$matches[1]] = $filepath;
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
         if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) {
71 71
 //          echo "$version_string can be migrated from";
72 72
             return true;
73
-        } elseif (! $version_string) {
73
+        } elseif ( ! $version_string) {
74 74
 //          echo "no version string provided: $version_string";
75 75
             // no version string provided... this must be pre 4.3
76
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
76
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
77 77
         } else {
78 78
 //          echo "$version_string doesnt apply";
79 79
             return false;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     public function schema_changes_before_migration()
89 89
     {
90 90
         // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
91
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
92 92
         $table_name = 'esp_answer';
93 93
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID int(10) unsigned NOT NULL,
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     public function add_default_admin_only_payments()
536 536
     {
537 537
         global $wpdb;
538
-        $table_name = $wpdb->prefix . "esp_payment_method";
538
+        $table_name = $wpdb->prefix."esp_payment_method";
539 539
         $user_id = EEH_Activation::get_default_creator_id();
540 540
         if ($this->_get_table_analysis()->tableExists($table_name)) {
541 541
             $SQL = "SELECT COUNT( * ) FROM $table_name";
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
                 $slug = sanitize_key($nicename);
564 564
                 // check that such a payment method exists
565 565
                 $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
-                if (! $exists) {
566
+                if ( ! $exists) {
567 567
                     $values = array(
568 568
                         'PMD_type'       => 'Admin_Only',
569 569
                         'PMD_name'       => $nicename,
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
                         $table_name,
578 578
                         $values,
579 579
                         array(
580
-                            '%s',// PMD_type
581
-                            '%s',// PMD_name
582
-                            '%s',// PMD_admin_name
583
-                            '%s',// PMD_admin_desc
584
-                            '%s',// PMD_slug
585
-                            '%d',// PMD_wp_user
586
-                            '%s',// PMD_scope
580
+                            '%s', // PMD_type
581
+                            '%s', // PMD_name
582
+                            '%s', // PMD_admin_name
583
+                            '%s', // PMD_admin_desc
584
+                            '%s', // PMD_slug
585
+                            '%d', // PMD_wp_user
586
+                            '%s', // PMD_scope
587 587
                         )
588 588
                     );
589
-                    if (! $success) {
589
+                    if ( ! $success) {
590 590
                         $this->add_error(sprintf(__(
591 591
                             "Could not insert new admin-only payment method with values %s during migration",
592 592
                             "event_espresso"
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
     public function insert_default_currencies()
609 609
     {
610 610
         global $wpdb;
611
-        $currency_table = $wpdb->prefix . "esp_currency";
611
+        $currency_table = $wpdb->prefix."esp_currency";
612 612
         if ($this->_get_table_analysis()->tableExists($currency_table)) {
613 613
             $SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614 614
             $countries = $wpdb->get_var($SQL);
615
-            if (! $countries) {
615
+            if ( ! $countries) {
616 616
                 $SQL = "INSERT INTO $currency_table
617 617
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
618 618
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php 1 patch
Indentation   +180 added lines, -181 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@  discard block
 block discarded – undo
9 9
  * and recalculates esp_registration.REG_final_price to actually be the final price
10 10
  * for that registration (before this it was just the ticket's price, NOT including
11 11
  * taxes or other price modifiers)
12
-
13 12
  */
14 13
 // make sure we have all the stages loaded too
15 14
 // unfortunately, this needs to be done upon INCLUSION of this file,
@@ -18,9 +17,9 @@  discard block
 block discarded – undo
18 17
 $stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*');
19 18
 $class_to_filepath = array();
20 19
 foreach ($stages as $filepath) {
21
-    $matches = array();
22
-    preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+	$matches = array();
21
+	preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
+	$class_to_filepath[ $matches[1] ] = $filepath;
24 23
 }
25 24
 // give addons a chance to autoload their stages too
26 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
@@ -39,71 +38,71 @@  discard block
 block discarded – undo
39 38
 class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base
40 39
 {
41 40
 
42
-    /**
43
-     * return EE_DMS_Core_4_7_0
44
-     *
45
-     * @param TableManager  $table_manager
46
-     * @param TableAnalysis $table_analysis
47
-     */
48
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
49
-    {
50
-        $this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso");
51
-        $this->_priority = 10;
52
-        $this->_migration_stages = array(
53
-            new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
54
-            new EE_DMS_4_7_0_Registration_Payments(),
55
-        );
56
-        parent::__construct($table_manager, $table_analysis);
57
-    }
41
+	/**
42
+	 * return EE_DMS_Core_4_7_0
43
+	 *
44
+	 * @param TableManager  $table_manager
45
+	 * @param TableAnalysis $table_analysis
46
+	 */
47
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
+	{
49
+		$this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
53
+			new EE_DMS_4_7_0_Registration_Payments(),
54
+		);
55
+		parent::__construct($table_manager, $table_analysis);
56
+	}
58 57
 
59 58
 
60 59
 
61
-    /**
62
-     * @param array $version_array
63
-     * @return bool
64
-     */
65
-    public function can_migrate_from_version($version_array)
66
-    {
67
-        $version_string = $version_array['Core'];
68
-        if ((
69
-                version_compare($version_string, '4.7.0.decaf', '<')
70
-                && version_compare($version_string, '4.6.0.decaf', '>=')
71
-            )
72
-            || (
73
-                version_compare($version_string, '4.7.0.decaf', '>=')
74
-                && ! $this->_get_table_analysis()->tableExists('esp_registration_payment')
75
-                && $this->_get_table_analysis()->tableExists('esp_registration')
76
-            )
77
-        ) {
78
-            return true;
79
-        } elseif (! $version_string) {
80
-            // no version string provided... this must be pre 4.3
81
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
82
-        } else {
83
-            return false;
84
-        }
85
-    }
60
+	/**
61
+	 * @param array $version_array
62
+	 * @return bool
63
+	 */
64
+	public function can_migrate_from_version($version_array)
65
+	{
66
+		$version_string = $version_array['Core'];
67
+		if ((
68
+				version_compare($version_string, '4.7.0.decaf', '<')
69
+				&& version_compare($version_string, '4.6.0.decaf', '>=')
70
+			)
71
+			|| (
72
+				version_compare($version_string, '4.7.0.decaf', '>=')
73
+				&& ! $this->_get_table_analysis()->tableExists('esp_registration_payment')
74
+				&& $this->_get_table_analysis()->tableExists('esp_registration')
75
+			)
76
+		) {
77
+			return true;
78
+		} elseif (! $version_string) {
79
+			// no version string provided... this must be pre 4.3
80
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
81
+		} else {
82
+			return false;
83
+		}
84
+	}
86 85
 
87 86
 
88 87
 
89
-    /**
90
-     * @return bool
91
-     */
92
-    public function schema_changes_before_migration()
93
-    {
94
-        // relies on 4.1's EEH_Activation::create_table
95
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
96
-        $table_name = 'esp_answer';
97
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
88
+	/**
89
+	 * @return bool
90
+	 */
91
+	public function schema_changes_before_migration()
92
+	{
93
+		// relies on 4.1's EEH_Activation::create_table
94
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+		$table_name = 'esp_answer';
96
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 97
 					REG_ID int(10) unsigned NOT NULL,
99 98
 					QST_ID int(10) unsigned NOT NULL,
100 99
 					ANS_value text NOT NULL,
101 100
 					PRIMARY KEY  (ANS_ID),
102 101
 					KEY REG_ID (REG_ID),
103 102
 					KEY QST_ID (QST_ID)";
104
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
105
-        $table_name = 'esp_attendee_meta';
106
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
103
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
+		$table_name = 'esp_attendee_meta';
105
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
107 106
 						ATT_ID bigint(20) unsigned NOT NULL,
108 107
 						ATT_fname varchar(45) NOT NULL,
109 108
 						ATT_lname varchar(45) NOT	NULL,
@@ -120,9 +119,9 @@  discard block
 block discarded – undo
120 119
 								KEY ATT_email (ATT_email(191)),
121 120
 								KEY ATT_lname (ATT_lname),
122 121
 								KEY ATT_fname (ATT_fname)";
123
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
124
-        $table_name = 'esp_country';
125
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
122
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
123
+		$table_name = 'esp_country';
124
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
126 125
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
127 126
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
128 127
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -138,25 +137,25 @@  discard block
 block discarded – undo
138 137
 					  CNT_is_EU tinyint(1) DEFAULT '0',
139 138
 					  CNT_active tinyint(1) DEFAULT '0',
140 139
 					  PRIMARY KEY  (CNT_ISO)";
141
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
142
-        $table_name = 'esp_currency';
143
-        $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
140
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
141
+		$table_name = 'esp_currency';
142
+		$sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
144 143
 				CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar',
145 144
 				CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars',
146 145
 				CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$',
147 146
 				CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
148 147
 				CUR_active tinyint(1) DEFAULT '0',
149 148
 				PRIMARY KEY  (CUR_code)";
150
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
151
-        $table_name = 'esp_currency_payment_method';
152
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
149
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
150
+		$table_name = 'esp_currency_payment_method';
151
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
153 152
 				CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
154 153
 				PMD_ID int(11) NOT NULL,
155 154
 				PRIMARY KEY  (CPM_ID),
156 155
 				KEY PMD_ID (PMD_ID)";
157
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
158
-        $table_name = 'esp_datetime';
159
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
156
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
157
+		$table_name = 'esp_datetime';
158
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
160 159
 				  EVT_ID bigint(20) unsigned NOT NULL,
161 160
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
162 161
 				  DTT_description text NOT NULL,
@@ -172,9 +171,9 @@  discard block
 block discarded – undo
172 171
 						KEY DTT_EVT_start (DTT_EVT_start),
173 172
 						KEY EVT_ID (EVT_ID),
174 173
 						KEY DTT_is_primary (DTT_is_primary)";
175
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
176
-        $table_name = 'esp_event_meta';
177
-        $sql = "
174
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
175
+		$table_name = 'esp_event_meta';
176
+		$sql = "
178 177
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
179 178
 			EVT_ID bigint(20) unsigned NOT NULL,
180 179
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -190,34 +189,34 @@  discard block
 block discarded – undo
190 189
 			EVT_donations tinyint(1) NULL,
191 190
 			PRIMARY KEY  (EVTM_ID),
192 191
 			KEY EVT_ID (EVT_ID)";
193
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
194
-        $table_name = 'esp_event_question_group';
195
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
192
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
193
+		$table_name = 'esp_event_question_group';
194
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
196 195
 					EVT_ID bigint(20) unsigned NOT NULL,
197 196
 					QSG_ID int(10) unsigned NOT NULL,
198 197
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
199 198
 					PRIMARY KEY  (EQG_ID),
200 199
 					KEY EVT_ID (EVT_ID),
201 200
 					KEY QSG_ID (QSG_ID)";
202
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
203
-        $table_name = 'esp_event_venue';
204
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
201
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
202
+		$table_name = 'esp_event_venue';
203
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
205 204
 				EVT_ID bigint(20) unsigned NOT NULL,
206 205
 				VNU_ID bigint(20) unsigned NOT NULL,
207 206
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
208 207
 				PRIMARY KEY  (EVV_ID)";
209
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
210
-        $table_name = 'esp_extra_meta';
211
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
208
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
209
+		$table_name = 'esp_extra_meta';
210
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
212 211
 				OBJ_ID int(11) DEFAULT NULL,
213 212
 				EXM_type varchar(45) DEFAULT NULL,
214 213
 				EXM_key varchar(45) DEFAULT NULL,
215 214
 				EXM_value text,
216 215
 				PRIMARY KEY  (EXM_ID),
217 216
 				KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))";
218
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
219
-        $table_name = 'esp_line_item';
220
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
217
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
218
+		$table_name = 'esp_line_item';
219
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
221 220
 				LIN_code varchar(245) NOT NULL DEFAULT '',
222 221
 				TXN_ID int(11) DEFAULT NULL,
223 222
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -235,9 +234,9 @@  discard block
 block discarded – undo
235 234
 				PRIMARY KEY  (LIN_ID),
236 235
 				KEY LIN_code (LIN_code(191)),
237 236
 				KEY TXN_ID (TXN_ID)";
238
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
239
-        $table_name = 'esp_log';
240
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
237
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
+		$table_name = 'esp_log';
239
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
241 240
 				LOG_time datetime DEFAULT NULL,
242 241
 				OBJ_ID varchar(45) DEFAULT NULL,
243 242
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -248,18 +247,18 @@  discard block
 block discarded – undo
248 247
 				KEY LOG_time (LOG_time),
249 248
 				KEY OBJ (OBJ_type,OBJ_ID),
250 249
 				KEY LOG_type (LOG_type)";
251
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
252
-        $table_name = 'esp_message_template';
253
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
250
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
251
+		$table_name = 'esp_message_template';
252
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
254 253
 					GRP_ID int(10) unsigned NOT NULL,
255 254
 					MTP_context varchar(50) NOT NULL,
256 255
 					MTP_template_field varchar(30) NOT NULL,
257 256
 					MTP_content text NOT NULL,
258 257
 					PRIMARY KEY  (MTP_ID),
259 258
 					KEY GRP_ID (GRP_ID)";
260
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
261
-        $table_name = 'esp_message_template_group';
262
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
260
+		$table_name = 'esp_message_template_group';
261
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
263 262
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
264 263
 					MTP_name varchar(245) NOT NULL DEFAULT '',
265 264
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -271,17 +270,17 @@  discard block
 block discarded – undo
271 270
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
272 271
 					PRIMARY KEY  (GRP_ID),
273 272
 					KEY MTP_user_id (MTP_user_id)";
274
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
275
-        $table_name = 'esp_event_message_template';
276
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
273
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
274
+		$table_name = 'esp_event_message_template';
275
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
277 276
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
278 277
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
279 278
 					PRIMARY KEY  (EMT_ID),
280 279
 					KEY EVT_ID (EVT_ID),
281 280
 					KEY GRP_ID (GRP_ID)";
282
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = 'esp_payment';
284
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
281
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
282
+		$table_name = 'esp_payment';
283
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
285 284
 					TXN_ID int(10) unsigned DEFAULT NULL,
286 285
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
287 286
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -298,9 +297,9 @@  discard block
 block discarded – undo
298 297
 					PRIMARY KEY  (PAY_ID),
299 298
 					KEY PAY_timestamp (PAY_timestamp),
300 299
 					KEY TXN_ID (TXN_ID)";
301
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
302
-        $table_name = 'esp_payment_method';
303
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
300
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
301
+		$table_name = 'esp_payment_method';
302
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
304 303
 				PMD_type varchar(124) DEFAULT NULL,
305 304
 				PMD_name varchar(255) DEFAULT NULL,
306 305
 				PMD_desc text,
@@ -316,32 +315,32 @@  discard block
 block discarded – undo
316 315
 				PRIMARY KEY  (PMD_ID),
317 316
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
318 317
 				KEY PMD_type (PMD_type)";
319
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
320
-        $table_name = "esp_ticket_price";
321
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
318
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
319
+		$table_name = "esp_ticket_price";
320
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
322 321
 					  TKT_ID int(10) unsigned NOT NULL,
323 322
 					  PRC_ID int(10) unsigned NOT NULL,
324 323
 					  PRIMARY KEY  (TKP_ID),
325 324
 					  KEY TKT_ID (TKT_ID),
326 325
 					  KEY PRC_ID (PRC_ID)";
327
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
-        $table_name = "esp_datetime_ticket";
329
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
326
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
327
+		$table_name = "esp_datetime_ticket";
328
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 329
 					  DTT_ID int(10) unsigned NOT NULL,
331 330
 					  TKT_ID int(10) unsigned NOT NULL,
332 331
 					  PRIMARY KEY  (DTK_ID),
333 332
 					  KEY DTT_ID (DTT_ID),
334 333
 					  KEY TKT_ID (TKT_ID)";
335
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
-        $table_name = "esp_ticket_template";
337
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
334
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
335
+		$table_name = "esp_ticket_template";
336
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
338 337
 					  TTM_name varchar(45) NOT NULL,
339 338
 					  TTM_description text,
340 339
 					  TTM_file varchar(45),
341 340
 					  PRIMARY KEY  (TTM_ID)";
342
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
343
-        $table_name = 'esp_question';
344
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question';
343
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
345 344
 					QST_display_text text NOT NULL,
346 345
 					QST_admin_label varchar(255) NOT NULL,
347 346
 					QST_system varchar(25) DEFAULT NULL,
@@ -354,18 +353,18 @@  discard block
 block discarded – undo
354 353
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
355 354
 					PRIMARY KEY  (QST_ID),
356 355
 					KEY QST_order (QST_order)';
357
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
358
-        $table_name = 'esp_question_group_question';
359
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
356
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
357
+		$table_name = 'esp_question_group_question';
358
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
360 359
 					QSG_ID int(10) unsigned NOT NULL,
361 360
 					QST_ID int(10) unsigned NOT NULL,
362 361
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
363 362
 					PRIMARY KEY  (QGQ_ID),
364 363
 					KEY QST_ID (QST_ID),
365 364
 					KEY QSG_ID_order (QSG_ID, QGQ_order)";
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
-        $table_name = 'esp_question_option';
368
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
365
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
366
+		$table_name = 'esp_question_option';
367
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369 368
 					QSO_value varchar(255) NOT NULL,
370 369
 					QSO_desc text NOT NULL,
371 370
 					QST_ID int(10) unsigned NOT NULL,
@@ -374,9 +373,9 @@  discard block
 block discarded – undo
374 373
 					PRIMARY KEY  (QSO_ID),
375 374
 					KEY QST_ID (QST_ID),
376 375
 					KEY QSO_order (QSO_order)";
377
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
378
-        $table_name = 'esp_registration';
379
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
376
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
377
+		$table_name = 'esp_registration';
378
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
380 379
 					  EVT_ID bigint(20) unsigned NOT NULL,
381 380
 					  ATT_ID bigint(20) unsigned NOT NULL,
382 381
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -400,18 +399,18 @@  discard block
 block discarded – undo
400 399
 					  KEY TKT_ID (TKT_ID),
401 400
 					  KEY EVT_ID (EVT_ID),
402 401
 					  KEY STS_ID (STS_ID)";
403
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
404
-        $table_name = 'esp_registration_payment';
405
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
403
+		$table_name = 'esp_registration_payment';
404
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
406 405
 					  REG_ID int(10) unsigned NOT NULL,
407 406
 					  PAY_ID int(10) unsigned NULL,
408 407
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
409 408
 					  PRIMARY KEY  (RPY_ID),
410 409
 					  KEY REG_ID (REG_ID),
411 410
 					  KEY PAY_ID (PAY_ID)";
412
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
413
-        $table_name = 'esp_checkin';
414
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
411
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
412
+		$table_name = 'esp_checkin';
413
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
415 414
 					REG_ID int(10) unsigned NOT NULL,
416 415
 					DTT_ID int(10) unsigned NOT NULL,
417 416
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -419,9 +418,9 @@  discard block
 block discarded – undo
419 418
 					PRIMARY KEY  (CHK_ID),
420 419
 					KEY REG_ID (REG_ID),
421 420
 					KEY DTT_ID (DTT_ID)";
422
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
423
-        $table_name = 'esp_state';
424
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
421
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
422
+		$table_name = 'esp_state';
423
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
425 424
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
426 425
 					  STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL,
427 426
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
@@ -429,9 +428,9 @@  discard block
 block discarded – undo
429 428
 					  PRIMARY KEY  (STA_ID),
430 429
 					  KEY STA_abbrev (STA_abbrev),
431 430
 					  KEY CNT_ISO (CNT_ISO)";
432
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
-        $table_name = 'esp_status';
434
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
431
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
432
+		$table_name = 'esp_status';
433
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
435 434
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
436 435
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
437 436
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -439,9 +438,9 @@  discard block
 block discarded – undo
439 438
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
440 439
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
441 440
 					  KEY STS_type (STS_type)";
442
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
443
-        $table_name = 'esp_transaction';
444
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
441
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
442
+		$table_name = 'esp_transaction';
443
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
445 444
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
446 445
 					  TXN_total decimal(10,3) DEFAULT '0.00',
447 446
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -453,9 +452,9 @@  discard block
 block discarded – undo
453 452
 					  PRIMARY KEY  (TXN_ID),
454 453
 					  KEY TXN_timestamp (TXN_timestamp),
455 454
 					  KEY STS_ID (STS_ID)";
456
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
457
-        $table_name = 'esp_venue_meta';
458
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
455
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
456
+		$table_name = 'esp_venue_meta';
457
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
459 458
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
460 459
 			VNU_address varchar(255) DEFAULT NULL,
461 460
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -474,10 +473,10 @@  discard block
 block discarded – undo
474 473
 			KEY VNU_ID (VNU_ID),
475 474
 			KEY STA_ID (STA_ID),
476 475
 			KEY CNT_ISO (CNT_ISO)";
477
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
478
-        // modified tables
479
-        $table_name = "esp_price";
480
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
476
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
477
+		// modified tables
478
+		$table_name = "esp_price";
479
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
481 480
 					  PRT_ID tinyint(3) unsigned NOT NULL,
482 481
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
483 482
 					  PRC_name varchar(245) NOT NULL,
@@ -490,9 +489,9 @@  discard block
 block discarded – undo
490 489
 					  PRC_parent int(10) unsigned DEFAULT 0,
491 490
 					  PRIMARY KEY  (PRC_ID),
492 491
 					  KEY PRT_ID (PRT_ID)";
493
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
494
-        $table_name = "esp_price_type";
495
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
492
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
493
+		$table_name = "esp_price_type";
494
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
496 495
 				  PRT_name varchar(45) NOT NULL,
497 496
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
498 497
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -501,9 +500,9 @@  discard block
 block discarded – undo
501 500
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
502 501
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
503 502
 				  PRIMARY KEY  (PRT_ID)";
504
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
505
-        $table_name = "esp_ticket";
506
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
503
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
504
+		$table_name = "esp_ticket";
505
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
507 506
 					  TTM_ID int(10) unsigned NOT NULL,
508 507
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
509 508
 					  TKT_description text NOT NULL,
@@ -525,9 +524,9 @@  discard block
 block discarded – undo
525 524
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
526 525
 					  PRIMARY KEY  (TKT_ID),
527 526
 					  KEY TKT_start_date (TKT_start_date)";
528
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
529
-        $table_name = 'esp_question_group';
530
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
527
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
528
+		$table_name = 'esp_question_group';
529
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
531 530
 					QSG_name varchar(255) NOT NULL,
532 531
 					QSG_identifier varchar(100) NOT NULL,
533 532
 					QSG_desc text NULL,
@@ -540,38 +539,38 @@  discard block
 block discarded – undo
540 539
 					PRIMARY KEY  (QSG_ID),
541 540
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
542 541
 					KEY QSG_order (QSG_order)';
543
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
544
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
545
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
546
-        // (because many need to convert old string states to foreign keys into the states table)
547
-        $script_4_1_defaults->insert_default_states();
548
-        $script_4_1_defaults->insert_default_countries();
549
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
550
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
551
-        $script_4_5_defaults->insert_default_price_types();
552
-        $script_4_5_defaults->insert_default_prices();
553
-        $script_4_5_defaults->insert_default_tickets();
554
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
555
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
556
-        $script_4_6_defaults->add_default_admin_only_payments();
557
-        $script_4_6_defaults->insert_default_currencies();
558
-        return true;
559
-    }
542
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
543
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
544
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
545
+		// (because many need to convert old string states to foreign keys into the states table)
546
+		$script_4_1_defaults->insert_default_states();
547
+		$script_4_1_defaults->insert_default_countries();
548
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
549
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
550
+		$script_4_5_defaults->insert_default_price_types();
551
+		$script_4_5_defaults->insert_default_prices();
552
+		$script_4_5_defaults->insert_default_tickets();
553
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
554
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
555
+		$script_4_6_defaults->add_default_admin_only_payments();
556
+		$script_4_6_defaults->insert_default_currencies();
557
+		return true;
558
+	}
560 559
 
561 560
 
562 561
 
563
-    /**
564
-     * @return boolean
565
-     */
566
-    public function schema_changes_after_migration()
567
-    {
568
-        return true;
569
-    }
562
+	/**
563
+	 * @return boolean
564
+	 */
565
+	public function schema_changes_after_migration()
566
+	{
567
+		return true;
568
+	}
570 569
 
571 570
 
572 571
 
573
-    public function migration_page_hooks()
574
-    {
575
-    }
572
+	public function migration_page_hooks()
573
+	{
574
+	}
576 575
 }
577 576
 // end of file: /core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_2_0.dms.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*');
16 16
 $class_to_filepath = array();
17 17
 if (! empty($stages)) {
18
-    foreach ($stages as $filepath) {
19
-        $matches = array();
20
-        preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-        $class_to_filepath[ $matches[1] ] = $filepath;
22
-    }
18
+	foreach ($stages as $filepath) {
19
+		$matches = array();
20
+		preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
+		$class_to_filepath[ $matches[1] ] = $filepath;
22
+	}
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath);
@@ -32,57 +32,57 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * EE_DMS_Core_4_2_0 constructor.
37
-     *
38
-     * @param TableManager  $table_manager
39
-     * @param TableAnalysis $table_analysis
40
-     */
41
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
42
-    {
43
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso");
44
-        $this->_priority = 10;
45
-        $this->_migration_stages = array(
46
-            new EE_DMS_4_2_0_question_group_questions(),
47
-            new EE_DMS_4_2_0_datetime_fields(),
48
-        );
49
-        parent::__construct($table_manager, $table_analysis);
50
-    }
35
+	/**
36
+	 * EE_DMS_Core_4_2_0 constructor.
37
+	 *
38
+	 * @param TableManager  $table_manager
39
+	 * @param TableAnalysis $table_analysis
40
+	 */
41
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
42
+	{
43
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso");
44
+		$this->_priority = 10;
45
+		$this->_migration_stages = array(
46
+			new EE_DMS_4_2_0_question_group_questions(),
47
+			new EE_DMS_4_2_0_datetime_fields(),
48
+		);
49
+		parent::__construct($table_manager, $table_analysis);
50
+	}
51 51
 
52 52
 
53 53
 
54
-    public function can_migrate_from_version($version_array)
55
-    {
56
-        $version_string = $version_array['Core'];
57
-        if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
54
+	public function can_migrate_from_version($version_array)
55
+	{
56
+		$version_string = $version_array['Core'];
57
+		if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
58 58
 //          echo "$version_string can be migrated fro";
59
-            return true;
60
-        } elseif (! $version_string) {
59
+			return true;
60
+		} elseif (! $version_string) {
61 61
 //          echo "no version string provided: $version_string";
62
-            // no version string provided... this must be pre 4.1
63
-            // because since 4.1 we're
64
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
-        } else {
62
+			// no version string provided... this must be pre 4.1
63
+			// because since 4.1 we're
64
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
+		} else {
66 66
 //          echo "$version_string doesnt apply";
67
-            return false;
68
-        }
69
-    }
67
+			return false;
68
+		}
69
+	}
70 70
 
71 71
 
72 72
 
73
-    public function schema_changes_before_migration()
74
-    {
75
-        // relies on 4.1's EEH_Activation::create_table
76
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
-        $table_name = 'esp_answer';
78
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
73
+	public function schema_changes_before_migration()
74
+	{
75
+		// relies on 4.1's EEH_Activation::create_table
76
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
+		$table_name = 'esp_answer';
78
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79 79
 					REG_ID int(10) unsigned NOT NULL,
80 80
 					QST_ID int(10) unsigned NOT NULL,
81 81
 					ANS_value text NOT NULL,
82 82
 					PRIMARY KEY  (ANS_ID)";
83
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
-        $table_name = 'esp_attendee_meta';
85
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
83
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
+		$table_name = 'esp_attendee_meta';
85
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
86 86
 						ATT_ID bigint(20) unsigned NOT NULL,
87 87
 						ATT_fname varchar(45) NOT NULL,
88 88
 						ATT_lname varchar(45) NOT	NULL,
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 								KEY ATT_fname (ATT_fname),
99 99
 								KEY ATT_lname (ATT_lname),
100 100
 								KEY ATT_email (ATT_email(191))";
101
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
-        $table_name = 'esp_country';
103
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
101
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
+		$table_name = 'esp_country';
103
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
104 104
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
105 105
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
106 106
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 					  CNT_is_EU tinyint(1) DEFAULT '0',
117 117
 					  CNT_active tinyint(1) DEFAULT '0',
118 118
 					  PRIMARY KEY  (CNT_ISO)";
119
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
-        $table_name = 'esp_datetime';
121
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
119
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
+		$table_name = 'esp_datetime';
121
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
122 122
 				  EVT_ID bigint(20) unsigned NOT NULL,
123 123
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
124 124
 				  DTT_description text NOT NULL,
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 						PRIMARY KEY  (DTT_ID),
134 134
 						KEY EVT_ID (EVT_ID),
135 135
 						KEY DTT_is_primary (DTT_is_primary)";
136
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
-        $table_name = 'esp_event_meta';
138
-        $sql = "
136
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
+		$table_name = 'esp_event_meta';
138
+		$sql = "
139 139
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
140 140
 			EVT_ID bigint(20) unsigned NOT NULL,
141 141
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -150,31 +150,31 @@  discard block
 block discarded – undo
150 150
 			EVT_external_URL varchar(200) NULL,
151 151
 			EVT_donations tinyint(1) NULL,
152 152
 			PRIMARY KEY  (EVTM_ID)";
153
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
-        $table_name = 'esp_event_question_group';
155
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
153
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
+		$table_name = 'esp_event_question_group';
155
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
156 156
 					EVT_ID bigint(20) unsigned NOT NULL,
157 157
 					QSG_ID int(10) unsigned NOT NULL,
158 158
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
159 159
 					PRIMARY KEY  (EQG_ID)";
160
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
-        $table_name = 'esp_event_venue';
162
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
160
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
+		$table_name = 'esp_event_venue';
162
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
163 163
 				EVT_ID bigint(20) unsigned NOT NULL,
164 164
 				VNU_ID bigint(20) unsigned NOT NULL,
165 165
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
166 166
 				PRIMARY KEY  (EVV_ID)";
167
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
-        $table_name = 'esp_extra_meta';
169
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
167
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
+		$table_name = 'esp_extra_meta';
169
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
170 170
 				OBJ_ID int(11) DEFAULT NULL,
171 171
 				EXM_type varchar(45) DEFAULT NULL,
172 172
 				EXM_key varchar(45) DEFAULT NULL,
173 173
 				EXM_value text,
174 174
 				PRIMARY KEY  (EXM_ID)";
175
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
-        $table_name = 'esp_line_item';
177
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
175
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
+		$table_name = 'esp_line_item';
177
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
178 178
 				LIN_code varchar(245) NOT NULL DEFAULT '',
179 179
 				TXN_ID int(11) DEFAULT NULL,
180 180
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
 				OBJ_ID int(11) DEFAULT NULL,
191 191
 				OBJ_type varchar(45)DEFAULT NULL,
192 192
 				PRIMARY KEY  (LIN_ID)";
193
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
-        $table_name = 'esp_message_template';
195
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
+		$table_name = 'esp_message_template';
195
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
196 196
 					GRP_ID int(10) unsigned NOT NULL,
197 197
 					MTP_context varchar(50) NOT NULL,
198 198
 					MTP_template_field varchar(30) NOT NULL,
199 199
 					MTP_content text NOT NULL,
200 200
 					PRIMARY KEY  (MTP_ID),
201 201
 					KEY GRP_ID (GRP_ID)";
202
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
-        $table_name = 'esp_message_template_group';
204
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
202
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
+		$table_name = 'esp_message_template_group';
204
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
205 205
 					EVT_ID bigint(20) unsigned DEFAULT NULL,
206 206
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
207 207
 					MTP_messenger varchar(30) NOT NULL,
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 					PRIMARY KEY  (GRP_ID),
214 214
 					KEY EVT_ID (EVT_ID),
215 215
 					KEY MTP_user_id (MTP_user_id)";
216
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
217
-        $table_name = 'esp_payment';
218
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
216
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
217
+		$table_name = 'esp_payment';
218
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
219 219
 					TXN_ID int(10) unsigned DEFAULT NULL,
220 220
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
221 221
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 					PRIMARY KEY  (PAY_ID),
232 232
 					KEY TXN_ID (TXN_ID),
233 233
 					KEY PAY_timestamp (PAY_timestamp)";
234
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
235
-        $table_name = "esp_ticket";
236
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
234
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
235
+		$table_name = "esp_ticket";
236
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
237 237
 					  TTM_ID int(10) unsigned NOT NULL,
238 238
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
239 239
 					  TKT_description text NOT NULL,
@@ -252,28 +252,28 @@  discard block
 block discarded – undo
252 252
 					  TKT_parent int(10) unsigned DEFAULT '0',
253 253
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
254 254
 					  PRIMARY KEY  (TKT_ID)";
255
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
-        $table_name = "esp_ticket_price";
257
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
255
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
+		$table_name = "esp_ticket_price";
257
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
258 258
 					  TKT_ID int(10) unsigned NOT NULL,
259 259
 					  PRC_ID int(10) unsigned NOT NULL,
260 260
 					  PRIMARY KEY  (TKP_ID)";
261
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
262
-        $table_name = "esp_datetime_ticket";
263
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
261
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
262
+		$table_name = "esp_datetime_ticket";
263
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
264 264
 					  DTT_ID int(10) unsigned NOT NULL,
265 265
 					  TKT_ID int(10) unsigned NOT NULL,
266 266
 					  PRIMARY KEY  (DTK_ID)";
267
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
268
-        $table_name = "esp_ticket_template";
269
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
267
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
268
+		$table_name = "esp_ticket_template";
269
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
270 270
 					  TTM_name varchar(45) NOT NULL,
271 271
 					  TTM_description text,
272 272
 					  TTM_file varchar(45),
273 273
 					  PRIMARY KEY  (TTM_ID)";
274
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
275
-        $table_name = "esp_price";
276
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
274
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
275
+		$table_name = "esp_price";
276
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
277 277
 					  PRT_ID tinyint(3) unsigned NOT NULL,
278 278
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
279 279
 					  PRC_name varchar(245) NOT NULL,
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
285 285
 					  PRC_parent int(10) unsigned DEFAULT 0,
286 286
 					  PRIMARY KEY  (PRC_ID)";
287
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
288
-        $table_name = "esp_price_type";
289
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
287
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
288
+		$table_name = "esp_price_type";
289
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
290 290
 				  PRT_name varchar(45) NOT NULL,
291 291
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
292 292
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
295 295
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
296 296
 				  PRIMARY KEY  (PRT_ID)";
297
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
298
-        $table_name = 'esp_question';
299
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
297
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
298
+		$table_name = 'esp_question';
299
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
300 300
 					QST_display_text text NOT NULL,
301 301
 					QST_admin_label varchar(255) NOT NULL,
302 302
 					QST_system varchar(25) DEFAULT NULL,
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 					QST_wp_user bigint(20) unsigned NULL,
309 309
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
310 310
 					PRIMARY KEY  (QST_ID)';
311
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
312
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
313
-        $table_name = 'esp_question_group';
314
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
311
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
312
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
313
+		$table_name = 'esp_question_group';
314
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
315 315
 					QSG_name varchar(255) NOT NULL,
316 316
 					QSG_identifier varchar(100) NOT NULL,
317 317
 					QSG_desc text NULL,
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
323 323
 					PRIMARY KEY  (QSG_ID),
324 324
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
325
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
-        $table_name = 'esp_question_group_question';
327
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
325
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
+		$table_name = 'esp_question_group_question';
327
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
328 328
 					QSG_ID int(10) unsigned NOT NULL,
329 329
 					QST_ID int(10) unsigned NOT NULL,
330 330
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
331 331
 					PRIMARY KEY  (QGQ_ID) ";
332
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
333
-        $table_name = 'esp_question_option';
334
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
332
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
333
+		$table_name = 'esp_question_option';
334
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335 335
 					QSO_value varchar(255) NOT NULL,
336 336
 					QSO_desc text NOT NULL,
337 337
 					QST_ID int(10) unsigned NOT NULL,
338 338
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
339 339
 					PRIMARY KEY  (QSO_ID)";
340
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
-        $table_name = 'esp_registration';
342
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
340
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
+		$table_name = 'esp_registration';
342
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343 343
 					  EVT_ID bigint(20) unsigned NOT NULL,
344 344
 					  ATT_ID bigint(20) unsigned NOT NULL,
345 345
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -362,25 +362,25 @@  discard block
 block discarded – undo
362 362
 					  KEY STS_ID (STS_ID),
363 363
 					  KEY REG_url_link (REG_url_link),
364 364
 					  KEY REG_code (REG_code)";
365
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
366
-        $table_name = 'esp_checkin';
367
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
365
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
366
+		$table_name = 'esp_checkin';
367
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
368 368
 					REG_ID int(10) unsigned NOT NULL,
369 369
 					DTT_ID int(10) unsigned NOT NULL,
370 370
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
371 371
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
372 372
 					PRIMARY KEY  (CHK_ID)";
373
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
374
-        $table_name = 'esp_state';
375
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
373
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
374
+		$table_name = 'esp_state';
375
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
376 376
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
377 377
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
378 378
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
379 379
 					  STA_active tinyint(1) DEFAULT '1',
380 380
 					  PRIMARY KEY  (STA_ID)";
381
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
382
-        $table_name = 'esp_status';
383
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
381
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
382
+		$table_name = 'esp_status';
383
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
384 384
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
385 385
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
386 386
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
389 389
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
390 390
 					  KEY STS_type (STS_type)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_transaction';
393
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_transaction';
393
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
394 394
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
395 395
 					  TXN_total decimal(10,3) DEFAULT '0.00',
396 396
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 					  PRIMARY KEY  (TXN_ID),
401 401
 					  KEY TXN_timestamp (TXN_timestamp),
402 402
 					  KEY STS_ID (STS_ID)";
403
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
404
-        $table_name = 'esp_venue_meta';
405
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
403
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
404
+		$table_name = 'esp_venue_meta';
405
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
406 406
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
407 407
 			VNU_address varchar(255) DEFAULT NULL,
408 408
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -420,36 +420,36 @@  discard block
 block discarded – undo
420 420
 			PRIMARY KEY  (VNUM_ID),
421 421
 			KEY STA_ID (STA_ID),
422 422
 			KEY CNT_ISO (CNT_ISO)";
423
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
424
-        $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
425
-        // setting up the DEFAULT stats and countries is also essential for the data migrations to run
426
-        // (because many need to convert old string states to foreign keys into the states table)
427
-        $script_with_defaults->insert_default_states();
428
-        $script_with_defaults->insert_default_countries();
429
-        // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
430
-        $script_with_defaults->insert_default_price_types();
431
-        $script_with_defaults->insert_default_prices();
432
-        $script_with_defaults->insert_default_tickets();
433
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
434
-        EE_Config::instance()->update_espresso_config(false, true);
435
-        return true;
436
-    }
423
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
424
+		$script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
425
+		// setting up the DEFAULT stats and countries is also essential for the data migrations to run
426
+		// (because many need to convert old string states to foreign keys into the states table)
427
+		$script_with_defaults->insert_default_states();
428
+		$script_with_defaults->insert_default_countries();
429
+		// setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
430
+		$script_with_defaults->insert_default_price_types();
431
+		$script_with_defaults->insert_default_prices();
432
+		$script_with_defaults->insert_default_tickets();
433
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
434
+		EE_Config::instance()->update_espresso_config(false, true);
435
+		return true;
436
+	}
437 437
 
438 438
 
439 439
 
440
-    /**
441
-     * We COULD clean up the esp_question.QST_order field here. We'll leave it for now
442
-     *
443
-     * @return boolean
444
-     */
445
-    public function schema_changes_after_migration()
446
-    {
447
-        return true;
448
-    }
440
+	/**
441
+	 * We COULD clean up the esp_question.QST_order field here. We'll leave it for now
442
+	 *
443
+	 * @return boolean
444
+	 */
445
+	public function schema_changes_after_migration()
446
+	{
447
+		return true;
448
+	}
449 449
 
450 450
 
451 451
 
452
-    public function migration_page_hooks()
453
-    {
454
-    }
452
+	public function migration_page_hooks()
453
+	{
454
+	}
455 455
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 // unfortunately, this needs to be done upon INCLUSION of this file,
13 13
 // instead of construction, because it only gets constructed on first page load
14 14
 // (all other times it gets resurrected from a wordpress option)
15
-$stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*');
15
+$stages = glob(EE_CORE.'data_migration_scripts/4_2_0_stages/*');
16 16
 $class_to_filepath = array();
17
-if (! empty($stages)) {
17
+if ( ! empty($stages)) {
18 18
     foreach ($stages as $filepath) {
19 19
         $matches = array();
20 20
         preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-        $class_to_filepath[ $matches[1] ] = $filepath;
21
+        $class_to_filepath[$matches[1]] = $filepath;
22 22
     }
23 23
 }
24 24
 // give addons a chance to autoload their stages too
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
         if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
58 58
 //          echo "$version_string can be migrated fro";
59 59
             return true;
60
-        } elseif (! $version_string) {
60
+        } elseif ( ! $version_string) {
61 61
 //          echo "no version string provided: $version_string";
62 62
             // no version string provided... this must be pre 4.1
63 63
             // because since 4.1 we're
64
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
64
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
65 65
         } else {
66 66
 //          echo "$version_string doesnt apply";
67 67
             return false;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function schema_changes_before_migration()
74 74
     {
75 75
         // relies on 4.1's EEH_Activation::create_table
76
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
76
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
77 77
         $table_name = 'esp_answer';
78 78
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79 79
 					REG_ID int(10) unsigned NOT NULL,
Please login to merge, or discard this patch.
modules/ticket_selector/ProcessTicketSelector.php 2 patches
Indentation   +497 added lines, -497 removed lines patch added patch discarded remove patch
@@ -33,526 +33,526 @@
 block discarded – undo
33 33
 class ProcessTicketSelector
34 34
 {
35 35
 
36
-    /**
37
-     * @var EE_Cart $cart
38
-     */
39
-    private $cart;
36
+	/**
37
+	 * @var EE_Cart $cart
38
+	 */
39
+	private $cart;
40 40
 
41
-    /**
42
-     * @var EE_Core_Config $core_config
43
-     */
44
-    private $core_config;
41
+	/**
42
+	 * @var EE_Core_Config $core_config
43
+	 */
44
+	private $core_config;
45 45
 
46
-    /**
47
-     * @var Request $request
48
-     */
49
-    private $request;
46
+	/**
47
+	 * @var Request $request
48
+	 */
49
+	private $request;
50 50
 
51
-    /**
52
-     * @var EE_Session $session
53
-     */
54
-    private $session;
51
+	/**
52
+	 * @var EE_Session $session
53
+	 */
54
+	private $session;
55 55
 
56
-    /**
57
-     * @var EEM_Ticket $ticket_model
58
-     */
59
-    private $ticket_model;
56
+	/**
57
+	 * @var EEM_Ticket $ticket_model
58
+	 */
59
+	private $ticket_model;
60 60
 
61
-    /**
62
-     * @var TicketDatetimeAvailabilityTracker $tracker
63
-     */
64
-    private $tracker;
61
+	/**
62
+	 * @var TicketDatetimeAvailabilityTracker $tracker
63
+	 */
64
+	private $tracker;
65 65
 
66 66
 
67
-    /**
68
-     * ProcessTicketSelector constructor.
69
-     * NOTE: PLZ use the Loader to instantiate this class if need be
70
-     * so that all dependencies get injected correctly (which will happen automatically)
71
-     * Null values for parameters are only for backwards compatibility but will be removed later on.
72
-     *
73
-     * @param EE_Core_Config                    $core_config
74
-     * @param Request                           $request
75
-     * @param EE_Session                        $session
76
-     * @param EEM_Ticket                        $ticket_model
77
-     * @param TicketDatetimeAvailabilityTracker $tracker
78
-     * @throws InvalidArgumentException
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidInterfaceException
81
-     */
82
-    public function __construct(
83
-        EE_Core_Config $core_config = null,
84
-        Request $request = null,
85
-        EE_Session $session = null,
86
-        EEM_Ticket $ticket_model = null,
87
-        TicketDatetimeAvailabilityTracker $tracker = null
88
-    ) {
89
-        /** @var LoaderInterface $loader */
90
-        $loader = LoaderFactory::getLoader();
91
-        $this->core_config = $core_config instanceof EE_Core_Config
92
-            ? $core_config
93
-            : $loader->getShared('EE_Core_Config');
94
-        $this->request = $request instanceof Request
95
-            ? $request
96
-            : $loader->getShared('EventEspresso\core\services\request\Request');
97
-        $this->session = $session instanceof EE_Session
98
-            ? $session
99
-            : $loader->getShared('EE_Session');
100
-        $this->ticket_model = $ticket_model instanceof EEM_Ticket
101
-            ? $ticket_model
102
-            : $loader->getShared('EEM_Ticket');
103
-        $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
104
-            ? $tracker
105
-            : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
106
-    }
67
+	/**
68
+	 * ProcessTicketSelector constructor.
69
+	 * NOTE: PLZ use the Loader to instantiate this class if need be
70
+	 * so that all dependencies get injected correctly (which will happen automatically)
71
+	 * Null values for parameters are only for backwards compatibility but will be removed later on.
72
+	 *
73
+	 * @param EE_Core_Config                    $core_config
74
+	 * @param Request                           $request
75
+	 * @param EE_Session                        $session
76
+	 * @param EEM_Ticket                        $ticket_model
77
+	 * @param TicketDatetimeAvailabilityTracker $tracker
78
+	 * @throws InvalidArgumentException
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidInterfaceException
81
+	 */
82
+	public function __construct(
83
+		EE_Core_Config $core_config = null,
84
+		Request $request = null,
85
+		EE_Session $session = null,
86
+		EEM_Ticket $ticket_model = null,
87
+		TicketDatetimeAvailabilityTracker $tracker = null
88
+	) {
89
+		/** @var LoaderInterface $loader */
90
+		$loader = LoaderFactory::getLoader();
91
+		$this->core_config = $core_config instanceof EE_Core_Config
92
+			? $core_config
93
+			: $loader->getShared('EE_Core_Config');
94
+		$this->request = $request instanceof Request
95
+			? $request
96
+			: $loader->getShared('EventEspresso\core\services\request\Request');
97
+		$this->session = $session instanceof EE_Session
98
+			? $session
99
+			: $loader->getShared('EE_Session');
100
+		$this->ticket_model = $ticket_model instanceof EEM_Ticket
101
+			? $ticket_model
102
+			: $loader->getShared('EEM_Ticket');
103
+		$this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
104
+			? $tracker
105
+			: $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
106
+	}
107 107
 
108 108
 
109
-    /**
110
-     * cancelTicketSelections
111
-     *
112
-     * @return bool
113
-     * @throws EE_Error
114
-     * @throws InvalidArgumentException
115
-     * @throws InvalidInterfaceException
116
-     * @throws InvalidDataTypeException
117
-     */
118
-    public function cancelTicketSelections()
119
-    {
120
-        // check nonce
121
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122
-            return false;
123
-        }
124
-        $this->session->clear_session(__CLASS__, __FUNCTION__);
125
-        if ($this->request->requestParamIsSet('event_id')) {
126
-            EEH_URL::safeRedirectAndExit(
127
-                EEH_Event_View::event_link_url(
128
-                    $this->request->getRequestParam('event_id')
129
-                )
130
-            );
131
-        }
132
-        EEH_URL::safeRedirectAndExit(
133
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
134
-        );
135
-        return true;
136
-    }
109
+	/**
110
+	 * cancelTicketSelections
111
+	 *
112
+	 * @return bool
113
+	 * @throws EE_Error
114
+	 * @throws InvalidArgumentException
115
+	 * @throws InvalidInterfaceException
116
+	 * @throws InvalidDataTypeException
117
+	 */
118
+	public function cancelTicketSelections()
119
+	{
120
+		// check nonce
121
+		if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122
+			return false;
123
+		}
124
+		$this->session->clear_session(__CLASS__, __FUNCTION__);
125
+		if ($this->request->requestParamIsSet('event_id')) {
126
+			EEH_URL::safeRedirectAndExit(
127
+				EEH_Event_View::event_link_url(
128
+					$this->request->getRequestParam('event_id')
129
+				)
130
+			);
131
+		}
132
+		EEH_URL::safeRedirectAndExit(
133
+			site_url('/' . $this->core_config->event_cpt_slug . '/')
134
+		);
135
+		return true;
136
+	}
137 137
 
138 138
 
139
-    /**
140
-     * processTicketSelectorNonce
141
-     *
142
-     * @param  string $nonce_name
143
-     * @param string  $id
144
-     * @return bool
145
-     */
146
-    private function processTicketSelectorNonce($nonce_name, $id = '')
147
-    {
148
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
149
-        if (! $this->request->isAdmin()
150
-            && (
151
-                ! $this->request->is_set($nonce_name_with_id)
152
-                || ! wp_verify_nonce(
153
-                    $this->request->get($nonce_name_with_id),
154
-                    $nonce_name
155
-                )
156
-            )
157
-        ) {
158
-            EE_Error::add_error(
159
-                sprintf(
160
-                    esc_html__(
161
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
162
-                        'event_espresso'
163
-                    ),
164
-                    '<br/>'
165
-                ),
166
-                __FILE__,
167
-                __FUNCTION__,
168
-                __LINE__
169
-            );
170
-            return false;
171
-        }
172
-        return true;
173
-    }
139
+	/**
140
+	 * processTicketSelectorNonce
141
+	 *
142
+	 * @param  string $nonce_name
143
+	 * @param string  $id
144
+	 * @return bool
145
+	 */
146
+	private function processTicketSelectorNonce($nonce_name, $id = '')
147
+	{
148
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
149
+		if (! $this->request->isAdmin()
150
+			&& (
151
+				! $this->request->is_set($nonce_name_with_id)
152
+				|| ! wp_verify_nonce(
153
+					$this->request->get($nonce_name_with_id),
154
+					$nonce_name
155
+				)
156
+			)
157
+		) {
158
+			EE_Error::add_error(
159
+				sprintf(
160
+					esc_html__(
161
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
162
+						'event_espresso'
163
+					),
164
+					'<br/>'
165
+				),
166
+				__FILE__,
167
+				__FUNCTION__,
168
+				__LINE__
169
+			);
170
+			return false;
171
+		}
172
+		return true;
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * process_ticket_selections
178
-     *
179
-     * @return array|bool
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws InvalidDataTypeException
183
-     * @throws InvalidInterfaceException
184
-     */
185
-    public function processTicketSelections()
186
-    {
187
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
188
-        if ($this->request->isBot()) {
189
-            EEH_URL::safeRedirectAndExit(
190
-                apply_filters(
191
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
192
-                    site_url()
193
-                )
194
-            );
195
-        }
196
-        // do we have an event id?
197
-        $id = $this->getEventId();
198
-        // we should really only have 1 registration in the works now
199
-        // (ie, no MER) so unless otherwise requested, clear the session
200
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
201
-            $this->session->clear_session(__CLASS__, __FUNCTION__);
202
-        }
203
-        // validate/sanitize/filter data
204
-        $valid = apply_filters(
205
-            'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
206
-            $this->validatePostData($id)
207
-        );
208
-        // check total tickets ordered vs max number of attendees that can register
209
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
210
-            $this->maxAttendeesViolation($valid);
211
-        } else {
212
-            // all data appears to be valid
213
-            if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
214
-                return true;
215
-            }
216
-        }
217
-        // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
218
-        // at this point, just return if registration is being made from admin
219
-        if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
220
-            return false;
221
-        }
222
-        if ($valid['return_url']) {
223
-            EEH_URL::safeRedirectAndExit($valid['return_url']);
224
-        }
225
-        if ($id) {
226
-            EEH_URL::safeRedirectAndExit(get_permalink($id));
227
-        }
228
-        echo EE_Error::get_notices();
229
-        return false;
230
-    }
176
+	/**
177
+	 * process_ticket_selections
178
+	 *
179
+	 * @return array|bool
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws InvalidDataTypeException
183
+	 * @throws InvalidInterfaceException
184
+	 */
185
+	public function processTicketSelections()
186
+	{
187
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
188
+		if ($this->request->isBot()) {
189
+			EEH_URL::safeRedirectAndExit(
190
+				apply_filters(
191
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
192
+					site_url()
193
+				)
194
+			);
195
+		}
196
+		// do we have an event id?
197
+		$id = $this->getEventId();
198
+		// we should really only have 1 registration in the works now
199
+		// (ie, no MER) so unless otherwise requested, clear the session
200
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
201
+			$this->session->clear_session(__CLASS__, __FUNCTION__);
202
+		}
203
+		// validate/sanitize/filter data
204
+		$valid = apply_filters(
205
+			'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
206
+			$this->validatePostData($id)
207
+		);
208
+		// check total tickets ordered vs max number of attendees that can register
209
+		if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
210
+			$this->maxAttendeesViolation($valid);
211
+		} else {
212
+			// all data appears to be valid
213
+			if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
214
+				return true;
215
+			}
216
+		}
217
+		// die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
218
+		// at this point, just return if registration is being made from admin
219
+		if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
220
+			return false;
221
+		}
222
+		if ($valid['return_url']) {
223
+			EEH_URL::safeRedirectAndExit($valid['return_url']);
224
+		}
225
+		if ($id) {
226
+			EEH_URL::safeRedirectAndExit(get_permalink($id));
227
+		}
228
+		echo EE_Error::get_notices();
229
+		return false;
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * @return int
235
-     */
236
-    private function getEventId()
237
-    {
238
-        // do we have an event id?
239
-        if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
240
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
241
-            EE_Error::add_error(
242
-                sprintf(
243
-                    esc_html__(
244
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
245
-                        'event_espresso'
246
-                    ),
247
-                    '<br/>'
248
-                ),
249
-                __FILE__,
250
-                __FUNCTION__,
251
-                __LINE__
252
-            );
253
-        }
254
-        // if event id is valid
255
-        return absint($this->request->getRequestParam('tkt-slctr-event-id'));
256
-    }
233
+	/**
234
+	 * @return int
235
+	 */
236
+	private function getEventId()
237
+	{
238
+		// do we have an event id?
239
+		if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
240
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
241
+			EE_Error::add_error(
242
+				sprintf(
243
+					esc_html__(
244
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
245
+						'event_espresso'
246
+					),
247
+					'<br/>'
248
+				),
249
+				__FILE__,
250
+				__FUNCTION__,
251
+				__LINE__
252
+			);
253
+		}
254
+		// if event id is valid
255
+		return absint($this->request->getRequestParam('tkt-slctr-event-id'));
256
+	}
257 257
 
258 258
 
259
-    /**
260
-     * validate_post_data
261
-     *
262
-     * @param int $id
263
-     * @return array
264
-     */
265
-    private function validatePostData($id = 0)
266
-    {
267
-        if (! $id) {
268
-            EE_Error::add_error(
269
-                esc_html__('The event id provided was not valid.', 'event_espresso'),
270
-                __FILE__,
271
-                __FUNCTION__,
272
-                __LINE__
273
-            );
274
-            return array();
275
-        }
276
-        // start with an empty array()
277
-        $valid_data = array();
278
-        // grab valid id
279
-        $valid_data['id'] = $id;
280
-        // array of other form names
281
-        $inputs_to_clean = array(
282
-            'event_id'   => 'tkt-slctr-event-id',
283
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
284
-            'rows'       => 'tkt-slctr-rows-',
285
-            'qty'        => 'tkt-slctr-qty-',
286
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
287
-            'return_url' => 'tkt-slctr-return-url-',
288
-        );
289
-        // let's track the total number of tickets ordered.'
290
-        $valid_data['total_tickets'] = 0;
291
-        // cycle through $inputs_to_clean array
292
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
293
-            // check for POST data
294
-            if ($this->request->requestParamIsSet($input_to_clean . $id)) {
295
-                // grab value
296
-                $input_value = $this->request->getRequestParam($input_to_clean . $id);
297
-                switch ($what) {
298
-                    // integers
299
-                    case 'event_id':
300
-                        $valid_data[ $what ] = absint($input_value);
301
-                        // get event via the event id we put in the form
302
-                        break;
303
-                    case 'rows':
304
-                    case 'max_atndz':
305
-                        $valid_data[ $what ] = absint($input_value);
306
-                        break;
307
-                    // arrays of integers
308
-                    case 'qty':
309
-                        /** @var array $row_qty */
310
-                        $row_qty = $input_value;
311
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
312
-                        if (! is_array($row_qty)) {
313
-                            /** @var string $row_qty */
314
-                            // get number of rows
315
-                            $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id)
316
-                                ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id))
317
-                                : 1;
318
-                            // explode integers by the dash
319
-                            $row_qty = explode('-', $row_qty);
320
-                            $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
321
-                            $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
322
-                            $row_qty = array($row => $qty);
323
-                            for ($x = 1; $x <= $rows; $x++) {
324
-                                if (! isset($row_qty[ $x ])) {
325
-                                    $row_qty[ $x ] = 0;
326
-                                }
327
-                            }
328
-                        }
329
-                        ksort($row_qty);
330
-                        // cycle thru values
331
-                        foreach ($row_qty as $qty) {
332
-                            $qty = absint($qty);
333
-                            // sanitize as integers
334
-                            $valid_data[ $what ][] = $qty;
335
-                            $valid_data['total_tickets'] += $qty;
336
-                        }
337
-                        break;
338
-                    // array of integers
339
-                    case 'ticket_id':
340
-                        // cycle thru values
341
-                        foreach ((array) $input_value as $key => $value) {
342
-                            // allow only integers
343
-                            $valid_data[ $what ][ $key ] = absint($value);
344
-                        }
345
-                        break;
346
-                    case 'return_url':
347
-                        // grab and sanitize return-url
348
-                        $input_value = esc_url_raw($input_value);
349
-                        // was the request coming from an iframe ? if so, then:
350
-                        if (strpos($input_value, 'event_list=iframe')) {
351
-                            // get anchor fragment
352
-                            $input_value = explode('#', $input_value);
353
-                            $input_value = end($input_value);
354
-                            // use event list url instead, but append anchor
355
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
356
-                        }
357
-                        $valid_data[ $what ] = $input_value;
358
-                        break;
359
-                }    // end switch $what
360
-            }
361
-        }    // end foreach $inputs_to_clean
362
-        return $valid_data;
363
-    }
259
+	/**
260
+	 * validate_post_data
261
+	 *
262
+	 * @param int $id
263
+	 * @return array
264
+	 */
265
+	private function validatePostData($id = 0)
266
+	{
267
+		if (! $id) {
268
+			EE_Error::add_error(
269
+				esc_html__('The event id provided was not valid.', 'event_espresso'),
270
+				__FILE__,
271
+				__FUNCTION__,
272
+				__LINE__
273
+			);
274
+			return array();
275
+		}
276
+		// start with an empty array()
277
+		$valid_data = array();
278
+		// grab valid id
279
+		$valid_data['id'] = $id;
280
+		// array of other form names
281
+		$inputs_to_clean = array(
282
+			'event_id'   => 'tkt-slctr-event-id',
283
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
284
+			'rows'       => 'tkt-slctr-rows-',
285
+			'qty'        => 'tkt-slctr-qty-',
286
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
287
+			'return_url' => 'tkt-slctr-return-url-',
288
+		);
289
+		// let's track the total number of tickets ordered.'
290
+		$valid_data['total_tickets'] = 0;
291
+		// cycle through $inputs_to_clean array
292
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
293
+			// check for POST data
294
+			if ($this->request->requestParamIsSet($input_to_clean . $id)) {
295
+				// grab value
296
+				$input_value = $this->request->getRequestParam($input_to_clean . $id);
297
+				switch ($what) {
298
+					// integers
299
+					case 'event_id':
300
+						$valid_data[ $what ] = absint($input_value);
301
+						// get event via the event id we put in the form
302
+						break;
303
+					case 'rows':
304
+					case 'max_atndz':
305
+						$valid_data[ $what ] = absint($input_value);
306
+						break;
307
+					// arrays of integers
308
+					case 'qty':
309
+						/** @var array $row_qty */
310
+						$row_qty = $input_value;
311
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
312
+						if (! is_array($row_qty)) {
313
+							/** @var string $row_qty */
314
+							// get number of rows
315
+							$rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id)
316
+								? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id))
317
+								: 1;
318
+							// explode integers by the dash
319
+							$row_qty = explode('-', $row_qty);
320
+							$row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
321
+							$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
322
+							$row_qty = array($row => $qty);
323
+							for ($x = 1; $x <= $rows; $x++) {
324
+								if (! isset($row_qty[ $x ])) {
325
+									$row_qty[ $x ] = 0;
326
+								}
327
+							}
328
+						}
329
+						ksort($row_qty);
330
+						// cycle thru values
331
+						foreach ($row_qty as $qty) {
332
+							$qty = absint($qty);
333
+							// sanitize as integers
334
+							$valid_data[ $what ][] = $qty;
335
+							$valid_data['total_tickets'] += $qty;
336
+						}
337
+						break;
338
+					// array of integers
339
+					case 'ticket_id':
340
+						// cycle thru values
341
+						foreach ((array) $input_value as $key => $value) {
342
+							// allow only integers
343
+							$valid_data[ $what ][ $key ] = absint($value);
344
+						}
345
+						break;
346
+					case 'return_url':
347
+						// grab and sanitize return-url
348
+						$input_value = esc_url_raw($input_value);
349
+						// was the request coming from an iframe ? if so, then:
350
+						if (strpos($input_value, 'event_list=iframe')) {
351
+							// get anchor fragment
352
+							$input_value = explode('#', $input_value);
353
+							$input_value = end($input_value);
354
+							// use event list url instead, but append anchor
355
+							$input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
356
+						}
357
+						$valid_data[ $what ] = $input_value;
358
+						break;
359
+				}    // end switch $what
360
+			}
361
+		}    // end foreach $inputs_to_clean
362
+		return $valid_data;
363
+	}
364 364
 
365 365
 
366
-    /**
367
-     * @param array $valid
368
-     */
369
-    private function maxAttendeesViolation(array $valid)
370
-    {
371
-        // ordering too many tickets !!!
372
-        $total_tickets_string = esc_html(
373
-            _n(
374
-                'You have attempted to purchase %s ticket.',
375
-                'You have attempted to purchase %s tickets.',
376
-                $valid['total_tickets'],
377
-                'event_espresso'
378
-            )
379
-        );
380
-        $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
381
-        // dev only message
382
-        $max_attendees_string = esc_html(
383
-            _n(
384
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
385
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
386
-                $valid['max_atndz'],
387
-                'event_espresso'
388
-            )
389
-        );
390
-        $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
391
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
392
-    }
366
+	/**
367
+	 * @param array $valid
368
+	 */
369
+	private function maxAttendeesViolation(array $valid)
370
+	{
371
+		// ordering too many tickets !!!
372
+		$total_tickets_string = esc_html(
373
+			_n(
374
+				'You have attempted to purchase %s ticket.',
375
+				'You have attempted to purchase %s tickets.',
376
+				$valid['total_tickets'],
377
+				'event_espresso'
378
+			)
379
+		);
380
+		$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
381
+		// dev only message
382
+		$max_attendees_string = esc_html(
383
+			_n(
384
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
385
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
386
+				$valid['max_atndz'],
387
+				'event_espresso'
388
+			)
389
+		);
390
+		$limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
391
+		EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
392
+	}
393 393
 
394 394
 
395
-    /**
396
-     * @param array $valid
397
-     * @return int
398
-     * @throws EE_Error
399
-     * @throws InvalidArgumentException
400
-     * @throws InvalidDataTypeException
401
-     * @throws InvalidInterfaceException
402
-     */
403
-    private function addTicketsToCart(array $valid)
404
-    {
405
-        $tickets_added = 0;
406
-        $tickets_selected = false;
407
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
408
-            // load cart using factory because we don't want to do so until actually needed
409
-            $this->cart = CartFactory::getCart();
410
-            // cycle thru the number of data rows sent from the event listing
411
-            for ($x = 0; $x < $valid['rows']; $x++) {
412
-                // does this row actually contain a ticket quantity?
413
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
414
-                    // YES we have a ticket quantity
415
-                    $tickets_selected = true;
416
-                    $valid_ticket = false;
417
-                    // \EEH_Debug_Tools::printr(
418
-                    //     $valid['ticket_id'][ $x ],
419
-                    //     '$valid[\'ticket_id\'][ $x ]',
420
-                    //     __FILE__, __LINE__
421
-                    // );
422
-                    if (isset($valid['ticket_id'][ $x ])) {
423
-                        // get ticket via the ticket id we put in the form
424
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
425
-                        if ($ticket instanceof EE_Ticket) {
426
-                            $valid_ticket = true;
427
-                            $tickets_added += $this->addTicketToCart(
428
-                                $ticket,
429
-                                $valid['qty'][ $x ]
430
-                            );
431
-                        }
432
-                    }
433
-                    if ($valid_ticket !== true) {
434
-                        // nothing added to cart retrieved
435
-                        EE_Error::add_error(
436
-                            sprintf(
437
-                                esc_html__(
438
-                                    'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
439
-                                    'event_espresso'
440
-                                ),
441
-                                '<br/>'
442
-                            ),
443
-                            __FILE__,
444
-                            __FUNCTION__,
445
-                            __LINE__
446
-                        );
447
-                    }
448
-                    if (EE_Error::has_error()) {
449
-                        break;
450
-                    }
451
-                }
452
-            }
453
-        }
454
-        do_action(
455
-            'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
456
-            $this->cart,
457
-            $this
458
-        );
459
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
460
-            // no ticket quantities were selected
461
-            EE_Error::add_error(
462
-                esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
463
-                __FILE__,
464
-                __FUNCTION__,
465
-                __LINE__
466
-            );
467
-        }
468
-        return $tickets_added;
469
-    }
395
+	/**
396
+	 * @param array $valid
397
+	 * @return int
398
+	 * @throws EE_Error
399
+	 * @throws InvalidArgumentException
400
+	 * @throws InvalidDataTypeException
401
+	 * @throws InvalidInterfaceException
402
+	 */
403
+	private function addTicketsToCart(array $valid)
404
+	{
405
+		$tickets_added = 0;
406
+		$tickets_selected = false;
407
+		if (! empty($valid) && $valid['total_tickets'] > 0) {
408
+			// load cart using factory because we don't want to do so until actually needed
409
+			$this->cart = CartFactory::getCart();
410
+			// cycle thru the number of data rows sent from the event listing
411
+			for ($x = 0; $x < $valid['rows']; $x++) {
412
+				// does this row actually contain a ticket quantity?
413
+				if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
414
+					// YES we have a ticket quantity
415
+					$tickets_selected = true;
416
+					$valid_ticket = false;
417
+					// \EEH_Debug_Tools::printr(
418
+					//     $valid['ticket_id'][ $x ],
419
+					//     '$valid[\'ticket_id\'][ $x ]',
420
+					//     __FILE__, __LINE__
421
+					// );
422
+					if (isset($valid['ticket_id'][ $x ])) {
423
+						// get ticket via the ticket id we put in the form
424
+						$ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
425
+						if ($ticket instanceof EE_Ticket) {
426
+							$valid_ticket = true;
427
+							$tickets_added += $this->addTicketToCart(
428
+								$ticket,
429
+								$valid['qty'][ $x ]
430
+							);
431
+						}
432
+					}
433
+					if ($valid_ticket !== true) {
434
+						// nothing added to cart retrieved
435
+						EE_Error::add_error(
436
+							sprintf(
437
+								esc_html__(
438
+									'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
439
+									'event_espresso'
440
+								),
441
+								'<br/>'
442
+							),
443
+							__FILE__,
444
+							__FUNCTION__,
445
+							__LINE__
446
+						);
447
+					}
448
+					if (EE_Error::has_error()) {
449
+						break;
450
+					}
451
+				}
452
+			}
453
+		}
454
+		do_action(
455
+			'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
456
+			$this->cart,
457
+			$this
458
+		);
459
+		if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
460
+			// no ticket quantities were selected
461
+			EE_Error::add_error(
462
+				esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
463
+				__FILE__,
464
+				__FUNCTION__,
465
+				__LINE__
466
+			);
467
+		}
468
+		return $tickets_added;
469
+	}
470 470
 
471 471
 
472
-    /**
473
-     * adds a ticket to the cart
474
-     *
475
-     * @param EE_Ticket $ticket
476
-     * @param int       $qty
477
-     * @return TRUE on success, FALSE on fail
478
-     * @throws InvalidArgumentException
479
-     * @throws InvalidInterfaceException
480
-     * @throws InvalidDataTypeException
481
-     * @throws EE_Error
482
-     */
483
-    private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
484
-    {
485
-        // get the number of spaces left for this datetime ticket
486
-        $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
487
-        // compare available spaces against the number of tickets being purchased
488
-        if ($available_spaces >= $qty) {
489
-            // allow addons to prevent a ticket from being added to cart
490
-            if (! apply_filters(
491
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
492
-                true,
493
-                $ticket,
494
-                $qty,
495
-                $available_spaces
496
-            )) {
497
-                return false;
498
-            }
499
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
500
-            // add event to cart
501
-            if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
502
-                $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
503
-                return true;
504
-            }
505
-            return false;
506
-        }
507
-        $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
508
-        return false;
509
-    }
472
+	/**
473
+	 * adds a ticket to the cart
474
+	 *
475
+	 * @param EE_Ticket $ticket
476
+	 * @param int       $qty
477
+	 * @return TRUE on success, FALSE on fail
478
+	 * @throws InvalidArgumentException
479
+	 * @throws InvalidInterfaceException
480
+	 * @throws InvalidDataTypeException
481
+	 * @throws EE_Error
482
+	 */
483
+	private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
484
+	{
485
+		// get the number of spaces left for this datetime ticket
486
+		$available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
487
+		// compare available spaces against the number of tickets being purchased
488
+		if ($available_spaces >= $qty) {
489
+			// allow addons to prevent a ticket from being added to cart
490
+			if (! apply_filters(
491
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
492
+				true,
493
+				$ticket,
494
+				$qty,
495
+				$available_spaces
496
+			)) {
497
+				return false;
498
+			}
499
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
500
+			// add event to cart
501
+			if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
502
+				$this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
503
+				return true;
504
+			}
505
+			return false;
506
+		}
507
+		$this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
508
+		return false;
509
+	}
510 510
 
511 511
 
512
-    /**
513
-     * @param $tickets_added
514
-     * @return bool
515
-     * @throws InvalidInterfaceException
516
-     * @throws InvalidDataTypeException
517
-     * @throws EE_Error
518
-     * @throws InvalidArgumentException
519
-     */
520
-    private function processSuccessfulCart($tickets_added)
521
-    {
522
-        // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
523
-        if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
524
-            // make sure cart is loaded
525
-            if (! $this->cart instanceof EE_Cart) {
526
-                $this->cart = CartFactory::getCart();
527
-            }
528
-            do_action(
529
-                'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
530
-                $this->cart,
531
-                $this
532
-            );
533
-            $this->cart->recalculate_all_cart_totals();
534
-            $this->cart->save_cart(false);
535
-            // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
536
-            // just return TRUE for registrations being made from admin
537
-            if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
538
-                return true;
539
-            }
540
-            EEH_URL::safeRedirectAndExit(
541
-                apply_filters(
542
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
543
-                    $this->core_config->reg_page_url()
544
-                )
545
-            );
546
-        }
547
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
548
-            // nothing added to cart
549
-            EE_Error::add_attention(
550
-                esc_html__('No tickets were added for the event', 'event_espresso'),
551
-                __FILE__,
552
-                __FUNCTION__,
553
-                __LINE__
554
-            );
555
-        }
556
-        return false;
557
-    }
512
+	/**
513
+	 * @param $tickets_added
514
+	 * @return bool
515
+	 * @throws InvalidInterfaceException
516
+	 * @throws InvalidDataTypeException
517
+	 * @throws EE_Error
518
+	 * @throws InvalidArgumentException
519
+	 */
520
+	private function processSuccessfulCart($tickets_added)
521
+	{
522
+		// exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
523
+		if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
524
+			// make sure cart is loaded
525
+			if (! $this->cart instanceof EE_Cart) {
526
+				$this->cart = CartFactory::getCart();
527
+			}
528
+			do_action(
529
+				'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
530
+				$this->cart,
531
+				$this
532
+			);
533
+			$this->cart->recalculate_all_cart_totals();
534
+			$this->cart->save_cart(false);
535
+			// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
536
+			// just return TRUE for registrations being made from admin
537
+			if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
538
+				return true;
539
+			}
540
+			EEH_URL::safeRedirectAndExit(
541
+				apply_filters(
542
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
543
+					$this->core_config->reg_page_url()
544
+				)
545
+			);
546
+		}
547
+		if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
548
+			// nothing added to cart
549
+			EE_Error::add_attention(
550
+				esc_html__('No tickets were added for the event', 'event_espresso'),
551
+				__FILE__,
552
+				__FUNCTION__,
553
+				__LINE__
554
+			);
555
+		}
556
+		return false;
557
+	}
558 558
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function cancelTicketSelections()
119 119
     {
120 120
         // check nonce
121
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
121
+        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122 122
             return false;
123 123
         }
124 124
         $this->session->clear_session(__CLASS__, __FUNCTION__);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             );
131 131
         }
132 132
         EEH_URL::safeRedirectAndExit(
133
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
133
+            site_url('/'.$this->core_config->event_cpt_slug.'/')
134 134
         );
135 135
         return true;
136 136
     }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     private function processTicketSelectorNonce($nonce_name, $id = '')
147 147
     {
148 148
         $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
149
-        if (! $this->request->isAdmin()
149
+        if ( ! $this->request->isAdmin()
150 150
             && (
151 151
                 ! $this->request->is_set($nonce_name_with_id)
152 152
                 || ! wp_verify_nonce(
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             $this->validatePostData($id)
207 207
         );
208 208
         // check total tickets ordered vs max number of attendees that can register
209
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
209
+        if ( ! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
210 210
             $this->maxAttendeesViolation($valid);
211 211
         } else {
212 212
             // all data appears to be valid
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     private function getEventId()
237 237
     {
238 238
         // do we have an event id?
239
-        if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
239
+        if ( ! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
240 240
             // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
241 241
             EE_Error::add_error(
242 242
                 sprintf(
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      */
265 265
     private function validatePostData($id = 0)
266 266
     {
267
-        if (! $id) {
267
+        if ( ! $id) {
268 268
             EE_Error::add_error(
269 269
                 esc_html__('The event id provided was not valid.', 'event_espresso'),
270 270
                 __FILE__,
@@ -291,29 +291,29 @@  discard block
 block discarded – undo
291 291
         // cycle through $inputs_to_clean array
292 292
         foreach ($inputs_to_clean as $what => $input_to_clean) {
293 293
             // check for POST data
294
-            if ($this->request->requestParamIsSet($input_to_clean . $id)) {
294
+            if ($this->request->requestParamIsSet($input_to_clean.$id)) {
295 295
                 // grab value
296
-                $input_value = $this->request->getRequestParam($input_to_clean . $id);
296
+                $input_value = $this->request->getRequestParam($input_to_clean.$id);
297 297
                 switch ($what) {
298 298
                     // integers
299 299
                     case 'event_id':
300
-                        $valid_data[ $what ] = absint($input_value);
300
+                        $valid_data[$what] = absint($input_value);
301 301
                         // get event via the event id we put in the form
302 302
                         break;
303 303
                     case 'rows':
304 304
                     case 'max_atndz':
305
-                        $valid_data[ $what ] = absint($input_value);
305
+                        $valid_data[$what] = absint($input_value);
306 306
                         break;
307 307
                     // arrays of integers
308 308
                     case 'qty':
309 309
                         /** @var array $row_qty */
310 310
                         $row_qty = $input_value;
311 311
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
312
-                        if (! is_array($row_qty)) {
312
+                        if ( ! is_array($row_qty)) {
313 313
                             /** @var string $row_qty */
314 314
                             // get number of rows
315
-                            $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id)
316
-                                ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id))
315
+                            $rows = $this->request->requestParamIsSet('tkt-slctr-rows-'.$id)
316
+                                ? absint($this->request->getRequestParam('tkt-slctr-rows-'.$id))
317 317
                                 : 1;
318 318
                             // explode integers by the dash
319 319
                             $row_qty = explode('-', $row_qty);
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
                             $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
322 322
                             $row_qty = array($row => $qty);
323 323
                             for ($x = 1; $x <= $rows; $x++) {
324
-                                if (! isset($row_qty[ $x ])) {
325
-                                    $row_qty[ $x ] = 0;
324
+                                if ( ! isset($row_qty[$x])) {
325
+                                    $row_qty[$x] = 0;
326 326
                                 }
327 327
                             }
328 328
                         }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                         foreach ($row_qty as $qty) {
332 332
                             $qty = absint($qty);
333 333
                             // sanitize as integers
334
-                            $valid_data[ $what ][] = $qty;
334
+                            $valid_data[$what][] = $qty;
335 335
                             $valid_data['total_tickets'] += $qty;
336 336
                         }
337 337
                         break;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
                         // cycle thru values
341 341
                         foreach ((array) $input_value as $key => $value) {
342 342
                             // allow only integers
343
-                            $valid_data[ $what ][ $key ] = absint($value);
343
+                            $valid_data[$what][$key] = absint($value);
344 344
                         }
345 345
                         break;
346 346
                     case 'return_url':
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
                             $input_value = explode('#', $input_value);
353 353
                             $input_value = end($input_value);
354 354
                             // use event list url instead, but append anchor
355
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
355
+                            $input_value = EEH_Event_View::event_archive_url().'#'.$input_value;
356 356
                         }
357
-                        $valid_data[ $what ] = $input_value;
357
+                        $valid_data[$what] = $input_value;
358 358
                         break;
359 359
                 }    // end switch $what
360 360
             }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             )
389 389
         );
390 390
         $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
391
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
391
+        EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
392 392
     }
393 393
 
394 394
 
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
     {
405 405
         $tickets_added = 0;
406 406
         $tickets_selected = false;
407
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
407
+        if ( ! empty($valid) && $valid['total_tickets'] > 0) {
408 408
             // load cart using factory because we don't want to do so until actually needed
409 409
             $this->cart = CartFactory::getCart();
410 410
             // cycle thru the number of data rows sent from the event listing
411 411
             for ($x = 0; $x < $valid['rows']; $x++) {
412 412
                 // does this row actually contain a ticket quantity?
413
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
413
+                if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
414 414
                     // YES we have a ticket quantity
415 415
                     $tickets_selected = true;
416 416
                     $valid_ticket = false;
@@ -419,14 +419,14 @@  discard block
 block discarded – undo
419 419
                     //     '$valid[\'ticket_id\'][ $x ]',
420 420
                     //     __FILE__, __LINE__
421 421
                     // );
422
-                    if (isset($valid['ticket_id'][ $x ])) {
422
+                    if (isset($valid['ticket_id'][$x])) {
423 423
                         // get ticket via the ticket id we put in the form
424
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
424
+                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]);
425 425
                         if ($ticket instanceof EE_Ticket) {
426 426
                             $valid_ticket = true;
427 427
                             $tickets_added += $this->addTicketToCart(
428 428
                                 $ticket,
429
-                                $valid['qty'][ $x ]
429
+                                $valid['qty'][$x]
430 430
                             );
431 431
                         }
432 432
                     }
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             $this->cart,
457 457
             $this
458 458
         );
459
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
459
+        if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
460 460
             // no ticket quantities were selected
461 461
             EE_Error::add_error(
462 462
                 esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         // compare available spaces against the number of tickets being purchased
488 488
         if ($available_spaces >= $qty) {
489 489
             // allow addons to prevent a ticket from being added to cart
490
-            if (! apply_filters(
490
+            if ( ! apply_filters(
491 491
                 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
492 492
                 true,
493 493
                 $ticket,
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
523 523
         if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
524 524
             // make sure cart is loaded
525
-            if (! $this->cart instanceof EE_Cart) {
525
+            if ( ! $this->cart instanceof EE_Cart) {
526 526
                 $this->cart = CartFactory::getCart();
527 527
             }
528 528
             do_action(
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                 )
545 545
             );
546 546
         }
547
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
547
+        if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
548 548
             // nothing added to cart
549 549
             EE_Error::add_attention(
550 550
                 esc_html__('No tickets were added for the event', 'event_espresso'),
Please login to merge, or discard this patch.
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 2 patches
Indentation   +2889 added lines, -2889 removed lines patch added patch discarded remove patch
@@ -12,2893 +12,2893 @@
 block discarded – undo
12 12
 class EE_SPCO_Reg_Step_Payment_Options extends EE_SPCO_Reg_Step
13 13
 {
14 14
 
15
-    /**
16
-     * @access protected
17
-     * @var EE_Line_Item_Display $Line_Item_Display
18
-     */
19
-    protected $line_item_display;
20
-
21
-    /**
22
-     * @access protected
23
-     * @var boolean $handle_IPN_in_this_request
24
-     */
25
-    protected $handle_IPN_in_this_request = false;
26
-
27
-
28
-    /**
29
-     *    set_hooks - for hooking into EE Core, other modules, etc
30
-     *
31
-     * @access    public
32
-     * @return    void
33
-     */
34
-    public static function set_hooks()
35
-    {
36
-        add_filter(
37
-            'FHEE__SPCO__EE_Line_Item_Filter_Collection',
38
-            array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')
39
-        );
40
-        add_action(
41
-            'wp_ajax_switch_spco_billing_form',
42
-            array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
43
-        );
44
-        add_action(
45
-            'wp_ajax_nopriv_switch_spco_billing_form',
46
-            array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
47
-        );
48
-        add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
49
-        add_action(
50
-            'wp_ajax_nopriv_save_payer_details',
51
-            array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')
52
-        );
53
-        add_action(
54
-            'wp_ajax_get_transaction_details_for_gateways',
55
-            array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
56
-        );
57
-        add_action(
58
-            'wp_ajax_nopriv_get_transaction_details_for_gateways',
59
-            array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
60
-        );
61
-        add_filter(
62
-            'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
63
-            array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'),
64
-            10,
65
-            1
66
-        );
67
-    }
68
-
69
-
70
-    /**
71
-     *    ajax switch_spco_billing_form
72
-     *
73
-     * @throws \EE_Error
74
-     */
75
-    public static function switch_spco_billing_form()
76
-    {
77
-        EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
78
-    }
79
-
80
-
81
-    /**
82
-     *    ajax save_payer_details
83
-     *
84
-     * @throws \EE_Error
85
-     */
86
-    public static function save_payer_details()
87
-    {
88
-        EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
89
-    }
90
-
91
-
92
-    /**
93
-     *    ajax get_transaction_details
94
-     *
95
-     * @throws \EE_Error
96
-     */
97
-    public static function get_transaction_details()
98
-    {
99
-        EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
100
-    }
101
-
102
-
103
-    /**
104
-     * bypass_recaptcha_for_load_payment_method
105
-     *
106
-     * @access public
107
-     * @return array
108
-     * @throws InvalidArgumentException
109
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
110
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
111
-     */
112
-    public static function bypass_recaptcha_for_load_payment_method()
113
-    {
114
-        return array(
115
-            'EESID'  => EE_Registry::instance()->SSN->id(),
116
-            'step'   => 'payment_options',
117
-            'action' => 'spco_billing_form',
118
-        );
119
-    }
120
-
121
-
122
-    /**
123
-     *    class constructor
124
-     *
125
-     * @access    public
126
-     * @param    EE_Checkout $checkout
127
-     */
128
-    public function __construct(EE_Checkout $checkout)
129
-    {
130
-        $this->_slug = 'payment_options';
131
-        $this->_name = esc_html__('Payment Options', 'event_espresso');
132
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/payment_options_main.template.php';
133
-        $this->checkout = $checkout;
134
-        $this->_reset_success_message();
135
-        $this->set_instructions(
136
-            esc_html__(
137
-                'Please select a method of payment and provide any necessary billing information before proceeding.',
138
-                'event_espresso'
139
-            )
140
-        );
141
-    }
142
-
143
-
144
-    /**
145
-     * @return null
146
-     */
147
-    public function line_item_display()
148
-    {
149
-        return $this->line_item_display;
150
-    }
151
-
152
-
153
-    /**
154
-     * @param null $line_item_display
155
-     */
156
-    public function set_line_item_display($line_item_display)
157
-    {
158
-        $this->line_item_display = $line_item_display;
159
-    }
160
-
161
-
162
-    /**
163
-     * @return boolean
164
-     */
165
-    public function handle_IPN_in_this_request()
166
-    {
167
-        return $this->handle_IPN_in_this_request;
168
-    }
169
-
170
-
171
-    /**
172
-     * @param boolean $handle_IPN_in_this_request
173
-     */
174
-    public function set_handle_IPN_in_this_request($handle_IPN_in_this_request)
175
-    {
176
-        $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN);
177
-    }
178
-
179
-
180
-    /**
181
-     * translate_js_strings
182
-     *
183
-     * @return void
184
-     */
185
-    public function translate_js_strings()
186
-    {
187
-        EE_Registry::$i18n_js_strings['no_payment_method'] = esc_html__(
188
-            'Please select a method of payment in order to continue.',
189
-            'event_espresso'
190
-        );
191
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
192
-            'A valid method of payment could not be determined. Please refresh the page and try again.',
193
-            'event_espresso'
194
-        );
195
-        EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = esc_html__(
196
-            'Forwarding to Secure Payment Provider.',
197
-            'event_espresso'
198
-        );
199
-    }
200
-
201
-
202
-    /**
203
-     * enqueue_styles_and_scripts
204
-     *
205
-     * @return void
206
-     * @throws EE_Error
207
-     * @throws InvalidArgumentException
208
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
209
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
210
-     */
211
-    public function enqueue_styles_and_scripts()
212
-    {
213
-        $transaction = $this->checkout->transaction;
214
-        // if the transaction isn't set or nothing is owed on it, don't enqueue any JS
215
-        if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
216
-            return;
217
-        }
218
-        foreach (EEM_Payment_Method::instance()->get_all_for_transaction(
219
-            $transaction,
220
-            EEM_Payment_Method::scope_cart
221
-        ) as $payment_method) {
222
-            $type_obj = $payment_method->type_obj();
223
-            if ($type_obj instanceof EE_PMT_Base) {
224
-                $billing_form = $type_obj->generate_new_billing_form($transaction);
225
-                if ($billing_form instanceof EE_Form_Section_Proper) {
226
-                    $billing_form->enqueue_js();
227
-                }
228
-            }
229
-        }
230
-    }
231
-
232
-
233
-    /**
234
-     * initialize_reg_step
235
-     *
236
-     * @return bool
237
-     * @throws EE_Error
238
-     * @throws InvalidArgumentException
239
-     * @throws ReflectionException
240
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
241
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
242
-     */
243
-    public function initialize_reg_step()
244
-    {
245
-        // TODO: if /when we implement donations, then this will need overriding
246
-        if (// don't need payment options for:
247
-            // registrations made via the admin
248
-            // completed transactions
249
-            // overpaid transactions
250
-            // $ 0.00 transactions(no payment required)
251
-            ! $this->checkout->payment_required()
252
-            // but do NOT remove if current action being called belongs to this reg step
253
-            && ! is_callable(array($this, $this->checkout->action))
254
-            && ! $this->completed()
255
-        ) {
256
-            // and if so, then we no longer need the Payment Options step
257
-            if ($this->is_current_step()) {
258
-                $this->checkout->generate_reg_form = false;
259
-            }
260
-            $this->checkout->remove_reg_step($this->_slug);
261
-            // DEBUG LOG
262
-            // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
263
-            return false;
264
-        }
265
-        // load EEM_Payment_Method
266
-        EE_Registry::instance()->load_model('Payment_Method');
267
-        // get all active payment methods
268
-        $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
269
-            $this->checkout->transaction,
270
-            EEM_Payment_Method::scope_cart
271
-        );
272
-        return true;
273
-    }
274
-
275
-
276
-    /**
277
-     * @return EE_Form_Section_Proper
278
-     * @throws EE_Error
279
-     * @throws InvalidArgumentException
280
-     * @throws ReflectionException
281
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
282
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
283
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
284
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
285
-     */
286
-    public function generate_reg_form()
287
-    {
288
-        // reset in case someone changes their mind
289
-        $this->_reset_selected_method_of_payment();
290
-        // set some defaults
291
-        $this->checkout->selected_method_of_payment = 'payments_closed';
292
-        $registrations_requiring_payment = array();
293
-        $registrations_for_free_events = array();
294
-        $registrations_requiring_pre_approval = array();
295
-        $sold_out_events = array();
296
-        $insufficient_spaces_available = array();
297
-        $no_payment_required = true;
298
-        // loop thru registrations to gather info
299
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
300
-        $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
301
-            $registrations,
302
-            $this->checkout->revisit
303
-        );
304
-        foreach ($registrations as $REG_ID => $registration) {
305
-            /** @var $registration EE_Registration */
306
-            // has this registration lost it's space ?
307
-            if (isset($ejected_registrations[ $REG_ID ])) {
308
-                if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
309
-                    $sold_out_events[ $registration->event()->ID() ] = $registration->event();
310
-                } else {
311
-                    $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
312
-                }
313
-                continue;
314
-            }
315
-            // event requires admin approval
316
-            if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
317
-                // add event to list of events with pre-approval reg status
318
-                $registrations_requiring_pre_approval[ $REG_ID ] = $registration;
319
-                do_action(
320
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
321
-                    $registration->event(),
322
-                    $this
323
-                );
324
-                continue;
325
-            }
326
-            if ($this->checkout->revisit
327
-                && $registration->status_ID() !== EEM_Registration::status_id_approved
328
-                && (
329
-                    $registration->event()->is_sold_out()
330
-                    || $registration->event()->is_sold_out(true)
331
-                )
332
-            ) {
333
-                // add event to list of events that are sold out
334
-                $sold_out_events[ $registration->event()->ID() ] = $registration->event();
335
-                do_action(
336
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
337
-                    $registration->event(),
338
-                    $this
339
-                );
340
-                continue;
341
-            }
342
-            // are they allowed to pay now and is there monies owing?
343
-            if ($registration->owes_monies_and_can_pay()) {
344
-                $registrations_requiring_payment[ $REG_ID ] = $registration;
345
-                do_action(
346
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
347
-                    $registration->event(),
348
-                    $this
349
-                );
350
-            } elseif (! $this->checkout->revisit
351
-                      && $registration->status_ID() !== EEM_Registration::status_id_not_approved
352
-                      && $registration->ticket()->is_free()
353
-            ) {
354
-                $registrations_for_free_events[ $registration->ticket()->ID() ] = $registration;
355
-            }
356
-        }
357
-        $subsections = array();
358
-        // now decide which template to load
359
-        if (! empty($sold_out_events)) {
360
-            $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
361
-        }
362
-        if (! empty($insufficient_spaces_available)) {
363
-            $subsections['insufficient_space'] = $this->_insufficient_spaces_available(
364
-                $insufficient_spaces_available
365
-            );
366
-        }
367
-        if (! empty($registrations_requiring_pre_approval)) {
368
-            $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
369
-                $registrations_requiring_pre_approval
370
-            );
371
-        }
372
-        if (! empty($registrations_for_free_events)) {
373
-            $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
374
-        }
375
-        if (! empty($registrations_requiring_payment)) {
376
-            if ($this->checkout->amount_owing > 0) {
377
-                // autoload Line_Item_Display classes
378
-                EEH_Autoloader::register_line_item_filter_autoloaders();
379
-                $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
380
-                    apply_filters(
381
-                        'FHEE__SPCO__EE_Line_Item_Filter_Collection',
382
-                        new EE_Line_Item_Filter_Collection()
383
-                    ),
384
-                    $this->checkout->cart->get_grand_total()
385
-                );
386
-                /** @var EE_Line_Item $filtered_line_item_tree */
387
-                $filtered_line_item_tree = $line_item_filter_processor->process();
388
-                EEH_Autoloader::register_line_item_display_autoloaders();
389
-                $this->set_line_item_display(new EE_Line_Item_Display('spco'));
390
-                $subsections['payment_options'] = $this->_display_payment_options(
391
-                    $this->line_item_display->display_line_item(
392
-                        $filtered_line_item_tree,
393
-                        array('registrations' => $registrations)
394
-                    )
395
-                );
396
-                $this->checkout->amount_owing = $filtered_line_item_tree->total();
397
-                $this->_apply_registration_payments_to_amount_owing($registrations);
398
-            }
399
-            $no_payment_required = false;
400
-        } else {
401
-            $this->_hide_reg_step_submit_button_if_revisit();
402
-        }
403
-        $this->_save_selected_method_of_payment();
404
-
405
-        $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs();
406
-        $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required);
407
-
408
-        return new EE_Form_Section_Proper(
409
-            array(
410
-                'name'            => $this->reg_form_name(),
411
-                'html_id'         => $this->reg_form_name(),
412
-                'subsections'     => $subsections,
413
-                'layout_strategy' => new EE_No_Layout(),
414
-            )
415
-        );
416
-    }
417
-
418
-
419
-    /**
420
-     * add line item filters required for this reg step
421
-     * these filters are applied via this line in EE_SPCO_Reg_Step_Payment_Options::set_hooks():
422
-     *        add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options',
423
-     *        'add_spco_line_item_filters' ) ); so any code that wants to use the same set of filters during the
424
-     *        payment options reg step, can apply these filters via the following: apply_filters(
425
-     *        'FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection() ) or to an existing
426
-     *        filter collection by passing that instead of instantiating a new collection
427
-     *
428
-     * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection
429
-     * @return EE_Line_Item_Filter_Collection
430
-     * @throws EE_Error
431
-     * @throws InvalidArgumentException
432
-     * @throws ReflectionException
433
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
434
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
435
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
436
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
437
-     */
438
-    public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection)
439
-    {
440
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
441
-            return $line_item_filter_collection;
442
-        }
443
-        if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
444
-            return $line_item_filter_collection;
445
-        }
446
-        if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
447
-            return $line_item_filter_collection;
448
-        }
449
-        $line_item_filter_collection->add(
450
-            new EE_Billable_Line_Item_Filter(
451
-                EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations(
452
-                    EE_Registry::instance()->SSN->checkout()->transaction->registrations(
453
-                        EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
454
-                    )
455
-                )
456
-            )
457
-        );
458
-        $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
459
-        return $line_item_filter_collection;
460
-    }
461
-
462
-
463
-    /**
464
-     * remove_ejected_registrations
465
-     * if a registrant has lost their potential space at an event due to lack of payment,
466
-     * then this method removes them from the list of registrations being paid for during this request
467
-     *
468
-     * @param \EE_Registration[] $registrations
469
-     * @return EE_Registration[]
470
-     * @throws EE_Error
471
-     * @throws InvalidArgumentException
472
-     * @throws ReflectionException
473
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
474
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
475
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
476
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
477
-     */
478
-    public static function remove_ejected_registrations(array $registrations)
479
-    {
480
-        $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
481
-            $registrations,
482
-            EE_Registry::instance()->SSN->checkout()->revisit
483
-        );
484
-        foreach ($registrations as $REG_ID => $registration) {
485
-            // has this registration lost it's space ?
486
-            if (isset($ejected_registrations[ $REG_ID ])) {
487
-                unset($registrations[ $REG_ID ]);
488
-                continue;
489
-            }
490
-        }
491
-        return $registrations;
492
-    }
493
-
494
-
495
-    /**
496
-     * find_registrations_that_lost_their_space
497
-     * If a registrant chooses an offline payment method like Invoice,
498
-     * then no space is reserved for them at the event until they fully pay fo that site
499
-     * (unless the event's default reg status is set to APPROVED)
500
-     * if a registrant then later returns to pay, but the number of spaces available has been reduced due to sales,
501
-     * then this method will determine which registrations have lost the ability to complete the reg process.
502
-     *
503
-     * @param \EE_Registration[] $registrations
504
-     * @param bool               $revisit
505
-     * @return array
506
-     * @throws EE_Error
507
-     * @throws InvalidArgumentException
508
-     * @throws ReflectionException
509
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
510
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
511
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
512
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
513
-     */
514
-    public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false)
515
-    {
516
-        // registrations per event
517
-        $event_reg_count = array();
518
-        // spaces left per event
519
-        $event_spaces_remaining = array();
520
-        // tickets left sorted by ID
521
-        $tickets_remaining = array();
522
-        // registrations that have lost their space
523
-        $ejected_registrations = array();
524
-        foreach ($registrations as $REG_ID => $registration) {
525
-            if ($registration->status_ID() === EEM_Registration::status_id_approved
526
-                || apply_filters(
527
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment',
528
-                    false,
529
-                    $registration,
530
-                    $revisit
531
-                )
532
-            ) {
533
-                continue;
534
-            }
535
-            $EVT_ID = $registration->event_ID();
536
-            $ticket = $registration->ticket();
537
-            if (! isset($tickets_remaining[ $ticket->ID() ])) {
538
-                $tickets_remaining[ $ticket->ID() ] = $ticket->remaining();
539
-            }
540
-            if ($tickets_remaining[ $ticket->ID() ] > 0) {
541
-                if (! isset($event_reg_count[ $EVT_ID ])) {
542
-                    $event_reg_count[ $EVT_ID ] = 0;
543
-                }
544
-                $event_reg_count[ $EVT_ID ]++;
545
-                if (! isset($event_spaces_remaining[ $EVT_ID ])) {
546
-                    $event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale();
547
-                }
548
-            }
549
-            if ($revisit
550
-                && ($tickets_remaining[ $ticket->ID() ] === 0
551
-                    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
552
-                )
553
-            ) {
554
-                $ejected_registrations[ $REG_ID ] = $registration->event();
555
-                if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
556
-                    /** @type EE_Registration_Processor $registration_processor */
557
-                    $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
558
-                    // at this point, we should have enough details about the registrant to consider the registration
559
-                    // NOT incomplete
560
-                    $registration_processor->manually_update_registration_status(
561
-                        $registration,
562
-                        EEM_Registration::status_id_wait_list
563
-                    );
564
-                }
565
-            }
566
-        }
567
-        return $ejected_registrations;
568
-    }
569
-
570
-
571
-    /**
572
-     * _hide_reg_step_submit_button
573
-     * removes the html for the reg step submit button
574
-     * by replacing it with an empty string via filter callback
575
-     *
576
-     * @return void
577
-     */
578
-    protected function _adjust_registration_status_if_event_old_sold()
579
-    {
580
-    }
581
-
582
-
583
-    /**
584
-     * _hide_reg_step_submit_button
585
-     * removes the html for the reg step submit button
586
-     * by replacing it with an empty string via filter callback
587
-     *
588
-     * @return void
589
-     */
590
-    protected function _hide_reg_step_submit_button_if_revisit()
591
-    {
592
-        if ($this->checkout->revisit) {
593
-            add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
594
-        }
595
-    }
596
-
597
-
598
-    /**
599
-     * sold_out_events
600
-     * displays notices regarding events that have sold out since hte registrant first signed up
601
-     *
602
-     * @param \EE_Event[] $sold_out_events_array
603
-     * @return \EE_Form_Section_Proper
604
-     * @throws \EE_Error
605
-     */
606
-    private function _sold_out_events($sold_out_events_array = array())
607
-    {
608
-        // set some defaults
609
-        $this->checkout->selected_method_of_payment = 'events_sold_out';
610
-        $sold_out_events = '';
611
-        foreach ($sold_out_events_array as $sold_out_event) {
612
-            $sold_out_events .= EEH_HTML::li(
613
-                EEH_HTML::span(
614
-                    '  ' . $sold_out_event->name(),
615
-                    '',
616
-                    'dashicons dashicons-marker ee-icon-size-16 pink-text'
617
-                )
618
-            );
619
-        }
620
-        return new EE_Form_Section_Proper(
621
-            array(
622
-                'layout_strategy' => new EE_Template_Layout(
623
-                    array(
624
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
625
-                                                  . $this->_slug
626
-                                                  . '/sold_out_events.template.php',
627
-                        'template_args'        => apply_filters(
628
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
629
-                            array(
630
-                                'sold_out_events'     => $sold_out_events,
631
-                                'sold_out_events_msg' => apply_filters(
632
-                                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
633
-                                    sprintf(
634
-                                        esc_html__(
635
-                                            'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s',
636
-                                            'event_espresso'
637
-                                        ),
638
-                                        '<strong>',
639
-                                        '</strong>',
640
-                                        '<br />'
641
-                                    )
642
-                                ),
643
-                            )
644
-                        ),
645
-                    )
646
-                ),
647
-            )
648
-        );
649
-    }
650
-
651
-
652
-    /**
653
-     * _insufficient_spaces_available
654
-     * displays notices regarding events that do not have enough remaining spaces
655
-     * to satisfy the current number of registrations looking to pay
656
-     *
657
-     * @param \EE_Event[] $insufficient_spaces_events_array
658
-     * @return \EE_Form_Section_Proper
659
-     * @throws \EE_Error
660
-     */
661
-    private function _insufficient_spaces_available($insufficient_spaces_events_array = array())
662
-    {
663
-        // set some defaults
664
-        $this->checkout->selected_method_of_payment = 'invoice';
665
-        $insufficient_space_events = '';
666
-        foreach ($insufficient_spaces_events_array as $event) {
667
-            if ($event instanceof EE_Event) {
668
-                $insufficient_space_events .= EEH_HTML::li(
669
-                    EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
670
-                );
671
-            }
672
-        }
673
-        return new EE_Form_Section_Proper(
674
-            array(
675
-                'subsections'     => array(
676
-                    'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
677
-                    'extra_hidden_inputs'   => $this->_extra_hidden_inputs(),
678
-                ),
679
-                'layout_strategy' => new EE_Template_Layout(
680
-                    array(
681
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
682
-                                                  . $this->_slug
683
-                                                  . '/sold_out_events.template.php',
684
-                        'template_args'        => apply_filters(
685
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args',
686
-                            array(
687
-                                'sold_out_events'     => $insufficient_space_events,
688
-                                'sold_out_events_msg' => apply_filters(
689
-                                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__insufficient_space_msg',
690
-                                    esc_html__(
691
-                                        'It appears that the event you were about to make a payment for has sold additional tickets since you first registered, and there are no longer enough spaces left to accommodate your selections. You may continue to pay and secure the available space(s) remaining, or simply cancel if you no longer wish to purchase. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
692
-                                        'event_espresso'
693
-                                    )
694
-                                ),
695
-                            )
696
-                        ),
697
-                    )
698
-                ),
699
-            )
700
-        );
701
-    }
702
-
703
-
704
-    /**
705
-     * registrations_requiring_pre_approval
706
-     *
707
-     * @param array $registrations_requiring_pre_approval
708
-     * @return EE_Form_Section_Proper
709
-     * @throws EE_Error
710
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
711
-     */
712
-    private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array())
713
-    {
714
-        $events_requiring_pre_approval = array();
715
-        foreach ($registrations_requiring_pre_approval as $registration) {
716
-            if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
717
-                $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
718
-                    EEH_HTML::span(
719
-                        '',
720
-                        '',
721
-                        'dashicons dashicons-marker ee-icon-size-16 orange-text'
722
-                    )
723
-                    . EEH_HTML::span($registration->event()->name(), '', 'orange-text')
724
-                );
725
-            }
726
-        }
727
-        return new EE_Form_Section_Proper(
728
-            array(
729
-                'layout_strategy' => new EE_Template_Layout(
730
-                    array(
731
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
732
-                                                  . $this->_slug
733
-                                                  . '/events_requiring_pre_approval.template.php', // layout_template
734
-                        'template_args'        => apply_filters(
735
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
736
-                            array(
737
-                                'events_requiring_pre_approval'     => implode('', $events_requiring_pre_approval),
738
-                                'events_requiring_pre_approval_msg' => apply_filters(
739
-                                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
740
-                                    esc_html__(
741
-                                        'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
742
-                                        'event_espresso'
743
-                                    )
744
-                                ),
745
-                            )
746
-                        ),
747
-                    )
748
-                ),
749
-            )
750
-        );
751
-    }
752
-
753
-
754
-    /**
755
-     * _no_payment_required
756
-     *
757
-     * @param \EE_Event[] $registrations_for_free_events
758
-     * @return \EE_Form_Section_Proper
759
-     * @throws \EE_Error
760
-     */
761
-    private function _no_payment_required($registrations_for_free_events = array())
762
-    {
763
-        // set some defaults
764
-        $this->checkout->selected_method_of_payment = 'no_payment_required';
765
-        // generate no_payment_required form
766
-        return new EE_Form_Section_Proper(
767
-            array(
768
-                'layout_strategy' => new EE_Template_Layout(
769
-                    array(
770
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
771
-                                                  . $this->_slug
772
-                                                  . '/no_payment_required.template.php', // layout_template
773
-                        'template_args'        => apply_filters(
774
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
775
-                            array(
776
-                                'revisit'                       => $this->checkout->revisit,
777
-                                'registrations'                 => array(),
778
-                                'ticket_count'                  => array(),
779
-                                'registrations_for_free_events' => $registrations_for_free_events,
780
-                                'no_payment_required_msg'       => EEH_HTML::p(
781
-                                    esc_html__('This is a free event, so no billing will occur.', 'event_espresso')
782
-                                ),
783
-                            )
784
-                        ),
785
-                    )
786
-                ),
787
-            )
788
-        );
789
-    }
790
-
791
-
792
-    /**
793
-     * _display_payment_options
794
-     *
795
-     * @param string $transaction_details
796
-     * @return EE_Form_Section_Proper
797
-     * @throws EE_Error
798
-     * @throws InvalidArgumentException
799
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
800
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
801
-     */
802
-    private function _display_payment_options($transaction_details = '')
803
-    {
804
-        // has method_of_payment been set by no-js user?
805
-        $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
806
-        // build payment options form
807
-        return apply_filters(
808
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__payment_options_form',
809
-            new EE_Form_Section_Proper(
810
-                array(
811
-                    'subsections'     => array(
812
-                        'before_payment_options' => apply_filters(
813
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
814
-                            new EE_Form_Section_Proper(
815
-                                array('layout_strategy' => new EE_Div_Per_Section_Layout())
816
-                            )
817
-                        ),
818
-                        'payment_options'        => $this->_setup_payment_options(),
819
-                        'after_payment_options'  => apply_filters(
820
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
821
-                            new EE_Form_Section_Proper(
822
-                                array('layout_strategy' => new EE_Div_Per_Section_Layout())
823
-                            )
824
-                        ),
825
-                    ),
826
-                    'layout_strategy' => new EE_Template_Layout(
827
-                        array(
828
-                            'layout_template_file' => $this->_template,
829
-                            'template_args'        => apply_filters(
830
-                                'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args',
831
-                                array(
832
-                                    'reg_count'                 => $this->line_item_display->total_items(),
833
-                                    'transaction_details'       => $transaction_details,
834
-                                    'available_payment_methods' => array(),
835
-                                )
836
-                            ),
837
-                        )
838
-                    ),
839
-                )
840
-            )
841
-        );
842
-    }
843
-
844
-
845
-    /**
846
-     * _extra_hidden_inputs
847
-     *
848
-     * @param bool $no_payment_required
849
-     * @return \EE_Form_Section_Proper
850
-     * @throws \EE_Error
851
-     */
852
-    private function _extra_hidden_inputs($no_payment_required = true)
853
-    {
854
-        return new EE_Form_Section_Proper(
855
-            array(
856
-                'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
857
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
858
-                'subsections'     => array(
859
-                    'spco_no_payment_required' => new EE_Hidden_Input(
860
-                        array(
861
-                            'normalization_strategy' => new EE_Boolean_Normalization(),
862
-                            'html_name'              => 'spco_no_payment_required',
863
-                            'html_id'                => 'spco-no-payment-required-payment_options',
864
-                            'default'                => $no_payment_required,
865
-                        )
866
-                    ),
867
-                    'spco_transaction_id'      => new EE_Fixed_Hidden_Input(
868
-                        array(
869
-                            'normalization_strategy' => new EE_Int_Normalization(),
870
-                            'html_name'              => 'spco_transaction_id',
871
-                            'html_id'                => 'spco-transaction-id',
872
-                            'default'                => $this->checkout->transaction->ID(),
873
-                        )
874
-                    ),
875
-                ),
876
-            )
877
-        );
878
-    }
879
-
880
-
881
-    /**
882
-     *    _apply_registration_payments_to_amount_owing
883
-     *
884
-     * @access protected
885
-     * @param array $registrations
886
-     * @throws EE_Error
887
-     */
888
-    protected function _apply_registration_payments_to_amount_owing(array $registrations)
889
-    {
890
-        $payments = array();
891
-        foreach ($registrations as $registration) {
892
-            if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
893
-                $payments += $registration->registration_payments();
894
-            }
895
-        }
896
-        if (! empty($payments)) {
897
-            foreach ($payments as $payment) {
898
-                if ($payment instanceof EE_Registration_Payment) {
899
-                    $this->checkout->amount_owing -= $payment->amount();
900
-                }
901
-            }
902
-        }
903
-    }
904
-
905
-
906
-    /**
907
-     *    _reset_selected_method_of_payment
908
-     *
909
-     * @access    private
910
-     * @param    bool $force_reset
911
-     * @return void
912
-     * @throws InvalidArgumentException
913
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
914
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
915
-     */
916
-    private function _reset_selected_method_of_payment($force_reset = false)
917
-    {
918
-        $reset_payment_method = $force_reset
919
-            ? true
920
-            : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false));
921
-        if ($reset_payment_method) {
922
-            $this->checkout->selected_method_of_payment = null;
923
-            $this->checkout->payment_method = null;
924
-            $this->checkout->billing_form = null;
925
-            $this->_save_selected_method_of_payment();
926
-        }
927
-    }
928
-
929
-
930
-    /**
931
-     * _save_selected_method_of_payment
932
-     * stores the selected_method_of_payment in the session
933
-     * so that it's available for all subsequent requests including AJAX
934
-     *
935
-     * @access        private
936
-     * @param string $selected_method_of_payment
937
-     * @return void
938
-     * @throws InvalidArgumentException
939
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
940
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
941
-     */
942
-    private function _save_selected_method_of_payment($selected_method_of_payment = '')
943
-    {
944
-        $selected_method_of_payment = ! empty($selected_method_of_payment)
945
-            ? $selected_method_of_payment
946
-            : $this->checkout->selected_method_of_payment;
947
-        EE_Registry::instance()->SSN->set_session_data(
948
-            array('selected_method_of_payment' => $selected_method_of_payment)
949
-        );
950
-    }
951
-
952
-
953
-    /**
954
-     * _setup_payment_options
955
-     *
956
-     * @return EE_Form_Section_Proper
957
-     * @throws EE_Error
958
-     * @throws InvalidArgumentException
959
-     * @throws ReflectionException
960
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
961
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
962
-     */
963
-    public function _setup_payment_options()
964
-    {
965
-        // load payment method classes
966
-        $this->checkout->available_payment_methods = $this->_get_available_payment_methods();
967
-        if (empty($this->checkout->available_payment_methods)) {
968
-            EE_Error::add_error(
969
-                apply_filters(
970
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__error_message_no_payment_methods',
971
-                    sprintf(
972
-                        esc_html__(
973
-                            'Sorry, you cannot complete your purchase because a payment method is not active.%1$s Please contact %2$s for assistance and provide a description of the problem.',
974
-                            'event_espresso'
975
-                        ),
976
-                        '<br>',
977
-                        EE_Registry::instance()->CFG->organization->get_pretty('email')
978
-                    )
979
-                ),
980
-                __FILE__,
981
-                __FUNCTION__,
982
-                __LINE__
983
-            );
984
-        }
985
-        // switch up header depending on number of available payment methods
986
-        $payment_method_header = count($this->checkout->available_payment_methods) > 1
987
-            ? apply_filters(
988
-                'FHEE__registration_page_payment_options__method_of_payment_hdr',
989
-                esc_html__('Please Select Your Method of Payment', 'event_espresso')
990
-            )
991
-            : apply_filters(
992
-                'FHEE__registration_page_payment_options__method_of_payment_hdr',
993
-                esc_html__('Method of Payment', 'event_espresso')
994
-            );
995
-        $available_payment_methods = array(
996
-            // display the "Payment Method" header
997
-            'payment_method_header' => new EE_Form_Section_HTML(
998
-                apply_filters(
999
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__payment_method_header',
1000
-                    EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr'),
1001
-                    $payment_method_header
1002
-                )
1003
-            ),
1004
-        );
1005
-        // the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
1006
-        $available_payment_method_options = array();
1007
-        $default_payment_method_option = array();
1008
-        // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
1009
-        $payment_methods_billing_info = array(
1010
-            new EE_Form_Section_HTML(
1011
-                EEH_HTML::div('<br />', '', '', 'clear:both;')
1012
-            ),
1013
-        );
1014
-        // loop through payment methods
1015
-        foreach ($this->checkout->available_payment_methods as $payment_method) {
1016
-            if ($payment_method instanceof EE_Payment_Method) {
1017
-                $payment_method_button = EEH_HTML::img(
1018
-                    $payment_method->button_url(),
1019
-                    $payment_method->name(),
1020
-                    'spco-payment-method-' . $payment_method->slug() . '-btn-img',
1021
-                    'spco-payment-method-btn-img'
1022
-                );
1023
-                // check if any payment methods are set as default
1024
-                // if payment method is already selected OR nothing is selected and this payment method should be
1025
-                // open_by_default
1026
-                if (($this->checkout->selected_method_of_payment === $payment_method->slug())
1027
-                    || (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1028
-                ) {
1029
-                    $this->checkout->selected_method_of_payment = $payment_method->slug();
1030
-                    $this->_save_selected_method_of_payment();
1031
-                    $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
1032
-                } else {
1033
-                    $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
1034
-                }
1035
-                $payment_methods_billing_info[ $payment_method->slug(
1036
-                ) . '-info' ] = $this->_payment_method_billing_info(
1037
-                    $payment_method
1038
-                );
1039
-            }
1040
-        }
1041
-        // prepend available_payment_method_options with default_payment_method_option so that it appears first in list
1042
-        // of PMs
1043
-        $available_payment_method_options = $default_payment_method_option + $available_payment_method_options;
1044
-        // now generate the actual form  inputs
1045
-        $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs(
1046
-            $available_payment_method_options
1047
-        );
1048
-        $available_payment_methods += $payment_methods_billing_info;
1049
-        // build the available payment methods form
1050
-        return new EE_Form_Section_Proper(
1051
-            array(
1052
-                'html_id'         => 'spco-available-methods-of-payment-dv',
1053
-                'subsections'     => $available_payment_methods,
1054
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1055
-            )
1056
-        );
1057
-    }
1058
-
1059
-
1060
-    /**
1061
-     * _get_available_payment_methods
1062
-     *
1063
-     * @return EE_Payment_Method[]
1064
-     * @throws EE_Error
1065
-     * @throws InvalidArgumentException
1066
-     * @throws ReflectionException
1067
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1068
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1069
-     */
1070
-    protected function _get_available_payment_methods()
1071
-    {
1072
-        if (! empty($this->checkout->available_payment_methods)) {
1073
-            return $this->checkout->available_payment_methods;
1074
-        }
1075
-        $available_payment_methods = array();
1076
-        // load EEM_Payment_Method
1077
-        EE_Registry::instance()->load_model('Payment_Method');
1078
-        /** @type EEM_Payment_Method $EEM_Payment_Method */
1079
-        $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1080
-        // get all active payment methods
1081
-        $payment_methods = $EEM_Payment_Method->get_all_for_transaction(
1082
-            $this->checkout->transaction,
1083
-            EEM_Payment_Method::scope_cart
1084
-        );
1085
-        foreach ($payment_methods as $payment_method) {
1086
-            if ($payment_method instanceof EE_Payment_Method) {
1087
-                $available_payment_methods[ $payment_method->slug() ] = $payment_method;
1088
-            }
1089
-        }
1090
-        return $available_payment_methods;
1091
-    }
1092
-
1093
-
1094
-    /**
1095
-     *    _available_payment_method_inputs
1096
-     *
1097
-     * @access    private
1098
-     * @param    array $available_payment_method_options
1099
-     * @return    \EE_Form_Section_Proper
1100
-     */
1101
-    private function _available_payment_method_inputs($available_payment_method_options = array())
1102
-    {
1103
-        // generate inputs
1104
-        return new EE_Form_Section_Proper(
1105
-            array(
1106
-                'html_id'         => 'ee-available-payment-method-inputs',
1107
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1108
-                'subsections'     => array(
1109
-                    '' => new EE_Radio_Button_Input(
1110
-                        $available_payment_method_options,
1111
-                        array(
1112
-                            'html_name'          => 'selected_method_of_payment',
1113
-                            'html_class'         => 'spco-payment-method',
1114
-                            'default'            => $this->checkout->selected_method_of_payment,
1115
-                            'label_size'         => 11,
1116
-                            'enforce_label_size' => true,
1117
-                        )
1118
-                    ),
1119
-                ),
1120
-            )
1121
-        );
1122
-    }
1123
-
1124
-
1125
-    /**
1126
-     *    _payment_method_billing_info
1127
-     *
1128
-     * @access    private
1129
-     * @param    EE_Payment_Method $payment_method
1130
-     * @return EE_Form_Section_Proper
1131
-     * @throws EE_Error
1132
-     * @throws InvalidArgumentException
1133
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1134
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1135
-     */
1136
-    private function _payment_method_billing_info(EE_Payment_Method $payment_method)
1137
-    {
1138
-        $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug()
1139
-            ? true
1140
-            : false;
1141
-        // generate the billing form for payment method
1142
-        $billing_form = $currently_selected
1143
-            ? $this->_get_billing_form_for_payment_method($payment_method)
1144
-            : new EE_Form_Section_HTML();
1145
-        $this->checkout->billing_form = $currently_selected
1146
-            ? $billing_form
1147
-            : $this->checkout->billing_form;
1148
-        // it's all in the details
1149
-        $info_html = EEH_HTML::h3(
1150
-            esc_html__('Important information regarding your payment', 'event_espresso'),
1151
-            '',
1152
-            'spco-payment-method-hdr'
1153
-        );
1154
-        // add some info regarding the step, either from what's saved in the admin,
1155
-        // or a default string depending on whether the PM has a billing form or not
1156
-        if ($payment_method->description()) {
1157
-            $payment_method_info = $payment_method->description();
1158
-        } elseif ($billing_form instanceof EE_Billing_Info_Form) {
1159
-            $payment_method_info = sprintf(
1160
-                esc_html__(
1161
-                    'Please provide the following billing information, then click the "%1$s" button below in order to proceed.',
1162
-                    'event_espresso'
1163
-                ),
1164
-                $this->submit_button_text()
1165
-            );
1166
-        } else {
1167
-            $payment_method_info = sprintf(
1168
-                esc_html__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'),
1169
-                $this->submit_button_text()
1170
-            );
1171
-        }
1172
-        $info_html .= EEH_HTML::div(
1173
-            apply_filters(
1174
-                'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info',
1175
-                $payment_method_info
1176
-            ),
1177
-            '',
1178
-            'spco-payment-method-desc ee-attention'
1179
-        );
1180
-        return new EE_Form_Section_Proper(
1181
-            array(
1182
-                'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1183
-                'html_class'      => 'spco-payment-method-info-dv',
1184
-                // only display the selected or default PM
1185
-                'html_style'      => $currently_selected ? '' : 'display:none;',
1186
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1187
-                'subsections'     => array(
1188
-                    'info'         => new EE_Form_Section_HTML($info_html),
1189
-                    'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML(),
1190
-                ),
1191
-            )
1192
-        );
1193
-    }
1194
-
1195
-
1196
-    /**
1197
-     * get_billing_form_html_for_payment_method
1198
-     *
1199
-     * @access public
1200
-     * @return string
1201
-     * @throws EE_Error
1202
-     * @throws InvalidArgumentException
1203
-     * @throws ReflectionException
1204
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1205
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1206
-     */
1207
-    public function get_billing_form_html_for_payment_method()
1208
-    {
1209
-        // how have they chosen to pay?
1210
-        $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1211
-        $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1212
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1213
-            return false;
1214
-        }
1215
-        if (apply_filters(
1216
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1217
-            false
1218
-        )) {
1219
-            EE_Error::add_success(
1220
-                apply_filters(
1221
-                    'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1222
-                    sprintf(
1223
-                        esc_html__(
1224
-                            'You have selected "%s" as your method of payment. Please note the important payment information below.',
1225
-                            'event_espresso'
1226
-                        ),
1227
-                        $this->checkout->payment_method->name()
1228
-                    )
1229
-                )
1230
-            );
1231
-        }
1232
-        // now generate billing form for selected method of payment
1233
-        $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1234
-        // fill form with attendee info if applicable
1235
-        if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
1236
-            && $this->checkout->transaction_has_primary_registrant()
1237
-        ) {
1238
-            $payment_method_billing_form->populate_from_attendee(
1239
-                $this->checkout->transaction->primary_registration()->attendee()
1240
-            );
1241
-        }
1242
-        // and debug content
1243
-        if ($payment_method_billing_form instanceof EE_Billing_Info_Form
1244
-            && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1245
-        ) {
1246
-            $payment_method_billing_form =
1247
-                $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1248
-                    $payment_method_billing_form
1249
-                );
1250
-        }
1251
-        $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper
1252
-            ? $payment_method_billing_form->get_html()
1253
-            : '';
1254
-        $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
1255
-        // localize validation rules for main form
1256
-        $this->checkout->current_step->reg_form->localize_validation_rules();
1257
-        $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1258
-        return true;
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     * _get_billing_form_for_payment_method
1264
-     *
1265
-     * @access private
1266
-     * @param EE_Payment_Method $payment_method
1267
-     * @return EE_Billing_Info_Form|EE_Form_Section_HTML
1268
-     * @throws EE_Error
1269
-     * @throws InvalidArgumentException
1270
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1271
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1272
-     */
1273
-    private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method)
1274
-    {
1275
-        $billing_form = $payment_method->type_obj()->billing_form(
1276
-            $this->checkout->transaction,
1277
-            array('amount_owing' => $this->checkout->amount_owing)
1278
-        );
1279
-        if ($billing_form instanceof EE_Billing_Info_Form) {
1280
-            if (apply_filters(
1281
-                'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1282
-                false
1283
-            )
1284
-                && EE_Registry::instance()->REQ->is_set('payment_method')
1285
-            ) {
1286
-                EE_Error::add_success(
1287
-                    apply_filters(
1288
-                        'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1289
-                        sprintf(
1290
-                            esc_html__(
1291
-                                'You have selected "%s" as your method of payment. Please note the important payment information below.',
1292
-                                'event_espresso'
1293
-                            ),
1294
-                            $payment_method->name()
1295
-                        )
1296
-                    )
1297
-                );
1298
-            }
1299
-            return apply_filters(
1300
-                'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
1301
-                $billing_form,
1302
-                $payment_method
1303
-            );
1304
-        }
1305
-        // no actual billing form, so return empty HTML form section
1306
-        return new EE_Form_Section_HTML();
1307
-    }
1308
-
1309
-
1310
-    /**
1311
-     * _get_selected_method_of_payment
1312
-     *
1313
-     * @access private
1314
-     * @param boolean $required whether to throw an error if the "selected_method_of_payment"
1315
-     *                          is not found in the incoming request
1316
-     * @param string  $request_param
1317
-     * @return NULL|string
1318
-     * @throws EE_Error
1319
-     * @throws InvalidArgumentException
1320
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1321
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1322
-     */
1323
-    private function _get_selected_method_of_payment(
1324
-        $required = false,
1325
-        $request_param = 'selected_method_of_payment'
1326
-    ) {
1327
-        // is selected_method_of_payment set in the request ?
1328
-        $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false);
1329
-        if ($selected_method_of_payment) {
1330
-            // sanitize it
1331
-            $selected_method_of_payment = is_array($selected_method_of_payment)
1332
-                ? array_shift($selected_method_of_payment)
1333
-                : $selected_method_of_payment;
1334
-            $selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
1335
-            // store it in the session so that it's available for all subsequent requests including AJAX
1336
-            $this->_save_selected_method_of_payment($selected_method_of_payment);
1337
-        } else {
1338
-            // or is is set in the session ?
1339
-            $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data(
1340
-                'selected_method_of_payment'
1341
-            );
1342
-        }
1343
-        // do ya really really gotta have it?
1344
-        if (empty($selected_method_of_payment) && $required) {
1345
-            EE_Error::add_error(
1346
-                sprintf(
1347
-                    esc_html__(
1348
-                        'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.',
1349
-                        'event_espresso'
1350
-                    ),
1351
-                    '<br/>',
1352
-                    '<br/>',
1353
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
1354
-                ),
1355
-                __FILE__,
1356
-                __FUNCTION__,
1357
-                __LINE__
1358
-            );
1359
-            return null;
1360
-        }
1361
-        return $selected_method_of_payment;
1362
-    }
1363
-
1364
-
1365
-
1366
-
1367
-
1368
-
1369
-    /********************************************************************************************************/
1370
-    /***********************************  SWITCH PAYMENT METHOD  ************************************/
1371
-    /********************************************************************************************************/
1372
-    /**
1373
-     * switch_payment_method
1374
-     *
1375
-     * @access public
1376
-     * @return string
1377
-     * @throws EE_Error
1378
-     * @throws InvalidArgumentException
1379
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1380
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1381
-     */
1382
-    public function switch_payment_method()
1383
-    {
1384
-        if (! $this->_verify_payment_method_is_set()) {
1385
-            return false;
1386
-        }
1387
-        if (apply_filters(
1388
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1389
-            false
1390
-        )) {
1391
-            EE_Error::add_success(
1392
-                apply_filters(
1393
-                    'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1394
-                    sprintf(
1395
-                        esc_html__(
1396
-                            'You have selected "%s" as your method of payment. Please note the important payment information below.',
1397
-                            'event_espresso'
1398
-                        ),
1399
-                        $this->checkout->payment_method->name()
1400
-                    )
1401
-                )
1402
-            );
1403
-        }
1404
-        // generate billing form for selected method of payment if it hasn't been done already
1405
-        if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1406
-            $this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1407
-                $this->checkout->payment_method
1408
-            );
1409
-        }
1410
-        // fill form with attendee info if applicable
1411
-        if (apply_filters(
1412
-            'FHEE__populate_billing_form_fields_from_attendee',
1413
-            (
1414
-                $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
1415
-                && $this->checkout->transaction_has_primary_registrant()
1416
-            ),
1417
-            $this->checkout->billing_form,
1418
-            $this->checkout->transaction
1419
-        )
1420
-        ) {
1421
-            $this->checkout->billing_form->populate_from_attendee(
1422
-                $this->checkout->transaction->primary_registration()->attendee()
1423
-            );
1424
-        }
1425
-        // and debug content
1426
-        if ($this->checkout->billing_form instanceof EE_Billing_Info_Form
1427
-            && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1428
-        ) {
1429
-            $this->checkout->billing_form =
1430
-                $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1431
-                    $this->checkout->billing_form
1432
-                );
1433
-        }
1434
-        // get html and validation rules for form
1435
-        if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
1436
-            $this->checkout->json_response->set_return_data(
1437
-                array('payment_method_info' => $this->checkout->billing_form->get_html())
1438
-            );
1439
-            // localize validation rules for main form
1440
-            $this->checkout->billing_form->localize_validation_rules(true);
1441
-            $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1442
-        } else {
1443
-            $this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
1444
-        }
1445
-        // prevents advancement to next step
1446
-        $this->checkout->continue_reg = false;
1447
-        return true;
1448
-    }
1449
-
1450
-
1451
-    /**
1452
-     * _verify_payment_method_is_set
1453
-     *
1454
-     * @return bool
1455
-     * @throws EE_Error
1456
-     * @throws InvalidArgumentException
1457
-     * @throws ReflectionException
1458
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1459
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1460
-     */
1461
-    protected function _verify_payment_method_is_set()
1462
-    {
1463
-        // generate billing form for selected method of payment if it hasn't been done already
1464
-        if (empty($this->checkout->selected_method_of_payment)) {
1465
-            // how have they chosen to pay?
1466
-            $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1467
-        } else {
1468
-            // choose your own adventure based on method_of_payment
1469
-            switch ($this->checkout->selected_method_of_payment) {
1470
-                case 'events_sold_out':
1471
-                    EE_Error::add_attention(
1472
-                        apply_filters(
1473
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg',
1474
-                            esc_html__(
1475
-                                'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
1476
-                                'event_espresso'
1477
-                            )
1478
-                        ),
1479
-                        __FILE__,
1480
-                        __FUNCTION__,
1481
-                        __LINE__
1482
-                    );
1483
-                    return false;
1484
-                    break;
1485
-                case 'payments_closed':
1486
-                    EE_Error::add_attention(
1487
-                        apply_filters(
1488
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg',
1489
-                            esc_html__(
1490
-                                'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.',
1491
-                                'event_espresso'
1492
-                            )
1493
-                        ),
1494
-                        __FILE__,
1495
-                        __FUNCTION__,
1496
-                        __LINE__
1497
-                    );
1498
-                    return false;
1499
-                    break;
1500
-                case 'no_payment_required':
1501
-                    EE_Error::add_attention(
1502
-                        apply_filters(
1503
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg',
1504
-                            esc_html__(
1505
-                                'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.',
1506
-                                'event_espresso'
1507
-                            )
1508
-                        ),
1509
-                        __FILE__,
1510
-                        __FUNCTION__,
1511
-                        __LINE__
1512
-                    );
1513
-                    return false;
1514
-                    break;
1515
-                default:
1516
-            }
1517
-        }
1518
-        // verify payment method
1519
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1520
-            // get payment method for selected method of payment
1521
-            $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1522
-        }
1523
-        return $this->checkout->payment_method instanceof EE_Payment_Method ? true : false;
1524
-    }
1525
-
1526
-
1527
-
1528
-    /********************************************************************************************************/
1529
-    /***************************************  SAVE PAYER DETAILS  ****************************************/
1530
-    /********************************************************************************************************/
1531
-    /**
1532
-     * save_payer_details_via_ajax
1533
-     *
1534
-     * @return void
1535
-     * @throws EE_Error
1536
-     * @throws InvalidArgumentException
1537
-     * @throws ReflectionException
1538
-     * @throws RuntimeException
1539
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1540
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1541
-     */
1542
-    public function save_payer_details_via_ajax()
1543
-    {
1544
-        if (! $this->_verify_payment_method_is_set()) {
1545
-            return;
1546
-        }
1547
-        // generate billing form for selected method of payment if it hasn't been done already
1548
-        if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1549
-            $this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1550
-                $this->checkout->payment_method
1551
-            );
1552
-        }
1553
-        // generate primary attendee from payer info if applicable
1554
-        if (! $this->checkout->transaction_has_primary_registrant()) {
1555
-            $attendee = $this->_create_attendee_from_request_data();
1556
-            if ($attendee instanceof EE_Attendee) {
1557
-                foreach ($this->checkout->transaction->registrations() as $registration) {
1558
-                    if ($registration->is_primary_registrant()) {
1559
-                        $this->checkout->primary_attendee_obj = $attendee;
1560
-                        $registration->_add_relation_to($attendee, 'Attendee');
1561
-                        $registration->set_attendee_id($attendee->ID());
1562
-                        $registration->update_cache_after_object_save('Attendee', $attendee);
1563
-                    }
1564
-                }
1565
-            }
1566
-        }
1567
-    }
1568
-
1569
-
1570
-    /**
1571
-     * create_attendee_from_request_data
1572
-     * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
1573
-     *
1574
-     * @return EE_Attendee
1575
-     * @throws EE_Error
1576
-     * @throws InvalidArgumentException
1577
-     * @throws ReflectionException
1578
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1579
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1580
-     */
1581
-    protected function _create_attendee_from_request_data()
1582
-    {
1583
-        // get State ID
1584
-        $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1585
-        if (! empty($STA_ID)) {
1586
-            // can we get state object from name ?
1587
-            EE_Registry::instance()->load_model('State');
1588
-            $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1589
-            $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1590
-        }
1591
-        // get Country ISO
1592
-        $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1593
-        if (! empty($CNT_ISO)) {
1594
-            // can we get country object from name ?
1595
-            EE_Registry::instance()->load_model('Country');
1596
-            $country = EEM_Country::instance()->get_col(
1597
-                array(array('CNT_name' => $CNT_ISO), 'limit' => 1),
1598
-                'CNT_ISO'
1599
-            );
1600
-            $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1601
-        }
1602
-        // grab attendee data
1603
-        $attendee_data = array(
1604
-            'ATT_fname'    => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1605
-            'ATT_lname'    => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1606
-            'ATT_email'    => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1607
-            'ATT_address'  => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1608
-            'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1609
-            'ATT_city'     => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1610
-            'STA_ID'       => $STA_ID,
1611
-            'CNT_ISO'      => $CNT_ISO,
1612
-            'ATT_zip'      => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1613
-            'ATT_phone'    => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1614
-        );
1615
-        // validate the email address since it is the most important piece of info
1616
-        if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) {
1617
-            EE_Error::add_error(
1618
-                esc_html__('An invalid email address was submitted.', 'event_espresso'),
1619
-                __FILE__,
1620
-                __FUNCTION__,
1621
-                __LINE__
1622
-            );
1623
-        }
1624
-        // does this attendee already exist in the db ? we're searching using a combination of first name, last name,
1625
-        // AND email address
1626
-        if (! empty($attendee_data['ATT_fname'])
1627
-            && ! empty($attendee_data['ATT_lname'])
1628
-            && ! empty($attendee_data['ATT_email'])
1629
-        ) {
1630
-            $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1631
-                array(
1632
-                    'ATT_fname' => $attendee_data['ATT_fname'],
1633
-                    'ATT_lname' => $attendee_data['ATT_lname'],
1634
-                    'ATT_email' => $attendee_data['ATT_email'],
1635
-                )
1636
-            );
1637
-            if ($existing_attendee instanceof EE_Attendee) {
1638
-                return $existing_attendee;
1639
-            }
1640
-        }
1641
-        // no existing attendee? kk let's create a new one
1642
-        // kinda lame, but we need a first and last name to create an attendee, so use the email address if those
1643
-        // don't exist
1644
-        $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname'])
1645
-            ? $attendee_data['ATT_fname']
1646
-            : $attendee_data['ATT_email'];
1647
-        $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname'])
1648
-            ? $attendee_data['ATT_lname']
1649
-            : $attendee_data['ATT_email'];
1650
-        return EE_Attendee::new_instance($attendee_data);
1651
-    }
1652
-
1653
-
1654
-
1655
-    /********************************************************************************************************/
1656
-    /****************************************  PROCESS REG STEP  *****************************************/
1657
-    /********************************************************************************************************/
1658
-    /**
1659
-     * process_reg_step
1660
-     *
1661
-     * @return bool
1662
-     * @throws EE_Error
1663
-     * @throws InvalidArgumentException
1664
-     * @throws ReflectionException
1665
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1666
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1667
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1668
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
1669
-     */
1670
-    public function process_reg_step()
1671
-    {
1672
-        // how have they chosen to pay?
1673
-        $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free()
1674
-            ? 'no_payment_required'
1675
-            : $this->_get_selected_method_of_payment(true);
1676
-        // choose your own adventure based on method_of_payment
1677
-        switch ($this->checkout->selected_method_of_payment) {
1678
-            case 'events_sold_out':
1679
-                $this->checkout->redirect = true;
1680
-                $this->checkout->redirect_url = $this->checkout->cancel_page_url;
1681
-                $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1682
-                // mark this reg step as completed
1683
-                $this->set_completed();
1684
-                return false;
1685
-                break;
1686
-
1687
-            case 'payments_closed':
1688
-                if (apply_filters(
1689
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success',
1690
-                    false
1691
-                )) {
1692
-                    EE_Error::add_success(
1693
-                        esc_html__('no payment required at this time.', 'event_espresso'),
1694
-                        __FILE__,
1695
-                        __FUNCTION__,
1696
-                        __LINE__
1697
-                    );
1698
-                }
1699
-                // mark this reg step as completed
1700
-                $this->set_completed();
1701
-                return true;
1702
-                break;
1703
-
1704
-            case 'no_payment_required':
1705
-                if (apply_filters(
1706
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success',
1707
-                    false
1708
-                )) {
1709
-                    EE_Error::add_success(
1710
-                        esc_html__('no payment required.', 'event_espresso'),
1711
-                        __FILE__,
1712
-                        __FUNCTION__,
1713
-                        __LINE__
1714
-                    );
1715
-                }
1716
-                // mark this reg step as completed
1717
-                $this->set_completed();
1718
-                return true;
1719
-                break;
1720
-
1721
-            default:
1722
-                $registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations(
1723
-                    EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
1724
-                );
1725
-                $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
1726
-                    $registrations,
1727
-                    EE_Registry::instance()->SSN->checkout()->revisit
1728
-                );
1729
-                // calculate difference between the two arrays
1730
-                $registrations = array_diff($registrations, $ejected_registrations);
1731
-                if (empty($registrations)) {
1732
-                    $this->_redirect_because_event_sold_out();
1733
-                    return false;
1734
-                }
1735
-                $payment_successful = $this->_process_payment();
1736
-                if ($payment_successful) {
1737
-                    $this->checkout->continue_reg = true;
1738
-                    $this->_maybe_set_completed($this->checkout->payment_method);
1739
-                } else {
1740
-                    $this->checkout->continue_reg = false;
1741
-                }
1742
-                return $payment_successful;
1743
-        }
1744
-    }
1745
-
1746
-
1747
-    /**
1748
-     * _redirect_because_event_sold_out
1749
-     *
1750
-     * @access protected
1751
-     * @return void
1752
-     */
1753
-    protected function _redirect_because_event_sold_out()
1754
-    {
1755
-        $this->checkout->continue_reg = false;
1756
-        // set redirect URL
1757
-        $this->checkout->redirect_url = add_query_arg(
1758
-            array('e_reg_url_link' => $this->checkout->reg_url_link),
1759
-            $this->checkout->current_step->reg_step_url()
1760
-        );
1761
-        $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1762
-    }
1763
-
1764
-
1765
-    /**
1766
-     * _maybe_set_completed
1767
-     *
1768
-     * @access protected
1769
-     * @param \EE_Payment_Method $payment_method
1770
-     * @return void
1771
-     * @throws \EE_Error
1772
-     */
1773
-    protected function _maybe_set_completed(EE_Payment_Method $payment_method)
1774
-    {
1775
-        switch ($payment_method->type_obj()->payment_occurs()) {
1776
-            case EE_PMT_Base::offsite:
1777
-                break;
1778
-            case EE_PMT_Base::onsite:
1779
-            case EE_PMT_Base::offline:
1780
-                // mark this reg step as completed
1781
-                $this->set_completed();
1782
-                break;
1783
-        }
1784
-    }
1785
-
1786
-
1787
-    /**
1788
-     *    update_reg_step
1789
-     *    this is the final step after a user  revisits the site to retry a payment
1790
-     *
1791
-     * @return bool
1792
-     * @throws EE_Error
1793
-     * @throws InvalidArgumentException
1794
-     * @throws ReflectionException
1795
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1796
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1797
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1798
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
1799
-     */
1800
-    public function update_reg_step()
1801
-    {
1802
-        $success = true;
1803
-        // if payment required
1804
-        if ($this->checkout->transaction->total() > 0) {
1805
-            do_action(
1806
-                'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway',
1807
-                $this->checkout->transaction
1808
-            );
1809
-            // attempt payment via payment method
1810
-            $success = $this->process_reg_step();
1811
-        }
1812
-        if ($success && ! $this->checkout->redirect) {
1813
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
1814
-                $this->checkout->transaction->ID()
1815
-            );
1816
-            // set return URL
1817
-            $this->checkout->redirect_url = add_query_arg(
1818
-                array('e_reg_url_link' => $this->checkout->reg_url_link),
1819
-                $this->checkout->thank_you_page_url
1820
-            );
1821
-        }
1822
-        return $success;
1823
-    }
1824
-
1825
-
1826
-    /**
1827
-     *    _process_payment
1828
-     *
1829
-     * @access private
1830
-     * @return bool
1831
-     * @throws EE_Error
1832
-     * @throws InvalidArgumentException
1833
-     * @throws ReflectionException
1834
-     * @throws RuntimeException
1835
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1836
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1837
-     */
1838
-    private function _process_payment()
1839
-    {
1840
-        // basically confirm that the event hasn't sold out since they hit the page
1841
-        if (! $this->_last_second_ticket_verifications()) {
1842
-            return false;
1843
-        }
1844
-        // ya gotta make a choice man
1845
-        if (empty($this->checkout->selected_method_of_payment)) {
1846
-            $this->checkout->json_response->set_plz_select_method_of_payment(
1847
-                esc_html__('Please select a method of payment before proceeding.', 'event_espresso')
1848
-            );
1849
-            return false;
1850
-        }
1851
-        // get EE_Payment_Method object
1852
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1853
-            return false;
1854
-        }
1855
-        // setup billing form
1856
-        if ($this->checkout->payment_method->is_on_site()) {
1857
-            $this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1858
-                $this->checkout->payment_method
1859
-            );
1860
-            // bad billing form ?
1861
-            if (! $this->_billing_form_is_valid()) {
1862
-                return false;
1863
-            }
1864
-        }
1865
-        // ensure primary registrant has been fully processed
1866
-        if (! $this->_setup_primary_registrant_prior_to_payment()) {
1867
-            return false;
1868
-        }
1869
-        // if session is close to expiring (under 10 minutes by default)
1870
-        if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) {
1871
-            // add some time to session expiration so that payment can be completed
1872
-            EE_Registry::instance()->SSN->extend_expiration();
1873
-        }
1874
-        /** @type EE_Transaction_Processor $transaction_processor */
1875
-        // $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1876
-        // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations
1877
-        // for events with a default reg status of Approved
1878
-        // $transaction_processor->toggle_registration_statuses_for_default_approved_events(
1879
-        //      $this->checkout->transaction, $this->checkout->reg_cache_where_params
1880
-        // );
1881
-        // attempt payment
1882
-        $payment = $this->_attempt_payment($this->checkout->payment_method);
1883
-        // process results
1884
-        $payment = $this->_validate_payment($payment);
1885
-        $payment = $this->_post_payment_processing($payment);
1886
-        // verify payment
1887
-        if ($payment instanceof EE_Payment) {
1888
-            // store that for later
1889
-            $this->checkout->payment = $payment;
1890
-            // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1891
-            $this->checkout->transaction->toggle_failed_transaction_status();
1892
-            $payment_status = $payment->status();
1893
-            if ($payment_status === EEM_Payment::status_id_approved
1894
-                || $payment_status === EEM_Payment::status_id_pending
1895
-            ) {
1896
-                return true;
1897
-            } else {
1898
-                return false;
1899
-            }
1900
-        } elseif ($payment === true) {
1901
-            // please note that offline payment methods will NOT make a payment,
1902
-            // but instead just mark themselves as the PMD_ID on the transaction, and return true
1903
-            $this->checkout->payment = $payment;
1904
-            return true;
1905
-        }
1906
-        // where's my money?
1907
-        return false;
1908
-    }
1909
-
1910
-
1911
-    /**
1912
-     * _last_second_ticket_verifications
1913
-     *
1914
-     * @access public
1915
-     * @return bool
1916
-     * @throws EE_Error
1917
-     */
1918
-    protected function _last_second_ticket_verifications()
1919
-    {
1920
-        // don't bother re-validating if not a return visit
1921
-        if (! $this->checkout->revisit) {
1922
-            return true;
1923
-        }
1924
-        $registrations = $this->checkout->transaction->registrations();
1925
-        if (empty($registrations)) {
1926
-            return false;
1927
-        }
1928
-        foreach ($registrations as $registration) {
1929
-            if ($registration instanceof EE_Registration && ! $registration->is_approved()) {
1930
-                $event = $registration->event_obj();
1931
-                if ($event instanceof EE_Event && $event->is_sold_out(true)) {
1932
-                    EE_Error::add_error(
1933
-                        apply_filters(
1934
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg',
1935
-                            sprintf(
1936
-                                esc_html__(
1937
-                                    'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
1938
-                                    'event_espresso'
1939
-                                ),
1940
-                                $event->name()
1941
-                            )
1942
-                        ),
1943
-                        __FILE__,
1944
-                        __FUNCTION__,
1945
-                        __LINE__
1946
-                    );
1947
-                    return false;
1948
-                }
1949
-            }
1950
-        }
1951
-        return true;
1952
-    }
1953
-
1954
-
1955
-    /**
1956
-     * redirect_form
1957
-     *
1958
-     * @access public
1959
-     * @return bool
1960
-     * @throws EE_Error
1961
-     * @throws InvalidArgumentException
1962
-     * @throws ReflectionException
1963
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1964
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1965
-     */
1966
-    public function redirect_form()
1967
-    {
1968
-        $payment_method_billing_info = $this->_payment_method_billing_info(
1969
-            $this->_get_payment_method_for_selected_method_of_payment()
1970
-        );
1971
-        $html = $payment_method_billing_info->get_html();
1972
-        $html .= $this->checkout->redirect_form;
1973
-        EE_Registry::instance()->REQ->add_output($html);
1974
-        return true;
1975
-    }
1976
-
1977
-
1978
-    /**
1979
-     * _billing_form_is_valid
1980
-     *
1981
-     * @access private
1982
-     * @return bool
1983
-     * @throws \EE_Error
1984
-     */
1985
-    private function _billing_form_is_valid()
1986
-    {
1987
-        if (! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1988
-            return true;
1989
-        }
1990
-        if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1991
-            if ($this->checkout->billing_form->was_submitted()) {
1992
-                $this->checkout->billing_form->receive_form_submission();
1993
-                if ($this->checkout->billing_form->is_valid()) {
1994
-                    return true;
1995
-                }
1996
-                $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1997
-                $error_strings = array();
1998
-                foreach ($validation_errors as $validation_error) {
1999
-                    if ($validation_error instanceof EE_Validation_Error) {
2000
-                        $form_section = $validation_error->get_form_section();
2001
-                        if ($form_section instanceof EE_Form_Input_Base) {
2002
-                            $label = $form_section->html_label_text();
2003
-                        } elseif ($form_section instanceof EE_Form_Section_Base) {
2004
-                            $label = $form_section->name();
2005
-                        } else {
2006
-                            $label = esc_html__('Validation Error', 'event_espresso');
2007
-                        }
2008
-                        $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
2009
-                    }
2010
-                }
2011
-                EE_Error::add_error(
2012
-                    sprintf(
2013
-                        esc_html__(
2014
-                            'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s',
2015
-                            'event_espresso'
2016
-                        ),
2017
-                        '<br/>',
2018
-                        implode('<br/>', $error_strings)
2019
-                    ),
2020
-                    __FILE__,
2021
-                    __FUNCTION__,
2022
-                    __LINE__
2023
-                );
2024
-            } else {
2025
-                EE_Error::add_error(
2026
-                    esc_html__(
2027
-                        'The billing form was not submitted or something prevented it\'s submission.',
2028
-                        'event_espresso'
2029
-                    ),
2030
-                    __FILE__,
2031
-                    __FUNCTION__,
2032
-                    __LINE__
2033
-                );
2034
-            }
2035
-        } else {
2036
-            EE_Error::add_error(
2037
-                esc_html__(
2038
-                    'The submitted billing form is invalid possibly due to a technical reason.',
2039
-                    'event_espresso'
2040
-                ),
2041
-                __FILE__,
2042
-                __FUNCTION__,
2043
-                __LINE__
2044
-            );
2045
-        }
2046
-        return false;
2047
-    }
2048
-
2049
-
2050
-    /**
2051
-     * _setup_primary_registrant_prior_to_payment
2052
-     * ensures that the primary registrant has a valid attendee object created with the critical details populated
2053
-     * (first & last name & email) and that both the transaction object and primary registration object have been saved
2054
-     * plz note that any other registrations will NOT be saved at this point (because they may not have any details
2055
-     * yet)
2056
-     *
2057
-     * @access private
2058
-     * @return bool
2059
-     * @throws EE_Error
2060
-     * @throws InvalidArgumentException
2061
-     * @throws ReflectionException
2062
-     * @throws RuntimeException
2063
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2064
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2065
-     */
2066
-    private function _setup_primary_registrant_prior_to_payment()
2067
-    {
2068
-        // check if transaction has a primary registrant and that it has a related Attendee object
2069
-        // if not, then we need to at least gather some primary registrant data before attempting payment
2070
-        if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
2071
-            && ! $this->checkout->transaction_has_primary_registrant()
2072
-            && ! $this->_capture_primary_registration_data_from_billing_form()
2073
-        ) {
2074
-            return false;
2075
-        }
2076
-        // because saving an object clears it's cache, we need to do the chevy shuffle
2077
-        // grab the primary_registration object
2078
-        $primary_registration = $this->checkout->transaction->primary_registration();
2079
-        // at this point we'll consider a TXN to not have been failed
2080
-        $this->checkout->transaction->toggle_failed_transaction_status();
2081
-        // save the TXN ( which clears cached copy of primary_registration)
2082
-        $this->checkout->transaction->save();
2083
-        // grab TXN ID and save it to the primary_registration
2084
-        $primary_registration->set_transaction_id($this->checkout->transaction->ID());
2085
-        // save what we have so far
2086
-        $primary_registration->save();
2087
-        return true;
2088
-    }
2089
-
2090
-
2091
-    /**
2092
-     * _capture_primary_registration_data_from_billing_form
2093
-     *
2094
-     * @access private
2095
-     * @return bool
2096
-     * @throws EE_Error
2097
-     * @throws InvalidArgumentException
2098
-     * @throws ReflectionException
2099
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2100
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2101
-     */
2102
-    private function _capture_primary_registration_data_from_billing_form()
2103
-    {
2104
-        // convert billing form data into an attendee
2105
-        $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
2106
-        if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2107
-            EE_Error::add_error(
2108
-                sprintf(
2109
-                    esc_html__(
2110
-                        'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.',
2111
-                        'event_espresso'
2112
-                    ),
2113
-                    '<br/>',
2114
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2115
-                ),
2116
-                __FILE__,
2117
-                __FUNCTION__,
2118
-                __LINE__
2119
-            );
2120
-            return false;
2121
-        }
2122
-        $primary_registration = $this->checkout->transaction->primary_registration();
2123
-        if (! $primary_registration instanceof EE_Registration) {
2124
-            EE_Error::add_error(
2125
-                sprintf(
2126
-                    esc_html__(
2127
-                        'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2128
-                        'event_espresso'
2129
-                    ),
2130
-                    '<br/>',
2131
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2132
-                ),
2133
-                __FILE__,
2134
-                __FUNCTION__,
2135
-                __LINE__
2136
-            );
2137
-            return false;
2138
-        }
2139
-        if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2140
-              instanceof
2141
-              EE_Attendee
2142
-        ) {
2143
-            EE_Error::add_error(
2144
-                sprintf(
2145
-                    esc_html__(
2146
-                        'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.',
2147
-                        'event_espresso'
2148
-                    ),
2149
-                    '<br/>',
2150
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2151
-                ),
2152
-                __FILE__,
2153
-                __FUNCTION__,
2154
-                __LINE__
2155
-            );
2156
-            return false;
2157
-        }
2158
-        /** @type EE_Registration_Processor $registration_processor */
2159
-        $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
2160
-        // at this point, we should have enough details about the registrant to consider the registration NOT incomplete
2161
-        $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
2162
-        return true;
2163
-    }
2164
-
2165
-
2166
-    /**
2167
-     * _get_payment_method_for_selected_method_of_payment
2168
-     * retrieves a valid payment method
2169
-     *
2170
-     * @access public
2171
-     * @return EE_Payment_Method
2172
-     * @throws EE_Error
2173
-     * @throws InvalidArgumentException
2174
-     * @throws ReflectionException
2175
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2176
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2177
-     */
2178
-    private function _get_payment_method_for_selected_method_of_payment()
2179
-    {
2180
-        if ($this->checkout->selected_method_of_payment === 'events_sold_out') {
2181
-            $this->_redirect_because_event_sold_out();
2182
-            return null;
2183
-        }
2184
-        // get EE_Payment_Method object
2185
-        if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) {
2186
-            $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
2187
-        } else {
2188
-            // load EEM_Payment_Method
2189
-            EE_Registry::instance()->load_model('Payment_Method');
2190
-            /** @type EEM_Payment_Method $EEM_Payment_Method */
2191
-            $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
2192
-            $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
2193
-        }
2194
-        // verify $payment_method
2195
-        if (! $payment_method instanceof EE_Payment_Method) {
2196
-            // not a payment
2197
-            EE_Error::add_error(
2198
-                sprintf(
2199
-                    esc_html__(
2200
-                        'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2201
-                        'event_espresso'
2202
-                    ),
2203
-                    '<br/>',
2204
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2205
-                ),
2206
-                __FILE__,
2207
-                __FUNCTION__,
2208
-                __LINE__
2209
-            );
2210
-            return null;
2211
-        }
2212
-        // and verify it has a valid Payment_Method Type object
2213
-        if (! $payment_method->type_obj() instanceof EE_PMT_Base) {
2214
-            // not a payment
2215
-            EE_Error::add_error(
2216
-                sprintf(
2217
-                    esc_html__(
2218
-                        'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2219
-                        'event_espresso'
2220
-                    ),
2221
-                    '<br/>',
2222
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2223
-                ),
2224
-                __FILE__,
2225
-                __FUNCTION__,
2226
-                __LINE__
2227
-            );
2228
-            return null;
2229
-        }
2230
-        return $payment_method;
2231
-    }
2232
-
2233
-
2234
-    /**
2235
-     *    _attempt_payment
2236
-     *
2237
-     * @access    private
2238
-     * @type    EE_Payment_Method $payment_method
2239
-     * @return mixed EE_Payment | boolean
2240
-     * @throws EE_Error
2241
-     * @throws InvalidArgumentException
2242
-     * @throws ReflectionException
2243
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2244
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2245
-     */
2246
-    private function _attempt_payment(EE_Payment_Method $payment_method)
2247
-    {
2248
-        $payment = null;
2249
-        $this->checkout->transaction->save();
2250
-        $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2251
-        if (! $payment_processor instanceof EE_Payment_Processor) {
2252
-            return false;
2253
-        }
2254
-        try {
2255
-            $payment_processor->set_revisit($this->checkout->revisit);
2256
-            // generate payment object
2257
-            $payment = $payment_processor->process_payment(
2258
-                $payment_method,
2259
-                $this->checkout->transaction,
2260
-                $this->checkout->amount_owing,
2261
-                $this->checkout->billing_form,
2262
-                $this->_get_return_url($payment_method),
2263
-                'CART',
2264
-                $this->checkout->admin_request,
2265
-                true,
2266
-                $this->reg_step_url()
2267
-            );
2268
-        } catch (Exception $e) {
2269
-            $this->_handle_payment_processor_exception($e);
2270
-        }
2271
-        return $payment;
2272
-    }
2273
-
2274
-
2275
-    /**
2276
-     * _handle_payment_processor_exception
2277
-     *
2278
-     * @access protected
2279
-     * @param \Exception $e
2280
-     * @return void
2281
-     * @throws EE_Error
2282
-     * @throws InvalidArgumentException
2283
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2284
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2285
-     */
2286
-    protected function _handle_payment_processor_exception(Exception $e)
2287
-    {
2288
-        EE_Error::add_error(
2289
-            sprintf(
2290
-                esc_html__(
2291
-                    'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s',
2292
-                    'event_espresso'
2293
-                ),
2294
-                '<br/>',
2295
-                EE_Registry::instance()->CFG->organization->get_pretty('email'),
2296
-                $e->getMessage(),
2297
-                $e->getFile(),
2298
-                $e->getLine()
2299
-            ),
2300
-            __FILE__,
2301
-            __FUNCTION__,
2302
-            __LINE__
2303
-        );
2304
-    }
2305
-
2306
-
2307
-    /**
2308
-     * _get_return_url
2309
-     *
2310
-     * @access protected
2311
-     * @param \EE_Payment_Method $payment_method
2312
-     * @return string
2313
-     * @throws \EE_Error
2314
-     */
2315
-    protected function _get_return_url(EE_Payment_Method $payment_method)
2316
-    {
2317
-        $return_url = '';
2318
-        switch ($payment_method->type_obj()->payment_occurs()) {
2319
-            case EE_PMT_Base::offsite:
2320
-                $return_url = add_query_arg(
2321
-                    array(
2322
-                        'action'                     => 'process_gateway_response',
2323
-                        'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2324
-                        'spco_txn'                   => $this->checkout->transaction->ID(),
2325
-                    ),
2326
-                    $this->reg_step_url()
2327
-                );
2328
-                break;
2329
-            case EE_PMT_Base::onsite:
2330
-            case EE_PMT_Base::offline:
2331
-                $return_url = $this->checkout->next_step->reg_step_url();
2332
-                break;
2333
-        }
2334
-        return $return_url;
2335
-    }
2336
-
2337
-
2338
-    /**
2339
-     * _validate_payment
2340
-     *
2341
-     * @access private
2342
-     * @param EE_Payment $payment
2343
-     * @return EE_Payment|FALSE
2344
-     * @throws EE_Error
2345
-     * @throws InvalidArgumentException
2346
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2347
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2348
-     */
2349
-    private function _validate_payment($payment = null)
2350
-    {
2351
-        if ($this->checkout->payment_method->is_off_line()) {
2352
-            return true;
2353
-        }
2354
-        // verify payment object
2355
-        if (! $payment instanceof EE_Payment) {
2356
-            // not a payment
2357
-            EE_Error::add_error(
2358
-                sprintf(
2359
-                    esc_html__(
2360
-                        'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.',
2361
-                        'event_espresso'
2362
-                    ),
2363
-                    '<br/>',
2364
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2365
-                ),
2366
-                __FILE__,
2367
-                __FUNCTION__,
2368
-                __LINE__
2369
-            );
2370
-            return false;
2371
-        }
2372
-        return $payment;
2373
-    }
2374
-
2375
-
2376
-    /**
2377
-     * _post_payment_processing
2378
-     *
2379
-     * @access private
2380
-     * @param EE_Payment|bool $payment
2381
-     * @return bool
2382
-     * @throws EE_Error
2383
-     * @throws InvalidArgumentException
2384
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2385
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2386
-     */
2387
-    private function _post_payment_processing($payment = null)
2388
-    {
2389
-        // Off-Line payment?
2390
-        if ($payment === true) {
2391
-            // $this->_setup_redirect_for_next_step();
2392
-            return true;
2393
-            // On-Site payment?
2394
-        } elseif ($this->checkout->payment_method->is_on_site()) {
2395
-            if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2396
-                // $this->_setup_redirect_for_next_step();
2397
-                $this->checkout->continue_reg = false;
2398
-            }
2399
-            // Off-Site payment?
2400
-        } elseif ($this->checkout->payment_method->is_off_site()) {
2401
-            // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
2402
-            if ($payment instanceof EE_Payment && $payment->redirect_url()) {
2403
-                do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
2404
-                $this->checkout->redirect = true;
2405
-                $this->checkout->redirect_form = $payment->redirect_form();
2406
-                $this->checkout->redirect_url = $this->reg_step_url('redirect_form');
2407
-                // set JSON response
2408
-                $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
2409
-                // and lastly, let's bump the payment status to pending
2410
-                $payment->set_status(EEM_Payment::status_id_pending);
2411
-                $payment->save();
2412
-            } else {
2413
-                // we couldn't redirect the user. Let's tell them why.
2414
-                $error_message = sprintf(
2415
-                    esc_html__(
2416
-                        'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.',
2417
-                        'event_espresso'
2418
-                    ),
2419
-                    '<br/>',
2420
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2421
-                );
2422
-                if ($payment instanceof EE_Payment && $payment->gateway_response()) {
2423
-                    $error_message = $error_message . '<br/>' . $payment->gateway_response();
2424
-                }
2425
-                $this->checkout->continue_reg = false;
2426
-                EE_Error::add_error(
2427
-                    $error_message,
2428
-                    __FILE__,
2429
-                    __FUNCTION__,
2430
-                    __LINE__
2431
-                );
2432
-            }
2433
-        } else {
2434
-            // ummm ya... not Off-Line, not On-Site, not off-Site ????
2435
-            $this->checkout->continue_reg = false;
2436
-            return false;
2437
-        }
2438
-        return $payment;
2439
-    }
2440
-
2441
-
2442
-    /**
2443
-     *    _process_payment_status
2444
-     *
2445
-     * @access private
2446
-     * @type    EE_Payment $payment
2447
-     * @param string       $payment_occurs
2448
-     * @return bool
2449
-     * @throws EE_Error
2450
-     * @throws InvalidArgumentException
2451
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2452
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2453
-     */
2454
-    private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline)
2455
-    {
2456
-        // off-line payment? carry on
2457
-        if ($payment_occurs === EE_PMT_Base::offline) {
2458
-            return true;
2459
-        }
2460
-        // verify payment validity
2461
-        if ($payment instanceof EE_Payment) {
2462
-            do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
2463
-            $msg = $payment->gateway_response();
2464
-            // check results
2465
-            switch ($payment->status()) {
2466
-                // good payment
2467
-                case EEM_Payment::status_id_approved:
2468
-                    EE_Error::add_success(
2469
-                        esc_html__('Your payment was processed successfully.', 'event_espresso'),
2470
-                        __FILE__,
2471
-                        __FUNCTION__,
2472
-                        __LINE__
2473
-                    );
2474
-                    return true;
2475
-                    break;
2476
-                // slow payment
2477
-                case EEM_Payment::status_id_pending:
2478
-                    if (empty($msg)) {
2479
-                        $msg = esc_html__(
2480
-                            'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.',
2481
-                            'event_espresso'
2482
-                        );
2483
-                    }
2484
-                    EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
2485
-                    return true;
2486
-                    break;
2487
-                // don't wanna payment
2488
-                case EEM_Payment::status_id_cancelled:
2489
-                    if (empty($msg)) {
2490
-                        $msg = _n(
2491
-                            'Payment cancelled. Please try again.',
2492
-                            'Payment cancelled. Please try again or select another method of payment.',
2493
-                            count($this->checkout->available_payment_methods),
2494
-                            'event_espresso'
2495
-                        );
2496
-                    }
2497
-                    EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2498
-                    return false;
2499
-                    break;
2500
-                // not enough payment
2501
-                case EEM_Payment::status_id_declined:
2502
-                    if (empty($msg)) {
2503
-                        $msg = _n(
2504
-                            'We\'re sorry but your payment was declined. Please try again.',
2505
-                            'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
2506
-                            count($this->checkout->available_payment_methods),
2507
-                            'event_espresso'
2508
-                        );
2509
-                    }
2510
-                    EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2511
-                    return false;
2512
-                    break;
2513
-                // bad payment
2514
-                case EEM_Payment::status_id_failed:
2515
-                    if (! empty($msg)) {
2516
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2517
-                        return false;
2518
-                    }
2519
-                    // default to error below
2520
-                    break;
2521
-            }
2522
-        }
2523
-        // off-site payment gateway responses are too unreliable, so let's just assume that
2524
-        // the payment processing is just running slower than the registrant's request
2525
-        if ($payment_occurs === EE_PMT_Base::offsite) {
2526
-            return true;
2527
-        }
2528
-        EE_Error::add_error(
2529
-            sprintf(
2530
-                esc_html__(
2531
-                    'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.',
2532
-                    'event_espresso'
2533
-                ),
2534
-                '<br/>',
2535
-                EE_Registry::instance()->CFG->organization->get_pretty('email')
2536
-            ),
2537
-            __FILE__,
2538
-            __FUNCTION__,
2539
-            __LINE__
2540
-        );
2541
-        return false;
2542
-    }
2543
-
2544
-
2545
-
2546
-
2547
-
2548
-
2549
-    /********************************************************************************************************/
2550
-    /**********************************  PROCESS GATEWAY RESPONSE  **********************************/
2551
-    /********************************************************************************************************/
2552
-    /**
2553
-     * process_gateway_response
2554
-     * this is the return point for Off-Site Payment Methods
2555
-     * It will attempt to "handle the IPN" if it appears that this has not already occurred,
2556
-     * otherwise, it will load up the last payment made for the TXN.
2557
-     * If the payment retrieved looks good, it will then either:
2558
-     *    complete the current step and allow advancement to the next reg step
2559
-     *        or present the payment options again
2560
-     *
2561
-     * @access private
2562
-     * @return EE_Payment|FALSE
2563
-     * @throws EE_Error
2564
-     * @throws InvalidArgumentException
2565
-     * @throws ReflectionException
2566
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2567
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2568
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2569
-     */
2570
-    public function process_gateway_response()
2571
-    {
2572
-        $payment = null;
2573
-        // how have they chosen to pay?
2574
-        $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2575
-        // get EE_Payment_Method object
2576
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2577
-            $this->checkout->continue_reg = false;
2578
-            return false;
2579
-        }
2580
-        if (! $this->checkout->payment_method->is_off_site()) {
2581
-            return false;
2582
-        }
2583
-        $this->_validate_offsite_return();
2584
-        // DEBUG LOG
2585
-        // $this->checkout->log(
2586
-        //     __CLASS__,
2587
-        //     __FUNCTION__,
2588
-        //     __LINE__,
2589
-        //     array(
2590
-        //         'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2591
-        //         'payment_method'             => $this->checkout->payment_method,
2592
-        //     ),
2593
-        //     true
2594
-        // );
2595
-        // verify TXN
2596
-        if ($this->checkout->transaction instanceof EE_Transaction) {
2597
-            $gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2598
-            if (! $gateway instanceof EE_Offsite_Gateway) {
2599
-                $this->checkout->continue_reg = false;
2600
-                return false;
2601
-            }
2602
-            $payment = $this->_process_off_site_payment($gateway);
2603
-            $payment = $this->_process_cancelled_payments($payment);
2604
-            $payment = $this->_validate_payment($payment);
2605
-            // if payment was not declined by the payment gateway or cancelled by the registrant
2606
-            if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
2607
-                // $this->_setup_redirect_for_next_step();
2608
-                // store that for later
2609
-                $this->checkout->payment = $payment;
2610
-                // mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
2611
-                // because we will complete this step during the IPN processing then
2612
-                if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) {
2613
-                    $this->set_completed();
2614
-                }
2615
-                return true;
2616
-            }
2617
-        }
2618
-        // DEBUG LOG
2619
-        // $this->checkout->log(
2620
-        //     __CLASS__,
2621
-        //     __FUNCTION__,
2622
-        //     __LINE__,
2623
-        //     array('payment' => $payment)
2624
-        // );
2625
-        $this->checkout->continue_reg = false;
2626
-        return false;
2627
-    }
2628
-
2629
-
2630
-    /**
2631
-     * _validate_return
2632
-     *
2633
-     * @access private
2634
-     * @return void
2635
-     * @throws EE_Error
2636
-     * @throws InvalidArgumentException
2637
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2638
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2639
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2640
-     */
2641
-    private function _validate_offsite_return()
2642
-    {
2643
-        $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
2644
-        if ($TXN_ID !== $this->checkout->transaction->ID()) {
2645
-            // Houston... we might have a problem
2646
-            $invalid_TXN = false;
2647
-            // first gather some info
2648
-            $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2649
-            $primary_registrant = $valid_TXN instanceof EE_Transaction
2650
-                ? $valid_TXN->primary_registration()
2651
-                : null;
2652
-            // let's start by retrieving the cart for this TXN
2653
-            $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction);
2654
-            if ($cart instanceof EE_Cart) {
2655
-                // verify that the current cart has tickets
2656
-                $tickets = $cart->get_tickets();
2657
-                if (empty($tickets)) {
2658
-                    $invalid_TXN = true;
2659
-                }
2660
-            } else {
2661
-                $invalid_TXN = true;
2662
-            }
2663
-            $valid_TXN_SID = $primary_registrant instanceof EE_Registration
2664
-                ? $primary_registrant->session_ID()
2665
-                : null;
2666
-            // validate current Session ID and compare against valid TXN session ID
2667
-            if ($invalid_TXN // if this is already true, then skip other checks
2668
-                || EE_Session::instance()->id() === null
2669
-                || (
2670
-                    // WARNING !!!
2671
-                    // this could be PayPal sending back duplicate requests (ya they do that)
2672
-                    // or it **could** mean someone is simply registering AGAIN after having just done so
2673
-                    // so now we need to determine if this current TXN looks valid or not
2674
-                    // and whether this reg step has even been started ?
2675
-                    EE_Session::instance()->id() === $valid_TXN_SID
2676
-                    // really? you're half way through this reg step, but you never started it ?
2677
-                    && $this->checkout->transaction->reg_step_completed($this->slug()) === false
2678
-                )
2679
-            ) {
2680
-                $invalid_TXN = true;
2681
-            }
2682
-            if ($invalid_TXN) {
2683
-                // is the valid TXN completed ?
2684
-                if ($valid_TXN instanceof EE_Transaction) {
2685
-                    // has this step even been started ?
2686
-                    $reg_step_completed = $valid_TXN->reg_step_completed($this->slug());
2687
-                    if ($reg_step_completed !== false && $reg_step_completed !== true) {
2688
-                        // so it **looks** like this is a double request from PayPal
2689
-                        // so let's try to pick up where we left off
2690
-                        $this->checkout->transaction = $valid_TXN;
2691
-                        $this->checkout->refresh_all_entities(true);
2692
-                        return;
2693
-                    }
2694
-                }
2695
-                // you appear to be lost?
2696
-                $this->_redirect_wayward_request($primary_registrant);
2697
-            }
2698
-        }
2699
-    }
2700
-
2701
-
2702
-    /**
2703
-     * _redirect_wayward_request
2704
-     *
2705
-     * @access private
2706
-     * @param \EE_Registration|null $primary_registrant
2707
-     * @return bool
2708
-     * @throws EE_Error
2709
-     * @throws InvalidArgumentException
2710
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2711
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2712
-     */
2713
-    private function _redirect_wayward_request(EE_Registration $primary_registrant)
2714
-    {
2715
-        if (! $primary_registrant instanceof EE_Registration) {
2716
-            // try redirecting based on the current TXN
2717
-            $primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2718
-                ? $this->checkout->transaction->primary_registration()
2719
-                : null;
2720
-        }
2721
-        if (! $primary_registrant instanceof EE_Registration) {
2722
-            EE_Error::add_error(
2723
-                sprintf(
2724
-                    esc_html__(
2725
-                        'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.',
2726
-                        'event_espresso'
2727
-                    ),
2728
-                    '<br/>',
2729
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2730
-                ),
2731
-                __FILE__,
2732
-                __FUNCTION__,
2733
-                __LINE__
2734
-            );
2735
-            return false;
2736
-        }
2737
-        // make sure transaction is not locked
2738
-        $this->checkout->transaction->unlock();
2739
-        wp_safe_redirect(
2740
-            add_query_arg(
2741
-                array(
2742
-                    'e_reg_url_link' => $primary_registrant->reg_url_link(),
2743
-                ),
2744
-                $this->checkout->thank_you_page_url
2745
-            )
2746
-        );
2747
-        exit();
2748
-    }
2749
-
2750
-
2751
-    /**
2752
-     * _process_off_site_payment
2753
-     *
2754
-     * @access private
2755
-     * @param \EE_Offsite_Gateway $gateway
2756
-     * @return EE_Payment
2757
-     * @throws EE_Error
2758
-     * @throws InvalidArgumentException
2759
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2760
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2761
-     */
2762
-    private function _process_off_site_payment(EE_Offsite_Gateway $gateway)
2763
-    {
2764
-        try {
2765
-            $request_data = \EE_Registry::instance()->REQ->params();
2766
-            // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
2767
-            $this->set_handle_IPN_in_this_request(
2768
-                $gateway->handle_IPN_in_this_request($request_data, false)
2769
-            );
2770
-            if ($this->handle_IPN_in_this_request()) {
2771
-                // get payment details and process results
2772
-                /** @type EE_Payment_Processor $payment_processor */
2773
-                $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2774
-                $payment = $payment_processor->process_ipn(
2775
-                    $request_data,
2776
-                    $this->checkout->transaction,
2777
-                    $this->checkout->payment_method,
2778
-                    true,
2779
-                    false
2780
-                );
2781
-                // $payment_source = 'process_ipn';
2782
-            } else {
2783
-                $payment = $this->checkout->transaction->last_payment();
2784
-                // $payment_source = 'last_payment';
2785
-            }
2786
-        } catch (Exception $e) {
2787
-            // let's just eat the exception and try to move on using any previously set payment info
2788
-            $payment = $this->checkout->transaction->last_payment();
2789
-            // $payment_source = 'last_payment after Exception';
2790
-            // but if we STILL don't have a payment object
2791
-            if (! $payment instanceof EE_Payment) {
2792
-                // then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2793
-                $this->_handle_payment_processor_exception($e);
2794
-            }
2795
-        }
2796
-        // DEBUG LOG
2797
-        // $this->checkout->log(
2798
-        //     __CLASS__,
2799
-        //     __FUNCTION__,
2800
-        //     __LINE__,
2801
-        //     array(
2802
-        //         'process_ipn_payment' => $payment,
2803
-        //         'payment_source'      => $payment_source,
2804
-        //     )
2805
-        // );
2806
-        return $payment;
2807
-    }
2808
-
2809
-
2810
-    /**
2811
-     * _process_cancelled_payments
2812
-     * just makes sure that the payment status gets updated correctly
2813
-     * so tha tan error isn't generated during payment validation
2814
-     *
2815
-     * @access private
2816
-     * @param EE_Payment $payment
2817
-     * @return EE_Payment | FALSE
2818
-     * @throws \EE_Error
2819
-     */
2820
-    private function _process_cancelled_payments($payment = null)
2821
-    {
2822
-        if ($payment instanceof EE_Payment
2823
-            && isset($_REQUEST['ee_cancel_payment'])
2824
-            && $payment->status() === EEM_Payment::status_id_failed
2825
-        ) {
2826
-            $payment->set_status(EEM_Payment::status_id_cancelled);
2827
-        }
2828
-        return $payment;
2829
-    }
2830
-
2831
-
2832
-    /**
2833
-     *    get_transaction_details_for_gateways
2834
-     *
2835
-     * @access    public
2836
-     * @return int
2837
-     * @throws EE_Error
2838
-     * @throws InvalidArgumentException
2839
-     * @throws ReflectionException
2840
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2841
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2842
-     */
2843
-    public function get_transaction_details_for_gateways()
2844
-    {
2845
-        $txn_details = array();
2846
-        // ya gotta make a choice man
2847
-        if (empty($this->checkout->selected_method_of_payment)) {
2848
-            $txn_details = array(
2849
-                'error' => esc_html__('Please select a method of payment before proceeding.', 'event_espresso'),
2850
-            );
2851
-        }
2852
-        // get EE_Payment_Method object
2853
-        if (empty($txn_details)
2854
-            &&
2855
-            ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2856
-        ) {
2857
-            $txn_details = array(
2858
-                'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2859
-                'error'                      => esc_html__(
2860
-                    'A valid Payment Method could not be determined.',
2861
-                    'event_espresso'
2862
-                ),
2863
-            );
2864
-        }
2865
-        if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2866
-            $return_url = $this->_get_return_url($this->checkout->payment_method);
2867
-            $txn_details = array(
2868
-                'TXN_ID'         => $this->checkout->transaction->ID(),
2869
-                'TXN_timestamp'  => $this->checkout->transaction->datetime(),
2870
-                'TXN_total'      => $this->checkout->transaction->total(),
2871
-                'TXN_paid'       => $this->checkout->transaction->paid(),
2872
-                'TXN_reg_steps'  => $this->checkout->transaction->reg_steps(),
2873
-                'STS_ID'         => $this->checkout->transaction->status_ID(),
2874
-                'PMD_ID'         => $this->checkout->transaction->payment_method_ID(),
2875
-                'payment_amount' => $this->checkout->amount_owing,
2876
-                'return_url'     => $return_url,
2877
-                'cancel_url'     => add_query_arg(array('ee_cancel_payment' => true), $return_url),
2878
-                'notify_url'     => EE_Config::instance()->core->txn_page_url(
2879
-                    array(
2880
-                        'e_reg_url_link'    => $this->checkout->transaction->primary_registration()->reg_url_link(),
2881
-                        'ee_payment_method' => $this->checkout->payment_method->slug(),
2882
-                    )
2883
-                ),
2884
-            );
2885
-        }
2886
-        echo wp_json_encode($txn_details);
2887
-        exit();
2888
-    }
2889
-
2890
-
2891
-    /**
2892
-     *    __sleep
2893
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
2894
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
2895
-     * reg form, because if needed, it will be regenerated anyways
2896
-     *
2897
-     * @return array
2898
-     */
2899
-    public function __sleep()
2900
-    {
2901
-        // remove the reg form and the checkout
2902
-        return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display'));
2903
-    }
15
+	/**
16
+	 * @access protected
17
+	 * @var EE_Line_Item_Display $Line_Item_Display
18
+	 */
19
+	protected $line_item_display;
20
+
21
+	/**
22
+	 * @access protected
23
+	 * @var boolean $handle_IPN_in_this_request
24
+	 */
25
+	protected $handle_IPN_in_this_request = false;
26
+
27
+
28
+	/**
29
+	 *    set_hooks - for hooking into EE Core, other modules, etc
30
+	 *
31
+	 * @access    public
32
+	 * @return    void
33
+	 */
34
+	public static function set_hooks()
35
+	{
36
+		add_filter(
37
+			'FHEE__SPCO__EE_Line_Item_Filter_Collection',
38
+			array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')
39
+		);
40
+		add_action(
41
+			'wp_ajax_switch_spco_billing_form',
42
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
43
+		);
44
+		add_action(
45
+			'wp_ajax_nopriv_switch_spco_billing_form',
46
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
47
+		);
48
+		add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
49
+		add_action(
50
+			'wp_ajax_nopriv_save_payer_details',
51
+			array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')
52
+		);
53
+		add_action(
54
+			'wp_ajax_get_transaction_details_for_gateways',
55
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
56
+		);
57
+		add_action(
58
+			'wp_ajax_nopriv_get_transaction_details_for_gateways',
59
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
60
+		);
61
+		add_filter(
62
+			'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
63
+			array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'),
64
+			10,
65
+			1
66
+		);
67
+	}
68
+
69
+
70
+	/**
71
+	 *    ajax switch_spco_billing_form
72
+	 *
73
+	 * @throws \EE_Error
74
+	 */
75
+	public static function switch_spco_billing_form()
76
+	{
77
+		EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
78
+	}
79
+
80
+
81
+	/**
82
+	 *    ajax save_payer_details
83
+	 *
84
+	 * @throws \EE_Error
85
+	 */
86
+	public static function save_payer_details()
87
+	{
88
+		EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
89
+	}
90
+
91
+
92
+	/**
93
+	 *    ajax get_transaction_details
94
+	 *
95
+	 * @throws \EE_Error
96
+	 */
97
+	public static function get_transaction_details()
98
+	{
99
+		EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
100
+	}
101
+
102
+
103
+	/**
104
+	 * bypass_recaptcha_for_load_payment_method
105
+	 *
106
+	 * @access public
107
+	 * @return array
108
+	 * @throws InvalidArgumentException
109
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
110
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
111
+	 */
112
+	public static function bypass_recaptcha_for_load_payment_method()
113
+	{
114
+		return array(
115
+			'EESID'  => EE_Registry::instance()->SSN->id(),
116
+			'step'   => 'payment_options',
117
+			'action' => 'spco_billing_form',
118
+		);
119
+	}
120
+
121
+
122
+	/**
123
+	 *    class constructor
124
+	 *
125
+	 * @access    public
126
+	 * @param    EE_Checkout $checkout
127
+	 */
128
+	public function __construct(EE_Checkout $checkout)
129
+	{
130
+		$this->_slug = 'payment_options';
131
+		$this->_name = esc_html__('Payment Options', 'event_espresso');
132
+		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/payment_options_main.template.php';
133
+		$this->checkout = $checkout;
134
+		$this->_reset_success_message();
135
+		$this->set_instructions(
136
+			esc_html__(
137
+				'Please select a method of payment and provide any necessary billing information before proceeding.',
138
+				'event_espresso'
139
+			)
140
+		);
141
+	}
142
+
143
+
144
+	/**
145
+	 * @return null
146
+	 */
147
+	public function line_item_display()
148
+	{
149
+		return $this->line_item_display;
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param null $line_item_display
155
+	 */
156
+	public function set_line_item_display($line_item_display)
157
+	{
158
+		$this->line_item_display = $line_item_display;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @return boolean
164
+	 */
165
+	public function handle_IPN_in_this_request()
166
+	{
167
+		return $this->handle_IPN_in_this_request;
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param boolean $handle_IPN_in_this_request
173
+	 */
174
+	public function set_handle_IPN_in_this_request($handle_IPN_in_this_request)
175
+	{
176
+		$this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN);
177
+	}
178
+
179
+
180
+	/**
181
+	 * translate_js_strings
182
+	 *
183
+	 * @return void
184
+	 */
185
+	public function translate_js_strings()
186
+	{
187
+		EE_Registry::$i18n_js_strings['no_payment_method'] = esc_html__(
188
+			'Please select a method of payment in order to continue.',
189
+			'event_espresso'
190
+		);
191
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
192
+			'A valid method of payment could not be determined. Please refresh the page and try again.',
193
+			'event_espresso'
194
+		);
195
+		EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = esc_html__(
196
+			'Forwarding to Secure Payment Provider.',
197
+			'event_espresso'
198
+		);
199
+	}
200
+
201
+
202
+	/**
203
+	 * enqueue_styles_and_scripts
204
+	 *
205
+	 * @return void
206
+	 * @throws EE_Error
207
+	 * @throws InvalidArgumentException
208
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
209
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
210
+	 */
211
+	public function enqueue_styles_and_scripts()
212
+	{
213
+		$transaction = $this->checkout->transaction;
214
+		// if the transaction isn't set or nothing is owed on it, don't enqueue any JS
215
+		if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
216
+			return;
217
+		}
218
+		foreach (EEM_Payment_Method::instance()->get_all_for_transaction(
219
+			$transaction,
220
+			EEM_Payment_Method::scope_cart
221
+		) as $payment_method) {
222
+			$type_obj = $payment_method->type_obj();
223
+			if ($type_obj instanceof EE_PMT_Base) {
224
+				$billing_form = $type_obj->generate_new_billing_form($transaction);
225
+				if ($billing_form instanceof EE_Form_Section_Proper) {
226
+					$billing_form->enqueue_js();
227
+				}
228
+			}
229
+		}
230
+	}
231
+
232
+
233
+	/**
234
+	 * initialize_reg_step
235
+	 *
236
+	 * @return bool
237
+	 * @throws EE_Error
238
+	 * @throws InvalidArgumentException
239
+	 * @throws ReflectionException
240
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
241
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
242
+	 */
243
+	public function initialize_reg_step()
244
+	{
245
+		// TODO: if /when we implement donations, then this will need overriding
246
+		if (// don't need payment options for:
247
+			// registrations made via the admin
248
+			// completed transactions
249
+			// overpaid transactions
250
+			// $ 0.00 transactions(no payment required)
251
+			! $this->checkout->payment_required()
252
+			// but do NOT remove if current action being called belongs to this reg step
253
+			&& ! is_callable(array($this, $this->checkout->action))
254
+			&& ! $this->completed()
255
+		) {
256
+			// and if so, then we no longer need the Payment Options step
257
+			if ($this->is_current_step()) {
258
+				$this->checkout->generate_reg_form = false;
259
+			}
260
+			$this->checkout->remove_reg_step($this->_slug);
261
+			// DEBUG LOG
262
+			// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
263
+			return false;
264
+		}
265
+		// load EEM_Payment_Method
266
+		EE_Registry::instance()->load_model('Payment_Method');
267
+		// get all active payment methods
268
+		$this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
269
+			$this->checkout->transaction,
270
+			EEM_Payment_Method::scope_cart
271
+		);
272
+		return true;
273
+	}
274
+
275
+
276
+	/**
277
+	 * @return EE_Form_Section_Proper
278
+	 * @throws EE_Error
279
+	 * @throws InvalidArgumentException
280
+	 * @throws ReflectionException
281
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
282
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
283
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
284
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
285
+	 */
286
+	public function generate_reg_form()
287
+	{
288
+		// reset in case someone changes their mind
289
+		$this->_reset_selected_method_of_payment();
290
+		// set some defaults
291
+		$this->checkout->selected_method_of_payment = 'payments_closed';
292
+		$registrations_requiring_payment = array();
293
+		$registrations_for_free_events = array();
294
+		$registrations_requiring_pre_approval = array();
295
+		$sold_out_events = array();
296
+		$insufficient_spaces_available = array();
297
+		$no_payment_required = true;
298
+		// loop thru registrations to gather info
299
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
300
+		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
301
+			$registrations,
302
+			$this->checkout->revisit
303
+		);
304
+		foreach ($registrations as $REG_ID => $registration) {
305
+			/** @var $registration EE_Registration */
306
+			// has this registration lost it's space ?
307
+			if (isset($ejected_registrations[ $REG_ID ])) {
308
+				if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
309
+					$sold_out_events[ $registration->event()->ID() ] = $registration->event();
310
+				} else {
311
+					$insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
312
+				}
313
+				continue;
314
+			}
315
+			// event requires admin approval
316
+			if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
317
+				// add event to list of events with pre-approval reg status
318
+				$registrations_requiring_pre_approval[ $REG_ID ] = $registration;
319
+				do_action(
320
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
321
+					$registration->event(),
322
+					$this
323
+				);
324
+				continue;
325
+			}
326
+			if ($this->checkout->revisit
327
+				&& $registration->status_ID() !== EEM_Registration::status_id_approved
328
+				&& (
329
+					$registration->event()->is_sold_out()
330
+					|| $registration->event()->is_sold_out(true)
331
+				)
332
+			) {
333
+				// add event to list of events that are sold out
334
+				$sold_out_events[ $registration->event()->ID() ] = $registration->event();
335
+				do_action(
336
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
337
+					$registration->event(),
338
+					$this
339
+				);
340
+				continue;
341
+			}
342
+			// are they allowed to pay now and is there monies owing?
343
+			if ($registration->owes_monies_and_can_pay()) {
344
+				$registrations_requiring_payment[ $REG_ID ] = $registration;
345
+				do_action(
346
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
347
+					$registration->event(),
348
+					$this
349
+				);
350
+			} elseif (! $this->checkout->revisit
351
+					  && $registration->status_ID() !== EEM_Registration::status_id_not_approved
352
+					  && $registration->ticket()->is_free()
353
+			) {
354
+				$registrations_for_free_events[ $registration->ticket()->ID() ] = $registration;
355
+			}
356
+		}
357
+		$subsections = array();
358
+		// now decide which template to load
359
+		if (! empty($sold_out_events)) {
360
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
361
+		}
362
+		if (! empty($insufficient_spaces_available)) {
363
+			$subsections['insufficient_space'] = $this->_insufficient_spaces_available(
364
+				$insufficient_spaces_available
365
+			);
366
+		}
367
+		if (! empty($registrations_requiring_pre_approval)) {
368
+			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
369
+				$registrations_requiring_pre_approval
370
+			);
371
+		}
372
+		if (! empty($registrations_for_free_events)) {
373
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
374
+		}
375
+		if (! empty($registrations_requiring_payment)) {
376
+			if ($this->checkout->amount_owing > 0) {
377
+				// autoload Line_Item_Display classes
378
+				EEH_Autoloader::register_line_item_filter_autoloaders();
379
+				$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
380
+					apply_filters(
381
+						'FHEE__SPCO__EE_Line_Item_Filter_Collection',
382
+						new EE_Line_Item_Filter_Collection()
383
+					),
384
+					$this->checkout->cart->get_grand_total()
385
+				);
386
+				/** @var EE_Line_Item $filtered_line_item_tree */
387
+				$filtered_line_item_tree = $line_item_filter_processor->process();
388
+				EEH_Autoloader::register_line_item_display_autoloaders();
389
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
390
+				$subsections['payment_options'] = $this->_display_payment_options(
391
+					$this->line_item_display->display_line_item(
392
+						$filtered_line_item_tree,
393
+						array('registrations' => $registrations)
394
+					)
395
+				);
396
+				$this->checkout->amount_owing = $filtered_line_item_tree->total();
397
+				$this->_apply_registration_payments_to_amount_owing($registrations);
398
+			}
399
+			$no_payment_required = false;
400
+		} else {
401
+			$this->_hide_reg_step_submit_button_if_revisit();
402
+		}
403
+		$this->_save_selected_method_of_payment();
404
+
405
+		$subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs();
406
+		$subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required);
407
+
408
+		return new EE_Form_Section_Proper(
409
+			array(
410
+				'name'            => $this->reg_form_name(),
411
+				'html_id'         => $this->reg_form_name(),
412
+				'subsections'     => $subsections,
413
+				'layout_strategy' => new EE_No_Layout(),
414
+			)
415
+		);
416
+	}
417
+
418
+
419
+	/**
420
+	 * add line item filters required for this reg step
421
+	 * these filters are applied via this line in EE_SPCO_Reg_Step_Payment_Options::set_hooks():
422
+	 *        add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options',
423
+	 *        'add_spco_line_item_filters' ) ); so any code that wants to use the same set of filters during the
424
+	 *        payment options reg step, can apply these filters via the following: apply_filters(
425
+	 *        'FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection() ) or to an existing
426
+	 *        filter collection by passing that instead of instantiating a new collection
427
+	 *
428
+	 * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection
429
+	 * @return EE_Line_Item_Filter_Collection
430
+	 * @throws EE_Error
431
+	 * @throws InvalidArgumentException
432
+	 * @throws ReflectionException
433
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
434
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
435
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
436
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
437
+	 */
438
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection)
439
+	{
440
+		if (! EE_Registry::instance()->SSN instanceof EE_Session) {
441
+			return $line_item_filter_collection;
442
+		}
443
+		if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
444
+			return $line_item_filter_collection;
445
+		}
446
+		if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
447
+			return $line_item_filter_collection;
448
+		}
449
+		$line_item_filter_collection->add(
450
+			new EE_Billable_Line_Item_Filter(
451
+				EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations(
452
+					EE_Registry::instance()->SSN->checkout()->transaction->registrations(
453
+						EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
454
+					)
455
+				)
456
+			)
457
+		);
458
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
459
+		return $line_item_filter_collection;
460
+	}
461
+
462
+
463
+	/**
464
+	 * remove_ejected_registrations
465
+	 * if a registrant has lost their potential space at an event due to lack of payment,
466
+	 * then this method removes them from the list of registrations being paid for during this request
467
+	 *
468
+	 * @param \EE_Registration[] $registrations
469
+	 * @return EE_Registration[]
470
+	 * @throws EE_Error
471
+	 * @throws InvalidArgumentException
472
+	 * @throws ReflectionException
473
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
474
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
475
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
476
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
477
+	 */
478
+	public static function remove_ejected_registrations(array $registrations)
479
+	{
480
+		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
481
+			$registrations,
482
+			EE_Registry::instance()->SSN->checkout()->revisit
483
+		);
484
+		foreach ($registrations as $REG_ID => $registration) {
485
+			// has this registration lost it's space ?
486
+			if (isset($ejected_registrations[ $REG_ID ])) {
487
+				unset($registrations[ $REG_ID ]);
488
+				continue;
489
+			}
490
+		}
491
+		return $registrations;
492
+	}
493
+
494
+
495
+	/**
496
+	 * find_registrations_that_lost_their_space
497
+	 * If a registrant chooses an offline payment method like Invoice,
498
+	 * then no space is reserved for them at the event until they fully pay fo that site
499
+	 * (unless the event's default reg status is set to APPROVED)
500
+	 * if a registrant then later returns to pay, but the number of spaces available has been reduced due to sales,
501
+	 * then this method will determine which registrations have lost the ability to complete the reg process.
502
+	 *
503
+	 * @param \EE_Registration[] $registrations
504
+	 * @param bool               $revisit
505
+	 * @return array
506
+	 * @throws EE_Error
507
+	 * @throws InvalidArgumentException
508
+	 * @throws ReflectionException
509
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
510
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
511
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
512
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
513
+	 */
514
+	public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false)
515
+	{
516
+		// registrations per event
517
+		$event_reg_count = array();
518
+		// spaces left per event
519
+		$event_spaces_remaining = array();
520
+		// tickets left sorted by ID
521
+		$tickets_remaining = array();
522
+		// registrations that have lost their space
523
+		$ejected_registrations = array();
524
+		foreach ($registrations as $REG_ID => $registration) {
525
+			if ($registration->status_ID() === EEM_Registration::status_id_approved
526
+				|| apply_filters(
527
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment',
528
+					false,
529
+					$registration,
530
+					$revisit
531
+				)
532
+			) {
533
+				continue;
534
+			}
535
+			$EVT_ID = $registration->event_ID();
536
+			$ticket = $registration->ticket();
537
+			if (! isset($tickets_remaining[ $ticket->ID() ])) {
538
+				$tickets_remaining[ $ticket->ID() ] = $ticket->remaining();
539
+			}
540
+			if ($tickets_remaining[ $ticket->ID() ] > 0) {
541
+				if (! isset($event_reg_count[ $EVT_ID ])) {
542
+					$event_reg_count[ $EVT_ID ] = 0;
543
+				}
544
+				$event_reg_count[ $EVT_ID ]++;
545
+				if (! isset($event_spaces_remaining[ $EVT_ID ])) {
546
+					$event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale();
547
+				}
548
+			}
549
+			if ($revisit
550
+				&& ($tickets_remaining[ $ticket->ID() ] === 0
551
+					|| $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
552
+				)
553
+			) {
554
+				$ejected_registrations[ $REG_ID ] = $registration->event();
555
+				if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
556
+					/** @type EE_Registration_Processor $registration_processor */
557
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
558
+					// at this point, we should have enough details about the registrant to consider the registration
559
+					// NOT incomplete
560
+					$registration_processor->manually_update_registration_status(
561
+						$registration,
562
+						EEM_Registration::status_id_wait_list
563
+					);
564
+				}
565
+			}
566
+		}
567
+		return $ejected_registrations;
568
+	}
569
+
570
+
571
+	/**
572
+	 * _hide_reg_step_submit_button
573
+	 * removes the html for the reg step submit button
574
+	 * by replacing it with an empty string via filter callback
575
+	 *
576
+	 * @return void
577
+	 */
578
+	protected function _adjust_registration_status_if_event_old_sold()
579
+	{
580
+	}
581
+
582
+
583
+	/**
584
+	 * _hide_reg_step_submit_button
585
+	 * removes the html for the reg step submit button
586
+	 * by replacing it with an empty string via filter callback
587
+	 *
588
+	 * @return void
589
+	 */
590
+	protected function _hide_reg_step_submit_button_if_revisit()
591
+	{
592
+		if ($this->checkout->revisit) {
593
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
594
+		}
595
+	}
596
+
597
+
598
+	/**
599
+	 * sold_out_events
600
+	 * displays notices regarding events that have sold out since hte registrant first signed up
601
+	 *
602
+	 * @param \EE_Event[] $sold_out_events_array
603
+	 * @return \EE_Form_Section_Proper
604
+	 * @throws \EE_Error
605
+	 */
606
+	private function _sold_out_events($sold_out_events_array = array())
607
+	{
608
+		// set some defaults
609
+		$this->checkout->selected_method_of_payment = 'events_sold_out';
610
+		$sold_out_events = '';
611
+		foreach ($sold_out_events_array as $sold_out_event) {
612
+			$sold_out_events .= EEH_HTML::li(
613
+				EEH_HTML::span(
614
+					'  ' . $sold_out_event->name(),
615
+					'',
616
+					'dashicons dashicons-marker ee-icon-size-16 pink-text'
617
+				)
618
+			);
619
+		}
620
+		return new EE_Form_Section_Proper(
621
+			array(
622
+				'layout_strategy' => new EE_Template_Layout(
623
+					array(
624
+						'layout_template_file' => SPCO_REG_STEPS_PATH
625
+												  . $this->_slug
626
+												  . '/sold_out_events.template.php',
627
+						'template_args'        => apply_filters(
628
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
629
+							array(
630
+								'sold_out_events'     => $sold_out_events,
631
+								'sold_out_events_msg' => apply_filters(
632
+									'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
633
+									sprintf(
634
+										esc_html__(
635
+											'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s',
636
+											'event_espresso'
637
+										),
638
+										'<strong>',
639
+										'</strong>',
640
+										'<br />'
641
+									)
642
+								),
643
+							)
644
+						),
645
+					)
646
+				),
647
+			)
648
+		);
649
+	}
650
+
651
+
652
+	/**
653
+	 * _insufficient_spaces_available
654
+	 * displays notices regarding events that do not have enough remaining spaces
655
+	 * to satisfy the current number of registrations looking to pay
656
+	 *
657
+	 * @param \EE_Event[] $insufficient_spaces_events_array
658
+	 * @return \EE_Form_Section_Proper
659
+	 * @throws \EE_Error
660
+	 */
661
+	private function _insufficient_spaces_available($insufficient_spaces_events_array = array())
662
+	{
663
+		// set some defaults
664
+		$this->checkout->selected_method_of_payment = 'invoice';
665
+		$insufficient_space_events = '';
666
+		foreach ($insufficient_spaces_events_array as $event) {
667
+			if ($event instanceof EE_Event) {
668
+				$insufficient_space_events .= EEH_HTML::li(
669
+					EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
670
+				);
671
+			}
672
+		}
673
+		return new EE_Form_Section_Proper(
674
+			array(
675
+				'subsections'     => array(
676
+					'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
677
+					'extra_hidden_inputs'   => $this->_extra_hidden_inputs(),
678
+				),
679
+				'layout_strategy' => new EE_Template_Layout(
680
+					array(
681
+						'layout_template_file' => SPCO_REG_STEPS_PATH
682
+												  . $this->_slug
683
+												  . '/sold_out_events.template.php',
684
+						'template_args'        => apply_filters(
685
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args',
686
+							array(
687
+								'sold_out_events'     => $insufficient_space_events,
688
+								'sold_out_events_msg' => apply_filters(
689
+									'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__insufficient_space_msg',
690
+									esc_html__(
691
+										'It appears that the event you were about to make a payment for has sold additional tickets since you first registered, and there are no longer enough spaces left to accommodate your selections. You may continue to pay and secure the available space(s) remaining, or simply cancel if you no longer wish to purchase. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
692
+										'event_espresso'
693
+									)
694
+								),
695
+							)
696
+						),
697
+					)
698
+				),
699
+			)
700
+		);
701
+	}
702
+
703
+
704
+	/**
705
+	 * registrations_requiring_pre_approval
706
+	 *
707
+	 * @param array $registrations_requiring_pre_approval
708
+	 * @return EE_Form_Section_Proper
709
+	 * @throws EE_Error
710
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
711
+	 */
712
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array())
713
+	{
714
+		$events_requiring_pre_approval = array();
715
+		foreach ($registrations_requiring_pre_approval as $registration) {
716
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
717
+				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
718
+					EEH_HTML::span(
719
+						'',
720
+						'',
721
+						'dashicons dashicons-marker ee-icon-size-16 orange-text'
722
+					)
723
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
724
+				);
725
+			}
726
+		}
727
+		return new EE_Form_Section_Proper(
728
+			array(
729
+				'layout_strategy' => new EE_Template_Layout(
730
+					array(
731
+						'layout_template_file' => SPCO_REG_STEPS_PATH
732
+												  . $this->_slug
733
+												  . '/events_requiring_pre_approval.template.php', // layout_template
734
+						'template_args'        => apply_filters(
735
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
736
+							array(
737
+								'events_requiring_pre_approval'     => implode('', $events_requiring_pre_approval),
738
+								'events_requiring_pre_approval_msg' => apply_filters(
739
+									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
740
+									esc_html__(
741
+										'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
742
+										'event_espresso'
743
+									)
744
+								),
745
+							)
746
+						),
747
+					)
748
+				),
749
+			)
750
+		);
751
+	}
752
+
753
+
754
+	/**
755
+	 * _no_payment_required
756
+	 *
757
+	 * @param \EE_Event[] $registrations_for_free_events
758
+	 * @return \EE_Form_Section_Proper
759
+	 * @throws \EE_Error
760
+	 */
761
+	private function _no_payment_required($registrations_for_free_events = array())
762
+	{
763
+		// set some defaults
764
+		$this->checkout->selected_method_of_payment = 'no_payment_required';
765
+		// generate no_payment_required form
766
+		return new EE_Form_Section_Proper(
767
+			array(
768
+				'layout_strategy' => new EE_Template_Layout(
769
+					array(
770
+						'layout_template_file' => SPCO_REG_STEPS_PATH
771
+												  . $this->_slug
772
+												  . '/no_payment_required.template.php', // layout_template
773
+						'template_args'        => apply_filters(
774
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
775
+							array(
776
+								'revisit'                       => $this->checkout->revisit,
777
+								'registrations'                 => array(),
778
+								'ticket_count'                  => array(),
779
+								'registrations_for_free_events' => $registrations_for_free_events,
780
+								'no_payment_required_msg'       => EEH_HTML::p(
781
+									esc_html__('This is a free event, so no billing will occur.', 'event_espresso')
782
+								),
783
+							)
784
+						),
785
+					)
786
+				),
787
+			)
788
+		);
789
+	}
790
+
791
+
792
+	/**
793
+	 * _display_payment_options
794
+	 *
795
+	 * @param string $transaction_details
796
+	 * @return EE_Form_Section_Proper
797
+	 * @throws EE_Error
798
+	 * @throws InvalidArgumentException
799
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
800
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
801
+	 */
802
+	private function _display_payment_options($transaction_details = '')
803
+	{
804
+		// has method_of_payment been set by no-js user?
805
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
806
+		// build payment options form
807
+		return apply_filters(
808
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__payment_options_form',
809
+			new EE_Form_Section_Proper(
810
+				array(
811
+					'subsections'     => array(
812
+						'before_payment_options' => apply_filters(
813
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
814
+							new EE_Form_Section_Proper(
815
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
816
+							)
817
+						),
818
+						'payment_options'        => $this->_setup_payment_options(),
819
+						'after_payment_options'  => apply_filters(
820
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
821
+							new EE_Form_Section_Proper(
822
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
823
+							)
824
+						),
825
+					),
826
+					'layout_strategy' => new EE_Template_Layout(
827
+						array(
828
+							'layout_template_file' => $this->_template,
829
+							'template_args'        => apply_filters(
830
+								'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args',
831
+								array(
832
+									'reg_count'                 => $this->line_item_display->total_items(),
833
+									'transaction_details'       => $transaction_details,
834
+									'available_payment_methods' => array(),
835
+								)
836
+							),
837
+						)
838
+					),
839
+				)
840
+			)
841
+		);
842
+	}
843
+
844
+
845
+	/**
846
+	 * _extra_hidden_inputs
847
+	 *
848
+	 * @param bool $no_payment_required
849
+	 * @return \EE_Form_Section_Proper
850
+	 * @throws \EE_Error
851
+	 */
852
+	private function _extra_hidden_inputs($no_payment_required = true)
853
+	{
854
+		return new EE_Form_Section_Proper(
855
+			array(
856
+				'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
857
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
858
+				'subsections'     => array(
859
+					'spco_no_payment_required' => new EE_Hidden_Input(
860
+						array(
861
+							'normalization_strategy' => new EE_Boolean_Normalization(),
862
+							'html_name'              => 'spco_no_payment_required',
863
+							'html_id'                => 'spco-no-payment-required-payment_options',
864
+							'default'                => $no_payment_required,
865
+						)
866
+					),
867
+					'spco_transaction_id'      => new EE_Fixed_Hidden_Input(
868
+						array(
869
+							'normalization_strategy' => new EE_Int_Normalization(),
870
+							'html_name'              => 'spco_transaction_id',
871
+							'html_id'                => 'spco-transaction-id',
872
+							'default'                => $this->checkout->transaction->ID(),
873
+						)
874
+					),
875
+				),
876
+			)
877
+		);
878
+	}
879
+
880
+
881
+	/**
882
+	 *    _apply_registration_payments_to_amount_owing
883
+	 *
884
+	 * @access protected
885
+	 * @param array $registrations
886
+	 * @throws EE_Error
887
+	 */
888
+	protected function _apply_registration_payments_to_amount_owing(array $registrations)
889
+	{
890
+		$payments = array();
891
+		foreach ($registrations as $registration) {
892
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
893
+				$payments += $registration->registration_payments();
894
+			}
895
+		}
896
+		if (! empty($payments)) {
897
+			foreach ($payments as $payment) {
898
+				if ($payment instanceof EE_Registration_Payment) {
899
+					$this->checkout->amount_owing -= $payment->amount();
900
+				}
901
+			}
902
+		}
903
+	}
904
+
905
+
906
+	/**
907
+	 *    _reset_selected_method_of_payment
908
+	 *
909
+	 * @access    private
910
+	 * @param    bool $force_reset
911
+	 * @return void
912
+	 * @throws InvalidArgumentException
913
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
914
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
915
+	 */
916
+	private function _reset_selected_method_of_payment($force_reset = false)
917
+	{
918
+		$reset_payment_method = $force_reset
919
+			? true
920
+			: sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false));
921
+		if ($reset_payment_method) {
922
+			$this->checkout->selected_method_of_payment = null;
923
+			$this->checkout->payment_method = null;
924
+			$this->checkout->billing_form = null;
925
+			$this->_save_selected_method_of_payment();
926
+		}
927
+	}
928
+
929
+
930
+	/**
931
+	 * _save_selected_method_of_payment
932
+	 * stores the selected_method_of_payment in the session
933
+	 * so that it's available for all subsequent requests including AJAX
934
+	 *
935
+	 * @access        private
936
+	 * @param string $selected_method_of_payment
937
+	 * @return void
938
+	 * @throws InvalidArgumentException
939
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
940
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
941
+	 */
942
+	private function _save_selected_method_of_payment($selected_method_of_payment = '')
943
+	{
944
+		$selected_method_of_payment = ! empty($selected_method_of_payment)
945
+			? $selected_method_of_payment
946
+			: $this->checkout->selected_method_of_payment;
947
+		EE_Registry::instance()->SSN->set_session_data(
948
+			array('selected_method_of_payment' => $selected_method_of_payment)
949
+		);
950
+	}
951
+
952
+
953
+	/**
954
+	 * _setup_payment_options
955
+	 *
956
+	 * @return EE_Form_Section_Proper
957
+	 * @throws EE_Error
958
+	 * @throws InvalidArgumentException
959
+	 * @throws ReflectionException
960
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
961
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
962
+	 */
963
+	public function _setup_payment_options()
964
+	{
965
+		// load payment method classes
966
+		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
967
+		if (empty($this->checkout->available_payment_methods)) {
968
+			EE_Error::add_error(
969
+				apply_filters(
970
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__error_message_no_payment_methods',
971
+					sprintf(
972
+						esc_html__(
973
+							'Sorry, you cannot complete your purchase because a payment method is not active.%1$s Please contact %2$s for assistance and provide a description of the problem.',
974
+							'event_espresso'
975
+						),
976
+						'<br>',
977
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
978
+					)
979
+				),
980
+				__FILE__,
981
+				__FUNCTION__,
982
+				__LINE__
983
+			);
984
+		}
985
+		// switch up header depending on number of available payment methods
986
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
987
+			? apply_filters(
988
+				'FHEE__registration_page_payment_options__method_of_payment_hdr',
989
+				esc_html__('Please Select Your Method of Payment', 'event_espresso')
990
+			)
991
+			: apply_filters(
992
+				'FHEE__registration_page_payment_options__method_of_payment_hdr',
993
+				esc_html__('Method of Payment', 'event_espresso')
994
+			);
995
+		$available_payment_methods = array(
996
+			// display the "Payment Method" header
997
+			'payment_method_header' => new EE_Form_Section_HTML(
998
+				apply_filters(
999
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__payment_method_header',
1000
+					EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr'),
1001
+					$payment_method_header
1002
+				)
1003
+			),
1004
+		);
1005
+		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
1006
+		$available_payment_method_options = array();
1007
+		$default_payment_method_option = array();
1008
+		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
1009
+		$payment_methods_billing_info = array(
1010
+			new EE_Form_Section_HTML(
1011
+				EEH_HTML::div('<br />', '', '', 'clear:both;')
1012
+			),
1013
+		);
1014
+		// loop through payment methods
1015
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
1016
+			if ($payment_method instanceof EE_Payment_Method) {
1017
+				$payment_method_button = EEH_HTML::img(
1018
+					$payment_method->button_url(),
1019
+					$payment_method->name(),
1020
+					'spco-payment-method-' . $payment_method->slug() . '-btn-img',
1021
+					'spco-payment-method-btn-img'
1022
+				);
1023
+				// check if any payment methods are set as default
1024
+				// if payment method is already selected OR nothing is selected and this payment method should be
1025
+				// open_by_default
1026
+				if (($this->checkout->selected_method_of_payment === $payment_method->slug())
1027
+					|| (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1028
+				) {
1029
+					$this->checkout->selected_method_of_payment = $payment_method->slug();
1030
+					$this->_save_selected_method_of_payment();
1031
+					$default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
1032
+				} else {
1033
+					$available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
1034
+				}
1035
+				$payment_methods_billing_info[ $payment_method->slug(
1036
+				) . '-info' ] = $this->_payment_method_billing_info(
1037
+					$payment_method
1038
+				);
1039
+			}
1040
+		}
1041
+		// prepend available_payment_method_options with default_payment_method_option so that it appears first in list
1042
+		// of PMs
1043
+		$available_payment_method_options = $default_payment_method_option + $available_payment_method_options;
1044
+		// now generate the actual form  inputs
1045
+		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs(
1046
+			$available_payment_method_options
1047
+		);
1048
+		$available_payment_methods += $payment_methods_billing_info;
1049
+		// build the available payment methods form
1050
+		return new EE_Form_Section_Proper(
1051
+			array(
1052
+				'html_id'         => 'spco-available-methods-of-payment-dv',
1053
+				'subsections'     => $available_payment_methods,
1054
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1055
+			)
1056
+		);
1057
+	}
1058
+
1059
+
1060
+	/**
1061
+	 * _get_available_payment_methods
1062
+	 *
1063
+	 * @return EE_Payment_Method[]
1064
+	 * @throws EE_Error
1065
+	 * @throws InvalidArgumentException
1066
+	 * @throws ReflectionException
1067
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1068
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1069
+	 */
1070
+	protected function _get_available_payment_methods()
1071
+	{
1072
+		if (! empty($this->checkout->available_payment_methods)) {
1073
+			return $this->checkout->available_payment_methods;
1074
+		}
1075
+		$available_payment_methods = array();
1076
+		// load EEM_Payment_Method
1077
+		EE_Registry::instance()->load_model('Payment_Method');
1078
+		/** @type EEM_Payment_Method $EEM_Payment_Method */
1079
+		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1080
+		// get all active payment methods
1081
+		$payment_methods = $EEM_Payment_Method->get_all_for_transaction(
1082
+			$this->checkout->transaction,
1083
+			EEM_Payment_Method::scope_cart
1084
+		);
1085
+		foreach ($payment_methods as $payment_method) {
1086
+			if ($payment_method instanceof EE_Payment_Method) {
1087
+				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
1088
+			}
1089
+		}
1090
+		return $available_payment_methods;
1091
+	}
1092
+
1093
+
1094
+	/**
1095
+	 *    _available_payment_method_inputs
1096
+	 *
1097
+	 * @access    private
1098
+	 * @param    array $available_payment_method_options
1099
+	 * @return    \EE_Form_Section_Proper
1100
+	 */
1101
+	private function _available_payment_method_inputs($available_payment_method_options = array())
1102
+	{
1103
+		// generate inputs
1104
+		return new EE_Form_Section_Proper(
1105
+			array(
1106
+				'html_id'         => 'ee-available-payment-method-inputs',
1107
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1108
+				'subsections'     => array(
1109
+					'' => new EE_Radio_Button_Input(
1110
+						$available_payment_method_options,
1111
+						array(
1112
+							'html_name'          => 'selected_method_of_payment',
1113
+							'html_class'         => 'spco-payment-method',
1114
+							'default'            => $this->checkout->selected_method_of_payment,
1115
+							'label_size'         => 11,
1116
+							'enforce_label_size' => true,
1117
+						)
1118
+					),
1119
+				),
1120
+			)
1121
+		);
1122
+	}
1123
+
1124
+
1125
+	/**
1126
+	 *    _payment_method_billing_info
1127
+	 *
1128
+	 * @access    private
1129
+	 * @param    EE_Payment_Method $payment_method
1130
+	 * @return EE_Form_Section_Proper
1131
+	 * @throws EE_Error
1132
+	 * @throws InvalidArgumentException
1133
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1134
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1135
+	 */
1136
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method)
1137
+	{
1138
+		$currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug()
1139
+			? true
1140
+			: false;
1141
+		// generate the billing form for payment method
1142
+		$billing_form = $currently_selected
1143
+			? $this->_get_billing_form_for_payment_method($payment_method)
1144
+			: new EE_Form_Section_HTML();
1145
+		$this->checkout->billing_form = $currently_selected
1146
+			? $billing_form
1147
+			: $this->checkout->billing_form;
1148
+		// it's all in the details
1149
+		$info_html = EEH_HTML::h3(
1150
+			esc_html__('Important information regarding your payment', 'event_espresso'),
1151
+			'',
1152
+			'spco-payment-method-hdr'
1153
+		);
1154
+		// add some info regarding the step, either from what's saved in the admin,
1155
+		// or a default string depending on whether the PM has a billing form or not
1156
+		if ($payment_method->description()) {
1157
+			$payment_method_info = $payment_method->description();
1158
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
1159
+			$payment_method_info = sprintf(
1160
+				esc_html__(
1161
+					'Please provide the following billing information, then click the "%1$s" button below in order to proceed.',
1162
+					'event_espresso'
1163
+				),
1164
+				$this->submit_button_text()
1165
+			);
1166
+		} else {
1167
+			$payment_method_info = sprintf(
1168
+				esc_html__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'),
1169
+				$this->submit_button_text()
1170
+			);
1171
+		}
1172
+		$info_html .= EEH_HTML::div(
1173
+			apply_filters(
1174
+				'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info',
1175
+				$payment_method_info
1176
+			),
1177
+			'',
1178
+			'spco-payment-method-desc ee-attention'
1179
+		);
1180
+		return new EE_Form_Section_Proper(
1181
+			array(
1182
+				'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1183
+				'html_class'      => 'spco-payment-method-info-dv',
1184
+				// only display the selected or default PM
1185
+				'html_style'      => $currently_selected ? '' : 'display:none;',
1186
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1187
+				'subsections'     => array(
1188
+					'info'         => new EE_Form_Section_HTML($info_html),
1189
+					'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML(),
1190
+				),
1191
+			)
1192
+		);
1193
+	}
1194
+
1195
+
1196
+	/**
1197
+	 * get_billing_form_html_for_payment_method
1198
+	 *
1199
+	 * @access public
1200
+	 * @return string
1201
+	 * @throws EE_Error
1202
+	 * @throws InvalidArgumentException
1203
+	 * @throws ReflectionException
1204
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1205
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1206
+	 */
1207
+	public function get_billing_form_html_for_payment_method()
1208
+	{
1209
+		// how have they chosen to pay?
1210
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1211
+		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1212
+		if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1213
+			return false;
1214
+		}
1215
+		if (apply_filters(
1216
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1217
+			false
1218
+		)) {
1219
+			EE_Error::add_success(
1220
+				apply_filters(
1221
+					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1222
+					sprintf(
1223
+						esc_html__(
1224
+							'You have selected "%s" as your method of payment. Please note the important payment information below.',
1225
+							'event_espresso'
1226
+						),
1227
+						$this->checkout->payment_method->name()
1228
+					)
1229
+				)
1230
+			);
1231
+		}
1232
+		// now generate billing form for selected method of payment
1233
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1234
+		// fill form with attendee info if applicable
1235
+		if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
1236
+			&& $this->checkout->transaction_has_primary_registrant()
1237
+		) {
1238
+			$payment_method_billing_form->populate_from_attendee(
1239
+				$this->checkout->transaction->primary_registration()->attendee()
1240
+			);
1241
+		}
1242
+		// and debug content
1243
+		if ($payment_method_billing_form instanceof EE_Billing_Info_Form
1244
+			&& $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1245
+		) {
1246
+			$payment_method_billing_form =
1247
+				$this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1248
+					$payment_method_billing_form
1249
+				);
1250
+		}
1251
+		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper
1252
+			? $payment_method_billing_form->get_html()
1253
+			: '';
1254
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
1255
+		// localize validation rules for main form
1256
+		$this->checkout->current_step->reg_form->localize_validation_rules();
1257
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1258
+		return true;
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 * _get_billing_form_for_payment_method
1264
+	 *
1265
+	 * @access private
1266
+	 * @param EE_Payment_Method $payment_method
1267
+	 * @return EE_Billing_Info_Form|EE_Form_Section_HTML
1268
+	 * @throws EE_Error
1269
+	 * @throws InvalidArgumentException
1270
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1271
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1272
+	 */
1273
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method)
1274
+	{
1275
+		$billing_form = $payment_method->type_obj()->billing_form(
1276
+			$this->checkout->transaction,
1277
+			array('amount_owing' => $this->checkout->amount_owing)
1278
+		);
1279
+		if ($billing_form instanceof EE_Billing_Info_Form) {
1280
+			if (apply_filters(
1281
+				'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1282
+				false
1283
+			)
1284
+				&& EE_Registry::instance()->REQ->is_set('payment_method')
1285
+			) {
1286
+				EE_Error::add_success(
1287
+					apply_filters(
1288
+						'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1289
+						sprintf(
1290
+							esc_html__(
1291
+								'You have selected "%s" as your method of payment. Please note the important payment information below.',
1292
+								'event_espresso'
1293
+							),
1294
+							$payment_method->name()
1295
+						)
1296
+					)
1297
+				);
1298
+			}
1299
+			return apply_filters(
1300
+				'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
1301
+				$billing_form,
1302
+				$payment_method
1303
+			);
1304
+		}
1305
+		// no actual billing form, so return empty HTML form section
1306
+		return new EE_Form_Section_HTML();
1307
+	}
1308
+
1309
+
1310
+	/**
1311
+	 * _get_selected_method_of_payment
1312
+	 *
1313
+	 * @access private
1314
+	 * @param boolean $required whether to throw an error if the "selected_method_of_payment"
1315
+	 *                          is not found in the incoming request
1316
+	 * @param string  $request_param
1317
+	 * @return NULL|string
1318
+	 * @throws EE_Error
1319
+	 * @throws InvalidArgumentException
1320
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1321
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1322
+	 */
1323
+	private function _get_selected_method_of_payment(
1324
+		$required = false,
1325
+		$request_param = 'selected_method_of_payment'
1326
+	) {
1327
+		// is selected_method_of_payment set in the request ?
1328
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false);
1329
+		if ($selected_method_of_payment) {
1330
+			// sanitize it
1331
+			$selected_method_of_payment = is_array($selected_method_of_payment)
1332
+				? array_shift($selected_method_of_payment)
1333
+				: $selected_method_of_payment;
1334
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
1335
+			// store it in the session so that it's available for all subsequent requests including AJAX
1336
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
1337
+		} else {
1338
+			// or is is set in the session ?
1339
+			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data(
1340
+				'selected_method_of_payment'
1341
+			);
1342
+		}
1343
+		// do ya really really gotta have it?
1344
+		if (empty($selected_method_of_payment) && $required) {
1345
+			EE_Error::add_error(
1346
+				sprintf(
1347
+					esc_html__(
1348
+						'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.',
1349
+						'event_espresso'
1350
+					),
1351
+					'<br/>',
1352
+					'<br/>',
1353
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1354
+				),
1355
+				__FILE__,
1356
+				__FUNCTION__,
1357
+				__LINE__
1358
+			);
1359
+			return null;
1360
+		}
1361
+		return $selected_method_of_payment;
1362
+	}
1363
+
1364
+
1365
+
1366
+
1367
+
1368
+
1369
+	/********************************************************************************************************/
1370
+	/***********************************  SWITCH PAYMENT METHOD  ************************************/
1371
+	/********************************************************************************************************/
1372
+	/**
1373
+	 * switch_payment_method
1374
+	 *
1375
+	 * @access public
1376
+	 * @return string
1377
+	 * @throws EE_Error
1378
+	 * @throws InvalidArgumentException
1379
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1380
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1381
+	 */
1382
+	public function switch_payment_method()
1383
+	{
1384
+		if (! $this->_verify_payment_method_is_set()) {
1385
+			return false;
1386
+		}
1387
+		if (apply_filters(
1388
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1389
+			false
1390
+		)) {
1391
+			EE_Error::add_success(
1392
+				apply_filters(
1393
+					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1394
+					sprintf(
1395
+						esc_html__(
1396
+							'You have selected "%s" as your method of payment. Please note the important payment information below.',
1397
+							'event_espresso'
1398
+						),
1399
+						$this->checkout->payment_method->name()
1400
+					)
1401
+				)
1402
+			);
1403
+		}
1404
+		// generate billing form for selected method of payment if it hasn't been done already
1405
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1406
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1407
+				$this->checkout->payment_method
1408
+			);
1409
+		}
1410
+		// fill form with attendee info if applicable
1411
+		if (apply_filters(
1412
+			'FHEE__populate_billing_form_fields_from_attendee',
1413
+			(
1414
+				$this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
1415
+				&& $this->checkout->transaction_has_primary_registrant()
1416
+			),
1417
+			$this->checkout->billing_form,
1418
+			$this->checkout->transaction
1419
+		)
1420
+		) {
1421
+			$this->checkout->billing_form->populate_from_attendee(
1422
+				$this->checkout->transaction->primary_registration()->attendee()
1423
+			);
1424
+		}
1425
+		// and debug content
1426
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form
1427
+			&& $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1428
+		) {
1429
+			$this->checkout->billing_form =
1430
+				$this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1431
+					$this->checkout->billing_form
1432
+				);
1433
+		}
1434
+		// get html and validation rules for form
1435
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
1436
+			$this->checkout->json_response->set_return_data(
1437
+				array('payment_method_info' => $this->checkout->billing_form->get_html())
1438
+			);
1439
+			// localize validation rules for main form
1440
+			$this->checkout->billing_form->localize_validation_rules(true);
1441
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1442
+		} else {
1443
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
1444
+		}
1445
+		// prevents advancement to next step
1446
+		$this->checkout->continue_reg = false;
1447
+		return true;
1448
+	}
1449
+
1450
+
1451
+	/**
1452
+	 * _verify_payment_method_is_set
1453
+	 *
1454
+	 * @return bool
1455
+	 * @throws EE_Error
1456
+	 * @throws InvalidArgumentException
1457
+	 * @throws ReflectionException
1458
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1459
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1460
+	 */
1461
+	protected function _verify_payment_method_is_set()
1462
+	{
1463
+		// generate billing form for selected method of payment if it hasn't been done already
1464
+		if (empty($this->checkout->selected_method_of_payment)) {
1465
+			// how have they chosen to pay?
1466
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1467
+		} else {
1468
+			// choose your own adventure based on method_of_payment
1469
+			switch ($this->checkout->selected_method_of_payment) {
1470
+				case 'events_sold_out':
1471
+					EE_Error::add_attention(
1472
+						apply_filters(
1473
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg',
1474
+							esc_html__(
1475
+								'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
1476
+								'event_espresso'
1477
+							)
1478
+						),
1479
+						__FILE__,
1480
+						__FUNCTION__,
1481
+						__LINE__
1482
+					);
1483
+					return false;
1484
+					break;
1485
+				case 'payments_closed':
1486
+					EE_Error::add_attention(
1487
+						apply_filters(
1488
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg',
1489
+							esc_html__(
1490
+								'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.',
1491
+								'event_espresso'
1492
+							)
1493
+						),
1494
+						__FILE__,
1495
+						__FUNCTION__,
1496
+						__LINE__
1497
+					);
1498
+					return false;
1499
+					break;
1500
+				case 'no_payment_required':
1501
+					EE_Error::add_attention(
1502
+						apply_filters(
1503
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg',
1504
+							esc_html__(
1505
+								'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.',
1506
+								'event_espresso'
1507
+							)
1508
+						),
1509
+						__FILE__,
1510
+						__FUNCTION__,
1511
+						__LINE__
1512
+					);
1513
+					return false;
1514
+					break;
1515
+				default:
1516
+			}
1517
+		}
1518
+		// verify payment method
1519
+		if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1520
+			// get payment method for selected method of payment
1521
+			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1522
+		}
1523
+		return $this->checkout->payment_method instanceof EE_Payment_Method ? true : false;
1524
+	}
1525
+
1526
+
1527
+
1528
+	/********************************************************************************************************/
1529
+	/***************************************  SAVE PAYER DETAILS  ****************************************/
1530
+	/********************************************************************************************************/
1531
+	/**
1532
+	 * save_payer_details_via_ajax
1533
+	 *
1534
+	 * @return void
1535
+	 * @throws EE_Error
1536
+	 * @throws InvalidArgumentException
1537
+	 * @throws ReflectionException
1538
+	 * @throws RuntimeException
1539
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1540
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1541
+	 */
1542
+	public function save_payer_details_via_ajax()
1543
+	{
1544
+		if (! $this->_verify_payment_method_is_set()) {
1545
+			return;
1546
+		}
1547
+		// generate billing form for selected method of payment if it hasn't been done already
1548
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1549
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1550
+				$this->checkout->payment_method
1551
+			);
1552
+		}
1553
+		// generate primary attendee from payer info if applicable
1554
+		if (! $this->checkout->transaction_has_primary_registrant()) {
1555
+			$attendee = $this->_create_attendee_from_request_data();
1556
+			if ($attendee instanceof EE_Attendee) {
1557
+				foreach ($this->checkout->transaction->registrations() as $registration) {
1558
+					if ($registration->is_primary_registrant()) {
1559
+						$this->checkout->primary_attendee_obj = $attendee;
1560
+						$registration->_add_relation_to($attendee, 'Attendee');
1561
+						$registration->set_attendee_id($attendee->ID());
1562
+						$registration->update_cache_after_object_save('Attendee', $attendee);
1563
+					}
1564
+				}
1565
+			}
1566
+		}
1567
+	}
1568
+
1569
+
1570
+	/**
1571
+	 * create_attendee_from_request_data
1572
+	 * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
1573
+	 *
1574
+	 * @return EE_Attendee
1575
+	 * @throws EE_Error
1576
+	 * @throws InvalidArgumentException
1577
+	 * @throws ReflectionException
1578
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1579
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1580
+	 */
1581
+	protected function _create_attendee_from_request_data()
1582
+	{
1583
+		// get State ID
1584
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1585
+		if (! empty($STA_ID)) {
1586
+			// can we get state object from name ?
1587
+			EE_Registry::instance()->load_model('State');
1588
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1589
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1590
+		}
1591
+		// get Country ISO
1592
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1593
+		if (! empty($CNT_ISO)) {
1594
+			// can we get country object from name ?
1595
+			EE_Registry::instance()->load_model('Country');
1596
+			$country = EEM_Country::instance()->get_col(
1597
+				array(array('CNT_name' => $CNT_ISO), 'limit' => 1),
1598
+				'CNT_ISO'
1599
+			);
1600
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1601
+		}
1602
+		// grab attendee data
1603
+		$attendee_data = array(
1604
+			'ATT_fname'    => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1605
+			'ATT_lname'    => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1606
+			'ATT_email'    => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1607
+			'ATT_address'  => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1608
+			'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1609
+			'ATT_city'     => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1610
+			'STA_ID'       => $STA_ID,
1611
+			'CNT_ISO'      => $CNT_ISO,
1612
+			'ATT_zip'      => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1613
+			'ATT_phone'    => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1614
+		);
1615
+		// validate the email address since it is the most important piece of info
1616
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) {
1617
+			EE_Error::add_error(
1618
+				esc_html__('An invalid email address was submitted.', 'event_espresso'),
1619
+				__FILE__,
1620
+				__FUNCTION__,
1621
+				__LINE__
1622
+			);
1623
+		}
1624
+		// does this attendee already exist in the db ? we're searching using a combination of first name, last name,
1625
+		// AND email address
1626
+		if (! empty($attendee_data['ATT_fname'])
1627
+			&& ! empty($attendee_data['ATT_lname'])
1628
+			&& ! empty($attendee_data['ATT_email'])
1629
+		) {
1630
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1631
+				array(
1632
+					'ATT_fname' => $attendee_data['ATT_fname'],
1633
+					'ATT_lname' => $attendee_data['ATT_lname'],
1634
+					'ATT_email' => $attendee_data['ATT_email'],
1635
+				)
1636
+			);
1637
+			if ($existing_attendee instanceof EE_Attendee) {
1638
+				return $existing_attendee;
1639
+			}
1640
+		}
1641
+		// no existing attendee? kk let's create a new one
1642
+		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those
1643
+		// don't exist
1644
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname'])
1645
+			? $attendee_data['ATT_fname']
1646
+			: $attendee_data['ATT_email'];
1647
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname'])
1648
+			? $attendee_data['ATT_lname']
1649
+			: $attendee_data['ATT_email'];
1650
+		return EE_Attendee::new_instance($attendee_data);
1651
+	}
1652
+
1653
+
1654
+
1655
+	/********************************************************************************************************/
1656
+	/****************************************  PROCESS REG STEP  *****************************************/
1657
+	/********************************************************************************************************/
1658
+	/**
1659
+	 * process_reg_step
1660
+	 *
1661
+	 * @return bool
1662
+	 * @throws EE_Error
1663
+	 * @throws InvalidArgumentException
1664
+	 * @throws ReflectionException
1665
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1666
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1667
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1668
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
1669
+	 */
1670
+	public function process_reg_step()
1671
+	{
1672
+		// how have they chosen to pay?
1673
+		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free()
1674
+			? 'no_payment_required'
1675
+			: $this->_get_selected_method_of_payment(true);
1676
+		// choose your own adventure based on method_of_payment
1677
+		switch ($this->checkout->selected_method_of_payment) {
1678
+			case 'events_sold_out':
1679
+				$this->checkout->redirect = true;
1680
+				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1681
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1682
+				// mark this reg step as completed
1683
+				$this->set_completed();
1684
+				return false;
1685
+				break;
1686
+
1687
+			case 'payments_closed':
1688
+				if (apply_filters(
1689
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success',
1690
+					false
1691
+				)) {
1692
+					EE_Error::add_success(
1693
+						esc_html__('no payment required at this time.', 'event_espresso'),
1694
+						__FILE__,
1695
+						__FUNCTION__,
1696
+						__LINE__
1697
+					);
1698
+				}
1699
+				// mark this reg step as completed
1700
+				$this->set_completed();
1701
+				return true;
1702
+				break;
1703
+
1704
+			case 'no_payment_required':
1705
+				if (apply_filters(
1706
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success',
1707
+					false
1708
+				)) {
1709
+					EE_Error::add_success(
1710
+						esc_html__('no payment required.', 'event_espresso'),
1711
+						__FILE__,
1712
+						__FUNCTION__,
1713
+						__LINE__
1714
+					);
1715
+				}
1716
+				// mark this reg step as completed
1717
+				$this->set_completed();
1718
+				return true;
1719
+				break;
1720
+
1721
+			default:
1722
+				$registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations(
1723
+					EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
1724
+				);
1725
+				$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
1726
+					$registrations,
1727
+					EE_Registry::instance()->SSN->checkout()->revisit
1728
+				);
1729
+				// calculate difference between the two arrays
1730
+				$registrations = array_diff($registrations, $ejected_registrations);
1731
+				if (empty($registrations)) {
1732
+					$this->_redirect_because_event_sold_out();
1733
+					return false;
1734
+				}
1735
+				$payment_successful = $this->_process_payment();
1736
+				if ($payment_successful) {
1737
+					$this->checkout->continue_reg = true;
1738
+					$this->_maybe_set_completed($this->checkout->payment_method);
1739
+				} else {
1740
+					$this->checkout->continue_reg = false;
1741
+				}
1742
+				return $payment_successful;
1743
+		}
1744
+	}
1745
+
1746
+
1747
+	/**
1748
+	 * _redirect_because_event_sold_out
1749
+	 *
1750
+	 * @access protected
1751
+	 * @return void
1752
+	 */
1753
+	protected function _redirect_because_event_sold_out()
1754
+	{
1755
+		$this->checkout->continue_reg = false;
1756
+		// set redirect URL
1757
+		$this->checkout->redirect_url = add_query_arg(
1758
+			array('e_reg_url_link' => $this->checkout->reg_url_link),
1759
+			$this->checkout->current_step->reg_step_url()
1760
+		);
1761
+		$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1762
+	}
1763
+
1764
+
1765
+	/**
1766
+	 * _maybe_set_completed
1767
+	 *
1768
+	 * @access protected
1769
+	 * @param \EE_Payment_Method $payment_method
1770
+	 * @return void
1771
+	 * @throws \EE_Error
1772
+	 */
1773
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method)
1774
+	{
1775
+		switch ($payment_method->type_obj()->payment_occurs()) {
1776
+			case EE_PMT_Base::offsite:
1777
+				break;
1778
+			case EE_PMT_Base::onsite:
1779
+			case EE_PMT_Base::offline:
1780
+				// mark this reg step as completed
1781
+				$this->set_completed();
1782
+				break;
1783
+		}
1784
+	}
1785
+
1786
+
1787
+	/**
1788
+	 *    update_reg_step
1789
+	 *    this is the final step after a user  revisits the site to retry a payment
1790
+	 *
1791
+	 * @return bool
1792
+	 * @throws EE_Error
1793
+	 * @throws InvalidArgumentException
1794
+	 * @throws ReflectionException
1795
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1796
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1797
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1798
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
1799
+	 */
1800
+	public function update_reg_step()
1801
+	{
1802
+		$success = true;
1803
+		// if payment required
1804
+		if ($this->checkout->transaction->total() > 0) {
1805
+			do_action(
1806
+				'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway',
1807
+				$this->checkout->transaction
1808
+			);
1809
+			// attempt payment via payment method
1810
+			$success = $this->process_reg_step();
1811
+		}
1812
+		if ($success && ! $this->checkout->redirect) {
1813
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
1814
+				$this->checkout->transaction->ID()
1815
+			);
1816
+			// set return URL
1817
+			$this->checkout->redirect_url = add_query_arg(
1818
+				array('e_reg_url_link' => $this->checkout->reg_url_link),
1819
+				$this->checkout->thank_you_page_url
1820
+			);
1821
+		}
1822
+		return $success;
1823
+	}
1824
+
1825
+
1826
+	/**
1827
+	 *    _process_payment
1828
+	 *
1829
+	 * @access private
1830
+	 * @return bool
1831
+	 * @throws EE_Error
1832
+	 * @throws InvalidArgumentException
1833
+	 * @throws ReflectionException
1834
+	 * @throws RuntimeException
1835
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1836
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1837
+	 */
1838
+	private function _process_payment()
1839
+	{
1840
+		// basically confirm that the event hasn't sold out since they hit the page
1841
+		if (! $this->_last_second_ticket_verifications()) {
1842
+			return false;
1843
+		}
1844
+		// ya gotta make a choice man
1845
+		if (empty($this->checkout->selected_method_of_payment)) {
1846
+			$this->checkout->json_response->set_plz_select_method_of_payment(
1847
+				esc_html__('Please select a method of payment before proceeding.', 'event_espresso')
1848
+			);
1849
+			return false;
1850
+		}
1851
+		// get EE_Payment_Method object
1852
+		if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1853
+			return false;
1854
+		}
1855
+		// setup billing form
1856
+		if ($this->checkout->payment_method->is_on_site()) {
1857
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1858
+				$this->checkout->payment_method
1859
+			);
1860
+			// bad billing form ?
1861
+			if (! $this->_billing_form_is_valid()) {
1862
+				return false;
1863
+			}
1864
+		}
1865
+		// ensure primary registrant has been fully processed
1866
+		if (! $this->_setup_primary_registrant_prior_to_payment()) {
1867
+			return false;
1868
+		}
1869
+		// if session is close to expiring (under 10 minutes by default)
1870
+		if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) {
1871
+			// add some time to session expiration so that payment can be completed
1872
+			EE_Registry::instance()->SSN->extend_expiration();
1873
+		}
1874
+		/** @type EE_Transaction_Processor $transaction_processor */
1875
+		// $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1876
+		// in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations
1877
+		// for events with a default reg status of Approved
1878
+		// $transaction_processor->toggle_registration_statuses_for_default_approved_events(
1879
+		//      $this->checkout->transaction, $this->checkout->reg_cache_where_params
1880
+		// );
1881
+		// attempt payment
1882
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1883
+		// process results
1884
+		$payment = $this->_validate_payment($payment);
1885
+		$payment = $this->_post_payment_processing($payment);
1886
+		// verify payment
1887
+		if ($payment instanceof EE_Payment) {
1888
+			// store that for later
1889
+			$this->checkout->payment = $payment;
1890
+			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1891
+			$this->checkout->transaction->toggle_failed_transaction_status();
1892
+			$payment_status = $payment->status();
1893
+			if ($payment_status === EEM_Payment::status_id_approved
1894
+				|| $payment_status === EEM_Payment::status_id_pending
1895
+			) {
1896
+				return true;
1897
+			} else {
1898
+				return false;
1899
+			}
1900
+		} elseif ($payment === true) {
1901
+			// please note that offline payment methods will NOT make a payment,
1902
+			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1903
+			$this->checkout->payment = $payment;
1904
+			return true;
1905
+		}
1906
+		// where's my money?
1907
+		return false;
1908
+	}
1909
+
1910
+
1911
+	/**
1912
+	 * _last_second_ticket_verifications
1913
+	 *
1914
+	 * @access public
1915
+	 * @return bool
1916
+	 * @throws EE_Error
1917
+	 */
1918
+	protected function _last_second_ticket_verifications()
1919
+	{
1920
+		// don't bother re-validating if not a return visit
1921
+		if (! $this->checkout->revisit) {
1922
+			return true;
1923
+		}
1924
+		$registrations = $this->checkout->transaction->registrations();
1925
+		if (empty($registrations)) {
1926
+			return false;
1927
+		}
1928
+		foreach ($registrations as $registration) {
1929
+			if ($registration instanceof EE_Registration && ! $registration->is_approved()) {
1930
+				$event = $registration->event_obj();
1931
+				if ($event instanceof EE_Event && $event->is_sold_out(true)) {
1932
+					EE_Error::add_error(
1933
+						apply_filters(
1934
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg',
1935
+							sprintf(
1936
+								esc_html__(
1937
+									'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
1938
+									'event_espresso'
1939
+								),
1940
+								$event->name()
1941
+							)
1942
+						),
1943
+						__FILE__,
1944
+						__FUNCTION__,
1945
+						__LINE__
1946
+					);
1947
+					return false;
1948
+				}
1949
+			}
1950
+		}
1951
+		return true;
1952
+	}
1953
+
1954
+
1955
+	/**
1956
+	 * redirect_form
1957
+	 *
1958
+	 * @access public
1959
+	 * @return bool
1960
+	 * @throws EE_Error
1961
+	 * @throws InvalidArgumentException
1962
+	 * @throws ReflectionException
1963
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1964
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1965
+	 */
1966
+	public function redirect_form()
1967
+	{
1968
+		$payment_method_billing_info = $this->_payment_method_billing_info(
1969
+			$this->_get_payment_method_for_selected_method_of_payment()
1970
+		);
1971
+		$html = $payment_method_billing_info->get_html();
1972
+		$html .= $this->checkout->redirect_form;
1973
+		EE_Registry::instance()->REQ->add_output($html);
1974
+		return true;
1975
+	}
1976
+
1977
+
1978
+	/**
1979
+	 * _billing_form_is_valid
1980
+	 *
1981
+	 * @access private
1982
+	 * @return bool
1983
+	 * @throws \EE_Error
1984
+	 */
1985
+	private function _billing_form_is_valid()
1986
+	{
1987
+		if (! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1988
+			return true;
1989
+		}
1990
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1991
+			if ($this->checkout->billing_form->was_submitted()) {
1992
+				$this->checkout->billing_form->receive_form_submission();
1993
+				if ($this->checkout->billing_form->is_valid()) {
1994
+					return true;
1995
+				}
1996
+				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1997
+				$error_strings = array();
1998
+				foreach ($validation_errors as $validation_error) {
1999
+					if ($validation_error instanceof EE_Validation_Error) {
2000
+						$form_section = $validation_error->get_form_section();
2001
+						if ($form_section instanceof EE_Form_Input_Base) {
2002
+							$label = $form_section->html_label_text();
2003
+						} elseif ($form_section instanceof EE_Form_Section_Base) {
2004
+							$label = $form_section->name();
2005
+						} else {
2006
+							$label = esc_html__('Validation Error', 'event_espresso');
2007
+						}
2008
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
2009
+					}
2010
+				}
2011
+				EE_Error::add_error(
2012
+					sprintf(
2013
+						esc_html__(
2014
+							'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s',
2015
+							'event_espresso'
2016
+						),
2017
+						'<br/>',
2018
+						implode('<br/>', $error_strings)
2019
+					),
2020
+					__FILE__,
2021
+					__FUNCTION__,
2022
+					__LINE__
2023
+				);
2024
+			} else {
2025
+				EE_Error::add_error(
2026
+					esc_html__(
2027
+						'The billing form was not submitted or something prevented it\'s submission.',
2028
+						'event_espresso'
2029
+					),
2030
+					__FILE__,
2031
+					__FUNCTION__,
2032
+					__LINE__
2033
+				);
2034
+			}
2035
+		} else {
2036
+			EE_Error::add_error(
2037
+				esc_html__(
2038
+					'The submitted billing form is invalid possibly due to a technical reason.',
2039
+					'event_espresso'
2040
+				),
2041
+				__FILE__,
2042
+				__FUNCTION__,
2043
+				__LINE__
2044
+			);
2045
+		}
2046
+		return false;
2047
+	}
2048
+
2049
+
2050
+	/**
2051
+	 * _setup_primary_registrant_prior_to_payment
2052
+	 * ensures that the primary registrant has a valid attendee object created with the critical details populated
2053
+	 * (first & last name & email) and that both the transaction object and primary registration object have been saved
2054
+	 * plz note that any other registrations will NOT be saved at this point (because they may not have any details
2055
+	 * yet)
2056
+	 *
2057
+	 * @access private
2058
+	 * @return bool
2059
+	 * @throws EE_Error
2060
+	 * @throws InvalidArgumentException
2061
+	 * @throws ReflectionException
2062
+	 * @throws RuntimeException
2063
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2064
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2065
+	 */
2066
+	private function _setup_primary_registrant_prior_to_payment()
2067
+	{
2068
+		// check if transaction has a primary registrant and that it has a related Attendee object
2069
+		// if not, then we need to at least gather some primary registrant data before attempting payment
2070
+		if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
2071
+			&& ! $this->checkout->transaction_has_primary_registrant()
2072
+			&& ! $this->_capture_primary_registration_data_from_billing_form()
2073
+		) {
2074
+			return false;
2075
+		}
2076
+		// because saving an object clears it's cache, we need to do the chevy shuffle
2077
+		// grab the primary_registration object
2078
+		$primary_registration = $this->checkout->transaction->primary_registration();
2079
+		// at this point we'll consider a TXN to not have been failed
2080
+		$this->checkout->transaction->toggle_failed_transaction_status();
2081
+		// save the TXN ( which clears cached copy of primary_registration)
2082
+		$this->checkout->transaction->save();
2083
+		// grab TXN ID and save it to the primary_registration
2084
+		$primary_registration->set_transaction_id($this->checkout->transaction->ID());
2085
+		// save what we have so far
2086
+		$primary_registration->save();
2087
+		return true;
2088
+	}
2089
+
2090
+
2091
+	/**
2092
+	 * _capture_primary_registration_data_from_billing_form
2093
+	 *
2094
+	 * @access private
2095
+	 * @return bool
2096
+	 * @throws EE_Error
2097
+	 * @throws InvalidArgumentException
2098
+	 * @throws ReflectionException
2099
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2100
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2101
+	 */
2102
+	private function _capture_primary_registration_data_from_billing_form()
2103
+	{
2104
+		// convert billing form data into an attendee
2105
+		$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
2106
+		if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2107
+			EE_Error::add_error(
2108
+				sprintf(
2109
+					esc_html__(
2110
+						'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.',
2111
+						'event_espresso'
2112
+					),
2113
+					'<br/>',
2114
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2115
+				),
2116
+				__FILE__,
2117
+				__FUNCTION__,
2118
+				__LINE__
2119
+			);
2120
+			return false;
2121
+		}
2122
+		$primary_registration = $this->checkout->transaction->primary_registration();
2123
+		if (! $primary_registration instanceof EE_Registration) {
2124
+			EE_Error::add_error(
2125
+				sprintf(
2126
+					esc_html__(
2127
+						'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2128
+						'event_espresso'
2129
+					),
2130
+					'<br/>',
2131
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2132
+				),
2133
+				__FILE__,
2134
+				__FUNCTION__,
2135
+				__LINE__
2136
+			);
2137
+			return false;
2138
+		}
2139
+		if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2140
+			  instanceof
2141
+			  EE_Attendee
2142
+		) {
2143
+			EE_Error::add_error(
2144
+				sprintf(
2145
+					esc_html__(
2146
+						'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.',
2147
+						'event_espresso'
2148
+					),
2149
+					'<br/>',
2150
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2151
+				),
2152
+				__FILE__,
2153
+				__FUNCTION__,
2154
+				__LINE__
2155
+			);
2156
+			return false;
2157
+		}
2158
+		/** @type EE_Registration_Processor $registration_processor */
2159
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
2160
+		// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
2161
+		$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
2162
+		return true;
2163
+	}
2164
+
2165
+
2166
+	/**
2167
+	 * _get_payment_method_for_selected_method_of_payment
2168
+	 * retrieves a valid payment method
2169
+	 *
2170
+	 * @access public
2171
+	 * @return EE_Payment_Method
2172
+	 * @throws EE_Error
2173
+	 * @throws InvalidArgumentException
2174
+	 * @throws ReflectionException
2175
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2176
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2177
+	 */
2178
+	private function _get_payment_method_for_selected_method_of_payment()
2179
+	{
2180
+		if ($this->checkout->selected_method_of_payment === 'events_sold_out') {
2181
+			$this->_redirect_because_event_sold_out();
2182
+			return null;
2183
+		}
2184
+		// get EE_Payment_Method object
2185
+		if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) {
2186
+			$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
2187
+		} else {
2188
+			// load EEM_Payment_Method
2189
+			EE_Registry::instance()->load_model('Payment_Method');
2190
+			/** @type EEM_Payment_Method $EEM_Payment_Method */
2191
+			$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
2192
+			$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
2193
+		}
2194
+		// verify $payment_method
2195
+		if (! $payment_method instanceof EE_Payment_Method) {
2196
+			// not a payment
2197
+			EE_Error::add_error(
2198
+				sprintf(
2199
+					esc_html__(
2200
+						'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2201
+						'event_espresso'
2202
+					),
2203
+					'<br/>',
2204
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2205
+				),
2206
+				__FILE__,
2207
+				__FUNCTION__,
2208
+				__LINE__
2209
+			);
2210
+			return null;
2211
+		}
2212
+		// and verify it has a valid Payment_Method Type object
2213
+		if (! $payment_method->type_obj() instanceof EE_PMT_Base) {
2214
+			// not a payment
2215
+			EE_Error::add_error(
2216
+				sprintf(
2217
+					esc_html__(
2218
+						'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2219
+						'event_espresso'
2220
+					),
2221
+					'<br/>',
2222
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2223
+				),
2224
+				__FILE__,
2225
+				__FUNCTION__,
2226
+				__LINE__
2227
+			);
2228
+			return null;
2229
+		}
2230
+		return $payment_method;
2231
+	}
2232
+
2233
+
2234
+	/**
2235
+	 *    _attempt_payment
2236
+	 *
2237
+	 * @access    private
2238
+	 * @type    EE_Payment_Method $payment_method
2239
+	 * @return mixed EE_Payment | boolean
2240
+	 * @throws EE_Error
2241
+	 * @throws InvalidArgumentException
2242
+	 * @throws ReflectionException
2243
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2244
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2245
+	 */
2246
+	private function _attempt_payment(EE_Payment_Method $payment_method)
2247
+	{
2248
+		$payment = null;
2249
+		$this->checkout->transaction->save();
2250
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2251
+		if (! $payment_processor instanceof EE_Payment_Processor) {
2252
+			return false;
2253
+		}
2254
+		try {
2255
+			$payment_processor->set_revisit($this->checkout->revisit);
2256
+			// generate payment object
2257
+			$payment = $payment_processor->process_payment(
2258
+				$payment_method,
2259
+				$this->checkout->transaction,
2260
+				$this->checkout->amount_owing,
2261
+				$this->checkout->billing_form,
2262
+				$this->_get_return_url($payment_method),
2263
+				'CART',
2264
+				$this->checkout->admin_request,
2265
+				true,
2266
+				$this->reg_step_url()
2267
+			);
2268
+		} catch (Exception $e) {
2269
+			$this->_handle_payment_processor_exception($e);
2270
+		}
2271
+		return $payment;
2272
+	}
2273
+
2274
+
2275
+	/**
2276
+	 * _handle_payment_processor_exception
2277
+	 *
2278
+	 * @access protected
2279
+	 * @param \Exception $e
2280
+	 * @return void
2281
+	 * @throws EE_Error
2282
+	 * @throws InvalidArgumentException
2283
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2284
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2285
+	 */
2286
+	protected function _handle_payment_processor_exception(Exception $e)
2287
+	{
2288
+		EE_Error::add_error(
2289
+			sprintf(
2290
+				esc_html__(
2291
+					'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s',
2292
+					'event_espresso'
2293
+				),
2294
+				'<br/>',
2295
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
2296
+				$e->getMessage(),
2297
+				$e->getFile(),
2298
+				$e->getLine()
2299
+			),
2300
+			__FILE__,
2301
+			__FUNCTION__,
2302
+			__LINE__
2303
+		);
2304
+	}
2305
+
2306
+
2307
+	/**
2308
+	 * _get_return_url
2309
+	 *
2310
+	 * @access protected
2311
+	 * @param \EE_Payment_Method $payment_method
2312
+	 * @return string
2313
+	 * @throws \EE_Error
2314
+	 */
2315
+	protected function _get_return_url(EE_Payment_Method $payment_method)
2316
+	{
2317
+		$return_url = '';
2318
+		switch ($payment_method->type_obj()->payment_occurs()) {
2319
+			case EE_PMT_Base::offsite:
2320
+				$return_url = add_query_arg(
2321
+					array(
2322
+						'action'                     => 'process_gateway_response',
2323
+						'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2324
+						'spco_txn'                   => $this->checkout->transaction->ID(),
2325
+					),
2326
+					$this->reg_step_url()
2327
+				);
2328
+				break;
2329
+			case EE_PMT_Base::onsite:
2330
+			case EE_PMT_Base::offline:
2331
+				$return_url = $this->checkout->next_step->reg_step_url();
2332
+				break;
2333
+		}
2334
+		return $return_url;
2335
+	}
2336
+
2337
+
2338
+	/**
2339
+	 * _validate_payment
2340
+	 *
2341
+	 * @access private
2342
+	 * @param EE_Payment $payment
2343
+	 * @return EE_Payment|FALSE
2344
+	 * @throws EE_Error
2345
+	 * @throws InvalidArgumentException
2346
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2347
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2348
+	 */
2349
+	private function _validate_payment($payment = null)
2350
+	{
2351
+		if ($this->checkout->payment_method->is_off_line()) {
2352
+			return true;
2353
+		}
2354
+		// verify payment object
2355
+		if (! $payment instanceof EE_Payment) {
2356
+			// not a payment
2357
+			EE_Error::add_error(
2358
+				sprintf(
2359
+					esc_html__(
2360
+						'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.',
2361
+						'event_espresso'
2362
+					),
2363
+					'<br/>',
2364
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2365
+				),
2366
+				__FILE__,
2367
+				__FUNCTION__,
2368
+				__LINE__
2369
+			);
2370
+			return false;
2371
+		}
2372
+		return $payment;
2373
+	}
2374
+
2375
+
2376
+	/**
2377
+	 * _post_payment_processing
2378
+	 *
2379
+	 * @access private
2380
+	 * @param EE_Payment|bool $payment
2381
+	 * @return bool
2382
+	 * @throws EE_Error
2383
+	 * @throws InvalidArgumentException
2384
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2385
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2386
+	 */
2387
+	private function _post_payment_processing($payment = null)
2388
+	{
2389
+		// Off-Line payment?
2390
+		if ($payment === true) {
2391
+			// $this->_setup_redirect_for_next_step();
2392
+			return true;
2393
+			// On-Site payment?
2394
+		} elseif ($this->checkout->payment_method->is_on_site()) {
2395
+			if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2396
+				// $this->_setup_redirect_for_next_step();
2397
+				$this->checkout->continue_reg = false;
2398
+			}
2399
+			// Off-Site payment?
2400
+		} elseif ($this->checkout->payment_method->is_off_site()) {
2401
+			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
2402
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
2403
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
2404
+				$this->checkout->redirect = true;
2405
+				$this->checkout->redirect_form = $payment->redirect_form();
2406
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
2407
+				// set JSON response
2408
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
2409
+				// and lastly, let's bump the payment status to pending
2410
+				$payment->set_status(EEM_Payment::status_id_pending);
2411
+				$payment->save();
2412
+			} else {
2413
+				// we couldn't redirect the user. Let's tell them why.
2414
+				$error_message = sprintf(
2415
+					esc_html__(
2416
+						'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.',
2417
+						'event_espresso'
2418
+					),
2419
+					'<br/>',
2420
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2421
+				);
2422
+				if ($payment instanceof EE_Payment && $payment->gateway_response()) {
2423
+					$error_message = $error_message . '<br/>' . $payment->gateway_response();
2424
+				}
2425
+				$this->checkout->continue_reg = false;
2426
+				EE_Error::add_error(
2427
+					$error_message,
2428
+					__FILE__,
2429
+					__FUNCTION__,
2430
+					__LINE__
2431
+				);
2432
+			}
2433
+		} else {
2434
+			// ummm ya... not Off-Line, not On-Site, not off-Site ????
2435
+			$this->checkout->continue_reg = false;
2436
+			return false;
2437
+		}
2438
+		return $payment;
2439
+	}
2440
+
2441
+
2442
+	/**
2443
+	 *    _process_payment_status
2444
+	 *
2445
+	 * @access private
2446
+	 * @type    EE_Payment $payment
2447
+	 * @param string       $payment_occurs
2448
+	 * @return bool
2449
+	 * @throws EE_Error
2450
+	 * @throws InvalidArgumentException
2451
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2452
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2453
+	 */
2454
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline)
2455
+	{
2456
+		// off-line payment? carry on
2457
+		if ($payment_occurs === EE_PMT_Base::offline) {
2458
+			return true;
2459
+		}
2460
+		// verify payment validity
2461
+		if ($payment instanceof EE_Payment) {
2462
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
2463
+			$msg = $payment->gateway_response();
2464
+			// check results
2465
+			switch ($payment->status()) {
2466
+				// good payment
2467
+				case EEM_Payment::status_id_approved:
2468
+					EE_Error::add_success(
2469
+						esc_html__('Your payment was processed successfully.', 'event_espresso'),
2470
+						__FILE__,
2471
+						__FUNCTION__,
2472
+						__LINE__
2473
+					);
2474
+					return true;
2475
+					break;
2476
+				// slow payment
2477
+				case EEM_Payment::status_id_pending:
2478
+					if (empty($msg)) {
2479
+						$msg = esc_html__(
2480
+							'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.',
2481
+							'event_espresso'
2482
+						);
2483
+					}
2484
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
2485
+					return true;
2486
+					break;
2487
+				// don't wanna payment
2488
+				case EEM_Payment::status_id_cancelled:
2489
+					if (empty($msg)) {
2490
+						$msg = _n(
2491
+							'Payment cancelled. Please try again.',
2492
+							'Payment cancelled. Please try again or select another method of payment.',
2493
+							count($this->checkout->available_payment_methods),
2494
+							'event_espresso'
2495
+						);
2496
+					}
2497
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2498
+					return false;
2499
+					break;
2500
+				// not enough payment
2501
+				case EEM_Payment::status_id_declined:
2502
+					if (empty($msg)) {
2503
+						$msg = _n(
2504
+							'We\'re sorry but your payment was declined. Please try again.',
2505
+							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
2506
+							count($this->checkout->available_payment_methods),
2507
+							'event_espresso'
2508
+						);
2509
+					}
2510
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2511
+					return false;
2512
+					break;
2513
+				// bad payment
2514
+				case EEM_Payment::status_id_failed:
2515
+					if (! empty($msg)) {
2516
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2517
+						return false;
2518
+					}
2519
+					// default to error below
2520
+					break;
2521
+			}
2522
+		}
2523
+		// off-site payment gateway responses are too unreliable, so let's just assume that
2524
+		// the payment processing is just running slower than the registrant's request
2525
+		if ($payment_occurs === EE_PMT_Base::offsite) {
2526
+			return true;
2527
+		}
2528
+		EE_Error::add_error(
2529
+			sprintf(
2530
+				esc_html__(
2531
+					'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.',
2532
+					'event_espresso'
2533
+				),
2534
+				'<br/>',
2535
+				EE_Registry::instance()->CFG->organization->get_pretty('email')
2536
+			),
2537
+			__FILE__,
2538
+			__FUNCTION__,
2539
+			__LINE__
2540
+		);
2541
+		return false;
2542
+	}
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+
2549
+	/********************************************************************************************************/
2550
+	/**********************************  PROCESS GATEWAY RESPONSE  **********************************/
2551
+	/********************************************************************************************************/
2552
+	/**
2553
+	 * process_gateway_response
2554
+	 * this is the return point for Off-Site Payment Methods
2555
+	 * It will attempt to "handle the IPN" if it appears that this has not already occurred,
2556
+	 * otherwise, it will load up the last payment made for the TXN.
2557
+	 * If the payment retrieved looks good, it will then either:
2558
+	 *    complete the current step and allow advancement to the next reg step
2559
+	 *        or present the payment options again
2560
+	 *
2561
+	 * @access private
2562
+	 * @return EE_Payment|FALSE
2563
+	 * @throws EE_Error
2564
+	 * @throws InvalidArgumentException
2565
+	 * @throws ReflectionException
2566
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2567
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2568
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2569
+	 */
2570
+	public function process_gateway_response()
2571
+	{
2572
+		$payment = null;
2573
+		// how have they chosen to pay?
2574
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2575
+		// get EE_Payment_Method object
2576
+		if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2577
+			$this->checkout->continue_reg = false;
2578
+			return false;
2579
+		}
2580
+		if (! $this->checkout->payment_method->is_off_site()) {
2581
+			return false;
2582
+		}
2583
+		$this->_validate_offsite_return();
2584
+		// DEBUG LOG
2585
+		// $this->checkout->log(
2586
+		//     __CLASS__,
2587
+		//     __FUNCTION__,
2588
+		//     __LINE__,
2589
+		//     array(
2590
+		//         'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2591
+		//         'payment_method'             => $this->checkout->payment_method,
2592
+		//     ),
2593
+		//     true
2594
+		// );
2595
+		// verify TXN
2596
+		if ($this->checkout->transaction instanceof EE_Transaction) {
2597
+			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2598
+			if (! $gateway instanceof EE_Offsite_Gateway) {
2599
+				$this->checkout->continue_reg = false;
2600
+				return false;
2601
+			}
2602
+			$payment = $this->_process_off_site_payment($gateway);
2603
+			$payment = $this->_process_cancelled_payments($payment);
2604
+			$payment = $this->_validate_payment($payment);
2605
+			// if payment was not declined by the payment gateway or cancelled by the registrant
2606
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
2607
+				// $this->_setup_redirect_for_next_step();
2608
+				// store that for later
2609
+				$this->checkout->payment = $payment;
2610
+				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
2611
+				// because we will complete this step during the IPN processing then
2612
+				if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) {
2613
+					$this->set_completed();
2614
+				}
2615
+				return true;
2616
+			}
2617
+		}
2618
+		// DEBUG LOG
2619
+		// $this->checkout->log(
2620
+		//     __CLASS__,
2621
+		//     __FUNCTION__,
2622
+		//     __LINE__,
2623
+		//     array('payment' => $payment)
2624
+		// );
2625
+		$this->checkout->continue_reg = false;
2626
+		return false;
2627
+	}
2628
+
2629
+
2630
+	/**
2631
+	 * _validate_return
2632
+	 *
2633
+	 * @access private
2634
+	 * @return void
2635
+	 * @throws EE_Error
2636
+	 * @throws InvalidArgumentException
2637
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2638
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2639
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2640
+	 */
2641
+	private function _validate_offsite_return()
2642
+	{
2643
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
2644
+		if ($TXN_ID !== $this->checkout->transaction->ID()) {
2645
+			// Houston... we might have a problem
2646
+			$invalid_TXN = false;
2647
+			// first gather some info
2648
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2649
+			$primary_registrant = $valid_TXN instanceof EE_Transaction
2650
+				? $valid_TXN->primary_registration()
2651
+				: null;
2652
+			// let's start by retrieving the cart for this TXN
2653
+			$cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction);
2654
+			if ($cart instanceof EE_Cart) {
2655
+				// verify that the current cart has tickets
2656
+				$tickets = $cart->get_tickets();
2657
+				if (empty($tickets)) {
2658
+					$invalid_TXN = true;
2659
+				}
2660
+			} else {
2661
+				$invalid_TXN = true;
2662
+			}
2663
+			$valid_TXN_SID = $primary_registrant instanceof EE_Registration
2664
+				? $primary_registrant->session_ID()
2665
+				: null;
2666
+			// validate current Session ID and compare against valid TXN session ID
2667
+			if ($invalid_TXN // if this is already true, then skip other checks
2668
+				|| EE_Session::instance()->id() === null
2669
+				|| (
2670
+					// WARNING !!!
2671
+					// this could be PayPal sending back duplicate requests (ya they do that)
2672
+					// or it **could** mean someone is simply registering AGAIN after having just done so
2673
+					// so now we need to determine if this current TXN looks valid or not
2674
+					// and whether this reg step has even been started ?
2675
+					EE_Session::instance()->id() === $valid_TXN_SID
2676
+					// really? you're half way through this reg step, but you never started it ?
2677
+					&& $this->checkout->transaction->reg_step_completed($this->slug()) === false
2678
+				)
2679
+			) {
2680
+				$invalid_TXN = true;
2681
+			}
2682
+			if ($invalid_TXN) {
2683
+				// is the valid TXN completed ?
2684
+				if ($valid_TXN instanceof EE_Transaction) {
2685
+					// has this step even been started ?
2686
+					$reg_step_completed = $valid_TXN->reg_step_completed($this->slug());
2687
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
2688
+						// so it **looks** like this is a double request from PayPal
2689
+						// so let's try to pick up where we left off
2690
+						$this->checkout->transaction = $valid_TXN;
2691
+						$this->checkout->refresh_all_entities(true);
2692
+						return;
2693
+					}
2694
+				}
2695
+				// you appear to be lost?
2696
+				$this->_redirect_wayward_request($primary_registrant);
2697
+			}
2698
+		}
2699
+	}
2700
+
2701
+
2702
+	/**
2703
+	 * _redirect_wayward_request
2704
+	 *
2705
+	 * @access private
2706
+	 * @param \EE_Registration|null $primary_registrant
2707
+	 * @return bool
2708
+	 * @throws EE_Error
2709
+	 * @throws InvalidArgumentException
2710
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2711
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2712
+	 */
2713
+	private function _redirect_wayward_request(EE_Registration $primary_registrant)
2714
+	{
2715
+		if (! $primary_registrant instanceof EE_Registration) {
2716
+			// try redirecting based on the current TXN
2717
+			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2718
+				? $this->checkout->transaction->primary_registration()
2719
+				: null;
2720
+		}
2721
+		if (! $primary_registrant instanceof EE_Registration) {
2722
+			EE_Error::add_error(
2723
+				sprintf(
2724
+					esc_html__(
2725
+						'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.',
2726
+						'event_espresso'
2727
+					),
2728
+					'<br/>',
2729
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2730
+				),
2731
+				__FILE__,
2732
+				__FUNCTION__,
2733
+				__LINE__
2734
+			);
2735
+			return false;
2736
+		}
2737
+		// make sure transaction is not locked
2738
+		$this->checkout->transaction->unlock();
2739
+		wp_safe_redirect(
2740
+			add_query_arg(
2741
+				array(
2742
+					'e_reg_url_link' => $primary_registrant->reg_url_link(),
2743
+				),
2744
+				$this->checkout->thank_you_page_url
2745
+			)
2746
+		);
2747
+		exit();
2748
+	}
2749
+
2750
+
2751
+	/**
2752
+	 * _process_off_site_payment
2753
+	 *
2754
+	 * @access private
2755
+	 * @param \EE_Offsite_Gateway $gateway
2756
+	 * @return EE_Payment
2757
+	 * @throws EE_Error
2758
+	 * @throws InvalidArgumentException
2759
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2760
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2761
+	 */
2762
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway)
2763
+	{
2764
+		try {
2765
+			$request_data = \EE_Registry::instance()->REQ->params();
2766
+			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
2767
+			$this->set_handle_IPN_in_this_request(
2768
+				$gateway->handle_IPN_in_this_request($request_data, false)
2769
+			);
2770
+			if ($this->handle_IPN_in_this_request()) {
2771
+				// get payment details and process results
2772
+				/** @type EE_Payment_Processor $payment_processor */
2773
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2774
+				$payment = $payment_processor->process_ipn(
2775
+					$request_data,
2776
+					$this->checkout->transaction,
2777
+					$this->checkout->payment_method,
2778
+					true,
2779
+					false
2780
+				);
2781
+				// $payment_source = 'process_ipn';
2782
+			} else {
2783
+				$payment = $this->checkout->transaction->last_payment();
2784
+				// $payment_source = 'last_payment';
2785
+			}
2786
+		} catch (Exception $e) {
2787
+			// let's just eat the exception and try to move on using any previously set payment info
2788
+			$payment = $this->checkout->transaction->last_payment();
2789
+			// $payment_source = 'last_payment after Exception';
2790
+			// but if we STILL don't have a payment object
2791
+			if (! $payment instanceof EE_Payment) {
2792
+				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2793
+				$this->_handle_payment_processor_exception($e);
2794
+			}
2795
+		}
2796
+		// DEBUG LOG
2797
+		// $this->checkout->log(
2798
+		//     __CLASS__,
2799
+		//     __FUNCTION__,
2800
+		//     __LINE__,
2801
+		//     array(
2802
+		//         'process_ipn_payment' => $payment,
2803
+		//         'payment_source'      => $payment_source,
2804
+		//     )
2805
+		// );
2806
+		return $payment;
2807
+	}
2808
+
2809
+
2810
+	/**
2811
+	 * _process_cancelled_payments
2812
+	 * just makes sure that the payment status gets updated correctly
2813
+	 * so tha tan error isn't generated during payment validation
2814
+	 *
2815
+	 * @access private
2816
+	 * @param EE_Payment $payment
2817
+	 * @return EE_Payment | FALSE
2818
+	 * @throws \EE_Error
2819
+	 */
2820
+	private function _process_cancelled_payments($payment = null)
2821
+	{
2822
+		if ($payment instanceof EE_Payment
2823
+			&& isset($_REQUEST['ee_cancel_payment'])
2824
+			&& $payment->status() === EEM_Payment::status_id_failed
2825
+		) {
2826
+			$payment->set_status(EEM_Payment::status_id_cancelled);
2827
+		}
2828
+		return $payment;
2829
+	}
2830
+
2831
+
2832
+	/**
2833
+	 *    get_transaction_details_for_gateways
2834
+	 *
2835
+	 * @access    public
2836
+	 * @return int
2837
+	 * @throws EE_Error
2838
+	 * @throws InvalidArgumentException
2839
+	 * @throws ReflectionException
2840
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2841
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2842
+	 */
2843
+	public function get_transaction_details_for_gateways()
2844
+	{
2845
+		$txn_details = array();
2846
+		// ya gotta make a choice man
2847
+		if (empty($this->checkout->selected_method_of_payment)) {
2848
+			$txn_details = array(
2849
+				'error' => esc_html__('Please select a method of payment before proceeding.', 'event_espresso'),
2850
+			);
2851
+		}
2852
+		// get EE_Payment_Method object
2853
+		if (empty($txn_details)
2854
+			&&
2855
+			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2856
+		) {
2857
+			$txn_details = array(
2858
+				'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2859
+				'error'                      => esc_html__(
2860
+					'A valid Payment Method could not be determined.',
2861
+					'event_espresso'
2862
+				),
2863
+			);
2864
+		}
2865
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2866
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
2867
+			$txn_details = array(
2868
+				'TXN_ID'         => $this->checkout->transaction->ID(),
2869
+				'TXN_timestamp'  => $this->checkout->transaction->datetime(),
2870
+				'TXN_total'      => $this->checkout->transaction->total(),
2871
+				'TXN_paid'       => $this->checkout->transaction->paid(),
2872
+				'TXN_reg_steps'  => $this->checkout->transaction->reg_steps(),
2873
+				'STS_ID'         => $this->checkout->transaction->status_ID(),
2874
+				'PMD_ID'         => $this->checkout->transaction->payment_method_ID(),
2875
+				'payment_amount' => $this->checkout->amount_owing,
2876
+				'return_url'     => $return_url,
2877
+				'cancel_url'     => add_query_arg(array('ee_cancel_payment' => true), $return_url),
2878
+				'notify_url'     => EE_Config::instance()->core->txn_page_url(
2879
+					array(
2880
+						'e_reg_url_link'    => $this->checkout->transaction->primary_registration()->reg_url_link(),
2881
+						'ee_payment_method' => $this->checkout->payment_method->slug(),
2882
+					)
2883
+				),
2884
+			);
2885
+		}
2886
+		echo wp_json_encode($txn_details);
2887
+		exit();
2888
+	}
2889
+
2890
+
2891
+	/**
2892
+	 *    __sleep
2893
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
2894
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
2895
+	 * reg form, because if needed, it will be regenerated anyways
2896
+	 *
2897
+	 * @return array
2898
+	 */
2899
+	public function __sleep()
2900
+	{
2901
+		// remove the reg form and the checkout
2902
+		return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display'));
2903
+	}
2904 2904
 }
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     {
130 130
         $this->_slug = 'payment_options';
131 131
         $this->_name = esc_html__('Payment Options', 'event_espresso');
132
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/payment_options_main.template.php';
132
+        $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.'/payment_options_main.template.php';
133 133
         $this->checkout = $checkout;
134 134
         $this->_reset_success_message();
135 135
         $this->set_instructions(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     {
213 213
         $transaction = $this->checkout->transaction;
214 214
         // if the transaction isn't set or nothing is owed on it, don't enqueue any JS
215
-        if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
215
+        if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
216 216
             return;
217 217
         }
218 218
         foreach (EEM_Payment_Method::instance()->get_all_for_transaction(
@@ -304,18 +304,18 @@  discard block
 block discarded – undo
304 304
         foreach ($registrations as $REG_ID => $registration) {
305 305
             /** @var $registration EE_Registration */
306 306
             // has this registration lost it's space ?
307
-            if (isset($ejected_registrations[ $REG_ID ])) {
307
+            if (isset($ejected_registrations[$REG_ID])) {
308 308
                 if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
309
-                    $sold_out_events[ $registration->event()->ID() ] = $registration->event();
309
+                    $sold_out_events[$registration->event()->ID()] = $registration->event();
310 310
                 } else {
311
-                    $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
311
+                    $insufficient_spaces_available[$registration->event()->ID()] = $registration->event();
312 312
                 }
313 313
                 continue;
314 314
             }
315 315
             // event requires admin approval
316 316
             if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
317 317
                 // add event to list of events with pre-approval reg status
318
-                $registrations_requiring_pre_approval[ $REG_ID ] = $registration;
318
+                $registrations_requiring_pre_approval[$REG_ID] = $registration;
319 319
                 do_action(
320 320
                     'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
321 321
                     $registration->event(),
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                 )
332 332
             ) {
333 333
                 // add event to list of events that are sold out
334
-                $sold_out_events[ $registration->event()->ID() ] = $registration->event();
334
+                $sold_out_events[$registration->event()->ID()] = $registration->event();
335 335
                 do_action(
336 336
                     'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
337 337
                     $registration->event(),
@@ -341,38 +341,38 @@  discard block
 block discarded – undo
341 341
             }
342 342
             // are they allowed to pay now and is there monies owing?
343 343
             if ($registration->owes_monies_and_can_pay()) {
344
-                $registrations_requiring_payment[ $REG_ID ] = $registration;
344
+                $registrations_requiring_payment[$REG_ID] = $registration;
345 345
                 do_action(
346 346
                     'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
347 347
                     $registration->event(),
348 348
                     $this
349 349
                 );
350
-            } elseif (! $this->checkout->revisit
350
+            } elseif ( ! $this->checkout->revisit
351 351
                       && $registration->status_ID() !== EEM_Registration::status_id_not_approved
352 352
                       && $registration->ticket()->is_free()
353 353
             ) {
354
-                $registrations_for_free_events[ $registration->ticket()->ID() ] = $registration;
354
+                $registrations_for_free_events[$registration->ticket()->ID()] = $registration;
355 355
             }
356 356
         }
357 357
         $subsections = array();
358 358
         // now decide which template to load
359
-        if (! empty($sold_out_events)) {
359
+        if ( ! empty($sold_out_events)) {
360 360
             $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
361 361
         }
362
-        if (! empty($insufficient_spaces_available)) {
362
+        if ( ! empty($insufficient_spaces_available)) {
363 363
             $subsections['insufficient_space'] = $this->_insufficient_spaces_available(
364 364
                 $insufficient_spaces_available
365 365
             );
366 366
         }
367
-        if (! empty($registrations_requiring_pre_approval)) {
367
+        if ( ! empty($registrations_requiring_pre_approval)) {
368 368
             $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
369 369
                 $registrations_requiring_pre_approval
370 370
             );
371 371
         }
372
-        if (! empty($registrations_for_free_events)) {
372
+        if ( ! empty($registrations_for_free_events)) {
373 373
             $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
374 374
         }
375
-        if (! empty($registrations_requiring_payment)) {
375
+        if ( ! empty($registrations_requiring_payment)) {
376 376
             if ($this->checkout->amount_owing > 0) {
377 377
                 // autoload Line_Item_Display classes
378 378
                 EEH_Autoloader::register_line_item_filter_autoloaders();
@@ -437,13 +437,13 @@  discard block
 block discarded – undo
437 437
      */
438 438
     public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection)
439 439
     {
440
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
440
+        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
441 441
             return $line_item_filter_collection;
442 442
         }
443
-        if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
443
+        if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
444 444
             return $line_item_filter_collection;
445 445
         }
446
-        if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
446
+        if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
447 447
             return $line_item_filter_collection;
448 448
         }
449 449
         $line_item_filter_collection->add(
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
         );
484 484
         foreach ($registrations as $REG_ID => $registration) {
485 485
             // has this registration lost it's space ?
486
-            if (isset($ejected_registrations[ $REG_ID ])) {
487
-                unset($registrations[ $REG_ID ]);
486
+            if (isset($ejected_registrations[$REG_ID])) {
487
+                unset($registrations[$REG_ID]);
488 488
                 continue;
489 489
             }
490 490
         }
@@ -534,24 +534,24 @@  discard block
 block discarded – undo
534 534
             }
535 535
             $EVT_ID = $registration->event_ID();
536 536
             $ticket = $registration->ticket();
537
-            if (! isset($tickets_remaining[ $ticket->ID() ])) {
538
-                $tickets_remaining[ $ticket->ID() ] = $ticket->remaining();
537
+            if ( ! isset($tickets_remaining[$ticket->ID()])) {
538
+                $tickets_remaining[$ticket->ID()] = $ticket->remaining();
539 539
             }
540
-            if ($tickets_remaining[ $ticket->ID() ] > 0) {
541
-                if (! isset($event_reg_count[ $EVT_ID ])) {
542
-                    $event_reg_count[ $EVT_ID ] = 0;
540
+            if ($tickets_remaining[$ticket->ID()] > 0) {
541
+                if ( ! isset($event_reg_count[$EVT_ID])) {
542
+                    $event_reg_count[$EVT_ID] = 0;
543 543
                 }
544
-                $event_reg_count[ $EVT_ID ]++;
545
-                if (! isset($event_spaces_remaining[ $EVT_ID ])) {
546
-                    $event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale();
544
+                $event_reg_count[$EVT_ID]++;
545
+                if ( ! isset($event_spaces_remaining[$EVT_ID])) {
546
+                    $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale();
547 547
                 }
548 548
             }
549 549
             if ($revisit
550
-                && ($tickets_remaining[ $ticket->ID() ] === 0
551
-                    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
550
+                && ($tickets_remaining[$ticket->ID()] === 0
551
+                    || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID]
552 552
                 )
553 553
             ) {
554
-                $ejected_registrations[ $REG_ID ] = $registration->event();
554
+                $ejected_registrations[$REG_ID] = $registration->event();
555 555
                 if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
556 556
                     /** @type EE_Registration_Processor $registration_processor */
557 557
                     $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
         foreach ($sold_out_events_array as $sold_out_event) {
612 612
             $sold_out_events .= EEH_HTML::li(
613 613
                 EEH_HTML::span(
614
-                    '  ' . $sold_out_event->name(),
614
+                    '  '.$sold_out_event->name(),
615 615
                     '',
616 616
                     'dashicons dashicons-marker ee-icon-size-16 pink-text'
617 617
                 )
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
         foreach ($insufficient_spaces_events_array as $event) {
667 667
             if ($event instanceof EE_Event) {
668 668
                 $insufficient_space_events .= EEH_HTML::li(
669
-                    EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
669
+                    EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
670 670
                 );
671 671
             }
672 672
         }
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
         $events_requiring_pre_approval = array();
715 715
         foreach ($registrations_requiring_pre_approval as $registration) {
716 716
             if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
717
-                $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
717
+                $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
718 718
                     EEH_HTML::span(
719 719
                         '',
720 720
                         '',
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
     {
854 854
         return new EE_Form_Section_Proper(
855 855
             array(
856
-                'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
856
+                'html_id'         => 'ee-'.$this->slug().'-extra-hidden-inputs',
857 857
                 'layout_strategy' => new EE_Div_Per_Section_Layout(),
858 858
                 'subsections'     => array(
859 859
                     'spco_no_payment_required' => new EE_Hidden_Input(
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
                 $payments += $registration->registration_payments();
894 894
             }
895 895
         }
896
-        if (! empty($payments)) {
896
+        if ( ! empty($payments)) {
897 897
             foreach ($payments as $payment) {
898 898
                 if ($payment instanceof EE_Registration_Payment) {
899 899
                     $this->checkout->amount_owing -= $payment->amount();
@@ -1017,23 +1017,23 @@  discard block
 block discarded – undo
1017 1017
                 $payment_method_button = EEH_HTML::img(
1018 1018
                     $payment_method->button_url(),
1019 1019
                     $payment_method->name(),
1020
-                    'spco-payment-method-' . $payment_method->slug() . '-btn-img',
1020
+                    'spco-payment-method-'.$payment_method->slug().'-btn-img',
1021 1021
                     'spco-payment-method-btn-img'
1022 1022
                 );
1023 1023
                 // check if any payment methods are set as default
1024 1024
                 // if payment method is already selected OR nothing is selected and this payment method should be
1025 1025
                 // open_by_default
1026 1026
                 if (($this->checkout->selected_method_of_payment === $payment_method->slug())
1027
-                    || (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1027
+                    || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1028 1028
                 ) {
1029 1029
                     $this->checkout->selected_method_of_payment = $payment_method->slug();
1030 1030
                     $this->_save_selected_method_of_payment();
1031
-                    $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
1031
+                    $default_payment_method_option[$payment_method->slug()] = $payment_method_button;
1032 1032
                 } else {
1033
-                    $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
1033
+                    $available_payment_method_options[$payment_method->slug()] = $payment_method_button;
1034 1034
                 }
1035
-                $payment_methods_billing_info[ $payment_method->slug(
1036
-                ) . '-info' ] = $this->_payment_method_billing_info(
1035
+                $payment_methods_billing_info[$payment_method->slug(
1036
+                ).'-info'] = $this->_payment_method_billing_info(
1037 1037
                     $payment_method
1038 1038
                 );
1039 1039
             }
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
      */
1070 1070
     protected function _get_available_payment_methods()
1071 1071
     {
1072
-        if (! empty($this->checkout->available_payment_methods)) {
1072
+        if ( ! empty($this->checkout->available_payment_methods)) {
1073 1073
             return $this->checkout->available_payment_methods;
1074 1074
         }
1075 1075
         $available_payment_methods = array();
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
         );
1085 1085
         foreach ($payment_methods as $payment_method) {
1086 1086
             if ($payment_method instanceof EE_Payment_Method) {
1087
-                $available_payment_methods[ $payment_method->slug() ] = $payment_method;
1087
+                $available_payment_methods[$payment_method->slug()] = $payment_method;
1088 1088
             }
1089 1089
         }
1090 1090
         return $available_payment_methods;
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
         );
1180 1180
         return new EE_Form_Section_Proper(
1181 1181
             array(
1182
-                'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1182
+                'html_id'         => 'spco-payment-method-info-'.$payment_method->slug(),
1183 1183
                 'html_class'      => 'spco-payment-method-info-dv',
1184 1184
                 // only display the selected or default PM
1185 1185
                 'html_style'      => $currently_selected ? '' : 'display:none;',
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
         // how have they chosen to pay?
1210 1210
         $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1211 1211
         $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1212
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1212
+        if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1213 1213
             return false;
1214 1214
         }
1215 1215
         if (apply_filters(
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
      */
1382 1382
     public function switch_payment_method()
1383 1383
     {
1384
-        if (! $this->_verify_payment_method_is_set()) {
1384
+        if ( ! $this->_verify_payment_method_is_set()) {
1385 1385
             return false;
1386 1386
         }
1387 1387
         if (apply_filters(
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
             }
1517 1517
         }
1518 1518
         // verify payment method
1519
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1519
+        if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1520 1520
             // get payment method for selected method of payment
1521 1521
             $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1522 1522
         }
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
      */
1542 1542
     public function save_payer_details_via_ajax()
1543 1543
     {
1544
-        if (! $this->_verify_payment_method_is_set()) {
1544
+        if ( ! $this->_verify_payment_method_is_set()) {
1545 1545
             return;
1546 1546
         }
1547 1547
         // generate billing form for selected method of payment if it hasn't been done already
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
             );
1552 1552
         }
1553 1553
         // generate primary attendee from payer info if applicable
1554
-        if (! $this->checkout->transaction_has_primary_registrant()) {
1554
+        if ( ! $this->checkout->transaction_has_primary_registrant()) {
1555 1555
             $attendee = $this->_create_attendee_from_request_data();
1556 1556
             if ($attendee instanceof EE_Attendee) {
1557 1557
                 foreach ($this->checkout->transaction->registrations() as $registration) {
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
     {
1583 1583
         // get State ID
1584 1584
         $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1585
-        if (! empty($STA_ID)) {
1585
+        if ( ! empty($STA_ID)) {
1586 1586
             // can we get state object from name ?
1587 1587
             EE_Registry::instance()->load_model('State');
1588 1588
             $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
         }
1591 1591
         // get Country ISO
1592 1592
         $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1593
-        if (! empty($CNT_ISO)) {
1593
+        if ( ! empty($CNT_ISO)) {
1594 1594
             // can we get country object from name ?
1595 1595
             EE_Registry::instance()->load_model('Country');
1596 1596
             $country = EEM_Country::instance()->get_col(
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
         }
1624 1624
         // does this attendee already exist in the db ? we're searching using a combination of first name, last name,
1625 1625
         // AND email address
1626
-        if (! empty($attendee_data['ATT_fname'])
1626
+        if ( ! empty($attendee_data['ATT_fname'])
1627 1627
             && ! empty($attendee_data['ATT_lname'])
1628 1628
             && ! empty($attendee_data['ATT_email'])
1629 1629
         ) {
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
     private function _process_payment()
1839 1839
     {
1840 1840
         // basically confirm that the event hasn't sold out since they hit the page
1841
-        if (! $this->_last_second_ticket_verifications()) {
1841
+        if ( ! $this->_last_second_ticket_verifications()) {
1842 1842
             return false;
1843 1843
         }
1844 1844
         // ya gotta make a choice man
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
             return false;
1850 1850
         }
1851 1851
         // get EE_Payment_Method object
1852
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1852
+        if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1853 1853
             return false;
1854 1854
         }
1855 1855
         // setup billing form
@@ -1858,12 +1858,12 @@  discard block
 block discarded – undo
1858 1858
                 $this->checkout->payment_method
1859 1859
             );
1860 1860
             // bad billing form ?
1861
-            if (! $this->_billing_form_is_valid()) {
1861
+            if ( ! $this->_billing_form_is_valid()) {
1862 1862
                 return false;
1863 1863
             }
1864 1864
         }
1865 1865
         // ensure primary registrant has been fully processed
1866
-        if (! $this->_setup_primary_registrant_prior_to_payment()) {
1866
+        if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1867 1867
             return false;
1868 1868
         }
1869 1869
         // if session is close to expiring (under 10 minutes by default)
@@ -1918,7 +1918,7 @@  discard block
 block discarded – undo
1918 1918
     protected function _last_second_ticket_verifications()
1919 1919
     {
1920 1920
         // don't bother re-validating if not a return visit
1921
-        if (! $this->checkout->revisit) {
1921
+        if ( ! $this->checkout->revisit) {
1922 1922
             return true;
1923 1923
         }
1924 1924
         $registrations = $this->checkout->transaction->registrations();
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
      */
1985 1985
     private function _billing_form_is_valid()
1986 1986
     {
1987
-        if (! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1987
+        if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1988 1988
             return true;
1989 1989
         }
1990 1990
         if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
@@ -2103,7 +2103,7 @@  discard block
 block discarded – undo
2103 2103
     {
2104 2104
         // convert billing form data into an attendee
2105 2105
         $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
2106
-        if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2106
+        if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2107 2107
             EE_Error::add_error(
2108 2108
                 sprintf(
2109 2109
                     esc_html__(
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
             return false;
2121 2121
         }
2122 2122
         $primary_registration = $this->checkout->transaction->primary_registration();
2123
-        if (! $primary_registration instanceof EE_Registration) {
2123
+        if ( ! $primary_registration instanceof EE_Registration) {
2124 2124
             EE_Error::add_error(
2125 2125
                 sprintf(
2126 2126
                     esc_html__(
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
             );
2137 2137
             return false;
2138 2138
         }
2139
-        if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2139
+        if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2140 2140
               instanceof
2141 2141
               EE_Attendee
2142 2142
         ) {
@@ -2182,8 +2182,8 @@  discard block
 block discarded – undo
2182 2182
             return null;
2183 2183
         }
2184 2184
         // get EE_Payment_Method object
2185
-        if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) {
2186
-            $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
2185
+        if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
2186
+            $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
2187 2187
         } else {
2188 2188
             // load EEM_Payment_Method
2189 2189
             EE_Registry::instance()->load_model('Payment_Method');
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
             $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
2193 2193
         }
2194 2194
         // verify $payment_method
2195
-        if (! $payment_method instanceof EE_Payment_Method) {
2195
+        if ( ! $payment_method instanceof EE_Payment_Method) {
2196 2196
             // not a payment
2197 2197
             EE_Error::add_error(
2198 2198
                 sprintf(
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
             return null;
2211 2211
         }
2212 2212
         // and verify it has a valid Payment_Method Type object
2213
-        if (! $payment_method->type_obj() instanceof EE_PMT_Base) {
2213
+        if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
2214 2214
             // not a payment
2215 2215
             EE_Error::add_error(
2216 2216
                 sprintf(
@@ -2248,7 +2248,7 @@  discard block
 block discarded – undo
2248 2248
         $payment = null;
2249 2249
         $this->checkout->transaction->save();
2250 2250
         $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2251
-        if (! $payment_processor instanceof EE_Payment_Processor) {
2251
+        if ( ! $payment_processor instanceof EE_Payment_Processor) {
2252 2252
             return false;
2253 2253
         }
2254 2254
         try {
@@ -2352,7 +2352,7 @@  discard block
 block discarded – undo
2352 2352
             return true;
2353 2353
         }
2354 2354
         // verify payment object
2355
-        if (! $payment instanceof EE_Payment) {
2355
+        if ( ! $payment instanceof EE_Payment) {
2356 2356
             // not a payment
2357 2357
             EE_Error::add_error(
2358 2358
                 sprintf(
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
             return true;
2393 2393
             // On-Site payment?
2394 2394
         } elseif ($this->checkout->payment_method->is_on_site()) {
2395
-            if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2395
+            if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2396 2396
                 // $this->_setup_redirect_for_next_step();
2397 2397
                 $this->checkout->continue_reg = false;
2398 2398
             }
@@ -2420,7 +2420,7 @@  discard block
 block discarded – undo
2420 2420
                     EE_Registry::instance()->CFG->organization->get_pretty('email')
2421 2421
                 );
2422 2422
                 if ($payment instanceof EE_Payment && $payment->gateway_response()) {
2423
-                    $error_message = $error_message . '<br/>' . $payment->gateway_response();
2423
+                    $error_message = $error_message.'<br/>'.$payment->gateway_response();
2424 2424
                 }
2425 2425
                 $this->checkout->continue_reg = false;
2426 2426
                 EE_Error::add_error(
@@ -2512,7 +2512,7 @@  discard block
 block discarded – undo
2512 2512
                     break;
2513 2513
                 // bad payment
2514 2514
                 case EEM_Payment::status_id_failed:
2515
-                    if (! empty($msg)) {
2515
+                    if ( ! empty($msg)) {
2516 2516
                         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2517 2517
                         return false;
2518 2518
                     }
@@ -2573,11 +2573,11 @@  discard block
 block discarded – undo
2573 2573
         // how have they chosen to pay?
2574 2574
         $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2575 2575
         // get EE_Payment_Method object
2576
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2576
+        if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2577 2577
             $this->checkout->continue_reg = false;
2578 2578
             return false;
2579 2579
         }
2580
-        if (! $this->checkout->payment_method->is_off_site()) {
2580
+        if ( ! $this->checkout->payment_method->is_off_site()) {
2581 2581
             return false;
2582 2582
         }
2583 2583
         $this->_validate_offsite_return();
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
         // verify TXN
2596 2596
         if ($this->checkout->transaction instanceof EE_Transaction) {
2597 2597
             $gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2598
-            if (! $gateway instanceof EE_Offsite_Gateway) {
2598
+            if ( ! $gateway instanceof EE_Offsite_Gateway) {
2599 2599
                 $this->checkout->continue_reg = false;
2600 2600
                 return false;
2601 2601
             }
@@ -2712,13 +2712,13 @@  discard block
 block discarded – undo
2712 2712
      */
2713 2713
     private function _redirect_wayward_request(EE_Registration $primary_registrant)
2714 2714
     {
2715
-        if (! $primary_registrant instanceof EE_Registration) {
2715
+        if ( ! $primary_registrant instanceof EE_Registration) {
2716 2716
             // try redirecting based on the current TXN
2717 2717
             $primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2718 2718
                 ? $this->checkout->transaction->primary_registration()
2719 2719
                 : null;
2720 2720
         }
2721
-        if (! $primary_registrant instanceof EE_Registration) {
2721
+        if ( ! $primary_registrant instanceof EE_Registration) {
2722 2722
             EE_Error::add_error(
2723 2723
                 sprintf(
2724 2724
                     esc_html__(
@@ -2788,7 +2788,7 @@  discard block
 block discarded – undo
2788 2788
             $payment = $this->checkout->transaction->last_payment();
2789 2789
             // $payment_source = 'last_payment after Exception';
2790 2790
             // but if we STILL don't have a payment object
2791
-            if (! $payment instanceof EE_Payment) {
2791
+            if ( ! $payment instanceof EE_Payment) {
2792 2792
                 // then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2793 2793
                 $this->_handle_payment_processor_exception($e);
2794 2794
             }
Please login to merge, or discard this patch.