@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | if (! empty($stages)) { |
13 | - foreach ($stages as $filepath) { |
|
14 | - $matches = []; |
|
15 | - preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | - } |
|
13 | + foreach ($stages as $filepath) { |
|
14 | + $matches = []; |
|
15 | + preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath); |
@@ -32,64 +32,64 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class EE_DMS_Core_4_2_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | - /** |
|
36 | - * EE_DMS_Core_4_2_0 constructor. |
|
37 | - * |
|
38 | - * @param TableManager|null $table_manager |
|
39 | - * @param TableAnalysis|null $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 = [ |
|
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 | - |
|
52 | - |
|
53 | - public function can_migrate_from_version($version_array) |
|
54 | - { |
|
55 | - $version_string = $version_array['Core']; |
|
56 | - if ( |
|
57 | - version_compare($version_string, '4.2.0.decaf', '<') && |
|
58 | - version_compare($version_string, '4.1.0.decaf', '>=') |
|
59 | - ) { |
|
60 | - // echo "$version_string can be migrated fro"; |
|
61 | - return true; |
|
62 | - } elseif (! $version_string) { |
|
63 | - // echo "no version string provided: $version_string"; |
|
64 | - // no version string provided... this must be pre 4.1 |
|
65 | - // because since 4.1 we're |
|
66 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
67 | - } else { |
|
68 | - // echo "$version_string doesnt apply"; |
|
69 | - return false; |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @throws EE_Error |
|
76 | - * @throws ReflectionException |
|
77 | - */ |
|
78 | - public function schema_changes_before_migration() |
|
79 | - { |
|
80 | - // relies on 4.1's EEH_Activation::create_table |
|
81 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
82 | - |
|
83 | - $table_name = 'esp_answer'; |
|
84 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
35 | + /** |
|
36 | + * EE_DMS_Core_4_2_0 constructor. |
|
37 | + * |
|
38 | + * @param TableManager|null $table_manager |
|
39 | + * @param TableAnalysis|null $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 = [ |
|
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 | + |
|
52 | + |
|
53 | + public function can_migrate_from_version($version_array) |
|
54 | + { |
|
55 | + $version_string = $version_array['Core']; |
|
56 | + if ( |
|
57 | + version_compare($version_string, '4.2.0.decaf', '<') && |
|
58 | + version_compare($version_string, '4.1.0.decaf', '>=') |
|
59 | + ) { |
|
60 | + // echo "$version_string can be migrated fro"; |
|
61 | + return true; |
|
62 | + } elseif (! $version_string) { |
|
63 | + // echo "no version string provided: $version_string"; |
|
64 | + // no version string provided... this must be pre 4.1 |
|
65 | + // because since 4.1 we're |
|
66 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
67 | + } else { |
|
68 | + // echo "$version_string doesnt apply"; |
|
69 | + return false; |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @throws EE_Error |
|
76 | + * @throws ReflectionException |
|
77 | + */ |
|
78 | + public function schema_changes_before_migration() |
|
79 | + { |
|
80 | + // relies on 4.1's EEH_Activation::create_table |
|
81 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
82 | + |
|
83 | + $table_name = 'esp_answer'; |
|
84 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
85 | 85 | REG_ID int(10) unsigned NOT NULL, |
86 | 86 | QST_ID int(10) unsigned NOT NULL, |
87 | 87 | ANS_value text NOT NULL, |
88 | 88 | PRIMARY KEY (ANS_ID)"; |
89 | - $this->_table_should_exist_previously($table_name, $sql); |
|
89 | + $this->_table_should_exist_previously($table_name, $sql); |
|
90 | 90 | |
91 | - $table_name = 'esp_attendee_meta'; |
|
92 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
91 | + $table_name = 'esp_attendee_meta'; |
|
92 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
93 | 93 | ATT_ID bigint(20) unsigned NOT NULL, |
94 | 94 | ATT_fname varchar(45) NOT NULL, |
95 | 95 | ATT_lname varchar(45) NOT NULL, |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | KEY ATT_fname (ATT_fname), |
106 | 106 | KEY ATT_lname (ATT_lname), |
107 | 107 | KEY ATT_email (ATT_email(191))"; |
108 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
108 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
109 | 109 | |
110 | - $table_name = 'esp_country'; |
|
111 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
110 | + $table_name = 'esp_country'; |
|
111 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
112 | 112 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
113 | 113 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
114 | 114 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | CNT_is_EU tinyint(1) DEFAULT '0', |
125 | 125 | CNT_active tinyint(1) DEFAULT '0', |
126 | 126 | PRIMARY KEY (CNT_ISO)"; |
127 | - $this->_table_should_exist_previously($table_name, $sql); |
|
127 | + $this->_table_should_exist_previously($table_name, $sql); |
|
128 | 128 | |
129 | - $table_name = 'esp_datetime'; |
|
130 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
129 | + $table_name = 'esp_datetime'; |
|
130 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
131 | 131 | EVT_ID bigint(20) unsigned NOT NULL, |
132 | 132 | DTT_name varchar(255) NOT NULL DEFAULT '', |
133 | 133 | DTT_description text NOT NULL, |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | PRIMARY KEY (DTT_ID), |
143 | 143 | KEY EVT_ID (EVT_ID), |
144 | 144 | KEY DTT_is_primary (DTT_is_primary)"; |
145 | - $this->_table_should_exist_previously($table_name, $sql); |
|
145 | + $this->_table_should_exist_previously($table_name, $sql); |
|
146 | 146 | |
147 | - $table_name = 'esp_event_meta'; |
|
148 | - $sql = " |
|
147 | + $table_name = 'esp_event_meta'; |
|
148 | + $sql = " |
|
149 | 149 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
150 | 150 | EVT_ID bigint(20) unsigned NOT NULL, |
151 | 151 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -160,35 +160,35 @@ discard block |
||
160 | 160 | EVT_external_URL varchar(200) NULL, |
161 | 161 | EVT_donations tinyint(1) NULL, |
162 | 162 | PRIMARY KEY (EVTM_ID)"; |
163 | - $this->_table_should_exist_previously($table_name, $sql); |
|
163 | + $this->_table_should_exist_previously($table_name, $sql); |
|
164 | 164 | |
165 | - $table_name = 'esp_event_question_group'; |
|
166 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | + $table_name = 'esp_event_question_group'; |
|
166 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
167 | 167 | EVT_ID bigint(20) unsigned NOT NULL, |
168 | 168 | QSG_ID int(10) unsigned NOT NULL, |
169 | 169 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
170 | 170 | PRIMARY KEY (EQG_ID)"; |
171 | - $this->_table_should_exist_previously($table_name, $sql); |
|
171 | + $this->_table_should_exist_previously($table_name, $sql); |
|
172 | 172 | |
173 | - $table_name = 'esp_event_venue'; |
|
174 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
173 | + $table_name = 'esp_event_venue'; |
|
174 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
175 | 175 | EVT_ID bigint(20) unsigned NOT NULL, |
176 | 176 | VNU_ID bigint(20) unsigned NOT NULL, |
177 | 177 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
178 | 178 | PRIMARY KEY (EVV_ID)"; |
179 | - $this->_table_should_exist_previously($table_name, $sql); |
|
179 | + $this->_table_should_exist_previously($table_name, $sql); |
|
180 | 180 | |
181 | - $table_name = 'esp_extra_meta'; |
|
182 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
181 | + $table_name = 'esp_extra_meta'; |
|
182 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
183 | 183 | OBJ_ID int(11) DEFAULT NULL, |
184 | 184 | EXM_type varchar(45) DEFAULT NULL, |
185 | 185 | EXM_key varchar(45) DEFAULT NULL, |
186 | 186 | EXM_value text, |
187 | 187 | PRIMARY KEY (EXM_ID)"; |
188 | - $this->_table_should_exist_previously($table_name, $sql); |
|
188 | + $this->_table_should_exist_previously($table_name, $sql); |
|
189 | 189 | |
190 | - $table_name = 'esp_line_item'; |
|
191 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
190 | + $table_name = 'esp_line_item'; |
|
191 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
192 | 192 | LIN_code varchar(245) NOT NULL DEFAULT '', |
193 | 193 | TXN_ID int(11) DEFAULT NULL, |
194 | 194 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -204,20 +204,20 @@ discard block |
||
204 | 204 | OBJ_ID int(11) DEFAULT NULL, |
205 | 205 | OBJ_type varchar(45)DEFAULT NULL, |
206 | 206 | PRIMARY KEY (LIN_ID)"; |
207 | - $this->_table_should_exist_previously($table_name, $sql); |
|
207 | + $this->_table_should_exist_previously($table_name, $sql); |
|
208 | 208 | |
209 | - $table_name = 'esp_message_template'; |
|
210 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
209 | + $table_name = 'esp_message_template'; |
|
210 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
211 | 211 | GRP_ID int(10) unsigned NOT NULL, |
212 | 212 | MTP_context varchar(50) NOT NULL, |
213 | 213 | MTP_template_field varchar(30) NOT NULL, |
214 | 214 | MTP_content text NOT NULL, |
215 | 215 | PRIMARY KEY (MTP_ID), |
216 | 216 | KEY GRP_ID (GRP_ID)"; |
217 | - $this->_table_should_exist_previously($table_name, $sql); |
|
217 | + $this->_table_should_exist_previously($table_name, $sql); |
|
218 | 218 | |
219 | - $table_name = 'esp_message_template_group'; |
|
220 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
219 | + $table_name = 'esp_message_template_group'; |
|
220 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
221 | 221 | EVT_ID bigint(20) unsigned DEFAULT NULL, |
222 | 222 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
223 | 223 | MTP_messenger varchar(30) NOT NULL, |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | PRIMARY KEY (GRP_ID), |
230 | 230 | KEY EVT_ID (EVT_ID), |
231 | 231 | KEY MTP_user_id (MTP_user_id)"; |
232 | - $this->_table_should_exist_previously($table_name, $sql); |
|
232 | + $this->_table_should_exist_previously($table_name, $sql); |
|
233 | 233 | |
234 | - $table_name = 'esp_payment'; |
|
235 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
234 | + $table_name = 'esp_payment'; |
|
235 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
236 | 236 | TXN_ID int(10) unsigned DEFAULT NULL, |
237 | 237 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
238 | 238 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | PRIMARY KEY (PAY_ID), |
249 | 249 | KEY TXN_ID (TXN_ID), |
250 | 250 | KEY PAY_timestamp (PAY_timestamp)"; |
251 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
251 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
252 | 252 | |
253 | - $table_name = "esp_ticket"; |
|
254 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
253 | + $table_name = "esp_ticket"; |
|
254 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
255 | 255 | TTM_ID int(10) unsigned NOT NULL, |
256 | 256 | TKT_name varchar(245) NOT NULL DEFAULT '', |
257 | 257 | TKT_description text NOT NULL, |
@@ -270,32 +270,32 @@ discard block |
||
270 | 270 | TKT_parent int(10) unsigned DEFAULT '0', |
271 | 271 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
272 | 272 | PRIMARY KEY (TKT_ID)"; |
273 | - $this->_table_should_exist_previously($table_name, $sql); |
|
273 | + $this->_table_should_exist_previously($table_name, $sql); |
|
274 | 274 | |
275 | - $table_name = "esp_ticket_price"; |
|
276 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
275 | + $table_name = "esp_ticket_price"; |
|
276 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
277 | 277 | TKT_ID int(10) unsigned NOT NULL, |
278 | 278 | PRC_ID int(10) unsigned NOT NULL, |
279 | 279 | PRIMARY KEY (TKP_ID)"; |
280 | - $this->_table_should_exist_previously($table_name, $sql); |
|
280 | + $this->_table_should_exist_previously($table_name, $sql); |
|
281 | 281 | |
282 | - $table_name = "esp_datetime_ticket"; |
|
283 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
282 | + $table_name = "esp_datetime_ticket"; |
|
283 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
284 | 284 | DTT_ID int(10) unsigned NOT NULL, |
285 | 285 | TKT_ID int(10) unsigned NOT NULL, |
286 | 286 | PRIMARY KEY (DTK_ID)"; |
287 | - $this->_table_should_exist_previously($table_name, $sql); |
|
287 | + $this->_table_should_exist_previously($table_name, $sql); |
|
288 | 288 | |
289 | - $table_name = "esp_ticket_template"; |
|
290 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
289 | + $table_name = "esp_ticket_template"; |
|
290 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
291 | 291 | TTM_name varchar(45) NOT NULL, |
292 | 292 | TTM_description text, |
293 | 293 | TTM_file varchar(45), |
294 | 294 | PRIMARY KEY (TTM_ID)"; |
295 | - $this->_table_should_exist_previously($table_name, $sql); |
|
295 | + $this->_table_should_exist_previously($table_name, $sql); |
|
296 | 296 | |
297 | - $table_name = "esp_price"; |
|
298 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
297 | + $table_name = "esp_price"; |
|
298 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
299 | 299 | PRT_ID tinyint(3) unsigned NOT NULL, |
300 | 300 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
301 | 301 | PRC_name varchar(245) NOT NULL, |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
307 | 307 | PRC_parent int(10) unsigned DEFAULT 0, |
308 | 308 | PRIMARY KEY (PRC_ID)"; |
309 | - $this->_table_should_exist_previously($table_name, $sql); |
|
309 | + $this->_table_should_exist_previously($table_name, $sql); |
|
310 | 310 | |
311 | - $table_name = "esp_price_type"; |
|
312 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
311 | + $table_name = "esp_price_type"; |
|
312 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
313 | 313 | PRT_name varchar(45) NOT NULL, |
314 | 314 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
315 | 315 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
318 | 318 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
319 | 319 | PRIMARY KEY (PRT_ID)"; |
320 | - $this->_table_should_exist_previously($table_name, $sql); |
|
320 | + $this->_table_should_exist_previously($table_name, $sql); |
|
321 | 321 | |
322 | - $table_name = 'esp_question'; |
|
323 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
322 | + $table_name = 'esp_question'; |
|
323 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
324 | 324 | QST_display_text text NOT NULL, |
325 | 325 | QST_admin_label varchar(255) NOT NULL, |
326 | 326 | QST_system varchar(25) DEFAULT NULL, |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | QST_wp_user bigint(20) unsigned NULL, |
333 | 333 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
334 | 334 | PRIMARY KEY (QST_ID)'; |
335 | - $this->_table_should_exist_previously($table_name, $sql); |
|
336 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
335 | + $this->_table_should_exist_previously($table_name, $sql); |
|
336 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
337 | 337 | |
338 | - $table_name = 'esp_question_group'; |
|
339 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
338 | + $table_name = 'esp_question_group'; |
|
339 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
340 | 340 | QSG_name varchar(255) NOT NULL, |
341 | 341 | QSG_identifier varchar(100) NOT NULL, |
342 | 342 | QSG_desc text NULL, |
@@ -347,27 +347,27 @@ discard block |
||
347 | 347 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
348 | 348 | PRIMARY KEY (QSG_ID), |
349 | 349 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
350 | - $this->_table_should_exist_previously($table_name, $sql); |
|
350 | + $this->_table_should_exist_previously($table_name, $sql); |
|
351 | 351 | |
352 | - $table_name = 'esp_question_group_question'; |
|
353 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
352 | + $table_name = 'esp_question_group_question'; |
|
353 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
354 | 354 | QSG_ID int(10) unsigned NOT NULL, |
355 | 355 | QST_ID int(10) unsigned NOT NULL, |
356 | 356 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
357 | 357 | PRIMARY KEY (QGQ_ID) "; |
358 | - $this->_table_should_exist_previously($table_name, $sql); |
|
358 | + $this->_table_should_exist_previously($table_name, $sql); |
|
359 | 359 | |
360 | - $table_name = 'esp_question_option'; |
|
361 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
360 | + $table_name = 'esp_question_option'; |
|
361 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
362 | 362 | QSO_value varchar(255) NOT NULL, |
363 | 363 | QSO_desc text NOT NULL, |
364 | 364 | QST_ID int(10) unsigned NOT NULL, |
365 | 365 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
366 | 366 | PRIMARY KEY (QSO_ID)"; |
367 | - $this->_table_should_exist_previously($table_name, $sql); |
|
367 | + $this->_table_should_exist_previously($table_name, $sql); |
|
368 | 368 | |
369 | - $table_name = 'esp_registration'; |
|
370 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
369 | + $table_name = 'esp_registration'; |
|
370 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
371 | 371 | EVT_ID bigint(20) unsigned NOT NULL, |
372 | 372 | ATT_ID bigint(20) unsigned NOT NULL, |
373 | 373 | TXN_ID int(10) unsigned NOT NULL, |
@@ -390,28 +390,28 @@ discard block |
||
390 | 390 | KEY STS_ID (STS_ID), |
391 | 391 | KEY REG_url_link (REG_url_link), |
392 | 392 | KEY REG_code (REG_code)"; |
393 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
393 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
394 | 394 | |
395 | - $table_name = 'esp_checkin'; |
|
396 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | + $table_name = 'esp_checkin'; |
|
396 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
397 | 397 | REG_ID int(10) unsigned NOT NULL, |
398 | 398 | DTT_ID int(10) unsigned NOT NULL, |
399 | 399 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
400 | 400 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
401 | 401 | PRIMARY KEY (CHK_ID)"; |
402 | - $this->_table_should_exist_previously($table_name, $sql); |
|
402 | + $this->_table_should_exist_previously($table_name, $sql); |
|
403 | 403 | |
404 | - $table_name = 'esp_state'; |
|
405 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
404 | + $table_name = 'esp_state'; |
|
405 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
406 | 406 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
407 | 407 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
408 | 408 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
409 | 409 | STA_active tinyint(1) DEFAULT '1', |
410 | 410 | PRIMARY KEY (STA_ID)"; |
411 | - $this->_table_should_exist_previously($table_name, $sql); |
|
411 | + $this->_table_should_exist_previously($table_name, $sql); |
|
412 | 412 | |
413 | - $table_name = 'esp_status'; |
|
414 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
413 | + $table_name = 'esp_status'; |
|
414 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
415 | 415 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
416 | 416 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
417 | 417 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
420 | 420 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
421 | 421 | KEY STS_type (STS_type)"; |
422 | - $this->_table_should_exist_previously($table_name, $sql); |
|
422 | + $this->_table_should_exist_previously($table_name, $sql); |
|
423 | 423 | |
424 | - $table_name = 'esp_transaction'; |
|
425 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | + $table_name = 'esp_transaction'; |
|
425 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
426 | 426 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
427 | 427 | TXN_total decimal(10,3) DEFAULT '0.00', |
428 | 428 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | PRIMARY KEY (TXN_ID), |
433 | 433 | KEY TXN_timestamp (TXN_timestamp), |
434 | 434 | KEY STS_ID (STS_ID)"; |
435 | - $this->_table_should_exist_previously($table_name, $sql); |
|
435 | + $this->_table_should_exist_previously($table_name, $sql); |
|
436 | 436 | |
437 | - $table_name = 'esp_venue_meta'; |
|
438 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
437 | + $table_name = 'esp_venue_meta'; |
|
438 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
439 | 439 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
440 | 440 | VNU_address varchar(255) DEFAULT NULL, |
441 | 441 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -453,34 +453,34 @@ discard block |
||
453 | 453 | PRIMARY KEY (VNUM_ID), |
454 | 454 | KEY STA_ID (STA_ID), |
455 | 455 | KEY CNT_ISO (CNT_ISO)"; |
456 | - $this->_table_should_exist_previously($table_name, $sql); |
|
457 | - $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
458 | - // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
459 | - // (because many need to convert old string states to foreign keys into the states table) |
|
460 | - $script_with_defaults->insert_default_states(); |
|
461 | - $script_with_defaults->insert_default_countries(); |
|
462 | - // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
463 | - $script_with_defaults->insert_default_price_types(); |
|
464 | - $script_with_defaults->insert_default_prices(); |
|
465 | - $script_with_defaults->insert_default_tickets(); |
|
466 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
467 | - EE_Config::instance()->update_espresso_config(); |
|
468 | - return true; |
|
469 | - } |
|
470 | - |
|
471 | - |
|
472 | - /** |
|
473 | - * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
474 | - * |
|
475 | - * @return boolean |
|
476 | - */ |
|
477 | - public function schema_changes_after_migration() |
|
478 | - { |
|
479 | - return true; |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - public function migration_page_hooks() |
|
484 | - { |
|
485 | - } |
|
456 | + $this->_table_should_exist_previously($table_name, $sql); |
|
457 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
458 | + // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
459 | + // (because many need to convert old string states to foreign keys into the states table) |
|
460 | + $script_with_defaults->insert_default_states(); |
|
461 | + $script_with_defaults->insert_default_countries(); |
|
462 | + // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
463 | + $script_with_defaults->insert_default_price_types(); |
|
464 | + $script_with_defaults->insert_default_prices(); |
|
465 | + $script_with_defaults->insert_default_tickets(); |
|
466 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
467 | + EE_Config::instance()->update_espresso_config(); |
|
468 | + return true; |
|
469 | + } |
|
470 | + |
|
471 | + |
|
472 | + /** |
|
473 | + * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
474 | + * |
|
475 | + * @return boolean |
|
476 | + */ |
|
477 | + public function schema_changes_after_migration() |
|
478 | + { |
|
479 | + return true; |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + public function migration_page_hooks() |
|
484 | + { |
|
485 | + } |
|
486 | 486 | } |
@@ -9,104 +9,104 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_8_0_event_subtotals extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - public function __construct() |
|
13 | - { |
|
14 | - global $wpdb; |
|
15 | - $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
16 | - $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
17 | - $this->_pretty_name = esc_html__('Event Sub-total line items', 'event_espresso'); |
|
18 | - parent::__construct(); |
|
19 | - } |
|
12 | + public function __construct() |
|
13 | + { |
|
14 | + global $wpdb; |
|
15 | + $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
16 | + $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
17 | + $this->_pretty_name = esc_html__('Event Sub-total line items', 'event_espresso'); |
|
18 | + parent::__construct(); |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @throws EE_Error |
|
24 | - */ |
|
25 | - protected function _migrate_old_row($old_row) |
|
26 | - { |
|
27 | - global $wpdb; |
|
28 | - // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
29 | - $event_id = $wpdb->get_var( |
|
30 | - $wpdb->prepare( |
|
31 | - 'SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', |
|
32 | - $old_row['TXN_ID'] |
|
33 | - ) |
|
34 | - ); |
|
22 | + /** |
|
23 | + * @throws EE_Error |
|
24 | + */ |
|
25 | + protected function _migrate_old_row($old_row) |
|
26 | + { |
|
27 | + global $wpdb; |
|
28 | + // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
29 | + $event_id = $wpdb->get_var( |
|
30 | + $wpdb->prepare( |
|
31 | + 'SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', |
|
32 | + $old_row['TXN_ID'] |
|
33 | + ) |
|
34 | + ); |
|
35 | 35 | |
36 | - $new_line_item_data = [ |
|
37 | - 'LIN_code' => 'event-' . $event_id, |
|
38 | - 'TXN_ID' => $old_row['TXN_ID'], |
|
39 | - 'LIN_name' => esc_html__('Event', 'event_espresso'), |
|
40 | - 'LIN_desc' => $old_row['LIN_desc'], |
|
41 | - 'LIN_unit_price' => $old_row['LIN_unit_price'], |
|
42 | - 'LIN_percent' => $old_row['LIN_percent'], |
|
43 | - 'LIN_is_taxable' => $old_row['LIN_is_taxable'], |
|
44 | - 'LIN_order' => $old_row['LIN_order'], |
|
45 | - 'LIN_total' => $old_row['LIN_total'], |
|
46 | - 'LIN_quantity' => $old_row['LIN_quantity'], |
|
47 | - 'LIN_parent' => $old_row['LIN_ID'], |
|
48 | - 'LIN_type' => 'sub-total', |
|
49 | - 'OBJ_type' => 'Event', |
|
50 | - 'OBJ_ID' => $event_id, |
|
51 | - ]; |
|
52 | - $new_line_item_data_types = [ |
|
53 | - '%s',// LIN_code |
|
54 | - '%d',// TXN_ID |
|
55 | - '%s',// LIN_name |
|
56 | - '%s',// LIN_desc |
|
57 | - '%f',// LIN_unit_price |
|
58 | - '%f',// LIN_percent |
|
59 | - '%d',// LIN_is_taxable |
|
60 | - '%d',// LIN_order |
|
61 | - '%f',// LIN_total |
|
62 | - '%d',// LIN_quantity |
|
63 | - '%d',// LIN_parent |
|
64 | - '%s',// LIN_type |
|
65 | - '%s',// OBJ_type |
|
66 | - '%d',// OBJ_ID |
|
67 | - ]; |
|
68 | - // insert the new event subtotal line item, pointing to this line item |
|
69 | - $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_data_types); |
|
70 | - if (! $success) { |
|
71 | - $this->add_error( |
|
72 | - $this->_create_error_message_for_db_insertion( |
|
73 | - $this->_old_table, |
|
74 | - $old_row, |
|
75 | - $this->_old_table, |
|
76 | - $new_line_item_data, |
|
77 | - $new_line_item_data_types |
|
78 | - ) |
|
79 | - ); |
|
80 | - } |
|
81 | - $new_line_item_id = $wpdb->insert_id; |
|
82 | - $this->get_migration_script()->set_mapping( |
|
83 | - $this->_old_table, |
|
84 | - $old_row['LIN_ID'], |
|
85 | - $this->_old_table, |
|
86 | - $new_line_item_id |
|
87 | - ); |
|
88 | - $query = $wpdb->prepare( |
|
89 | - "UPDATE $this->_old_table SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
90 | - $new_line_item_id, |
|
91 | - $old_row['LIN_ID'], |
|
92 | - $new_line_item_id |
|
93 | - ); |
|
94 | - $success = $wpdb->query($query); |
|
95 | - if ($success === false) { |
|
96 | - $this->add_error( |
|
97 | - sprintf( |
|
98 | - esc_html__( |
|
99 | - 'Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', |
|
100 | - 'event_espresso' |
|
101 | - ), |
|
102 | - $new_line_item_id, |
|
103 | - $old_row['LIN_ID'], |
|
104 | - $wpdb->last_error, |
|
105 | - $query, |
|
106 | - false |
|
107 | - ) |
|
108 | - ); |
|
109 | - } |
|
110 | - return 1; |
|
111 | - } |
|
36 | + $new_line_item_data = [ |
|
37 | + 'LIN_code' => 'event-' . $event_id, |
|
38 | + 'TXN_ID' => $old_row['TXN_ID'], |
|
39 | + 'LIN_name' => esc_html__('Event', 'event_espresso'), |
|
40 | + 'LIN_desc' => $old_row['LIN_desc'], |
|
41 | + 'LIN_unit_price' => $old_row['LIN_unit_price'], |
|
42 | + 'LIN_percent' => $old_row['LIN_percent'], |
|
43 | + 'LIN_is_taxable' => $old_row['LIN_is_taxable'], |
|
44 | + 'LIN_order' => $old_row['LIN_order'], |
|
45 | + 'LIN_total' => $old_row['LIN_total'], |
|
46 | + 'LIN_quantity' => $old_row['LIN_quantity'], |
|
47 | + 'LIN_parent' => $old_row['LIN_ID'], |
|
48 | + 'LIN_type' => 'sub-total', |
|
49 | + 'OBJ_type' => 'Event', |
|
50 | + 'OBJ_ID' => $event_id, |
|
51 | + ]; |
|
52 | + $new_line_item_data_types = [ |
|
53 | + '%s',// LIN_code |
|
54 | + '%d',// TXN_ID |
|
55 | + '%s',// LIN_name |
|
56 | + '%s',// LIN_desc |
|
57 | + '%f',// LIN_unit_price |
|
58 | + '%f',// LIN_percent |
|
59 | + '%d',// LIN_is_taxable |
|
60 | + '%d',// LIN_order |
|
61 | + '%f',// LIN_total |
|
62 | + '%d',// LIN_quantity |
|
63 | + '%d',// LIN_parent |
|
64 | + '%s',// LIN_type |
|
65 | + '%s',// OBJ_type |
|
66 | + '%d',// OBJ_ID |
|
67 | + ]; |
|
68 | + // insert the new event subtotal line item, pointing to this line item |
|
69 | + $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_data_types); |
|
70 | + if (! $success) { |
|
71 | + $this->add_error( |
|
72 | + $this->_create_error_message_for_db_insertion( |
|
73 | + $this->_old_table, |
|
74 | + $old_row, |
|
75 | + $this->_old_table, |
|
76 | + $new_line_item_data, |
|
77 | + $new_line_item_data_types |
|
78 | + ) |
|
79 | + ); |
|
80 | + } |
|
81 | + $new_line_item_id = $wpdb->insert_id; |
|
82 | + $this->get_migration_script()->set_mapping( |
|
83 | + $this->_old_table, |
|
84 | + $old_row['LIN_ID'], |
|
85 | + $this->_old_table, |
|
86 | + $new_line_item_id |
|
87 | + ); |
|
88 | + $query = $wpdb->prepare( |
|
89 | + "UPDATE $this->_old_table SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
90 | + $new_line_item_id, |
|
91 | + $old_row['LIN_ID'], |
|
92 | + $new_line_item_id |
|
93 | + ); |
|
94 | + $success = $wpdb->query($query); |
|
95 | + if ($success === false) { |
|
96 | + $this->add_error( |
|
97 | + sprintf( |
|
98 | + esc_html__( |
|
99 | + 'Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', |
|
100 | + 'event_espresso' |
|
101 | + ), |
|
102 | + $new_line_item_id, |
|
103 | + $old_row['LIN_ID'], |
|
104 | + $wpdb->last_error, |
|
105 | + $query, |
|
106 | + false |
|
107 | + ) |
|
108 | + ); |
|
109 | + } |
|
110 | + return 1; |
|
111 | + } |
|
112 | 112 | } |
@@ -29,108 +29,108 @@ |
||
29 | 29 | */ |
30 | 30 | abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base |
31 | 31 | { |
32 | - /** |
|
33 | - * The migration script this is a stage of |
|
34 | - * |
|
35 | - * @var EE_Data_Migration_Script_Base |
|
36 | - */ |
|
37 | - protected EE_Data_Migration_Script_Base $_migration_script; |
|
32 | + /** |
|
33 | + * The migration script this is a stage of |
|
34 | + * |
|
35 | + * @var EE_Data_Migration_Script_Base |
|
36 | + */ |
|
37 | + protected EE_Data_Migration_Script_Base $_migration_script; |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * This should eb called to essentially 'finalize' construction of the stage. |
|
42 | - * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is |
|
43 | - * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to |
|
44 | - * |
|
45 | - * @param EE_Data_Migration_Script_Base $migration_script |
|
46 | - */ |
|
47 | - public function _construct_finalize(EE_Data_Migration_Script_Base $migration_script) |
|
48 | - { |
|
49 | - $this->_migration_script = $migration_script; |
|
50 | - } |
|
40 | + /** |
|
41 | + * This should eb called to essentially 'finalize' construction of the stage. |
|
42 | + * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is |
|
43 | + * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to |
|
44 | + * |
|
45 | + * @param EE_Data_Migration_Script_Base $migration_script |
|
46 | + */ |
|
47 | + public function _construct_finalize(EE_Data_Migration_Script_Base $migration_script) |
|
48 | + { |
|
49 | + $this->_migration_script = $migration_script; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here, |
|
55 | - * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children |
|
56 | - * needs to catch exceptions and decide what's a fatal error and what isn't. |
|
57 | - * |
|
58 | - * @param int $num_items_to_migrate |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function migration_step($num_items_to_migrate = 50) |
|
62 | - { |
|
63 | - // before we run the migration step, we want ot take note of warnings that get outputted |
|
64 | - ob_start(); |
|
65 | - $items_migrated = $this->_migration_step($num_items_to_migrate); |
|
66 | - $output = ob_get_contents(); |
|
67 | - ob_end_clean(); |
|
68 | - if ($output) { |
|
69 | - $this->add_error($output); |
|
70 | - } |
|
71 | - $this->_records_migrated += $items_migrated; |
|
72 | - return $items_migrated; |
|
73 | - } |
|
53 | + /** |
|
54 | + * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here, |
|
55 | + * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children |
|
56 | + * needs to catch exceptions and decide what's a fatal error and what isn't. |
|
57 | + * |
|
58 | + * @param int $num_items_to_migrate |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function migration_step($num_items_to_migrate = 50) |
|
62 | + { |
|
63 | + // before we run the migration step, we want ot take note of warnings that get outputted |
|
64 | + ob_start(); |
|
65 | + $items_migrated = $this->_migration_step($num_items_to_migrate); |
|
66 | + $output = ob_get_contents(); |
|
67 | + ob_end_clean(); |
|
68 | + if ($output) { |
|
69 | + $this->add_error($output); |
|
70 | + } |
|
71 | + $this->_records_migrated += $items_migrated; |
|
72 | + return $items_migrated; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
78 | - * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
79 | - * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
80 | - * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
81 | - * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
82 | - * very least we MUST report/return 50 items migrated) |
|
83 | - * |
|
84 | - * @param int $num_items_to_migrate |
|
85 | - * @return int number of items ACTUALLY migrated |
|
86 | - */ |
|
87 | - abstract protected function _migration_step($num_items_to_migrate = 50); |
|
76 | + /** |
|
77 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
78 | + * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
79 | + * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
80 | + * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
81 | + * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
82 | + * very least we MUST report/return 50 items migrated) |
|
83 | + * |
|
84 | + * @param int $num_items_to_migrate |
|
85 | + * @return int number of items ACTUALLY migrated |
|
86 | + */ |
|
87 | + abstract protected function _migration_step($num_items_to_migrate = 50); |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * Counts the records that have been migrated so far |
|
92 | - * |
|
93 | - * @return int |
|
94 | - */ |
|
95 | - public function count_records_migrated(): int |
|
96 | - { |
|
97 | - return $this->_records_migrated; |
|
98 | - } |
|
90 | + /** |
|
91 | + * Counts the records that have been migrated so far |
|
92 | + * |
|
93 | + * @return int |
|
94 | + */ |
|
95 | + public function count_records_migrated(): int |
|
96 | + { |
|
97 | + return $this->_records_migrated; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | - /** |
|
102 | - * returns an array of strings describing errors |
|
103 | - * |
|
104 | - * @return array |
|
105 | - */ |
|
106 | - public function get_errors(): array |
|
107 | - { |
|
108 | - return $this->_errors; |
|
109 | - } |
|
101 | + /** |
|
102 | + * returns an array of strings describing errors |
|
103 | + * |
|
104 | + * @return array |
|
105 | + */ |
|
106 | + public function get_errors(): array |
|
107 | + { |
|
108 | + return $this->_errors; |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * Sets all the properties of this script stage to match what's in the array, which is assumed |
|
114 | - * to have been made from the properties_as_array() function. |
|
115 | - * |
|
116 | - * @param array $array_of_properties like what's produced from properties_as_array() method |
|
117 | - */ |
|
118 | - public function instantiate_from_array_of_properties($array_of_properties) |
|
119 | - { |
|
120 | - unset($array_of_properties['class']); |
|
121 | - foreach ($array_of_properties as $property_name => $property_value) { |
|
122 | - $this->{$property_name} = $property_value; |
|
123 | - } |
|
124 | - } |
|
112 | + /** |
|
113 | + * Sets all the properties of this script stage to match what's in the array, which is assumed |
|
114 | + * to have been made from the properties_as_array() function. |
|
115 | + * |
|
116 | + * @param array $array_of_properties like what's produced from properties_as_array() method |
|
117 | + */ |
|
118 | + public function instantiate_from_array_of_properties($array_of_properties) |
|
119 | + { |
|
120 | + unset($array_of_properties['class']); |
|
121 | + foreach ($array_of_properties as $property_name => $property_value) { |
|
122 | + $this->{$property_name} = $property_value; |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | 126 | |
127 | - /** |
|
128 | - * Gets the script this is a stage of |
|
129 | - * |
|
130 | - * @return EE_Data_Migration_Script_Base |
|
131 | - */ |
|
132 | - protected function get_migration_script(): EE_Data_Migration_Script_Base |
|
133 | - { |
|
134 | - return $this->_migration_script; |
|
135 | - } |
|
127 | + /** |
|
128 | + * Gets the script this is a stage of |
|
129 | + * |
|
130 | + * @return EE_Data_Migration_Script_Base |
|
131 | + */ |
|
132 | + protected function get_migration_script(): EE_Data_Migration_Script_Base |
|
133 | + { |
|
134 | + return $this->_migration_script; |
|
135 | + } |
|
136 | 136 | } |
@@ -12,80 +12,80 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_DMS_4_3_0_event_message_templates extends EE_Data_Migration_Script_Stage_Table |
14 | 14 | { |
15 | - /** |
|
16 | - * This property will hold the table name for event_message_templates |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - private string $_emt_table; |
|
15 | + /** |
|
16 | + * This property will hold the table name for event_message_templates |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + private string $_emt_table; |
|
21 | 21 | |
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - global $wpdb; |
|
26 | - $this->_pretty_name = esc_html__('Event Message Templates', 'event_espresso'); |
|
27 | - $this->_old_table = $wpdb->prefix . "esp_message_template_group"; |
|
28 | - $this->_emt_table = $wpdb->prefix . "esp_event_message_template"; |
|
29 | - parent::__construct(); |
|
30 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + global $wpdb; |
|
26 | + $this->_pretty_name = esc_html__('Event Message Templates', 'event_espresso'); |
|
27 | + $this->_old_table = $wpdb->prefix . "esp_message_template_group"; |
|
28 | + $this->_emt_table = $wpdb->prefix . "esp_event_message_template"; |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - protected function _migrate_old_row($old_row) |
|
34 | - { |
|
35 | - // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups ) |
|
36 | - global $wpdb; |
|
37 | - if ($old_row['EVT_ID'] > 0) { |
|
38 | - // let's get the EVT for this id so we can update the custom name on the old row. |
|
39 | - $event_name = 'Custom Template for ' . $wpdb->get_var( |
|
40 | - $wpdb->prepare( |
|
41 | - "SELECT post_title from $wpdb->posts WHERE ID = %d", |
|
42 | - absint( |
|
43 | - $old_row['EVT_ID'] |
|
44 | - ) |
|
45 | - ) |
|
46 | - ); |
|
33 | + protected function _migrate_old_row($old_row) |
|
34 | + { |
|
35 | + // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups ) |
|
36 | + global $wpdb; |
|
37 | + if ($old_row['EVT_ID'] > 0) { |
|
38 | + // let's get the EVT for this id so we can update the custom name on the old row. |
|
39 | + $event_name = 'Custom Template for ' . $wpdb->get_var( |
|
40 | + $wpdb->prepare( |
|
41 | + "SELECT post_title from $wpdb->posts WHERE ID = %d", |
|
42 | + absint( |
|
43 | + $old_row['EVT_ID'] |
|
44 | + ) |
|
45 | + ) |
|
46 | + ); |
|
47 | 47 | |
48 | - // update name |
|
49 | - $updated = $wpdb->update( |
|
50 | - $this->_old_table, |
|
51 | - ['MTP_name' => $event_name], |
|
52 | - ['GRP_ID' => (int) $old_row['GRP_ID']], |
|
53 | - ['%s'], |
|
54 | - ['%d'] |
|
55 | - ); |
|
48 | + // update name |
|
49 | + $updated = $wpdb->update( |
|
50 | + $this->_old_table, |
|
51 | + ['MTP_name' => $event_name], |
|
52 | + ['GRP_ID' => (int) $old_row['GRP_ID']], |
|
53 | + ['%s'], |
|
54 | + ['%d'] |
|
55 | + ); |
|
56 | 56 | |
57 | - $inserted = $wpdb->insert( |
|
58 | - $this->_emt_table, |
|
59 | - [ |
|
60 | - 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
61 | - 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
62 | - ], |
|
63 | - ['%d', '%d'] |
|
64 | - ); |
|
57 | + $inserted = $wpdb->insert( |
|
58 | + $this->_emt_table, |
|
59 | + [ |
|
60 | + 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
61 | + 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
62 | + ], |
|
63 | + ['%d', '%d'] |
|
64 | + ); |
|
65 | 65 | |
66 | - if (false === $updated) { |
|
67 | - $this->add_error( |
|
68 | - sprintf( |
|
69 | - esc_html__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), |
|
70 | - $this->_old_table, |
|
71 | - $event_name |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
66 | + if (false === $updated) { |
|
67 | + $this->add_error( |
|
68 | + sprintf( |
|
69 | + esc_html__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), |
|
70 | + $this->_old_table, |
|
71 | + $event_name |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - if (false === $inserted) { |
|
77 | - $this->add_error( |
|
78 | - sprintf( |
|
79 | - esc_html__( |
|
80 | - "Error in inserting a row into setting EVT_ID = %d and GRP_ID = %d", |
|
81 | - "event_espresso" |
|
82 | - ), |
|
83 | - $this->_emt_table, |
|
84 | - $old_row['EVT_ID'], |
|
85 | - $old_row['GRP_ID'] |
|
86 | - ) |
|
87 | - ); |
|
88 | - } |
|
89 | - } |
|
90 | - } |
|
76 | + if (false === $inserted) { |
|
77 | + $this->add_error( |
|
78 | + sprintf( |
|
79 | + esc_html__( |
|
80 | + "Error in inserting a row into setting EVT_ID = %d and GRP_ID = %d", |
|
81 | + "event_espresso" |
|
82 | + ), |
|
83 | + $this->_emt_table, |
|
84 | + $old_row['EVT_ID'], |
|
85 | + $old_row['GRP_ID'] |
|
86 | + ) |
|
87 | + ); |
|
88 | + } |
|
89 | + } |
|
90 | + } |
|
91 | 91 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | { |
25 | 25 | global $wpdb; |
26 | 26 | $this->_pretty_name = esc_html__('Event Message Templates', 'event_espresso'); |
27 | - $this->_old_table = $wpdb->prefix . "esp_message_template_group"; |
|
28 | - $this->_emt_table = $wpdb->prefix . "esp_event_message_template"; |
|
27 | + $this->_old_table = $wpdb->prefix."esp_message_template_group"; |
|
28 | + $this->_emt_table = $wpdb->prefix."esp_event_message_template"; |
|
29 | 29 | parent::__construct(); |
30 | 30 | } |
31 | 31 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | global $wpdb; |
37 | 37 | if ($old_row['EVT_ID'] > 0) { |
38 | 38 | // let's get the EVT for this id so we can update the custom name on the old row. |
39 | - $event_name = 'Custom Template for ' . $wpdb->get_var( |
|
39 | + $event_name = 'Custom Template for '.$wpdb->get_var( |
|
40 | 40 | $wpdb->prepare( |
41 | 41 | "SELECT post_title from $wpdb->posts WHERE ID = %d", |
42 | 42 | absint( |
@@ -26,128 +26,128 @@ |
||
26 | 26 | */ |
27 | 27 | class EE_DMS_4_1_0_event_venue extends EE_Data_Migration_Script_Stage |
28 | 28 | { |
29 | - /** |
|
30 | - * @throws EE_Error |
|
31 | - */ |
|
32 | - public function _migration_step($num_items_to_migrate = 50) |
|
33 | - { |
|
34 | - global $wpdb; |
|
35 | - $start_at_record = $this->count_records_migrated(); |
|
36 | - $rows = $wpdb->get_results( |
|
37 | - $wpdb->prepare( |
|
38 | - "SELECT * FROM $this->_old_table AS ev |
|
29 | + /** |
|
30 | + * @throws EE_Error |
|
31 | + */ |
|
32 | + public function _migration_step($num_items_to_migrate = 50) |
|
33 | + { |
|
34 | + global $wpdb; |
|
35 | + $start_at_record = $this->count_records_migrated(); |
|
36 | + $rows = $wpdb->get_results( |
|
37 | + $wpdb->prepare( |
|
38 | + "SELECT * FROM $this->_old_table AS ev |
|
39 | 39 | INNER JOIN " . $wpdb->prefix . "events_detail AS e ON ev.event_id=e.id |
40 | 40 | WHERE e.event_status!='D' LIMIT %d,%d", |
41 | - $start_at_record, |
|
42 | - $num_items_to_migrate |
|
43 | - ), |
|
44 | - ARRAY_A |
|
45 | - ); |
|
46 | - $items_actually_migrated = 0; |
|
47 | - foreach ($rows as $event_venue_rel) { |
|
48 | - $this->_insert_new_event_to_venue_rel($event_venue_rel); |
|
49 | - $items_actually_migrated++; |
|
50 | - } |
|
51 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
52 | - $this->set_completed(); |
|
53 | - } |
|
54 | - return $items_actually_migrated; |
|
55 | - } |
|
41 | + $start_at_record, |
|
42 | + $num_items_to_migrate |
|
43 | + ), |
|
44 | + ARRAY_A |
|
45 | + ); |
|
46 | + $items_actually_migrated = 0; |
|
47 | + foreach ($rows as $event_venue_rel) { |
|
48 | + $this->_insert_new_event_to_venue_rel($event_venue_rel); |
|
49 | + $items_actually_migrated++; |
|
50 | + } |
|
51 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
52 | + $this->set_completed(); |
|
53 | + } |
|
54 | + return $items_actually_migrated; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - public function _count_records_to_migrate() |
|
59 | - { |
|
60 | - global $wpdb; |
|
61 | - return $wpdb->get_var( |
|
62 | - "SELECT COUNT(ev.id) FROM " . $this->_old_table . " AS ev |
|
58 | + public function _count_records_to_migrate() |
|
59 | + { |
|
60 | + global $wpdb; |
|
61 | + return $wpdb->get_var( |
|
62 | + "SELECT COUNT(ev.id) FROM " . $this->_old_table . " AS ev |
|
63 | 63 | INNER JOIN " . $wpdb->prefix . 'events_detail AS e ON ev.event_id=e.id |
64 | 64 | WHERE e.event_status!="D"' |
65 | - ); |
|
66 | - } |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - public function __construct() |
|
70 | - { |
|
71 | - global $wpdb; |
|
72 | - $this->_old_table = $wpdb->prefix . "events_venue_rel"; |
|
73 | - $this->_new_table = $wpdb->prefix . "esp_event_venue"; |
|
74 | - $this->_pretty_name = esc_html__("Event to Venue Relations", "event_espresso"); |
|
75 | - parent::__construct(); |
|
76 | - } |
|
69 | + public function __construct() |
|
70 | + { |
|
71 | + global $wpdb; |
|
72 | + $this->_old_table = $wpdb->prefix . "events_venue_rel"; |
|
73 | + $this->_new_table = $wpdb->prefix . "esp_event_venue"; |
|
74 | + $this->_pretty_name = esc_html__("Event to Venue Relations", "event_espresso"); |
|
75 | + parent::__construct(); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * Attempts to insert a new question group in the new format given an old one |
|
81 | - * |
|
82 | - * @param array $old_event_venue_rel |
|
83 | - * @return void |
|
84 | - * @throws EE_Error |
|
85 | - * @global wpdb $wpdb |
|
86 | - */ |
|
87 | - private function _insert_new_event_to_venue_rel(array $old_event_venue_rel): void |
|
88 | - { |
|
89 | - global $wpdb; |
|
90 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
|
91 | - $wpdb->prefix . "events_detail", |
|
92 | - $old_event_venue_rel['event_id'], |
|
93 | - $wpdb->prefix . "posts" |
|
94 | - ); |
|
95 | - $new_venue_id = $this->get_migration_script()->get_mapping_new_pk( |
|
96 | - $wpdb->prefix . "events_venue", |
|
97 | - $old_event_venue_rel['venue_id'], |
|
98 | - $wpdb->prefix . "posts" |
|
99 | - ); |
|
100 | - if (! $new_event_id) { |
|
101 | - $this->add_error( |
|
102 | - sprintf( |
|
103 | - esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), |
|
104 | - $old_event_venue_rel['event_id'] |
|
105 | - ) |
|
106 | - ); |
|
107 | - return; |
|
108 | - } |
|
109 | - if (! $new_venue_id) { |
|
110 | - $this->add_error( |
|
111 | - sprintf( |
|
112 | - esc_html__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), |
|
113 | - $old_event_venue_rel['venue_id'] |
|
114 | - ) |
|
115 | - ); |
|
116 | - return; |
|
117 | - } |
|
118 | - // first ensure there are no other relation entries for this event |
|
119 | - // because although EE4 supports it, EE3 didn't really |
|
120 | - $wpdb->delete( |
|
121 | - $this->_new_table, |
|
122 | - [ |
|
123 | - 'EVT_ID' => $new_event_id, |
|
124 | - ], |
|
125 | - [ |
|
126 | - '%d',// EVT_ID |
|
127 | - ] |
|
128 | - ); |
|
129 | - // echo "last query". $wpdb->last_query;die; |
|
130 | - $cols_n_values = [ |
|
131 | - 'EVT_ID' => $new_event_id, |
|
132 | - 'VNU_ID' => $new_venue_id, |
|
133 | - 'EVV_primary' => true, |
|
134 | - ]; |
|
135 | - $data_types = [ |
|
136 | - '%d',// EVT_ID |
|
137 | - '%d',// VNU_ID |
|
138 | - '%d',// EVT_primary |
|
139 | - ]; |
|
140 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $data_types); |
|
141 | - if (! $success) { |
|
142 | - $this->add_error( |
|
143 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
144 | - $this->_old_table, |
|
145 | - $old_event_venue_rel, |
|
146 | - $this->_new_table, |
|
147 | - $cols_n_values, |
|
148 | - $data_types |
|
149 | - ) |
|
150 | - ); |
|
151 | - } |
|
152 | - } |
|
79 | + /** |
|
80 | + * Attempts to insert a new question group in the new format given an old one |
|
81 | + * |
|
82 | + * @param array $old_event_venue_rel |
|
83 | + * @return void |
|
84 | + * @throws EE_Error |
|
85 | + * @global wpdb $wpdb |
|
86 | + */ |
|
87 | + private function _insert_new_event_to_venue_rel(array $old_event_venue_rel): void |
|
88 | + { |
|
89 | + global $wpdb; |
|
90 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
|
91 | + $wpdb->prefix . "events_detail", |
|
92 | + $old_event_venue_rel['event_id'], |
|
93 | + $wpdb->prefix . "posts" |
|
94 | + ); |
|
95 | + $new_venue_id = $this->get_migration_script()->get_mapping_new_pk( |
|
96 | + $wpdb->prefix . "events_venue", |
|
97 | + $old_event_venue_rel['venue_id'], |
|
98 | + $wpdb->prefix . "posts" |
|
99 | + ); |
|
100 | + if (! $new_event_id) { |
|
101 | + $this->add_error( |
|
102 | + sprintf( |
|
103 | + esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), |
|
104 | + $old_event_venue_rel['event_id'] |
|
105 | + ) |
|
106 | + ); |
|
107 | + return; |
|
108 | + } |
|
109 | + if (! $new_venue_id) { |
|
110 | + $this->add_error( |
|
111 | + sprintf( |
|
112 | + esc_html__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), |
|
113 | + $old_event_venue_rel['venue_id'] |
|
114 | + ) |
|
115 | + ); |
|
116 | + return; |
|
117 | + } |
|
118 | + // first ensure there are no other relation entries for this event |
|
119 | + // because although EE4 supports it, EE3 didn't really |
|
120 | + $wpdb->delete( |
|
121 | + $this->_new_table, |
|
122 | + [ |
|
123 | + 'EVT_ID' => $new_event_id, |
|
124 | + ], |
|
125 | + [ |
|
126 | + '%d',// EVT_ID |
|
127 | + ] |
|
128 | + ); |
|
129 | + // echo "last query". $wpdb->last_query;die; |
|
130 | + $cols_n_values = [ |
|
131 | + 'EVT_ID' => $new_event_id, |
|
132 | + 'VNU_ID' => $new_venue_id, |
|
133 | + 'EVV_primary' => true, |
|
134 | + ]; |
|
135 | + $data_types = [ |
|
136 | + '%d',// EVT_ID |
|
137 | + '%d',// VNU_ID |
|
138 | + '%d',// EVT_primary |
|
139 | + ]; |
|
140 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $data_types); |
|
141 | + if (! $success) { |
|
142 | + $this->add_error( |
|
143 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
144 | + $this->_old_table, |
|
145 | + $old_event_venue_rel, |
|
146 | + $this->_new_table, |
|
147 | + $cols_n_values, |
|
148 | + $data_types |
|
149 | + ) |
|
150 | + ); |
|
151 | + } |
|
152 | + } |
|
153 | 153 | } |
@@ -26,136 +26,136 @@ |
||
26 | 26 | */ |
27 | 27 | class EE_DMS_4_1_0_event_category extends EE_Data_Migration_Script_Stage |
28 | 28 | { |
29 | - /** |
|
30 | - * @throws EE_Error |
|
31 | - */ |
|
32 | - public function _migration_step($num_items_to_migrate = 50) |
|
33 | - { |
|
34 | - global $wpdb; |
|
35 | - $start_at_record = $this->count_records_migrated(); |
|
36 | - $rows = |
|
37 | - $wpdb->get_results( |
|
38 | - $wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items_to_migrate), |
|
39 | - ARRAY_A |
|
40 | - ); |
|
41 | - $items_actually_migrated = 0; |
|
42 | - foreach ($rows as $event_venue_rel) { |
|
43 | - $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel); |
|
44 | - if ($term_relation_id) { |
|
45 | - $this->get_migration_script()->set_mapping( |
|
46 | - $this->_old_table, |
|
47 | - $event_venue_rel['id'], |
|
48 | - $this->_new_table, |
|
49 | - $term_relation_id |
|
50 | - ); |
|
51 | - } |
|
52 | - $items_actually_migrated++; |
|
53 | - } |
|
54 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
55 | - $this->set_completed(); |
|
56 | - } |
|
57 | - return $items_actually_migrated; |
|
58 | - } |
|
29 | + /** |
|
30 | + * @throws EE_Error |
|
31 | + */ |
|
32 | + public function _migration_step($num_items_to_migrate = 50) |
|
33 | + { |
|
34 | + global $wpdb; |
|
35 | + $start_at_record = $this->count_records_migrated(); |
|
36 | + $rows = |
|
37 | + $wpdb->get_results( |
|
38 | + $wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items_to_migrate), |
|
39 | + ARRAY_A |
|
40 | + ); |
|
41 | + $items_actually_migrated = 0; |
|
42 | + foreach ($rows as $event_venue_rel) { |
|
43 | + $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel); |
|
44 | + if ($term_relation_id) { |
|
45 | + $this->get_migration_script()->set_mapping( |
|
46 | + $this->_old_table, |
|
47 | + $event_venue_rel['id'], |
|
48 | + $this->_new_table, |
|
49 | + $term_relation_id |
|
50 | + ); |
|
51 | + } |
|
52 | + $items_actually_migrated++; |
|
53 | + } |
|
54 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
55 | + $this->set_completed(); |
|
56 | + } |
|
57 | + return $items_actually_migrated; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - public function _count_records_to_migrate() |
|
62 | - { |
|
63 | - global $wpdb; |
|
64 | - return $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
65 | - } |
|
61 | + public function _count_records_to_migrate() |
|
62 | + { |
|
63 | + global $wpdb; |
|
64 | + return $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - public function __construct() |
|
69 | - { |
|
70 | - global $wpdb; |
|
71 | - $this->_old_table = $wpdb->prefix . "events_category_rel"; |
|
72 | - $this->_new_table = $wpdb->prefix . "term_relationships"; |
|
73 | - $this->_pretty_name = esc_html__("Event to Category (4.1 Term Relationships)", "event_espresso"); |
|
74 | - parent::__construct(); |
|
75 | - } |
|
68 | + public function __construct() |
|
69 | + { |
|
70 | + global $wpdb; |
|
71 | + $this->_old_table = $wpdb->prefix . "events_category_rel"; |
|
72 | + $this->_new_table = $wpdb->prefix . "term_relationships"; |
|
73 | + $this->_pretty_name = esc_html__("Event to Category (4.1 Term Relationships)", "event_espresso"); |
|
74 | + parent::__construct(); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * Attempts to insert a new question group in the new format given an old one |
|
80 | - * |
|
81 | - * @param array $old_event_cat_relation |
|
82 | - * @return int |
|
83 | - * @throws EE_Error |
|
84 | - * @global wpdb $wpdb |
|
85 | - */ |
|
86 | - private function _add_relation_from_event_to_term_taxonomy(array $old_event_cat_relation): int |
|
87 | - { |
|
88 | - global $wpdb; |
|
89 | - $new_event_id = |
|
90 | - $this->get_migration_script()->get_mapping_new_pk( |
|
91 | - $wpdb->prefix . "events_detail", |
|
92 | - intval($old_event_cat_relation['event_id']), |
|
93 | - $wpdb->prefix . "posts" |
|
94 | - ); |
|
95 | - $new_term_taxonomy_id = |
|
96 | - $this->get_migration_script()->get_mapping_new_pk( |
|
97 | - $wpdb->prefix . "events_category_detail", |
|
98 | - intval($old_event_cat_relation['cat_id']), |
|
99 | - $wpdb->prefix . "term_taxonomy" |
|
100 | - ); |
|
101 | - if (! $new_event_id) { |
|
102 | - $this->add_error( |
|
103 | - sprintf( |
|
104 | - esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), |
|
105 | - $old_event_cat_relation['event_id'] |
|
106 | - ) |
|
107 | - ); |
|
108 | - return 0; |
|
109 | - } |
|
110 | - if (! $new_term_taxonomy_id) { |
|
111 | - $this->add_error( |
|
112 | - sprintf( |
|
113 | - esc_html__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), |
|
114 | - $old_event_cat_relation['cat_id'] |
|
115 | - ) |
|
116 | - ); |
|
117 | - return 0; |
|
118 | - } |
|
119 | - $cols_n_values = [ |
|
120 | - 'object_id' => $new_event_id, |
|
121 | - 'term_taxonomy_id' => $new_term_taxonomy_id, |
|
122 | - 'term_order' => 0, |
|
123 | - ]; |
|
124 | - $data_types = [ |
|
125 | - '%d',// object_id |
|
126 | - '%d',// term_taxonomy_id |
|
127 | - '%d',// term_order |
|
128 | - ]; |
|
129 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $data_types); |
|
130 | - if (! $success) { |
|
131 | - $this->add_error( |
|
132 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
133 | - $this->_old_table, |
|
134 | - $old_event_cat_relation, |
|
135 | - $this->_new_table, |
|
136 | - $cols_n_values, |
|
137 | - $data_types |
|
138 | - ) |
|
139 | - ); |
|
140 | - return 0; |
|
141 | - } else { |
|
142 | - // increment the term-taxonomies count |
|
143 | - $success = |
|
144 | - $wpdb->query( |
|
145 | - $wpdb->prepare( |
|
146 | - "UPDATE $wpdb->term_taxonomy SET count = count +1 WHERE term_taxonomy_id=%d", |
|
147 | - $new_term_taxonomy_id |
|
148 | - ) |
|
149 | - ); |
|
150 | - if (! $success) { |
|
151 | - $this->add_error( |
|
152 | - sprintf( |
|
153 | - esc_html__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), |
|
154 | - $wpdb->last_error |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
158 | - } |
|
159 | - return $wpdb->insert_id; |
|
160 | - } |
|
78 | + /** |
|
79 | + * Attempts to insert a new question group in the new format given an old one |
|
80 | + * |
|
81 | + * @param array $old_event_cat_relation |
|
82 | + * @return int |
|
83 | + * @throws EE_Error |
|
84 | + * @global wpdb $wpdb |
|
85 | + */ |
|
86 | + private function _add_relation_from_event_to_term_taxonomy(array $old_event_cat_relation): int |
|
87 | + { |
|
88 | + global $wpdb; |
|
89 | + $new_event_id = |
|
90 | + $this->get_migration_script()->get_mapping_new_pk( |
|
91 | + $wpdb->prefix . "events_detail", |
|
92 | + intval($old_event_cat_relation['event_id']), |
|
93 | + $wpdb->prefix . "posts" |
|
94 | + ); |
|
95 | + $new_term_taxonomy_id = |
|
96 | + $this->get_migration_script()->get_mapping_new_pk( |
|
97 | + $wpdb->prefix . "events_category_detail", |
|
98 | + intval($old_event_cat_relation['cat_id']), |
|
99 | + $wpdb->prefix . "term_taxonomy" |
|
100 | + ); |
|
101 | + if (! $new_event_id) { |
|
102 | + $this->add_error( |
|
103 | + sprintf( |
|
104 | + esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), |
|
105 | + $old_event_cat_relation['event_id'] |
|
106 | + ) |
|
107 | + ); |
|
108 | + return 0; |
|
109 | + } |
|
110 | + if (! $new_term_taxonomy_id) { |
|
111 | + $this->add_error( |
|
112 | + sprintf( |
|
113 | + esc_html__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), |
|
114 | + $old_event_cat_relation['cat_id'] |
|
115 | + ) |
|
116 | + ); |
|
117 | + return 0; |
|
118 | + } |
|
119 | + $cols_n_values = [ |
|
120 | + 'object_id' => $new_event_id, |
|
121 | + 'term_taxonomy_id' => $new_term_taxonomy_id, |
|
122 | + 'term_order' => 0, |
|
123 | + ]; |
|
124 | + $data_types = [ |
|
125 | + '%d',// object_id |
|
126 | + '%d',// term_taxonomy_id |
|
127 | + '%d',// term_order |
|
128 | + ]; |
|
129 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $data_types); |
|
130 | + if (! $success) { |
|
131 | + $this->add_error( |
|
132 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
133 | + $this->_old_table, |
|
134 | + $old_event_cat_relation, |
|
135 | + $this->_new_table, |
|
136 | + $cols_n_values, |
|
137 | + $data_types |
|
138 | + ) |
|
139 | + ); |
|
140 | + return 0; |
|
141 | + } else { |
|
142 | + // increment the term-taxonomies count |
|
143 | + $success = |
|
144 | + $wpdb->query( |
|
145 | + $wpdb->prepare( |
|
146 | + "UPDATE $wpdb->term_taxonomy SET count = count +1 WHERE term_taxonomy_id=%d", |
|
147 | + $new_term_taxonomy_id |
|
148 | + ) |
|
149 | + ); |
|
150 | + if (! $success) { |
|
151 | + $this->add_error( |
|
152 | + sprintf( |
|
153 | + esc_html__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), |
|
154 | + $wpdb->last_error |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | + } |
|
159 | + return $wpdb->insert_id; |
|
160 | + } |
|
161 | 161 | } |
@@ -44,251 +44,251 @@ |
||
44 | 44 | */ |
45 | 45 | class EE_DMS_4_1_0_line_items extends EE_Data_Migration_Script_Stage_Table |
46 | 46 | { |
47 | - private string $_new_line_table; |
|
47 | + private string $_new_line_table; |
|
48 | 48 | |
49 | - private string $_new_transaction_table; |
|
49 | + private string $_new_transaction_table; |
|
50 | 50 | |
51 | - private string $_new_reg_table; |
|
51 | + private string $_new_reg_table; |
|
52 | 52 | |
53 | 53 | |
54 | - public function __construct() |
|
55 | - { |
|
56 | - global $wpdb; |
|
57 | - $this->_pretty_name = esc_html__("Line Items", "event_espresso"); |
|
58 | - $this->_old_table = $wpdb->prefix . "events_attendee"; |
|
59 | - $this->select_expression = 'att.*, e.event_status'; |
|
60 | - $this->_extra_where_sql = ' AS att |
|
54 | + public function __construct() |
|
55 | + { |
|
56 | + global $wpdb; |
|
57 | + $this->_pretty_name = esc_html__("Line Items", "event_espresso"); |
|
58 | + $this->_old_table = $wpdb->prefix . "events_attendee"; |
|
59 | + $this->select_expression = 'att.*, e.event_status'; |
|
60 | + $this->_extra_where_sql = ' AS att |
|
61 | 61 | INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id=e.id |
62 | 62 | WHERE e.event_status!="D"'; |
63 | - $this->_new_transaction_table = $wpdb->prefix . "esp_transaction"; |
|
64 | - $this->_new_line_table = $wpdb->prefix . "esp_line_item"; |
|
65 | - $this->_new_reg_table = $wpdb->prefix . "esp_registration"; |
|
66 | - parent::__construct(); |
|
67 | - } |
|
63 | + $this->_new_transaction_table = $wpdb->prefix . "esp_transaction"; |
|
64 | + $this->_new_line_table = $wpdb->prefix . "esp_line_item"; |
|
65 | + $this->_new_reg_table = $wpdb->prefix . "esp_registration"; |
|
66 | + parent::__construct(); |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * @throws EE_Error |
|
72 | - */ |
|
73 | - protected function _migrate_old_row($old_row) |
|
74 | - { |
|
75 | - // insert line items if its a primary id |
|
76 | - if ((int) $old_row['is_primary']) { |
|
77 | - $txn_id = (int) $this->get_migration_script()->get_mapping_new_pk( |
|
78 | - $this->_old_table, |
|
79 | - $old_row['id'], |
|
80 | - $this->_new_transaction_table |
|
81 | - ); |
|
82 | - if (! $txn_id) { |
|
83 | - $this->add_error( |
|
84 | - sprintf( |
|
85 | - esc_html__( |
|
86 | - "Could not find the transaction for the 3.1 attendee %d from row %s", |
|
87 | - "event_espresso" |
|
88 | - ), |
|
89 | - $old_row['id'], |
|
90 | - $this->_json_encode($old_row) |
|
91 | - ) |
|
92 | - ); |
|
93 | - return; |
|
94 | - } |
|
95 | - $txn = $this->_get_txn($txn_id); |
|
96 | - $new_line_items = $this->_insert_new_line_items($txn, $old_row); |
|
97 | - $this->get_migration_script()->set_mapping( |
|
98 | - $this->_old_table, |
|
99 | - $old_row['id'], |
|
100 | - $this->_new_line_table, |
|
101 | - $new_line_items |
|
102 | - ); |
|
103 | - } |
|
104 | - } |
|
70 | + /** |
|
71 | + * @throws EE_Error |
|
72 | + */ |
|
73 | + protected function _migrate_old_row($old_row) |
|
74 | + { |
|
75 | + // insert line items if its a primary id |
|
76 | + if ((int) $old_row['is_primary']) { |
|
77 | + $txn_id = (int) $this->get_migration_script()->get_mapping_new_pk( |
|
78 | + $this->_old_table, |
|
79 | + $old_row['id'], |
|
80 | + $this->_new_transaction_table |
|
81 | + ); |
|
82 | + if (! $txn_id) { |
|
83 | + $this->add_error( |
|
84 | + sprintf( |
|
85 | + esc_html__( |
|
86 | + "Could not find the transaction for the 3.1 attendee %d from row %s", |
|
87 | + "event_espresso" |
|
88 | + ), |
|
89 | + $old_row['id'], |
|
90 | + $this->_json_encode($old_row) |
|
91 | + ) |
|
92 | + ); |
|
93 | + return; |
|
94 | + } |
|
95 | + $txn = $this->_get_txn($txn_id); |
|
96 | + $new_line_items = $this->_insert_new_line_items($txn, $old_row); |
|
97 | + $this->get_migration_script()->set_mapping( |
|
98 | + $this->_old_table, |
|
99 | + $old_row['id'], |
|
100 | + $this->_new_line_table, |
|
101 | + $new_line_items |
|
102 | + ); |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - private function _get_txn(int $txn_id) |
|
108 | - { |
|
109 | - global $wpdb; |
|
110 | - return $wpdb->get_row( |
|
111 | - $wpdb->prepare( |
|
112 | - "SELECT * FROM $this->_new_transaction_table WHERE TXN_ID=%d", |
|
113 | - $txn_id |
|
114 | - ), |
|
115 | - ARRAY_A |
|
116 | - ); |
|
117 | - } |
|
107 | + private function _get_txn(int $txn_id) |
|
108 | + { |
|
109 | + global $wpdb; |
|
110 | + return $wpdb->get_row( |
|
111 | + $wpdb->prepare( |
|
112 | + "SELECT * FROM $this->_new_transaction_table WHERE TXN_ID=%d", |
|
113 | + $txn_id |
|
114 | + ), |
|
115 | + ARRAY_A |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | |
119 | 119 | |
120 | - /** |
|
121 | - * In 4.1, we'd normally need more info than just the registrations to make the line items. Ie, we'd need |
|
122 | - * the transaction, and tax prices at the time of registration. (And probably promotions and other price factors). |
|
123 | - * But seeing how these are REGs created from 3.1 attendee data, which have |
|
124 | - * |
|
125 | - * @param array $transaction |
|
126 | - * @param array $old_attendee |
|
127 | - * @return array new line item ids |
|
128 | - */ |
|
129 | - private function _insert_new_line_items(array $transaction, array $old_attendee): array |
|
130 | - { |
|
131 | - global $wpdb; |
|
132 | - $regs_on_this_transaction = $wpdb->get_results( |
|
133 | - $wpdb->prepare( |
|
134 | - "SELECT * FROM $this->_new_reg_table WHERE TXN_ID=%d", |
|
135 | - $transaction['TXN_ID'] |
|
136 | - ), |
|
137 | - ARRAY_A |
|
138 | - ); |
|
139 | - $new_line_item_ids = []; |
|
140 | - // create a total ine item |
|
141 | - $total_line_item_id = $this->_insert_new_line_item( |
|
142 | - [ |
|
143 | - 'LIN_code' => 'total', |
|
144 | - 'TXN_ID' => $transaction['TXN_ID'], |
|
145 | - 'LIN_name' => esc_html__( |
|
146 | - "Total", |
|
147 | - "event_espresso" |
|
148 | - ), |
|
149 | - 'LIN_total' => $transaction['TXN_total'], |
|
150 | - 'LIN_type' => 'total', |
|
151 | - 'OBJ_ID' => $transaction['TXN_ID'], |
|
152 | - 'OBJ_type' => 'Transaction', |
|
153 | - ], |
|
154 | - $old_attendee |
|
155 | - ); |
|
156 | - $new_line_item_ids[] = $total_line_item_id; |
|
157 | - // create a subtotal line item |
|
158 | - $reg_total = 0; |
|
159 | - foreach ($regs_on_this_transaction as $new_reg) { |
|
160 | - $reg_total += floatval($new_reg['REG_final_price']); |
|
161 | - } |
|
162 | - $subtotal_line_item_id = $this->_insert_new_line_item( |
|
163 | - [ |
|
164 | - 'LIN_code' => 'sub-total', |
|
165 | - 'TXN_ID' => $transaction['TXN_ID'], |
|
166 | - 'LIN_name' => esc_html__( |
|
167 | - "Subtotal", |
|
168 | - "event_espresso" |
|
169 | - ), |
|
170 | - 'LIN_total' => $reg_total, |
|
171 | - 'LIN_parent' => $total_line_item_id, |
|
172 | - 'LIN_type' => 'sub-total', |
|
173 | - ], |
|
174 | - $old_attendee |
|
175 | - ); |
|
176 | - $new_line_item_ids[] = $subtotal_line_item_id; |
|
177 | - // group REGs by TKT_ID |
|
178 | - $regs_by_tkt = []; |
|
179 | - foreach ($regs_on_this_transaction as $new_reg) { |
|
180 | - $regs_by_tkt[ $new_reg['TKT_ID'] ][] = $new_reg; |
|
181 | - } |
|
120 | + /** |
|
121 | + * In 4.1, we'd normally need more info than just the registrations to make the line items. Ie, we'd need |
|
122 | + * the transaction, and tax prices at the time of registration. (And probably promotions and other price factors). |
|
123 | + * But seeing how these are REGs created from 3.1 attendee data, which have |
|
124 | + * |
|
125 | + * @param array $transaction |
|
126 | + * @param array $old_attendee |
|
127 | + * @return array new line item ids |
|
128 | + */ |
|
129 | + private function _insert_new_line_items(array $transaction, array $old_attendee): array |
|
130 | + { |
|
131 | + global $wpdb; |
|
132 | + $regs_on_this_transaction = $wpdb->get_results( |
|
133 | + $wpdb->prepare( |
|
134 | + "SELECT * FROM $this->_new_reg_table WHERE TXN_ID=%d", |
|
135 | + $transaction['TXN_ID'] |
|
136 | + ), |
|
137 | + ARRAY_A |
|
138 | + ); |
|
139 | + $new_line_item_ids = []; |
|
140 | + // create a total ine item |
|
141 | + $total_line_item_id = $this->_insert_new_line_item( |
|
142 | + [ |
|
143 | + 'LIN_code' => 'total', |
|
144 | + 'TXN_ID' => $transaction['TXN_ID'], |
|
145 | + 'LIN_name' => esc_html__( |
|
146 | + "Total", |
|
147 | + "event_espresso" |
|
148 | + ), |
|
149 | + 'LIN_total' => $transaction['TXN_total'], |
|
150 | + 'LIN_type' => 'total', |
|
151 | + 'OBJ_ID' => $transaction['TXN_ID'], |
|
152 | + 'OBJ_type' => 'Transaction', |
|
153 | + ], |
|
154 | + $old_attendee |
|
155 | + ); |
|
156 | + $new_line_item_ids[] = $total_line_item_id; |
|
157 | + // create a subtotal line item |
|
158 | + $reg_total = 0; |
|
159 | + foreach ($regs_on_this_transaction as $new_reg) { |
|
160 | + $reg_total += floatval($new_reg['REG_final_price']); |
|
161 | + } |
|
162 | + $subtotal_line_item_id = $this->_insert_new_line_item( |
|
163 | + [ |
|
164 | + 'LIN_code' => 'sub-total', |
|
165 | + 'TXN_ID' => $transaction['TXN_ID'], |
|
166 | + 'LIN_name' => esc_html__( |
|
167 | + "Subtotal", |
|
168 | + "event_espresso" |
|
169 | + ), |
|
170 | + 'LIN_total' => $reg_total, |
|
171 | + 'LIN_parent' => $total_line_item_id, |
|
172 | + 'LIN_type' => 'sub-total', |
|
173 | + ], |
|
174 | + $old_attendee |
|
175 | + ); |
|
176 | + $new_line_item_ids[] = $subtotal_line_item_id; |
|
177 | + // group REGs by TKT_ID |
|
178 | + $regs_by_tkt = []; |
|
179 | + foreach ($regs_on_this_transaction as $new_reg) { |
|
180 | + $regs_by_tkt[ $new_reg['TKT_ID'] ][] = $new_reg; |
|
181 | + } |
|
182 | 182 | |
183 | - // create individual line items |
|
183 | + // create individual line items |
|
184 | 184 | |
185 | - foreach ($regs_by_tkt as $ticket_id => $regs) { |
|
186 | - $count = count($regs); |
|
187 | - $line_total = 0; |
|
188 | - foreach ($regs as $new_reg) { |
|
189 | - $line_total += $new_reg['REG_final_price']; |
|
190 | - } |
|
191 | - $a_reg = reset($regs); |
|
192 | - $new_ticket = $this->_get_new_ticket_row($a_reg['TKT_ID']); |
|
193 | - $reg_line_item_id = $this->_insert_new_line_item( |
|
194 | - [ |
|
195 | - 'LIN_code' => md5( |
|
196 | - 'Ticket' . $ticket_id . time() |
|
197 | - ), |
|
198 | - 'TXN_ID' => $transaction['TXN_ID'], |
|
199 | - 'LIN_name' => $new_ticket['TKT_name'], |
|
200 | - 'LIN_unit_price' => $a_reg['REG_final_price'], |
|
201 | - 'LIN_is_taxable' => false, |
|
202 | - 'LIN_total' => $line_total, |
|
203 | - 'LIN_quantity' => $count, |
|
204 | - 'LIN_parent' => $subtotal_line_item_id, |
|
205 | - 'OBJ_ID' => $ticket_id, |
|
206 | - 'OBJ_type' => 'Ticket', |
|
207 | - ], |
|
208 | - $old_attendee |
|
209 | - ); |
|
210 | - $new_line_item_ids[] = $reg_line_item_id; |
|
211 | - } |
|
185 | + foreach ($regs_by_tkt as $ticket_id => $regs) { |
|
186 | + $count = count($regs); |
|
187 | + $line_total = 0; |
|
188 | + foreach ($regs as $new_reg) { |
|
189 | + $line_total += $new_reg['REG_final_price']; |
|
190 | + } |
|
191 | + $a_reg = reset($regs); |
|
192 | + $new_ticket = $this->_get_new_ticket_row($a_reg['TKT_ID']); |
|
193 | + $reg_line_item_id = $this->_insert_new_line_item( |
|
194 | + [ |
|
195 | + 'LIN_code' => md5( |
|
196 | + 'Ticket' . $ticket_id . time() |
|
197 | + ), |
|
198 | + 'TXN_ID' => $transaction['TXN_ID'], |
|
199 | + 'LIN_name' => $new_ticket['TKT_name'], |
|
200 | + 'LIN_unit_price' => $a_reg['REG_final_price'], |
|
201 | + 'LIN_is_taxable' => false, |
|
202 | + 'LIN_total' => $line_total, |
|
203 | + 'LIN_quantity' => $count, |
|
204 | + 'LIN_parent' => $subtotal_line_item_id, |
|
205 | + 'OBJ_ID' => $ticket_id, |
|
206 | + 'OBJ_type' => 'Ticket', |
|
207 | + ], |
|
208 | + $old_attendee |
|
209 | + ); |
|
210 | + $new_line_item_ids[] = $reg_line_item_id; |
|
211 | + } |
|
212 | 212 | |
213 | 213 | |
214 | - return $new_line_item_ids; |
|
215 | - } |
|
214 | + return $new_line_item_ids; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Gets the full ticket by ID |
|
220 | - * |
|
221 | - * @param int $new_ticket_id |
|
222 | - * @return array |
|
223 | - * @global wpdb $wpdb |
|
224 | - */ |
|
225 | - private function _get_new_ticket_row(int $new_ticket_id): array |
|
226 | - { |
|
227 | - global $wpdb; |
|
228 | - return $wpdb->get_row( |
|
229 | - $wpdb->prepare( |
|
230 | - "SELECT * FROM {$wpdb->prefix}esp_ticket WHERE TKT_ID=%d", |
|
231 | - $new_ticket_id |
|
232 | - ), |
|
233 | - ARRAY_A |
|
234 | - ); |
|
235 | - } |
|
218 | + /** |
|
219 | + * Gets the full ticket by ID |
|
220 | + * |
|
221 | + * @param int $new_ticket_id |
|
222 | + * @return array |
|
223 | + * @global wpdb $wpdb |
|
224 | + */ |
|
225 | + private function _get_new_ticket_row(int $new_ticket_id): array |
|
226 | + { |
|
227 | + global $wpdb; |
|
228 | + return $wpdb->get_row( |
|
229 | + $wpdb->prepare( |
|
230 | + "SELECT * FROM {$wpdb->prefix}esp_ticket WHERE TKT_ID=%d", |
|
231 | + $new_ticket_id |
|
232 | + ), |
|
233 | + ARRAY_A |
|
234 | + ); |
|
235 | + } |
|
236 | 236 | |
237 | 237 | |
238 | - private function _insert_new_line_item(array $cols_n_values, array $old_attendee): int |
|
239 | - { |
|
240 | - global $wpdb; |
|
241 | - $default_cols_n_values = [ |
|
242 | - 'LIN_code' => '', |
|
243 | - 'TXN_ID' => 0, |
|
244 | - 'LIN_name' => '', |
|
245 | - 'LIN_desc' => '', |
|
246 | - 'LIN_unit_price' => 0, |
|
247 | - 'LIN_percent' => 0, |
|
248 | - 'LIN_is_taxable' => false, |
|
249 | - 'LIN_order' => 0, |
|
250 | - 'LIN_total' => 0, |
|
251 | - 'LIN_quantity' => null, |
|
252 | - 'LIN_parent' => 0, |
|
253 | - 'LIN_type' => 'line-item', |
|
254 | - 'OBJ_ID' => null, |
|
255 | - 'OBJ_type' => null, |
|
256 | - ]; |
|
257 | - $cols_n_values = array_merge($default_cols_n_values, $cols_n_values); |
|
258 | - $data_types = [ |
|
259 | - '%s',// LIN_code |
|
260 | - '%d',// TXN_ID |
|
261 | - '%s',// LIN_name |
|
262 | - '%s',// LIN_desc |
|
263 | - '%f',// LIN_unit_price |
|
264 | - '%f',// LIN_percent |
|
265 | - '%d',// LIN_is_taxable |
|
266 | - '%d',// LIN_order |
|
267 | - '%f',// LIN_total |
|
268 | - '%d',// LIN_quantity |
|
269 | - '%d',// LIN_parent |
|
270 | - '%s',// LIN_type |
|
271 | - '%d',// OBJ_ID |
|
272 | - '%s',// OBJ_type |
|
273 | - ]; |
|
238 | + private function _insert_new_line_item(array $cols_n_values, array $old_attendee): int |
|
239 | + { |
|
240 | + global $wpdb; |
|
241 | + $default_cols_n_values = [ |
|
242 | + 'LIN_code' => '', |
|
243 | + 'TXN_ID' => 0, |
|
244 | + 'LIN_name' => '', |
|
245 | + 'LIN_desc' => '', |
|
246 | + 'LIN_unit_price' => 0, |
|
247 | + 'LIN_percent' => 0, |
|
248 | + 'LIN_is_taxable' => false, |
|
249 | + 'LIN_order' => 0, |
|
250 | + 'LIN_total' => 0, |
|
251 | + 'LIN_quantity' => null, |
|
252 | + 'LIN_parent' => 0, |
|
253 | + 'LIN_type' => 'line-item', |
|
254 | + 'OBJ_ID' => null, |
|
255 | + 'OBJ_type' => null, |
|
256 | + ]; |
|
257 | + $cols_n_values = array_merge($default_cols_n_values, $cols_n_values); |
|
258 | + $data_types = [ |
|
259 | + '%s',// LIN_code |
|
260 | + '%d',// TXN_ID |
|
261 | + '%s',// LIN_name |
|
262 | + '%s',// LIN_desc |
|
263 | + '%f',// LIN_unit_price |
|
264 | + '%f',// LIN_percent |
|
265 | + '%d',// LIN_is_taxable |
|
266 | + '%d',// LIN_order |
|
267 | + '%f',// LIN_total |
|
268 | + '%d',// LIN_quantity |
|
269 | + '%d',// LIN_parent |
|
270 | + '%s',// LIN_type |
|
271 | + '%d',// OBJ_ID |
|
272 | + '%s',// OBJ_type |
|
273 | + ]; |
|
274 | 274 | |
275 | - $success = $wpdb->insert( |
|
276 | - $this->_new_line_table, |
|
277 | - $cols_n_values, |
|
278 | - $data_types |
|
279 | - ); |
|
280 | - if (! $success) { |
|
281 | - $this->add_error( |
|
282 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
283 | - $this->_old_table, |
|
284 | - $old_attendee, |
|
285 | - $this->_new_reg_table, |
|
286 | - $cols_n_values, |
|
287 | - $data_types |
|
288 | - ) |
|
289 | - ); |
|
290 | - return 0; |
|
291 | - } |
|
292 | - return $wpdb->insert_id; |
|
293 | - } |
|
275 | + $success = $wpdb->insert( |
|
276 | + $this->_new_line_table, |
|
277 | + $cols_n_values, |
|
278 | + $data_types |
|
279 | + ); |
|
280 | + if (! $success) { |
|
281 | + $this->add_error( |
|
282 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
283 | + $this->_old_table, |
|
284 | + $old_attendee, |
|
285 | + $this->_new_reg_table, |
|
286 | + $cols_n_values, |
|
287 | + $data_types |
|
288 | + ) |
|
289 | + ); |
|
290 | + return 0; |
|
291 | + } |
|
292 | + return $wpdb->insert_id; |
|
293 | + } |
|
294 | 294 | } |
@@ -107,454 +107,454 @@ |
||
107 | 107 | */ |
108 | 108 | class EE_DMS_4_1_0_prices extends EE_Data_Migration_Script_Stage_Table |
109 | 109 | { |
110 | - const price_type_base = 1; |
|
110 | + const price_type_base = 1; |
|
111 | 111 | |
112 | - const price_type_member_discount = 3; |
|
112 | + const price_type_member_discount = 3; |
|
113 | 113 | |
114 | - const price_type_percent_surcharge = 4; |
|
114 | + const price_type_percent_surcharge = 4; |
|
115 | 115 | |
116 | - const price_type_flat_surcharge = 5; |
|
116 | + const price_type_flat_surcharge = 5; |
|
117 | 117 | |
118 | - private string $_new_price_table; |
|
118 | + private string $_new_price_table; |
|
119 | 119 | |
120 | - private string $_new_ticket_table; |
|
120 | + private string $_new_ticket_table; |
|
121 | 121 | |
122 | - private string $_new_ticket_price_table; |
|
122 | + private string $_new_ticket_price_table; |
|
123 | 123 | |
124 | - private string $_new_datetime_ticket_table; |
|
124 | + private string $_new_datetime_ticket_table; |
|
125 | 125 | |
126 | - /** |
|
127 | - * A count of all the different tickets created, used for setting the new ones' TKT_Order |
|
128 | - * |
|
129 | - * @var int |
|
130 | - */ |
|
131 | - private int $_ticket_count = 0; |
|
126 | + /** |
|
127 | + * A count of all the different tickets created, used for setting the new ones' TKT_Order |
|
128 | + * |
|
129 | + * @var int |
|
130 | + */ |
|
131 | + private int $_ticket_count = 0; |
|
132 | 132 | |
133 | - private array $price_data_types = [ |
|
134 | - '%d',// PRT_ID |
|
135 | - '%f',// PRT_amount |
|
136 | - '%s',// PRC_name |
|
137 | - '%d',// PRC_is_default |
|
138 | - '%d',// PRC_overrides |
|
139 | - '%d',// PRC_order |
|
140 | - '%d',// PRC_deleted |
|
141 | - '%d',// PRC_parent |
|
142 | - ]; |
|
133 | + private array $price_data_types = [ |
|
134 | + '%d',// PRT_ID |
|
135 | + '%f',// PRT_amount |
|
136 | + '%s',// PRC_name |
|
137 | + '%d',// PRC_is_default |
|
138 | + '%d',// PRC_overrides |
|
139 | + '%d',// PRC_order |
|
140 | + '%d',// PRC_deleted |
|
141 | + '%d',// PRC_parent |
|
142 | + ]; |
|
143 | 143 | |
144 | 144 | |
145 | - public function __construct() |
|
146 | - { |
|
147 | - global $wpdb; |
|
148 | - $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
|
149 | - $this->_old_table = $wpdb->prefix . "events_prices"; |
|
150 | - $this->select_expression = 'p.*, e.event_status'; |
|
151 | - $this->_extra_where_sql = ' AS p |
|
145 | + public function __construct() |
|
146 | + { |
|
147 | + global $wpdb; |
|
148 | + $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
|
149 | + $this->_old_table = $wpdb->prefix . "events_prices"; |
|
150 | + $this->select_expression = 'p.*, e.event_status'; |
|
151 | + $this->_extra_where_sql = ' AS p |
|
152 | 152 | INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON p.event_id=e.id |
153 | 153 | WHERE e.event_status!="D"'; |
154 | - $this->_new_price_table = $wpdb->prefix . "esp_price"; |
|
155 | - $this->_new_ticket_table = $wpdb->prefix . "esp_ticket"; |
|
156 | - $this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
157 | - $this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket"; |
|
158 | - parent::__construct(); |
|
159 | - } |
|
154 | + $this->_new_price_table = $wpdb->prefix . "esp_price"; |
|
155 | + $this->_new_ticket_table = $wpdb->prefix . "esp_ticket"; |
|
156 | + $this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
157 | + $this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket"; |
|
158 | + parent::__construct(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * @throws EE_Error |
|
164 | - */ |
|
165 | - protected function _migrate_old_row($old_row) |
|
166 | - { |
|
167 | - // create the base price |
|
168 | - $new_price_id = $this->_insert_new_price($old_row); |
|
169 | - // create the member discount if there is any |
|
170 | - // commented-out because we may actually NOT be supporting this in 4.1 |
|
171 | - // if($old_row['event_cost'] != $old_row['member_price']){ |
|
172 | - // $member_price_discount_id = $this->_insert_new_member_price($old_row); |
|
173 | - // }else{ |
|
174 | - // $member_price_discount_id = 0; |
|
175 | - // } |
|
176 | - // create the surcharge if there is any |
|
177 | - if (floatval($old_row['surcharge']) >= 0.01) { |
|
178 | - $surcharge_price_id = $this->_insert_new_surcharge_price($old_row); |
|
179 | - $this->get_migration_script()->set_mapping( |
|
180 | - $this->_old_table, |
|
181 | - $old_row['id'], |
|
182 | - $this->_new_price_table, |
|
183 | - [$new_price_id, $surcharge_price_id] |
|
184 | - ); |
|
185 | - } else { |
|
186 | - $surcharge_price_id = 0; |
|
187 | - $this->get_migration_script()->set_mapping( |
|
188 | - $this->_old_table, |
|
189 | - $old_row['id'], |
|
190 | - $this->_new_price_table, |
|
191 | - [$new_price_id] |
|
192 | - ); |
|
193 | - } |
|
194 | - // associate the ticket to all datetimes for event (ie, this ONE ticket grants access to ALL datetimes, not just one of the attendee's choice. |
|
195 | - // if the latter were the case, then we'd create a separate ticket for each datetime and have their |
|
196 | - // association be one-to-one) |
|
197 | - // create ticket |
|
198 | - // $ticket_id = $this->_insert_new_ticket($old_row); |
|
199 | - // if($ticket_id){ |
|
200 | - // $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_ticket_table, $ticket_id); |
|
201 | - // //associate to the prices |
|
202 | - // $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
203 | - // $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
204 | - // //associate to datetimes for the event |
|
205 | - // foreach($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id){ |
|
206 | - // $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
207 | - // } |
|
208 | - // } |
|
209 | - // create a ticket for each old price -old datetime combo |
|
210 | - $tickets_for_old_price = []; |
|
211 | - foreach ($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id) { |
|
212 | - $ticket_id = $this->_insert_new_ticket($old_row); |
|
213 | - $tickets_for_old_price[] = $ticket_id; |
|
214 | - // associate to old prices |
|
215 | - $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
216 | - $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
217 | - $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
218 | - } |
|
219 | - $this->get_migration_script()->set_mapping( |
|
220 | - $this->_old_table, |
|
221 | - $old_row['id'], |
|
222 | - $this->_new_ticket_table, |
|
223 | - $tickets_for_old_price |
|
224 | - ); |
|
225 | - } |
|
162 | + /** |
|
163 | + * @throws EE_Error |
|
164 | + */ |
|
165 | + protected function _migrate_old_row($old_row) |
|
166 | + { |
|
167 | + // create the base price |
|
168 | + $new_price_id = $this->_insert_new_price($old_row); |
|
169 | + // create the member discount if there is any |
|
170 | + // commented-out because we may actually NOT be supporting this in 4.1 |
|
171 | + // if($old_row['event_cost'] != $old_row['member_price']){ |
|
172 | + // $member_price_discount_id = $this->_insert_new_member_price($old_row); |
|
173 | + // }else{ |
|
174 | + // $member_price_discount_id = 0; |
|
175 | + // } |
|
176 | + // create the surcharge if there is any |
|
177 | + if (floatval($old_row['surcharge']) >= 0.01) { |
|
178 | + $surcharge_price_id = $this->_insert_new_surcharge_price($old_row); |
|
179 | + $this->get_migration_script()->set_mapping( |
|
180 | + $this->_old_table, |
|
181 | + $old_row['id'], |
|
182 | + $this->_new_price_table, |
|
183 | + [$new_price_id, $surcharge_price_id] |
|
184 | + ); |
|
185 | + } else { |
|
186 | + $surcharge_price_id = 0; |
|
187 | + $this->get_migration_script()->set_mapping( |
|
188 | + $this->_old_table, |
|
189 | + $old_row['id'], |
|
190 | + $this->_new_price_table, |
|
191 | + [$new_price_id] |
|
192 | + ); |
|
193 | + } |
|
194 | + // associate the ticket to all datetimes for event (ie, this ONE ticket grants access to ALL datetimes, not just one of the attendee's choice. |
|
195 | + // if the latter were the case, then we'd create a separate ticket for each datetime and have their |
|
196 | + // association be one-to-one) |
|
197 | + // create ticket |
|
198 | + // $ticket_id = $this->_insert_new_ticket($old_row); |
|
199 | + // if($ticket_id){ |
|
200 | + // $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_ticket_table, $ticket_id); |
|
201 | + // //associate to the prices |
|
202 | + // $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
203 | + // $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
204 | + // //associate to datetimes for the event |
|
205 | + // foreach($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id){ |
|
206 | + // $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
207 | + // } |
|
208 | + // } |
|
209 | + // create a ticket for each old price -old datetime combo |
|
210 | + $tickets_for_old_price = []; |
|
211 | + foreach ($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id) { |
|
212 | + $ticket_id = $this->_insert_new_ticket($old_row); |
|
213 | + $tickets_for_old_price[] = $ticket_id; |
|
214 | + // associate to old prices |
|
215 | + $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
216 | + $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
217 | + $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
218 | + } |
|
219 | + $this->get_migration_script()->set_mapping( |
|
220 | + $this->_old_table, |
|
221 | + $old_row['id'], |
|
222 | + $this->_new_ticket_table, |
|
223 | + $tickets_for_old_price |
|
224 | + ); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * Creates a 4.1 price base type |
|
230 | - * |
|
231 | - * @param array $old_price |
|
232 | - * @return int |
|
233 | - * @global wpdb $wpdb |
|
234 | - */ |
|
235 | - private function _insert_new_price(array $old_price): int |
|
236 | - { |
|
237 | - global $wpdb; |
|
238 | - $cols_n_values = [ |
|
239 | - 'PRT_ID' => self::price_type_base, |
|
240 | - 'PRC_amount' => floatval($old_price['event_cost']), |
|
241 | - 'PRC_name' => $old_price['price_type'], |
|
242 | - 'PRC_is_default' => false, |
|
243 | - 'PRC_overrides' => false, |
|
244 | - 'PRC_order' => 0, |
|
245 | - 'PRC_deleted' => false, |
|
246 | - 'PRC_parent' => null, |
|
228 | + /** |
|
229 | + * Creates a 4.1 price base type |
|
230 | + * |
|
231 | + * @param array $old_price |
|
232 | + * @return int |
|
233 | + * @global wpdb $wpdb |
|
234 | + */ |
|
235 | + private function _insert_new_price(array $old_price): int |
|
236 | + { |
|
237 | + global $wpdb; |
|
238 | + $cols_n_values = [ |
|
239 | + 'PRT_ID' => self::price_type_base, |
|
240 | + 'PRC_amount' => floatval($old_price['event_cost']), |
|
241 | + 'PRC_name' => $old_price['price_type'], |
|
242 | + 'PRC_is_default' => false, |
|
243 | + 'PRC_overrides' => false, |
|
244 | + 'PRC_order' => 0, |
|
245 | + 'PRC_deleted' => false, |
|
246 | + 'PRC_parent' => null, |
|
247 | 247 | |
248 | - ]; |
|
249 | - $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
250 | - if (! $success) { |
|
251 | - $this->add_error( |
|
252 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
253 | - $this->_old_table, |
|
254 | - $old_price, |
|
255 | - $this->_new_price_table, |
|
256 | - $cols_n_values, |
|
257 | - $this->price_data_types |
|
258 | - ) |
|
259 | - ); |
|
260 | - return 0; |
|
261 | - } |
|
262 | - return $wpdb->insert_id; |
|
263 | - } |
|
264 | - /** |
|
265 | - * Creates a 4.1 member price discount |
|
266 | - * |
|
267 | - * @param array $old_price |
|
268 | - * @return int |
|
269 | - * @global wpdb $wpdb |
|
270 | - */ |
|
271 | - // private function _insert_new_member_price($old_price){ |
|
272 | - // $discount_amount = floatval($old_price['event_cost']) - floatval($old_price['member_price']); |
|
273 | - // global $wpdb; |
|
274 | - // $cols_n_values = array( |
|
275 | - // 'PRT_ID'=>self::price_type_member_discount, |
|
276 | - // 'PRC_amount'=>$discount_amount, |
|
277 | - // 'PRC_name'=>$old_price['member_price_type'], |
|
278 | - // 'PRC_is_default'=>false, |
|
279 | - // 'PRC_overrides'=>false, |
|
280 | - // 'PRC_order'=>10, |
|
281 | - // 'PRC_deleted'=>false, |
|
282 | - // 'PRC_parent'=>null |
|
283 | - // |
|
284 | - // ); |
|
285 | - // $data_types = array( |
|
286 | - // '%d',//PRT_ID |
|
287 | - // '%f',//PRT_amount |
|
288 | - // '%s',//PRC_name |
|
289 | - // '%d',//PRC_is_default |
|
290 | - // '%d',//PRC_overrides |
|
291 | - // '%d',//PRC_order |
|
292 | - // '%d',//PRC_deleted |
|
293 | - // '%d',//PRC_parent |
|
294 | - // ); |
|
295 | - // $success = $wpdb->insert($this->_new_price_table,$cols_n_values,$data_types); |
|
296 | - // if ( ! $success){ |
|
297 | - // $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $data_types)); |
|
298 | - // return 0; |
|
299 | - // } |
|
300 | - // $new_id = $wpdb->insert_id; |
|
301 | - // return $new_id; |
|
302 | - // } |
|
303 | - /** |
|
304 | - * Creates a 4.1 member price discount |
|
305 | - * |
|
306 | - * @param array $old_price |
|
307 | - * @return int |
|
308 | - * @global wpdb $wpdb |
|
309 | - */ |
|
310 | - private function _insert_new_surcharge_price(array $old_price): int |
|
311 | - { |
|
312 | - if ($old_price['surcharge_type'] == 'flat_rate') { |
|
313 | - $price_type = self::price_type_flat_surcharge; |
|
314 | - } else { |
|
315 | - $price_type = self::price_type_percent_surcharge; |
|
316 | - } |
|
317 | - global $wpdb; |
|
318 | - $cols_n_values = [ |
|
319 | - 'PRT_ID' => $price_type, |
|
320 | - 'PRC_amount' => floatval($old_price['surcharge']), |
|
321 | - 'PRC_name' => esc_html__("Surcharge", "event_espresso"), |
|
322 | - 'PRC_is_default' => false, |
|
323 | - 'PRC_overrides' => false, |
|
324 | - 'PRC_order' => 20, |
|
325 | - 'PRC_deleted' => false, |
|
326 | - 'PRC_parent' => null, |
|
248 | + ]; |
|
249 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
250 | + if (! $success) { |
|
251 | + $this->add_error( |
|
252 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
253 | + $this->_old_table, |
|
254 | + $old_price, |
|
255 | + $this->_new_price_table, |
|
256 | + $cols_n_values, |
|
257 | + $this->price_data_types |
|
258 | + ) |
|
259 | + ); |
|
260 | + return 0; |
|
261 | + } |
|
262 | + return $wpdb->insert_id; |
|
263 | + } |
|
264 | + /** |
|
265 | + * Creates a 4.1 member price discount |
|
266 | + * |
|
267 | + * @param array $old_price |
|
268 | + * @return int |
|
269 | + * @global wpdb $wpdb |
|
270 | + */ |
|
271 | + // private function _insert_new_member_price($old_price){ |
|
272 | + // $discount_amount = floatval($old_price['event_cost']) - floatval($old_price['member_price']); |
|
273 | + // global $wpdb; |
|
274 | + // $cols_n_values = array( |
|
275 | + // 'PRT_ID'=>self::price_type_member_discount, |
|
276 | + // 'PRC_amount'=>$discount_amount, |
|
277 | + // 'PRC_name'=>$old_price['member_price_type'], |
|
278 | + // 'PRC_is_default'=>false, |
|
279 | + // 'PRC_overrides'=>false, |
|
280 | + // 'PRC_order'=>10, |
|
281 | + // 'PRC_deleted'=>false, |
|
282 | + // 'PRC_parent'=>null |
|
283 | + // |
|
284 | + // ); |
|
285 | + // $data_types = array( |
|
286 | + // '%d',//PRT_ID |
|
287 | + // '%f',//PRT_amount |
|
288 | + // '%s',//PRC_name |
|
289 | + // '%d',//PRC_is_default |
|
290 | + // '%d',//PRC_overrides |
|
291 | + // '%d',//PRC_order |
|
292 | + // '%d',//PRC_deleted |
|
293 | + // '%d',//PRC_parent |
|
294 | + // ); |
|
295 | + // $success = $wpdb->insert($this->_new_price_table,$cols_n_values,$data_types); |
|
296 | + // if ( ! $success){ |
|
297 | + // $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $data_types)); |
|
298 | + // return 0; |
|
299 | + // } |
|
300 | + // $new_id = $wpdb->insert_id; |
|
301 | + // return $new_id; |
|
302 | + // } |
|
303 | + /** |
|
304 | + * Creates a 4.1 member price discount |
|
305 | + * |
|
306 | + * @param array $old_price |
|
307 | + * @return int |
|
308 | + * @global wpdb $wpdb |
|
309 | + */ |
|
310 | + private function _insert_new_surcharge_price(array $old_price): int |
|
311 | + { |
|
312 | + if ($old_price['surcharge_type'] == 'flat_rate') { |
|
313 | + $price_type = self::price_type_flat_surcharge; |
|
314 | + } else { |
|
315 | + $price_type = self::price_type_percent_surcharge; |
|
316 | + } |
|
317 | + global $wpdb; |
|
318 | + $cols_n_values = [ |
|
319 | + 'PRT_ID' => $price_type, |
|
320 | + 'PRC_amount' => floatval($old_price['surcharge']), |
|
321 | + 'PRC_name' => esc_html__("Surcharge", "event_espresso"), |
|
322 | + 'PRC_is_default' => false, |
|
323 | + 'PRC_overrides' => false, |
|
324 | + 'PRC_order' => 20, |
|
325 | + 'PRC_deleted' => false, |
|
326 | + 'PRC_parent' => null, |
|
327 | 327 | |
328 | - ]; |
|
329 | - $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
330 | - if (! $success) { |
|
331 | - $this->add_error( |
|
332 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
333 | - $this->_old_table, |
|
334 | - $old_price, |
|
335 | - $this->_new_price_table, |
|
336 | - $cols_n_values, |
|
337 | - $this->price_data_types |
|
338 | - ) |
|
339 | - ); |
|
340 | - return 0; |
|
341 | - } |
|
342 | - return $wpdb->insert_id; |
|
343 | - } |
|
328 | + ]; |
|
329 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
330 | + if (! $success) { |
|
331 | + $this->add_error( |
|
332 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
333 | + $this->_old_table, |
|
334 | + $old_price, |
|
335 | + $this->_new_price_table, |
|
336 | + $cols_n_values, |
|
337 | + $this->price_data_types |
|
338 | + ) |
|
339 | + ); |
|
340 | + return 0; |
|
341 | + } |
|
342 | + return $wpdb->insert_id; |
|
343 | + } |
|
344 | 344 | |
345 | 345 | |
346 | - /** |
|
347 | - * Inserts a 4.1 ticket based off the 3.1 price, and the price IDs we've already made from the 3.1 price |
|
348 | - * |
|
349 | - * @param array $old_price_row array where keys are columns |
|
350 | - * @return int new ticket id |
|
351 | - */ |
|
352 | - private function _insert_new_ticket(array $old_price_row): int |
|
353 | - { |
|
354 | - global $wpdb; |
|
355 | - $event_row = $this->_get_event_row($old_price_row['event_id']); |
|
356 | - if ($old_price_row['surcharge_type'] == 'flat_rate') { |
|
357 | - $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']); |
|
358 | - } else {// percent surcharge |
|
359 | - $final_ticket_price = |
|
360 | - floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge']) / 100); |
|
361 | - } |
|
362 | - $start_date = |
|
363 | - $event_row['registration_start'] . |
|
364 | - " " . |
|
365 | - $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']); |
|
366 | - $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
367 | - $this, |
|
368 | - $old_price_row, |
|
369 | - $start_date, |
|
370 | - $event_row['timezone_string'] |
|
371 | - ); |
|
372 | - $end_date = |
|
373 | - $event_row['registration_end'] . |
|
374 | - " " . |
|
375 | - $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']); |
|
376 | - $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
377 | - $this, |
|
378 | - $old_price_row, |
|
379 | - $end_date, |
|
380 | - $event_row['timezone_string'] |
|
381 | - ); |
|
382 | - $cols_n_values = [ |
|
383 | - 'TTM_ID' => 0, |
|
384 | - 'TKT_name' => $old_price_row['price_type'], |
|
385 | - 'TKT_description' => '', |
|
386 | - 'TKT_start_date' => $start_date_utc, |
|
387 | - 'TKT_end_date' => $end_date_utc, |
|
388 | - 'TKT_min' => 0, |
|
389 | - 'TKT_max' => -1, |
|
390 | - 'TKT_price' => $final_ticket_price, |
|
391 | - 'TKT_sold' => 0, |
|
392 | - // note: this will get calculated as we actually add registrations during the migration |
|
393 | - 'TKT_qty' => -1, |
|
394 | - 'TKT_uses' => 1, |
|
395 | - 'TKT_taxable' => false, |
|
396 | - // so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices |
|
397 | - 'TKT_is_default' => false, |
|
398 | - 'TKT_order' => $this->_get_ticket_count(), |
|
399 | - 'TKT_row' => 0, |
|
400 | - // doesn't matter because UI reset this on first save anyways |
|
401 | - 'TKT_deleted' => false, |
|
402 | - 'TKT_parent' => 0, |
|
346 | + /** |
|
347 | + * Inserts a 4.1 ticket based off the 3.1 price, and the price IDs we've already made from the 3.1 price |
|
348 | + * |
|
349 | + * @param array $old_price_row array where keys are columns |
|
350 | + * @return int new ticket id |
|
351 | + */ |
|
352 | + private function _insert_new_ticket(array $old_price_row): int |
|
353 | + { |
|
354 | + global $wpdb; |
|
355 | + $event_row = $this->_get_event_row($old_price_row['event_id']); |
|
356 | + if ($old_price_row['surcharge_type'] == 'flat_rate') { |
|
357 | + $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']); |
|
358 | + } else {// percent surcharge |
|
359 | + $final_ticket_price = |
|
360 | + floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge']) / 100); |
|
361 | + } |
|
362 | + $start_date = |
|
363 | + $event_row['registration_start'] . |
|
364 | + " " . |
|
365 | + $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']); |
|
366 | + $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
367 | + $this, |
|
368 | + $old_price_row, |
|
369 | + $start_date, |
|
370 | + $event_row['timezone_string'] |
|
371 | + ); |
|
372 | + $end_date = |
|
373 | + $event_row['registration_end'] . |
|
374 | + " " . |
|
375 | + $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']); |
|
376 | + $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
377 | + $this, |
|
378 | + $old_price_row, |
|
379 | + $end_date, |
|
380 | + $event_row['timezone_string'] |
|
381 | + ); |
|
382 | + $cols_n_values = [ |
|
383 | + 'TTM_ID' => 0, |
|
384 | + 'TKT_name' => $old_price_row['price_type'], |
|
385 | + 'TKT_description' => '', |
|
386 | + 'TKT_start_date' => $start_date_utc, |
|
387 | + 'TKT_end_date' => $end_date_utc, |
|
388 | + 'TKT_min' => 0, |
|
389 | + 'TKT_max' => -1, |
|
390 | + 'TKT_price' => $final_ticket_price, |
|
391 | + 'TKT_sold' => 0, |
|
392 | + // note: this will get calculated as we actually add registrations during the migration |
|
393 | + 'TKT_qty' => -1, |
|
394 | + 'TKT_uses' => 1, |
|
395 | + 'TKT_taxable' => false, |
|
396 | + // so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices |
|
397 | + 'TKT_is_default' => false, |
|
398 | + 'TKT_order' => $this->_get_ticket_count(), |
|
399 | + 'TKT_row' => 0, |
|
400 | + // doesn't matter because UI reset this on first save anyways |
|
401 | + 'TKT_deleted' => false, |
|
402 | + 'TKT_parent' => 0, |
|
403 | 403 | |
404 | - ]; |
|
405 | - $data_types = [ |
|
406 | - '%d',// TTM_ID |
|
407 | - '%s',// TKT_name |
|
408 | - '%s',// TKT_description |
|
409 | - '%s',// TKT_start_date |
|
410 | - '%s',// TKT_end_date |
|
411 | - '%d',// TKT_min |
|
412 | - '%d',// TKT_max |
|
413 | - '%f',// TKT_price |
|
414 | - '%d',// TKT_sold |
|
415 | - '%d',// TKT_qty |
|
416 | - '%d',// TKT_uses |
|
417 | - '%d',// TKT_taxable |
|
418 | - '%d',// TKT_is_default |
|
419 | - '%d',// TKT_order |
|
420 | - '%d',// TKT_row |
|
421 | - '%d',// TKT_deleted |
|
422 | - '%d',// TKT_parent |
|
423 | - ]; |
|
424 | - $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $data_types); |
|
425 | - if (! $success) { |
|
426 | - $this->add_error( |
|
427 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
428 | - $this->_old_table, |
|
429 | - $old_price_row, |
|
430 | - $this->_new_ticket_table, |
|
431 | - $cols_n_values, |
|
432 | - $data_types |
|
433 | - ) |
|
434 | - ); |
|
435 | - return 0; |
|
436 | - } |
|
437 | - return $wpdb->insert_id; |
|
438 | - } |
|
404 | + ]; |
|
405 | + $data_types = [ |
|
406 | + '%d',// TTM_ID |
|
407 | + '%s',// TKT_name |
|
408 | + '%s',// TKT_description |
|
409 | + '%s',// TKT_start_date |
|
410 | + '%s',// TKT_end_date |
|
411 | + '%d',// TKT_min |
|
412 | + '%d',// TKT_max |
|
413 | + '%f',// TKT_price |
|
414 | + '%d',// TKT_sold |
|
415 | + '%d',// TKT_qty |
|
416 | + '%d',// TKT_uses |
|
417 | + '%d',// TKT_taxable |
|
418 | + '%d',// TKT_is_default |
|
419 | + '%d',// TKT_order |
|
420 | + '%d',// TKT_row |
|
421 | + '%d',// TKT_deleted |
|
422 | + '%d',// TKT_parent |
|
423 | + ]; |
|
424 | + $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $data_types); |
|
425 | + if (! $success) { |
|
426 | + $this->add_error( |
|
427 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
428 | + $this->_old_table, |
|
429 | + $old_price_row, |
|
430 | + $this->_new_ticket_table, |
|
431 | + $cols_n_values, |
|
432 | + $data_types |
|
433 | + ) |
|
434 | + ); |
|
435 | + return 0; |
|
436 | + } |
|
437 | + return $wpdb->insert_id; |
|
438 | + } |
|
439 | 439 | |
440 | 440 | |
441 | - /** |
|
442 | - * Adds a join between a ticket and a price |
|
443 | - * |
|
444 | - * @param int $new_ticket_id |
|
445 | - * @param int $new_price_id |
|
446 | - * @return void |
|
447 | - * @global wpdb $wpdb |
|
448 | - */ |
|
449 | - private function _insert_ticket_price_relation(int $new_ticket_id, int $new_price_id): void |
|
450 | - { |
|
451 | - global $wpdb; |
|
452 | - $cols_n_values = [ |
|
453 | - 'TKT_ID' => $new_ticket_id, |
|
454 | - 'PRC_ID' => $new_price_id, |
|
455 | - ]; |
|
456 | - $data_types = [ |
|
457 | - '%d',// TKT_ID |
|
458 | - '%d',// PRC_ID |
|
459 | - ]; |
|
460 | - $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $data_types); |
|
461 | - if (! $success) { |
|
462 | - $this->add_error( |
|
463 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
464 | - $this->_old_table, |
|
465 | - ['ticket id' => $new_ticket_id, 'price id' => $new_price_id], |
|
466 | - $this->_new_ticket_price_table, |
|
467 | - $cols_n_values, |
|
468 | - $data_types |
|
469 | - ) |
|
470 | - ); |
|
471 | - } |
|
472 | - } |
|
441 | + /** |
|
442 | + * Adds a join between a ticket and a price |
|
443 | + * |
|
444 | + * @param int $new_ticket_id |
|
445 | + * @param int $new_price_id |
|
446 | + * @return void |
|
447 | + * @global wpdb $wpdb |
|
448 | + */ |
|
449 | + private function _insert_ticket_price_relation(int $new_ticket_id, int $new_price_id): void |
|
450 | + { |
|
451 | + global $wpdb; |
|
452 | + $cols_n_values = [ |
|
453 | + 'TKT_ID' => $new_ticket_id, |
|
454 | + 'PRC_ID' => $new_price_id, |
|
455 | + ]; |
|
456 | + $data_types = [ |
|
457 | + '%d',// TKT_ID |
|
458 | + '%d',// PRC_ID |
|
459 | + ]; |
|
460 | + $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $data_types); |
|
461 | + if (! $success) { |
|
462 | + $this->add_error( |
|
463 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
464 | + $this->_old_table, |
|
465 | + ['ticket id' => $new_ticket_id, 'price id' => $new_price_id], |
|
466 | + $this->_new_ticket_price_table, |
|
467 | + $cols_n_values, |
|
468 | + $data_types |
|
469 | + ) |
|
470 | + ); |
|
471 | + } |
|
472 | + } |
|
473 | 473 | |
474 | 474 | |
475 | - /** |
|
476 | - * Adds a join between a ticket and a datetime |
|
477 | - * |
|
478 | - * @param int $new_datetime_id |
|
479 | - * @param int $new_ticket_id |
|
480 | - * @return void |
|
481 | - * @global wpdb $wpdb |
|
482 | - */ |
|
483 | - private function _insert_datetime_ticket_relation(int $new_datetime_id, int $new_ticket_id) |
|
484 | - { |
|
485 | - global $wpdb; |
|
486 | - $cols_n_values = [ |
|
487 | - 'TKT_ID' => $new_ticket_id, |
|
488 | - 'DTT_ID' => $new_datetime_id, |
|
489 | - ]; |
|
490 | - $data_types = [ |
|
491 | - '%d',// TKT_ID |
|
492 | - '%d',// DTT_ID |
|
493 | - ]; |
|
494 | - $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $data_types); |
|
495 | - if (! $success) { |
|
496 | - $this->add_error( |
|
497 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
498 | - $this->_old_table, |
|
499 | - ['ticket id' => $new_ticket_id, 'datetime id' => $new_datetime_id], |
|
500 | - $this->_new_datetime_ticket_table, |
|
501 | - $cols_n_values, |
|
502 | - $data_types |
|
503 | - ) |
|
504 | - ); |
|
505 | - } |
|
506 | - } |
|
475 | + /** |
|
476 | + * Adds a join between a ticket and a datetime |
|
477 | + * |
|
478 | + * @param int $new_datetime_id |
|
479 | + * @param int $new_ticket_id |
|
480 | + * @return void |
|
481 | + * @global wpdb $wpdb |
|
482 | + */ |
|
483 | + private function _insert_datetime_ticket_relation(int $new_datetime_id, int $new_ticket_id) |
|
484 | + { |
|
485 | + global $wpdb; |
|
486 | + $cols_n_values = [ |
|
487 | + 'TKT_ID' => $new_ticket_id, |
|
488 | + 'DTT_ID' => $new_datetime_id, |
|
489 | + ]; |
|
490 | + $data_types = [ |
|
491 | + '%d',// TKT_ID |
|
492 | + '%d',// DTT_ID |
|
493 | + ]; |
|
494 | + $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $data_types); |
|
495 | + if (! $success) { |
|
496 | + $this->add_error( |
|
497 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
498 | + $this->_old_table, |
|
499 | + ['ticket id' => $new_ticket_id, 'datetime id' => $new_datetime_id], |
|
500 | + $this->_new_datetime_ticket_table, |
|
501 | + $cols_n_values, |
|
502 | + $data_types |
|
503 | + ) |
|
504 | + ); |
|
505 | + } |
|
506 | + } |
|
507 | 507 | |
508 | 508 | |
509 | - /** |
|
510 | - * Simply gets the 3.1 event row data |
|
511 | - * |
|
512 | - * @param int $event_id |
|
513 | - * @return array |
|
514 | - * @global wpdb $wpdb |
|
515 | - */ |
|
516 | - private function _get_event_row(int $event_id): array |
|
517 | - { |
|
518 | - global $wpdb; |
|
519 | - $old_event_table = $wpdb->prefix . "events_detail"; |
|
520 | - return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A); |
|
521 | - } |
|
509 | + /** |
|
510 | + * Simply gets the 3.1 event row data |
|
511 | + * |
|
512 | + * @param int $event_id |
|
513 | + * @return array |
|
514 | + * @global wpdb $wpdb |
|
515 | + */ |
|
516 | + private function _get_event_row(int $event_id): array |
|
517 | + { |
|
518 | + global $wpdb; |
|
519 | + $old_event_table = $wpdb->prefix . "events_detail"; |
|
520 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A); |
|
521 | + } |
|
522 | 522 | |
523 | 523 | |
524 | - /** |
|
525 | - * Gets a higher ticket count than last time it was called (and is persisted between HTTP requests). |
|
526 | - * Yes we COULD run a query joining events->datetimes->ticket_datetimes->tickets, but this should work fine too |
|
527 | - * |
|
528 | - * @return int |
|
529 | - */ |
|
530 | - private function _get_ticket_count(): int |
|
531 | - { |
|
532 | - return $this->_ticket_count++; |
|
533 | - } |
|
524 | + /** |
|
525 | + * Gets a higher ticket count than last time it was called (and is persisted between HTTP requests). |
|
526 | + * Yes we COULD run a query joining events->datetimes->ticket_datetimes->tickets, but this should work fine too |
|
527 | + * |
|
528 | + * @return int |
|
529 | + */ |
|
530 | + private function _get_ticket_count(): int |
|
531 | + { |
|
532 | + return $this->_ticket_count++; |
|
533 | + } |
|
534 | 534 | |
535 | 535 | |
536 | - /** |
|
537 | - * Using the 3.1 event id, gets the 4.1 datetimes for it |
|
538 | - * |
|
539 | - * @param int $old_event_id |
|
540 | - * @return array where values are datetime ids |
|
541 | - * @throws EE_Error |
|
542 | - */ |
|
543 | - private function _get_datetime_ids_for_old_event_id(int $old_event_id): array |
|
544 | - { |
|
545 | - global $wpdb; |
|
546 | - $new_cpt_id = $this->get_migration_script()->get_mapping_new_pk( |
|
547 | - $wpdb->prefix . "events_detail", |
|
548 | - $old_event_id, |
|
549 | - $wpdb->posts |
|
550 | - ); |
|
551 | - return $wpdb->get_col( |
|
552 | - $wpdb->prepare( |
|
553 | - "SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d", |
|
554 | - $new_cpt_id |
|
555 | - ) |
|
556 | - ); |
|
557 | - } |
|
536 | + /** |
|
537 | + * Using the 3.1 event id, gets the 4.1 datetimes for it |
|
538 | + * |
|
539 | + * @param int $old_event_id |
|
540 | + * @return array where values are datetime ids |
|
541 | + * @throws EE_Error |
|
542 | + */ |
|
543 | + private function _get_datetime_ids_for_old_event_id(int $old_event_id): array |
|
544 | + { |
|
545 | + global $wpdb; |
|
546 | + $new_cpt_id = $this->get_migration_script()->get_mapping_new_pk( |
|
547 | + $wpdb->prefix . "events_detail", |
|
548 | + $old_event_id, |
|
549 | + $wpdb->posts |
|
550 | + ); |
|
551 | + return $wpdb->get_col( |
|
552 | + $wpdb->prepare( |
|
553 | + "SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d", |
|
554 | + $new_cpt_id |
|
555 | + ) |
|
556 | + ); |
|
557 | + } |
|
558 | 558 | } |
559 | 559 | // @todo: tell users that in 3.1 the limit was on registration PER event,in 4.1 it's limit PER TICKET... SO, if they sell 2 different types of tickets |
560 | 560 | // |
@@ -89,322 +89,322 @@ |
||
89 | 89 | */ |
90 | 90 | class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage |
91 | 91 | { |
92 | - public function __construct() |
|
93 | - { |
|
94 | - $this->_pretty_name = esc_html__("Organization Options/Config", "event_espresso"); |
|
95 | - $this->_org_options_we_know_how_to_migrate = apply_filters( |
|
96 | - 'FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', |
|
97 | - $this->_org_options_we_know_how_to_migrate |
|
98 | - ); |
|
99 | - parent::__construct(); |
|
100 | - } |
|
92 | + public function __construct() |
|
93 | + { |
|
94 | + $this->_pretty_name = esc_html__("Organization Options/Config", "event_espresso"); |
|
95 | + $this->_org_options_we_know_how_to_migrate = apply_filters( |
|
96 | + 'FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', |
|
97 | + $this->_org_options_we_know_how_to_migrate |
|
98 | + ); |
|
99 | + parent::__construct(); |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - public function _migration_step($num_items_to_migrate = 50) |
|
104 | - { |
|
105 | - $items_actually_migrated = 0; |
|
106 | - $old_org_options = get_option('events_organization_settings'); |
|
107 | - foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
108 | - // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
109 | - if (isset($old_org_options[ $option_name ])) { |
|
110 | - $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
111 | - } |
|
112 | - if ($option_name == 'surcharge') { |
|
113 | - $this->_insert_new_global_surcharge_price($old_org_options); |
|
114 | - } |
|
115 | - $items_actually_migrated++; |
|
116 | - } |
|
103 | + public function _migration_step($num_items_to_migrate = 50) |
|
104 | + { |
|
105 | + $items_actually_migrated = 0; |
|
106 | + $old_org_options = get_option('events_organization_settings'); |
|
107 | + foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
108 | + // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
109 | + if (isset($old_org_options[ $option_name ])) { |
|
110 | + $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
111 | + } |
|
112 | + if ($option_name == 'surcharge') { |
|
113 | + $this->_insert_new_global_surcharge_price($old_org_options); |
|
114 | + } |
|
115 | + $items_actually_migrated++; |
|
116 | + } |
|
117 | 117 | |
118 | - $success = EE_Config::instance()->update_espresso_config(); |
|
119 | - if (! $success) { |
|
120 | - $this->add_error( |
|
121 | - sprintf( |
|
122 | - esc_html__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), |
|
123 | - EE_Error::get_notices(false) |
|
124 | - ) |
|
125 | - ); |
|
126 | - EE_Error::overwrite_errors(); |
|
127 | - } |
|
128 | - EE_Network_Config::instance()->update_config(false, false); |
|
129 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
130 | - // we may have added new pages and this might be necessary |
|
131 | - flush_rewrite_rules(); |
|
132 | - $this->set_completed(); |
|
133 | - } |
|
134 | - return $items_actually_migrated; |
|
135 | - } |
|
118 | + $success = EE_Config::instance()->update_espresso_config(); |
|
119 | + if (! $success) { |
|
120 | + $this->add_error( |
|
121 | + sprintf( |
|
122 | + esc_html__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), |
|
123 | + EE_Error::get_notices(false) |
|
124 | + ) |
|
125 | + ); |
|
126 | + EE_Error::overwrite_errors(); |
|
127 | + } |
|
128 | + EE_Network_Config::instance()->update_config(false, false); |
|
129 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
130 | + // we may have added new pages and this might be necessary |
|
131 | + flush_rewrite_rules(); |
|
132 | + $this->set_completed(); |
|
133 | + } |
|
134 | + return $items_actually_migrated; |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | - public function _count_records_to_migrate(): int |
|
139 | - { |
|
140 | - return (int) count($this->_org_options_we_know_how_to_migrate); |
|
141 | - } |
|
138 | + public function _count_records_to_migrate(): int |
|
139 | + { |
|
140 | + return (int) count($this->_org_options_we_know_how_to_migrate); |
|
141 | + } |
|
142 | 142 | |
143 | 143 | |
144 | - private function _handle_org_option($option_name, $value) |
|
145 | - { |
|
146 | - $c = EE_Config::instance(); |
|
147 | - $cn = EE_Network_Config::instance(); |
|
148 | - switch ($option_name) { |
|
149 | - case 'organization': |
|
150 | - $c->organization->name = $value; |
|
151 | - break; |
|
152 | - case 'organization_street1': |
|
153 | - $c->organization->address_1 = $value; |
|
154 | - break; |
|
155 | - case 'organization_street2': |
|
156 | - $c->organization->address_2 = $value; |
|
157 | - break; |
|
158 | - case 'organization_city': |
|
159 | - $c->organization->city = $value; |
|
160 | - break; |
|
161 | - case 'organization_state': |
|
162 | - try { |
|
163 | - $state = $this->get_migration_script()->get_or_create_state($value); |
|
164 | - $state_id = $state['STA_ID']; |
|
165 | - $c->organization->STA_ID = $state_id; |
|
166 | - } catch (EE_Error $e) { |
|
167 | - } |
|
168 | - break; |
|
169 | - case 'organization_zip': |
|
170 | - $c->organization->zip = $value; |
|
171 | - break; |
|
172 | - case 'contact_email': |
|
173 | - $c->organization->email = $value; |
|
174 | - break; |
|
175 | - case 'default_payment_status': |
|
176 | - $c->registration->default_STS_ID = |
|
177 | - $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
178 | - break; |
|
179 | - case 'organization_country': |
|
180 | - $iso = $this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
181 | - $c->organization->CNT_ISO = $iso; |
|
182 | - $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
183 | - if (! $country_row) { |
|
184 | - $this->add_error( |
|
185 | - sprintf( |
|
186 | - esc_html__( |
|
187 | - "Could not set country's currency config because no country exists for ISO %s", |
|
188 | - "event_espresso" |
|
189 | - ), |
|
190 | - $iso |
|
191 | - ) |
|
192 | - ); |
|
193 | - } |
|
194 | - // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
195 | - $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
196 | - $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
197 | - $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
198 | - $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
199 | - $c->currency->sign_b4 = filter_var( |
|
200 | - $country_row['CNT_cur_sign_b4'], |
|
201 | - FILTER_VALIDATE_BOOLEAN |
|
202 | - ); // currency sign before or after: $TRUE or FALSE$ |
|
203 | - $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
204 | - $c->currency->dec_mrk = |
|
205 | - $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
206 | - $c->currency->thsnds = $country_row['CNT_cur_thsnds']; |
|
207 | - break; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
208 | - // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
|
209 | - // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
|
210 | - // $c->currency->sign = $value;break; |
|
211 | - case 'show_pending_payment_options': |
|
212 | - $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
213 | - break; |
|
214 | - case 'display_address_in_regform': |
|
215 | - $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
216 | - break; |
|
217 | - case 'default_logo_url': |
|
218 | - $c->organization->logo_url = $value; |
|
219 | - break; |
|
220 | - case 'event_page_id': |
|
221 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
222 | - // to ESPRESSO_THANK_YOU |
|
223 | - $reg_page_post = get_post($value); |
|
224 | - $reg_page_post->post_content = str_replace( |
|
225 | - "[ESPRESSO_EVENTS]", |
|
226 | - "[ESPRESSO_CHECKOUT]", |
|
227 | - $reg_page_post->post_content |
|
228 | - ); |
|
229 | - wp_update_post($reg_page_post); |
|
230 | - $c->core->reg_page_id = $value; |
|
231 | - break; |
|
232 | - case 'return_url': |
|
233 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
234 | - // to ESPRESSO_THANK_YOU |
|
235 | - $thank_you_page_post = get_post($value); |
|
236 | - $thank_you_page_post->post_content = str_replace( |
|
237 | - "[ESPRESSO_PAYMENTS]", |
|
238 | - "[ESPRESSO_THANK_YOU]", |
|
239 | - $thank_you_page_post->post_content |
|
240 | - ); |
|
241 | - wp_update_post($thank_you_page_post); |
|
242 | - $c->core->thank_you_page_id = $value; |
|
243 | - break; |
|
244 | - case 'cancel_return': |
|
245 | - $c->core->cancel_page_id = $value; |
|
144 | + private function _handle_org_option($option_name, $value) |
|
145 | + { |
|
146 | + $c = EE_Config::instance(); |
|
147 | + $cn = EE_Network_Config::instance(); |
|
148 | + switch ($option_name) { |
|
149 | + case 'organization': |
|
150 | + $c->organization->name = $value; |
|
151 | + break; |
|
152 | + case 'organization_street1': |
|
153 | + $c->organization->address_1 = $value; |
|
154 | + break; |
|
155 | + case 'organization_street2': |
|
156 | + $c->organization->address_2 = $value; |
|
157 | + break; |
|
158 | + case 'organization_city': |
|
159 | + $c->organization->city = $value; |
|
160 | + break; |
|
161 | + case 'organization_state': |
|
162 | + try { |
|
163 | + $state = $this->get_migration_script()->get_or_create_state($value); |
|
164 | + $state_id = $state['STA_ID']; |
|
165 | + $c->organization->STA_ID = $state_id; |
|
166 | + } catch (EE_Error $e) { |
|
167 | + } |
|
168 | + break; |
|
169 | + case 'organization_zip': |
|
170 | + $c->organization->zip = $value; |
|
171 | + break; |
|
172 | + case 'contact_email': |
|
173 | + $c->organization->email = $value; |
|
174 | + break; |
|
175 | + case 'default_payment_status': |
|
176 | + $c->registration->default_STS_ID = |
|
177 | + $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
178 | + break; |
|
179 | + case 'organization_country': |
|
180 | + $iso = $this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
181 | + $c->organization->CNT_ISO = $iso; |
|
182 | + $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
183 | + if (! $country_row) { |
|
184 | + $this->add_error( |
|
185 | + sprintf( |
|
186 | + esc_html__( |
|
187 | + "Could not set country's currency config because no country exists for ISO %s", |
|
188 | + "event_espresso" |
|
189 | + ), |
|
190 | + $iso |
|
191 | + ) |
|
192 | + ); |
|
193 | + } |
|
194 | + // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
195 | + $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
196 | + $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
197 | + $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
198 | + $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
199 | + $c->currency->sign_b4 = filter_var( |
|
200 | + $country_row['CNT_cur_sign_b4'], |
|
201 | + FILTER_VALIDATE_BOOLEAN |
|
202 | + ); // currency sign before or after: $TRUE or FALSE$ |
|
203 | + $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
204 | + $c->currency->dec_mrk = |
|
205 | + $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
206 | + $c->currency->thsnds = $country_row['CNT_cur_thsnds']; |
|
207 | + break; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
208 | + // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
|
209 | + // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
|
210 | + // $c->currency->sign = $value;break; |
|
211 | + case 'show_pending_payment_options': |
|
212 | + $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
213 | + break; |
|
214 | + case 'display_address_in_regform': |
|
215 | + $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
216 | + break; |
|
217 | + case 'default_logo_url': |
|
218 | + $c->organization->logo_url = $value; |
|
219 | + break; |
|
220 | + case 'event_page_id': |
|
221 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
222 | + // to ESPRESSO_THANK_YOU |
|
223 | + $reg_page_post = get_post($value); |
|
224 | + $reg_page_post->post_content = str_replace( |
|
225 | + "[ESPRESSO_EVENTS]", |
|
226 | + "[ESPRESSO_CHECKOUT]", |
|
227 | + $reg_page_post->post_content |
|
228 | + ); |
|
229 | + wp_update_post($reg_page_post); |
|
230 | + $c->core->reg_page_id = $value; |
|
231 | + break; |
|
232 | + case 'return_url': |
|
233 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
234 | + // to ESPRESSO_THANK_YOU |
|
235 | + $thank_you_page_post = get_post($value); |
|
236 | + $thank_you_page_post->post_content = str_replace( |
|
237 | + "[ESPRESSO_PAYMENTS]", |
|
238 | + "[ESPRESSO_THANK_YOU]", |
|
239 | + $thank_you_page_post->post_content |
|
240 | + ); |
|
241 | + wp_update_post($thank_you_page_post); |
|
242 | + $c->core->thank_you_page_id = $value; |
|
243 | + break; |
|
244 | + case 'cancel_return': |
|
245 | + $c->core->cancel_page_id = $value; |
|
246 | 246 | |
247 | - break; |
|
248 | - case 'notify_url': |
|
249 | - $c->core->txn_page_id = $value; |
|
250 | - break; |
|
251 | - case 'use_captcha': |
|
252 | - $c->registration->use_captcha = ($value == 'Y'); |
|
253 | - break; |
|
254 | - case 'recaptcha_publickey': |
|
255 | - $c->registration->recaptcha_publickey = $value; |
|
256 | - break; |
|
257 | - case 'recaptcha_privatekey': |
|
258 | - $c->registration->recaptcha_privatekey = $value; |
|
259 | - break; |
|
260 | - case 'recaptcha_theme': |
|
261 | - $c->registration->recaptcha_theme = $value; |
|
262 | - break; |
|
263 | - case 'recaptcha_width': |
|
264 | - $c->registration->recaptcha_width = $value; |
|
265 | - break; |
|
266 | - case 'recaptcha_language': |
|
267 | - $c->registration->recaptcha_language = $value; |
|
268 | - break; |
|
269 | - case 'espresso_dashboard_widget': |
|
270 | - $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
271 | - break; |
|
272 | - case 'use_personnel_manager': |
|
273 | - $c->admin->use_personnel_manager = ($value == 'Y'); |
|
274 | - break; |
|
275 | - case 'use_event_timezones': |
|
276 | - $c->admin->use_event_timezones = ($value == 'Y'); |
|
277 | - break; |
|
278 | - case 'affiliate_id': |
|
279 | - $c->admin->affiliate_id = $value; |
|
280 | - break; |
|
281 | - case 'site_license_key': |
|
282 | - $cn->core->site_license_key = $value; |
|
283 | - break; |
|
284 | - default: |
|
285 | - do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
286 | - } |
|
287 | - } |
|
247 | + break; |
|
248 | + case 'notify_url': |
|
249 | + $c->core->txn_page_id = $value; |
|
250 | + break; |
|
251 | + case 'use_captcha': |
|
252 | + $c->registration->use_captcha = ($value == 'Y'); |
|
253 | + break; |
|
254 | + case 'recaptcha_publickey': |
|
255 | + $c->registration->recaptcha_publickey = $value; |
|
256 | + break; |
|
257 | + case 'recaptcha_privatekey': |
|
258 | + $c->registration->recaptcha_privatekey = $value; |
|
259 | + break; |
|
260 | + case 'recaptcha_theme': |
|
261 | + $c->registration->recaptcha_theme = $value; |
|
262 | + break; |
|
263 | + case 'recaptcha_width': |
|
264 | + $c->registration->recaptcha_width = $value; |
|
265 | + break; |
|
266 | + case 'recaptcha_language': |
|
267 | + $c->registration->recaptcha_language = $value; |
|
268 | + break; |
|
269 | + case 'espresso_dashboard_widget': |
|
270 | + $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
271 | + break; |
|
272 | + case 'use_personnel_manager': |
|
273 | + $c->admin->use_personnel_manager = ($value == 'Y'); |
|
274 | + break; |
|
275 | + case 'use_event_timezones': |
|
276 | + $c->admin->use_event_timezones = ($value == 'Y'); |
|
277 | + break; |
|
278 | + case 'affiliate_id': |
|
279 | + $c->admin->affiliate_id = $value; |
|
280 | + break; |
|
281 | + case 'site_license_key': |
|
282 | + $cn->core->site_license_key = $value; |
|
283 | + break; |
|
284 | + default: |
|
285 | + do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
286 | + } |
|
287 | + } |
|
288 | 288 | |
289 | 289 | |
290 | - /** |
|
291 | - * Creates a 4.1 member price discount |
|
292 | - * |
|
293 | - * @param array $org_options |
|
294 | - * @return void |
|
295 | - * @global wpdb $wpdb |
|
296 | - */ |
|
297 | - private function _insert_new_global_surcharge_price(array $org_options): void |
|
298 | - { |
|
299 | - $amount = (float) $org_options['surcharge']; |
|
300 | - // dont create a price if the surcharge is 0 |
|
301 | - if ($amount <= .01) { |
|
302 | - return; |
|
303 | - } |
|
304 | - if ($org_options['surcharge_type'] == 'flat_rate') { |
|
305 | - $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
306 | - } else { |
|
307 | - $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
308 | - } |
|
309 | - global $wpdb; |
|
310 | - $cols_n_values = [ |
|
311 | - 'PRT_ID' => $price_type, |
|
312 | - 'PRC_amount' => $amount, |
|
313 | - 'PRC_name' => $org_options['surcharge_text'], |
|
314 | - 'PRC_is_default' => true, |
|
315 | - 'PRC_overrides' => false, |
|
316 | - 'PRC_order' => 100, |
|
317 | - 'PRC_deleted' => false, |
|
318 | - 'PRC_parent' => null, |
|
290 | + /** |
|
291 | + * Creates a 4.1 member price discount |
|
292 | + * |
|
293 | + * @param array $org_options |
|
294 | + * @return void |
|
295 | + * @global wpdb $wpdb |
|
296 | + */ |
|
297 | + private function _insert_new_global_surcharge_price(array $org_options): void |
|
298 | + { |
|
299 | + $amount = (float) $org_options['surcharge']; |
|
300 | + // dont create a price if the surcharge is 0 |
|
301 | + if ($amount <= .01) { |
|
302 | + return; |
|
303 | + } |
|
304 | + if ($org_options['surcharge_type'] == 'flat_rate') { |
|
305 | + $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
306 | + } else { |
|
307 | + $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
308 | + } |
|
309 | + global $wpdb; |
|
310 | + $cols_n_values = [ |
|
311 | + 'PRT_ID' => $price_type, |
|
312 | + 'PRC_amount' => $amount, |
|
313 | + 'PRC_name' => $org_options['surcharge_text'], |
|
314 | + 'PRC_is_default' => true, |
|
315 | + 'PRC_overrides' => false, |
|
316 | + 'PRC_order' => 100, |
|
317 | + 'PRC_deleted' => false, |
|
318 | + 'PRC_parent' => null, |
|
319 | 319 | |
320 | - ]; |
|
321 | - $data_types = [ |
|
322 | - '%d',// PRT_ID |
|
323 | - '%f',// PRT_amount |
|
324 | - '%s',// PRC_name |
|
325 | - '%d',// PRC_is_default |
|
326 | - '%d',// PRC_overrides |
|
327 | - '%d',// PRC_order |
|
328 | - '%d',// PRC_deleted |
|
329 | - '%d',// PRC_parent |
|
330 | - ]; |
|
331 | - $price_table = $wpdb->prefix . "esp_price"; |
|
332 | - $success = $wpdb->insert($price_table, $cols_n_values, $data_types); |
|
333 | - if (! $success) { |
|
334 | - $this->add_error( |
|
335 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
336 | - 'org_options', |
|
337 | - [ |
|
338 | - 'surcharge' => $org_options['surcharge'], |
|
339 | - 'surcharge_type' => $org_options['surcharge_type'], |
|
340 | - 'surcharge_text' => $org_options['surcharge_text'], |
|
341 | - ], |
|
342 | - $price_table, |
|
343 | - $cols_n_values, |
|
344 | - $data_types |
|
345 | - ) |
|
346 | - ); |
|
347 | - } |
|
348 | - } |
|
320 | + ]; |
|
321 | + $data_types = [ |
|
322 | + '%d',// PRT_ID |
|
323 | + '%f',// PRT_amount |
|
324 | + '%s',// PRC_name |
|
325 | + '%d',// PRC_is_default |
|
326 | + '%d',// PRC_overrides |
|
327 | + '%d',// PRC_order |
|
328 | + '%d',// PRC_deleted |
|
329 | + '%d',// PRC_parent |
|
330 | + ]; |
|
331 | + $price_table = $wpdb->prefix . "esp_price"; |
|
332 | + $success = $wpdb->insert($price_table, $cols_n_values, $data_types); |
|
333 | + if (! $success) { |
|
334 | + $this->add_error( |
|
335 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
336 | + 'org_options', |
|
337 | + [ |
|
338 | + 'surcharge' => $org_options['surcharge'], |
|
339 | + 'surcharge_type' => $org_options['surcharge_type'], |
|
340 | + 'surcharge_text' => $org_options['surcharge_text'], |
|
341 | + ], |
|
342 | + $price_table, |
|
343 | + $cols_n_values, |
|
344 | + $data_types |
|
345 | + ) |
|
346 | + ); |
|
347 | + } |
|
348 | + } |
|
349 | 349 | |
350 | 350 | |
351 | - protected $_org_options_we_know_how_to_migrate = [ |
|
352 | - 'organization', |
|
353 | - 'organization_street1', |
|
354 | - 'organization_street2', |
|
355 | - 'organization_city', |
|
356 | - 'organization_state', |
|
357 | - 'organization_zip', |
|
358 | - 'contact_email', |
|
359 | - 'default_mail', |
|
360 | - 'payment_subject', |
|
361 | - 'payment_message', |
|
362 | - 'message', |
|
363 | - 'default_payment_status', |
|
364 | - 'surcharge',// unused? |
|
365 | - 'country_id',// unused? |
|
366 | - 'organization_country', |
|
367 | - // 'currency_symbol', |
|
368 | - 'expire_on_registration_end', |
|
369 | - 'email_before_payment', |
|
370 | - 'email_fancy_headers', |
|
371 | - 'enable_default_style', |
|
372 | - 'event_ssl_active', |
|
373 | - 'selected_style', |
|
374 | - 'show_pending_payment_options', |
|
375 | - 'show_reg_footer', |
|
376 | - 'skip_confirmation_page', |
|
377 | - 'allow_mer_discounts',// no equiv |
|
378 | - 'allow_mer_vouchers',// no equiv |
|
379 | - 'display_short_description_in_event_list', |
|
380 | - 'display_description_on_multi_reg_page', |
|
381 | - 'display_address_in_event_list', |
|
382 | - 'display_address_in_regform', |
|
383 | - 'use_custom_post_types',// no equiv |
|
384 | - 'display_ical_download', |
|
385 | - 'display_featured_image', |
|
386 | - 'themeroller', |
|
387 | - 'default_logo_url', |
|
388 | - 'event_page_id', |
|
389 | - 'return_url', |
|
390 | - 'cancel_return', |
|
391 | - 'notify_url', |
|
392 | - 'events_in_dashboard', |
|
393 | - 'use_captcha', |
|
394 | - 'recaptcha_publickey', |
|
395 | - 'recaptcha_privatekey', |
|
396 | - 'recaptcha_theme', |
|
397 | - 'recaptcha_width', |
|
398 | - 'recaptcha_language', |
|
399 | - 'espresso_dashboard_widget', |
|
400 | - 'time_reg_limit', |
|
401 | - // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
|
402 | - 'use_personnel_manager',// no equiv |
|
403 | - 'use_event_timezones', |
|
404 | - 'full_logging', |
|
405 | - 'surcharge_type',// unused |
|
406 | - 'surcharge_text',// unused |
|
407 | - 'affiliate_id', |
|
408 | - 'site_license_key', |
|
409 | - ]; |
|
351 | + protected $_org_options_we_know_how_to_migrate = [ |
|
352 | + 'organization', |
|
353 | + 'organization_street1', |
|
354 | + 'organization_street2', |
|
355 | + 'organization_city', |
|
356 | + 'organization_state', |
|
357 | + 'organization_zip', |
|
358 | + 'contact_email', |
|
359 | + 'default_mail', |
|
360 | + 'payment_subject', |
|
361 | + 'payment_message', |
|
362 | + 'message', |
|
363 | + 'default_payment_status', |
|
364 | + 'surcharge',// unused? |
|
365 | + 'country_id',// unused? |
|
366 | + 'organization_country', |
|
367 | + // 'currency_symbol', |
|
368 | + 'expire_on_registration_end', |
|
369 | + 'email_before_payment', |
|
370 | + 'email_fancy_headers', |
|
371 | + 'enable_default_style', |
|
372 | + 'event_ssl_active', |
|
373 | + 'selected_style', |
|
374 | + 'show_pending_payment_options', |
|
375 | + 'show_reg_footer', |
|
376 | + 'skip_confirmation_page', |
|
377 | + 'allow_mer_discounts',// no equiv |
|
378 | + 'allow_mer_vouchers',// no equiv |
|
379 | + 'display_short_description_in_event_list', |
|
380 | + 'display_description_on_multi_reg_page', |
|
381 | + 'display_address_in_event_list', |
|
382 | + 'display_address_in_regform', |
|
383 | + 'use_custom_post_types',// no equiv |
|
384 | + 'display_ical_download', |
|
385 | + 'display_featured_image', |
|
386 | + 'themeroller', |
|
387 | + 'default_logo_url', |
|
388 | + 'event_page_id', |
|
389 | + 'return_url', |
|
390 | + 'cancel_return', |
|
391 | + 'notify_url', |
|
392 | + 'events_in_dashboard', |
|
393 | + 'use_captcha', |
|
394 | + 'recaptcha_publickey', |
|
395 | + 'recaptcha_privatekey', |
|
396 | + 'recaptcha_theme', |
|
397 | + 'recaptcha_width', |
|
398 | + 'recaptcha_language', |
|
399 | + 'espresso_dashboard_widget', |
|
400 | + 'time_reg_limit', |
|
401 | + // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
|
402 | + 'use_personnel_manager',// no equiv |
|
403 | + 'use_event_timezones', |
|
404 | + 'full_logging', |
|
405 | + 'surcharge_type',// unused |
|
406 | + 'surcharge_text',// unused |
|
407 | + 'affiliate_id', |
|
408 | + 'site_license_key', |
|
409 | + ]; |
|
410 | 410 | } |