@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*'); |
18 | 18 | $class_to_filepath = array(); |
19 | 19 | foreach ($stages as $filepath) { |
20 | - $matches = array(); |
|
21 | - preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
22 | - $class_to_filepath[$matches[1]] = $filepath; |
|
20 | + $matches = array(); |
|
21 | + preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
22 | + $class_to_filepath[$matches[1]] = $filepath; |
|
23 | 23 | } |
24 | 24 | //give addons a chance to autoload their stages too |
25 | 25 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath); |
@@ -38,71 +38,71 @@ discard block |
||
38 | 38 | class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base |
39 | 39 | { |
40 | 40 | |
41 | - /** |
|
42 | - * return EE_DMS_Core_4_8_0 |
|
43 | - * |
|
44 | - * @param TableManager $table_manager |
|
45 | - * @param TableAnalysis $table_analysis |
|
46 | - */ |
|
47 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
48 | - { |
|
49 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso"); |
|
50 | - $this->_priority = 10; |
|
51 | - $this->_migration_stages = array( |
|
52 | - new EE_DMS_4_8_0_pretax_totals(), |
|
53 | - new EE_DMS_4_8_0_event_subtotals(), |
|
54 | - ); |
|
55 | - parent::__construct($table_manager, $table_analysis); |
|
56 | - } |
|
41 | + /** |
|
42 | + * return EE_DMS_Core_4_8_0 |
|
43 | + * |
|
44 | + * @param TableManager $table_manager |
|
45 | + * @param TableAnalysis $table_analysis |
|
46 | + */ |
|
47 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
48 | + { |
|
49 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso"); |
|
50 | + $this->_priority = 10; |
|
51 | + $this->_migration_stages = array( |
|
52 | + new EE_DMS_4_8_0_pretax_totals(), |
|
53 | + new EE_DMS_4_8_0_event_subtotals(), |
|
54 | + ); |
|
55 | + parent::__construct($table_manager, $table_analysis); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Because this is being done at basically the same time as the MER-ready branch |
|
62 | - * of core, it's possible people might have installed MEr-ready branch first, |
|
63 | - * and then this one, in which case we still want to perform this migration, |
|
64 | - * even though the version might not have increased |
|
65 | - * |
|
66 | - * @param array $version_array |
|
67 | - * @return bool |
|
68 | - */ |
|
69 | - public function can_migrate_from_version($version_array) |
|
70 | - { |
|
71 | - $version_string = $version_array['Core']; |
|
72 | - if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) { |
|
60 | + /** |
|
61 | + * Because this is being done at basically the same time as the MER-ready branch |
|
62 | + * of core, it's possible people might have installed MEr-ready branch first, |
|
63 | + * and then this one, in which case we still want to perform this migration, |
|
64 | + * even though the version might not have increased |
|
65 | + * |
|
66 | + * @param array $version_array |
|
67 | + * @return bool |
|
68 | + */ |
|
69 | + public function can_migrate_from_version($version_array) |
|
70 | + { |
|
71 | + $version_string = $version_array['Core']; |
|
72 | + if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) { |
|
73 | 73 | // echo "$version_string can be migrated from"; |
74 | - return true; |
|
75 | - } elseif ( ! $version_string) { |
|
74 | + return true; |
|
75 | + } elseif ( ! $version_string) { |
|
76 | 76 | // echo "no version string provided: $version_string"; |
77 | - //no version string provided... this must be pre 4.3 |
|
78 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | - } else { |
|
77 | + //no version string provided... this must be pre 4.3 |
|
78 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | + } else { |
|
80 | 80 | // echo "$version_string doesnt apply"; |
81 | - return false; |
|
82 | - } |
|
83 | - } |
|
81 | + return false; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function schema_changes_before_migration() |
|
91 | - { |
|
92 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
93 | - $now_in_mysql = current_time('mysql', true); |
|
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | - $table_name = 'esp_answer'; |
|
96 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
87 | + /** |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function schema_changes_before_migration() |
|
91 | + { |
|
92 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
93 | + $now_in_mysql = current_time('mysql', true); |
|
94 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | + $table_name = 'esp_answer'; |
|
96 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
97 | 97 | REG_ID int(10) unsigned NOT NULL, |
98 | 98 | QST_ID int(10) unsigned NOT NULL, |
99 | 99 | ANS_value text NOT NULL, |
100 | 100 | PRIMARY KEY (ANS_ID), |
101 | 101 | KEY REG_ID (REG_ID), |
102 | 102 | KEY QST_ID (QST_ID)"; |
103 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
104 | - $table_name = 'esp_attendee_meta'; |
|
105 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
103 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
104 | + $table_name = 'esp_attendee_meta'; |
|
105 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
106 | 106 | ATT_ID bigint(20) unsigned NOT NULL, |
107 | 107 | ATT_fname varchar(45) NOT NULL, |
108 | 108 | ATT_lname varchar(45) NOT NULL, |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | KEY ATT_email (ATT_email), |
120 | 120 | KEY ATT_lname (ATT_lname), |
121 | 121 | KEY ATT_fname (ATT_fname)"; |
122 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
123 | - $table_name = 'esp_country'; |
|
124 | - $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
122 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
123 | + $table_name = 'esp_country'; |
|
124 | + $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
125 | 125 | CNT_ISO3 varchar(3) collate utf8_bin NOT NULL, |
126 | 126 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
127 | 127 | CNT_name varchar(45) collate utf8_bin NOT NULL, |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | CNT_is_EU tinyint(1) DEFAULT '0', |
138 | 138 | CNT_active tinyint(1) DEFAULT '0', |
139 | 139 | PRIMARY KEY (CNT_ISO)"; |
140 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
141 | - $table_name = 'esp_currency'; |
|
142 | - $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
140 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
141 | + $table_name = 'esp_currency'; |
|
142 | + $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
143 | 143 | CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar', |
144 | 144 | CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars', |
145 | 145 | CUR_sign varchar(45) collate utf8_bin DEFAULT '$', |
146 | 146 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
147 | 147 | CUR_active tinyint(1) DEFAULT '0', |
148 | 148 | PRIMARY KEY (CUR_code)"; |
149 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
150 | - $table_name = 'esp_datetime'; |
|
151 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
149 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
150 | + $table_name = 'esp_datetime'; |
|
151 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
152 | 152 | EVT_ID bigint(20) unsigned NOT NULL, |
153 | 153 | DTT_name varchar(255) NOT NULL DEFAULT '', |
154 | 154 | DTT_description text NOT NULL, |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | KEY DTT_EVT_start (DTT_EVT_start), |
165 | 165 | KEY EVT_ID (EVT_ID), |
166 | 166 | KEY DTT_is_primary (DTT_is_primary)"; |
167 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
168 | - $table_name = 'esp_event_meta'; |
|
169 | - $sql = " |
|
167 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
168 | + $table_name = 'esp_event_meta'; |
|
169 | + $sql = " |
|
170 | 170 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
171 | 171 | EVT_ID bigint(20) unsigned NOT NULL, |
172 | 172 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -182,34 +182,34 @@ discard block |
||
182 | 182 | EVT_donations tinyint(1) NULL, |
183 | 183 | PRIMARY KEY (EVTM_ID), |
184 | 184 | KEY EVT_ID (EVT_ID)"; |
185 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | - $table_name = 'esp_event_question_group'; |
|
187 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
185 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $table_name = 'esp_event_question_group'; |
|
187 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | 188 | EVT_ID bigint(20) unsigned NOT NULL, |
189 | 189 | QSG_ID int(10) unsigned NOT NULL, |
190 | 190 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
191 | 191 | PRIMARY KEY (EQG_ID), |
192 | 192 | KEY EVT_ID (EVT_ID), |
193 | 193 | KEY QSG_ID (QSG_ID)"; |
194 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
195 | - $table_name = 'esp_event_venue'; |
|
196 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
194 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
195 | + $table_name = 'esp_event_venue'; |
|
196 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
197 | 197 | EVT_ID bigint(20) unsigned NOT NULL, |
198 | 198 | VNU_ID bigint(20) unsigned NOT NULL, |
199 | 199 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
200 | 200 | PRIMARY KEY (EVV_ID)"; |
201 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | - $table_name = 'esp_extra_meta'; |
|
203 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
201 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | + $table_name = 'esp_extra_meta'; |
|
203 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
204 | 204 | OBJ_ID int(11) DEFAULT NULL, |
205 | 205 | EXM_type varchar(45) DEFAULT NULL, |
206 | 206 | EXM_key varchar(45) DEFAULT NULL, |
207 | 207 | EXM_value text, |
208 | 208 | PRIMARY KEY (EXM_ID), |
209 | 209 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
210 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | - $table_name = 'esp_extra_join'; |
|
212 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
210 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | + $table_name = 'esp_extra_join'; |
|
212 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
213 | 213 | EXJ_first_model_id varchar(6) NOT NULL, |
214 | 214 | EXJ_first_model_name varchar(20) NOT NULL, |
215 | 215 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | PRIMARY KEY (EXJ_ID), |
218 | 218 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
219 | 219 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
220 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
221 | - $table_name = 'esp_line_item'; |
|
222 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
220 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
221 | + $table_name = 'esp_line_item'; |
|
222 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
223 | 223 | LIN_code varchar(245) NOT NULL DEFAULT '', |
224 | 224 | TXN_ID int(11) DEFAULT NULL, |
225 | 225 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | PRIMARY KEY (LIN_ID), |
239 | 239 | KEY LIN_code (LIN_code(191)), |
240 | 240 | KEY TXN_ID (TXN_ID)"; |
241 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
242 | - $table_name = 'esp_log'; |
|
243 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
241 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
242 | + $table_name = 'esp_log'; |
|
243 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
244 | 244 | LOG_time datetime DEFAULT NULL, |
245 | 245 | OBJ_ID varchar(45) DEFAULT NULL, |
246 | 246 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -251,18 +251,18 @@ discard block |
||
251 | 251 | KEY LOG_time (LOG_time), |
252 | 252 | KEY OBJ (OBJ_type,OBJ_ID), |
253 | 253 | KEY LOG_type (LOG_type)"; |
254 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
255 | - $table_name = 'esp_message_template'; |
|
256 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
254 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
255 | + $table_name = 'esp_message_template'; |
|
256 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
257 | 257 | GRP_ID int(10) unsigned NOT NULL, |
258 | 258 | MTP_context varchar(50) NOT NULL, |
259 | 259 | MTP_template_field varchar(30) NOT NULL, |
260 | 260 | MTP_content text NOT NULL, |
261 | 261 | PRIMARY KEY (MTP_ID), |
262 | 262 | KEY GRP_ID (GRP_ID)"; |
263 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | - $table_name = 'esp_message_template_group'; |
|
265 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
263 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | + $table_name = 'esp_message_template_group'; |
|
265 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
266 | 266 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
267 | 267 | MTP_name varchar(245) NOT NULL DEFAULT '', |
268 | 268 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -274,17 +274,17 @@ discard block |
||
274 | 274 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
275 | 275 | PRIMARY KEY (GRP_ID), |
276 | 276 | KEY MTP_user_id (MTP_user_id)"; |
277 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
278 | - $table_name = 'esp_event_message_template'; |
|
279 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
277 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
278 | + $table_name = 'esp_event_message_template'; |
|
279 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
280 | 280 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
281 | 281 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
282 | 282 | PRIMARY KEY (EMT_ID), |
283 | 283 | KEY EVT_ID (EVT_ID), |
284 | 284 | KEY GRP_ID (GRP_ID)"; |
285 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
286 | - $table_name = 'esp_payment'; |
|
287 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
285 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
286 | + $table_name = 'esp_payment'; |
|
287 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
288 | 288 | TXN_ID int(10) unsigned DEFAULT NULL, |
289 | 289 | STS_ID varchar(3) collate utf8_bin DEFAULT NULL, |
290 | 290 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | PRIMARY KEY (PAY_ID), |
302 | 302 | KEY PAY_timestamp (PAY_timestamp), |
303 | 303 | KEY TXN_ID (TXN_ID)"; |
304 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
305 | - $table_name = 'esp_payment_method'; |
|
306 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
304 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
305 | + $table_name = 'esp_payment_method'; |
|
306 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
307 | 307 | PMD_type varchar(124) DEFAULT NULL, |
308 | 308 | PMD_name varchar(255) DEFAULT NULL, |
309 | 309 | PMD_desc text, |
@@ -319,32 +319,32 @@ discard block |
||
319 | 319 | PRIMARY KEY (PMD_ID), |
320 | 320 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
321 | 321 | KEY PMD_type (PMD_type)"; |
322 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
323 | - $table_name = "esp_ticket_price"; |
|
324 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
322 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
323 | + $table_name = "esp_ticket_price"; |
|
324 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
325 | 325 | TKT_ID int(10) unsigned NOT NULL, |
326 | 326 | PRC_ID int(10) unsigned NOT NULL, |
327 | 327 | PRIMARY KEY (TKP_ID), |
328 | 328 | KEY TKT_ID (TKT_ID), |
329 | 329 | KEY PRC_ID (PRC_ID)"; |
330 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
331 | - $table_name = "esp_datetime_ticket"; |
|
332 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
330 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
331 | + $table_name = "esp_datetime_ticket"; |
|
332 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | 333 | DTT_ID int(10) unsigned NOT NULL, |
334 | 334 | TKT_ID int(10) unsigned NOT NULL, |
335 | 335 | PRIMARY KEY (DTK_ID), |
336 | 336 | KEY DTT_ID (DTT_ID), |
337 | 337 | KEY TKT_ID (TKT_ID)"; |
338 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
339 | - $table_name = "esp_ticket_template"; |
|
340 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
338 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
339 | + $table_name = "esp_ticket_template"; |
|
340 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
341 | 341 | TTM_name varchar(45) NOT NULL, |
342 | 342 | TTM_description text, |
343 | 343 | TTM_file varchar(45), |
344 | 344 | PRIMARY KEY (TTM_ID)"; |
345 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
346 | - $table_name = 'esp_question'; |
|
347 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
345 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
346 | + $table_name = 'esp_question'; |
|
347 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
348 | 348 | QST_display_text text NOT NULL, |
349 | 349 | QST_admin_label varchar(255) NOT NULL, |
350 | 350 | QST_system varchar(25) NOT NULL DEFAULT "", |
@@ -358,18 +358,18 @@ discard block |
||
358 | 358 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
359 | 359 | PRIMARY KEY (QST_ID), |
360 | 360 | KEY QST_order (QST_order)'; |
361 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
362 | - $table_name = 'esp_question_group_question'; |
|
363 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
361 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
362 | + $table_name = 'esp_question_group_question'; |
|
363 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
364 | 364 | QSG_ID int(10) unsigned NOT NULL, |
365 | 365 | QST_ID int(10) unsigned NOT NULL, |
366 | 366 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
367 | 367 | PRIMARY KEY (QGQ_ID), |
368 | 368 | KEY QST_ID (QST_ID), |
369 | 369 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
370 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
371 | - $table_name = 'esp_question_option'; |
|
372 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
370 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
371 | + $table_name = 'esp_question_option'; |
|
372 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
373 | 373 | QSO_value varchar(255) NOT NULL, |
374 | 374 | QSO_desc text NOT NULL, |
375 | 375 | QST_ID int(10) unsigned NOT NULL, |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | PRIMARY KEY (QSO_ID), |
380 | 380 | KEY QST_ID (QST_ID), |
381 | 381 | KEY QSO_order (QSO_order)"; |
382 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
383 | - $table_name = 'esp_registration'; |
|
384 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
382 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
383 | + $table_name = 'esp_registration'; |
|
384 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
385 | 385 | EVT_ID bigint(20) unsigned NOT NULL, |
386 | 386 | ATT_ID bigint(20) unsigned NOT NULL, |
387 | 387 | TXN_ID int(10) unsigned NOT NULL, |
@@ -405,18 +405,18 @@ discard block |
||
405 | 405 | KEY TKT_ID (TKT_ID), |
406 | 406 | KEY EVT_ID (EVT_ID), |
407 | 407 | KEY STS_ID (STS_ID)"; |
408 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
409 | - $table_name = 'esp_registration_payment'; |
|
410 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
408 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
409 | + $table_name = 'esp_registration_payment'; |
|
410 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
411 | 411 | REG_ID int(10) unsigned NOT NULL, |
412 | 412 | PAY_ID int(10) unsigned NULL, |
413 | 413 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
414 | 414 | PRIMARY KEY (RPY_ID), |
415 | 415 | KEY REG_ID (REG_ID), |
416 | 416 | KEY PAY_ID (PAY_ID)"; |
417 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
418 | - $table_name = 'esp_checkin'; |
|
419 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
417 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
418 | + $table_name = 'esp_checkin'; |
|
419 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
420 | 420 | REG_ID int(10) unsigned NOT NULL, |
421 | 421 | DTT_ID int(10) unsigned NOT NULL, |
422 | 422 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -424,9 +424,9 @@ discard block |
||
424 | 424 | PRIMARY KEY (CHK_ID), |
425 | 425 | KEY REG_ID (REG_ID), |
426 | 426 | KEY DTT_ID (DTT_ID)"; |
427 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
428 | - $table_name = 'esp_state'; |
|
429 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
427 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
428 | + $table_name = 'esp_state'; |
|
429 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
430 | 430 | CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
431 | 431 | STA_abbrev varchar(24) collate utf8_bin NOT NULL, |
432 | 432 | STA_name varchar(100) collate utf8_bin NOT NULL, |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | PRIMARY KEY (STA_ID), |
435 | 435 | KEY STA_abbrev (STA_abbrev), |
436 | 436 | KEY CNT_ISO (CNT_ISO)"; |
437 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
438 | - $table_name = 'esp_status'; |
|
439 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
437 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
438 | + $table_name = 'esp_status'; |
|
439 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
440 | 440 | STS_code varchar(45) NOT NULL, |
441 | 441 | STS_type varchar(45) NOT NULL, |
442 | 442 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
445 | 445 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
446 | 446 | KEY STS_type (STS_type)"; |
447 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
448 | - $table_name = 'esp_transaction'; |
|
449 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
447 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
448 | + $table_name = 'esp_transaction'; |
|
449 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
450 | 450 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
451 | 451 | TXN_total decimal(10,3) DEFAULT '0.00', |
452 | 452 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | PRIMARY KEY (TXN_ID), |
459 | 459 | KEY TXN_timestamp (TXN_timestamp), |
460 | 460 | KEY STS_ID (STS_ID)"; |
461 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
462 | - $table_name = 'esp_venue_meta'; |
|
463 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
461 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
462 | + $table_name = 'esp_venue_meta'; |
|
463 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
464 | 464 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
465 | 465 | VNU_address varchar(255) DEFAULT NULL, |
466 | 466 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | KEY VNU_ID (VNU_ID), |
480 | 480 | KEY STA_ID (STA_ID), |
481 | 481 | KEY CNT_ISO (CNT_ISO)"; |
482 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
483 | - //modified tables |
|
484 | - $table_name = "esp_price"; |
|
485 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
482 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
483 | + //modified tables |
|
484 | + $table_name = "esp_price"; |
|
485 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
486 | 486 | PRT_ID tinyint(3) unsigned NOT NULL, |
487 | 487 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
488 | 488 | PRC_name varchar(245) NOT NULL, |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | PRC_parent int(10) unsigned DEFAULT 0, |
496 | 496 | PRIMARY KEY (PRC_ID), |
497 | 497 | KEY PRT_ID (PRT_ID)"; |
498 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
499 | - $table_name = "esp_price_type"; |
|
500 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
498 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
499 | + $table_name = "esp_price_type"; |
|
500 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
501 | 501 | PRT_name varchar(45) NOT NULL, |
502 | 502 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
503 | 503 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
507 | 507 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
508 | 508 | PRIMARY KEY (PRT_ID)"; |
509 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
510 | - $table_name = "esp_ticket"; |
|
511 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
509 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
510 | + $table_name = "esp_ticket"; |
|
511 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
512 | 512 | TTM_ID int(10) unsigned NOT NULL, |
513 | 513 | TKT_name varchar(245) NOT NULL DEFAULT '', |
514 | 514 | TKT_description text NOT NULL, |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
531 | 531 | PRIMARY KEY (TKT_ID), |
532 | 532 | KEY TKT_start_date (TKT_start_date)"; |
533 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
534 | - $table_name = 'esp_question_group'; |
|
535 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
533 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
534 | + $table_name = 'esp_question_group'; |
|
535 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
536 | 536 | QSG_name varchar(255) NOT NULL, |
537 | 537 | QSG_identifier varchar(100) NOT NULL, |
538 | 538 | QSG_desc text NULL, |
@@ -545,221 +545,221 @@ discard block |
||
545 | 545 | PRIMARY KEY (QSG_ID), |
546 | 546 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
547 | 547 | KEY QSG_order (QSG_order)'; |
548 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
549 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
550 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
551 | - //(because many need to convert old string states to foreign keys into the states table) |
|
552 | - $script_4_1_defaults->insert_default_states(); |
|
553 | - $script_4_1_defaults->insert_default_countries(); |
|
554 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
555 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
556 | - $script_4_5_defaults->insert_default_price_types(); |
|
557 | - $script_4_5_defaults->insert_default_prices(); |
|
558 | - $script_4_5_defaults->insert_default_tickets(); |
|
559 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
560 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
561 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
562 | - $script_4_6_defaults->insert_default_currencies(); |
|
563 | - $this->verify_new_countries(); |
|
564 | - $this->verify_new_currencies(); |
|
565 | - return true; |
|
566 | - } |
|
548 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
549 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
550 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
551 | + //(because many need to convert old string states to foreign keys into the states table) |
|
552 | + $script_4_1_defaults->insert_default_states(); |
|
553 | + $script_4_1_defaults->insert_default_countries(); |
|
554 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
555 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
556 | + $script_4_5_defaults->insert_default_price_types(); |
|
557 | + $script_4_5_defaults->insert_default_prices(); |
|
558 | + $script_4_5_defaults->insert_default_tickets(); |
|
559 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
560 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
561 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
562 | + $script_4_6_defaults->insert_default_currencies(); |
|
563 | + $this->verify_new_countries(); |
|
564 | + $this->verify_new_currencies(); |
|
565 | + return true; |
|
566 | + } |
|
567 | 567 | |
568 | 568 | |
569 | 569 | |
570 | - /** |
|
571 | - * @return boolean |
|
572 | - */ |
|
573 | - public function schema_changes_after_migration() |
|
574 | - { |
|
575 | - $this->fix_non_default_taxes(); |
|
576 | - //this is actually the same as the last DMS |
|
577 | - /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
578 | - $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
579 | - return $script_4_7_defaults->schema_changes_after_migration(); |
|
580 | - } |
|
570 | + /** |
|
571 | + * @return boolean |
|
572 | + */ |
|
573 | + public function schema_changes_after_migration() |
|
574 | + { |
|
575 | + $this->fix_non_default_taxes(); |
|
576 | + //this is actually the same as the last DMS |
|
577 | + /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
578 | + $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
579 | + return $script_4_7_defaults->schema_changes_after_migration(); |
|
580 | + } |
|
581 | 581 | |
582 | 582 | |
583 | 583 | |
584 | - public function migration_page_hooks() |
|
585 | - { |
|
586 | - } |
|
584 | + public function migration_page_hooks() |
|
585 | + { |
|
586 | + } |
|
587 | 587 | |
588 | 588 | |
589 | 589 | |
590 | - /** |
|
591 | - * verifies each of the new countries exists that somehow we missed in 4.1 |
|
592 | - */ |
|
593 | - public function verify_new_countries() |
|
594 | - { |
|
595 | - //a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
596 | - //how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
597 | - //currency symbols: http://www.xe.com/symbols.php |
|
598 | - //CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active |
|
599 | - //('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
600 | - $newer_countries = array( |
|
601 | - array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0), |
|
602 | - array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
603 | - array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0), |
|
604 | - array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0), |
|
605 | - array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
606 | - array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
607 | - array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
608 | - array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0), |
|
609 | - array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0), |
|
610 | - array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0), |
|
611 | - array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0), |
|
612 | - array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0), |
|
613 | - array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0), |
|
614 | - array( |
|
615 | - 'BQ', |
|
616 | - 'BES', |
|
617 | - 0, |
|
618 | - 'Bonaire, Saint Eustatius and Saba', |
|
619 | - 'USD', |
|
620 | - 'Dollar', |
|
621 | - 'Dollars', |
|
622 | - '$', |
|
623 | - 1, |
|
624 | - 2, |
|
625 | - '+599', |
|
626 | - 0, |
|
627 | - 0, |
|
628 | - ), |
|
629 | - array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0), |
|
630 | - array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0), |
|
631 | - array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0), |
|
632 | - array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0), |
|
633 | - array( |
|
634 | - 'HM', |
|
635 | - 'HMD', |
|
636 | - 0, |
|
637 | - 'Heard Island and McDonald Islands', |
|
638 | - 'AUD', |
|
639 | - 'Dollar', |
|
640 | - 'Dollars', |
|
641 | - '$', |
|
642 | - 1, |
|
643 | - 2, |
|
644 | - '+891', |
|
645 | - 0, |
|
646 | - 0, |
|
647 | - ), |
|
648 | - array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0), |
|
649 | - array( |
|
650 | - 'GS', |
|
651 | - 'SGS', |
|
652 | - 0, |
|
653 | - 'South Georgia and the South Sandwich Islands', |
|
654 | - 'GBP', |
|
655 | - 'Pound', |
|
656 | - 'Pounds', |
|
657 | - '£', |
|
658 | - 1, |
|
659 | - 2, |
|
660 | - '+500', |
|
661 | - 0, |
|
662 | - 0, |
|
663 | - ), |
|
664 | - array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0), |
|
665 | - array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0), |
|
666 | - array( |
|
667 | - 'UM', |
|
668 | - 'UMI', |
|
669 | - 0, |
|
670 | - 'United States Minor Outlying Islands', |
|
671 | - 'USD', |
|
672 | - 'Dollar', |
|
673 | - 'Dollars', |
|
674 | - '$', |
|
675 | - 1, |
|
676 | - 2, |
|
677 | - '+1', |
|
678 | - 0, |
|
679 | - 0, |
|
680 | - ), |
|
681 | - ); |
|
682 | - global $wpdb; |
|
683 | - $country_table = $wpdb->prefix . "esp_country"; |
|
684 | - $country_format = array( |
|
685 | - "CNT_ISO" => '%s', |
|
686 | - "CNT_ISO3" => '%s', |
|
687 | - "RGN_ID" => '%d', |
|
688 | - "CNT_name" => '%s', |
|
689 | - "CNT_cur_code" => '%s', |
|
690 | - "CNT_cur_single" => '%s', |
|
691 | - "CNT_cur_plural" => '%s', |
|
692 | - "CNT_cur_sign" => '%s', |
|
693 | - "CNT_cur_sign_b4" => '%d', |
|
694 | - "CNT_cur_dec_plc" => '%d', |
|
695 | - "CNT_tel_code" => '%s', |
|
696 | - "CNT_is_EU" => '%d', |
|
697 | - "CNT_active" => '%d', |
|
698 | - ); |
|
699 | - if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
700 | - foreach ($newer_countries as $country) { |
|
701 | - $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
|
702 | - $countries = $wpdb->get_var($SQL); |
|
703 | - if ( ! $countries) { |
|
704 | - $wpdb->insert($country_table, |
|
705 | - array_combine(array_keys($country_format), $country), |
|
706 | - $country_format |
|
707 | - ); |
|
708 | - } |
|
709 | - } |
|
710 | - } |
|
711 | - } |
|
590 | + /** |
|
591 | + * verifies each of the new countries exists that somehow we missed in 4.1 |
|
592 | + */ |
|
593 | + public function verify_new_countries() |
|
594 | + { |
|
595 | + //a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
596 | + //how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
597 | + //currency symbols: http://www.xe.com/symbols.php |
|
598 | + //CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active |
|
599 | + //('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
600 | + $newer_countries = array( |
|
601 | + array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0), |
|
602 | + array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
603 | + array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0), |
|
604 | + array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0), |
|
605 | + array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
606 | + array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
607 | + array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
608 | + array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0), |
|
609 | + array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0), |
|
610 | + array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0), |
|
611 | + array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0), |
|
612 | + array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0), |
|
613 | + array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0), |
|
614 | + array( |
|
615 | + 'BQ', |
|
616 | + 'BES', |
|
617 | + 0, |
|
618 | + 'Bonaire, Saint Eustatius and Saba', |
|
619 | + 'USD', |
|
620 | + 'Dollar', |
|
621 | + 'Dollars', |
|
622 | + '$', |
|
623 | + 1, |
|
624 | + 2, |
|
625 | + '+599', |
|
626 | + 0, |
|
627 | + 0, |
|
628 | + ), |
|
629 | + array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0), |
|
630 | + array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0), |
|
631 | + array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0), |
|
632 | + array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0), |
|
633 | + array( |
|
634 | + 'HM', |
|
635 | + 'HMD', |
|
636 | + 0, |
|
637 | + 'Heard Island and McDonald Islands', |
|
638 | + 'AUD', |
|
639 | + 'Dollar', |
|
640 | + 'Dollars', |
|
641 | + '$', |
|
642 | + 1, |
|
643 | + 2, |
|
644 | + '+891', |
|
645 | + 0, |
|
646 | + 0, |
|
647 | + ), |
|
648 | + array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0), |
|
649 | + array( |
|
650 | + 'GS', |
|
651 | + 'SGS', |
|
652 | + 0, |
|
653 | + 'South Georgia and the South Sandwich Islands', |
|
654 | + 'GBP', |
|
655 | + 'Pound', |
|
656 | + 'Pounds', |
|
657 | + '£', |
|
658 | + 1, |
|
659 | + 2, |
|
660 | + '+500', |
|
661 | + 0, |
|
662 | + 0, |
|
663 | + ), |
|
664 | + array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0), |
|
665 | + array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0), |
|
666 | + array( |
|
667 | + 'UM', |
|
668 | + 'UMI', |
|
669 | + 0, |
|
670 | + 'United States Minor Outlying Islands', |
|
671 | + 'USD', |
|
672 | + 'Dollar', |
|
673 | + 'Dollars', |
|
674 | + '$', |
|
675 | + 1, |
|
676 | + 2, |
|
677 | + '+1', |
|
678 | + 0, |
|
679 | + 0, |
|
680 | + ), |
|
681 | + ); |
|
682 | + global $wpdb; |
|
683 | + $country_table = $wpdb->prefix . "esp_country"; |
|
684 | + $country_format = array( |
|
685 | + "CNT_ISO" => '%s', |
|
686 | + "CNT_ISO3" => '%s', |
|
687 | + "RGN_ID" => '%d', |
|
688 | + "CNT_name" => '%s', |
|
689 | + "CNT_cur_code" => '%s', |
|
690 | + "CNT_cur_single" => '%s', |
|
691 | + "CNT_cur_plural" => '%s', |
|
692 | + "CNT_cur_sign" => '%s', |
|
693 | + "CNT_cur_sign_b4" => '%d', |
|
694 | + "CNT_cur_dec_plc" => '%d', |
|
695 | + "CNT_tel_code" => '%s', |
|
696 | + "CNT_is_EU" => '%d', |
|
697 | + "CNT_active" => '%d', |
|
698 | + ); |
|
699 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
700 | + foreach ($newer_countries as $country) { |
|
701 | + $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
|
702 | + $countries = $wpdb->get_var($SQL); |
|
703 | + if ( ! $countries) { |
|
704 | + $wpdb->insert($country_table, |
|
705 | + array_combine(array_keys($country_format), $country), |
|
706 | + $country_format |
|
707 | + ); |
|
708 | + } |
|
709 | + } |
|
710 | + } |
|
711 | + } |
|
712 | 712 | |
713 | 713 | |
714 | 714 | |
715 | - /** |
|
716 | - * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
717 | - */ |
|
718 | - public function verify_new_currencies() |
|
719 | - { |
|
720 | - //a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
721 | - //how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
722 | - //currency symbols: http://www.xe.com/symbols.php |
|
723 | - // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
724 | - //( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
725 | - $newer_currencies = array( |
|
726 | - array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
|
727 | - ); |
|
728 | - global $wpdb; |
|
729 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
730 | - $currency_format = array( |
|
731 | - "CUR_code" => '%s', |
|
732 | - "CUR_single" => '%s', |
|
733 | - "CUR_plural" => '%s', |
|
734 | - "CUR_sign" => '%s', |
|
735 | - "CUR_dec_plc" => '%d', |
|
736 | - "CUR_active" => '%d', |
|
737 | - ); |
|
738 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
739 | - foreach ($newer_currencies as $currency) { |
|
740 | - $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
|
741 | - $countries = $wpdb->get_var($SQL); |
|
742 | - if ( ! $countries) { |
|
743 | - $wpdb->insert($currency_table, |
|
744 | - array_combine(array_keys($currency_format), $currency), |
|
745 | - $currency_format |
|
746 | - ); |
|
747 | - } |
|
748 | - } |
|
749 | - } |
|
750 | - } |
|
715 | + /** |
|
716 | + * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
717 | + */ |
|
718 | + public function verify_new_currencies() |
|
719 | + { |
|
720 | + //a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
721 | + //how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
722 | + //currency symbols: http://www.xe.com/symbols.php |
|
723 | + // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
724 | + //( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
725 | + $newer_currencies = array( |
|
726 | + array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
|
727 | + ); |
|
728 | + global $wpdb; |
|
729 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
730 | + $currency_format = array( |
|
731 | + "CUR_code" => '%s', |
|
732 | + "CUR_single" => '%s', |
|
733 | + "CUR_plural" => '%s', |
|
734 | + "CUR_sign" => '%s', |
|
735 | + "CUR_dec_plc" => '%d', |
|
736 | + "CUR_active" => '%d', |
|
737 | + ); |
|
738 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
739 | + foreach ($newer_currencies as $currency) { |
|
740 | + $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
|
741 | + $countries = $wpdb->get_var($SQL); |
|
742 | + if ( ! $countries) { |
|
743 | + $wpdb->insert($currency_table, |
|
744 | + array_combine(array_keys($currency_format), $currency), |
|
745 | + $currency_format |
|
746 | + ); |
|
747 | + } |
|
748 | + } |
|
749 | + } |
|
750 | + } |
|
751 | 751 | |
752 | 752 | |
753 | 753 | |
754 | - /** |
|
755 | - * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
756 | - * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
757 | - * we should be able to stop doing this in 4.9 |
|
758 | - */ |
|
759 | - public function fix_non_default_taxes() |
|
760 | - { |
|
761 | - global $wpdb; |
|
762 | - $query = $wpdb->prepare("UPDATE |
|
754 | + /** |
|
755 | + * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
756 | + * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
757 | + * we should be able to stop doing this in 4.9 |
|
758 | + */ |
|
759 | + public function fix_non_default_taxes() |
|
760 | + { |
|
761 | + global $wpdb; |
|
762 | + $query = $wpdb->prepare("UPDATE |
|
763 | 763 | {$wpdb->prefix}esp_price p INNER JOIN |
764 | 764 | {$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID |
765 | 765 | SET |
@@ -768,6 +768,6 @@ discard block |
||
768 | 768 | p.PRC_is_default = 0 AND |
769 | 769 | pt.PBT_ID = %d |
770 | 770 | ", EEM_Price_Type::base_type_tax); |
771 | - $wpdb->query($query); |
|
772 | - } |
|
771 | + $wpdb->query($query); |
|
772 | + } |
|
773 | 773 | } |
@@ -9,7 +9,6 @@ discard block |
||
9 | 9 | * and recalculates esp_registration.REG_final_price to actually be the final price |
10 | 10 | * for that registration (before this it was just the ticket's price, NOT including |
11 | 11 | * taxes or other price modifiers) |
12 | - |
|
13 | 12 | */ |
14 | 13 | // make sure we have all the stages loaded too |
15 | 14 | // unfortunately, this needs to be done upon INCLUSION of this file, |
@@ -18,9 +17,9 @@ discard block |
||
18 | 17 | $stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*'); |
19 | 18 | $class_to_filepath = array(); |
20 | 19 | foreach ($stages as $filepath) { |
21 | - $matches = array(); |
|
22 | - preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
23 | - $class_to_filepath[$matches[1]] = $filepath; |
|
20 | + $matches = array(); |
|
21 | + preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
22 | + $class_to_filepath[$matches[1]] = $filepath; |
|
24 | 23 | } |
25 | 24 | //give addons a chance to autoload their stages too |
26 | 25 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath); |
@@ -39,72 +38,72 @@ discard block |
||
39 | 38 | class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base |
40 | 39 | { |
41 | 40 | |
42 | - /** |
|
43 | - * return EE_DMS_Core_4_7_0 |
|
44 | - * |
|
45 | - * @param TableManager $table_manager |
|
46 | - * @param TableAnalysis $table_analysis |
|
47 | - */ |
|
48 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
49 | - { |
|
50 | - $this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso"); |
|
51 | - $this->_priority = 10; |
|
52 | - $this->_migration_stages = array( |
|
53 | - new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
54 | - new EE_DMS_4_7_0_Registration_Payments(), |
|
55 | - ); |
|
56 | - parent::__construct($table_manager, $table_analysis); |
|
57 | - } |
|
41 | + /** |
|
42 | + * return EE_DMS_Core_4_7_0 |
|
43 | + * |
|
44 | + * @param TableManager $table_manager |
|
45 | + * @param TableAnalysis $table_analysis |
|
46 | + */ |
|
47 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
48 | + { |
|
49 | + $this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso"); |
|
50 | + $this->_priority = 10; |
|
51 | + $this->_migration_stages = array( |
|
52 | + new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
53 | + new EE_DMS_4_7_0_Registration_Payments(), |
|
54 | + ); |
|
55 | + parent::__construct($table_manager, $table_analysis); |
|
56 | + } |
|
58 | 57 | |
59 | 58 | |
60 | 59 | |
61 | - /** |
|
62 | - * @param array $version_array |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function can_migrate_from_version($version_array) |
|
66 | - { |
|
67 | - $version_string = $version_array['Core']; |
|
68 | - if ( |
|
69 | - ( |
|
70 | - version_compare($version_string, '4.7.0', '<=') |
|
71 | - && version_compare($version_string, '4.6.0', '>=') |
|
72 | - ) |
|
73 | - || ( |
|
74 | - version_compare($version_string, '4.7.0', '>=') |
|
75 | - && ! $this->_get_table_analysis()->tableExists('esp_registration_payment') |
|
76 | - && $this->_get_table_analysis()->tableExists('esp_registration') |
|
77 | - ) |
|
78 | - ) { |
|
79 | - return true; |
|
80 | - } elseif ( ! $version_string) { |
|
81 | - //no version string provided... this must be pre 4.3 |
|
82 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
83 | - } else { |
|
84 | - return false; |
|
85 | - } |
|
86 | - } |
|
60 | + /** |
|
61 | + * @param array $version_array |
|
62 | + * @return bool |
|
63 | + */ |
|
64 | + public function can_migrate_from_version($version_array) |
|
65 | + { |
|
66 | + $version_string = $version_array['Core']; |
|
67 | + if ( |
|
68 | + ( |
|
69 | + version_compare($version_string, '4.7.0', '<=') |
|
70 | + && version_compare($version_string, '4.6.0', '>=') |
|
71 | + ) |
|
72 | + || ( |
|
73 | + version_compare($version_string, '4.7.0', '>=') |
|
74 | + && ! $this->_get_table_analysis()->tableExists('esp_registration_payment') |
|
75 | + && $this->_get_table_analysis()->tableExists('esp_registration') |
|
76 | + ) |
|
77 | + ) { |
|
78 | + return true; |
|
79 | + } elseif ( ! $version_string) { |
|
80 | + //no version string provided... this must be pre 4.3 |
|
81 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
82 | + } else { |
|
83 | + return false; |
|
84 | + } |
|
85 | + } |
|
87 | 86 | |
88 | 87 | |
89 | 88 | |
90 | - /** |
|
91 | - * @return bool |
|
92 | - */ |
|
93 | - public function schema_changes_before_migration() |
|
94 | - { |
|
95 | - //relies on 4.1's EEH_Activation::create_table |
|
96 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
97 | - $table_name = 'esp_answer'; |
|
98 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
89 | + /** |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function schema_changes_before_migration() |
|
93 | + { |
|
94 | + //relies on 4.1's EEH_Activation::create_table |
|
95 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
96 | + $table_name = 'esp_answer'; |
|
97 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
99 | 98 | REG_ID INT UNSIGNED NOT NULL, |
100 | 99 | QST_ID INT UNSIGNED NOT NULL, |
101 | 100 | ANS_value TEXT NOT NULL, |
102 | 101 | PRIMARY KEY (ANS_ID), |
103 | 102 | KEY REG_ID (REG_ID), |
104 | 103 | KEY QST_ID (QST_ID)"; |
105 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
106 | - $table_name = 'esp_attendee_meta'; |
|
107 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
104 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
105 | + $table_name = 'esp_attendee_meta'; |
|
106 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
108 | 107 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
109 | 108 | ATT_fname VARCHAR(45) NOT NULL, |
110 | 109 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -121,9 +120,9 @@ discard block |
||
121 | 120 | KEY ATT_email (ATT_email), |
122 | 121 | KEY ATT_lname (ATT_lname), |
123 | 122 | KEY ATT_fname (ATT_fname)"; |
124 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
123 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
124 | + $table_name = 'esp_country'; |
|
125 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
127 | 126 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
128 | 127 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
129 | 128 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -139,18 +138,18 @@ discard block |
||
139 | 138 | CNT_is_EU TINYINT(1) DEFAULT '0', |
140 | 139 | CNT_active TINYINT(1) DEFAULT '0', |
141 | 140 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
141 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
142 | + $table_name = 'esp_currency'; |
|
143 | + $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
145 | 144 | CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar', |
146 | 145 | CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars', |
147 | 146 | CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$', |
148 | 147 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
149 | 148 | CUR_active TINYINT(1) DEFAULT '0', |
150 | 149 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - $table_name = 'esp_datetime'; |
|
153 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
150 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
151 | + $table_name = 'esp_datetime'; |
|
152 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
154 | 153 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
155 | 154 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
156 | 155 | DTT_description TEXT NOT NULL, |
@@ -166,9 +165,9 @@ discard block |
||
166 | 165 | KEY DTT_EVT_start (DTT_EVT_start), |
167 | 166 | KEY EVT_ID (EVT_ID), |
168 | 167 | KEY DTT_is_primary (DTT_is_primary)"; |
169 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
170 | - $table_name = 'esp_event_meta'; |
|
171 | - $sql = " |
|
168 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
169 | + $table_name = 'esp_event_meta'; |
|
170 | + $sql = " |
|
172 | 171 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
173 | 172 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
174 | 173 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -184,34 +183,34 @@ discard block |
||
184 | 183 | EVT_donations TINYINT(1) NULL, |
185 | 184 | PRIMARY KEY (EVTM_ID), |
186 | 185 | KEY EVT_ID (EVT_ID)"; |
187 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
188 | - $table_name = 'esp_event_question_group'; |
|
189 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
186 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | + $table_name = 'esp_event_question_group'; |
|
188 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
190 | 189 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
191 | 190 | QSG_ID INT UNSIGNED NOT NULL, |
192 | 191 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
193 | 192 | PRIMARY KEY (EQG_ID), |
194 | 193 | KEY EVT_ID (EVT_ID), |
195 | 194 | KEY QSG_ID (QSG_ID)"; |
196 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
197 | - $table_name = 'esp_event_venue'; |
|
198 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
195 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
196 | + $table_name = 'esp_event_venue'; |
|
197 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
199 | 198 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
200 | 199 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
201 | 200 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
202 | 201 | PRIMARY KEY (EVV_ID)"; |
203 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
204 | - $table_name = 'esp_extra_meta'; |
|
205 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
202 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
203 | + $table_name = 'esp_extra_meta'; |
|
204 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
206 | 205 | OBJ_ID INT(11) DEFAULT NULL, |
207 | 206 | EXM_type VARCHAR(45) DEFAULT NULL, |
208 | 207 | EXM_key VARCHAR(45) DEFAULT NULL, |
209 | 208 | EXM_value TEXT, |
210 | 209 | PRIMARY KEY (EXM_ID), |
211 | 210 | KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))"; |
212 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
213 | - $table_name = 'esp_line_item'; |
|
214 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
211 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
212 | + $table_name = 'esp_line_item'; |
|
213 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
215 | 214 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
216 | 215 | TXN_ID INT(11) DEFAULT NULL, |
217 | 216 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -229,9 +228,9 @@ discard block |
||
229 | 228 | PRIMARY KEY (LIN_ID), |
230 | 229 | KEY LIN_code (LIN_code(191)), |
231 | 230 | KEY TXN_ID (TXN_ID)"; |
232 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
233 | - $table_name = 'esp_log'; |
|
234 | - $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
231 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
232 | + $table_name = 'esp_log'; |
|
233 | + $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
235 | 234 | LOG_time DATETIME DEFAULT NULL, |
236 | 235 | OBJ_ID VARCHAR(45) DEFAULT NULL, |
237 | 236 | OBJ_type VARCHAR(45) DEFAULT NULL, |
@@ -242,18 +241,18 @@ discard block |
||
242 | 241 | KEY LOG_time (LOG_time), |
243 | 242 | KEY OBJ (OBJ_type,OBJ_ID), |
244 | 243 | KEY LOG_type (LOG_type)"; |
245 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
246 | - $table_name = 'esp_message_template'; |
|
247 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
244 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
245 | + $table_name = 'esp_message_template'; |
|
246 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
248 | 247 | GRP_ID INT(10) UNSIGNED NOT NULL, |
249 | 248 | MTP_context VARCHAR(50) NOT NULL, |
250 | 249 | MTP_template_field VARCHAR(30) NOT NULL, |
251 | 250 | MTP_content TEXT NOT NULL, |
252 | 251 | PRIMARY KEY (MTP_ID), |
253 | 252 | KEY GRP_ID (GRP_ID)"; |
254 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
255 | - $table_name = 'esp_message_template_group'; |
|
256 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
253 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
254 | + $table_name = 'esp_message_template_group'; |
|
255 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
257 | 256 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
258 | 257 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
259 | 258 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -265,17 +264,17 @@ discard block |
||
265 | 264 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
266 | 265 | PRIMARY KEY (GRP_ID), |
267 | 266 | KEY MTP_user_id (MTP_user_id)"; |
268 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
269 | - $table_name = 'esp_event_message_template'; |
|
270 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
267 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
268 | + $table_name = 'esp_event_message_template'; |
|
269 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
271 | 270 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
272 | 271 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
273 | 272 | PRIMARY KEY (EMT_ID), |
274 | 273 | KEY EVT_ID (EVT_ID), |
275 | 274 | KEY GRP_ID (GRP_ID)"; |
276 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
277 | - $table_name = 'esp_payment'; |
|
278 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
275 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
276 | + $table_name = 'esp_payment'; |
|
277 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
279 | 278 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
280 | 279 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
281 | 280 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -292,9 +291,9 @@ discard block |
||
292 | 291 | PRIMARY KEY (PAY_ID), |
293 | 292 | KEY PAY_timestamp (PAY_timestamp), |
294 | 293 | KEY TXN_ID (TXN_ID)"; |
295 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
296 | - $table_name = 'esp_payment_method'; |
|
297 | - $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
294 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
295 | + $table_name = 'esp_payment_method'; |
|
296 | + $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
298 | 297 | PMD_type VARCHAR(124) DEFAULT NULL, |
299 | 298 | PMD_name VARCHAR(255) DEFAULT NULL, |
300 | 299 | PMD_desc TEXT, |
@@ -310,32 +309,32 @@ discard block |
||
310 | 309 | PRIMARY KEY (PMD_ID), |
311 | 310 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
312 | 311 | KEY PMD_type (PMD_type)"; |
313 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
314 | - $table_name = "esp_ticket_price"; |
|
315 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
312 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
313 | + $table_name = "esp_ticket_price"; |
|
314 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
316 | 315 | TKT_ID INT(10) UNSIGNED NOT NULL, |
317 | 316 | PRC_ID INT(10) UNSIGNED NOT NULL, |
318 | 317 | PRIMARY KEY (TKP_ID), |
319 | 318 | KEY TKT_ID (TKT_ID), |
320 | 319 | KEY PRC_ID (PRC_ID)"; |
321 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
322 | - $table_name = "esp_datetime_ticket"; |
|
323 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = "esp_datetime_ticket"; |
|
322 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
324 | 323 | DTT_ID INT(10) UNSIGNED NOT NULL, |
325 | 324 | TKT_ID INT(10) UNSIGNED NOT NULL, |
326 | 325 | PRIMARY KEY (DTK_ID), |
327 | 326 | KEY DTT_ID (DTT_ID), |
328 | 327 | KEY TKT_ID (TKT_ID)"; |
329 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | - $table_name = "esp_ticket_template"; |
|
331 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
328 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
329 | + $table_name = "esp_ticket_template"; |
|
330 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
332 | 331 | TTM_name VARCHAR(45) NOT NULL, |
333 | 332 | TTM_description TEXT, |
334 | 333 | TTM_file VARCHAR(45), |
335 | 334 | PRIMARY KEY (TTM_ID)"; |
336 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
337 | - $table_name = 'esp_question'; |
|
338 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
335 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
336 | + $table_name = 'esp_question'; |
|
337 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
339 | 338 | QST_display_text TEXT NOT NULL, |
340 | 339 | QST_admin_label VARCHAR(255) NOT NULL, |
341 | 340 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -348,18 +347,18 @@ discard block |
||
348 | 347 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
349 | 348 | PRIMARY KEY (QST_ID), |
350 | 349 | KEY QST_order (QST_order)'; |
351 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
352 | - $table_name = 'esp_question_group_question'; |
|
353 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
350 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | + $table_name = 'esp_question_group_question'; |
|
352 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
354 | 353 | QSG_ID INT UNSIGNED NOT NULL, |
355 | 354 | QST_ID INT UNSIGNED NOT NULL, |
356 | 355 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
357 | 356 | PRIMARY KEY (QGQ_ID), |
358 | 357 | KEY QST_ID (QST_ID), |
359 | 358 | KEY QSG_ID_order (QSG_ID, QGQ_order)"; |
360 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
361 | - $table_name = 'esp_question_option'; |
|
362 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
359 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
360 | + $table_name = 'esp_question_option'; |
|
361 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
363 | 362 | QSO_value VARCHAR(255) NOT NULL, |
364 | 363 | QSO_desc TEXT NOT NULL, |
365 | 364 | QST_ID INT UNSIGNED NOT NULL, |
@@ -368,9 +367,9 @@ discard block |
||
368 | 367 | PRIMARY KEY (QSO_ID), |
369 | 368 | KEY QST_ID (QST_ID), |
370 | 369 | KEY QSO_order (QSO_order)"; |
371 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
372 | - $table_name = 'esp_registration'; |
|
373 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
370 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
371 | + $table_name = 'esp_registration'; |
|
372 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
374 | 373 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
375 | 374 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
376 | 375 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -394,18 +393,18 @@ discard block |
||
394 | 393 | KEY TKT_ID (TKT_ID), |
395 | 394 | KEY EVT_ID (EVT_ID), |
396 | 395 | KEY STS_ID (STS_ID)"; |
397 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
398 | - $table_name = 'esp_registration_payment'; |
|
399 | - $sql = "RPY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
396 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
397 | + $table_name = 'esp_registration_payment'; |
|
398 | + $sql = "RPY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
400 | 399 | REG_ID INT(10) UNSIGNED NOT NULL, |
401 | 400 | PAY_ID INT(10) UNSIGNED NULL, |
402 | 401 | RPY_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
403 | 402 | PRIMARY KEY (RPY_ID), |
404 | 403 | KEY REG_ID (REG_ID), |
405 | 404 | KEY PAY_ID (PAY_ID)"; |
406 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
407 | - $table_name = 'esp_checkin'; |
|
408 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
405 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
406 | + $table_name = 'esp_checkin'; |
|
407 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
409 | 408 | REG_ID INT(10) UNSIGNED NOT NULL, |
410 | 409 | DTT_ID INT(10) UNSIGNED NOT NULL, |
411 | 410 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -413,9 +412,9 @@ discard block |
||
413 | 412 | PRIMARY KEY (CHK_ID), |
414 | 413 | KEY REG_ID (REG_ID), |
415 | 414 | KEY DTT_ID (DTT_ID)"; |
416 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | - $table_name = 'esp_state'; |
|
418 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
415 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | + $table_name = 'esp_state'; |
|
417 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
419 | 418 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
420 | 419 | STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL, |
421 | 420 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
@@ -423,9 +422,9 @@ discard block |
||
423 | 422 | PRIMARY KEY (STA_ID), |
424 | 423 | KEY STA_abbrev (STA_abbrev), |
425 | 424 | KEY CNT_ISO (CNT_ISO)"; |
426 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
427 | - $table_name = 'esp_status'; |
|
428 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
425 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
426 | + $table_name = 'esp_status'; |
|
427 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
429 | 428 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
430 | 429 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
431 | 430 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -433,9 +432,9 @@ discard block |
||
433 | 432 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
434 | 433 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
435 | 434 | KEY STS_type (STS_type)"; |
436 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
437 | - $table_name = 'esp_transaction'; |
|
438 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
435 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | + $table_name = 'esp_transaction'; |
|
437 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
439 | 438 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
440 | 439 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
441 | 440 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -447,9 +446,9 @@ discard block |
||
447 | 446 | PRIMARY KEY (TXN_ID), |
448 | 447 | KEY TXN_timestamp (TXN_timestamp), |
449 | 448 | KEY STS_ID (STS_ID)"; |
450 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | - $table_name = 'esp_venue_meta'; |
|
452 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
449 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
450 | + $table_name = 'esp_venue_meta'; |
|
451 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
453 | 452 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
454 | 453 | VNU_address VARCHAR(255) DEFAULT NULL, |
455 | 454 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -468,10 +467,10 @@ discard block |
||
468 | 467 | KEY VNU_ID (VNU_ID), |
469 | 468 | KEY STA_ID (STA_ID), |
470 | 469 | KEY CNT_ISO (CNT_ISO)"; |
471 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
472 | - //modified tables |
|
473 | - $table_name = "esp_price"; |
|
474 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
470 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
471 | + //modified tables |
|
472 | + $table_name = "esp_price"; |
|
473 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
475 | 474 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
476 | 475 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
477 | 476 | PRC_name VARCHAR(245) NOT NULL, |
@@ -484,9 +483,9 @@ discard block |
||
484 | 483 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
485 | 484 | PRIMARY KEY (PRC_ID), |
486 | 485 | KEY PRT_ID (PRT_ID)"; |
487 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | - $table_name = "esp_price_type"; |
|
489 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
486 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
487 | + $table_name = "esp_price_type"; |
|
488 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
490 | 489 | PRT_name VARCHAR(45) NOT NULL, |
491 | 490 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
492 | 491 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -495,9 +494,9 @@ discard block |
||
495 | 494 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
496 | 495 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
497 | 496 | PRIMARY KEY (PRT_ID)"; |
498 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
499 | - $table_name = "esp_ticket"; |
|
500 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
497 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
498 | + $table_name = "esp_ticket"; |
|
499 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
501 | 500 | TTM_ID INT(10) UNSIGNED NOT NULL, |
502 | 501 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
503 | 502 | TKT_description TEXT NOT NULL, |
@@ -519,9 +518,9 @@ discard block |
||
519 | 518 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
520 | 519 | PRIMARY KEY (TKT_ID), |
521 | 520 | KEY TKT_start_date (TKT_start_date)"; |
522 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | - $table_name = 'esp_question_group'; |
|
524 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
521 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
522 | + $table_name = 'esp_question_group'; |
|
523 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
525 | 524 | QSG_name VARCHAR(255) NOT NULL, |
526 | 525 | QSG_identifier VARCHAR(100) NOT NULL, |
527 | 526 | QSG_desc TEXT NULL, |
@@ -534,38 +533,38 @@ discard block |
||
534 | 533 | PRIMARY KEY (QSG_ID), |
535 | 534 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
536 | 535 | KEY QSG_order (QSG_order)'; |
537 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
538 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
539 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
540 | - //(because many need to convert old string states to foreign keys into the states table) |
|
541 | - $script_4_1_defaults->insert_default_states(); |
|
542 | - $script_4_1_defaults->insert_default_countries(); |
|
543 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
544 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
545 | - $script_4_5_defaults->insert_default_price_types(); |
|
546 | - $script_4_5_defaults->insert_default_prices(); |
|
547 | - $script_4_5_defaults->insert_default_tickets(); |
|
548 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
549 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
550 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
551 | - $script_4_6_defaults->insert_default_currencies(); |
|
552 | - return true; |
|
553 | - } |
|
536 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
537 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
538 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
539 | + //(because many need to convert old string states to foreign keys into the states table) |
|
540 | + $script_4_1_defaults->insert_default_states(); |
|
541 | + $script_4_1_defaults->insert_default_countries(); |
|
542 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
543 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
544 | + $script_4_5_defaults->insert_default_price_types(); |
|
545 | + $script_4_5_defaults->insert_default_prices(); |
|
546 | + $script_4_5_defaults->insert_default_tickets(); |
|
547 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
548 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
549 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
550 | + $script_4_6_defaults->insert_default_currencies(); |
|
551 | + return true; |
|
552 | + } |
|
554 | 553 | |
555 | 554 | |
556 | 555 | |
557 | - /** |
|
558 | - * @return boolean |
|
559 | - */ |
|
560 | - public function schema_changes_after_migration() |
|
561 | - { |
|
562 | - return true; |
|
563 | - } |
|
556 | + /** |
|
557 | + * @return boolean |
|
558 | + */ |
|
559 | + public function schema_changes_after_migration() |
|
560 | + { |
|
561 | + return true; |
|
562 | + } |
|
564 | 563 | |
565 | 564 | |
566 | 565 | |
567 | - public function migration_page_hooks() |
|
568 | - { |
|
569 | - } |
|
566 | + public function migration_page_hooks() |
|
567 | + { |
|
568 | + } |
|
570 | 569 | } |
571 | 570 | // end of file: /core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php |
572 | 571 | \ No newline at end of file |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[$matches[1]] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | - // echo "$version_string can be migrated from"; |
|
66 | - return true; |
|
67 | - } elseif ( ! $version_string) { |
|
68 | - // echo "no version string provided: $version_string"; |
|
69 | - //no version string provided... this must be pre 4.3 |
|
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
72 | - // echo "$version_string doesnt apply"; |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | + // echo "$version_string can be migrated from"; |
|
66 | + return true; |
|
67 | + } elseif ( ! $version_string) { |
|
68 | + // echo "no version string provided: $version_string"; |
|
69 | + //no version string provided... this must be pre 4.3 |
|
70 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | + // echo "$version_string doesnt apply"; |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $now_in_mysql = current_time('mysql', true); |
|
86 | - $table_name = 'esp_answer'; |
|
87 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $now_in_mysql = current_time('mysql', true); |
|
86 | + $table_name = 'esp_answer'; |
|
87 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | REG_ID int(10) unsigned NOT NULL, |
89 | 89 | QST_ID int(10) unsigned NOT NULL, |
90 | 90 | ANS_value text NOT NULL, |
91 | 91 | PRIMARY KEY (ANS_ID), |
92 | 92 | KEY REG_ID (REG_ID), |
93 | 93 | KEY QST_ID (QST_ID)"; |
94 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,18 +139,18 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - $table_name = 'esp_datetime'; |
|
153 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + $table_name = 'esp_datetime'; |
|
153 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
154 | 154 | EVT_ID bigint(20) unsigned NOT NULL, |
155 | 155 | DTT_name varchar(255) NOT NULL DEFAULT '', |
156 | 156 | DTT_description text NOT NULL, |
@@ -167,25 +167,25 @@ discard block |
||
167 | 167 | KEY DTT_EVT_start (DTT_EVT_start), |
168 | 168 | KEY EVT_ID (EVT_ID), |
169 | 169 | KEY DTT_is_primary (DTT_is_primary)"; |
170 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
171 | - $table_name = "esp_datetime_ticket"; |
|
172 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
170 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
171 | + $table_name = "esp_datetime_ticket"; |
|
172 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
173 | 173 | DTT_ID int(10) unsigned NOT NULL, |
174 | 174 | TKT_ID int(10) unsigned NOT NULL, |
175 | 175 | PRIMARY KEY (DTK_ID), |
176 | 176 | KEY DTT_ID (DTT_ID), |
177 | 177 | KEY TKT_ID (TKT_ID)"; |
178 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
179 | - $table_name = 'esp_event_message_template'; |
|
180 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
178 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
179 | + $table_name = 'esp_event_message_template'; |
|
180 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | 181 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
182 | 182 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
183 | 183 | PRIMARY KEY (EMT_ID), |
184 | 184 | KEY EVT_ID (EVT_ID), |
185 | 185 | KEY GRP_ID (GRP_ID)"; |
186 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | - $table_name = 'esp_event_meta'; |
|
188 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
186 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | + $table_name = 'esp_event_meta'; |
|
188 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
189 | 189 | EVT_ID bigint(20) unsigned NOT NULL, |
190 | 190 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
191 | 191 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -200,34 +200,34 @@ discard block |
||
200 | 200 | EVT_donations tinyint(1) NULL, |
201 | 201 | PRIMARY KEY (EVTM_ID), |
202 | 202 | KEY EVT_ID (EVT_ID)"; |
203 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
204 | - $table_name = 'esp_event_question_group'; |
|
205 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
203 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
204 | + $table_name = 'esp_event_question_group'; |
|
205 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
206 | 206 | EVT_ID bigint(20) unsigned NOT NULL, |
207 | 207 | QSG_ID int(10) unsigned NOT NULL, |
208 | 208 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
209 | 209 | PRIMARY KEY (EQG_ID), |
210 | 210 | KEY EVT_ID (EVT_ID), |
211 | 211 | KEY QSG_ID (QSG_ID)"; |
212 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
213 | - $table_name = 'esp_event_venue'; |
|
214 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
212 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
213 | + $table_name = 'esp_event_venue'; |
|
214 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
215 | 215 | EVT_ID bigint(20) unsigned NOT NULL, |
216 | 216 | VNU_ID bigint(20) unsigned NOT NULL, |
217 | 217 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
218 | 218 | PRIMARY KEY (EVV_ID)"; |
219 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | - $table_name = 'esp_extra_meta'; |
|
221 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
219 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $table_name = 'esp_extra_meta'; |
|
221 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
222 | 222 | OBJ_ID int(11) DEFAULT NULL, |
223 | 223 | EXM_type varchar(45) DEFAULT NULL, |
224 | 224 | EXM_key varchar(45) DEFAULT NULL, |
225 | 225 | EXM_value text, |
226 | 226 | PRIMARY KEY (EXM_ID), |
227 | 227 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
228 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
229 | - $table_name = 'esp_extra_join'; |
|
230 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
228 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
229 | + $table_name = 'esp_extra_join'; |
|
230 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
231 | 231 | EXJ_first_model_id varchar(6) NOT NULL, |
232 | 232 | EXJ_first_model_name varchar(20) NOT NULL, |
233 | 233 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | PRIMARY KEY (EXJ_ID), |
236 | 236 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
237 | 237 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
238 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
239 | - $table_name = 'esp_line_item'; |
|
240 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
238 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
239 | + $table_name = 'esp_line_item'; |
|
240 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
241 | 241 | LIN_code varchar(245) NOT NULL DEFAULT '', |
242 | 242 | TXN_ID int(11) DEFAULT NULL, |
243 | 243 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | PRIMARY KEY (LIN_ID), |
257 | 257 | KEY LIN_code (LIN_code(191)), |
258 | 258 | KEY TXN_ID (TXN_ID)"; |
259 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | - $table_name = 'esp_log'; |
|
261 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
259 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | + $table_name = 'esp_log'; |
|
261 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
262 | 262 | LOG_time datetime DEFAULT NULL, |
263 | 263 | OBJ_ID varchar(45) DEFAULT NULL, |
264 | 264 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | KEY LOG_time (LOG_time), |
270 | 270 | KEY OBJ (OBJ_type,OBJ_ID), |
271 | 271 | KEY LOG_type (LOG_type)"; |
272 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
273 | - $table_name = 'esp_message'; |
|
274 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
275 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
276 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
277 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
272 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
273 | + $table_name = 'esp_message'; |
|
274 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
275 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
276 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
277 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
278 | 278 | GRP_ID int(10) unsigned NULL, |
279 | 279 | MSG_token varchar(255) NULL, |
280 | 280 | TXN_ID int(10) unsigned NULL, |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | KEY STS_ID (STS_ID), |
307 | 307 | KEY MSG_created (MSG_created), |
308 | 308 | KEY MSG_modified (MSG_modified)"; |
309 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
310 | - $table_name = 'esp_message_template'; |
|
311 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
309 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
310 | + $table_name = 'esp_message_template'; |
|
311 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
312 | 312 | GRP_ID int(10) unsigned NOT NULL, |
313 | 313 | MTP_context varchar(50) NOT NULL, |
314 | 314 | MTP_template_field varchar(30) NOT NULL, |
315 | 315 | MTP_content text NOT NULL, |
316 | 316 | PRIMARY KEY (MTP_ID), |
317 | 317 | KEY GRP_ID (GRP_ID)"; |
318 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
319 | - $table_name = 'esp_message_template_group'; |
|
320 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
318 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
319 | + $table_name = 'esp_message_template_group'; |
|
320 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
321 | 321 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
322 | 322 | MTP_name varchar(245) NOT NULL DEFAULT '', |
323 | 323 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
330 | 330 | PRIMARY KEY (GRP_ID), |
331 | 331 | KEY MTP_user_id (MTP_user_id)"; |
332 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
333 | - $table_name = 'esp_payment'; |
|
334 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
333 | + $table_name = 'esp_payment'; |
|
334 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
335 | 335 | TXN_ID int(10) unsigned DEFAULT NULL, |
336 | 336 | STS_ID varchar(3) DEFAULT NULL, |
337 | 337 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | PRIMARY KEY (PAY_ID), |
349 | 349 | KEY PAY_timestamp (PAY_timestamp), |
350 | 350 | KEY TXN_ID (TXN_ID)"; |
351 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
352 | - $table_name = 'esp_payment_method'; |
|
353 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
351 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
352 | + $table_name = 'esp_payment_method'; |
|
353 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
354 | 354 | PMD_type varchar(124) DEFAULT NULL, |
355 | 355 | PMD_name varchar(255) DEFAULT NULL, |
356 | 356 | PMD_desc text, |
@@ -366,24 +366,24 @@ discard block |
||
366 | 366 | PRIMARY KEY (PMD_ID), |
367 | 367 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
368 | 368 | KEY PMD_type (PMD_type)"; |
369 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
370 | - $table_name = "esp_ticket_price"; |
|
371 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
369 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
370 | + $table_name = "esp_ticket_price"; |
|
371 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
372 | 372 | TKT_ID int(10) unsigned NOT NULL, |
373 | 373 | PRC_ID int(10) unsigned NOT NULL, |
374 | 374 | PRIMARY KEY (TKP_ID), |
375 | 375 | KEY TKT_ID (TKT_ID), |
376 | 376 | KEY PRC_ID (PRC_ID)"; |
377 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | - $table_name = "esp_ticket_template"; |
|
379 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
377 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | + $table_name = "esp_ticket_template"; |
|
379 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
380 | 380 | TTM_name varchar(45) NOT NULL, |
381 | 381 | TTM_description text, |
382 | 382 | TTM_file varchar(45), |
383 | 383 | PRIMARY KEY (TTM_ID)"; |
384 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | - $table_name = 'esp_question'; |
|
386 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
384 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | + $table_name = 'esp_question'; |
|
386 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | 387 | QST_display_text text NOT NULL, |
388 | 388 | QST_admin_label varchar(255) NOT NULL, |
389 | 389 | QST_system varchar(25) DEFAULT NULL, |
@@ -397,18 +397,18 @@ discard block |
||
397 | 397 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
398 | 398 | PRIMARY KEY (QST_ID), |
399 | 399 | KEY QST_order (QST_order)'; |
400 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
401 | - $table_name = 'esp_question_group_question'; |
|
402 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
400 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
401 | + $table_name = 'esp_question_group_question'; |
|
402 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
403 | 403 | QSG_ID int(10) unsigned NOT NULL, |
404 | 404 | QST_ID int(10) unsigned NOT NULL, |
405 | 405 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
406 | 406 | PRIMARY KEY (QGQ_ID), |
407 | 407 | KEY QST_ID (QST_ID), |
408 | 408 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
409 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
410 | - $table_name = 'esp_question_option'; |
|
411 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
409 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
410 | + $table_name = 'esp_question_option'; |
|
411 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
412 | 412 | QSO_value varchar(255) NOT NULL, |
413 | 413 | QSO_desc text NOT NULL, |
414 | 414 | QST_ID int(10) unsigned NOT NULL, |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | PRIMARY KEY (QSO_ID), |
419 | 419 | KEY QST_ID (QST_ID), |
420 | 420 | KEY QSO_order (QSO_order)"; |
421 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
422 | - $table_name = 'esp_registration'; |
|
423 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
421 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
422 | + $table_name = 'esp_registration'; |
|
423 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | 424 | EVT_ID bigint(20) unsigned NOT NULL, |
425 | 425 | ATT_ID bigint(20) unsigned NOT NULL, |
426 | 426 | TXN_ID int(10) unsigned NOT NULL, |
@@ -444,18 +444,18 @@ discard block |
||
444 | 444 | KEY TKT_ID (TKT_ID), |
445 | 445 | KEY EVT_ID (EVT_ID), |
446 | 446 | KEY STS_ID (STS_ID)"; |
447 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
448 | - $table_name = 'esp_registration_payment'; |
|
449 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
447 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
448 | + $table_name = 'esp_registration_payment'; |
|
449 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
450 | 450 | REG_ID int(10) unsigned NOT NULL, |
451 | 451 | PAY_ID int(10) unsigned NULL, |
452 | 452 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
453 | 453 | PRIMARY KEY (RPY_ID), |
454 | 454 | KEY REG_ID (REG_ID), |
455 | 455 | KEY PAY_ID (PAY_ID)"; |
456 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
457 | - $table_name = 'esp_state'; |
|
458 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
456 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
457 | + $table_name = 'esp_state'; |
|
458 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
459 | 459 | CNT_ISO varchar(2) NOT NULL, |
460 | 460 | STA_abbrev varchar(24) NOT NULL, |
461 | 461 | STA_name varchar(100) NOT NULL, |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | PRIMARY KEY (STA_ID), |
464 | 464 | KEY STA_abbrev (STA_abbrev), |
465 | 465 | KEY CNT_ISO (CNT_ISO)"; |
466 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | - $table_name = 'esp_status'; |
|
468 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
466 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | + $table_name = 'esp_status'; |
|
468 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
469 | 469 | STS_code varchar(45) NOT NULL, |
470 | 470 | STS_type varchar(45) NOT NULL, |
471 | 471 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
474 | 474 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
475 | 475 | KEY STS_type (STS_type)"; |
476 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
477 | - $table_name = 'esp_transaction'; |
|
478 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
476 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
477 | + $table_name = 'esp_transaction'; |
|
478 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
479 | 479 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
480 | 480 | TXN_total decimal(12,3) DEFAULT '0.00', |
481 | 481 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -487,9 +487,9 @@ discard block |
||
487 | 487 | PRIMARY KEY (TXN_ID), |
488 | 488 | KEY TXN_timestamp (TXN_timestamp), |
489 | 489 | KEY STS_ID (STS_ID)"; |
490 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
491 | - $table_name = 'esp_venue_meta'; |
|
492 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
490 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
491 | + $table_name = 'esp_venue_meta'; |
|
492 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
493 | 493 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
494 | 494 | VNU_address varchar(255) DEFAULT NULL, |
495 | 495 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | KEY VNU_ID (VNU_ID), |
509 | 509 | KEY STA_ID (STA_ID), |
510 | 510 | KEY CNT_ISO (CNT_ISO)"; |
511 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
512 | - //modified tables |
|
513 | - $table_name = "esp_price"; |
|
514 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
511 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
512 | + //modified tables |
|
513 | + $table_name = "esp_price"; |
|
514 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
515 | 515 | PRT_ID tinyint(3) unsigned NOT NULL, |
516 | 516 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
517 | 517 | PRC_name varchar(245) NOT NULL, |
@@ -524,9 +524,9 @@ discard block |
||
524 | 524 | PRC_parent int(10) unsigned DEFAULT 0, |
525 | 525 | PRIMARY KEY (PRC_ID), |
526 | 526 | KEY PRT_ID (PRT_ID)"; |
527 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
528 | - $table_name = "esp_price_type"; |
|
529 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
527 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
528 | + $table_name = "esp_price_type"; |
|
529 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
530 | 530 | PRT_name varchar(45) NOT NULL, |
531 | 531 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
532 | 532 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
536 | 536 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
537 | 537 | PRIMARY KEY (PRT_ID)"; |
538 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
539 | - $table_name = "esp_ticket"; |
|
540 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
539 | + $table_name = "esp_ticket"; |
|
540 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | TTM_ID int(10) unsigned NOT NULL, |
542 | 542 | TKT_name varchar(245) NOT NULL DEFAULT '', |
543 | 543 | TKT_description text NOT NULL, |
@@ -560,9 +560,9 @@ discard block |
||
560 | 560 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
561 | 561 | PRIMARY KEY (TKT_ID), |
562 | 562 | KEY TKT_start_date (TKT_start_date)"; |
563 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
564 | - $table_name = 'esp_question_group'; |
|
565 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
563 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
564 | + $table_name = 'esp_question_group'; |
|
565 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
566 | 566 | QSG_name varchar(255) NOT NULL, |
567 | 567 | QSG_identifier varchar(100) NOT NULL, |
568 | 568 | QSG_desc text NULL, |
@@ -575,138 +575,138 @@ discard block |
||
575 | 575 | PRIMARY KEY (QSG_ID), |
576 | 576 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
577 | 577 | KEY QSG_order (QSG_order)'; |
578 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
579 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
580 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
581 | - //(because many need to convert old string states to foreign keys into the states table) |
|
582 | - $script_4_1_defaults->insert_default_states(); |
|
583 | - $script_4_1_defaults->insert_default_countries(); |
|
584 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
585 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
586 | - $script_4_5_defaults->insert_default_price_types(); |
|
587 | - $script_4_5_defaults->insert_default_prices(); |
|
588 | - $script_4_5_defaults->insert_default_tickets(); |
|
589 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
590 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
591 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
592 | - $script_4_6_defaults->insert_default_currencies(); |
|
593 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
594 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
595 | - $script_4_8_defaults->verify_new_countries(); |
|
596 | - $script_4_8_defaults->verify_new_currencies(); |
|
597 | - $this->verify_db_collations(); |
|
598 | - $this->verify_db_collations_again(); |
|
599 | - return true; |
|
600 | - } |
|
578 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
579 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
580 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
581 | + //(because many need to convert old string states to foreign keys into the states table) |
|
582 | + $script_4_1_defaults->insert_default_states(); |
|
583 | + $script_4_1_defaults->insert_default_countries(); |
|
584 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
585 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
586 | + $script_4_5_defaults->insert_default_price_types(); |
|
587 | + $script_4_5_defaults->insert_default_prices(); |
|
588 | + $script_4_5_defaults->insert_default_tickets(); |
|
589 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
590 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
591 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
592 | + $script_4_6_defaults->insert_default_currencies(); |
|
593 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
594 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
595 | + $script_4_8_defaults->verify_new_countries(); |
|
596 | + $script_4_8_defaults->verify_new_currencies(); |
|
597 | + $this->verify_db_collations(); |
|
598 | + $this->verify_db_collations_again(); |
|
599 | + return true; |
|
600 | + } |
|
601 | 601 | |
602 | 602 | |
603 | 603 | |
604 | - /** |
|
605 | - * @return boolean |
|
606 | - */ |
|
607 | - public function schema_changes_after_migration() |
|
608 | - { |
|
609 | - return true; |
|
610 | - } |
|
604 | + /** |
|
605 | + * @return boolean |
|
606 | + */ |
|
607 | + public function schema_changes_after_migration() |
|
608 | + { |
|
609 | + return true; |
|
610 | + } |
|
611 | 611 | |
612 | 612 | |
613 | 613 | |
614 | - public function migration_page_hooks() |
|
615 | - { |
|
616 | - } |
|
614 | + public function migration_page_hooks() |
|
615 | + { |
|
616 | + } |
|
617 | 617 | |
618 | 618 | |
619 | 619 | |
620 | - /** |
|
621 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
622 | - * |
|
623 | - * @return void |
|
624 | - */ |
|
625 | - public function verify_db_collations() |
|
626 | - { |
|
627 | - if (get_option('ee_verified_db_collations', false)) { |
|
628 | - return; |
|
629 | - } |
|
630 | - // grab tables from each model |
|
631 | - $tables_to_check = array(); |
|
632 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
633 | - if (method_exists($model_name, 'instance')) { |
|
634 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
635 | - if ($model_obj instanceof EEM_Base) { |
|
636 | - foreach ($model_obj->get_tables() as $table) { |
|
637 | - if ( |
|
638 | - strpos($table->get_table_name(), 'esp_') |
|
639 | - && (is_main_site()//for main tables, verify global tables |
|
640 | - || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
641 | - ) |
|
642 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
643 | - ) { |
|
644 | - $tables_to_check[] = $table->get_table_name(); |
|
645 | - } |
|
646 | - } |
|
647 | - } |
|
648 | - } |
|
649 | - } |
|
650 | - //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
651 | - //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
652 | - //of hard-coding this |
|
653 | - $addon_tables = array( |
|
654 | - //mailchimp |
|
655 | - 'esp_event_mailchimp_list_group', |
|
656 | - 'esp_event_question_mailchimp_field', |
|
657 | - //multisite |
|
658 | - 'esp_blog_meta', |
|
659 | - //people |
|
660 | - 'esp_people_to_post', |
|
661 | - //promotions |
|
662 | - 'esp_promotion', |
|
663 | - 'esp_promotion_object', |
|
664 | - ); |
|
665 | - foreach ($addon_tables as $table_name) { |
|
666 | - $tables_to_check[] = $table_name; |
|
667 | - } |
|
668 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
669 | - //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
670 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
671 | - //seeing how this ran with the fix from 10435, no need to check again |
|
672 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
673 | - } |
|
620 | + /** |
|
621 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
622 | + * |
|
623 | + * @return void |
|
624 | + */ |
|
625 | + public function verify_db_collations() |
|
626 | + { |
|
627 | + if (get_option('ee_verified_db_collations', false)) { |
|
628 | + return; |
|
629 | + } |
|
630 | + // grab tables from each model |
|
631 | + $tables_to_check = array(); |
|
632 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
633 | + if (method_exists($model_name, 'instance')) { |
|
634 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
635 | + if ($model_obj instanceof EEM_Base) { |
|
636 | + foreach ($model_obj->get_tables() as $table) { |
|
637 | + if ( |
|
638 | + strpos($table->get_table_name(), 'esp_') |
|
639 | + && (is_main_site()//for main tables, verify global tables |
|
640 | + || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
641 | + ) |
|
642 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
643 | + ) { |
|
644 | + $tables_to_check[] = $table->get_table_name(); |
|
645 | + } |
|
646 | + } |
|
647 | + } |
|
648 | + } |
|
649 | + } |
|
650 | + //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
651 | + //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
652 | + //of hard-coding this |
|
653 | + $addon_tables = array( |
|
654 | + //mailchimp |
|
655 | + 'esp_event_mailchimp_list_group', |
|
656 | + 'esp_event_question_mailchimp_field', |
|
657 | + //multisite |
|
658 | + 'esp_blog_meta', |
|
659 | + //people |
|
660 | + 'esp_people_to_post', |
|
661 | + //promotions |
|
662 | + 'esp_promotion', |
|
663 | + 'esp_promotion_object', |
|
664 | + ); |
|
665 | + foreach ($addon_tables as $table_name) { |
|
666 | + $tables_to_check[] = $table_name; |
|
667 | + } |
|
668 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
669 | + //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
670 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
671 | + //seeing how this ran with the fix from 10435, no need to check again |
|
672 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
673 | + } |
|
674 | 674 | |
675 | 675 | |
676 | 676 | |
677 | - /** |
|
678 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
679 | - * which meant some DB collations might not have been updated |
|
680 | - * @return void |
|
681 | - */ |
|
682 | - public function verify_db_collations_again(){ |
|
683 | - if (get_option('ee_verified_db_collations_again', false)) { |
|
684 | - return; |
|
685 | - } |
|
686 | - $tables_to_check = array( |
|
687 | - 'esp_attendee_meta', |
|
688 | - 'esp_message' |
|
689 | - ); |
|
690 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
691 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
692 | - } |
|
677 | + /** |
|
678 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
679 | + * which meant some DB collations might not have been updated |
|
680 | + * @return void |
|
681 | + */ |
|
682 | + public function verify_db_collations_again(){ |
|
683 | + if (get_option('ee_verified_db_collations_again', false)) { |
|
684 | + return; |
|
685 | + } |
|
686 | + $tables_to_check = array( |
|
687 | + 'esp_attendee_meta', |
|
688 | + 'esp_message' |
|
689 | + ); |
|
690 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
691 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
692 | + } |
|
693 | 693 | |
694 | 694 | |
695 | 695 | |
696 | - /** |
|
697 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
698 | - * @param $tables_to_check |
|
699 | - * @return boolean true if logic ran, false if it didn't |
|
700 | - */ |
|
701 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
702 | - { |
|
703 | - foreach ($tables_to_check as $table_name) { |
|
704 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
705 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
706 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
707 | - ) { |
|
708 | - maybe_convert_table_to_utf8mb4($table_name); |
|
709 | - } |
|
710 | - } |
|
711 | - } |
|
696 | + /** |
|
697 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
698 | + * @param $tables_to_check |
|
699 | + * @return boolean true if logic ran, false if it didn't |
|
700 | + */ |
|
701 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
702 | + { |
|
703 | + foreach ($tables_to_check as $table_name) { |
|
704 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
705 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
706 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
707 | + ) { |
|
708 | + maybe_convert_table_to_utf8mb4($table_name); |
|
709 | + } |
|
710 | + } |
|
711 | + } |
|
712 | 712 | } |
713 | 713 | \ No newline at end of file |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
15 | 15 | $class_to_filepath = array(); |
16 | 16 | foreach ($stages as $filepath) { |
17 | - $matches = array(); |
|
18 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | - $class_to_filepath[$matches[1]] = $filepath; |
|
17 | + $matches = array(); |
|
18 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | + $class_to_filepath[$matches[1]] = $filepath; |
|
20 | 20 | } |
21 | 21 | //give addons a chance to autoload their stages too |
22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -35,69 +35,69 @@ discard block |
||
35 | 35 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * return EE_DMS_Core_4_6_0 |
|
40 | - * |
|
41 | - * @param TableManager $table_manager |
|
42 | - * @param TableAnalysis $table_analysis |
|
43 | - */ |
|
44 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | - { |
|
46 | - $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | - $this->_priority = 10; |
|
48 | - $this->_migration_stages = array( |
|
49 | - new EE_DMS_4_6_0_gateways(), |
|
50 | - new EE_DMS_4_6_0_question_types(), |
|
51 | - new EE_DMS_4_6_0_country_system_question(), |
|
52 | - new EE_DMS_4_6_0_state_system_question(), |
|
53 | - new EE_DMS_4_6_0_billing_info(), |
|
54 | - new EE_DMS_4_6_0_transactions(), |
|
55 | - new EE_DMS_4_6_0_payments(), |
|
56 | - new EE_DMS_4_6_0_invoice_settings(), |
|
57 | - ); |
|
58 | - parent::__construct($table_manager, $table_analysis); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @param array $version_array |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function can_migrate_from_version($version_array) |
|
68 | - { |
|
69 | - $version_string = $version_array['Core']; |
|
70 | - if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
38 | + /** |
|
39 | + * return EE_DMS_Core_4_6_0 |
|
40 | + * |
|
41 | + * @param TableManager $table_manager |
|
42 | + * @param TableAnalysis $table_analysis |
|
43 | + */ |
|
44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | + { |
|
46 | + $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | + $this->_priority = 10; |
|
48 | + $this->_migration_stages = array( |
|
49 | + new EE_DMS_4_6_0_gateways(), |
|
50 | + new EE_DMS_4_6_0_question_types(), |
|
51 | + new EE_DMS_4_6_0_country_system_question(), |
|
52 | + new EE_DMS_4_6_0_state_system_question(), |
|
53 | + new EE_DMS_4_6_0_billing_info(), |
|
54 | + new EE_DMS_4_6_0_transactions(), |
|
55 | + new EE_DMS_4_6_0_payments(), |
|
56 | + new EE_DMS_4_6_0_invoice_settings(), |
|
57 | + ); |
|
58 | + parent::__construct($table_manager, $table_analysis); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @param array $version_array |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function can_migrate_from_version($version_array) |
|
68 | + { |
|
69 | + $version_string = $version_array['Core']; |
|
70 | + if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
71 | 71 | // echo "$version_string can be migrated from"; |
72 | - return true; |
|
73 | - } elseif ( ! $version_string) { |
|
72 | + return true; |
|
73 | + } elseif ( ! $version_string) { |
|
74 | 74 | // echo "no version string provided: $version_string"; |
75 | - //no version string provided... this must be pre 4.3 |
|
76 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | - } else { |
|
75 | + //no version string provided... this must be pre 4.3 |
|
76 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | + } else { |
|
78 | 78 | // echo "$version_string doesnt apply"; |
79 | - return false; |
|
80 | - } |
|
81 | - } |
|
79 | + return false; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @return bool |
|
87 | - */ |
|
88 | - public function schema_changes_before_migration() |
|
89 | - { |
|
90 | - //relies on 4.1's EEH_Activation::create_table |
|
91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | - $table_name = 'esp_answer'; |
|
93 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
85 | + /** |
|
86 | + * @return bool |
|
87 | + */ |
|
88 | + public function schema_changes_before_migration() |
|
89 | + { |
|
90 | + //relies on 4.1's EEH_Activation::create_table |
|
91 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + $table_name = 'esp_answer'; |
|
93 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
94 | 94 | REG_ID INT UNSIGNED NOT NULL, |
95 | 95 | QST_ID INT UNSIGNED NOT NULL, |
96 | 96 | ANS_value TEXT NOT NULL, |
97 | 97 | PRIMARY KEY (ANS_ID)"; |
98 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | - $table_name = 'esp_attendee_meta'; |
|
100 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
98 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | + $table_name = 'esp_attendee_meta'; |
|
100 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
101 | 101 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
102 | 102 | ATT_fname VARCHAR(45) NOT NULL, |
103 | 103 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | KEY ATT_fname (ATT_fname), |
114 | 114 | KEY ATT_lname (ATT_lname), |
115 | 115 | KEY ATT_email (ATT_email)"; |
116 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | - $table_name = 'esp_country'; |
|
118 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
116 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | + $table_name = 'esp_country'; |
|
118 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
119 | 119 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
120 | 120 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
121 | 121 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | CNT_is_EU TINYINT(1) DEFAULT '0', |
132 | 132 | CNT_active TINYINT(1) DEFAULT '0', |
133 | 133 | PRIMARY KEY (CNT_ISO)"; |
134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | - $table_name = 'esp_currency'; |
|
136 | - $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | + $table_name = 'esp_currency'; |
|
136 | + $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
137 | 137 | CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar', |
138 | 138 | CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars', |
139 | 139 | CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$', |
140 | 140 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
141 | 141 | CUR_active TINYINT(1) DEFAULT '0', |
142 | 142 | PRIMARY KEY (CUR_code)"; |
143 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | - $table_name = 'esp_datetime'; |
|
145 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
143 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | + $table_name = 'esp_datetime'; |
|
145 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
146 | 146 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
147 | 147 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
148 | 148 | DTT_description TEXT NOT NULL, |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | PRIMARY KEY (DTT_ID), |
158 | 158 | KEY EVT_ID (EVT_ID), |
159 | 159 | KEY DTT_is_primary (DTT_is_primary)"; |
160 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | - $table_name = 'esp_event_meta'; |
|
162 | - $sql = " |
|
160 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | + $table_name = 'esp_event_meta'; |
|
162 | + $sql = " |
|
163 | 163 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
164 | 164 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
165 | 165 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -174,31 +174,31 @@ discard block |
||
174 | 174 | EVT_external_URL VARCHAR(200) NULL, |
175 | 175 | EVT_donations TINYINT(1) NULL, |
176 | 176 | PRIMARY KEY (EVTM_ID)"; |
177 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | - $table_name = 'esp_event_question_group'; |
|
179 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
177 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | + $table_name = 'esp_event_question_group'; |
|
179 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
180 | 180 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
181 | 181 | QSG_ID INT UNSIGNED NOT NULL, |
182 | 182 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
183 | 183 | PRIMARY KEY (EQG_ID)"; |
184 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
185 | - $table_name = 'esp_event_venue'; |
|
186 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
184 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
185 | + $table_name = 'esp_event_venue'; |
|
186 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
187 | 187 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
188 | 188 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
189 | 189 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
190 | 190 | PRIMARY KEY (EVV_ID)"; |
191 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
192 | - $table_name = 'esp_extra_meta'; |
|
193 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
191 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
192 | + $table_name = 'esp_extra_meta'; |
|
193 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
194 | 194 | OBJ_ID INT(11) DEFAULT NULL, |
195 | 195 | EXM_type VARCHAR(45) DEFAULT NULL, |
196 | 196 | EXM_key VARCHAR(45) DEFAULT NULL, |
197 | 197 | EXM_value TEXT, |
198 | 198 | PRIMARY KEY (EXM_ID)"; |
199 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
200 | - $table_name = 'esp_line_item'; |
|
201 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
199 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
200 | + $table_name = 'esp_line_item'; |
|
201 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
202 | 202 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
203 | 203 | TXN_ID INT(11) DEFAULT NULL, |
204 | 204 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | OBJ_ID INT(11) DEFAULT NULL, |
215 | 215 | OBJ_type VARCHAR(45)DEFAULT NULL, |
216 | 216 | PRIMARY KEY (LIN_ID)"; |
217 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
218 | - $table_name = 'esp_log'; |
|
219 | - $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
217 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
218 | + $table_name = 'esp_log'; |
|
219 | + $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
220 | 220 | LOG_time DATETIME DEFAULT NULL, |
221 | 221 | OBJ_ID VARCHAR(45) DEFAULT NULL, |
222 | 222 | OBJ_type VARCHAR(45) DEFAULT NULL, |
@@ -224,19 +224,19 @@ discard block |
||
224 | 224 | LOG_message TEXT, |
225 | 225 | LOG_wp_user INT(11) DEFAULT NULL, |
226 | 226 | PRIMARY KEY (LOG_ID)"; |
227 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | - $table_name = 'esp_message_template'; |
|
229 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
227 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | + $table_name = 'esp_message_template'; |
|
229 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
230 | 230 | GRP_ID INT(10) UNSIGNED NOT NULL, |
231 | 231 | MTP_context VARCHAR(50) NOT NULL, |
232 | 232 | MTP_template_field VARCHAR(30) NOT NULL, |
233 | 233 | MTP_content TEXT NOT NULL, |
234 | 234 | PRIMARY KEY (MTP_ID), |
235 | 235 | KEY GRP_ID (GRP_ID)"; |
236 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
237 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
238 | - $table_name = 'esp_message_template_group'; |
|
239 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
236 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
237 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
238 | + $table_name = 'esp_message_template_group'; |
|
239 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
240 | 240 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
241 | 241 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
242 | 242 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -248,17 +248,17 @@ discard block |
||
248 | 248 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
249 | 249 | PRIMARY KEY (GRP_ID), |
250 | 250 | KEY MTP_user_id (MTP_user_id)"; |
251 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
252 | - $table_name = 'esp_event_message_template'; |
|
253 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
251 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
252 | + $table_name = 'esp_event_message_template'; |
|
253 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
254 | 254 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
255 | 255 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
256 | 256 | PRIMARY KEY (EMT_ID), |
257 | 257 | KEY EVT_ID (EVT_ID), |
258 | 258 | KEY GRP_ID (GRP_ID)"; |
259 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | - $table_name = 'esp_payment'; |
|
261 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
259 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | + $table_name = 'esp_payment'; |
|
261 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
262 | 262 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
263 | 263 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
264 | 264 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | PRIMARY KEY (PAY_ID), |
276 | 276 | KEY TXN_ID (TXN_ID), |
277 | 277 | KEY PAY_timestamp (PAY_timestamp)"; |
278 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
279 | - $table_name = 'esp_payment_method'; |
|
280 | - $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
278 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
279 | + $table_name = 'esp_payment_method'; |
|
280 | + $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
281 | 281 | PMD_type VARCHAR(124) DEFAULT NULL, |
282 | 282 | PMD_name VARCHAR(255) DEFAULT NULL, |
283 | 283 | PMD_desc TEXT, |
@@ -292,28 +292,28 @@ discard block |
||
292 | 292 | PMD_scope VARCHAR(255) NULL DEFAULT 'frontend', |
293 | 293 | PRIMARY KEY (PMD_ID), |
294 | 294 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
295 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
296 | - $table_name = "esp_ticket_price"; |
|
297 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
295 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
296 | + $table_name = "esp_ticket_price"; |
|
297 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
298 | 298 | TKT_ID INT(10) UNSIGNED NOT NULL, |
299 | 299 | PRC_ID INT(10) UNSIGNED NOT NULL, |
300 | 300 | PRIMARY KEY (TKP_ID)"; |
301 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
302 | - $table_name = "esp_datetime_ticket"; |
|
303 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
301 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
302 | + $table_name = "esp_datetime_ticket"; |
|
303 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
304 | 304 | DTT_ID INT(10) UNSIGNED NOT NULL, |
305 | 305 | TKT_ID INT(10) UNSIGNED NOT NULL, |
306 | 306 | PRIMARY KEY (DTK_ID)"; |
307 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | - $table_name = "esp_ticket_template"; |
|
309 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
307 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | + $table_name = "esp_ticket_template"; |
|
309 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
310 | 310 | TTM_name VARCHAR(45) NOT NULL, |
311 | 311 | TTM_description TEXT, |
312 | 312 | TTM_file VARCHAR(45), |
313 | 313 | PRIMARY KEY (TTM_ID)"; |
314 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
315 | - $table_name = 'esp_question'; |
|
316 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
314 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
315 | + $table_name = 'esp_question'; |
|
316 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
317 | 317 | QST_display_text TEXT NOT NULL, |
318 | 318 | QST_admin_label VARCHAR(255) NOT NULL, |
319 | 319 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -325,25 +325,25 @@ discard block |
||
325 | 325 | QST_wp_user BIGINT UNSIGNED NULL, |
326 | 326 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
327 | 327 | PRIMARY KEY (QST_ID)'; |
328 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
329 | - $table_name = 'esp_question_group_question'; |
|
330 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
328 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
329 | + $table_name = 'esp_question_group_question'; |
|
330 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
331 | 331 | QSG_ID INT UNSIGNED NOT NULL, |
332 | 332 | QST_ID INT UNSIGNED NOT NULL, |
333 | 333 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
334 | 334 | PRIMARY KEY (QGQ_ID) "; |
335 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
336 | - $table_name = 'esp_question_option'; |
|
337 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
335 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
336 | + $table_name = 'esp_question_option'; |
|
337 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
338 | 338 | QSO_value VARCHAR(255) NOT NULL, |
339 | 339 | QSO_desc TEXT NOT NULL, |
340 | 340 | QST_ID INT UNSIGNED NOT NULL, |
341 | 341 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
342 | 342 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
343 | 343 | PRIMARY KEY (QSO_ID)"; |
344 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | - $table_name = 'esp_registration'; |
|
346 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
344 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | + $table_name = 'esp_registration'; |
|
346 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
347 | 347 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
348 | 348 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
349 | 349 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -366,25 +366,25 @@ discard block |
||
366 | 366 | KEY STS_ID (STS_ID), |
367 | 367 | KEY REG_url_link (REG_url_link), |
368 | 368 | KEY REG_code (REG_code)"; |
369 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
370 | - $table_name = 'esp_checkin'; |
|
371 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
369 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
370 | + $table_name = 'esp_checkin'; |
|
371 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
372 | 372 | REG_ID INT(10) UNSIGNED NOT NULL, |
373 | 373 | DTT_ID INT(10) UNSIGNED NOT NULL, |
374 | 374 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
375 | 375 | CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
376 | 376 | PRIMARY KEY (CHK_ID)"; |
377 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | - $table_name = 'esp_state'; |
|
379 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
377 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | + $table_name = 'esp_state'; |
|
379 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
380 | 380 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
381 | 381 | STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL, |
382 | 382 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
383 | 383 | STA_active TINYINT(1) DEFAULT '1', |
384 | 384 | PRIMARY KEY (STA_ID)"; |
385 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
386 | - $table_name = 'esp_status'; |
|
387 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
385 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
386 | + $table_name = 'esp_status'; |
|
387 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
388 | 388 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
389 | 389 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
390 | 390 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
393 | 393 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
394 | 394 | KEY STS_type (STS_type)"; |
395 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | - $table_name = 'esp_transaction'; |
|
397 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
395 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | + $table_name = 'esp_transaction'; |
|
397 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
398 | 398 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
399 | 399 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
400 | 400 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -406,9 +406,9 @@ discard block |
||
406 | 406 | PRIMARY KEY (TXN_ID), |
407 | 407 | KEY TXN_timestamp (TXN_timestamp), |
408 | 408 | KEY STS_ID (STS_ID)"; |
409 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
410 | - $table_name = 'esp_venue_meta'; |
|
411 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
409 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
410 | + $table_name = 'esp_venue_meta'; |
|
411 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
412 | 412 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
413 | 413 | VNU_address VARCHAR(255) DEFAULT NULL, |
414 | 414 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | PRIMARY KEY (VNUM_ID), |
427 | 427 | KEY STA_ID (STA_ID), |
428 | 428 | KEY CNT_ISO (CNT_ISO)"; |
429 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
430 | - //modified tables |
|
431 | - $table_name = "esp_price"; |
|
432 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
429 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
430 | + //modified tables |
|
431 | + $table_name = "esp_price"; |
|
432 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
433 | 433 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
434 | 434 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
435 | 435 | PRC_name VARCHAR(245) NOT NULL, |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | PRC_wp_user BIGINT UNSIGNED NULL, |
442 | 442 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
443 | 443 | PRIMARY KEY (PRC_ID)"; |
444 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
445 | - $table_name = "esp_price_type"; |
|
446 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
444 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
445 | + $table_name = "esp_price_type"; |
|
446 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
447 | 447 | PRT_name VARCHAR(45) NOT NULL, |
448 | 448 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
449 | 449 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -452,9 +452,9 @@ discard block |
||
452 | 452 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
453 | 453 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
454 | 454 | PRIMARY KEY (PRT_ID)"; |
455 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
456 | - $table_name = "esp_ticket"; |
|
457 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
455 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
456 | + $table_name = "esp_ticket"; |
|
457 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
458 | 458 | TTM_ID INT(10) UNSIGNED NOT NULL, |
459 | 459 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
460 | 460 | TKT_description TEXT NOT NULL, |
@@ -475,10 +475,10 @@ discard block |
||
475 | 475 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
476 | 476 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
477 | 477 | PRIMARY KEY (TKT_ID)"; |
478 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
479 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
480 | - $table_name = 'esp_question_group'; |
|
481 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
478 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
479 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
480 | + $table_name = 'esp_question_group'; |
|
481 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
482 | 482 | QSG_name VARCHAR(255) NOT NULL, |
483 | 483 | QSG_identifier VARCHAR(100) NOT NULL, |
484 | 484 | QSG_desc TEXT NULL, |
@@ -490,119 +490,119 @@ discard block |
||
490 | 490 | QSG_wp_user BIGINT UNSIGNED NULL, |
491 | 491 | PRIMARY KEY (QSG_ID), |
492 | 492 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
493 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
494 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
495 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
496 | - //(because many need to convert old string states to foreign keys into the states table) |
|
497 | - $script_4_1_defaults->insert_default_states(); |
|
498 | - $script_4_1_defaults->insert_default_countries(); |
|
499 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
500 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
501 | - $script_4_5_defaults->insert_default_price_types(); |
|
502 | - $script_4_5_defaults->insert_default_prices(); |
|
503 | - $script_4_5_defaults->insert_default_tickets(); |
|
504 | - //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
505 | - EE_Config::instance()->update_espresso_config(false, true); |
|
506 | - $this->add_default_admin_only_payments(); |
|
507 | - $this->insert_default_currencies(); |
|
508 | - return true; |
|
509 | - } |
|
510 | - |
|
511 | - |
|
512 | - |
|
513 | - /** |
|
514 | - * @return boolean |
|
515 | - */ |
|
516 | - public function schema_changes_after_migration() |
|
517 | - { |
|
518 | - return true; |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - |
|
523 | - public function migration_page_hooks() |
|
524 | - { |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - public function add_default_admin_only_payments() |
|
530 | - { |
|
531 | - global $wpdb; |
|
532 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
533 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
534 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
535 | - $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
536 | - $existing_payment_methods = $wpdb->get_var($SQL); |
|
537 | - $default_admin_only_payment_methods = apply_filters( |
|
538 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
539 | - array( |
|
540 | - __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
541 | - __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
542 | - __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
543 | - __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
544 | - __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
545 | - __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
546 | - 'event_espresso'), |
|
547 | - __("Money Order", 'event_espresso') => '', |
|
548 | - __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
549 | - __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
550 | - )); |
|
551 | - //make sure we hae payment method records for the following |
|
552 | - //so admins can record payments for them from the admin page |
|
553 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
554 | - $slug = sanitize_key($nicename); |
|
555 | - //check that such a payment method exists |
|
556 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
557 | - if ( ! $exists) { |
|
558 | - $values = array( |
|
559 | - 'PMD_type' => 'Admin_Only', |
|
560 | - 'PMD_name' => $nicename, |
|
561 | - 'PMD_admin_name' => $nicename, |
|
562 | - 'PMD_admin_desc' => $description, |
|
563 | - 'PMD_slug' => $slug, |
|
564 | - 'PMD_wp_user' => $user_id, |
|
565 | - 'PMD_scope' => serialize(array('ADMIN')), |
|
566 | - ); |
|
567 | - $success = $wpdb->insert( |
|
568 | - $table_name, |
|
569 | - $values, |
|
570 | - array( |
|
571 | - '%s',//PMD_type |
|
572 | - '%s',//PMD_name |
|
573 | - '%s',//PMD_admin_name |
|
574 | - '%s',//PMD_admin_desc |
|
575 | - '%s',//PMD_slug |
|
576 | - '%d',//PMD_wp_user |
|
577 | - '%s',//PMD_scope |
|
578 | - ) |
|
579 | - ); |
|
580 | - if ( ! $success) { |
|
581 | - $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
582 | - "event_espresso"), $this->_json_encode($values))); |
|
583 | - } |
|
584 | - } |
|
585 | - } |
|
586 | - } |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - |
|
591 | - /** |
|
592 | - * insert_default_countries |
|
593 | - * |
|
594 | - * @static |
|
595 | - * @return void |
|
596 | - */ |
|
597 | - public function insert_default_currencies() |
|
598 | - { |
|
599 | - global $wpdb; |
|
600 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
601 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
602 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
603 | - $countries = $wpdb->get_var($SQL); |
|
604 | - if ( ! $countries) { |
|
605 | - $SQL = "INSERT INTO $currency_table |
|
493 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
494 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
495 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
496 | + //(because many need to convert old string states to foreign keys into the states table) |
|
497 | + $script_4_1_defaults->insert_default_states(); |
|
498 | + $script_4_1_defaults->insert_default_countries(); |
|
499 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
500 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
501 | + $script_4_5_defaults->insert_default_price_types(); |
|
502 | + $script_4_5_defaults->insert_default_prices(); |
|
503 | + $script_4_5_defaults->insert_default_tickets(); |
|
504 | + //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
505 | + EE_Config::instance()->update_espresso_config(false, true); |
|
506 | + $this->add_default_admin_only_payments(); |
|
507 | + $this->insert_default_currencies(); |
|
508 | + return true; |
|
509 | + } |
|
510 | + |
|
511 | + |
|
512 | + |
|
513 | + /** |
|
514 | + * @return boolean |
|
515 | + */ |
|
516 | + public function schema_changes_after_migration() |
|
517 | + { |
|
518 | + return true; |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + |
|
523 | + public function migration_page_hooks() |
|
524 | + { |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + public function add_default_admin_only_payments() |
|
530 | + { |
|
531 | + global $wpdb; |
|
532 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
533 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
534 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
535 | + $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
536 | + $existing_payment_methods = $wpdb->get_var($SQL); |
|
537 | + $default_admin_only_payment_methods = apply_filters( |
|
538 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
539 | + array( |
|
540 | + __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
541 | + __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
542 | + __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
543 | + __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
544 | + __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
545 | + __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
546 | + 'event_espresso'), |
|
547 | + __("Money Order", 'event_espresso') => '', |
|
548 | + __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
549 | + __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
550 | + )); |
|
551 | + //make sure we hae payment method records for the following |
|
552 | + //so admins can record payments for them from the admin page |
|
553 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
554 | + $slug = sanitize_key($nicename); |
|
555 | + //check that such a payment method exists |
|
556 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
557 | + if ( ! $exists) { |
|
558 | + $values = array( |
|
559 | + 'PMD_type' => 'Admin_Only', |
|
560 | + 'PMD_name' => $nicename, |
|
561 | + 'PMD_admin_name' => $nicename, |
|
562 | + 'PMD_admin_desc' => $description, |
|
563 | + 'PMD_slug' => $slug, |
|
564 | + 'PMD_wp_user' => $user_id, |
|
565 | + 'PMD_scope' => serialize(array('ADMIN')), |
|
566 | + ); |
|
567 | + $success = $wpdb->insert( |
|
568 | + $table_name, |
|
569 | + $values, |
|
570 | + array( |
|
571 | + '%s',//PMD_type |
|
572 | + '%s',//PMD_name |
|
573 | + '%s',//PMD_admin_name |
|
574 | + '%s',//PMD_admin_desc |
|
575 | + '%s',//PMD_slug |
|
576 | + '%d',//PMD_wp_user |
|
577 | + '%s',//PMD_scope |
|
578 | + ) |
|
579 | + ); |
|
580 | + if ( ! $success) { |
|
581 | + $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
582 | + "event_espresso"), $this->_json_encode($values))); |
|
583 | + } |
|
584 | + } |
|
585 | + } |
|
586 | + } |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + |
|
591 | + /** |
|
592 | + * insert_default_countries |
|
593 | + * |
|
594 | + * @static |
|
595 | + * @return void |
|
596 | + */ |
|
597 | + public function insert_default_currencies() |
|
598 | + { |
|
599 | + global $wpdb; |
|
600 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
601 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
602 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
603 | + $countries = $wpdb->get_var($SQL); |
|
604 | + if ( ! $countries) { |
|
605 | + $SQL = "INSERT INTO $currency_table |
|
606 | 606 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
607 | 607 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
608 | 608 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -756,10 +756,10 @@ discard block |
||
756 | 756 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
757 | 757 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
758 | 758 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
759 | - $wpdb->query($SQL); |
|
760 | - } |
|
761 | - } |
|
762 | - } |
|
759 | + $wpdb->query($SQL); |
|
760 | + } |
|
761 | + } |
|
762 | + } |
|
763 | 763 | |
764 | 764 | } |
765 | 765 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,30 +25,30 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEM_Currency extends EEM_Base{ |
|
28 | +class EEM_Currency extends EEM_Base { |
|
29 | 29 | // private instance of the Attendee object |
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | - protected function __construct( $timezone = NULL ) { |
|
33 | - $this->singular_item = __('Currency','event_espresso'); |
|
34 | - $this->plural_item = __('Currencies','event_espresso'); |
|
32 | + protected function __construct($timezone = NULL) { |
|
33 | + $this->singular_item = __('Currency', 'event_espresso'); |
|
34 | + $this->plural_item = __('Currencies', 'event_espresso'); |
|
35 | 35 | $this->_tables = array( |
36 | 36 | 'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code') |
37 | 37 | ); |
38 | 38 | $this->_fields = array( |
39 | 39 | 'Currency'=>array( |
40 | - 'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code','event_espresso')), |
|
41 | - 'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular','event_espresso'), false), |
|
42 | - 'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural','event_espresso'), false), |
|
43 | - 'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign','event_espresso'), false), |
|
44 | - 'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places','event_espresso'), false, 2), |
|
45 | - 'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false,true), |
|
40 | + 'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')), |
|
41 | + 'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false), |
|
42 | + 'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false), |
|
43 | + 'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false), |
|
44 | + 'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2), |
|
45 | + 'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true), |
|
46 | 46 | )); |
47 | 47 | $this->_model_relations = array(); |
48 | 48 | //this model is generally available for reading |
49 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
49 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
50 | 50 | |
51 | - parent::__construct( $timezone ); |
|
51 | + parent::__construct($timezone); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | * @param array $query_params see EEM_Base::get_all |
58 | 58 | * @return EE_Currency[] |
59 | 59 | */ |
60 | - public function get_all_active($query_params = array()){ |
|
60 | + public function get_all_active($query_params = array()) { |
|
61 | 61 | $query_params[0]['CUR_active'] = true; |
62 | - if( ! isset($query_params['order_by'])){ |
|
63 | - $query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC'); |
|
62 | + if ( ! isset($query_params['order_by'])) { |
|
63 | + $query_params['order_by'] = array('CUR_code'=>'ASC', 'CUR_single'=>'ASC'); |
|
64 | 64 | } |
65 | 65 | return $this->get_all($query_params); |
66 | 66 | } |
@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | * @param EE_PMT_Base $payment_method_type |
70 | 70 | * @return EE_Currency[] |
71 | 71 | */ |
72 | - public function get_all_currencies_usable_by($payment_method_type){ |
|
73 | - if($payment_method_type instanceof EE_PMT_Base && |
|
74 | - $payment_method_type->get_gateway()){ |
|
72 | + public function get_all_currencies_usable_by($payment_method_type) { |
|
73 | + if ($payment_method_type instanceof EE_PMT_Base && |
|
74 | + $payment_method_type->get_gateway()) { |
|
75 | 75 | $currencies_supported = $payment_method_type->get_gateway()->currencies_supported(); |
76 | - }else{ |
|
76 | + } else { |
|
77 | 77 | $currencies_supported = EE_Gateway::all_currencies_supported; |
78 | 78 | } |
79 | - if($currencies_supported == EE_Gateway::all_currencies_supported || empty( $currencies_supported ) ) { |
|
79 | + if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) { |
|
80 | 80 | $currencies = $this->get_all_active(); |
81 | - }else{ |
|
82 | - $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported)))); |
|
81 | + } else { |
|
82 | + $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN', $currencies_supported)))); |
|
83 | 83 | } |
84 | 84 | return $currencies; |
85 | 85 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | * @access protected |
38 | 38 | * @return EEM_Payment_Method |
39 | 39 | */ |
40 | - protected function __construct( $timezone = NULL ) { |
|
41 | - $this->singlular_item = __( 'Payment Method', 'event_espresso' ); |
|
42 | - $this->plural_item = __( 'Payment Methods', 'event_espresso' ); |
|
43 | - $this->_tables = array( 'Payment_Method' => new EE_Primary_Table( 'esp_payment_method', 'PMD_ID' ) ); |
|
40 | + protected function __construct($timezone = NULL) { |
|
41 | + $this->singlular_item = __('Payment Method', 'event_espresso'); |
|
42 | + $this->plural_item = __('Payment Methods', 'event_espresso'); |
|
43 | + $this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID')); |
|
44 | 44 | $this->_fields = array( |
45 | 45 | 'Payment_Method' => array( |
46 | - 'PMD_ID' => new EE_Primary_Key_Int_Field( 'PMD_ID', __( "ID", 'event_espresso' ) ), |
|
47 | - 'PMD_type' => new EE_Plain_Text_Field( 'PMD_type', __( "Payment Method Type", 'event_espresso' ), FALSE, 'Admin_Only' ), |
|
48 | - 'PMD_name' => new EE_Plain_Text_Field( 'PMD_name', __( "Name", 'event_espresso' ), FALSE ), |
|
49 | - 'PMD_desc' => new EE_Post_Content_Field( 'PMD_desc', __( "Description", 'event_espresso' ), FALSE, '' ), |
|
50 | - 'PMD_admin_name' => new EE_Plain_Text_Field( 'PMD_admin_name', __( "Admin-Only Name", 'event_espresso' ), TRUE ), |
|
51 | - 'PMD_admin_desc' => new EE_Post_Content_Field( 'PMD_admin_desc', __( "Admin-Only Description", 'event_espresso' ), TRUE ), |
|
52 | - 'PMD_slug' => new EE_Slug_Field( 'PMD_slug', __( "Slug", 'event_espresso' ), FALSE ), |
|
53 | - 'PMD_order' => new EE_Integer_Field( 'PMD_order', __( "Order", 'event_espresso' ), FALSE, 0 ), |
|
54 | - 'PMD_debug_mode' => new EE_Boolean_Field( 'PMD_debug_mode', __( "Debug Mode On?", 'event_espresso' ), FALSE, FALSE ), |
|
55 | - 'PMD_wp_user' => new EE_WP_User_Field( 'PMD_wp_user', __( "Payment Method Creator ID", 'event_espresso' ), FALSE ), |
|
56 | - 'PMD_open_by_default' => new EE_Boolean_Field( 'PMD_open_by_default', __( "Open by Default?", 'event_espresso' ), FALSE, FALSE ), 'PMD_button_url' => new EE_Plain_Text_Field( 'PMD_button_url', __( "Button URL", 'event_espresso' ), TRUE, '' ), |
|
57 | - 'PMD_scope' => new EE_Serialized_Text_Field( 'PMD_scope', __( "Usable From?", 'event_espresso' ), FALSE, array() ), //possible values currently are 'CART','ADMIN','API' |
|
46 | + 'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')), |
|
47 | + 'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), FALSE, 'Admin_Only'), |
|
48 | + 'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), FALSE), |
|
49 | + 'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), FALSE, ''), |
|
50 | + 'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), TRUE), |
|
51 | + 'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), TRUE), |
|
52 | + 'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), FALSE), |
|
53 | + 'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), FALSE, 0), |
|
54 | + 'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), FALSE, FALSE), |
|
55 | + 'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), FALSE), |
|
56 | + 'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), FALSE, FALSE), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), TRUE, ''), |
|
57 | + 'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), FALSE, array()), //possible values currently are 'CART','ADMIN','API' |
|
58 | 58 | ) ); |
59 | 59 | $this->_model_relations = array( |
60 | 60 | // 'Event'=>new EE_HABTM_Relation('Event_Payment_Method'), |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'Transaction' => new EE_Has_Many_Relation(), |
63 | 63 | 'WP_User' => new EE_Belongs_To_Relation(), |
64 | 64 | ); |
65 | - parent::__construct( $timezone ); |
|
65 | + parent::__construct($timezone); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $slug |
73 | 73 | * @return EE_Payment_Method |
74 | 74 | */ |
75 | - public function get_one_by_slug( $slug ) { |
|
76 | - return $this->get_one( array( array( 'PMD_slug' => $slug ) ) ); |
|
75 | + public function get_one_by_slug($slug) { |
|
76 | + return $this->get_one(array(array('PMD_slug' => $slug))); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | return apply_filters( |
88 | 88 | 'FHEE__EEM_Payment_Method__scopes', |
89 | 89 | array( |
90 | - self::scope_cart => __( "Front-end Registration Page", 'event_espresso' ), |
|
91 | - self::scope_admin => __( "Admin Registration Page (no online processing)", 'event_espresso' ) |
|
90 | + self::scope_cart => __("Front-end Registration Page", 'event_espresso'), |
|
91 | + self::scope_admin => __("Admin Registration Page (no online processing)", 'event_espresso') |
|
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | } |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
101 | 101 | * @return boolean |
102 | 102 | */ |
103 | - public function is_valid_scope( $scope ) { |
|
103 | + public function is_valid_scope($scope) { |
|
104 | 104 | $scopes = $this->scopes(); |
105 | - if ( isset( $scopes[ $scope ] ) ) { |
|
105 | + if (isset($scopes[$scope])) { |
|
106 | 106 | return TRUE; |
107 | 107 | } else { |
108 | 108 | return FALSE; |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | * @throws EE_Error |
119 | 119 | * @return EE_Payment_Method[] |
120 | 120 | */ |
121 | - public function get_all_active( $scope = NULL, $query_params = array() ) { |
|
122 | - if( ! isset( $query_params[ 'order_by' ] ) && ! isset( $query_params[ 'order' ] ) ) { |
|
123 | - $query_params['order_by'] = array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ); |
|
121 | + public function get_all_active($scope = NULL, $query_params = array()) { |
|
122 | + if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
123 | + $query_params['order_by'] = array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC'); |
|
124 | 124 | } |
125 | - return $this->get_all( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
125 | + return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param array $query_params |
132 | 132 | * @return int |
133 | 133 | */ |
134 | - public function count_active( $scope = NULL, $query_params = array() ){ |
|
135 | - return $this->count( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
134 | + public function count_active($scope = NULL, $query_params = array()) { |
|
135 | + return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -143,21 +143,21 @@ discard block |
||
143 | 143 | * @return array like param of EEM_Base::get_all() |
144 | 144 | * @throws EE_Error |
145 | 145 | */ |
146 | - protected function _get_query_params_for_all_active( $scope = NULL, $query_params = array() ){ |
|
147 | - if ( $scope ) { |
|
148 | - if ( $this->is_valid_scope( $scope ) ) { |
|
149 | - return array_replace_recursive( array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params ); |
|
146 | + protected function _get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
147 | + if ($scope) { |
|
148 | + if ($this->is_valid_scope($scope)) { |
|
149 | + return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params); |
|
150 | 150 | } else { |
151 | - throw new EE_Error( sprintf( __( "'%s' is not a valid scope for a payment method", "event_espresso" ), $scope ) ); |
|
151 | + throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope)); |
|
152 | 152 | } |
153 | 153 | } else { |
154 | 154 | $acceptable_scopes = array(); |
155 | 155 | $count = 0; |
156 | - foreach ( $this->scopes() as $scope_name => $desc ) { |
|
156 | + foreach ($this->scopes() as $scope_name => $desc) { |
|
157 | 157 | $count++; |
158 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' ); |
|
158 | + $acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%'); |
|
159 | 159 | } |
160 | - return array_replace_recursive( array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params ); |
|
160 | + return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @return array like param of EEM_Base::get_all() |
170 | 170 | * @throws EE_Error |
171 | 171 | */ |
172 | - public function get_query_params_for_all_active( $scope = NULL, $query_params = array() ) { |
|
173 | - return $this->_get_query_params_for_all_active( $scope, $query_params ); |
|
172 | + public function get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
173 | + return $this->_get_query_params_for_all_active($scope, $query_params); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | * @param array $query_params |
181 | 181 | * @return EE_Payment_Method |
182 | 182 | */ |
183 | - public function get_one_active( $scope = NULL, $query_params = array() ) { |
|
184 | - return $this->get_one( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
183 | + public function get_one_active($scope = NULL, $query_params = array()) { |
|
184 | + return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @param string $type |
192 | 192 | * @return EE_Payment_Method |
193 | 193 | */ |
194 | - public function get_one_of_type( $type ) { |
|
195 | - return $this->get_one( array( array( 'PMD_type' => $type ) ) ); |
|
194 | + public function get_one_of_type($type) { |
|
195 | + return $this->get_one(array(array('PMD_type' => $type))); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -205,22 +205,22 @@ discard block |
||
205 | 205 | * @return EE_Payment_Method |
206 | 206 | * @throws EE_Error |
207 | 207 | */ |
208 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ) { |
|
208 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
209 | 209 | //first: check if it's a slug |
210 | - if( is_string( $base_class_obj_or_id ) ) { |
|
211 | - $obj = $this->get_one_by_slug( $base_class_obj_or_id ); |
|
212 | - if( $obj ) { |
|
210 | + if (is_string($base_class_obj_or_id)) { |
|
211 | + $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
212 | + if ($obj) { |
|
213 | 213 | return $obj; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | //ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
217 | 217 | try { |
218 | - return parent::ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db ); |
|
218 | + return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
219 | 219 | } |
220 | - catch ( EE_Error $e ) { |
|
220 | + catch (EE_Error $e) { |
|
221 | 221 | //handle it outside the catch |
222 | 222 | } |
223 | - throw new EE_Error( sprintf( __( "'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso" ), $base_class_obj_or_id ) ); |
|
223 | + throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id)); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | * @param mixed $base_obj_or_id_or_slug |
232 | 232 | * @return int |
233 | 233 | */ |
234 | - function ensure_is_ID( $base_obj_or_id_or_slug ) { |
|
235 | - if ( is_string( $base_obj_or_id_or_slug ) ) { |
|
234 | + function ensure_is_ID($base_obj_or_id_or_slug) { |
|
235 | + if (is_string($base_obj_or_id_or_slug)) { |
|
236 | 236 | //assume it's a slug |
237 | - $base_obj_or_id_or_slug = $this->get_one_by_slug( $base_obj_or_id_or_slug ); |
|
237 | + $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
238 | 238 | } |
239 | - return parent::ensure_is_ID( $base_obj_or_id_or_slug ); |
|
239 | + return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -245,36 +245,36 @@ discard block |
||
245 | 245 | * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default. |
246 | 246 | * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart |
247 | 247 | */ |
248 | - function verify_button_urls( $payment_methods = NULL ) { |
|
249 | - $payment_methods = is_array( $payment_methods ) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
250 | - foreach ( $payment_methods as $payment_method ) { |
|
248 | + function verify_button_urls($payment_methods = NULL) { |
|
249 | + $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
250 | + foreach ($payment_methods as $payment_method) { |
|
251 | 251 | try { |
252 | 252 | $current_button_url = $payment_method->button_url(); |
253 | - $buttons_urls_to_try = apply_filters( 'FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
254 | - 'current_ssl' => str_replace( "http://", "https://", $current_button_url ), |
|
255 | - 'current' => str_replace( "https://", "http://", $current_button_url ), |
|
256 | - 'default_ssl' => str_replace( "http://", "https://", $payment_method->type_obj()->default_button_url() ), |
|
257 | - 'default' => str_replace( "https://", "http://", $payment_method->type_obj()->default_button_url() ), |
|
258 | - ) ); |
|
259 | - foreach( $buttons_urls_to_try as $button_url_to_try ) { |
|
260 | - if( |
|
253 | + $buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
254 | + 'current_ssl' => str_replace("http://", "https://", $current_button_url), |
|
255 | + 'current' => str_replace("https://", "http://", $current_button_url), |
|
256 | + 'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()), |
|
257 | + 'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()), |
|
258 | + )); |
|
259 | + foreach ($buttons_urls_to_try as $button_url_to_try) { |
|
260 | + if ( |
|
261 | 261 | (//this is the current url and it exists, regardless of SSL issues |
262 | 262 | $button_url_to_try == $current_button_url && |
263 | 263 | EEH_URL::remote_file_exists( |
264 | 264 | $button_url_to_try, |
265 | 265 | array( |
266 | 266 | 'sslverify' => false, |
267 | - 'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
267 | + 'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
268 | 268 | ) ) |
269 | 269 | ) |
270 | 270 | || |
271 | 271 | (//this is NOT the current url and it exists with a working SSL cert |
272 | 272 | $button_url_to_try != $current_button_url && |
273 | - EEH_URL::remote_file_exists( $button_url_to_try ) |
|
273 | + EEH_URL::remote_file_exists($button_url_to_try) |
|
274 | 274 | ) ) { |
275 | - if( $current_button_url != $button_url_to_try ){ |
|
276 | - $payment_method->save( array( 'PMD_button_url' => $button_url_to_try ) ); |
|
277 | - EE_Error::add_attention( sprintf( __( "Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso" ), $payment_method->name(), $button_url_to_try ) ); |
|
275 | + if ($current_button_url != $button_url_to_try) { |
|
276 | + $payment_method->save(array('PMD_button_url' => $button_url_to_try)); |
|
277 | + EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try)); |
|
278 | 278 | } |
279 | 279 | //this image exists. So if wasn't set before, now it is; |
280 | 280 | //or if it was already set, we have nothing to do |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | } |
283 | 283 | } |
284 | 284 | } |
285 | - catch ( EE_Error $e ) { |
|
286 | - $payment_method->set_active( FALSE ); |
|
285 | + catch (EE_Error $e) { |
|
286 | + $payment_method->set_active(FALSE); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
@@ -297,29 +297,29 @@ discard block |
||
297 | 297 | * @param array $rows |
298 | 298 | * @return EE_Payment_Method[] |
299 | 299 | */ |
300 | - protected function _create_objects( $rows = array() ) { |
|
301 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
302 | - $payment_methods = parent::_create_objects( $rows ); |
|
300 | + protected function _create_objects($rows = array()) { |
|
301 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
302 | + $payment_methods = parent::_create_objects($rows); |
|
303 | 303 | /* @var $payment_methods EE_Payment_Method[] */ |
304 | 304 | $usable_payment_methods = array(); |
305 | - foreach ( $payment_methods as $key => $payment_method ) { |
|
306 | - if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $payment_method->type() ) ) { |
|
307 | - $usable_payment_methods[ $key ] = $payment_method; |
|
305 | + foreach ($payment_methods as $key => $payment_method) { |
|
306 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
307 | + $usable_payment_methods[$key] = $payment_method; |
|
308 | 308 | //some payment methods enqueue their scripts in EE_PMT_*::__construct |
309 | 309 | //which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
310 | 310 | //its scripts). but for backwards-compat we should continue to do that |
311 | 311 | $payment_method->type_obj(); |
312 | - } elseif( $payment_method->active() ) { |
|
312 | + } elseif ($payment_method->active()) { |
|
313 | 313 | //only deactivate and notify the admin if the payment is active somewhere |
314 | 314 | $payment_method->deactivate(); |
315 | 315 | $payment_method->save(); |
316 | 316 | EE_Error::add_persistent_admin_notice( |
317 | - 'auto-deactivated-' . $payment_method->type(), |
|
317 | + 'auto-deactivated-'.$payment_method->type(), |
|
318 | 318 | sprintf( |
319 | - __( 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso' ), |
|
319 | + __('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'), |
|
320 | 320 | $payment_method->admin_name(), |
321 | 321 | '<br />', |
322 | - '<a href="' . admin_url('plugins.php') . '">', |
|
322 | + '<a href="'.admin_url('plugins.php').'">', |
|
323 | 323 | '</a>' |
324 | 324 | ), |
325 | 325 | true |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @param string $scope @see EEM_Payment_Method::get_all_for_events |
340 | 340 | * @return EE_Payment_Method[] |
341 | 341 | */ |
342 | - public function get_all_for_transaction( $transaction, $scope ) { |
|
342 | + public function get_all_for_transaction($transaction, $scope) { |
|
343 | 343 | //give addons a chance to override what payment methods are chosen based on the transaction |
344 | 344 | return apply_filters( |
345 | 345 | 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
346 | - $this->get_all_active( $scope, array( 'group_by' => 'PMD_type' ) ), |
|
346 | + $this->get_all_active($scope, array('group_by' => 'PMD_type')), |
|
347 | 347 | $transaction, |
348 | 348 | $scope |
349 | 349 | ); |
@@ -359,16 +359,16 @@ discard block |
||
359 | 359 | * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
360 | 360 | * @return EE_Payment|null |
361 | 361 | */ |
362 | - public function get_last_used_for_registration( $registration_or_reg_id ) { |
|
363 | - $registration_id = EEM_Registration::instance()->ensure_is_ID( $registration_or_reg_id ); |
|
362 | + public function get_last_used_for_registration($registration_or_reg_id) { |
|
363 | + $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
364 | 364 | |
365 | 365 | $query_params = array( |
366 | 366 | 0 => array( |
367 | 367 | 'Payment.Registration.REG_ID' => $registration_id, |
368 | 368 | ), |
369 | - 'order_by' => array( 'Payment.PAY_ID' => 'DESC' ) |
|
369 | + 'order_by' => array('Payment.PAY_ID' => 'DESC') |
|
370 | 370 | ); |
371 | - return $this->get_one( $query_params ); |
|
371 | + return $this->get_one($query_params); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -14,244 +14,244 @@ discard block |
||
14 | 14 | class EEH_Activation |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * constant used to indicate a cron task is no longer in use |
|
19 | - */ |
|
20 | - const cron_task_no_longer_in_use = 'no_longer_in_use'; |
|
21 | - |
|
22 | - /** |
|
23 | - * option name that will indicate whether or not we still |
|
24 | - * need to create EE's folders in the uploads directory |
|
25 | - * (because if EE was installed without file system access, |
|
26 | - * we need to request credentials before we can create them) |
|
27 | - */ |
|
28 | - const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete'; |
|
29 | - |
|
30 | - /** |
|
31 | - * WP_User->ID |
|
32 | - * |
|
33 | - * @var int |
|
34 | - */ |
|
35 | - private static $_default_creator_id; |
|
36 | - |
|
37 | - /** |
|
38 | - * indicates whether or not we've already verified core's default data during this request, |
|
39 | - * because after migrations are done, any addons activated while in maintenance mode |
|
40 | - * will want to setup their own default data, and they might hook into core's default data |
|
41 | - * and trigger core to setup its default data. In which case they might all ask for core to init its default data. |
|
42 | - * This prevents doing that for EVERY single addon. |
|
43 | - * |
|
44 | - * @var boolean |
|
45 | - */ |
|
46 | - protected static $_initialized_db_content_already_in_this_request = false; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
50 | - */ |
|
51 | - private static $table_analysis; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
55 | - */ |
|
56 | - private static $table_manager; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @return \EventEspresso\core\services\database\TableAnalysis |
|
61 | - */ |
|
62 | - public static function getTableAnalysis() |
|
63 | - { |
|
64 | - if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
65 | - self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
66 | - } |
|
67 | - return self::$table_analysis; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return \EventEspresso\core\services\database\TableManager |
|
73 | - */ |
|
74 | - public static function getTableManager() |
|
75 | - { |
|
76 | - if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
77 | - self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
78 | - } |
|
79 | - return self::$table_manager; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * _ensure_table_name_has_prefix |
|
85 | - * |
|
86 | - * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix() |
|
87 | - * @access public |
|
88 | - * @static |
|
89 | - * @param $table_name |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public static function ensure_table_name_has_prefix($table_name) |
|
93 | - { |
|
94 | - return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * system_initialization |
|
100 | - * ensures the EE configuration settings are loaded with at least default options set |
|
101 | - * and that all critical EE pages have been generated with the appropriate shortcodes in place |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @static |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public static function system_initialization() |
|
108 | - { |
|
109 | - EEH_Activation::reset_and_update_config(); |
|
110 | - //which is fired BEFORE activation of plugin anyways |
|
111 | - EEH_Activation::verify_default_pages_exist(); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Sets the database schema and creates folders. This should |
|
117 | - * be called on plugin activation and reactivation |
|
118 | - * |
|
119 | - * @return boolean success, whether the database and folders are setup properly |
|
120 | - * @throws \EE_Error |
|
121 | - */ |
|
122 | - public static function initialize_db_and_folders() |
|
123 | - { |
|
124 | - $good_filesystem = EEH_Activation::create_upload_directories(); |
|
125 | - $good_db = EEH_Activation::create_database_tables(); |
|
126 | - return $good_filesystem && $good_db; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * assuming we have an up-to-date database schema, this will populate it |
|
132 | - * with default and initial data. This should be called |
|
133 | - * upon activation of a new plugin, reactivation, and at the end |
|
134 | - * of running migration scripts |
|
135 | - * |
|
136 | - * @throws \EE_Error |
|
137 | - */ |
|
138 | - public static function initialize_db_content() |
|
139 | - { |
|
140 | - //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
|
141 | - if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
142 | - return; |
|
143 | - } |
|
144 | - EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
|
145 | - |
|
146 | - EEH_Activation::initialize_system_questions(); |
|
147 | - EEH_Activation::insert_default_status_codes(); |
|
148 | - EEH_Activation::generate_default_message_templates(); |
|
149 | - EEH_Activation::create_no_ticket_prices_array(); |
|
150 | - EE_Registry::instance()->CAP->init_caps(); |
|
151 | - |
|
152 | - EEH_Activation::validate_messages_system(); |
|
153 | - EEH_Activation::insert_default_payment_methods(); |
|
154 | - //in case we've |
|
155 | - EEH_Activation::remove_cron_tasks(); |
|
156 | - EEH_Activation::create_cron_tasks(); |
|
157 | - // remove all TXN locks since that is being done via extra meta now |
|
158 | - delete_option('ee_locked_transactions'); |
|
159 | - //also, check for CAF default db content |
|
160 | - do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
161 | - //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
|
162 | - //which users really won't care about on initial activation |
|
163 | - EE_Error::overwrite_success(); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"), |
|
169 | - * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event |
|
170 | - * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use |
|
171 | - * (null) |
|
172 | - * |
|
173 | - * @param string $which_to_include can be 'current' (ones that are currently in use), |
|
174 | - * 'old' (only returns ones that should no longer be used),or 'all', |
|
175 | - * @return array |
|
176 | - * @throws \EE_Error |
|
177 | - */ |
|
178 | - public static function get_cron_tasks($which_to_include) |
|
179 | - { |
|
180 | - $cron_tasks = apply_filters( |
|
181 | - 'FHEE__EEH_Activation__get_cron_tasks', |
|
182 | - array( |
|
183 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' => 'hourly', |
|
17 | + /** |
|
18 | + * constant used to indicate a cron task is no longer in use |
|
19 | + */ |
|
20 | + const cron_task_no_longer_in_use = 'no_longer_in_use'; |
|
21 | + |
|
22 | + /** |
|
23 | + * option name that will indicate whether or not we still |
|
24 | + * need to create EE's folders in the uploads directory |
|
25 | + * (because if EE was installed without file system access, |
|
26 | + * we need to request credentials before we can create them) |
|
27 | + */ |
|
28 | + const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete'; |
|
29 | + |
|
30 | + /** |
|
31 | + * WP_User->ID |
|
32 | + * |
|
33 | + * @var int |
|
34 | + */ |
|
35 | + private static $_default_creator_id; |
|
36 | + |
|
37 | + /** |
|
38 | + * indicates whether or not we've already verified core's default data during this request, |
|
39 | + * because after migrations are done, any addons activated while in maintenance mode |
|
40 | + * will want to setup their own default data, and they might hook into core's default data |
|
41 | + * and trigger core to setup its default data. In which case they might all ask for core to init its default data. |
|
42 | + * This prevents doing that for EVERY single addon. |
|
43 | + * |
|
44 | + * @var boolean |
|
45 | + */ |
|
46 | + protected static $_initialized_db_content_already_in_this_request = false; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
50 | + */ |
|
51 | + private static $table_analysis; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
55 | + */ |
|
56 | + private static $table_manager; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @return \EventEspresso\core\services\database\TableAnalysis |
|
61 | + */ |
|
62 | + public static function getTableAnalysis() |
|
63 | + { |
|
64 | + if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
65 | + self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
66 | + } |
|
67 | + return self::$table_analysis; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return \EventEspresso\core\services\database\TableManager |
|
73 | + */ |
|
74 | + public static function getTableManager() |
|
75 | + { |
|
76 | + if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
77 | + self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
78 | + } |
|
79 | + return self::$table_manager; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * _ensure_table_name_has_prefix |
|
85 | + * |
|
86 | + * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix() |
|
87 | + * @access public |
|
88 | + * @static |
|
89 | + * @param $table_name |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public static function ensure_table_name_has_prefix($table_name) |
|
93 | + { |
|
94 | + return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * system_initialization |
|
100 | + * ensures the EE configuration settings are loaded with at least default options set |
|
101 | + * and that all critical EE pages have been generated with the appropriate shortcodes in place |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @static |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public static function system_initialization() |
|
108 | + { |
|
109 | + EEH_Activation::reset_and_update_config(); |
|
110 | + //which is fired BEFORE activation of plugin anyways |
|
111 | + EEH_Activation::verify_default_pages_exist(); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Sets the database schema and creates folders. This should |
|
117 | + * be called on plugin activation and reactivation |
|
118 | + * |
|
119 | + * @return boolean success, whether the database and folders are setup properly |
|
120 | + * @throws \EE_Error |
|
121 | + */ |
|
122 | + public static function initialize_db_and_folders() |
|
123 | + { |
|
124 | + $good_filesystem = EEH_Activation::create_upload_directories(); |
|
125 | + $good_db = EEH_Activation::create_database_tables(); |
|
126 | + return $good_filesystem && $good_db; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * assuming we have an up-to-date database schema, this will populate it |
|
132 | + * with default and initial data. This should be called |
|
133 | + * upon activation of a new plugin, reactivation, and at the end |
|
134 | + * of running migration scripts |
|
135 | + * |
|
136 | + * @throws \EE_Error |
|
137 | + */ |
|
138 | + public static function initialize_db_content() |
|
139 | + { |
|
140 | + //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
|
141 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
142 | + return; |
|
143 | + } |
|
144 | + EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
|
145 | + |
|
146 | + EEH_Activation::initialize_system_questions(); |
|
147 | + EEH_Activation::insert_default_status_codes(); |
|
148 | + EEH_Activation::generate_default_message_templates(); |
|
149 | + EEH_Activation::create_no_ticket_prices_array(); |
|
150 | + EE_Registry::instance()->CAP->init_caps(); |
|
151 | + |
|
152 | + EEH_Activation::validate_messages_system(); |
|
153 | + EEH_Activation::insert_default_payment_methods(); |
|
154 | + //in case we've |
|
155 | + EEH_Activation::remove_cron_tasks(); |
|
156 | + EEH_Activation::create_cron_tasks(); |
|
157 | + // remove all TXN locks since that is being done via extra meta now |
|
158 | + delete_option('ee_locked_transactions'); |
|
159 | + //also, check for CAF default db content |
|
160 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
161 | + //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
|
162 | + //which users really won't care about on initial activation |
|
163 | + EE_Error::overwrite_success(); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"), |
|
169 | + * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event |
|
170 | + * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use |
|
171 | + * (null) |
|
172 | + * |
|
173 | + * @param string $which_to_include can be 'current' (ones that are currently in use), |
|
174 | + * 'old' (only returns ones that should no longer be used),or 'all', |
|
175 | + * @return array |
|
176 | + * @throws \EE_Error |
|
177 | + */ |
|
178 | + public static function get_cron_tasks($which_to_include) |
|
179 | + { |
|
180 | + $cron_tasks = apply_filters( |
|
181 | + 'FHEE__EEH_Activation__get_cron_tasks', |
|
182 | + array( |
|
183 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' => 'hourly', |
|
184 | 184 | // 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use |
185 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, |
|
186 | - //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
|
187 | - 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs' => 'daily', |
|
188 | - ) |
|
189 | - ); |
|
190 | - if ($which_to_include === 'old') { |
|
191 | - $cron_tasks = array_filter( |
|
192 | - $cron_tasks, |
|
193 | - function ($value) { |
|
194 | - return $value === EEH_Activation::cron_task_no_longer_in_use; |
|
195 | - } |
|
196 | - ); |
|
197 | - } elseif ($which_to_include === 'current') { |
|
198 | - $cron_tasks = array_filter($cron_tasks); |
|
199 | - } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
200 | - throw new EE_Error( |
|
201 | - sprintf( |
|
202 | - __( |
|
203 | - 'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', |
|
204 | - 'event_espresso' |
|
205 | - ), |
|
206 | - $which_to_include |
|
207 | - ) |
|
208 | - ); |
|
209 | - } |
|
210 | - return $cron_tasks; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Ensure cron tasks are setup (the removal of crons should be done by remove_crons()) |
|
216 | - * |
|
217 | - * @throws \EE_Error |
|
218 | - */ |
|
219 | - public static function create_cron_tasks() |
|
220 | - { |
|
221 | - |
|
222 | - foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
223 | - if (! wp_next_scheduled($hook_name)) { |
|
224 | - /** |
|
225 | - * This allows client code to define the initial start timestamp for this schedule. |
|
226 | - */ |
|
227 | - if (is_array($frequency) |
|
228 | - && count($frequency) === 2 |
|
229 | - && isset($frequency[0], $frequency[1]) |
|
230 | - ) { |
|
231 | - $start_timestamp = $frequency[0]; |
|
232 | - $frequency = $frequency[1]; |
|
233 | - } else { |
|
234 | - $start_timestamp = time(); |
|
235 | - } |
|
236 | - wp_schedule_event($start_timestamp, $frequency, $hook_name); |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * Remove the currently-existing and now-removed cron tasks. |
|
245 | - * |
|
246 | - * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
|
247 | - * @throws \EE_Error |
|
248 | - */ |
|
249 | - public static function remove_cron_tasks($remove_all = true) |
|
250 | - { |
|
251 | - $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
|
252 | - $crons = _get_cron_array(); |
|
253 | - $crons = is_array($crons) ? $crons : array(); |
|
254 | - /* reminder of what $crons look like: |
|
185 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, |
|
186 | + //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
|
187 | + 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs' => 'daily', |
|
188 | + ) |
|
189 | + ); |
|
190 | + if ($which_to_include === 'old') { |
|
191 | + $cron_tasks = array_filter( |
|
192 | + $cron_tasks, |
|
193 | + function ($value) { |
|
194 | + return $value === EEH_Activation::cron_task_no_longer_in_use; |
|
195 | + } |
|
196 | + ); |
|
197 | + } elseif ($which_to_include === 'current') { |
|
198 | + $cron_tasks = array_filter($cron_tasks); |
|
199 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
200 | + throw new EE_Error( |
|
201 | + sprintf( |
|
202 | + __( |
|
203 | + 'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', |
|
204 | + 'event_espresso' |
|
205 | + ), |
|
206 | + $which_to_include |
|
207 | + ) |
|
208 | + ); |
|
209 | + } |
|
210 | + return $cron_tasks; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Ensure cron tasks are setup (the removal of crons should be done by remove_crons()) |
|
216 | + * |
|
217 | + * @throws \EE_Error |
|
218 | + */ |
|
219 | + public static function create_cron_tasks() |
|
220 | + { |
|
221 | + |
|
222 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
223 | + if (! wp_next_scheduled($hook_name)) { |
|
224 | + /** |
|
225 | + * This allows client code to define the initial start timestamp for this schedule. |
|
226 | + */ |
|
227 | + if (is_array($frequency) |
|
228 | + && count($frequency) === 2 |
|
229 | + && isset($frequency[0], $frequency[1]) |
|
230 | + ) { |
|
231 | + $start_timestamp = $frequency[0]; |
|
232 | + $frequency = $frequency[1]; |
|
233 | + } else { |
|
234 | + $start_timestamp = time(); |
|
235 | + } |
|
236 | + wp_schedule_event($start_timestamp, $frequency, $hook_name); |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * Remove the currently-existing and now-removed cron tasks. |
|
245 | + * |
|
246 | + * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
|
247 | + * @throws \EE_Error |
|
248 | + */ |
|
249 | + public static function remove_cron_tasks($remove_all = true) |
|
250 | + { |
|
251 | + $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
|
252 | + $crons = _get_cron_array(); |
|
253 | + $crons = is_array($crons) ? $crons : array(); |
|
254 | + /* reminder of what $crons look like: |
|
255 | 255 | * Top-level keys are timestamps, and their values are arrays. |
256 | 256 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
257 | 257 | * and their values are arrays. |
@@ -268,912 +268,912 @@ discard block |
||
268 | 268 | * ... |
269 | 269 | * ... |
270 | 270 | */ |
271 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
272 | - foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
273 | - if (is_array($hooks_to_fire_at_time)) { |
|
274 | - foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
275 | - if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
276 | - && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
277 | - ) { |
|
278 | - unset($crons[$timestamp][$hook_name]); |
|
279 | - } |
|
280 | - } |
|
281 | - //also take care of any empty cron timestamps. |
|
282 | - if (empty($hooks_to_fire_at_time)) { |
|
283 | - unset($crons[$timestamp]); |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
287 | - _set_cron_array($crons); |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * CPT_initialization |
|
293 | - * registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist |
|
294 | - * |
|
295 | - * @access public |
|
296 | - * @static |
|
297 | - * @return void |
|
298 | - */ |
|
299 | - public static function CPT_initialization() |
|
300 | - { |
|
301 | - // register Custom Post Types |
|
302 | - EE_Registry::instance()->load_core('Register_CPTs'); |
|
303 | - flush_rewrite_rules(); |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * reset_and_update_config |
|
310 | - * The following code was moved over from EE_Config so that it will no longer run on every request. |
|
311 | - * If there is old calendar config data saved, then it will get converted on activation. |
|
312 | - * This was basically a DMS before we had DMS's, and will get removed after a few more versions. |
|
313 | - * |
|
314 | - * @access public |
|
315 | - * @static |
|
316 | - * @return void |
|
317 | - */ |
|
318 | - public static function reset_and_update_config() |
|
319 | - { |
|
320 | - do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
321 | - add_filter( |
|
322 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
323 | - array('EEH_Activation', 'migrate_old_config_data'), |
|
324 | - 10, |
|
325 | - 3 |
|
326 | - ); |
|
327 | - //EE_Config::reset(); |
|
328 | - if (! EE_Config::logging_enabled()) { |
|
329 | - delete_option(EE_Config::LOG_NAME); |
|
330 | - } |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * load_calendar_config |
|
336 | - * |
|
337 | - * @access public |
|
338 | - * @return void |
|
339 | - */ |
|
340 | - public static function load_calendar_config() |
|
341 | - { |
|
342 | - // grab array of all plugin folders and loop thru it |
|
343 | - $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR); |
|
344 | - if (empty($plugins)) { |
|
345 | - return; |
|
346 | - } |
|
347 | - foreach ($plugins as $plugin_path) { |
|
348 | - // grab plugin folder name from path |
|
349 | - $plugin = basename($plugin_path); |
|
350 | - // drill down to Espresso plugins |
|
351 | - // then to calendar related plugins |
|
352 | - if ( |
|
353 | - strpos($plugin, 'espresso') !== false |
|
354 | - || strpos($plugin, 'Espresso') !== false |
|
355 | - || strpos($plugin, 'ee4') !== false |
|
356 | - || strpos($plugin, 'EE4') !== false |
|
357 | - || strpos($plugin, 'calendar') !== false |
|
358 | - ) { |
|
359 | - // this is what we are looking for |
|
360 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
361 | - // does it exist in this folder ? |
|
362 | - if (is_readable($calendar_config)) { |
|
363 | - // YEAH! let's load it |
|
364 | - require_once($calendar_config); |
|
365 | - } |
|
366 | - } |
|
367 | - } |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * _migrate_old_config_data |
|
374 | - * |
|
375 | - * @access public |
|
376 | - * @param array|stdClass $settings |
|
377 | - * @param string $config |
|
378 | - * @param \EE_Config $EE_Config |
|
379 | - * @return \stdClass |
|
380 | - */ |
|
381 | - public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) |
|
382 | - { |
|
383 | - $convert_from_array = array('addons'); |
|
384 | - // in case old settings were saved as an array |
|
385 | - if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
386 | - // convert existing settings to an object |
|
387 | - $config_array = $settings; |
|
388 | - $settings = new stdClass(); |
|
389 | - foreach ($config_array as $key => $value) { |
|
390 | - if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
391 | - $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
392 | - } else { |
|
393 | - $settings->{$key} = $value; |
|
394 | - } |
|
395 | - } |
|
396 | - add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
397 | - } |
|
398 | - return $settings; |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * deactivate_event_espresso |
|
404 | - * |
|
405 | - * @access public |
|
406 | - * @static |
|
407 | - * @return void |
|
408 | - */ |
|
409 | - public static function deactivate_event_espresso() |
|
410 | - { |
|
411 | - // check permissions |
|
412 | - if (current_user_can('activate_plugins')) { |
|
413 | - deactivate_plugins(EE_PLUGIN_BASENAME, true); |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * verify_default_pages_exist |
|
423 | - * |
|
424 | - * @access public |
|
425 | - * @static |
|
426 | - * @return void |
|
427 | - */ |
|
428 | - public static function verify_default_pages_exist() |
|
429 | - { |
|
430 | - $critical_page_problem = false; |
|
431 | - $critical_pages = array( |
|
432 | - array( |
|
433 | - 'id' => 'reg_page_id', |
|
434 | - 'name' => __('Registration Checkout', 'event_espresso'), |
|
435 | - 'post' => null, |
|
436 | - 'code' => 'ESPRESSO_CHECKOUT', |
|
437 | - ), |
|
438 | - array( |
|
439 | - 'id' => 'txn_page_id', |
|
440 | - 'name' => __('Transactions', 'event_espresso'), |
|
441 | - 'post' => null, |
|
442 | - 'code' => 'ESPRESSO_TXN_PAGE', |
|
443 | - ), |
|
444 | - array( |
|
445 | - 'id' => 'thank_you_page_id', |
|
446 | - 'name' => __('Thank You', 'event_espresso'), |
|
447 | - 'post' => null, |
|
448 | - 'code' => 'ESPRESSO_THANK_YOU', |
|
449 | - ), |
|
450 | - array( |
|
451 | - 'id' => 'cancel_page_id', |
|
452 | - 'name' => __('Registration Cancelled', 'event_espresso'), |
|
453 | - 'post' => null, |
|
454 | - 'code' => 'ESPRESSO_CANCELLED', |
|
455 | - ), |
|
456 | - ); |
|
457 | - $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
458 | - foreach ($critical_pages as $critical_page) { |
|
459 | - // is critical page ID set in config ? |
|
460 | - if ($EE_Core_Config->{$critical_page['id']} !== false) { |
|
461 | - // attempt to find post by ID |
|
462 | - $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']}); |
|
463 | - } |
|
464 | - // no dice? |
|
465 | - if ($critical_page['post'] === null) { |
|
466 | - // attempt to find post by title |
|
467 | - $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
468 | - // still nothing? |
|
469 | - if ($critical_page['post'] === null) { |
|
470 | - $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
471 | - // REALLY? Still nothing ??!?!? |
|
472 | - if ($critical_page['post'] === null) { |
|
473 | - $msg = __( |
|
474 | - 'The Event Espresso critical page configuration settings could not be updated.', |
|
475 | - 'event_espresso' |
|
476 | - ); |
|
477 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
478 | - break; |
|
479 | - } |
|
480 | - } |
|
481 | - } |
|
482 | - // check that Post ID matches critical page ID in config |
|
483 | - if ( |
|
484 | - isset($critical_page['post']->ID) |
|
485 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
486 | - ) { |
|
487 | - //update Config with post ID |
|
488 | - $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
489 | - if (! EE_Config::instance()->update_espresso_config(false, false)) { |
|
490 | - $msg = __( |
|
491 | - 'The Event Espresso critical page configuration settings could not be updated.', |
|
492 | - 'event_espresso' |
|
493 | - ); |
|
494 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
495 | - } |
|
496 | - } |
|
497 | - $critical_page_problem = |
|
498 | - ! isset($critical_page['post']->post_status) |
|
499 | - || $critical_page['post']->post_status !== 'publish' |
|
500 | - || strpos($critical_page['post']->post_content, $critical_page['code']) === false |
|
501 | - ? true |
|
502 | - : $critical_page_problem; |
|
503 | - } |
|
504 | - if ($critical_page_problem) { |
|
505 | - $msg = sprintf( |
|
506 | - __( |
|
507 | - 'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', |
|
508 | - 'event_espresso' |
|
509 | - ), |
|
510 | - '<a href="' |
|
511 | - . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') |
|
512 | - . '">' |
|
513 | - . __('Event Espresso Critical Pages Settings', 'event_espresso') |
|
514 | - . '</a>' |
|
515 | - ); |
|
516 | - EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
517 | - } |
|
518 | - if (EE_Error::has_notices()) { |
|
519 | - EE_Error::get_notices(false, true, true); |
|
520 | - } |
|
521 | - } |
|
522 | - |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * Returns the first post which uses the specified shortcode |
|
527 | - * |
|
528 | - * @param string $ee_shortcode usually one of the critical pages shortcodes, eg |
|
529 | - * ESPRESSO_THANK_YOU. So we will search fora post with the content |
|
530 | - * "[ESPRESSO_THANK_YOU" |
|
531 | - * (we don't search for the closing shortcode bracket because they might have added |
|
532 | - * parameter to the shortcode |
|
533 | - * @return WP_Post or NULl |
|
534 | - */ |
|
535 | - public static function get_page_by_ee_shortcode($ee_shortcode) |
|
536 | - { |
|
537 | - global $wpdb; |
|
538 | - $shortcode_and_opening_bracket = '[' . $ee_shortcode; |
|
539 | - $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
|
540 | - if ($post_id) { |
|
541 | - return get_post($post_id); |
|
542 | - } else { |
|
543 | - return null; |
|
544 | - } |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * This function generates a post for critical espresso pages |
|
550 | - * |
|
551 | - * @access public |
|
552 | - * @static |
|
553 | - * @param array $critical_page |
|
554 | - * @return array |
|
555 | - */ |
|
556 | - public static function create_critical_page($critical_page) |
|
557 | - { |
|
558 | - |
|
559 | - $post_args = array( |
|
560 | - 'post_title' => $critical_page['name'], |
|
561 | - 'post_status' => 'publish', |
|
562 | - 'post_type' => 'page', |
|
563 | - 'comment_status' => 'closed', |
|
564 | - 'post_content' => '[' . $critical_page['code'] . ']', |
|
565 | - ); |
|
566 | - |
|
567 | - $post_id = wp_insert_post($post_args); |
|
568 | - if (! $post_id) { |
|
569 | - $msg = sprintf( |
|
570 | - __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
571 | - $critical_page['name'] |
|
572 | - ); |
|
573 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
574 | - return $critical_page; |
|
575 | - } |
|
576 | - // get newly created post's details |
|
577 | - if (! $critical_page['post'] = get_post($post_id)) { |
|
578 | - $msg = sprintf( |
|
579 | - __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
580 | - $critical_page['name'] |
|
581 | - ); |
|
582 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
583 | - } |
|
584 | - |
|
585 | - return $critical_page; |
|
586 | - |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * Tries to find the oldest admin for this site. If there are no admins for this site then return NULL. |
|
594 | - * The role being used to check is filterable. |
|
595 | - * |
|
596 | - * @since 4.6.0 |
|
597 | - * @global WPDB $wpdb |
|
598 | - * @return mixed null|int WP_user ID or NULL |
|
599 | - */ |
|
600 | - public static function get_default_creator_id() |
|
601 | - { |
|
602 | - global $wpdb; |
|
603 | - if ( ! empty(self::$_default_creator_id)) { |
|
604 | - return self::$_default_creator_id; |
|
605 | - }/**/ |
|
606 | - $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
607 | - //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
|
608 | - $pre_filtered_id = apply_filters( |
|
609 | - 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', |
|
610 | - false, |
|
611 | - $role_to_check |
|
612 | - ); |
|
613 | - if ($pre_filtered_id !== false) { |
|
614 | - return (int)$pre_filtered_id; |
|
615 | - } |
|
616 | - $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
617 | - $query = $wpdb->prepare( |
|
618 | - "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", |
|
619 | - '%' . $role_to_check . '%' |
|
620 | - ); |
|
621 | - $user_id = $wpdb->get_var($query); |
|
622 | - $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
623 | - if ($user_id && (int)$user_id) { |
|
624 | - self::$_default_creator_id = (int)$user_id; |
|
625 | - return self::$_default_creator_id; |
|
626 | - } else { |
|
627 | - return null; |
|
628 | - } |
|
629 | - } |
|
630 | - |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * used by EE and EE addons during plugin activation to create tables. |
|
635 | - * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable, |
|
636 | - * but includes extra logic regarding activations. |
|
637 | - * |
|
638 | - * @access public |
|
639 | - * @static |
|
640 | - * @param string $table_name without the $wpdb->prefix |
|
641 | - * @param string $sql SQL for creating the table (contents between brackets in an SQL create |
|
642 | - * table query) |
|
643 | - * @param string $engine like 'ENGINE=MyISAM' or 'ENGINE=InnoDB' |
|
644 | - * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty |
|
645 | - * and new once this function is done (ie, you really do want to CREATE a |
|
646 | - * table, and expect it to be empty once you're done) leave as FALSE when |
|
647 | - * you just want to verify the table exists and matches this definition |
|
648 | - * (and if it HAS data in it you want to leave it be) |
|
649 | - * @return void |
|
650 | - * @throws EE_Error if there are database errors |
|
651 | - */ |
|
652 | - public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) |
|
653 | - { |
|
654 | - if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) { |
|
655 | - return; |
|
656 | - } |
|
657 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
658 | - if ( ! function_exists('dbDelta')) { |
|
659 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
660 | - } |
|
661 | - $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
|
662 | - $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
663 | - // do we need to first delete an existing version of this table ? |
|
664 | - if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
665 | - // ok, delete the table... but ONLY if it's empty |
|
666 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
667 | - // table is NOT empty, are you SURE you want to delete this table ??? |
|
668 | - if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
669 | - \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
670 | - } else if ( ! $deleted_safely) { |
|
671 | - // so we should be more cautious rather than just dropping tables so easily |
|
672 | - error_log( |
|
673 | - sprintf( |
|
674 | - __( |
|
675 | - 'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.', |
|
676 | - 'event_espresso' |
|
677 | - ), |
|
678 | - $wp_table_name, |
|
679 | - '<br/>', |
|
680 | - 'espresso_db_update' |
|
681 | - ) |
|
682 | - ); |
|
683 | - } |
|
684 | - } |
|
685 | - $engine = str_replace('ENGINE=', '', $engine); |
|
686 | - \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
687 | - } |
|
688 | - |
|
689 | - |
|
690 | - |
|
691 | - /** |
|
692 | - * add_column_if_it_doesn't_exist |
|
693 | - * Checks if this column already exists on the specified table. Handy for addons which want to add a column |
|
694 | - * |
|
695 | - * @access public |
|
696 | - * @static |
|
697 | - * @deprecated instead use TableManager::addColumn() |
|
698 | - * @param string $table_name (without "wp_", eg "esp_attendee" |
|
699 | - * @param string $column_name |
|
700 | - * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be |
|
701 | - * 'VARCHAR(10)' |
|
702 | - * @return bool|int |
|
703 | - */ |
|
704 | - public static function add_column_if_it_doesnt_exist( |
|
705 | - $table_name, |
|
706 | - $column_name, |
|
707 | - $column_info = 'INT UNSIGNED NOT NULL' |
|
708 | - ) { |
|
709 | - return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
710 | - } |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * get_fields_on_table |
|
715 | - * Gets all the fields on the database table. |
|
716 | - * |
|
717 | - * @access public |
|
718 | - * @deprecated instead use TableManager::getTableColumns() |
|
719 | - * @static |
|
720 | - * @param string $table_name , without prefixed $wpdb->prefix |
|
721 | - * @return array of database column names |
|
722 | - */ |
|
723 | - public static function get_fields_on_table($table_name = null) |
|
724 | - { |
|
725 | - return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
726 | - } |
|
727 | - |
|
728 | - |
|
729 | - /** |
|
730 | - * db_table_is_empty |
|
731 | - * |
|
732 | - * @access public\ |
|
733 | - * @deprecated instead use TableAnalysis::tableIsEmpty() |
|
734 | - * @static |
|
735 | - * @param string $table_name |
|
736 | - * @return bool |
|
737 | - */ |
|
738 | - public static function db_table_is_empty($table_name) |
|
739 | - { |
|
740 | - return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
741 | - } |
|
742 | - |
|
743 | - |
|
744 | - /** |
|
745 | - * delete_db_table_if_empty |
|
746 | - * |
|
747 | - * @access public |
|
748 | - * @static |
|
749 | - * @param string $table_name |
|
750 | - * @return bool | int |
|
751 | - */ |
|
752 | - public static function delete_db_table_if_empty($table_name) |
|
753 | - { |
|
754 | - if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
755 | - return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
756 | - } |
|
757 | - return false; |
|
758 | - } |
|
759 | - |
|
760 | - |
|
761 | - /** |
|
762 | - * delete_unused_db_table |
|
763 | - * |
|
764 | - * @access public |
|
765 | - * @static |
|
766 | - * @deprecated instead use TableManager::dropTable() |
|
767 | - * @param string $table_name |
|
768 | - * @return bool | int |
|
769 | - */ |
|
770 | - public static function delete_unused_db_table($table_name) |
|
771 | - { |
|
772 | - return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
773 | - } |
|
774 | - |
|
775 | - |
|
776 | - /** |
|
777 | - * drop_index |
|
778 | - * |
|
779 | - * @access public |
|
780 | - * @static |
|
781 | - * @deprecated instead use TableManager::dropIndex() |
|
782 | - * @param string $table_name |
|
783 | - * @param string $index_name |
|
784 | - * @return bool | int |
|
785 | - */ |
|
786 | - public static function drop_index($table_name, $index_name) |
|
787 | - { |
|
788 | - return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
789 | - } |
|
790 | - |
|
791 | - |
|
792 | - |
|
793 | - /** |
|
794 | - * create_database_tables |
|
795 | - * |
|
796 | - * @access public |
|
797 | - * @static |
|
798 | - * @throws EE_Error |
|
799 | - * @return boolean success (whether database is setup properly or not) |
|
800 | - */ |
|
801 | - public static function create_database_tables() |
|
802 | - { |
|
803 | - EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
804 | - //find the migration script that sets the database to be compatible with the code |
|
805 | - $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
|
806 | - if ($dms_name) { |
|
807 | - $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
808 | - $current_data_migration_script->set_migrating(false); |
|
809 | - $current_data_migration_script->schema_changes_before_migration(); |
|
810 | - $current_data_migration_script->schema_changes_after_migration(); |
|
811 | - if ($current_data_migration_script->get_errors()) { |
|
812 | - if (WP_DEBUG) { |
|
813 | - foreach ($current_data_migration_script->get_errors() as $error) { |
|
814 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
815 | - } |
|
816 | - } else { |
|
817 | - EE_Error::add_error( |
|
818 | - __( |
|
819 | - 'There were errors creating the Event Espresso database tables and Event Espresso has been |
|
271 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
272 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
273 | + if (is_array($hooks_to_fire_at_time)) { |
|
274 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
275 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
276 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
277 | + ) { |
|
278 | + unset($crons[$timestamp][$hook_name]); |
|
279 | + } |
|
280 | + } |
|
281 | + //also take care of any empty cron timestamps. |
|
282 | + if (empty($hooks_to_fire_at_time)) { |
|
283 | + unset($crons[$timestamp]); |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | + _set_cron_array($crons); |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * CPT_initialization |
|
293 | + * registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist |
|
294 | + * |
|
295 | + * @access public |
|
296 | + * @static |
|
297 | + * @return void |
|
298 | + */ |
|
299 | + public static function CPT_initialization() |
|
300 | + { |
|
301 | + // register Custom Post Types |
|
302 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
303 | + flush_rewrite_rules(); |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * reset_and_update_config |
|
310 | + * The following code was moved over from EE_Config so that it will no longer run on every request. |
|
311 | + * If there is old calendar config data saved, then it will get converted on activation. |
|
312 | + * This was basically a DMS before we had DMS's, and will get removed after a few more versions. |
|
313 | + * |
|
314 | + * @access public |
|
315 | + * @static |
|
316 | + * @return void |
|
317 | + */ |
|
318 | + public static function reset_and_update_config() |
|
319 | + { |
|
320 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
321 | + add_filter( |
|
322 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
323 | + array('EEH_Activation', 'migrate_old_config_data'), |
|
324 | + 10, |
|
325 | + 3 |
|
326 | + ); |
|
327 | + //EE_Config::reset(); |
|
328 | + if (! EE_Config::logging_enabled()) { |
|
329 | + delete_option(EE_Config::LOG_NAME); |
|
330 | + } |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * load_calendar_config |
|
336 | + * |
|
337 | + * @access public |
|
338 | + * @return void |
|
339 | + */ |
|
340 | + public static function load_calendar_config() |
|
341 | + { |
|
342 | + // grab array of all plugin folders and loop thru it |
|
343 | + $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR); |
|
344 | + if (empty($plugins)) { |
|
345 | + return; |
|
346 | + } |
|
347 | + foreach ($plugins as $plugin_path) { |
|
348 | + // grab plugin folder name from path |
|
349 | + $plugin = basename($plugin_path); |
|
350 | + // drill down to Espresso plugins |
|
351 | + // then to calendar related plugins |
|
352 | + if ( |
|
353 | + strpos($plugin, 'espresso') !== false |
|
354 | + || strpos($plugin, 'Espresso') !== false |
|
355 | + || strpos($plugin, 'ee4') !== false |
|
356 | + || strpos($plugin, 'EE4') !== false |
|
357 | + || strpos($plugin, 'calendar') !== false |
|
358 | + ) { |
|
359 | + // this is what we are looking for |
|
360 | + $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
361 | + // does it exist in this folder ? |
|
362 | + if (is_readable($calendar_config)) { |
|
363 | + // YEAH! let's load it |
|
364 | + require_once($calendar_config); |
|
365 | + } |
|
366 | + } |
|
367 | + } |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * _migrate_old_config_data |
|
374 | + * |
|
375 | + * @access public |
|
376 | + * @param array|stdClass $settings |
|
377 | + * @param string $config |
|
378 | + * @param \EE_Config $EE_Config |
|
379 | + * @return \stdClass |
|
380 | + */ |
|
381 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) |
|
382 | + { |
|
383 | + $convert_from_array = array('addons'); |
|
384 | + // in case old settings were saved as an array |
|
385 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
386 | + // convert existing settings to an object |
|
387 | + $config_array = $settings; |
|
388 | + $settings = new stdClass(); |
|
389 | + foreach ($config_array as $key => $value) { |
|
390 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
391 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
392 | + } else { |
|
393 | + $settings->{$key} = $value; |
|
394 | + } |
|
395 | + } |
|
396 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
397 | + } |
|
398 | + return $settings; |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * deactivate_event_espresso |
|
404 | + * |
|
405 | + * @access public |
|
406 | + * @static |
|
407 | + * @return void |
|
408 | + */ |
|
409 | + public static function deactivate_event_espresso() |
|
410 | + { |
|
411 | + // check permissions |
|
412 | + if (current_user_can('activate_plugins')) { |
|
413 | + deactivate_plugins(EE_PLUGIN_BASENAME, true); |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + |
|
418 | + |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * verify_default_pages_exist |
|
423 | + * |
|
424 | + * @access public |
|
425 | + * @static |
|
426 | + * @return void |
|
427 | + */ |
|
428 | + public static function verify_default_pages_exist() |
|
429 | + { |
|
430 | + $critical_page_problem = false; |
|
431 | + $critical_pages = array( |
|
432 | + array( |
|
433 | + 'id' => 'reg_page_id', |
|
434 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
435 | + 'post' => null, |
|
436 | + 'code' => 'ESPRESSO_CHECKOUT', |
|
437 | + ), |
|
438 | + array( |
|
439 | + 'id' => 'txn_page_id', |
|
440 | + 'name' => __('Transactions', 'event_espresso'), |
|
441 | + 'post' => null, |
|
442 | + 'code' => 'ESPRESSO_TXN_PAGE', |
|
443 | + ), |
|
444 | + array( |
|
445 | + 'id' => 'thank_you_page_id', |
|
446 | + 'name' => __('Thank You', 'event_espresso'), |
|
447 | + 'post' => null, |
|
448 | + 'code' => 'ESPRESSO_THANK_YOU', |
|
449 | + ), |
|
450 | + array( |
|
451 | + 'id' => 'cancel_page_id', |
|
452 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
453 | + 'post' => null, |
|
454 | + 'code' => 'ESPRESSO_CANCELLED', |
|
455 | + ), |
|
456 | + ); |
|
457 | + $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
458 | + foreach ($critical_pages as $critical_page) { |
|
459 | + // is critical page ID set in config ? |
|
460 | + if ($EE_Core_Config->{$critical_page['id']} !== false) { |
|
461 | + // attempt to find post by ID |
|
462 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']}); |
|
463 | + } |
|
464 | + // no dice? |
|
465 | + if ($critical_page['post'] === null) { |
|
466 | + // attempt to find post by title |
|
467 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
468 | + // still nothing? |
|
469 | + if ($critical_page['post'] === null) { |
|
470 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
471 | + // REALLY? Still nothing ??!?!? |
|
472 | + if ($critical_page['post'] === null) { |
|
473 | + $msg = __( |
|
474 | + 'The Event Espresso critical page configuration settings could not be updated.', |
|
475 | + 'event_espresso' |
|
476 | + ); |
|
477 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
478 | + break; |
|
479 | + } |
|
480 | + } |
|
481 | + } |
|
482 | + // check that Post ID matches critical page ID in config |
|
483 | + if ( |
|
484 | + isset($critical_page['post']->ID) |
|
485 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
486 | + ) { |
|
487 | + //update Config with post ID |
|
488 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
489 | + if (! EE_Config::instance()->update_espresso_config(false, false)) { |
|
490 | + $msg = __( |
|
491 | + 'The Event Espresso critical page configuration settings could not be updated.', |
|
492 | + 'event_espresso' |
|
493 | + ); |
|
494 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
495 | + } |
|
496 | + } |
|
497 | + $critical_page_problem = |
|
498 | + ! isset($critical_page['post']->post_status) |
|
499 | + || $critical_page['post']->post_status !== 'publish' |
|
500 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === false |
|
501 | + ? true |
|
502 | + : $critical_page_problem; |
|
503 | + } |
|
504 | + if ($critical_page_problem) { |
|
505 | + $msg = sprintf( |
|
506 | + __( |
|
507 | + 'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', |
|
508 | + 'event_espresso' |
|
509 | + ), |
|
510 | + '<a href="' |
|
511 | + . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') |
|
512 | + . '">' |
|
513 | + . __('Event Espresso Critical Pages Settings', 'event_espresso') |
|
514 | + . '</a>' |
|
515 | + ); |
|
516 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
517 | + } |
|
518 | + if (EE_Error::has_notices()) { |
|
519 | + EE_Error::get_notices(false, true, true); |
|
520 | + } |
|
521 | + } |
|
522 | + |
|
523 | + |
|
524 | + |
|
525 | + /** |
|
526 | + * Returns the first post which uses the specified shortcode |
|
527 | + * |
|
528 | + * @param string $ee_shortcode usually one of the critical pages shortcodes, eg |
|
529 | + * ESPRESSO_THANK_YOU. So we will search fora post with the content |
|
530 | + * "[ESPRESSO_THANK_YOU" |
|
531 | + * (we don't search for the closing shortcode bracket because they might have added |
|
532 | + * parameter to the shortcode |
|
533 | + * @return WP_Post or NULl |
|
534 | + */ |
|
535 | + public static function get_page_by_ee_shortcode($ee_shortcode) |
|
536 | + { |
|
537 | + global $wpdb; |
|
538 | + $shortcode_and_opening_bracket = '[' . $ee_shortcode; |
|
539 | + $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
|
540 | + if ($post_id) { |
|
541 | + return get_post($post_id); |
|
542 | + } else { |
|
543 | + return null; |
|
544 | + } |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * This function generates a post for critical espresso pages |
|
550 | + * |
|
551 | + * @access public |
|
552 | + * @static |
|
553 | + * @param array $critical_page |
|
554 | + * @return array |
|
555 | + */ |
|
556 | + public static function create_critical_page($critical_page) |
|
557 | + { |
|
558 | + |
|
559 | + $post_args = array( |
|
560 | + 'post_title' => $critical_page['name'], |
|
561 | + 'post_status' => 'publish', |
|
562 | + 'post_type' => 'page', |
|
563 | + 'comment_status' => 'closed', |
|
564 | + 'post_content' => '[' . $critical_page['code'] . ']', |
|
565 | + ); |
|
566 | + |
|
567 | + $post_id = wp_insert_post($post_args); |
|
568 | + if (! $post_id) { |
|
569 | + $msg = sprintf( |
|
570 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
571 | + $critical_page['name'] |
|
572 | + ); |
|
573 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
574 | + return $critical_page; |
|
575 | + } |
|
576 | + // get newly created post's details |
|
577 | + if (! $critical_page['post'] = get_post($post_id)) { |
|
578 | + $msg = sprintf( |
|
579 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
580 | + $critical_page['name'] |
|
581 | + ); |
|
582 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
583 | + } |
|
584 | + |
|
585 | + return $critical_page; |
|
586 | + |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * Tries to find the oldest admin for this site. If there are no admins for this site then return NULL. |
|
594 | + * The role being used to check is filterable. |
|
595 | + * |
|
596 | + * @since 4.6.0 |
|
597 | + * @global WPDB $wpdb |
|
598 | + * @return mixed null|int WP_user ID or NULL |
|
599 | + */ |
|
600 | + public static function get_default_creator_id() |
|
601 | + { |
|
602 | + global $wpdb; |
|
603 | + if ( ! empty(self::$_default_creator_id)) { |
|
604 | + return self::$_default_creator_id; |
|
605 | + }/**/ |
|
606 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
607 | + //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
|
608 | + $pre_filtered_id = apply_filters( |
|
609 | + 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', |
|
610 | + false, |
|
611 | + $role_to_check |
|
612 | + ); |
|
613 | + if ($pre_filtered_id !== false) { |
|
614 | + return (int)$pre_filtered_id; |
|
615 | + } |
|
616 | + $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
617 | + $query = $wpdb->prepare( |
|
618 | + "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", |
|
619 | + '%' . $role_to_check . '%' |
|
620 | + ); |
|
621 | + $user_id = $wpdb->get_var($query); |
|
622 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
623 | + if ($user_id && (int)$user_id) { |
|
624 | + self::$_default_creator_id = (int)$user_id; |
|
625 | + return self::$_default_creator_id; |
|
626 | + } else { |
|
627 | + return null; |
|
628 | + } |
|
629 | + } |
|
630 | + |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * used by EE and EE addons during plugin activation to create tables. |
|
635 | + * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable, |
|
636 | + * but includes extra logic regarding activations. |
|
637 | + * |
|
638 | + * @access public |
|
639 | + * @static |
|
640 | + * @param string $table_name without the $wpdb->prefix |
|
641 | + * @param string $sql SQL for creating the table (contents between brackets in an SQL create |
|
642 | + * table query) |
|
643 | + * @param string $engine like 'ENGINE=MyISAM' or 'ENGINE=InnoDB' |
|
644 | + * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty |
|
645 | + * and new once this function is done (ie, you really do want to CREATE a |
|
646 | + * table, and expect it to be empty once you're done) leave as FALSE when |
|
647 | + * you just want to verify the table exists and matches this definition |
|
648 | + * (and if it HAS data in it you want to leave it be) |
|
649 | + * @return void |
|
650 | + * @throws EE_Error if there are database errors |
|
651 | + */ |
|
652 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) |
|
653 | + { |
|
654 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) { |
|
655 | + return; |
|
656 | + } |
|
657 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
658 | + if ( ! function_exists('dbDelta')) { |
|
659 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
660 | + } |
|
661 | + $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
|
662 | + $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
663 | + // do we need to first delete an existing version of this table ? |
|
664 | + if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
665 | + // ok, delete the table... but ONLY if it's empty |
|
666 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
667 | + // table is NOT empty, are you SURE you want to delete this table ??? |
|
668 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
669 | + \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
670 | + } else if ( ! $deleted_safely) { |
|
671 | + // so we should be more cautious rather than just dropping tables so easily |
|
672 | + error_log( |
|
673 | + sprintf( |
|
674 | + __( |
|
675 | + 'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.', |
|
676 | + 'event_espresso' |
|
677 | + ), |
|
678 | + $wp_table_name, |
|
679 | + '<br/>', |
|
680 | + 'espresso_db_update' |
|
681 | + ) |
|
682 | + ); |
|
683 | + } |
|
684 | + } |
|
685 | + $engine = str_replace('ENGINE=', '', $engine); |
|
686 | + \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
687 | + } |
|
688 | + |
|
689 | + |
|
690 | + |
|
691 | + /** |
|
692 | + * add_column_if_it_doesn't_exist |
|
693 | + * Checks if this column already exists on the specified table. Handy for addons which want to add a column |
|
694 | + * |
|
695 | + * @access public |
|
696 | + * @static |
|
697 | + * @deprecated instead use TableManager::addColumn() |
|
698 | + * @param string $table_name (without "wp_", eg "esp_attendee" |
|
699 | + * @param string $column_name |
|
700 | + * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be |
|
701 | + * 'VARCHAR(10)' |
|
702 | + * @return bool|int |
|
703 | + */ |
|
704 | + public static function add_column_if_it_doesnt_exist( |
|
705 | + $table_name, |
|
706 | + $column_name, |
|
707 | + $column_info = 'INT UNSIGNED NOT NULL' |
|
708 | + ) { |
|
709 | + return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
710 | + } |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * get_fields_on_table |
|
715 | + * Gets all the fields on the database table. |
|
716 | + * |
|
717 | + * @access public |
|
718 | + * @deprecated instead use TableManager::getTableColumns() |
|
719 | + * @static |
|
720 | + * @param string $table_name , without prefixed $wpdb->prefix |
|
721 | + * @return array of database column names |
|
722 | + */ |
|
723 | + public static function get_fields_on_table($table_name = null) |
|
724 | + { |
|
725 | + return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
726 | + } |
|
727 | + |
|
728 | + |
|
729 | + /** |
|
730 | + * db_table_is_empty |
|
731 | + * |
|
732 | + * @access public\ |
|
733 | + * @deprecated instead use TableAnalysis::tableIsEmpty() |
|
734 | + * @static |
|
735 | + * @param string $table_name |
|
736 | + * @return bool |
|
737 | + */ |
|
738 | + public static function db_table_is_empty($table_name) |
|
739 | + { |
|
740 | + return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
741 | + } |
|
742 | + |
|
743 | + |
|
744 | + /** |
|
745 | + * delete_db_table_if_empty |
|
746 | + * |
|
747 | + * @access public |
|
748 | + * @static |
|
749 | + * @param string $table_name |
|
750 | + * @return bool | int |
|
751 | + */ |
|
752 | + public static function delete_db_table_if_empty($table_name) |
|
753 | + { |
|
754 | + if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
755 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
756 | + } |
|
757 | + return false; |
|
758 | + } |
|
759 | + |
|
760 | + |
|
761 | + /** |
|
762 | + * delete_unused_db_table |
|
763 | + * |
|
764 | + * @access public |
|
765 | + * @static |
|
766 | + * @deprecated instead use TableManager::dropTable() |
|
767 | + * @param string $table_name |
|
768 | + * @return bool | int |
|
769 | + */ |
|
770 | + public static function delete_unused_db_table($table_name) |
|
771 | + { |
|
772 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
773 | + } |
|
774 | + |
|
775 | + |
|
776 | + /** |
|
777 | + * drop_index |
|
778 | + * |
|
779 | + * @access public |
|
780 | + * @static |
|
781 | + * @deprecated instead use TableManager::dropIndex() |
|
782 | + * @param string $table_name |
|
783 | + * @param string $index_name |
|
784 | + * @return bool | int |
|
785 | + */ |
|
786 | + public static function drop_index($table_name, $index_name) |
|
787 | + { |
|
788 | + return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
789 | + } |
|
790 | + |
|
791 | + |
|
792 | + |
|
793 | + /** |
|
794 | + * create_database_tables |
|
795 | + * |
|
796 | + * @access public |
|
797 | + * @static |
|
798 | + * @throws EE_Error |
|
799 | + * @return boolean success (whether database is setup properly or not) |
|
800 | + */ |
|
801 | + public static function create_database_tables() |
|
802 | + { |
|
803 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
804 | + //find the migration script that sets the database to be compatible with the code |
|
805 | + $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
|
806 | + if ($dms_name) { |
|
807 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
808 | + $current_data_migration_script->set_migrating(false); |
|
809 | + $current_data_migration_script->schema_changes_before_migration(); |
|
810 | + $current_data_migration_script->schema_changes_after_migration(); |
|
811 | + if ($current_data_migration_script->get_errors()) { |
|
812 | + if (WP_DEBUG) { |
|
813 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
814 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
815 | + } |
|
816 | + } else { |
|
817 | + EE_Error::add_error( |
|
818 | + __( |
|
819 | + 'There were errors creating the Event Espresso database tables and Event Espresso has been |
|
820 | 820 | deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', |
821 | - 'event_espresso' |
|
822 | - ) |
|
823 | - ); |
|
824 | - } |
|
825 | - return false; |
|
826 | - } |
|
827 | - EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
|
828 | - } else { |
|
829 | - EE_Error::add_error( |
|
830 | - __( |
|
831 | - 'Could not determine most up-to-date data migration script from which to pull database schema |
|
821 | + 'event_espresso' |
|
822 | + ) |
|
823 | + ); |
|
824 | + } |
|
825 | + return false; |
|
826 | + } |
|
827 | + EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
|
828 | + } else { |
|
829 | + EE_Error::add_error( |
|
830 | + __( |
|
831 | + 'Could not determine most up-to-date data migration script from which to pull database schema |
|
832 | 832 | structure. So database is probably not setup properly', |
833 | - 'event_espresso' |
|
834 | - ), |
|
835 | - __FILE__, |
|
836 | - __FUNCTION__, |
|
837 | - __LINE__ |
|
838 | - ); |
|
839 | - return false; |
|
840 | - } |
|
841 | - return true; |
|
842 | - } |
|
843 | - |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * initialize_system_questions |
|
848 | - * |
|
849 | - * @access public |
|
850 | - * @static |
|
851 | - * @return void |
|
852 | - */ |
|
853 | - public static function initialize_system_questions() |
|
854 | - { |
|
855 | - // QUESTION GROUPS |
|
856 | - global $wpdb; |
|
857 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
858 | - $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
|
859 | - // what we have |
|
860 | - $question_groups = $wpdb->get_col($SQL); |
|
861 | - // check the response |
|
862 | - $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
863 | - // what we should have |
|
864 | - $QSG_systems = array(1, 2); |
|
865 | - // loop thru what we should have and compare to what we have |
|
866 | - foreach ($QSG_systems as $QSG_system) { |
|
867 | - // reset values array |
|
868 | - $QSG_values = array(); |
|
869 | - // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
|
870 | - if (! in_array("$QSG_system", $question_groups)) { |
|
871 | - // add it |
|
872 | - switch ($QSG_system) { |
|
873 | - case 1: |
|
874 | - $QSG_values = array( |
|
875 | - 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
876 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
877 | - 'QSG_desc' => '', |
|
878 | - 'QSG_order' => 1, |
|
879 | - 'QSG_show_group_name' => 1, |
|
880 | - 'QSG_show_group_desc' => 1, |
|
881 | - 'QSG_system' => EEM_Question_Group::system_personal, |
|
882 | - 'QSG_deleted' => 0, |
|
883 | - ); |
|
884 | - break; |
|
885 | - case 2: |
|
886 | - $QSG_values = array( |
|
887 | - 'QSG_name' => __('Address Information', 'event_espresso'), |
|
888 | - 'QSG_identifier' => 'address-information-' . time(), |
|
889 | - 'QSG_desc' => '', |
|
890 | - 'QSG_order' => 2, |
|
891 | - 'QSG_show_group_name' => 1, |
|
892 | - 'QSG_show_group_desc' => 1, |
|
893 | - 'QSG_system' => EEM_Question_Group::system_address, |
|
894 | - 'QSG_deleted' => 0, |
|
895 | - ); |
|
896 | - break; |
|
897 | - } |
|
898 | - // make sure we have some values before inserting them |
|
899 | - if (! empty($QSG_values)) { |
|
900 | - // insert system question |
|
901 | - $wpdb->insert( |
|
902 | - $table_name, |
|
903 | - $QSG_values, |
|
904 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
905 | - ); |
|
906 | - $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
907 | - } |
|
908 | - } |
|
909 | - } |
|
910 | - // QUESTIONS |
|
911 | - global $wpdb; |
|
912 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
913 | - $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
|
914 | - // what we have |
|
915 | - $questions = $wpdb->get_col($SQL); |
|
916 | - // what we should have |
|
917 | - $QST_systems = array( |
|
918 | - 'fname', |
|
919 | - 'lname', |
|
920 | - 'email', |
|
921 | - 'address', |
|
922 | - 'address2', |
|
923 | - 'city', |
|
924 | - 'country', |
|
925 | - 'state', |
|
926 | - 'zip', |
|
927 | - 'phone', |
|
928 | - ); |
|
929 | - $order_for_group_1 = 1; |
|
930 | - $order_for_group_2 = 1; |
|
931 | - // loop thru what we should have and compare to what we have |
|
932 | - foreach ($QST_systems as $QST_system) { |
|
933 | - // reset values array |
|
934 | - $QST_values = array(); |
|
935 | - // if we don't have what we should have |
|
936 | - if (! in_array($QST_system, $questions)) { |
|
937 | - // add it |
|
938 | - switch ($QST_system) { |
|
939 | - case 'fname': |
|
940 | - $QST_values = array( |
|
941 | - 'QST_display_text' => __('First Name', 'event_espresso'), |
|
942 | - 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
943 | - 'QST_system' => 'fname', |
|
944 | - 'QST_type' => 'TEXT', |
|
945 | - 'QST_required' => 1, |
|
946 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
947 | - 'QST_order' => 1, |
|
948 | - 'QST_admin_only' => 0, |
|
949 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
950 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
951 | - 'QST_deleted' => 0, |
|
952 | - ); |
|
953 | - break; |
|
954 | - case 'lname': |
|
955 | - $QST_values = array( |
|
956 | - 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
957 | - 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
958 | - 'QST_system' => 'lname', |
|
959 | - 'QST_type' => 'TEXT', |
|
960 | - 'QST_required' => 1, |
|
961 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
962 | - 'QST_order' => 2, |
|
963 | - 'QST_admin_only' => 0, |
|
964 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
965 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
966 | - 'QST_deleted' => 0, |
|
967 | - ); |
|
968 | - break; |
|
969 | - case 'email': |
|
970 | - $QST_values = array( |
|
971 | - 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
972 | - 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
973 | - 'QST_system' => 'email', |
|
974 | - 'QST_type' => 'EMAIL', |
|
975 | - 'QST_required' => 1, |
|
976 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
977 | - 'QST_order' => 3, |
|
978 | - 'QST_admin_only' => 0, |
|
979 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
980 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
981 | - 'QST_deleted' => 0, |
|
982 | - ); |
|
983 | - break; |
|
984 | - case 'address': |
|
985 | - $QST_values = array( |
|
986 | - 'QST_display_text' => __('Address', 'event_espresso'), |
|
987 | - 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
988 | - 'QST_system' => 'address', |
|
989 | - 'QST_type' => 'TEXT', |
|
990 | - 'QST_required' => 0, |
|
991 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
992 | - 'QST_order' => 4, |
|
993 | - 'QST_admin_only' => 0, |
|
994 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
995 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
996 | - 'QST_deleted' => 0, |
|
997 | - ); |
|
998 | - break; |
|
999 | - case 'address2': |
|
1000 | - $QST_values = array( |
|
1001 | - 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1002 | - 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1003 | - 'QST_system' => 'address2', |
|
1004 | - 'QST_type' => 'TEXT', |
|
1005 | - 'QST_required' => 0, |
|
1006 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1007 | - 'QST_order' => 5, |
|
1008 | - 'QST_admin_only' => 0, |
|
1009 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1010 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1011 | - 'QST_deleted' => 0, |
|
1012 | - ); |
|
1013 | - break; |
|
1014 | - case 'city': |
|
1015 | - $QST_values = array( |
|
1016 | - 'QST_display_text' => __('City', 'event_espresso'), |
|
1017 | - 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1018 | - 'QST_system' => 'city', |
|
1019 | - 'QST_type' => 'TEXT', |
|
1020 | - 'QST_required' => 0, |
|
1021 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1022 | - 'QST_order' => 6, |
|
1023 | - 'QST_admin_only' => 0, |
|
1024 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1025 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1026 | - 'QST_deleted' => 0, |
|
1027 | - ); |
|
1028 | - break; |
|
1029 | - case 'country': |
|
1030 | - $QST_values = array( |
|
1031 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
1032 | - 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1033 | - 'QST_system' => 'country', |
|
1034 | - 'QST_type' => 'COUNTRY', |
|
1035 | - 'QST_required' => 0, |
|
1036 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1037 | - 'QST_order' => 7, |
|
1038 | - 'QST_admin_only' => 0, |
|
1039 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1040 | - 'QST_deleted' => 0, |
|
1041 | - ); |
|
1042 | - break; |
|
1043 | - case 'state': |
|
1044 | - $QST_values = array( |
|
1045 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1046 | - 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1047 | - 'QST_system' => 'state', |
|
1048 | - 'QST_type' => 'STATE', |
|
1049 | - 'QST_required' => 0, |
|
1050 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1051 | - 'QST_order' => 8, |
|
1052 | - 'QST_admin_only' => 0, |
|
1053 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1054 | - 'QST_deleted' => 0, |
|
1055 | - ); |
|
1056 | - break; |
|
1057 | - case 'zip': |
|
1058 | - $QST_values = array( |
|
1059 | - 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1060 | - 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1061 | - 'QST_system' => 'zip', |
|
1062 | - 'QST_type' => 'TEXT', |
|
1063 | - 'QST_required' => 0, |
|
1064 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1065 | - 'QST_order' => 9, |
|
1066 | - 'QST_admin_only' => 0, |
|
1067 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1068 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1069 | - 'QST_deleted' => 0, |
|
1070 | - ); |
|
1071 | - break; |
|
1072 | - case 'phone': |
|
1073 | - $QST_values = array( |
|
1074 | - 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1075 | - 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1076 | - 'QST_system' => 'phone', |
|
1077 | - 'QST_type' => 'TEXT', |
|
1078 | - 'QST_required' => 0, |
|
1079 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1080 | - 'QST_order' => 10, |
|
1081 | - 'QST_admin_only' => 0, |
|
1082 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1083 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1084 | - 'QST_deleted' => 0, |
|
1085 | - ); |
|
1086 | - break; |
|
1087 | - } |
|
1088 | - if (! empty($QST_values)) { |
|
1089 | - // insert system question |
|
1090 | - $wpdb->insert( |
|
1091 | - $table_name, |
|
1092 | - $QST_values, |
|
1093 | - array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1094 | - ); |
|
1095 | - $QST_ID = $wpdb->insert_id; |
|
1096 | - // QUESTION GROUP QUESTIONS |
|
1097 | - if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1098 | - $system_question_we_want = EEM_Question_Group::system_personal; |
|
1099 | - } else { |
|
1100 | - $system_question_we_want = EEM_Question_Group::system_address; |
|
1101 | - } |
|
1102 | - if (isset($QSG_IDs[$system_question_we_want])) { |
|
1103 | - $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1104 | - } else { |
|
1105 | - $id_col = EEM_Question_Group::instance() |
|
1106 | - ->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1107 | - if (is_array($id_col)) { |
|
1108 | - $QSG_ID = reset($id_col); |
|
1109 | - } else { |
|
1110 | - //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
|
1111 | - EE_Log::instance()->log( |
|
1112 | - __FILE__, |
|
1113 | - __FUNCTION__, |
|
1114 | - sprintf( |
|
1115 | - __( |
|
1116 | - 'Could not associate question %1$s to a question group because no system question |
|
833 | + 'event_espresso' |
|
834 | + ), |
|
835 | + __FILE__, |
|
836 | + __FUNCTION__, |
|
837 | + __LINE__ |
|
838 | + ); |
|
839 | + return false; |
|
840 | + } |
|
841 | + return true; |
|
842 | + } |
|
843 | + |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * initialize_system_questions |
|
848 | + * |
|
849 | + * @access public |
|
850 | + * @static |
|
851 | + * @return void |
|
852 | + */ |
|
853 | + public static function initialize_system_questions() |
|
854 | + { |
|
855 | + // QUESTION GROUPS |
|
856 | + global $wpdb; |
|
857 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
858 | + $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
|
859 | + // what we have |
|
860 | + $question_groups = $wpdb->get_col($SQL); |
|
861 | + // check the response |
|
862 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
863 | + // what we should have |
|
864 | + $QSG_systems = array(1, 2); |
|
865 | + // loop thru what we should have and compare to what we have |
|
866 | + foreach ($QSG_systems as $QSG_system) { |
|
867 | + // reset values array |
|
868 | + $QSG_values = array(); |
|
869 | + // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
|
870 | + if (! in_array("$QSG_system", $question_groups)) { |
|
871 | + // add it |
|
872 | + switch ($QSG_system) { |
|
873 | + case 1: |
|
874 | + $QSG_values = array( |
|
875 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
876 | + 'QSG_identifier' => 'personal-information-' . time(), |
|
877 | + 'QSG_desc' => '', |
|
878 | + 'QSG_order' => 1, |
|
879 | + 'QSG_show_group_name' => 1, |
|
880 | + 'QSG_show_group_desc' => 1, |
|
881 | + 'QSG_system' => EEM_Question_Group::system_personal, |
|
882 | + 'QSG_deleted' => 0, |
|
883 | + ); |
|
884 | + break; |
|
885 | + case 2: |
|
886 | + $QSG_values = array( |
|
887 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
888 | + 'QSG_identifier' => 'address-information-' . time(), |
|
889 | + 'QSG_desc' => '', |
|
890 | + 'QSG_order' => 2, |
|
891 | + 'QSG_show_group_name' => 1, |
|
892 | + 'QSG_show_group_desc' => 1, |
|
893 | + 'QSG_system' => EEM_Question_Group::system_address, |
|
894 | + 'QSG_deleted' => 0, |
|
895 | + ); |
|
896 | + break; |
|
897 | + } |
|
898 | + // make sure we have some values before inserting them |
|
899 | + if (! empty($QSG_values)) { |
|
900 | + // insert system question |
|
901 | + $wpdb->insert( |
|
902 | + $table_name, |
|
903 | + $QSG_values, |
|
904 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
905 | + ); |
|
906 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
907 | + } |
|
908 | + } |
|
909 | + } |
|
910 | + // QUESTIONS |
|
911 | + global $wpdb; |
|
912 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
913 | + $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
|
914 | + // what we have |
|
915 | + $questions = $wpdb->get_col($SQL); |
|
916 | + // what we should have |
|
917 | + $QST_systems = array( |
|
918 | + 'fname', |
|
919 | + 'lname', |
|
920 | + 'email', |
|
921 | + 'address', |
|
922 | + 'address2', |
|
923 | + 'city', |
|
924 | + 'country', |
|
925 | + 'state', |
|
926 | + 'zip', |
|
927 | + 'phone', |
|
928 | + ); |
|
929 | + $order_for_group_1 = 1; |
|
930 | + $order_for_group_2 = 1; |
|
931 | + // loop thru what we should have and compare to what we have |
|
932 | + foreach ($QST_systems as $QST_system) { |
|
933 | + // reset values array |
|
934 | + $QST_values = array(); |
|
935 | + // if we don't have what we should have |
|
936 | + if (! in_array($QST_system, $questions)) { |
|
937 | + // add it |
|
938 | + switch ($QST_system) { |
|
939 | + case 'fname': |
|
940 | + $QST_values = array( |
|
941 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
942 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
943 | + 'QST_system' => 'fname', |
|
944 | + 'QST_type' => 'TEXT', |
|
945 | + 'QST_required' => 1, |
|
946 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
947 | + 'QST_order' => 1, |
|
948 | + 'QST_admin_only' => 0, |
|
949 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
950 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
951 | + 'QST_deleted' => 0, |
|
952 | + ); |
|
953 | + break; |
|
954 | + case 'lname': |
|
955 | + $QST_values = array( |
|
956 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
957 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
958 | + 'QST_system' => 'lname', |
|
959 | + 'QST_type' => 'TEXT', |
|
960 | + 'QST_required' => 1, |
|
961 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
962 | + 'QST_order' => 2, |
|
963 | + 'QST_admin_only' => 0, |
|
964 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
965 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
966 | + 'QST_deleted' => 0, |
|
967 | + ); |
|
968 | + break; |
|
969 | + case 'email': |
|
970 | + $QST_values = array( |
|
971 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
972 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
973 | + 'QST_system' => 'email', |
|
974 | + 'QST_type' => 'EMAIL', |
|
975 | + 'QST_required' => 1, |
|
976 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
977 | + 'QST_order' => 3, |
|
978 | + 'QST_admin_only' => 0, |
|
979 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
980 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
981 | + 'QST_deleted' => 0, |
|
982 | + ); |
|
983 | + break; |
|
984 | + case 'address': |
|
985 | + $QST_values = array( |
|
986 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
987 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
988 | + 'QST_system' => 'address', |
|
989 | + 'QST_type' => 'TEXT', |
|
990 | + 'QST_required' => 0, |
|
991 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
992 | + 'QST_order' => 4, |
|
993 | + 'QST_admin_only' => 0, |
|
994 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
995 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
996 | + 'QST_deleted' => 0, |
|
997 | + ); |
|
998 | + break; |
|
999 | + case 'address2': |
|
1000 | + $QST_values = array( |
|
1001 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1002 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1003 | + 'QST_system' => 'address2', |
|
1004 | + 'QST_type' => 'TEXT', |
|
1005 | + 'QST_required' => 0, |
|
1006 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1007 | + 'QST_order' => 5, |
|
1008 | + 'QST_admin_only' => 0, |
|
1009 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1010 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1011 | + 'QST_deleted' => 0, |
|
1012 | + ); |
|
1013 | + break; |
|
1014 | + case 'city': |
|
1015 | + $QST_values = array( |
|
1016 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1017 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1018 | + 'QST_system' => 'city', |
|
1019 | + 'QST_type' => 'TEXT', |
|
1020 | + 'QST_required' => 0, |
|
1021 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1022 | + 'QST_order' => 6, |
|
1023 | + 'QST_admin_only' => 0, |
|
1024 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1025 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1026 | + 'QST_deleted' => 0, |
|
1027 | + ); |
|
1028 | + break; |
|
1029 | + case 'country': |
|
1030 | + $QST_values = array( |
|
1031 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1032 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1033 | + 'QST_system' => 'country', |
|
1034 | + 'QST_type' => 'COUNTRY', |
|
1035 | + 'QST_required' => 0, |
|
1036 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1037 | + 'QST_order' => 7, |
|
1038 | + 'QST_admin_only' => 0, |
|
1039 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1040 | + 'QST_deleted' => 0, |
|
1041 | + ); |
|
1042 | + break; |
|
1043 | + case 'state': |
|
1044 | + $QST_values = array( |
|
1045 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1046 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1047 | + 'QST_system' => 'state', |
|
1048 | + 'QST_type' => 'STATE', |
|
1049 | + 'QST_required' => 0, |
|
1050 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1051 | + 'QST_order' => 8, |
|
1052 | + 'QST_admin_only' => 0, |
|
1053 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1054 | + 'QST_deleted' => 0, |
|
1055 | + ); |
|
1056 | + break; |
|
1057 | + case 'zip': |
|
1058 | + $QST_values = array( |
|
1059 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1060 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1061 | + 'QST_system' => 'zip', |
|
1062 | + 'QST_type' => 'TEXT', |
|
1063 | + 'QST_required' => 0, |
|
1064 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1065 | + 'QST_order' => 9, |
|
1066 | + 'QST_admin_only' => 0, |
|
1067 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1068 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1069 | + 'QST_deleted' => 0, |
|
1070 | + ); |
|
1071 | + break; |
|
1072 | + case 'phone': |
|
1073 | + $QST_values = array( |
|
1074 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1075 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1076 | + 'QST_system' => 'phone', |
|
1077 | + 'QST_type' => 'TEXT', |
|
1078 | + 'QST_required' => 0, |
|
1079 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1080 | + 'QST_order' => 10, |
|
1081 | + 'QST_admin_only' => 0, |
|
1082 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1083 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1084 | + 'QST_deleted' => 0, |
|
1085 | + ); |
|
1086 | + break; |
|
1087 | + } |
|
1088 | + if (! empty($QST_values)) { |
|
1089 | + // insert system question |
|
1090 | + $wpdb->insert( |
|
1091 | + $table_name, |
|
1092 | + $QST_values, |
|
1093 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1094 | + ); |
|
1095 | + $QST_ID = $wpdb->insert_id; |
|
1096 | + // QUESTION GROUP QUESTIONS |
|
1097 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1098 | + $system_question_we_want = EEM_Question_Group::system_personal; |
|
1099 | + } else { |
|
1100 | + $system_question_we_want = EEM_Question_Group::system_address; |
|
1101 | + } |
|
1102 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1103 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1104 | + } else { |
|
1105 | + $id_col = EEM_Question_Group::instance() |
|
1106 | + ->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1107 | + if (is_array($id_col)) { |
|
1108 | + $QSG_ID = reset($id_col); |
|
1109 | + } else { |
|
1110 | + //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
|
1111 | + EE_Log::instance()->log( |
|
1112 | + __FILE__, |
|
1113 | + __FUNCTION__, |
|
1114 | + sprintf( |
|
1115 | + __( |
|
1116 | + 'Could not associate question %1$s to a question group because no system question |
|
1117 | 1117 | group existed', |
1118 | - 'event_espresso' |
|
1119 | - ), |
|
1120 | - $QST_ID), |
|
1121 | - 'error'); |
|
1122 | - continue; |
|
1123 | - } |
|
1124 | - } |
|
1125 | - // add system questions to groups |
|
1126 | - $wpdb->insert( |
|
1127 | - \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1128 | - array( |
|
1129 | - 'QSG_ID' => $QSG_ID, |
|
1130 | - 'QST_ID' => $QST_ID, |
|
1131 | - 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++, |
|
1132 | - ), |
|
1133 | - array('%d', '%d', '%d') |
|
1134 | - ); |
|
1135 | - } |
|
1136 | - } |
|
1137 | - } |
|
1138 | - } |
|
1139 | - |
|
1140 | - |
|
1141 | - /** |
|
1142 | - * Makes sure the default payment method (Invoice) is active. |
|
1143 | - * This used to be done automatically as part of constructing the old gateways config |
|
1144 | - * |
|
1145 | - * @throws \EE_Error |
|
1146 | - */ |
|
1147 | - public static function insert_default_payment_methods() |
|
1148 | - { |
|
1149 | - if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1150 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1151 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1152 | - } else { |
|
1153 | - EEM_Payment_Method::instance()->verify_button_urls(); |
|
1154 | - } |
|
1155 | - } |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * insert_default_status_codes |
|
1159 | - * |
|
1160 | - * @access public |
|
1161 | - * @static |
|
1162 | - * @return void |
|
1163 | - */ |
|
1164 | - public static function insert_default_status_codes() |
|
1165 | - { |
|
1166 | - |
|
1167 | - global $wpdb; |
|
1168 | - |
|
1169 | - if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1170 | - |
|
1171 | - $table_name = EEM_Status::instance()->table(); |
|
1172 | - |
|
1173 | - $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );"; |
|
1174 | - $wpdb->query($SQL); |
|
1175 | - |
|
1176 | - $SQL = "INSERT INTO $table_name |
|
1118 | + 'event_espresso' |
|
1119 | + ), |
|
1120 | + $QST_ID), |
|
1121 | + 'error'); |
|
1122 | + continue; |
|
1123 | + } |
|
1124 | + } |
|
1125 | + // add system questions to groups |
|
1126 | + $wpdb->insert( |
|
1127 | + \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1128 | + array( |
|
1129 | + 'QSG_ID' => $QSG_ID, |
|
1130 | + 'QST_ID' => $QST_ID, |
|
1131 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++, |
|
1132 | + ), |
|
1133 | + array('%d', '%d', '%d') |
|
1134 | + ); |
|
1135 | + } |
|
1136 | + } |
|
1137 | + } |
|
1138 | + } |
|
1139 | + |
|
1140 | + |
|
1141 | + /** |
|
1142 | + * Makes sure the default payment method (Invoice) is active. |
|
1143 | + * This used to be done automatically as part of constructing the old gateways config |
|
1144 | + * |
|
1145 | + * @throws \EE_Error |
|
1146 | + */ |
|
1147 | + public static function insert_default_payment_methods() |
|
1148 | + { |
|
1149 | + if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1150 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1151 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1152 | + } else { |
|
1153 | + EEM_Payment_Method::instance()->verify_button_urls(); |
|
1154 | + } |
|
1155 | + } |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * insert_default_status_codes |
|
1159 | + * |
|
1160 | + * @access public |
|
1161 | + * @static |
|
1162 | + * @return void |
|
1163 | + */ |
|
1164 | + public static function insert_default_status_codes() |
|
1165 | + { |
|
1166 | + |
|
1167 | + global $wpdb; |
|
1168 | + |
|
1169 | + if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1170 | + |
|
1171 | + $table_name = EEM_Status::instance()->table(); |
|
1172 | + |
|
1173 | + $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );"; |
|
1174 | + $wpdb->query($SQL); |
|
1175 | + |
|
1176 | + $SQL = "INSERT INTO $table_name |
|
1177 | 1177 | (STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES |
1178 | 1178 | ('ACT', 'ACTIVE', 'event', 0, NULL, 1), |
1179 | 1179 | ('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0), |
@@ -1213,522 +1213,522 @@ discard block |
||
1213 | 1213 | ('MID', 'IDLE', 'message', 0, NULL, 1), |
1214 | 1214 | ('MRS', 'RESEND', 'message', 0, NULL, 1), |
1215 | 1215 | ('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);"; |
1216 | - $wpdb->query($SQL); |
|
1217 | - |
|
1218 | - } |
|
1219 | - |
|
1220 | - } |
|
1221 | - |
|
1222 | - |
|
1223 | - /** |
|
1224 | - * create_upload_directories |
|
1225 | - * Creates folders in the uploads directory to facilitate addons and templates |
|
1226 | - * |
|
1227 | - * @access public |
|
1228 | - * @static |
|
1229 | - * @return boolean success of verifying upload directories exist |
|
1230 | - */ |
|
1231 | - public static function create_upload_directories() |
|
1232 | - { |
|
1233 | - // Create the required folders |
|
1234 | - $folders = array( |
|
1235 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
1236 | - EVENT_ESPRESSO_GATEWAY_DIR, |
|
1237 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1238 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1239 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/', |
|
1240 | - ); |
|
1241 | - foreach ($folders as $folder) { |
|
1242 | - try { |
|
1243 | - EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1244 | - @ chmod($folder, 0755); |
|
1245 | - } catch (EE_Error $e) { |
|
1246 | - EE_Error::add_error( |
|
1247 | - sprintf( |
|
1248 | - __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1249 | - $folder, |
|
1250 | - '<br />' . $e->getMessage() |
|
1251 | - ), |
|
1252 | - __FILE__, __FUNCTION__, __LINE__ |
|
1253 | - ); |
|
1254 | - //indicate we'll need to fix this later |
|
1255 | - update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1256 | - return false; |
|
1257 | - } |
|
1258 | - } |
|
1259 | - //just add the .htaccess file to the logs directory to begin with. Even if logging |
|
1260 | - //is disabled, there might be activation errors recorded in there |
|
1261 | - EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); |
|
1262 | - //remember EE's folders are all good |
|
1263 | - delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1264 | - return true; |
|
1265 | - } |
|
1266 | - |
|
1267 | - /** |
|
1268 | - * Whether the upload directories need to be fixed or not. |
|
1269 | - * If EE is installed but filesystem access isn't initially available, |
|
1270 | - * we need to get the user's filesystem credentials and THEN create them, |
|
1271 | - * so there might be period of time when EE is installed but its |
|
1272 | - * upload directories aren't available. This indicates such a state |
|
1273 | - * |
|
1274 | - * @return boolean |
|
1275 | - */ |
|
1276 | - public static function upload_directories_incomplete() |
|
1277 | - { |
|
1278 | - return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1279 | - } |
|
1280 | - |
|
1281 | - |
|
1282 | - /** |
|
1283 | - * generate_default_message_templates |
|
1284 | - * |
|
1285 | - * @static |
|
1286 | - * @throws EE_Error |
|
1287 | - * @return bool true means new templates were created. |
|
1288 | - * false means no templates were created. |
|
1289 | - * This is NOT an error flag. To check for errors you will want |
|
1290 | - * to use either EE_Error or a try catch for an EE_Error exception. |
|
1291 | - */ |
|
1292 | - public static function generate_default_message_templates() |
|
1293 | - { |
|
1294 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1295 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1296 | - /* |
|
1216 | + $wpdb->query($SQL); |
|
1217 | + |
|
1218 | + } |
|
1219 | + |
|
1220 | + } |
|
1221 | + |
|
1222 | + |
|
1223 | + /** |
|
1224 | + * create_upload_directories |
|
1225 | + * Creates folders in the uploads directory to facilitate addons and templates |
|
1226 | + * |
|
1227 | + * @access public |
|
1228 | + * @static |
|
1229 | + * @return boolean success of verifying upload directories exist |
|
1230 | + */ |
|
1231 | + public static function create_upload_directories() |
|
1232 | + { |
|
1233 | + // Create the required folders |
|
1234 | + $folders = array( |
|
1235 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
1236 | + EVENT_ESPRESSO_GATEWAY_DIR, |
|
1237 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1238 | + EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1239 | + EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/', |
|
1240 | + ); |
|
1241 | + foreach ($folders as $folder) { |
|
1242 | + try { |
|
1243 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1244 | + @ chmod($folder, 0755); |
|
1245 | + } catch (EE_Error $e) { |
|
1246 | + EE_Error::add_error( |
|
1247 | + sprintf( |
|
1248 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1249 | + $folder, |
|
1250 | + '<br />' . $e->getMessage() |
|
1251 | + ), |
|
1252 | + __FILE__, __FUNCTION__, __LINE__ |
|
1253 | + ); |
|
1254 | + //indicate we'll need to fix this later |
|
1255 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1256 | + return false; |
|
1257 | + } |
|
1258 | + } |
|
1259 | + //just add the .htaccess file to the logs directory to begin with. Even if logging |
|
1260 | + //is disabled, there might be activation errors recorded in there |
|
1261 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); |
|
1262 | + //remember EE's folders are all good |
|
1263 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1264 | + return true; |
|
1265 | + } |
|
1266 | + |
|
1267 | + /** |
|
1268 | + * Whether the upload directories need to be fixed or not. |
|
1269 | + * If EE is installed but filesystem access isn't initially available, |
|
1270 | + * we need to get the user's filesystem credentials and THEN create them, |
|
1271 | + * so there might be period of time when EE is installed but its |
|
1272 | + * upload directories aren't available. This indicates such a state |
|
1273 | + * |
|
1274 | + * @return boolean |
|
1275 | + */ |
|
1276 | + public static function upload_directories_incomplete() |
|
1277 | + { |
|
1278 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1279 | + } |
|
1280 | + |
|
1281 | + |
|
1282 | + /** |
|
1283 | + * generate_default_message_templates |
|
1284 | + * |
|
1285 | + * @static |
|
1286 | + * @throws EE_Error |
|
1287 | + * @return bool true means new templates were created. |
|
1288 | + * false means no templates were created. |
|
1289 | + * This is NOT an error flag. To check for errors you will want |
|
1290 | + * to use either EE_Error or a try catch for an EE_Error exception. |
|
1291 | + */ |
|
1292 | + public static function generate_default_message_templates() |
|
1293 | + { |
|
1294 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1295 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1296 | + /* |
|
1297 | 1297 | * This first method is taking care of ensuring any default messengers |
1298 | 1298 | * that should be made active and have templates generated are done. |
1299 | 1299 | */ |
1300 | - $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates( |
|
1301 | - $message_resource_manager |
|
1302 | - ); |
|
1303 | - /** |
|
1304 | - * This method is verifying there are no NEW default message types |
|
1305 | - * for ACTIVE messengers that need activated (and corresponding templates setup). |
|
1306 | - */ |
|
1307 | - $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1308 | - $message_resource_manager |
|
1309 | - ); |
|
1310 | - //after all is done, let's persist these changes to the db. |
|
1311 | - $message_resource_manager->update_has_activated_messengers_option(); |
|
1312 | - $message_resource_manager->update_active_messengers_option(); |
|
1313 | - // will return true if either of these are true. Otherwise will return false. |
|
1314 | - return $new_templates_created_for_message_type || $new_templates_created_for_messenger; |
|
1315 | - } |
|
1316 | - |
|
1317 | - |
|
1318 | - |
|
1319 | - /** |
|
1320 | - * @param \EE_Message_Resource_Manager $message_resource_manager |
|
1321 | - * @return array|bool |
|
1322 | - * @throws \EE_Error |
|
1323 | - */ |
|
1324 | - protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1325 | - EE_Message_Resource_Manager $message_resource_manager |
|
1326 | - ) { |
|
1327 | - /** @type EE_messenger[] $active_messengers */ |
|
1328 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
1329 | - $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1330 | - $templates_created = false; |
|
1331 | - foreach ($active_messengers as $active_messenger) { |
|
1332 | - $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
|
1333 | - $default_message_type_names_to_activate = array(); |
|
1334 | - // looping through each default message type reported by the messenger |
|
1335 | - // and setup the actual message types to activate. |
|
1336 | - foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1337 | - // if already active or has already been activated before we skip |
|
1338 | - // (otherwise we might reactivate something user's intentionally deactivated.) |
|
1339 | - // we also skip if the message type is not installed. |
|
1340 | - if ( |
|
1341 | - $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1342 | - $default_message_type_name_for_messenger, |
|
1343 | - $active_messenger->name |
|
1344 | - ) |
|
1345 | - || $message_resource_manager->is_message_type_active_for_messenger( |
|
1346 | - $active_messenger->name, |
|
1347 | - $default_message_type_name_for_messenger |
|
1348 | - ) |
|
1349 | - || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1350 | - ) { |
|
1351 | - continue; |
|
1352 | - } |
|
1353 | - $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger; |
|
1354 | - } |
|
1355 | - //let's activate! |
|
1356 | - $message_resource_manager->ensure_message_types_are_active( |
|
1357 | - $default_message_type_names_to_activate, |
|
1358 | - $active_messenger->name, |
|
1359 | - false |
|
1360 | - ); |
|
1361 | - //activate the templates for these message types |
|
1362 | - if ( ! empty($default_message_type_names_to_activate)) { |
|
1363 | - $templates_created = EEH_MSG_Template::generate_new_templates( |
|
1364 | - $active_messenger->name, |
|
1365 | - $default_message_type_names_for_messenger, |
|
1366 | - '', |
|
1367 | - true |
|
1368 | - ); |
|
1369 | - } |
|
1370 | - } |
|
1371 | - return $templates_created; |
|
1372 | - } |
|
1373 | - |
|
1374 | - |
|
1375 | - |
|
1376 | - /** |
|
1377 | - * This will activate and generate default messengers and default message types for those messengers. |
|
1378 | - * |
|
1379 | - * @param EE_message_Resource_Manager $message_resource_manager |
|
1380 | - * @return array|bool True means there were default messengers and message type templates generated. |
|
1381 | - * False means that there were no templates generated |
|
1382 | - * (which could simply mean there are no default message types for a messenger). |
|
1383 | - * @throws EE_Error |
|
1384 | - */ |
|
1385 | - protected static function _activate_and_generate_default_messengers_and_message_templates( |
|
1386 | - EE_Message_Resource_Manager $message_resource_manager |
|
1387 | - ) { |
|
1388 | - /** @type EE_messenger[] $messengers_to_generate */ |
|
1389 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1390 | - $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1391 | - $templates_generated = false; |
|
1392 | - foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1393 | - $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
|
1394 | - //verify the default message types match an installed message type. |
|
1395 | - foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1396 | - if ( |
|
1397 | - ! isset($installed_message_types[$name]) |
|
1398 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1399 | - $name, |
|
1400 | - $messenger_to_generate->name |
|
1401 | - ) |
|
1402 | - ) { |
|
1403 | - unset($default_message_type_names_for_messenger[$key]); |
|
1404 | - } |
|
1405 | - } |
|
1406 | - // in previous iterations, the active_messengers option in the db |
|
1407 | - // needed updated before calling create templates. however with the changes this may not be necessary. |
|
1408 | - // This comment is left here just in case we discover that we _do_ need to update before |
|
1409 | - // passing off to create templates (after the refactor is done). |
|
1410 | - // @todo remove this comment when determined not necessary. |
|
1411 | - $message_resource_manager->activate_messenger( |
|
1412 | - $messenger_to_generate->name, |
|
1413 | - $default_message_type_names_for_messenger, |
|
1414 | - false |
|
1415 | - ); |
|
1416 | - //create any templates needing created (or will reactivate templates already generated as necessary). |
|
1417 | - if ( ! empty($default_message_type_names_for_messenger)) { |
|
1418 | - $templates_generated = EEH_MSG_Template::generate_new_templates( |
|
1419 | - $messenger_to_generate->name, |
|
1420 | - $default_message_type_names_for_messenger, |
|
1421 | - '', |
|
1422 | - true |
|
1423 | - ); |
|
1424 | - } |
|
1425 | - } |
|
1426 | - return $templates_generated; |
|
1427 | - } |
|
1428 | - |
|
1429 | - |
|
1430 | - /** |
|
1431 | - * This returns the default messengers to generate templates for on activation of EE. |
|
1432 | - * It considers: |
|
1433 | - * - whether a messenger is already active in the db. |
|
1434 | - * - whether a messenger has been made active at any time in the past. |
|
1435 | - * |
|
1436 | - * @static |
|
1437 | - * @param EE_Message_Resource_Manager $message_resource_manager |
|
1438 | - * @return EE_messenger[] |
|
1439 | - */ |
|
1440 | - protected static function _get_default_messengers_to_generate_on_activation( |
|
1441 | - EE_Message_Resource_Manager $message_resource_manager |
|
1442 | - ) { |
|
1443 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
1444 | - $installed_messengers = $message_resource_manager->installed_messengers(); |
|
1445 | - $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
|
1446 | - |
|
1447 | - $messengers_to_generate = array(); |
|
1448 | - foreach ($installed_messengers as $installed_messenger) { |
|
1449 | - //if installed messenger is a messenger that should be activated on install |
|
1450 | - //and is not already active |
|
1451 | - //and has never been activated |
|
1452 | - if ( |
|
1453 | - ! $installed_messenger->activate_on_install |
|
1454 | - || isset($active_messengers[$installed_messenger->name]) |
|
1455 | - || isset($has_activated[$installed_messenger->name]) |
|
1456 | - ) { |
|
1457 | - continue; |
|
1458 | - } |
|
1459 | - $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1460 | - } |
|
1461 | - return $messengers_to_generate; |
|
1462 | - } |
|
1463 | - |
|
1464 | - |
|
1465 | - /** |
|
1466 | - * This simply validates active message types to ensure they actually match installed |
|
1467 | - * message types. If there's a mismatch then we deactivate the message type and ensure all related db |
|
1468 | - * rows are set inactive. |
|
1469 | - * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever |
|
1470 | - * EE_Messenger_Resource_Manager is constructed. Message Types are a bit more resource heavy for validation so they |
|
1471 | - * are still handled in here. |
|
1472 | - * |
|
1473 | - * @since 4.3.1 |
|
1474 | - * @return void |
|
1475 | - */ |
|
1476 | - public static function validate_messages_system() |
|
1477 | - { |
|
1478 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1479 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1480 | - $message_resource_manager->validate_active_message_types_are_installed(); |
|
1481 | - do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1482 | - } |
|
1483 | - |
|
1484 | - |
|
1485 | - /** |
|
1486 | - * create_no_ticket_prices_array |
|
1487 | - * |
|
1488 | - * @access public |
|
1489 | - * @static |
|
1490 | - * @return void |
|
1491 | - */ |
|
1492 | - public static function create_no_ticket_prices_array() |
|
1493 | - { |
|
1494 | - // this creates an array for tracking events that have no active ticket prices created |
|
1495 | - // this allows us to warn admins of the situation so that it can be corrected |
|
1496 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false); |
|
1497 | - if (! $espresso_no_ticket_prices) { |
|
1498 | - add_option('ee_no_ticket_prices', array(), '', false); |
|
1499 | - } |
|
1500 | - } |
|
1501 | - |
|
1502 | - |
|
1503 | - /** |
|
1504 | - * plugin_deactivation |
|
1505 | - * |
|
1506 | - * @access public |
|
1507 | - * @static |
|
1508 | - * @return void |
|
1509 | - */ |
|
1510 | - public static function plugin_deactivation() |
|
1511 | - { |
|
1512 | - } |
|
1513 | - |
|
1514 | - |
|
1515 | - /** |
|
1516 | - * Finds all our EE4 custom post types, and deletes them and their associated data |
|
1517 | - * (like post meta or term relations) |
|
1518 | - * |
|
1519 | - * @global wpdb $wpdb |
|
1520 | - * @throws \EE_Error |
|
1521 | - */ |
|
1522 | - public static function delete_all_espresso_cpt_data() |
|
1523 | - { |
|
1524 | - global $wpdb; |
|
1525 | - //get all the CPT post_types |
|
1526 | - $ee_post_types = array(); |
|
1527 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1528 | - if (method_exists($model_name, 'instance')) { |
|
1529 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
1530 | - if ($model_obj instanceof EEM_CPT_Base) { |
|
1531 | - $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1532 | - } |
|
1533 | - } |
|
1534 | - } |
|
1535 | - //get all our CPTs |
|
1536 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")"; |
|
1537 | - $cpt_ids = $wpdb->get_col($query); |
|
1538 | - //delete each post meta and term relations too |
|
1539 | - foreach ($cpt_ids as $post_id) { |
|
1540 | - wp_delete_post($post_id, true); |
|
1541 | - } |
|
1542 | - } |
|
1543 | - |
|
1544 | - /** |
|
1545 | - * Deletes all EE custom tables |
|
1546 | - * |
|
1547 | - * @return array |
|
1548 | - */ |
|
1549 | - public static function drop_espresso_tables() |
|
1550 | - { |
|
1551 | - $tables = array(); |
|
1552 | - // load registry |
|
1553 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1554 | - if (method_exists($model_name, 'instance')) { |
|
1555 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
1556 | - if ($model_obj instanceof EEM_Base) { |
|
1557 | - foreach ($model_obj->get_tables() as $table) { |
|
1558 | - if (strpos($table->get_table_name(), 'esp_') |
|
1559 | - && |
|
1560 | - ( |
|
1561 | - is_main_site()//main site? nuke them all |
|
1562 | - || ! $table->is_global()//not main site,but not global either. nuke it |
|
1563 | - ) |
|
1564 | - ) { |
|
1565 | - $tables[] = $table->get_table_name(); |
|
1566 | - } |
|
1567 | - } |
|
1568 | - } |
|
1569 | - } |
|
1570 | - } |
|
1571 | - |
|
1572 | - //there are some tables whose models were removed. |
|
1573 | - //they should be removed when removing all EE core's data |
|
1574 | - $tables_without_models = array( |
|
1575 | - 'esp_promotion', |
|
1576 | - 'esp_promotion_applied', |
|
1577 | - 'esp_promotion_object', |
|
1578 | - 'esp_promotion_rule', |
|
1579 | - 'esp_rule', |
|
1580 | - 'esp_currency_payment_method', |
|
1581 | - ); |
|
1582 | - foreach ($tables_without_models as $table) { |
|
1583 | - $tables[] = $table; |
|
1584 | - } |
|
1585 | - return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1586 | - } |
|
1587 | - |
|
1588 | - |
|
1589 | - |
|
1590 | - /** |
|
1591 | - * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
1592 | - * each table name provided has a wpdb prefix attached, and that it exists. |
|
1593 | - * Returns the list actually deleted |
|
1594 | - * |
|
1595 | - * @deprecated in 4.9.13. Instead use TableManager::dropTables() |
|
1596 | - * @global WPDB $wpdb |
|
1597 | - * @param array $table_names |
|
1598 | - * @return array of table names which we deleted |
|
1599 | - */ |
|
1600 | - public static function drop_tables($table_names) |
|
1601 | - { |
|
1602 | - return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1603 | - } |
|
1604 | - |
|
1605 | - |
|
1606 | - |
|
1607 | - /** |
|
1608 | - * plugin_uninstall |
|
1609 | - * |
|
1610 | - * @access public |
|
1611 | - * @static |
|
1612 | - * @param bool $remove_all |
|
1613 | - * @return void |
|
1614 | - */ |
|
1615 | - public static function delete_all_espresso_tables_and_data($remove_all = true) |
|
1616 | - { |
|
1617 | - global $wpdb; |
|
1618 | - self::drop_espresso_tables(); |
|
1619 | - $wp_options_to_delete = array( |
|
1620 | - 'ee_no_ticket_prices' => true, |
|
1621 | - 'ee_active_messengers' => true, |
|
1622 | - 'ee_has_activated_messenger' => true, |
|
1623 | - 'ee_flush_rewrite_rules' => true, |
|
1624 | - 'ee_config' => false, |
|
1625 | - 'ee_data_migration_current_db_state' => true, |
|
1626 | - 'ee_data_migration_mapping_' => false, |
|
1627 | - 'ee_data_migration_script_' => false, |
|
1628 | - 'ee_data_migrations' => true, |
|
1629 | - 'ee_dms_map' => false, |
|
1630 | - 'ee_notices' => true, |
|
1631 | - 'lang_file_check_' => false, |
|
1632 | - 'ee_maintenance_mode' => true, |
|
1633 | - 'ee_ueip_optin' => true, |
|
1634 | - 'ee_ueip_has_notified' => true, |
|
1635 | - 'ee_plugin_activation_errors' => true, |
|
1636 | - 'ee_id_mapping_from' => false, |
|
1637 | - 'espresso_persistent_admin_notices' => true, |
|
1638 | - 'ee_encryption_key' => true, |
|
1639 | - 'pue_force_upgrade_' => false, |
|
1640 | - 'pue_json_error_' => false, |
|
1641 | - 'pue_install_key_' => false, |
|
1642 | - 'pue_verification_error_' => false, |
|
1643 | - 'pu_dismissed_upgrade_' => false, |
|
1644 | - 'external_updates-' => false, |
|
1645 | - 'ee_extra_data' => true, |
|
1646 | - 'ee_ssn_' => false, |
|
1647 | - 'ee_rss_' => false, |
|
1648 | - 'ee_rte_n_tx_' => false, |
|
1649 | - 'ee_pers_admin_notices' => true, |
|
1650 | - 'ee_job_parameters_' => false, |
|
1651 | - 'ee_upload_directories_incomplete' => true, |
|
1652 | - 'ee_verified_db_collations' => true, |
|
1653 | - ); |
|
1654 | - if (is_main_site()) { |
|
1655 | - $wp_options_to_delete['ee_network_config'] = true; |
|
1656 | - } |
|
1657 | - $undeleted_options = array(); |
|
1658 | - foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1659 | - if ($no_wildcard) { |
|
1660 | - if ( ! delete_option($option_name)) { |
|
1661 | - $undeleted_options[] = $option_name; |
|
1662 | - } |
|
1663 | - } else { |
|
1664 | - $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1665 | - foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1666 | - if ( ! delete_option($option_name_from_wildcard)) { |
|
1667 | - $undeleted_options[] = $option_name_from_wildcard; |
|
1668 | - } |
|
1669 | - } |
|
1670 | - } |
|
1671 | - } |
|
1672 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1673 | - remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1674 | - if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1675 | - $db_update_sans_ee4 = array(); |
|
1676 | - foreach ($espresso_db_update as $version => $times_activated) { |
|
1677 | - if ((string)$version[0] === '3') {//if its NON EE4 |
|
1678 | - $db_update_sans_ee4[$version] = $times_activated; |
|
1679 | - } |
|
1680 | - } |
|
1681 | - update_option('espresso_db_update', $db_update_sans_ee4); |
|
1682 | - } |
|
1683 | - $errors = ''; |
|
1684 | - if ( ! empty($undeleted_options)) { |
|
1685 | - $errors .= sprintf( |
|
1686 | - __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1687 | - '<br/>', |
|
1688 | - implode(',<br/>', $undeleted_options) |
|
1689 | - ); |
|
1690 | - } |
|
1691 | - if ( ! empty($errors)) { |
|
1692 | - EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1693 | - } |
|
1694 | - } |
|
1695 | - |
|
1696 | - /** |
|
1697 | - * Gets the mysql error code from the last used query by wpdb |
|
1698 | - * |
|
1699 | - * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html |
|
1700 | - */ |
|
1701 | - public static function last_wpdb_error_code() |
|
1702 | - { |
|
1703 | - global $wpdb; |
|
1704 | - if ($wpdb->use_mysqli) { |
|
1705 | - return mysqli_errno($wpdb->dbh); |
|
1706 | - } else { |
|
1707 | - return mysql_errno($wpdb->dbh); |
|
1708 | - } |
|
1709 | - } |
|
1710 | - |
|
1711 | - /** |
|
1712 | - * Checks that the database table exists. Also works on temporary tables (for unit tests mostly). |
|
1713 | - * |
|
1714 | - * @global wpdb $wpdb |
|
1715 | - * @deprecated instead use TableAnalysis::tableExists() |
|
1716 | - * @param string $table_name with or without $wpdb->prefix |
|
1717 | - * @return boolean |
|
1718 | - */ |
|
1719 | - public static function table_exists($table_name) |
|
1720 | - { |
|
1721 | - return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1722 | - } |
|
1723 | - |
|
1724 | - /** |
|
1725 | - * Resets the cache on EEH_Activation |
|
1726 | - */ |
|
1727 | - public static function reset() |
|
1728 | - { |
|
1729 | - self::$_default_creator_id = null; |
|
1730 | - self::$_initialized_db_content_already_in_this_request = false; |
|
1731 | - } |
|
1300 | + $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates( |
|
1301 | + $message_resource_manager |
|
1302 | + ); |
|
1303 | + /** |
|
1304 | + * This method is verifying there are no NEW default message types |
|
1305 | + * for ACTIVE messengers that need activated (and corresponding templates setup). |
|
1306 | + */ |
|
1307 | + $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1308 | + $message_resource_manager |
|
1309 | + ); |
|
1310 | + //after all is done, let's persist these changes to the db. |
|
1311 | + $message_resource_manager->update_has_activated_messengers_option(); |
|
1312 | + $message_resource_manager->update_active_messengers_option(); |
|
1313 | + // will return true if either of these are true. Otherwise will return false. |
|
1314 | + return $new_templates_created_for_message_type || $new_templates_created_for_messenger; |
|
1315 | + } |
|
1316 | + |
|
1317 | + |
|
1318 | + |
|
1319 | + /** |
|
1320 | + * @param \EE_Message_Resource_Manager $message_resource_manager |
|
1321 | + * @return array|bool |
|
1322 | + * @throws \EE_Error |
|
1323 | + */ |
|
1324 | + protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1325 | + EE_Message_Resource_Manager $message_resource_manager |
|
1326 | + ) { |
|
1327 | + /** @type EE_messenger[] $active_messengers */ |
|
1328 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
1329 | + $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1330 | + $templates_created = false; |
|
1331 | + foreach ($active_messengers as $active_messenger) { |
|
1332 | + $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
|
1333 | + $default_message_type_names_to_activate = array(); |
|
1334 | + // looping through each default message type reported by the messenger |
|
1335 | + // and setup the actual message types to activate. |
|
1336 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1337 | + // if already active or has already been activated before we skip |
|
1338 | + // (otherwise we might reactivate something user's intentionally deactivated.) |
|
1339 | + // we also skip if the message type is not installed. |
|
1340 | + if ( |
|
1341 | + $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1342 | + $default_message_type_name_for_messenger, |
|
1343 | + $active_messenger->name |
|
1344 | + ) |
|
1345 | + || $message_resource_manager->is_message_type_active_for_messenger( |
|
1346 | + $active_messenger->name, |
|
1347 | + $default_message_type_name_for_messenger |
|
1348 | + ) |
|
1349 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1350 | + ) { |
|
1351 | + continue; |
|
1352 | + } |
|
1353 | + $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger; |
|
1354 | + } |
|
1355 | + //let's activate! |
|
1356 | + $message_resource_manager->ensure_message_types_are_active( |
|
1357 | + $default_message_type_names_to_activate, |
|
1358 | + $active_messenger->name, |
|
1359 | + false |
|
1360 | + ); |
|
1361 | + //activate the templates for these message types |
|
1362 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1363 | + $templates_created = EEH_MSG_Template::generate_new_templates( |
|
1364 | + $active_messenger->name, |
|
1365 | + $default_message_type_names_for_messenger, |
|
1366 | + '', |
|
1367 | + true |
|
1368 | + ); |
|
1369 | + } |
|
1370 | + } |
|
1371 | + return $templates_created; |
|
1372 | + } |
|
1373 | + |
|
1374 | + |
|
1375 | + |
|
1376 | + /** |
|
1377 | + * This will activate and generate default messengers and default message types for those messengers. |
|
1378 | + * |
|
1379 | + * @param EE_message_Resource_Manager $message_resource_manager |
|
1380 | + * @return array|bool True means there were default messengers and message type templates generated. |
|
1381 | + * False means that there were no templates generated |
|
1382 | + * (which could simply mean there are no default message types for a messenger). |
|
1383 | + * @throws EE_Error |
|
1384 | + */ |
|
1385 | + protected static function _activate_and_generate_default_messengers_and_message_templates( |
|
1386 | + EE_Message_Resource_Manager $message_resource_manager |
|
1387 | + ) { |
|
1388 | + /** @type EE_messenger[] $messengers_to_generate */ |
|
1389 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1390 | + $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1391 | + $templates_generated = false; |
|
1392 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1393 | + $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
|
1394 | + //verify the default message types match an installed message type. |
|
1395 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1396 | + if ( |
|
1397 | + ! isset($installed_message_types[$name]) |
|
1398 | + || $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1399 | + $name, |
|
1400 | + $messenger_to_generate->name |
|
1401 | + ) |
|
1402 | + ) { |
|
1403 | + unset($default_message_type_names_for_messenger[$key]); |
|
1404 | + } |
|
1405 | + } |
|
1406 | + // in previous iterations, the active_messengers option in the db |
|
1407 | + // needed updated before calling create templates. however with the changes this may not be necessary. |
|
1408 | + // This comment is left here just in case we discover that we _do_ need to update before |
|
1409 | + // passing off to create templates (after the refactor is done). |
|
1410 | + // @todo remove this comment when determined not necessary. |
|
1411 | + $message_resource_manager->activate_messenger( |
|
1412 | + $messenger_to_generate->name, |
|
1413 | + $default_message_type_names_for_messenger, |
|
1414 | + false |
|
1415 | + ); |
|
1416 | + //create any templates needing created (or will reactivate templates already generated as necessary). |
|
1417 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1418 | + $templates_generated = EEH_MSG_Template::generate_new_templates( |
|
1419 | + $messenger_to_generate->name, |
|
1420 | + $default_message_type_names_for_messenger, |
|
1421 | + '', |
|
1422 | + true |
|
1423 | + ); |
|
1424 | + } |
|
1425 | + } |
|
1426 | + return $templates_generated; |
|
1427 | + } |
|
1428 | + |
|
1429 | + |
|
1430 | + /** |
|
1431 | + * This returns the default messengers to generate templates for on activation of EE. |
|
1432 | + * It considers: |
|
1433 | + * - whether a messenger is already active in the db. |
|
1434 | + * - whether a messenger has been made active at any time in the past. |
|
1435 | + * |
|
1436 | + * @static |
|
1437 | + * @param EE_Message_Resource_Manager $message_resource_manager |
|
1438 | + * @return EE_messenger[] |
|
1439 | + */ |
|
1440 | + protected static function _get_default_messengers_to_generate_on_activation( |
|
1441 | + EE_Message_Resource_Manager $message_resource_manager |
|
1442 | + ) { |
|
1443 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
1444 | + $installed_messengers = $message_resource_manager->installed_messengers(); |
|
1445 | + $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
|
1446 | + |
|
1447 | + $messengers_to_generate = array(); |
|
1448 | + foreach ($installed_messengers as $installed_messenger) { |
|
1449 | + //if installed messenger is a messenger that should be activated on install |
|
1450 | + //and is not already active |
|
1451 | + //and has never been activated |
|
1452 | + if ( |
|
1453 | + ! $installed_messenger->activate_on_install |
|
1454 | + || isset($active_messengers[$installed_messenger->name]) |
|
1455 | + || isset($has_activated[$installed_messenger->name]) |
|
1456 | + ) { |
|
1457 | + continue; |
|
1458 | + } |
|
1459 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1460 | + } |
|
1461 | + return $messengers_to_generate; |
|
1462 | + } |
|
1463 | + |
|
1464 | + |
|
1465 | + /** |
|
1466 | + * This simply validates active message types to ensure they actually match installed |
|
1467 | + * message types. If there's a mismatch then we deactivate the message type and ensure all related db |
|
1468 | + * rows are set inactive. |
|
1469 | + * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever |
|
1470 | + * EE_Messenger_Resource_Manager is constructed. Message Types are a bit more resource heavy for validation so they |
|
1471 | + * are still handled in here. |
|
1472 | + * |
|
1473 | + * @since 4.3.1 |
|
1474 | + * @return void |
|
1475 | + */ |
|
1476 | + public static function validate_messages_system() |
|
1477 | + { |
|
1478 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1479 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1480 | + $message_resource_manager->validate_active_message_types_are_installed(); |
|
1481 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1482 | + } |
|
1483 | + |
|
1484 | + |
|
1485 | + /** |
|
1486 | + * create_no_ticket_prices_array |
|
1487 | + * |
|
1488 | + * @access public |
|
1489 | + * @static |
|
1490 | + * @return void |
|
1491 | + */ |
|
1492 | + public static function create_no_ticket_prices_array() |
|
1493 | + { |
|
1494 | + // this creates an array for tracking events that have no active ticket prices created |
|
1495 | + // this allows us to warn admins of the situation so that it can be corrected |
|
1496 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false); |
|
1497 | + if (! $espresso_no_ticket_prices) { |
|
1498 | + add_option('ee_no_ticket_prices', array(), '', false); |
|
1499 | + } |
|
1500 | + } |
|
1501 | + |
|
1502 | + |
|
1503 | + /** |
|
1504 | + * plugin_deactivation |
|
1505 | + * |
|
1506 | + * @access public |
|
1507 | + * @static |
|
1508 | + * @return void |
|
1509 | + */ |
|
1510 | + public static function plugin_deactivation() |
|
1511 | + { |
|
1512 | + } |
|
1513 | + |
|
1514 | + |
|
1515 | + /** |
|
1516 | + * Finds all our EE4 custom post types, and deletes them and their associated data |
|
1517 | + * (like post meta or term relations) |
|
1518 | + * |
|
1519 | + * @global wpdb $wpdb |
|
1520 | + * @throws \EE_Error |
|
1521 | + */ |
|
1522 | + public static function delete_all_espresso_cpt_data() |
|
1523 | + { |
|
1524 | + global $wpdb; |
|
1525 | + //get all the CPT post_types |
|
1526 | + $ee_post_types = array(); |
|
1527 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1528 | + if (method_exists($model_name, 'instance')) { |
|
1529 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1530 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1531 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1532 | + } |
|
1533 | + } |
|
1534 | + } |
|
1535 | + //get all our CPTs |
|
1536 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")"; |
|
1537 | + $cpt_ids = $wpdb->get_col($query); |
|
1538 | + //delete each post meta and term relations too |
|
1539 | + foreach ($cpt_ids as $post_id) { |
|
1540 | + wp_delete_post($post_id, true); |
|
1541 | + } |
|
1542 | + } |
|
1543 | + |
|
1544 | + /** |
|
1545 | + * Deletes all EE custom tables |
|
1546 | + * |
|
1547 | + * @return array |
|
1548 | + */ |
|
1549 | + public static function drop_espresso_tables() |
|
1550 | + { |
|
1551 | + $tables = array(); |
|
1552 | + // load registry |
|
1553 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1554 | + if (method_exists($model_name, 'instance')) { |
|
1555 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1556 | + if ($model_obj instanceof EEM_Base) { |
|
1557 | + foreach ($model_obj->get_tables() as $table) { |
|
1558 | + if (strpos($table->get_table_name(), 'esp_') |
|
1559 | + && |
|
1560 | + ( |
|
1561 | + is_main_site()//main site? nuke them all |
|
1562 | + || ! $table->is_global()//not main site,but not global either. nuke it |
|
1563 | + ) |
|
1564 | + ) { |
|
1565 | + $tables[] = $table->get_table_name(); |
|
1566 | + } |
|
1567 | + } |
|
1568 | + } |
|
1569 | + } |
|
1570 | + } |
|
1571 | + |
|
1572 | + //there are some tables whose models were removed. |
|
1573 | + //they should be removed when removing all EE core's data |
|
1574 | + $tables_without_models = array( |
|
1575 | + 'esp_promotion', |
|
1576 | + 'esp_promotion_applied', |
|
1577 | + 'esp_promotion_object', |
|
1578 | + 'esp_promotion_rule', |
|
1579 | + 'esp_rule', |
|
1580 | + 'esp_currency_payment_method', |
|
1581 | + ); |
|
1582 | + foreach ($tables_without_models as $table) { |
|
1583 | + $tables[] = $table; |
|
1584 | + } |
|
1585 | + return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1586 | + } |
|
1587 | + |
|
1588 | + |
|
1589 | + |
|
1590 | + /** |
|
1591 | + * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
1592 | + * each table name provided has a wpdb prefix attached, and that it exists. |
|
1593 | + * Returns the list actually deleted |
|
1594 | + * |
|
1595 | + * @deprecated in 4.9.13. Instead use TableManager::dropTables() |
|
1596 | + * @global WPDB $wpdb |
|
1597 | + * @param array $table_names |
|
1598 | + * @return array of table names which we deleted |
|
1599 | + */ |
|
1600 | + public static function drop_tables($table_names) |
|
1601 | + { |
|
1602 | + return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1603 | + } |
|
1604 | + |
|
1605 | + |
|
1606 | + |
|
1607 | + /** |
|
1608 | + * plugin_uninstall |
|
1609 | + * |
|
1610 | + * @access public |
|
1611 | + * @static |
|
1612 | + * @param bool $remove_all |
|
1613 | + * @return void |
|
1614 | + */ |
|
1615 | + public static function delete_all_espresso_tables_and_data($remove_all = true) |
|
1616 | + { |
|
1617 | + global $wpdb; |
|
1618 | + self::drop_espresso_tables(); |
|
1619 | + $wp_options_to_delete = array( |
|
1620 | + 'ee_no_ticket_prices' => true, |
|
1621 | + 'ee_active_messengers' => true, |
|
1622 | + 'ee_has_activated_messenger' => true, |
|
1623 | + 'ee_flush_rewrite_rules' => true, |
|
1624 | + 'ee_config' => false, |
|
1625 | + 'ee_data_migration_current_db_state' => true, |
|
1626 | + 'ee_data_migration_mapping_' => false, |
|
1627 | + 'ee_data_migration_script_' => false, |
|
1628 | + 'ee_data_migrations' => true, |
|
1629 | + 'ee_dms_map' => false, |
|
1630 | + 'ee_notices' => true, |
|
1631 | + 'lang_file_check_' => false, |
|
1632 | + 'ee_maintenance_mode' => true, |
|
1633 | + 'ee_ueip_optin' => true, |
|
1634 | + 'ee_ueip_has_notified' => true, |
|
1635 | + 'ee_plugin_activation_errors' => true, |
|
1636 | + 'ee_id_mapping_from' => false, |
|
1637 | + 'espresso_persistent_admin_notices' => true, |
|
1638 | + 'ee_encryption_key' => true, |
|
1639 | + 'pue_force_upgrade_' => false, |
|
1640 | + 'pue_json_error_' => false, |
|
1641 | + 'pue_install_key_' => false, |
|
1642 | + 'pue_verification_error_' => false, |
|
1643 | + 'pu_dismissed_upgrade_' => false, |
|
1644 | + 'external_updates-' => false, |
|
1645 | + 'ee_extra_data' => true, |
|
1646 | + 'ee_ssn_' => false, |
|
1647 | + 'ee_rss_' => false, |
|
1648 | + 'ee_rte_n_tx_' => false, |
|
1649 | + 'ee_pers_admin_notices' => true, |
|
1650 | + 'ee_job_parameters_' => false, |
|
1651 | + 'ee_upload_directories_incomplete' => true, |
|
1652 | + 'ee_verified_db_collations' => true, |
|
1653 | + ); |
|
1654 | + if (is_main_site()) { |
|
1655 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1656 | + } |
|
1657 | + $undeleted_options = array(); |
|
1658 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1659 | + if ($no_wildcard) { |
|
1660 | + if ( ! delete_option($option_name)) { |
|
1661 | + $undeleted_options[] = $option_name; |
|
1662 | + } |
|
1663 | + } else { |
|
1664 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1665 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1666 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1667 | + $undeleted_options[] = $option_name_from_wildcard; |
|
1668 | + } |
|
1669 | + } |
|
1670 | + } |
|
1671 | + } |
|
1672 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1673 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1674 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1675 | + $db_update_sans_ee4 = array(); |
|
1676 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1677 | + if ((string)$version[0] === '3') {//if its NON EE4 |
|
1678 | + $db_update_sans_ee4[$version] = $times_activated; |
|
1679 | + } |
|
1680 | + } |
|
1681 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1682 | + } |
|
1683 | + $errors = ''; |
|
1684 | + if ( ! empty($undeleted_options)) { |
|
1685 | + $errors .= sprintf( |
|
1686 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1687 | + '<br/>', |
|
1688 | + implode(',<br/>', $undeleted_options) |
|
1689 | + ); |
|
1690 | + } |
|
1691 | + if ( ! empty($errors)) { |
|
1692 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1693 | + } |
|
1694 | + } |
|
1695 | + |
|
1696 | + /** |
|
1697 | + * Gets the mysql error code from the last used query by wpdb |
|
1698 | + * |
|
1699 | + * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html |
|
1700 | + */ |
|
1701 | + public static function last_wpdb_error_code() |
|
1702 | + { |
|
1703 | + global $wpdb; |
|
1704 | + if ($wpdb->use_mysqli) { |
|
1705 | + return mysqli_errno($wpdb->dbh); |
|
1706 | + } else { |
|
1707 | + return mysql_errno($wpdb->dbh); |
|
1708 | + } |
|
1709 | + } |
|
1710 | + |
|
1711 | + /** |
|
1712 | + * Checks that the database table exists. Also works on temporary tables (for unit tests mostly). |
|
1713 | + * |
|
1714 | + * @global wpdb $wpdb |
|
1715 | + * @deprecated instead use TableAnalysis::tableExists() |
|
1716 | + * @param string $table_name with or without $wpdb->prefix |
|
1717 | + * @return boolean |
|
1718 | + */ |
|
1719 | + public static function table_exists($table_name) |
|
1720 | + { |
|
1721 | + return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1722 | + } |
|
1723 | + |
|
1724 | + /** |
|
1725 | + * Resets the cache on EEH_Activation |
|
1726 | + */ |
|
1727 | + public static function reset() |
|
1728 | + { |
|
1729 | + self::$_default_creator_id = null; |
|
1730 | + self::$_initialized_db_content_already_in_this_request = false; |
|
1731 | + } |
|
1732 | 1732 | } |
1733 | 1733 | // End of file EEH_Activation.helper.php |
1734 | 1734 | // Location: /helpers/EEH_Activation.core.php |