@@ -27,1313 +27,1313 @@ |
||
27 | 27 | final class EE_System implements ResettableInterface |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
32 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
33 | - */ |
|
34 | - const req_type_normal = 0; |
|
35 | - |
|
36 | - /** |
|
37 | - * Indicates this is a brand new installation of EE so we should install |
|
38 | - * tables and default data etc |
|
39 | - */ |
|
40 | - const req_type_new_activation = 1; |
|
41 | - |
|
42 | - /** |
|
43 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
44 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
45 | - * and that default data is setup too |
|
46 | - */ |
|
47 | - const req_type_reactivation = 2; |
|
48 | - |
|
49 | - /** |
|
50 | - * indicates that EE has been upgraded since its previous request. |
|
51 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
52 | - */ |
|
53 | - const req_type_upgrade = 3; |
|
54 | - |
|
55 | - /** |
|
56 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
57 | - */ |
|
58 | - const req_type_downgrade = 4; |
|
59 | - |
|
60 | - /** |
|
61 | - * @deprecated since version 4.6.0.dev.006 |
|
62 | - * Now whenever a new_activation is detected the request type is still just |
|
63 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
64 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
65 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
66 | - * (Specifically, when the migration manager indicates migrations are finished |
|
67 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
68 | - */ |
|
69 | - const req_type_activation_but_not_installed = 5; |
|
70 | - |
|
71 | - /** |
|
72 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
73 | - */ |
|
74 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var EE_System $_instance |
|
78 | - */ |
|
79 | - private static $_instance; |
|
80 | - |
|
81 | - /** |
|
82 | - * @var EE_Registry $registry |
|
83 | - */ |
|
84 | - private $registry; |
|
85 | - |
|
86 | - /** |
|
87 | - * @var LoaderInterface $loader |
|
88 | - */ |
|
89 | - private $loader; |
|
90 | - |
|
91 | - /** |
|
92 | - * @var EE_Capabilities $capabilities |
|
93 | - */ |
|
94 | - private $capabilities; |
|
95 | - |
|
96 | - /** |
|
97 | - * @var RequestInterface $request |
|
98 | - */ |
|
99 | - private $request; |
|
100 | - |
|
101 | - /** |
|
102 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
103 | - */ |
|
104 | - private $maintenance_mode; |
|
105 | - |
|
106 | - /** |
|
107 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
108 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
109 | - * |
|
110 | - * @var int $_req_type |
|
111 | - */ |
|
112 | - private $_req_type; |
|
113 | - |
|
114 | - /** |
|
115 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
116 | - * |
|
117 | - * @var boolean $_major_version_change |
|
118 | - */ |
|
119 | - private $_major_version_change = false; |
|
120 | - |
|
121 | - /** |
|
122 | - * A Context DTO dedicated solely to identifying the current request type. |
|
123 | - * |
|
124 | - * @var RequestTypeContextCheckerInterface $request_type |
|
125 | - */ |
|
126 | - private $request_type; |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * @singleton method used to instantiate class object |
|
131 | - * @param EE_Registry|null $registry |
|
132 | - * @param LoaderInterface|null $loader |
|
133 | - * @param RequestInterface|null $request |
|
134 | - * @param EE_Maintenance_Mode|null $maintenance_mode |
|
135 | - * @return EE_System |
|
136 | - */ |
|
137 | - public static function instance( |
|
138 | - EE_Registry $registry = null, |
|
139 | - LoaderInterface $loader = null, |
|
140 | - RequestInterface $request = null, |
|
141 | - EE_Maintenance_Mode $maintenance_mode = null |
|
142 | - ) { |
|
143 | - // check if class object is instantiated |
|
144 | - if (! self::$_instance instanceof EE_System) { |
|
145 | - self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
146 | - } |
|
147 | - return self::$_instance; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * resets the instance and returns it |
|
153 | - * |
|
154 | - * @return EE_System |
|
155 | - */ |
|
156 | - public static function reset() |
|
157 | - { |
|
158 | - self::$_instance->_req_type = null; |
|
159 | - // make sure none of the old hooks are left hanging around |
|
160 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
161 | - // we need to reset the migration manager in order for it to detect DMSs properly |
|
162 | - EE_Data_Migration_Manager::reset(); |
|
163 | - self::instance()->detect_activations_or_upgrades(); |
|
164 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
165 | - return self::instance(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * sets hooks for running rest of system |
|
171 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
172 | - * starting EE Addons from any other point may lead to problems |
|
173 | - * |
|
174 | - * @param EE_Registry $registry |
|
175 | - * @param LoaderInterface $loader |
|
176 | - * @param RequestInterface $request |
|
177 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
178 | - */ |
|
179 | - private function __construct( |
|
180 | - EE_Registry $registry, |
|
181 | - LoaderInterface $loader, |
|
182 | - RequestInterface $request, |
|
183 | - EE_Maintenance_Mode $maintenance_mode |
|
184 | - ) { |
|
185 | - $this->registry = $registry; |
|
186 | - $this->loader = $loader; |
|
187 | - $this->request = $request; |
|
188 | - $this->maintenance_mode = $maintenance_mode; |
|
189 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
190 | - add_action( |
|
191 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
192 | - array($this, 'loadCapabilities'), |
|
193 | - 5 |
|
194 | - ); |
|
195 | - add_action( |
|
196 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
197 | - array($this, 'loadCommandBus'), |
|
198 | - 7 |
|
199 | - ); |
|
200 | - add_action( |
|
201 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
202 | - array($this, 'loadPluginApi'), |
|
203 | - 9 |
|
204 | - ); |
|
205 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
206 | - add_action( |
|
207 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
208 | - array($this, 'load_espresso_addons') |
|
209 | - ); |
|
210 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
211 | - // because the newly-activated addon didn't get a chance to run at all |
|
212 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
213 | - // detect whether install or upgrade |
|
214 | - add_action( |
|
215 | - 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
216 | - array($this, 'detect_activations_or_upgrades'), |
|
217 | - 3 |
|
218 | - ); |
|
219 | - // load EE_Config, EE_Textdomain, etc |
|
220 | - add_action( |
|
221 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
222 | - array($this, 'load_core_configuration'), |
|
223 | - 5 |
|
224 | - ); |
|
225 | - // load specifications for matching routes to current request |
|
226 | - add_action( |
|
227 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
228 | - array($this, 'loadRouteMatchSpecifications') |
|
229 | - ); |
|
230 | - // load EE_Config, EE_Textdomain, etc |
|
231 | - add_action( |
|
232 | - 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
233 | - array($this, 'register_shortcodes_modules_and_widgets'), |
|
234 | - 7 |
|
235 | - ); |
|
236 | - // you wanna get going? I wanna get going... let's get going! |
|
237 | - add_action( |
|
238 | - 'AHEE__EE_Bootstrap__brew_espresso', |
|
239 | - array($this, 'brew_espresso'), |
|
240 | - 9 |
|
241 | - ); |
|
242 | - // other housekeeping |
|
243 | - // exclude EE critical pages from wp_list_pages |
|
244 | - add_filter( |
|
245 | - 'wp_list_pages_excludes', |
|
246 | - array($this, 'remove_pages_from_wp_list_pages'), |
|
247 | - 10 |
|
248 | - ); |
|
249 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
250 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
251 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * load and setup EE_Capabilities |
|
257 | - * |
|
258 | - * @return void |
|
259 | - * @throws EE_Error |
|
260 | - */ |
|
261 | - public function loadCapabilities() |
|
262 | - { |
|
263 | - $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
264 | - add_action( |
|
265 | - 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
266 | - function () { |
|
267 | - LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
268 | - } |
|
269 | - ); |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * create and cache the CommandBus, and also add middleware |
|
275 | - * The CapChecker middleware requires the use of EE_Capabilities |
|
276 | - * which is why we need to load the CommandBus after Caps are set up |
|
277 | - * |
|
278 | - * @return void |
|
279 | - * @throws EE_Error |
|
280 | - */ |
|
281 | - public function loadCommandBus() |
|
282 | - { |
|
283 | - $this->loader->getShared( |
|
284 | - 'CommandBusInterface', |
|
285 | - array( |
|
286 | - null, |
|
287 | - apply_filters( |
|
288 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
289 | - array( |
|
290 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
291 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
292 | - ) |
|
293 | - ), |
|
294 | - ) |
|
295 | - ); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * @return void |
|
301 | - * @throws EE_Error |
|
302 | - */ |
|
303 | - public function loadPluginApi() |
|
304 | - { |
|
305 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
306 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
307 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
308 | - $this->loader->getShared('EE_Request_Handler'); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * @param string $addon_name |
|
314 | - * @param string $version_constant |
|
315 | - * @param string $min_version_required |
|
316 | - * @param string $load_callback |
|
317 | - * @param string $plugin_file_constant |
|
318 | - * @return void |
|
319 | - */ |
|
320 | - private function deactivateIncompatibleAddon( |
|
321 | - $addon_name, |
|
322 | - $version_constant, |
|
323 | - $min_version_required, |
|
324 | - $load_callback, |
|
325 | - $plugin_file_constant |
|
326 | - ) { |
|
327 | - if (! defined($version_constant)) { |
|
328 | - return; |
|
329 | - } |
|
330 | - $addon_version = constant($version_constant); |
|
331 | - if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
332 | - remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
333 | - if (! function_exists('deactivate_plugins')) { |
|
334 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
335 | - } |
|
336 | - deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
337 | - unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
|
338 | - EE_Error::add_error( |
|
339 | - sprintf( |
|
340 | - esc_html__( |
|
341 | - 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
342 | - 'event_espresso' |
|
343 | - ), |
|
344 | - $addon_name, |
|
345 | - $min_version_required |
|
346 | - ), |
|
347 | - __FILE__, |
|
348 | - __FUNCTION__ . "({$addon_name})", |
|
349 | - __LINE__ |
|
350 | - ); |
|
351 | - EE_Error::get_notices(false, true); |
|
352 | - } |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * load_espresso_addons |
|
358 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
359 | - * this is hooked into both: |
|
360 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
361 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
362 | - * and the WP 'activate_plugin' hook point |
|
363 | - * |
|
364 | - * @access public |
|
365 | - * @return void |
|
366 | - */ |
|
367 | - public function load_espresso_addons() |
|
368 | - { |
|
369 | - $this->deactivateIncompatibleAddon( |
|
370 | - 'Wait Lists', |
|
371 | - 'EE_WAIT_LISTS_VERSION', |
|
372 | - '1.0.0.beta.074', |
|
373 | - 'load_espresso_wait_lists', |
|
374 | - 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
375 | - ); |
|
376 | - $this->deactivateIncompatibleAddon( |
|
377 | - 'Automated Upcoming Event Notifications', |
|
378 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
379 | - '1.0.0.beta.091', |
|
380 | - 'load_espresso_automated_upcoming_event_notification', |
|
381 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
382 | - ); |
|
383 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
384 | - // if the WP API basic auth plugin isn't already loaded, load it now. |
|
385 | - // We want it for mobile apps. Just include the entire plugin |
|
386 | - // also, don't load the basic auth when a plugin is getting activated, because |
|
387 | - // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
388 | - // and causes a fatal error |
|
389 | - if (($this->request->isWordPressApi() || $this->request->isApi()) |
|
390 | - && $this->request->getRequestParam('activate') !== 'true' |
|
391 | - && ! function_exists('json_basic_auth_handler') |
|
392 | - && ! function_exists('json_basic_auth_error') |
|
393 | - && ! in_array( |
|
394 | - $this->request->getRequestParam('action'), |
|
395 | - array('activate', 'activate-selected'), |
|
396 | - true |
|
397 | - ) |
|
398 | - ) { |
|
399 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
400 | - } |
|
401 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * detect_activations_or_upgrades |
|
407 | - * Checks for activation or upgrade of core first; |
|
408 | - * then also checks if any registered addons have been activated or upgraded |
|
409 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
410 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
411 | - * |
|
412 | - * @access public |
|
413 | - * @return void |
|
414 | - */ |
|
415 | - public function detect_activations_or_upgrades() |
|
416 | - { |
|
417 | - // first off: let's make sure to handle core |
|
418 | - $this->detect_if_activation_or_upgrade(); |
|
419 | - foreach ($this->registry->addons as $addon) { |
|
420 | - if ($addon instanceof EE_Addon) { |
|
421 | - // detect teh request type for that addon |
|
422 | - $addon->detect_activation_or_upgrade(); |
|
423 | - } |
|
424 | - } |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * detect_if_activation_or_upgrade |
|
430 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
431 | - * and either setting up the DB or setting up maintenance mode etc. |
|
432 | - * |
|
433 | - * @access public |
|
434 | - * @return void |
|
435 | - */ |
|
436 | - public function detect_if_activation_or_upgrade() |
|
437 | - { |
|
438 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
439 | - // check if db has been updated, or if its a brand-new installation |
|
440 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
441 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
442 | - // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
443 | - switch ($request_type) { |
|
444 | - case EE_System::req_type_new_activation: |
|
445 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
446 | - $this->_handle_core_version_change($espresso_db_update); |
|
447 | - break; |
|
448 | - case EE_System::req_type_reactivation: |
|
449 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
450 | - $this->_handle_core_version_change($espresso_db_update); |
|
451 | - break; |
|
452 | - case EE_System::req_type_upgrade: |
|
453 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
454 | - // migrations may be required now that we've upgraded |
|
455 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
456 | - $this->_handle_core_version_change($espresso_db_update); |
|
457 | - break; |
|
458 | - case EE_System::req_type_downgrade: |
|
459 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
460 | - // its possible migrations are no longer required |
|
461 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
462 | - $this->_handle_core_version_change($espresso_db_update); |
|
463 | - break; |
|
464 | - case EE_System::req_type_normal: |
|
465 | - default: |
|
466 | - break; |
|
467 | - } |
|
468 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
469 | - } |
|
470 | - |
|
471 | - |
|
472 | - /** |
|
473 | - * Updates the list of installed versions and sets hooks for |
|
474 | - * initializing the database later during the request |
|
475 | - * |
|
476 | - * @param array $espresso_db_update |
|
477 | - */ |
|
478 | - private function _handle_core_version_change($espresso_db_update) |
|
479 | - { |
|
480 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
481 | - // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
482 | - add_action( |
|
483 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
484 | - array($this, 'initialize_db_if_no_migrations_required') |
|
485 | - ); |
|
486 | - } |
|
487 | - |
|
488 | - |
|
489 | - /** |
|
490 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
491 | - * information about what versions of EE have been installed and activated, |
|
492 | - * NOT necessarily the state of the database |
|
493 | - * |
|
494 | - * @param mixed $espresso_db_update the value of the WordPress option. |
|
495 | - * If not supplied, fetches it from the options table |
|
496 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
497 | - */ |
|
498 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
499 | - { |
|
500 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
501 | - if (! $espresso_db_update) { |
|
502 | - $espresso_db_update = get_option('espresso_db_update'); |
|
503 | - } |
|
504 | - // check that option is an array |
|
505 | - if (! is_array($espresso_db_update)) { |
|
506 | - // if option is FALSE, then it never existed |
|
507 | - if ($espresso_db_update === false) { |
|
508 | - // make $espresso_db_update an array and save option with autoload OFF |
|
509 | - $espresso_db_update = array(); |
|
510 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
511 | - } else { |
|
512 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
513 | - $espresso_db_update = array($espresso_db_update => array()); |
|
514 | - update_option('espresso_db_update', $espresso_db_update); |
|
515 | - } |
|
516 | - } else { |
|
517 | - $corrected_db_update = array(); |
|
518 | - // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
519 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
520 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
521 | - // the key is an int, and the value IS NOT an array |
|
522 | - // so it must be numerically-indexed, where values are versions installed... |
|
523 | - // fix it! |
|
524 | - $version_string = $should_be_array; |
|
525 | - $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
526 | - } else { |
|
527 | - // ok it checks out |
|
528 | - $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
529 | - } |
|
530 | - } |
|
531 | - $espresso_db_update = $corrected_db_update; |
|
532 | - update_option('espresso_db_update', $espresso_db_update); |
|
533 | - } |
|
534 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
535 | - return $espresso_db_update; |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
541 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
542 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
543 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
544 | - * so that it will be done when migrations are finished |
|
545 | - * |
|
546 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
547 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
548 | - * This is a resource-intensive job |
|
549 | - * so we prefer to only do it when necessary |
|
550 | - * @return void |
|
551 | - * @throws EE_Error |
|
552 | - */ |
|
553 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
554 | - { |
|
555 | - $request_type = $this->detect_req_type(); |
|
556 | - // only initialize system if we're not in maintenance mode. |
|
557 | - if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
558 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
559 | - $rewrite_rules = $this->loader->getShared( |
|
560 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
561 | - ); |
|
562 | - $rewrite_rules->flush(); |
|
563 | - if ($verify_schema) { |
|
564 | - EEH_Activation::initialize_db_and_folders(); |
|
565 | - } |
|
566 | - EEH_Activation::initialize_db_content(); |
|
567 | - EEH_Activation::system_initialization(); |
|
568 | - if ($initialize_addons_too) { |
|
569 | - $this->initialize_addons(); |
|
570 | - } |
|
571 | - } else { |
|
572 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
573 | - } |
|
574 | - if ($request_type === EE_System::req_type_new_activation |
|
575 | - || $request_type === EE_System::req_type_reactivation |
|
576 | - || ( |
|
577 | - $request_type === EE_System::req_type_upgrade |
|
578 | - && $this->is_major_version_change() |
|
579 | - ) |
|
580 | - ) { |
|
581 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
582 | - } |
|
583 | - } |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * Initializes the db for all registered addons |
|
588 | - * |
|
589 | - * @throws EE_Error |
|
590 | - */ |
|
591 | - public function initialize_addons() |
|
592 | - { |
|
593 | - // foreach registered addon, make sure its db is up-to-date too |
|
594 | - foreach ($this->registry->addons as $addon) { |
|
595 | - if ($addon instanceof EE_Addon) { |
|
596 | - $addon->initialize_db_if_no_migrations_required(); |
|
597 | - } |
|
598 | - } |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - /** |
|
603 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
604 | - * |
|
605 | - * @param array $version_history |
|
606 | - * @param string $current_version_to_add version to be added to the version history |
|
607 | - * @return boolean success as to whether or not this option was changed |
|
608 | - */ |
|
609 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
610 | - { |
|
611 | - if (! $version_history) { |
|
612 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
613 | - } |
|
614 | - if ($current_version_to_add === null) { |
|
615 | - $current_version_to_add = espresso_version(); |
|
616 | - } |
|
617 | - $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
618 | - // re-save |
|
619 | - return update_option('espresso_db_update', $version_history); |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - /** |
|
624 | - * Detects if the current version indicated in the has existed in the list of |
|
625 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
626 | - * |
|
627 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
628 | - * If not supplied, fetches it from the options table. |
|
629 | - * Also, caches its result so later parts of the code can also know whether |
|
630 | - * there's been an update or not. This way we can add the current version to |
|
631 | - * espresso_db_update, but still know if this is a new install or not |
|
632 | - * @return int one of the constants on EE_System::req_type_ |
|
633 | - */ |
|
634 | - public function detect_req_type($espresso_db_update = null) |
|
635 | - { |
|
636 | - if ($this->_req_type === null) { |
|
637 | - $espresso_db_update = ! empty($espresso_db_update) |
|
638 | - ? $espresso_db_update |
|
639 | - : $this->fix_espresso_db_upgrade_option(); |
|
640 | - $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
641 | - $espresso_db_update, |
|
642 | - 'ee_espresso_activation', |
|
643 | - espresso_version() |
|
644 | - ); |
|
645 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
646 | - $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
647 | - } |
|
648 | - return $this->_req_type; |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - /** |
|
653 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
654 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
655 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
656 | - * |
|
657 | - * @param $activation_history |
|
658 | - * @return bool |
|
659 | - */ |
|
660 | - private function _detect_major_version_change($activation_history) |
|
661 | - { |
|
662 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
663 | - $previous_version_parts = explode('.', $previous_version); |
|
664 | - $current_version_parts = explode('.', espresso_version()); |
|
665 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
666 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
667 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
668 | - ); |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * Returns true if either the major or minor version of EE changed during this request. |
|
674 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
675 | - * |
|
676 | - * @return bool |
|
677 | - */ |
|
678 | - public function is_major_version_change() |
|
679 | - { |
|
680 | - return $this->_major_version_change; |
|
681 | - } |
|
682 | - |
|
683 | - |
|
684 | - /** |
|
685 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
686 | - * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
687 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
688 | - * just activated to (for core that will always be espresso_version()) |
|
689 | - * |
|
690 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
691 | - * ee plugin. for core that's 'espresso_db_update' |
|
692 | - * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
693 | - * indicate that this plugin was just activated |
|
694 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
695 | - * espresso_version()) |
|
696 | - * @return int one of the constants on EE_System::req_type_* |
|
697 | - */ |
|
698 | - public static function detect_req_type_given_activation_history( |
|
699 | - $activation_history_for_addon, |
|
700 | - $activation_indicator_option_name, |
|
701 | - $version_to_upgrade_to |
|
702 | - ) { |
|
703 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
704 | - if ($activation_history_for_addon) { |
|
705 | - // it exists, so this isn't a completely new install |
|
706 | - // check if this version already in that list of previously installed versions |
|
707 | - if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
708 | - // it a version we haven't seen before |
|
709 | - if ($version_is_higher === 1) { |
|
710 | - $req_type = EE_System::req_type_upgrade; |
|
711 | - } else { |
|
712 | - $req_type = EE_System::req_type_downgrade; |
|
713 | - } |
|
714 | - delete_option($activation_indicator_option_name); |
|
715 | - } else { |
|
716 | - // its not an update. maybe a reactivation? |
|
717 | - if (get_option($activation_indicator_option_name, false)) { |
|
718 | - if ($version_is_higher === -1) { |
|
719 | - $req_type = EE_System::req_type_downgrade; |
|
720 | - } elseif ($version_is_higher === 0) { |
|
721 | - // we've seen this version before, but it's an activation. must be a reactivation |
|
722 | - $req_type = EE_System::req_type_reactivation; |
|
723 | - } else {// $version_is_higher === 1 |
|
724 | - $req_type = EE_System::req_type_upgrade; |
|
725 | - } |
|
726 | - delete_option($activation_indicator_option_name); |
|
727 | - } else { |
|
728 | - // we've seen this version before and the activation indicate doesn't show it was just activated |
|
729 | - if ($version_is_higher === -1) { |
|
730 | - $req_type = EE_System::req_type_downgrade; |
|
731 | - } elseif ($version_is_higher === 0) { |
|
732 | - // we've seen this version before and it's not an activation. its normal request |
|
733 | - $req_type = EE_System::req_type_normal; |
|
734 | - } else {// $version_is_higher === 1 |
|
735 | - $req_type = EE_System::req_type_upgrade; |
|
736 | - } |
|
737 | - } |
|
738 | - } |
|
739 | - } else { |
|
740 | - // brand new install |
|
741 | - $req_type = EE_System::req_type_new_activation; |
|
742 | - delete_option($activation_indicator_option_name); |
|
743 | - } |
|
744 | - return $req_type; |
|
745 | - } |
|
746 | - |
|
747 | - |
|
748 | - /** |
|
749 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
750 | - * the $activation_history_for_addon |
|
751 | - * |
|
752 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
753 | - * sometimes containing 'unknown-date' |
|
754 | - * @param string $version_to_upgrade_to (current version) |
|
755 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
756 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
757 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
758 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
759 | - */ |
|
760 | - private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
761 | - { |
|
762 | - // find the most recently-activated version |
|
763 | - $most_recently_active_version = |
|
764 | - EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
765 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
766 | - } |
|
767 | - |
|
768 | - |
|
769 | - /** |
|
770 | - * Gets the most recently active version listed in the activation history, |
|
771 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
772 | - * |
|
773 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
774 | - * sometimes containing 'unknown-date' |
|
775 | - * @return string |
|
776 | - */ |
|
777 | - private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
778 | - { |
|
779 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
780 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
781 | - if (is_array($activation_history)) { |
|
782 | - foreach ($activation_history as $version => $times_activated) { |
|
783 | - // check there is a record of when this version was activated. Otherwise, |
|
784 | - // mark it as unknown |
|
785 | - if (! $times_activated) { |
|
786 | - $times_activated = array('unknown-date'); |
|
787 | - } |
|
788 | - if (is_string($times_activated)) { |
|
789 | - $times_activated = array($times_activated); |
|
790 | - } |
|
791 | - foreach ($times_activated as $an_activation) { |
|
792 | - if ($an_activation !== 'unknown-date' |
|
793 | - && $an_activation |
|
794 | - > $most_recently_active_version_activation) { |
|
795 | - $most_recently_active_version = $version; |
|
796 | - $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
797 | - ? '1970-01-01 00:00:00' |
|
798 | - : $an_activation; |
|
799 | - } |
|
800 | - } |
|
801 | - } |
|
802 | - } |
|
803 | - return $most_recently_active_version; |
|
804 | - } |
|
805 | - |
|
806 | - |
|
807 | - /** |
|
808 | - * This redirects to the about EE page after activation |
|
809 | - * |
|
810 | - * @return void |
|
811 | - */ |
|
812 | - public function redirect_to_about_ee() |
|
813 | - { |
|
814 | - $notices = EE_Error::get_notices(false); |
|
815 | - // if current user is an admin and it's not an ajax or rest request |
|
816 | - if (! isset($notices['errors']) |
|
817 | - && $this->request->isAdmin() |
|
818 | - && apply_filters( |
|
819 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
820 | - $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
821 | - ) |
|
822 | - ) { |
|
823 | - $query_params = array('page' => 'espresso_about'); |
|
824 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
825 | - $query_params['new_activation'] = true; |
|
826 | - } |
|
827 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
828 | - $query_params['reactivation'] = true; |
|
829 | - } |
|
830 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
831 | - wp_safe_redirect($url); |
|
832 | - exit(); |
|
833 | - } |
|
834 | - } |
|
835 | - |
|
836 | - |
|
837 | - /** |
|
838 | - * load_core_configuration |
|
839 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
840 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
841 | - * |
|
842 | - * @return void |
|
843 | - * @throws ReflectionException |
|
844 | - * @throws Exception |
|
845 | - */ |
|
846 | - public function load_core_configuration() |
|
847 | - { |
|
848 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
849 | - $this->loader->getShared('EE_Load_Textdomain'); |
|
850 | - // load textdomain |
|
851 | - EE_Load_Textdomain::load_textdomain(); |
|
852 | - // load caf stuff a chance to play during the activation process too. |
|
853 | - $this->_maybe_brew_regular(); |
|
854 | - // load and setup EE_Config and EE_Network_Config |
|
855 | - $config = $this->loader->getShared('EE_Config'); |
|
856 | - $this->loader->getShared('EE_Network_Config'); |
|
857 | - // setup autoloaders |
|
858 | - // enable logging? |
|
859 | - if ($config->admin->use_remote_logging) { |
|
860 | - $this->loader->getShared('EE_Log'); |
|
861 | - } |
|
862 | - // check for activation errors |
|
863 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
864 | - if ($activation_errors) { |
|
865 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
866 | - update_option('ee_plugin_activation_errors', false); |
|
867 | - } |
|
868 | - // get model names |
|
869 | - $this->_parse_model_names(); |
|
870 | - // configure custom post type definitions |
|
871 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
872 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
873 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
874 | - } |
|
875 | - |
|
876 | - |
|
877 | - /** |
|
878 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
879 | - * |
|
880 | - * @return void |
|
881 | - * @throws ReflectionException |
|
882 | - */ |
|
883 | - private function _parse_model_names() |
|
884 | - { |
|
885 | - // get all the files in the EE_MODELS folder that end in .model.php |
|
886 | - $models = glob(EE_MODELS . '*.model.php'); |
|
887 | - $model_names = array(); |
|
888 | - $non_abstract_db_models = array(); |
|
889 | - foreach ($models as $model) { |
|
890 | - // get model classname |
|
891 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
892 | - $short_name = str_replace('EEM_', '', $classname); |
|
893 | - $reflectionClass = new ReflectionClass($classname); |
|
894 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
895 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
896 | - } |
|
897 | - $model_names[ $short_name ] = $classname; |
|
898 | - } |
|
899 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
900 | - $this->registry->non_abstract_db_models = apply_filters( |
|
901 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
902 | - $non_abstract_db_models |
|
903 | - ); |
|
904 | - } |
|
905 | - |
|
906 | - |
|
907 | - /** |
|
908 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
909 | - * that need to be setup before our EE_System launches. |
|
910 | - * |
|
911 | - * @return void |
|
912 | - * @throws DomainException |
|
913 | - * @throws InvalidArgumentException |
|
914 | - * @throws InvalidDataTypeException |
|
915 | - * @throws InvalidInterfaceException |
|
916 | - * @throws InvalidClassException |
|
917 | - * @throws InvalidFilePathException |
|
918 | - */ |
|
919 | - private function _maybe_brew_regular() |
|
920 | - { |
|
921 | - /** @var Domain $domain */ |
|
922 | - $domain = DomainFactory::getShared( |
|
923 | - new FullyQualifiedName( |
|
924 | - 'EventEspresso\core\domain\Domain' |
|
925 | - ), |
|
926 | - array( |
|
927 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
928 | - Version::fromString(espresso_version()), |
|
929 | - ) |
|
930 | - ); |
|
931 | - if ($domain->isCaffeinated()) { |
|
932 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
933 | - } |
|
934 | - } |
|
935 | - |
|
936 | - |
|
937 | - /** |
|
938 | - * @since 4.9.71.p |
|
939 | - * @throws Exception |
|
940 | - */ |
|
941 | - public function loadRouteMatchSpecifications() |
|
942 | - { |
|
943 | - try { |
|
944 | - $this->loader->getShared( |
|
945 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' |
|
946 | - ); |
|
947 | - } catch (Exception $exception) { |
|
948 | - new ExceptionStackTraceDisplay($exception); |
|
949 | - } |
|
950 | - do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
951 | - } |
|
952 | - |
|
953 | - |
|
954 | - /** |
|
955 | - * register_shortcodes_modules_and_widgets |
|
956 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
957 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
958 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
959 | - * |
|
960 | - * @access public |
|
961 | - * @return void |
|
962 | - * @throws Exception |
|
963 | - */ |
|
964 | - public function register_shortcodes_modules_and_widgets() |
|
965 | - { |
|
966 | - if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) { |
|
967 | - try { |
|
968 | - // load, register, and add shortcodes the new way |
|
969 | - $this->loader->getShared( |
|
970 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager', |
|
971 | - array( |
|
972 | - // and the old way, but we'll put it under control of the new system |
|
973 | - EE_Config::getLegacyShortcodesManager(), |
|
974 | - ) |
|
975 | - ); |
|
976 | - } catch (Exception $exception) { |
|
977 | - new ExceptionStackTraceDisplay($exception); |
|
978 | - } |
|
979 | - } |
|
980 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
981 | - // check for addons using old hook point |
|
982 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
983 | - $this->_incompatible_addon_error(); |
|
984 | - } |
|
985 | - } |
|
986 | - |
|
987 | - |
|
988 | - /** |
|
989 | - * _incompatible_addon_error |
|
990 | - * |
|
991 | - * @access public |
|
992 | - * @return void |
|
993 | - */ |
|
994 | - private function _incompatible_addon_error() |
|
995 | - { |
|
996 | - // get array of classes hooking into here |
|
997 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
998 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
999 | - ); |
|
1000 | - if (! empty($class_names)) { |
|
1001 | - $msg = __( |
|
1002 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
1003 | - 'event_espresso' |
|
1004 | - ); |
|
1005 | - $msg .= '<ul>'; |
|
1006 | - foreach ($class_names as $class_name) { |
|
1007 | - $msg .= '<li><b>Event Espresso - ' |
|
1008 | - . str_replace( |
|
1009 | - array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
1010 | - '', |
|
1011 | - $class_name |
|
1012 | - ) . '</b></li>'; |
|
1013 | - } |
|
1014 | - $msg .= '</ul>'; |
|
1015 | - $msg .= __( |
|
1016 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
1017 | - 'event_espresso' |
|
1018 | - ); |
|
1019 | - // save list of incompatible addons to wp-options for later use |
|
1020 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
1021 | - if (is_admin()) { |
|
1022 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1023 | - } |
|
1024 | - } |
|
1025 | - } |
|
1026 | - |
|
1027 | - |
|
1028 | - /** |
|
1029 | - * brew_espresso |
|
1030 | - * begins the process of setting hooks for initializing EE in the correct order |
|
1031 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
1032 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
1033 | - * |
|
1034 | - * @return void |
|
1035 | - */ |
|
1036 | - public function brew_espresso() |
|
1037 | - { |
|
1038 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
1039 | - // load some final core systems |
|
1040 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
1041 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
1042 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
1043 | - add_action('init', array($this, 'load_controllers'), 7); |
|
1044 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
1045 | - add_action('init', array($this, 'initialize'), 10); |
|
1046 | - add_action('init', array($this, 'initialize_last'), 100); |
|
1047 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
1048 | - // pew pew pew |
|
1049 | - $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService'); |
|
1050 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
1051 | - } |
|
1052 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
1053 | - } |
|
1054 | - |
|
1055 | - |
|
1056 | - /** |
|
1057 | - * set_hooks_for_core |
|
1058 | - * |
|
1059 | - * @access public |
|
1060 | - * @return void |
|
1061 | - * @throws EE_Error |
|
1062 | - */ |
|
1063 | - public function set_hooks_for_core() |
|
1064 | - { |
|
1065 | - $this->_deactivate_incompatible_addons(); |
|
1066 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
1067 | - $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
1068 | - // caps need to be initialized on every request so that capability maps are set. |
|
1069 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
1070 | - $this->registry->CAP->init_caps(); |
|
1071 | - } |
|
1072 | - |
|
1073 | - |
|
1074 | - /** |
|
1075 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
1076 | - * deactivates any addons considered incompatible with the current version of EE |
|
1077 | - */ |
|
1078 | - private function _deactivate_incompatible_addons() |
|
1079 | - { |
|
1080 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
1081 | - if (! empty($incompatible_addons)) { |
|
1082 | - $active_plugins = get_option('active_plugins', array()); |
|
1083 | - foreach ($active_plugins as $active_plugin) { |
|
1084 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
1085 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
1086 | - unset($_GET['activate']); |
|
1087 | - espresso_deactivate_plugin($active_plugin); |
|
1088 | - } |
|
1089 | - } |
|
1090 | - } |
|
1091 | - } |
|
1092 | - } |
|
1093 | - |
|
1094 | - |
|
1095 | - /** |
|
1096 | - * perform_activations_upgrades_and_migrations |
|
1097 | - * |
|
1098 | - * @access public |
|
1099 | - * @return void |
|
1100 | - */ |
|
1101 | - public function perform_activations_upgrades_and_migrations() |
|
1102 | - { |
|
1103 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
1104 | - } |
|
1105 | - |
|
1106 | - |
|
1107 | - /** |
|
1108 | - * @return void |
|
1109 | - * @throws DomainException |
|
1110 | - */ |
|
1111 | - public function load_CPTs_and_session() |
|
1112 | - { |
|
1113 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
1114 | - /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */ |
|
1115 | - $register_custom_taxonomies = $this->loader->getShared( |
|
1116 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
1117 | - ); |
|
1118 | - $register_custom_taxonomies->registerCustomTaxonomies(); |
|
1119 | - /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */ |
|
1120 | - $register_custom_post_types = $this->loader->getShared( |
|
1121 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
1122 | - ); |
|
1123 | - $register_custom_post_types->registerCustomPostTypes(); |
|
1124 | - /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */ |
|
1125 | - $register_custom_taxonomy_terms = $this->loader->getShared( |
|
1126 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
1127 | - ); |
|
1128 | - $register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
1129 | - // load legacy Custom Post Types and Taxonomies |
|
1130 | - $this->loader->getShared('EE_Register_CPTs'); |
|
1131 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
1132 | - } |
|
1133 | - |
|
1134 | - |
|
1135 | - /** |
|
1136 | - * load_controllers |
|
1137 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
1138 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
1139 | - * time |
|
1140 | - * |
|
1141 | - * @access public |
|
1142 | - * @return void |
|
1143 | - */ |
|
1144 | - public function load_controllers() |
|
1145 | - { |
|
1146 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
1147 | - // let's get it started |
|
1148 | - if (! $this->maintenance_mode->level() |
|
1149 | - && ($this->request->isFrontend() || $this->request->isFrontAjax()) |
|
1150 | - ) { |
|
1151 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
1152 | - $this->loader->getShared('EE_Front_Controller'); |
|
1153 | - } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
1154 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
1155 | - $this->loader->getShared('EE_Admin'); |
|
1156 | - } elseif ($this->request->isWordPressHeartbeat()) { |
|
1157 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
1158 | - } |
|
1159 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
1160 | - } |
|
1161 | - |
|
1162 | - |
|
1163 | - /** |
|
1164 | - * core_loaded_and_ready |
|
1165 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1166 | - * |
|
1167 | - * @access public |
|
1168 | - * @return void |
|
1169 | - * @throws Exception |
|
1170 | - */ |
|
1171 | - public function core_loaded_and_ready() |
|
1172 | - { |
|
1173 | - if ($this->request->isAdmin() |
|
1174 | - || $this->request->isFrontend() |
|
1175 | - || $this->request->isIframe() |
|
1176 | - || $this->request->isWordPressApi() |
|
1177 | - ) { |
|
1178 | - try { |
|
1179 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
1180 | - $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
1181 | - if ($this->canLoadBlocks()) { |
|
1182 | - $this->loader->getShared( |
|
1183 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
1184 | - ); |
|
1185 | - } |
|
1186 | - } catch (Exception $exception) { |
|
1187 | - new ExceptionStackTraceDisplay($exception); |
|
1188 | - } |
|
1189 | - } |
|
1190 | - if ($this->request->isAdmin() |
|
1191 | - || $this->request->isEeAjax() |
|
1192 | - || $this->request->isFrontend() |
|
1193 | - ) { |
|
1194 | - $this->loader->getShared('EE_Session'); |
|
1195 | - } |
|
1196 | - // integrate WP_Query with the EE models |
|
1197 | - $this->loader->getShared('EE_CPT_Strategy'); |
|
1198 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
1199 | - // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
1200 | - // builders require these even on the front-end |
|
1201 | - require_once EE_PUBLIC . 'template_tags.php'; |
|
1202 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
1203 | - } |
|
1204 | - |
|
1205 | - |
|
1206 | - /** |
|
1207 | - * initialize |
|
1208 | - * this is the best place to begin initializing client code |
|
1209 | - * |
|
1210 | - * @access public |
|
1211 | - * @return void |
|
1212 | - */ |
|
1213 | - public function initialize() |
|
1214 | - { |
|
1215 | - do_action('AHEE__EE_System__initialize'); |
|
1216 | - } |
|
1217 | - |
|
1218 | - |
|
1219 | - /** |
|
1220 | - * initialize_last |
|
1221 | - * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
1222 | - * initialize has done so |
|
1223 | - * |
|
1224 | - * @access public |
|
1225 | - * @return void |
|
1226 | - */ |
|
1227 | - public function initialize_last() |
|
1228 | - { |
|
1229 | - do_action('AHEE__EE_System__initialize_last'); |
|
1230 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
1231 | - $rewrite_rules = $this->loader->getShared( |
|
1232 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
1233 | - ); |
|
1234 | - $rewrite_rules->flushRewriteRules(); |
|
1235 | - add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
1236 | - if (($this->request->isAjax() || $this->request->isAdmin()) |
|
1237 | - && $this->maintenance_mode->models_can_query()) { |
|
1238 | - $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
1239 | - $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
1240 | - } |
|
1241 | - } |
|
1242 | - |
|
1243 | - |
|
1244 | - /** |
|
1245 | - * @return void |
|
1246 | - * @throws EE_Error |
|
1247 | - */ |
|
1248 | - public function addEspressoToolbar() |
|
1249 | - { |
|
1250 | - $this->loader->getShared( |
|
1251 | - 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
1252 | - array($this->registry->CAP) |
|
1253 | - ); |
|
1254 | - } |
|
1255 | - |
|
1256 | - |
|
1257 | - /** |
|
1258 | - * do_not_cache |
|
1259 | - * sets no cache headers and defines no cache constants for WP plugins |
|
1260 | - * |
|
1261 | - * @access public |
|
1262 | - * @return void |
|
1263 | - */ |
|
1264 | - public static function do_not_cache() |
|
1265 | - { |
|
1266 | - // set no cache constants |
|
1267 | - if (! defined('DONOTCACHEPAGE')) { |
|
1268 | - define('DONOTCACHEPAGE', true); |
|
1269 | - } |
|
1270 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
1271 | - define('DONOTCACHCEOBJECT', true); |
|
1272 | - } |
|
1273 | - if (! defined('DONOTCACHEDB')) { |
|
1274 | - define('DONOTCACHEDB', true); |
|
1275 | - } |
|
1276 | - // add no cache headers |
|
1277 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1278 | - // plus a little extra for nginx and Google Chrome |
|
1279 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1280 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1281 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1282 | - } |
|
1283 | - |
|
1284 | - |
|
1285 | - /** |
|
1286 | - * extra_nocache_headers |
|
1287 | - * |
|
1288 | - * @access public |
|
1289 | - * @param $headers |
|
1290 | - * @return array |
|
1291 | - */ |
|
1292 | - public static function extra_nocache_headers($headers) |
|
1293 | - { |
|
1294 | - // for NGINX |
|
1295 | - $headers['X-Accel-Expires'] = 0; |
|
1296 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1297 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1298 | - return $headers; |
|
1299 | - } |
|
1300 | - |
|
1301 | - |
|
1302 | - /** |
|
1303 | - * nocache_headers |
|
1304 | - * |
|
1305 | - * @access public |
|
1306 | - * @return void |
|
1307 | - */ |
|
1308 | - public static function nocache_headers() |
|
1309 | - { |
|
1310 | - nocache_headers(); |
|
1311 | - } |
|
1312 | - |
|
1313 | - |
|
1314 | - /** |
|
1315 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1316 | - * never returned with the function. |
|
1317 | - * |
|
1318 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1319 | - * @return array |
|
1320 | - */ |
|
1321 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1322 | - { |
|
1323 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1324 | - } |
|
1325 | - |
|
1326 | - |
|
1327 | - /** |
|
1328 | - * Return whether blocks can be registered/loaded or not. |
|
1329 | - * @return bool |
|
1330 | - */ |
|
1331 | - private function canLoadBlocks() |
|
1332 | - { |
|
1333 | - return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
1334 | - && function_exists('register_block_type') |
|
1335 | - // don't load blocks if in the Divi page builder editor context |
|
1336 | - // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
1337 | - && ! $this->request->getRequestParam('et_fb', false); |
|
1338 | - } |
|
30 | + /** |
|
31 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
32 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
33 | + */ |
|
34 | + const req_type_normal = 0; |
|
35 | + |
|
36 | + /** |
|
37 | + * Indicates this is a brand new installation of EE so we should install |
|
38 | + * tables and default data etc |
|
39 | + */ |
|
40 | + const req_type_new_activation = 1; |
|
41 | + |
|
42 | + /** |
|
43 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
44 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
45 | + * and that default data is setup too |
|
46 | + */ |
|
47 | + const req_type_reactivation = 2; |
|
48 | + |
|
49 | + /** |
|
50 | + * indicates that EE has been upgraded since its previous request. |
|
51 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
52 | + */ |
|
53 | + const req_type_upgrade = 3; |
|
54 | + |
|
55 | + /** |
|
56 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
57 | + */ |
|
58 | + const req_type_downgrade = 4; |
|
59 | + |
|
60 | + /** |
|
61 | + * @deprecated since version 4.6.0.dev.006 |
|
62 | + * Now whenever a new_activation is detected the request type is still just |
|
63 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
64 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
65 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
66 | + * (Specifically, when the migration manager indicates migrations are finished |
|
67 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
68 | + */ |
|
69 | + const req_type_activation_but_not_installed = 5; |
|
70 | + |
|
71 | + /** |
|
72 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
73 | + */ |
|
74 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var EE_System $_instance |
|
78 | + */ |
|
79 | + private static $_instance; |
|
80 | + |
|
81 | + /** |
|
82 | + * @var EE_Registry $registry |
|
83 | + */ |
|
84 | + private $registry; |
|
85 | + |
|
86 | + /** |
|
87 | + * @var LoaderInterface $loader |
|
88 | + */ |
|
89 | + private $loader; |
|
90 | + |
|
91 | + /** |
|
92 | + * @var EE_Capabilities $capabilities |
|
93 | + */ |
|
94 | + private $capabilities; |
|
95 | + |
|
96 | + /** |
|
97 | + * @var RequestInterface $request |
|
98 | + */ |
|
99 | + private $request; |
|
100 | + |
|
101 | + /** |
|
102 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
103 | + */ |
|
104 | + private $maintenance_mode; |
|
105 | + |
|
106 | + /** |
|
107 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
108 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
109 | + * |
|
110 | + * @var int $_req_type |
|
111 | + */ |
|
112 | + private $_req_type; |
|
113 | + |
|
114 | + /** |
|
115 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
116 | + * |
|
117 | + * @var boolean $_major_version_change |
|
118 | + */ |
|
119 | + private $_major_version_change = false; |
|
120 | + |
|
121 | + /** |
|
122 | + * A Context DTO dedicated solely to identifying the current request type. |
|
123 | + * |
|
124 | + * @var RequestTypeContextCheckerInterface $request_type |
|
125 | + */ |
|
126 | + private $request_type; |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * @singleton method used to instantiate class object |
|
131 | + * @param EE_Registry|null $registry |
|
132 | + * @param LoaderInterface|null $loader |
|
133 | + * @param RequestInterface|null $request |
|
134 | + * @param EE_Maintenance_Mode|null $maintenance_mode |
|
135 | + * @return EE_System |
|
136 | + */ |
|
137 | + public static function instance( |
|
138 | + EE_Registry $registry = null, |
|
139 | + LoaderInterface $loader = null, |
|
140 | + RequestInterface $request = null, |
|
141 | + EE_Maintenance_Mode $maintenance_mode = null |
|
142 | + ) { |
|
143 | + // check if class object is instantiated |
|
144 | + if (! self::$_instance instanceof EE_System) { |
|
145 | + self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
146 | + } |
|
147 | + return self::$_instance; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * resets the instance and returns it |
|
153 | + * |
|
154 | + * @return EE_System |
|
155 | + */ |
|
156 | + public static function reset() |
|
157 | + { |
|
158 | + self::$_instance->_req_type = null; |
|
159 | + // make sure none of the old hooks are left hanging around |
|
160 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
161 | + // we need to reset the migration manager in order for it to detect DMSs properly |
|
162 | + EE_Data_Migration_Manager::reset(); |
|
163 | + self::instance()->detect_activations_or_upgrades(); |
|
164 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
165 | + return self::instance(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * sets hooks for running rest of system |
|
171 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
172 | + * starting EE Addons from any other point may lead to problems |
|
173 | + * |
|
174 | + * @param EE_Registry $registry |
|
175 | + * @param LoaderInterface $loader |
|
176 | + * @param RequestInterface $request |
|
177 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
178 | + */ |
|
179 | + private function __construct( |
|
180 | + EE_Registry $registry, |
|
181 | + LoaderInterface $loader, |
|
182 | + RequestInterface $request, |
|
183 | + EE_Maintenance_Mode $maintenance_mode |
|
184 | + ) { |
|
185 | + $this->registry = $registry; |
|
186 | + $this->loader = $loader; |
|
187 | + $this->request = $request; |
|
188 | + $this->maintenance_mode = $maintenance_mode; |
|
189 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
190 | + add_action( |
|
191 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
192 | + array($this, 'loadCapabilities'), |
|
193 | + 5 |
|
194 | + ); |
|
195 | + add_action( |
|
196 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
197 | + array($this, 'loadCommandBus'), |
|
198 | + 7 |
|
199 | + ); |
|
200 | + add_action( |
|
201 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
202 | + array($this, 'loadPluginApi'), |
|
203 | + 9 |
|
204 | + ); |
|
205 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
206 | + add_action( |
|
207 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
208 | + array($this, 'load_espresso_addons') |
|
209 | + ); |
|
210 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
211 | + // because the newly-activated addon didn't get a chance to run at all |
|
212 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
213 | + // detect whether install or upgrade |
|
214 | + add_action( |
|
215 | + 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
216 | + array($this, 'detect_activations_or_upgrades'), |
|
217 | + 3 |
|
218 | + ); |
|
219 | + // load EE_Config, EE_Textdomain, etc |
|
220 | + add_action( |
|
221 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
222 | + array($this, 'load_core_configuration'), |
|
223 | + 5 |
|
224 | + ); |
|
225 | + // load specifications for matching routes to current request |
|
226 | + add_action( |
|
227 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
228 | + array($this, 'loadRouteMatchSpecifications') |
|
229 | + ); |
|
230 | + // load EE_Config, EE_Textdomain, etc |
|
231 | + add_action( |
|
232 | + 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
233 | + array($this, 'register_shortcodes_modules_and_widgets'), |
|
234 | + 7 |
|
235 | + ); |
|
236 | + // you wanna get going? I wanna get going... let's get going! |
|
237 | + add_action( |
|
238 | + 'AHEE__EE_Bootstrap__brew_espresso', |
|
239 | + array($this, 'brew_espresso'), |
|
240 | + 9 |
|
241 | + ); |
|
242 | + // other housekeeping |
|
243 | + // exclude EE critical pages from wp_list_pages |
|
244 | + add_filter( |
|
245 | + 'wp_list_pages_excludes', |
|
246 | + array($this, 'remove_pages_from_wp_list_pages'), |
|
247 | + 10 |
|
248 | + ); |
|
249 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
250 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
251 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * load and setup EE_Capabilities |
|
257 | + * |
|
258 | + * @return void |
|
259 | + * @throws EE_Error |
|
260 | + */ |
|
261 | + public function loadCapabilities() |
|
262 | + { |
|
263 | + $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
264 | + add_action( |
|
265 | + 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
266 | + function () { |
|
267 | + LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
268 | + } |
|
269 | + ); |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * create and cache the CommandBus, and also add middleware |
|
275 | + * The CapChecker middleware requires the use of EE_Capabilities |
|
276 | + * which is why we need to load the CommandBus after Caps are set up |
|
277 | + * |
|
278 | + * @return void |
|
279 | + * @throws EE_Error |
|
280 | + */ |
|
281 | + public function loadCommandBus() |
|
282 | + { |
|
283 | + $this->loader->getShared( |
|
284 | + 'CommandBusInterface', |
|
285 | + array( |
|
286 | + null, |
|
287 | + apply_filters( |
|
288 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
289 | + array( |
|
290 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
291 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
292 | + ) |
|
293 | + ), |
|
294 | + ) |
|
295 | + ); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * @return void |
|
301 | + * @throws EE_Error |
|
302 | + */ |
|
303 | + public function loadPluginApi() |
|
304 | + { |
|
305 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
306 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
307 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
308 | + $this->loader->getShared('EE_Request_Handler'); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * @param string $addon_name |
|
314 | + * @param string $version_constant |
|
315 | + * @param string $min_version_required |
|
316 | + * @param string $load_callback |
|
317 | + * @param string $plugin_file_constant |
|
318 | + * @return void |
|
319 | + */ |
|
320 | + private function deactivateIncompatibleAddon( |
|
321 | + $addon_name, |
|
322 | + $version_constant, |
|
323 | + $min_version_required, |
|
324 | + $load_callback, |
|
325 | + $plugin_file_constant |
|
326 | + ) { |
|
327 | + if (! defined($version_constant)) { |
|
328 | + return; |
|
329 | + } |
|
330 | + $addon_version = constant($version_constant); |
|
331 | + if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
332 | + remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
333 | + if (! function_exists('deactivate_plugins')) { |
|
334 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
335 | + } |
|
336 | + deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
337 | + unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
|
338 | + EE_Error::add_error( |
|
339 | + sprintf( |
|
340 | + esc_html__( |
|
341 | + 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
342 | + 'event_espresso' |
|
343 | + ), |
|
344 | + $addon_name, |
|
345 | + $min_version_required |
|
346 | + ), |
|
347 | + __FILE__, |
|
348 | + __FUNCTION__ . "({$addon_name})", |
|
349 | + __LINE__ |
|
350 | + ); |
|
351 | + EE_Error::get_notices(false, true); |
|
352 | + } |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * load_espresso_addons |
|
358 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
359 | + * this is hooked into both: |
|
360 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
361 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
362 | + * and the WP 'activate_plugin' hook point |
|
363 | + * |
|
364 | + * @access public |
|
365 | + * @return void |
|
366 | + */ |
|
367 | + public function load_espresso_addons() |
|
368 | + { |
|
369 | + $this->deactivateIncompatibleAddon( |
|
370 | + 'Wait Lists', |
|
371 | + 'EE_WAIT_LISTS_VERSION', |
|
372 | + '1.0.0.beta.074', |
|
373 | + 'load_espresso_wait_lists', |
|
374 | + 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
375 | + ); |
|
376 | + $this->deactivateIncompatibleAddon( |
|
377 | + 'Automated Upcoming Event Notifications', |
|
378 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
379 | + '1.0.0.beta.091', |
|
380 | + 'load_espresso_automated_upcoming_event_notification', |
|
381 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
382 | + ); |
|
383 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
384 | + // if the WP API basic auth plugin isn't already loaded, load it now. |
|
385 | + // We want it for mobile apps. Just include the entire plugin |
|
386 | + // also, don't load the basic auth when a plugin is getting activated, because |
|
387 | + // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
388 | + // and causes a fatal error |
|
389 | + if (($this->request->isWordPressApi() || $this->request->isApi()) |
|
390 | + && $this->request->getRequestParam('activate') !== 'true' |
|
391 | + && ! function_exists('json_basic_auth_handler') |
|
392 | + && ! function_exists('json_basic_auth_error') |
|
393 | + && ! in_array( |
|
394 | + $this->request->getRequestParam('action'), |
|
395 | + array('activate', 'activate-selected'), |
|
396 | + true |
|
397 | + ) |
|
398 | + ) { |
|
399 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
400 | + } |
|
401 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * detect_activations_or_upgrades |
|
407 | + * Checks for activation or upgrade of core first; |
|
408 | + * then also checks if any registered addons have been activated or upgraded |
|
409 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
410 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
411 | + * |
|
412 | + * @access public |
|
413 | + * @return void |
|
414 | + */ |
|
415 | + public function detect_activations_or_upgrades() |
|
416 | + { |
|
417 | + // first off: let's make sure to handle core |
|
418 | + $this->detect_if_activation_or_upgrade(); |
|
419 | + foreach ($this->registry->addons as $addon) { |
|
420 | + if ($addon instanceof EE_Addon) { |
|
421 | + // detect teh request type for that addon |
|
422 | + $addon->detect_activation_or_upgrade(); |
|
423 | + } |
|
424 | + } |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * detect_if_activation_or_upgrade |
|
430 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
431 | + * and either setting up the DB or setting up maintenance mode etc. |
|
432 | + * |
|
433 | + * @access public |
|
434 | + * @return void |
|
435 | + */ |
|
436 | + public function detect_if_activation_or_upgrade() |
|
437 | + { |
|
438 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
439 | + // check if db has been updated, or if its a brand-new installation |
|
440 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
441 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
442 | + // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
443 | + switch ($request_type) { |
|
444 | + case EE_System::req_type_new_activation: |
|
445 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
446 | + $this->_handle_core_version_change($espresso_db_update); |
|
447 | + break; |
|
448 | + case EE_System::req_type_reactivation: |
|
449 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
450 | + $this->_handle_core_version_change($espresso_db_update); |
|
451 | + break; |
|
452 | + case EE_System::req_type_upgrade: |
|
453 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
454 | + // migrations may be required now that we've upgraded |
|
455 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
456 | + $this->_handle_core_version_change($espresso_db_update); |
|
457 | + break; |
|
458 | + case EE_System::req_type_downgrade: |
|
459 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
460 | + // its possible migrations are no longer required |
|
461 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
462 | + $this->_handle_core_version_change($espresso_db_update); |
|
463 | + break; |
|
464 | + case EE_System::req_type_normal: |
|
465 | + default: |
|
466 | + break; |
|
467 | + } |
|
468 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
469 | + } |
|
470 | + |
|
471 | + |
|
472 | + /** |
|
473 | + * Updates the list of installed versions and sets hooks for |
|
474 | + * initializing the database later during the request |
|
475 | + * |
|
476 | + * @param array $espresso_db_update |
|
477 | + */ |
|
478 | + private function _handle_core_version_change($espresso_db_update) |
|
479 | + { |
|
480 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
481 | + // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
482 | + add_action( |
|
483 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
484 | + array($this, 'initialize_db_if_no_migrations_required') |
|
485 | + ); |
|
486 | + } |
|
487 | + |
|
488 | + |
|
489 | + /** |
|
490 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
491 | + * information about what versions of EE have been installed and activated, |
|
492 | + * NOT necessarily the state of the database |
|
493 | + * |
|
494 | + * @param mixed $espresso_db_update the value of the WordPress option. |
|
495 | + * If not supplied, fetches it from the options table |
|
496 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
497 | + */ |
|
498 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
499 | + { |
|
500 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
501 | + if (! $espresso_db_update) { |
|
502 | + $espresso_db_update = get_option('espresso_db_update'); |
|
503 | + } |
|
504 | + // check that option is an array |
|
505 | + if (! is_array($espresso_db_update)) { |
|
506 | + // if option is FALSE, then it never existed |
|
507 | + if ($espresso_db_update === false) { |
|
508 | + // make $espresso_db_update an array and save option with autoload OFF |
|
509 | + $espresso_db_update = array(); |
|
510 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
511 | + } else { |
|
512 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
513 | + $espresso_db_update = array($espresso_db_update => array()); |
|
514 | + update_option('espresso_db_update', $espresso_db_update); |
|
515 | + } |
|
516 | + } else { |
|
517 | + $corrected_db_update = array(); |
|
518 | + // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
519 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
520 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
521 | + // the key is an int, and the value IS NOT an array |
|
522 | + // so it must be numerically-indexed, where values are versions installed... |
|
523 | + // fix it! |
|
524 | + $version_string = $should_be_array; |
|
525 | + $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
526 | + } else { |
|
527 | + // ok it checks out |
|
528 | + $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
529 | + } |
|
530 | + } |
|
531 | + $espresso_db_update = $corrected_db_update; |
|
532 | + update_option('espresso_db_update', $espresso_db_update); |
|
533 | + } |
|
534 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
535 | + return $espresso_db_update; |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
541 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
542 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
543 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
544 | + * so that it will be done when migrations are finished |
|
545 | + * |
|
546 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
547 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
548 | + * This is a resource-intensive job |
|
549 | + * so we prefer to only do it when necessary |
|
550 | + * @return void |
|
551 | + * @throws EE_Error |
|
552 | + */ |
|
553 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
554 | + { |
|
555 | + $request_type = $this->detect_req_type(); |
|
556 | + // only initialize system if we're not in maintenance mode. |
|
557 | + if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
558 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
559 | + $rewrite_rules = $this->loader->getShared( |
|
560 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
561 | + ); |
|
562 | + $rewrite_rules->flush(); |
|
563 | + if ($verify_schema) { |
|
564 | + EEH_Activation::initialize_db_and_folders(); |
|
565 | + } |
|
566 | + EEH_Activation::initialize_db_content(); |
|
567 | + EEH_Activation::system_initialization(); |
|
568 | + if ($initialize_addons_too) { |
|
569 | + $this->initialize_addons(); |
|
570 | + } |
|
571 | + } else { |
|
572 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
573 | + } |
|
574 | + if ($request_type === EE_System::req_type_new_activation |
|
575 | + || $request_type === EE_System::req_type_reactivation |
|
576 | + || ( |
|
577 | + $request_type === EE_System::req_type_upgrade |
|
578 | + && $this->is_major_version_change() |
|
579 | + ) |
|
580 | + ) { |
|
581 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
582 | + } |
|
583 | + } |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * Initializes the db for all registered addons |
|
588 | + * |
|
589 | + * @throws EE_Error |
|
590 | + */ |
|
591 | + public function initialize_addons() |
|
592 | + { |
|
593 | + // foreach registered addon, make sure its db is up-to-date too |
|
594 | + foreach ($this->registry->addons as $addon) { |
|
595 | + if ($addon instanceof EE_Addon) { |
|
596 | + $addon->initialize_db_if_no_migrations_required(); |
|
597 | + } |
|
598 | + } |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + /** |
|
603 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
604 | + * |
|
605 | + * @param array $version_history |
|
606 | + * @param string $current_version_to_add version to be added to the version history |
|
607 | + * @return boolean success as to whether or not this option was changed |
|
608 | + */ |
|
609 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
610 | + { |
|
611 | + if (! $version_history) { |
|
612 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
613 | + } |
|
614 | + if ($current_version_to_add === null) { |
|
615 | + $current_version_to_add = espresso_version(); |
|
616 | + } |
|
617 | + $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
618 | + // re-save |
|
619 | + return update_option('espresso_db_update', $version_history); |
|
620 | + } |
|
621 | + |
|
622 | + |
|
623 | + /** |
|
624 | + * Detects if the current version indicated in the has existed in the list of |
|
625 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
626 | + * |
|
627 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
628 | + * If not supplied, fetches it from the options table. |
|
629 | + * Also, caches its result so later parts of the code can also know whether |
|
630 | + * there's been an update or not. This way we can add the current version to |
|
631 | + * espresso_db_update, but still know if this is a new install or not |
|
632 | + * @return int one of the constants on EE_System::req_type_ |
|
633 | + */ |
|
634 | + public function detect_req_type($espresso_db_update = null) |
|
635 | + { |
|
636 | + if ($this->_req_type === null) { |
|
637 | + $espresso_db_update = ! empty($espresso_db_update) |
|
638 | + ? $espresso_db_update |
|
639 | + : $this->fix_espresso_db_upgrade_option(); |
|
640 | + $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
641 | + $espresso_db_update, |
|
642 | + 'ee_espresso_activation', |
|
643 | + espresso_version() |
|
644 | + ); |
|
645 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
646 | + $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
647 | + } |
|
648 | + return $this->_req_type; |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + /** |
|
653 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
654 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
655 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
656 | + * |
|
657 | + * @param $activation_history |
|
658 | + * @return bool |
|
659 | + */ |
|
660 | + private function _detect_major_version_change($activation_history) |
|
661 | + { |
|
662 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
663 | + $previous_version_parts = explode('.', $previous_version); |
|
664 | + $current_version_parts = explode('.', espresso_version()); |
|
665 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
666 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
667 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
668 | + ); |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * Returns true if either the major or minor version of EE changed during this request. |
|
674 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
675 | + * |
|
676 | + * @return bool |
|
677 | + */ |
|
678 | + public function is_major_version_change() |
|
679 | + { |
|
680 | + return $this->_major_version_change; |
|
681 | + } |
|
682 | + |
|
683 | + |
|
684 | + /** |
|
685 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
686 | + * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
687 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
688 | + * just activated to (for core that will always be espresso_version()) |
|
689 | + * |
|
690 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
691 | + * ee plugin. for core that's 'espresso_db_update' |
|
692 | + * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
693 | + * indicate that this plugin was just activated |
|
694 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
695 | + * espresso_version()) |
|
696 | + * @return int one of the constants on EE_System::req_type_* |
|
697 | + */ |
|
698 | + public static function detect_req_type_given_activation_history( |
|
699 | + $activation_history_for_addon, |
|
700 | + $activation_indicator_option_name, |
|
701 | + $version_to_upgrade_to |
|
702 | + ) { |
|
703 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
704 | + if ($activation_history_for_addon) { |
|
705 | + // it exists, so this isn't a completely new install |
|
706 | + // check if this version already in that list of previously installed versions |
|
707 | + if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
708 | + // it a version we haven't seen before |
|
709 | + if ($version_is_higher === 1) { |
|
710 | + $req_type = EE_System::req_type_upgrade; |
|
711 | + } else { |
|
712 | + $req_type = EE_System::req_type_downgrade; |
|
713 | + } |
|
714 | + delete_option($activation_indicator_option_name); |
|
715 | + } else { |
|
716 | + // its not an update. maybe a reactivation? |
|
717 | + if (get_option($activation_indicator_option_name, false)) { |
|
718 | + if ($version_is_higher === -1) { |
|
719 | + $req_type = EE_System::req_type_downgrade; |
|
720 | + } elseif ($version_is_higher === 0) { |
|
721 | + // we've seen this version before, but it's an activation. must be a reactivation |
|
722 | + $req_type = EE_System::req_type_reactivation; |
|
723 | + } else {// $version_is_higher === 1 |
|
724 | + $req_type = EE_System::req_type_upgrade; |
|
725 | + } |
|
726 | + delete_option($activation_indicator_option_name); |
|
727 | + } else { |
|
728 | + // we've seen this version before and the activation indicate doesn't show it was just activated |
|
729 | + if ($version_is_higher === -1) { |
|
730 | + $req_type = EE_System::req_type_downgrade; |
|
731 | + } elseif ($version_is_higher === 0) { |
|
732 | + // we've seen this version before and it's not an activation. its normal request |
|
733 | + $req_type = EE_System::req_type_normal; |
|
734 | + } else {// $version_is_higher === 1 |
|
735 | + $req_type = EE_System::req_type_upgrade; |
|
736 | + } |
|
737 | + } |
|
738 | + } |
|
739 | + } else { |
|
740 | + // brand new install |
|
741 | + $req_type = EE_System::req_type_new_activation; |
|
742 | + delete_option($activation_indicator_option_name); |
|
743 | + } |
|
744 | + return $req_type; |
|
745 | + } |
|
746 | + |
|
747 | + |
|
748 | + /** |
|
749 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
750 | + * the $activation_history_for_addon |
|
751 | + * |
|
752 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
753 | + * sometimes containing 'unknown-date' |
|
754 | + * @param string $version_to_upgrade_to (current version) |
|
755 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
756 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
757 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
758 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
759 | + */ |
|
760 | + private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
761 | + { |
|
762 | + // find the most recently-activated version |
|
763 | + $most_recently_active_version = |
|
764 | + EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
765 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
766 | + } |
|
767 | + |
|
768 | + |
|
769 | + /** |
|
770 | + * Gets the most recently active version listed in the activation history, |
|
771 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
772 | + * |
|
773 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
774 | + * sometimes containing 'unknown-date' |
|
775 | + * @return string |
|
776 | + */ |
|
777 | + private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
778 | + { |
|
779 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
780 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
781 | + if (is_array($activation_history)) { |
|
782 | + foreach ($activation_history as $version => $times_activated) { |
|
783 | + // check there is a record of when this version was activated. Otherwise, |
|
784 | + // mark it as unknown |
|
785 | + if (! $times_activated) { |
|
786 | + $times_activated = array('unknown-date'); |
|
787 | + } |
|
788 | + if (is_string($times_activated)) { |
|
789 | + $times_activated = array($times_activated); |
|
790 | + } |
|
791 | + foreach ($times_activated as $an_activation) { |
|
792 | + if ($an_activation !== 'unknown-date' |
|
793 | + && $an_activation |
|
794 | + > $most_recently_active_version_activation) { |
|
795 | + $most_recently_active_version = $version; |
|
796 | + $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
797 | + ? '1970-01-01 00:00:00' |
|
798 | + : $an_activation; |
|
799 | + } |
|
800 | + } |
|
801 | + } |
|
802 | + } |
|
803 | + return $most_recently_active_version; |
|
804 | + } |
|
805 | + |
|
806 | + |
|
807 | + /** |
|
808 | + * This redirects to the about EE page after activation |
|
809 | + * |
|
810 | + * @return void |
|
811 | + */ |
|
812 | + public function redirect_to_about_ee() |
|
813 | + { |
|
814 | + $notices = EE_Error::get_notices(false); |
|
815 | + // if current user is an admin and it's not an ajax or rest request |
|
816 | + if (! isset($notices['errors']) |
|
817 | + && $this->request->isAdmin() |
|
818 | + && apply_filters( |
|
819 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
820 | + $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
821 | + ) |
|
822 | + ) { |
|
823 | + $query_params = array('page' => 'espresso_about'); |
|
824 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
825 | + $query_params['new_activation'] = true; |
|
826 | + } |
|
827 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
828 | + $query_params['reactivation'] = true; |
|
829 | + } |
|
830 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
831 | + wp_safe_redirect($url); |
|
832 | + exit(); |
|
833 | + } |
|
834 | + } |
|
835 | + |
|
836 | + |
|
837 | + /** |
|
838 | + * load_core_configuration |
|
839 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
840 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
841 | + * |
|
842 | + * @return void |
|
843 | + * @throws ReflectionException |
|
844 | + * @throws Exception |
|
845 | + */ |
|
846 | + public function load_core_configuration() |
|
847 | + { |
|
848 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
849 | + $this->loader->getShared('EE_Load_Textdomain'); |
|
850 | + // load textdomain |
|
851 | + EE_Load_Textdomain::load_textdomain(); |
|
852 | + // load caf stuff a chance to play during the activation process too. |
|
853 | + $this->_maybe_brew_regular(); |
|
854 | + // load and setup EE_Config and EE_Network_Config |
|
855 | + $config = $this->loader->getShared('EE_Config'); |
|
856 | + $this->loader->getShared('EE_Network_Config'); |
|
857 | + // setup autoloaders |
|
858 | + // enable logging? |
|
859 | + if ($config->admin->use_remote_logging) { |
|
860 | + $this->loader->getShared('EE_Log'); |
|
861 | + } |
|
862 | + // check for activation errors |
|
863 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
864 | + if ($activation_errors) { |
|
865 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
866 | + update_option('ee_plugin_activation_errors', false); |
|
867 | + } |
|
868 | + // get model names |
|
869 | + $this->_parse_model_names(); |
|
870 | + // configure custom post type definitions |
|
871 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
872 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
873 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
874 | + } |
|
875 | + |
|
876 | + |
|
877 | + /** |
|
878 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
879 | + * |
|
880 | + * @return void |
|
881 | + * @throws ReflectionException |
|
882 | + */ |
|
883 | + private function _parse_model_names() |
|
884 | + { |
|
885 | + // get all the files in the EE_MODELS folder that end in .model.php |
|
886 | + $models = glob(EE_MODELS . '*.model.php'); |
|
887 | + $model_names = array(); |
|
888 | + $non_abstract_db_models = array(); |
|
889 | + foreach ($models as $model) { |
|
890 | + // get model classname |
|
891 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
892 | + $short_name = str_replace('EEM_', '', $classname); |
|
893 | + $reflectionClass = new ReflectionClass($classname); |
|
894 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
895 | + $non_abstract_db_models[ $short_name ] = $classname; |
|
896 | + } |
|
897 | + $model_names[ $short_name ] = $classname; |
|
898 | + } |
|
899 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
900 | + $this->registry->non_abstract_db_models = apply_filters( |
|
901 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
902 | + $non_abstract_db_models |
|
903 | + ); |
|
904 | + } |
|
905 | + |
|
906 | + |
|
907 | + /** |
|
908 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
909 | + * that need to be setup before our EE_System launches. |
|
910 | + * |
|
911 | + * @return void |
|
912 | + * @throws DomainException |
|
913 | + * @throws InvalidArgumentException |
|
914 | + * @throws InvalidDataTypeException |
|
915 | + * @throws InvalidInterfaceException |
|
916 | + * @throws InvalidClassException |
|
917 | + * @throws InvalidFilePathException |
|
918 | + */ |
|
919 | + private function _maybe_brew_regular() |
|
920 | + { |
|
921 | + /** @var Domain $domain */ |
|
922 | + $domain = DomainFactory::getShared( |
|
923 | + new FullyQualifiedName( |
|
924 | + 'EventEspresso\core\domain\Domain' |
|
925 | + ), |
|
926 | + array( |
|
927 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
928 | + Version::fromString(espresso_version()), |
|
929 | + ) |
|
930 | + ); |
|
931 | + if ($domain->isCaffeinated()) { |
|
932 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
933 | + } |
|
934 | + } |
|
935 | + |
|
936 | + |
|
937 | + /** |
|
938 | + * @since 4.9.71.p |
|
939 | + * @throws Exception |
|
940 | + */ |
|
941 | + public function loadRouteMatchSpecifications() |
|
942 | + { |
|
943 | + try { |
|
944 | + $this->loader->getShared( |
|
945 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' |
|
946 | + ); |
|
947 | + } catch (Exception $exception) { |
|
948 | + new ExceptionStackTraceDisplay($exception); |
|
949 | + } |
|
950 | + do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
951 | + } |
|
952 | + |
|
953 | + |
|
954 | + /** |
|
955 | + * register_shortcodes_modules_and_widgets |
|
956 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
957 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
958 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
959 | + * |
|
960 | + * @access public |
|
961 | + * @return void |
|
962 | + * @throws Exception |
|
963 | + */ |
|
964 | + public function register_shortcodes_modules_and_widgets() |
|
965 | + { |
|
966 | + if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) { |
|
967 | + try { |
|
968 | + // load, register, and add shortcodes the new way |
|
969 | + $this->loader->getShared( |
|
970 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager', |
|
971 | + array( |
|
972 | + // and the old way, but we'll put it under control of the new system |
|
973 | + EE_Config::getLegacyShortcodesManager(), |
|
974 | + ) |
|
975 | + ); |
|
976 | + } catch (Exception $exception) { |
|
977 | + new ExceptionStackTraceDisplay($exception); |
|
978 | + } |
|
979 | + } |
|
980 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
981 | + // check for addons using old hook point |
|
982 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
983 | + $this->_incompatible_addon_error(); |
|
984 | + } |
|
985 | + } |
|
986 | + |
|
987 | + |
|
988 | + /** |
|
989 | + * _incompatible_addon_error |
|
990 | + * |
|
991 | + * @access public |
|
992 | + * @return void |
|
993 | + */ |
|
994 | + private function _incompatible_addon_error() |
|
995 | + { |
|
996 | + // get array of classes hooking into here |
|
997 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
998 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
999 | + ); |
|
1000 | + if (! empty($class_names)) { |
|
1001 | + $msg = __( |
|
1002 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
1003 | + 'event_espresso' |
|
1004 | + ); |
|
1005 | + $msg .= '<ul>'; |
|
1006 | + foreach ($class_names as $class_name) { |
|
1007 | + $msg .= '<li><b>Event Espresso - ' |
|
1008 | + . str_replace( |
|
1009 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
1010 | + '', |
|
1011 | + $class_name |
|
1012 | + ) . '</b></li>'; |
|
1013 | + } |
|
1014 | + $msg .= '</ul>'; |
|
1015 | + $msg .= __( |
|
1016 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
1017 | + 'event_espresso' |
|
1018 | + ); |
|
1019 | + // save list of incompatible addons to wp-options for later use |
|
1020 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
1021 | + if (is_admin()) { |
|
1022 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1023 | + } |
|
1024 | + } |
|
1025 | + } |
|
1026 | + |
|
1027 | + |
|
1028 | + /** |
|
1029 | + * brew_espresso |
|
1030 | + * begins the process of setting hooks for initializing EE in the correct order |
|
1031 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
1032 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
1033 | + * |
|
1034 | + * @return void |
|
1035 | + */ |
|
1036 | + public function brew_espresso() |
|
1037 | + { |
|
1038 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
1039 | + // load some final core systems |
|
1040 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
1041 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
1042 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
1043 | + add_action('init', array($this, 'load_controllers'), 7); |
|
1044 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
1045 | + add_action('init', array($this, 'initialize'), 10); |
|
1046 | + add_action('init', array($this, 'initialize_last'), 100); |
|
1047 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
1048 | + // pew pew pew |
|
1049 | + $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService'); |
|
1050 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
1051 | + } |
|
1052 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
1053 | + } |
|
1054 | + |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * set_hooks_for_core |
|
1058 | + * |
|
1059 | + * @access public |
|
1060 | + * @return void |
|
1061 | + * @throws EE_Error |
|
1062 | + */ |
|
1063 | + public function set_hooks_for_core() |
|
1064 | + { |
|
1065 | + $this->_deactivate_incompatible_addons(); |
|
1066 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
1067 | + $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
1068 | + // caps need to be initialized on every request so that capability maps are set. |
|
1069 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
1070 | + $this->registry->CAP->init_caps(); |
|
1071 | + } |
|
1072 | + |
|
1073 | + |
|
1074 | + /** |
|
1075 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
1076 | + * deactivates any addons considered incompatible with the current version of EE |
|
1077 | + */ |
|
1078 | + private function _deactivate_incompatible_addons() |
|
1079 | + { |
|
1080 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
1081 | + if (! empty($incompatible_addons)) { |
|
1082 | + $active_plugins = get_option('active_plugins', array()); |
|
1083 | + foreach ($active_plugins as $active_plugin) { |
|
1084 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
1085 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
1086 | + unset($_GET['activate']); |
|
1087 | + espresso_deactivate_plugin($active_plugin); |
|
1088 | + } |
|
1089 | + } |
|
1090 | + } |
|
1091 | + } |
|
1092 | + } |
|
1093 | + |
|
1094 | + |
|
1095 | + /** |
|
1096 | + * perform_activations_upgrades_and_migrations |
|
1097 | + * |
|
1098 | + * @access public |
|
1099 | + * @return void |
|
1100 | + */ |
|
1101 | + public function perform_activations_upgrades_and_migrations() |
|
1102 | + { |
|
1103 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
1104 | + } |
|
1105 | + |
|
1106 | + |
|
1107 | + /** |
|
1108 | + * @return void |
|
1109 | + * @throws DomainException |
|
1110 | + */ |
|
1111 | + public function load_CPTs_and_session() |
|
1112 | + { |
|
1113 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
1114 | + /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */ |
|
1115 | + $register_custom_taxonomies = $this->loader->getShared( |
|
1116 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
1117 | + ); |
|
1118 | + $register_custom_taxonomies->registerCustomTaxonomies(); |
|
1119 | + /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */ |
|
1120 | + $register_custom_post_types = $this->loader->getShared( |
|
1121 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
1122 | + ); |
|
1123 | + $register_custom_post_types->registerCustomPostTypes(); |
|
1124 | + /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */ |
|
1125 | + $register_custom_taxonomy_terms = $this->loader->getShared( |
|
1126 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
1127 | + ); |
|
1128 | + $register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
1129 | + // load legacy Custom Post Types and Taxonomies |
|
1130 | + $this->loader->getShared('EE_Register_CPTs'); |
|
1131 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
1132 | + } |
|
1133 | + |
|
1134 | + |
|
1135 | + /** |
|
1136 | + * load_controllers |
|
1137 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
1138 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
1139 | + * time |
|
1140 | + * |
|
1141 | + * @access public |
|
1142 | + * @return void |
|
1143 | + */ |
|
1144 | + public function load_controllers() |
|
1145 | + { |
|
1146 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
1147 | + // let's get it started |
|
1148 | + if (! $this->maintenance_mode->level() |
|
1149 | + && ($this->request->isFrontend() || $this->request->isFrontAjax()) |
|
1150 | + ) { |
|
1151 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
1152 | + $this->loader->getShared('EE_Front_Controller'); |
|
1153 | + } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
1154 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
1155 | + $this->loader->getShared('EE_Admin'); |
|
1156 | + } elseif ($this->request->isWordPressHeartbeat()) { |
|
1157 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
1158 | + } |
|
1159 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
1160 | + } |
|
1161 | + |
|
1162 | + |
|
1163 | + /** |
|
1164 | + * core_loaded_and_ready |
|
1165 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1166 | + * |
|
1167 | + * @access public |
|
1168 | + * @return void |
|
1169 | + * @throws Exception |
|
1170 | + */ |
|
1171 | + public function core_loaded_and_ready() |
|
1172 | + { |
|
1173 | + if ($this->request->isAdmin() |
|
1174 | + || $this->request->isFrontend() |
|
1175 | + || $this->request->isIframe() |
|
1176 | + || $this->request->isWordPressApi() |
|
1177 | + ) { |
|
1178 | + try { |
|
1179 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
1180 | + $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
1181 | + if ($this->canLoadBlocks()) { |
|
1182 | + $this->loader->getShared( |
|
1183 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
1184 | + ); |
|
1185 | + } |
|
1186 | + } catch (Exception $exception) { |
|
1187 | + new ExceptionStackTraceDisplay($exception); |
|
1188 | + } |
|
1189 | + } |
|
1190 | + if ($this->request->isAdmin() |
|
1191 | + || $this->request->isEeAjax() |
|
1192 | + || $this->request->isFrontend() |
|
1193 | + ) { |
|
1194 | + $this->loader->getShared('EE_Session'); |
|
1195 | + } |
|
1196 | + // integrate WP_Query with the EE models |
|
1197 | + $this->loader->getShared('EE_CPT_Strategy'); |
|
1198 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
1199 | + // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
1200 | + // builders require these even on the front-end |
|
1201 | + require_once EE_PUBLIC . 'template_tags.php'; |
|
1202 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
1203 | + } |
|
1204 | + |
|
1205 | + |
|
1206 | + /** |
|
1207 | + * initialize |
|
1208 | + * this is the best place to begin initializing client code |
|
1209 | + * |
|
1210 | + * @access public |
|
1211 | + * @return void |
|
1212 | + */ |
|
1213 | + public function initialize() |
|
1214 | + { |
|
1215 | + do_action('AHEE__EE_System__initialize'); |
|
1216 | + } |
|
1217 | + |
|
1218 | + |
|
1219 | + /** |
|
1220 | + * initialize_last |
|
1221 | + * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
1222 | + * initialize has done so |
|
1223 | + * |
|
1224 | + * @access public |
|
1225 | + * @return void |
|
1226 | + */ |
|
1227 | + public function initialize_last() |
|
1228 | + { |
|
1229 | + do_action('AHEE__EE_System__initialize_last'); |
|
1230 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
1231 | + $rewrite_rules = $this->loader->getShared( |
|
1232 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
1233 | + ); |
|
1234 | + $rewrite_rules->flushRewriteRules(); |
|
1235 | + add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
1236 | + if (($this->request->isAjax() || $this->request->isAdmin()) |
|
1237 | + && $this->maintenance_mode->models_can_query()) { |
|
1238 | + $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
1239 | + $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
1240 | + } |
|
1241 | + } |
|
1242 | + |
|
1243 | + |
|
1244 | + /** |
|
1245 | + * @return void |
|
1246 | + * @throws EE_Error |
|
1247 | + */ |
|
1248 | + public function addEspressoToolbar() |
|
1249 | + { |
|
1250 | + $this->loader->getShared( |
|
1251 | + 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
1252 | + array($this->registry->CAP) |
|
1253 | + ); |
|
1254 | + } |
|
1255 | + |
|
1256 | + |
|
1257 | + /** |
|
1258 | + * do_not_cache |
|
1259 | + * sets no cache headers and defines no cache constants for WP plugins |
|
1260 | + * |
|
1261 | + * @access public |
|
1262 | + * @return void |
|
1263 | + */ |
|
1264 | + public static function do_not_cache() |
|
1265 | + { |
|
1266 | + // set no cache constants |
|
1267 | + if (! defined('DONOTCACHEPAGE')) { |
|
1268 | + define('DONOTCACHEPAGE', true); |
|
1269 | + } |
|
1270 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
1271 | + define('DONOTCACHCEOBJECT', true); |
|
1272 | + } |
|
1273 | + if (! defined('DONOTCACHEDB')) { |
|
1274 | + define('DONOTCACHEDB', true); |
|
1275 | + } |
|
1276 | + // add no cache headers |
|
1277 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1278 | + // plus a little extra for nginx and Google Chrome |
|
1279 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1280 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1281 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1282 | + } |
|
1283 | + |
|
1284 | + |
|
1285 | + /** |
|
1286 | + * extra_nocache_headers |
|
1287 | + * |
|
1288 | + * @access public |
|
1289 | + * @param $headers |
|
1290 | + * @return array |
|
1291 | + */ |
|
1292 | + public static function extra_nocache_headers($headers) |
|
1293 | + { |
|
1294 | + // for NGINX |
|
1295 | + $headers['X-Accel-Expires'] = 0; |
|
1296 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1297 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1298 | + return $headers; |
|
1299 | + } |
|
1300 | + |
|
1301 | + |
|
1302 | + /** |
|
1303 | + * nocache_headers |
|
1304 | + * |
|
1305 | + * @access public |
|
1306 | + * @return void |
|
1307 | + */ |
|
1308 | + public static function nocache_headers() |
|
1309 | + { |
|
1310 | + nocache_headers(); |
|
1311 | + } |
|
1312 | + |
|
1313 | + |
|
1314 | + /** |
|
1315 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1316 | + * never returned with the function. |
|
1317 | + * |
|
1318 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1319 | + * @return array |
|
1320 | + */ |
|
1321 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1322 | + { |
|
1323 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1324 | + } |
|
1325 | + |
|
1326 | + |
|
1327 | + /** |
|
1328 | + * Return whether blocks can be registered/loaded or not. |
|
1329 | + * @return bool |
|
1330 | + */ |
|
1331 | + private function canLoadBlocks() |
|
1332 | + { |
|
1333 | + return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
1334 | + && function_exists('register_block_type') |
|
1335 | + // don't load blocks if in the Divi page builder editor context |
|
1336 | + // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
1337 | + && ! $this->request->getRequestParam('et_fb', false); |
|
1338 | + } |
|
1339 | 1339 | } |
@@ -17,196 +17,196 @@ |
||
17 | 17 | class EE_Log |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - private $_log = ''; |
|
24 | - |
|
25 | - /** |
|
26 | - * Used for remote logging |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - private $_remote_logging_url = ''; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - private $_remote_log = ''; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var EE_Log |
|
39 | - */ |
|
40 | - private static $_instance; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @return EE_Log |
|
45 | - */ |
|
46 | - public static function instance() |
|
47 | - { |
|
48 | - if (! self::$_instance instanceof EE_Log) { |
|
49 | - self::$_instance = new self(); |
|
50 | - } |
|
51 | - return self::$_instance; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @access private |
|
56 | - * @return EE_Log |
|
57 | - */ |
|
58 | - private function __construct() |
|
59 | - { |
|
60 | - |
|
61 | - if (! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
62 | - return; |
|
63 | - } |
|
64 | - |
|
65 | - $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url; |
|
66 | - $this->_remote_log = ''; |
|
67 | - |
|
68 | - if (EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
69 | - add_action('shutdown', array($this, 'send_log'), 9999); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * verify_filesystem |
|
76 | - * tests that the required files and folders exist and are writable |
|
77 | - * |
|
78 | - */ |
|
79 | - public function verify_filesystem() |
|
80 | - { |
|
81 | - $msg = esc_html__( |
|
82 | - 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
83 | - 'event_espresso' |
|
84 | - ); |
|
85 | - EE_Error::doing_it_wrong( |
|
86 | - __METHOD__, |
|
87 | - $msg, |
|
88 | - '$VID:$' |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * _format_message |
|
95 | - * makes yer log entries look all purdy |
|
96 | - * |
|
97 | - * @param string $file |
|
98 | - * @param string $function |
|
99 | - * @param string $message |
|
100 | - * @param string $type |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - private function _format_message($file = '', $function = '', $message = '', $type = '') |
|
104 | - { |
|
105 | - $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
106 | - $msg .= '[' . current_time('mysql') . '] '; |
|
107 | - $msg .= ! empty($file) ? basename($file) : ''; |
|
108 | - $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
109 | - $msg .= ! empty($function) ? $function . '()' : ''; |
|
110 | - $msg .= PHP_EOL; |
|
111 | - $type = ! empty($type) ? $type : 'log message'; |
|
112 | - $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
113 | - return $msg; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * log |
|
119 | - * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the |
|
120 | - * EE_Log::write_log() callback |
|
121 | - * |
|
122 | - * @param string $file |
|
123 | - * @param string $function |
|
124 | - * @param string $message |
|
125 | - * @param string $type |
|
126 | - */ |
|
127 | - public function log($file = '', $function = '', $message = '', $type = '') |
|
128 | - { |
|
129 | - $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * write_log |
|
135 | - * appends the results of the 'AHEE_log' filter to the espresso log file |
|
136 | - */ |
|
137 | - public function write_log() |
|
138 | - { |
|
139 | - $msg = esc_html__( |
|
140 | - 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
141 | - 'event_espresso' |
|
142 | - ); |
|
143 | - EE_Error::doing_it_wrong( |
|
144 | - __METHOD__, |
|
145 | - $msg, |
|
146 | - '$VID:$' |
|
147 | - ); |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * send_log |
|
153 | - * sends the espresso log to a remote URL via a PHP cURL request |
|
154 | - */ |
|
155 | - public function send_log() |
|
156 | - { |
|
157 | - |
|
158 | - if (empty($this->_remote_logging_url)) { |
|
159 | - return; |
|
160 | - } |
|
161 | - |
|
162 | - $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
163 | - $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
164 | - $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
165 | - $data .= '&time=' . time(); |
|
166 | - $data .= '&remote_log=' . $this->_log; |
|
167 | - $data .= '&request_array=' . json_encode($_REQUEST); |
|
168 | - $data .= '&action=save'; |
|
169 | - |
|
170 | - if (defined('EELOGGING_PASS')) { |
|
171 | - $data .= '&pass=' . EELOGGING_PASS; |
|
172 | - } |
|
173 | - if (defined('EELOGGING_KEY')) { |
|
174 | - $data .= '&key=' . EELOGGING_KEY; |
|
175 | - } |
|
176 | - |
|
177 | - $c = curl_init($this->_remote_logging_url); |
|
178 | - curl_setopt($c, CURLOPT_POST, true); |
|
179 | - curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
180 | - curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
181 | - curl_exec($c); |
|
182 | - curl_close($c); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * write_debug |
|
188 | - * writes the contents of the current request's $_GET and $_POST arrays to a log file. |
|
189 | - * previous entries are overwritten |
|
190 | - */ |
|
191 | - public function write_debug() |
|
192 | - { |
|
193 | - $msg = esc_html__( |
|
194 | - 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
195 | - 'event_espresso' |
|
196 | - ); |
|
197 | - EE_Error::doing_it_wrong( |
|
198 | - __METHOD__, |
|
199 | - $msg, |
|
200 | - '$VID:$' |
|
201 | - ); |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * __clone |
|
207 | - */ |
|
208 | - public function __clone() |
|
209 | - { |
|
210 | - trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
211 | - } |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + private $_log = ''; |
|
24 | + |
|
25 | + /** |
|
26 | + * Used for remote logging |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + private $_remote_logging_url = ''; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + private $_remote_log = ''; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var EE_Log |
|
39 | + */ |
|
40 | + private static $_instance; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @return EE_Log |
|
45 | + */ |
|
46 | + public static function instance() |
|
47 | + { |
|
48 | + if (! self::$_instance instanceof EE_Log) { |
|
49 | + self::$_instance = new self(); |
|
50 | + } |
|
51 | + return self::$_instance; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @access private |
|
56 | + * @return EE_Log |
|
57 | + */ |
|
58 | + private function __construct() |
|
59 | + { |
|
60 | + |
|
61 | + if (! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
62 | + return; |
|
63 | + } |
|
64 | + |
|
65 | + $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url; |
|
66 | + $this->_remote_log = ''; |
|
67 | + |
|
68 | + if (EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
69 | + add_action('shutdown', array($this, 'send_log'), 9999); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * verify_filesystem |
|
76 | + * tests that the required files and folders exist and are writable |
|
77 | + * |
|
78 | + */ |
|
79 | + public function verify_filesystem() |
|
80 | + { |
|
81 | + $msg = esc_html__( |
|
82 | + 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
83 | + 'event_espresso' |
|
84 | + ); |
|
85 | + EE_Error::doing_it_wrong( |
|
86 | + __METHOD__, |
|
87 | + $msg, |
|
88 | + '$VID:$' |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * _format_message |
|
95 | + * makes yer log entries look all purdy |
|
96 | + * |
|
97 | + * @param string $file |
|
98 | + * @param string $function |
|
99 | + * @param string $message |
|
100 | + * @param string $type |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + private function _format_message($file = '', $function = '', $message = '', $type = '') |
|
104 | + { |
|
105 | + $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
106 | + $msg .= '[' . current_time('mysql') . '] '; |
|
107 | + $msg .= ! empty($file) ? basename($file) : ''; |
|
108 | + $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
109 | + $msg .= ! empty($function) ? $function . '()' : ''; |
|
110 | + $msg .= PHP_EOL; |
|
111 | + $type = ! empty($type) ? $type : 'log message'; |
|
112 | + $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
113 | + return $msg; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * log |
|
119 | + * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the |
|
120 | + * EE_Log::write_log() callback |
|
121 | + * |
|
122 | + * @param string $file |
|
123 | + * @param string $function |
|
124 | + * @param string $message |
|
125 | + * @param string $type |
|
126 | + */ |
|
127 | + public function log($file = '', $function = '', $message = '', $type = '') |
|
128 | + { |
|
129 | + $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * write_log |
|
135 | + * appends the results of the 'AHEE_log' filter to the espresso log file |
|
136 | + */ |
|
137 | + public function write_log() |
|
138 | + { |
|
139 | + $msg = esc_html__( |
|
140 | + 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
141 | + 'event_espresso' |
|
142 | + ); |
|
143 | + EE_Error::doing_it_wrong( |
|
144 | + __METHOD__, |
|
145 | + $msg, |
|
146 | + '$VID:$' |
|
147 | + ); |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * send_log |
|
153 | + * sends the espresso log to a remote URL via a PHP cURL request |
|
154 | + */ |
|
155 | + public function send_log() |
|
156 | + { |
|
157 | + |
|
158 | + if (empty($this->_remote_logging_url)) { |
|
159 | + return; |
|
160 | + } |
|
161 | + |
|
162 | + $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
163 | + $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
164 | + $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
165 | + $data .= '&time=' . time(); |
|
166 | + $data .= '&remote_log=' . $this->_log; |
|
167 | + $data .= '&request_array=' . json_encode($_REQUEST); |
|
168 | + $data .= '&action=save'; |
|
169 | + |
|
170 | + if (defined('EELOGGING_PASS')) { |
|
171 | + $data .= '&pass=' . EELOGGING_PASS; |
|
172 | + } |
|
173 | + if (defined('EELOGGING_KEY')) { |
|
174 | + $data .= '&key=' . EELOGGING_KEY; |
|
175 | + } |
|
176 | + |
|
177 | + $c = curl_init($this->_remote_logging_url); |
|
178 | + curl_setopt($c, CURLOPT_POST, true); |
|
179 | + curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
180 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
181 | + curl_exec($c); |
|
182 | + curl_close($c); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * write_debug |
|
188 | + * writes the contents of the current request's $_GET and $_POST arrays to a log file. |
|
189 | + * previous entries are overwritten |
|
190 | + */ |
|
191 | + public function write_debug() |
|
192 | + { |
|
193 | + $msg = esc_html__( |
|
194 | + 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
195 | + 'event_espresso' |
|
196 | + ); |
|
197 | + EE_Error::doing_it_wrong( |
|
198 | + __METHOD__, |
|
199 | + $msg, |
|
200 | + '$VID:$' |
|
201 | + ); |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * __clone |
|
207 | + */ |
|
208 | + public function __clone() |
|
209 | + { |
|
210 | + trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
211 | + } |
|
212 | 212 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public static function instance() |
47 | 47 | { |
48 | - if (! self::$_instance instanceof EE_Log) { |
|
48 | + if ( ! self::$_instance instanceof EE_Log) { |
|
49 | 49 | self::$_instance = new self(); |
50 | 50 | } |
51 | 51 | return self::$_instance; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | private function __construct() |
59 | 59 | { |
60 | 60 | |
61 | - if (! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
61 | + if ( ! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | */ |
103 | 103 | private function _format_message($file = '', $function = '', $message = '', $type = '') |
104 | 104 | { |
105 | - $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
106 | - $msg .= '[' . current_time('mysql') . '] '; |
|
105 | + $msg = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
106 | + $msg .= '['.current_time('mysql').'] '; |
|
107 | 107 | $msg .= ! empty($file) ? basename($file) : ''; |
108 | 108 | $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
109 | - $msg .= ! empty($function) ? $function . '()' : ''; |
|
109 | + $msg .= ! empty($function) ? $function.'()' : ''; |
|
110 | 110 | $msg .= PHP_EOL; |
111 | 111 | $type = ! empty($type) ? $type : 'log message'; |
112 | - $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
112 | + $msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : ''; |
|
113 | 113 | return $msg; |
114 | 114 | } |
115 | 115 | |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
163 | - $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
164 | - $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
165 | - $data .= '&time=' . time(); |
|
166 | - $data .= '&remote_log=' . $this->_log; |
|
167 | - $data .= '&request_array=' . json_encode($_REQUEST); |
|
162 | + $data = 'domain='.$_SERVER['HTTP_HOST']; |
|
163 | + $data .= '&ip='.$_SERVER['SERVER_ADDR']; |
|
164 | + $data .= '&server_type='.$_SERVER['SERVER_SOFTWARE']; |
|
165 | + $data .= '&time='.time(); |
|
166 | + $data .= '&remote_log='.$this->_log; |
|
167 | + $data .= '&request_array='.json_encode($_REQUEST); |
|
168 | 168 | $data .= '&action=save'; |
169 | 169 | |
170 | 170 | if (defined('EELOGGING_PASS')) { |
171 | - $data .= '&pass=' . EELOGGING_PASS; |
|
171 | + $data .= '&pass='.EELOGGING_PASS; |
|
172 | 172 | } |
173 | 173 | if (defined('EELOGGING_KEY')) { |
174 | - $data .= '&key=' . EELOGGING_KEY; |
|
174 | + $data .= '&key='.EELOGGING_KEY; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | $c = curl_init($this->_remote_logging_url); |
@@ -103,286 +103,286 @@ |
||
103 | 103 | class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage |
104 | 104 | { |
105 | 105 | |
106 | - public function _migration_step($num_items = 50) |
|
107 | - { |
|
106 | + public function _migration_step($num_items = 50) |
|
107 | + { |
|
108 | 108 | |
109 | - $items_actually_migrated = 0; |
|
110 | - $old_org_options = get_option('events_organization_settings'); |
|
111 | - foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
112 | - // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
113 | - if (isset($old_org_options[ $option_name ])) { |
|
114 | - $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
115 | - } |
|
116 | - if ($option_name=='surcharge') { |
|
117 | - $this->_insert_new_global_surcharge_price($old_org_options); |
|
118 | - } |
|
119 | - $items_actually_migrated++; |
|
120 | - } |
|
109 | + $items_actually_migrated = 0; |
|
110 | + $old_org_options = get_option('events_organization_settings'); |
|
111 | + foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
112 | + // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
113 | + if (isset($old_org_options[ $option_name ])) { |
|
114 | + $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
115 | + } |
|
116 | + if ($option_name=='surcharge') { |
|
117 | + $this->_insert_new_global_surcharge_price($old_org_options); |
|
118 | + } |
|
119 | + $items_actually_migrated++; |
|
120 | + } |
|
121 | 121 | |
122 | - $success = EE_Config::instance()->update_espresso_config(false, true); |
|
123 | - if (! $success) { |
|
124 | - $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
|
125 | - EE_Error::overwrite_errors(); |
|
126 | - } |
|
127 | - EE_Network_Config::instance()->update_config(false, false); |
|
128 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
129 | - // we may have added new pages and this might be necessary |
|
130 | - flush_rewrite_rules(); |
|
131 | - $this->set_completed(); |
|
132 | - } |
|
133 | - return $items_actually_migrated; |
|
134 | - } |
|
135 | - public function _count_records_to_migrate() |
|
136 | - { |
|
137 | - $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate); |
|
138 | - return $count_of_options_to_migrate; |
|
139 | - } |
|
140 | - public function __construct() |
|
141 | - { |
|
142 | - $this->_pretty_name = __("Organization Options/Config", "event_espresso"); |
|
143 | - $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate); |
|
144 | - parent::__construct(); |
|
145 | - } |
|
122 | + $success = EE_Config::instance()->update_espresso_config(false, true); |
|
123 | + if (! $success) { |
|
124 | + $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
|
125 | + EE_Error::overwrite_errors(); |
|
126 | + } |
|
127 | + EE_Network_Config::instance()->update_config(false, false); |
|
128 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
129 | + // we may have added new pages and this might be necessary |
|
130 | + flush_rewrite_rules(); |
|
131 | + $this->set_completed(); |
|
132 | + } |
|
133 | + return $items_actually_migrated; |
|
134 | + } |
|
135 | + public function _count_records_to_migrate() |
|
136 | + { |
|
137 | + $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate); |
|
138 | + return $count_of_options_to_migrate; |
|
139 | + } |
|
140 | + public function __construct() |
|
141 | + { |
|
142 | + $this->_pretty_name = __("Organization Options/Config", "event_espresso"); |
|
143 | + $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate); |
|
144 | + parent::__construct(); |
|
145 | + } |
|
146 | 146 | |
147 | - private function _handle_org_option($option_name, $value) |
|
148 | - { |
|
149 | - $c = EE_Config::instance(); |
|
150 | - $cn = EE_Network_Config::instance(); |
|
151 | - switch ($option_name) { |
|
152 | - case 'organization': |
|
153 | - $c->organization->name = $value; |
|
154 | - break; |
|
155 | - case 'organization_street1': |
|
156 | - $c->organization->address_1 = $value; |
|
157 | - break; |
|
158 | - case 'organization_street2': |
|
159 | - $c->organization->address_2 = $value; |
|
160 | - break; |
|
161 | - case 'organization_city': |
|
162 | - $c->organization->city = $value; |
|
163 | - break; |
|
164 | - case 'organization_state': |
|
165 | - try { |
|
166 | - $state = $this->get_migration_script()->get_or_create_state($value); |
|
167 | - $state_id = $state['STA_ID']; |
|
168 | - $c->organization->STA_ID = $state_id; |
|
169 | - } catch (EE_Error $e) { |
|
170 | - } |
|
171 | - break; |
|
172 | - case 'organization_zip': |
|
173 | - $c->organization->zip = $value; |
|
174 | - break; |
|
175 | - case 'contact_email': |
|
176 | - $c->organization->email = $value; |
|
177 | - break; |
|
178 | - case 'default_payment_status': |
|
179 | - $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
180 | - break; |
|
181 | - case 'organization_country': |
|
182 | - $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
183 | - $c->organization->CNT_ISO = $iso; |
|
184 | - $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
185 | - if (! $country_row) { |
|
186 | - $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
|
187 | - } |
|
188 | - // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
189 | - $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
190 | - $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
191 | - $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
192 | - $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
193 | - $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE or FALSE$ |
|
194 | - $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
195 | - $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
196 | - $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
147 | + private function _handle_org_option($option_name, $value) |
|
148 | + { |
|
149 | + $c = EE_Config::instance(); |
|
150 | + $cn = EE_Network_Config::instance(); |
|
151 | + switch ($option_name) { |
|
152 | + case 'organization': |
|
153 | + $c->organization->name = $value; |
|
154 | + break; |
|
155 | + case 'organization_street1': |
|
156 | + $c->organization->address_1 = $value; |
|
157 | + break; |
|
158 | + case 'organization_street2': |
|
159 | + $c->organization->address_2 = $value; |
|
160 | + break; |
|
161 | + case 'organization_city': |
|
162 | + $c->organization->city = $value; |
|
163 | + break; |
|
164 | + case 'organization_state': |
|
165 | + try { |
|
166 | + $state = $this->get_migration_script()->get_or_create_state($value); |
|
167 | + $state_id = $state['STA_ID']; |
|
168 | + $c->organization->STA_ID = $state_id; |
|
169 | + } catch (EE_Error $e) { |
|
170 | + } |
|
171 | + break; |
|
172 | + case 'organization_zip': |
|
173 | + $c->organization->zip = $value; |
|
174 | + break; |
|
175 | + case 'contact_email': |
|
176 | + $c->organization->email = $value; |
|
177 | + break; |
|
178 | + case 'default_payment_status': |
|
179 | + $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
180 | + break; |
|
181 | + case 'organization_country': |
|
182 | + $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
183 | + $c->organization->CNT_ISO = $iso; |
|
184 | + $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
185 | + if (! $country_row) { |
|
186 | + $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
|
187 | + } |
|
188 | + // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
189 | + $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
190 | + $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
191 | + $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
192 | + $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
193 | + $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE or FALSE$ |
|
194 | + $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
195 | + $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
196 | + $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
197 | 197 | // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
198 | 198 | // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
199 | 199 | // $c->currency->sign = $value;break; |
200 | - case 'show_pending_payment_options': |
|
201 | - $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
202 | - break; |
|
203 | - case 'display_address_in_regform': |
|
204 | - $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
205 | - break; |
|
206 | - case 'default_logo_url': |
|
207 | - $c->organization->logo_url = $value; |
|
208 | - break; |
|
209 | - case 'event_page_id': |
|
210 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
211 | - // to ESPRESSO_THANK_YOU |
|
212 | - $reg_page_post = get_post($value); |
|
213 | - $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content); |
|
214 | - wp_update_post($reg_page_post); |
|
215 | - $c->core->reg_page_id = $value; |
|
216 | - break; |
|
217 | - case 'return_url': |
|
218 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
219 | - // to ESPRESSO_THANK_YOU |
|
220 | - $thank_you_page_post = get_post($value); |
|
221 | - $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content); |
|
222 | - wp_update_post($thank_you_page_post); |
|
223 | - $c->core->thank_you_page_id = $value; |
|
224 | - break; |
|
225 | - case 'cancel_return': |
|
226 | - $c->core->cancel_page_id = $value; |
|
200 | + case 'show_pending_payment_options': |
|
201 | + $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
202 | + break; |
|
203 | + case 'display_address_in_regform': |
|
204 | + $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
205 | + break; |
|
206 | + case 'default_logo_url': |
|
207 | + $c->organization->logo_url = $value; |
|
208 | + break; |
|
209 | + case 'event_page_id': |
|
210 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
211 | + // to ESPRESSO_THANK_YOU |
|
212 | + $reg_page_post = get_post($value); |
|
213 | + $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content); |
|
214 | + wp_update_post($reg_page_post); |
|
215 | + $c->core->reg_page_id = $value; |
|
216 | + break; |
|
217 | + case 'return_url': |
|
218 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
219 | + // to ESPRESSO_THANK_YOU |
|
220 | + $thank_you_page_post = get_post($value); |
|
221 | + $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content); |
|
222 | + wp_update_post($thank_you_page_post); |
|
223 | + $c->core->thank_you_page_id = $value; |
|
224 | + break; |
|
225 | + case 'cancel_return': |
|
226 | + $c->core->cancel_page_id = $value; |
|
227 | 227 | |
228 | - break; |
|
229 | - case 'notify_url': |
|
230 | - $c->core->txn_page_id = $value; |
|
231 | - break; |
|
232 | - case 'use_captcha': |
|
233 | - $c->registration->use_captcha = ($value == 'Y'); |
|
234 | - break; |
|
235 | - case 'recaptcha_publickey': |
|
236 | - $c->registration->recaptcha_publickey = $value; |
|
237 | - break; |
|
238 | - case 'recaptcha_privatekey': |
|
239 | - $c->registration->recaptcha_privatekey = $value; |
|
240 | - break; |
|
241 | - case 'recaptcha_theme': |
|
242 | - $c->registration->recaptcha_theme = $value; |
|
243 | - break; |
|
244 | - case 'recaptcha_width': |
|
245 | - $c->registration->recaptcha_width = $value; |
|
246 | - break; |
|
247 | - case 'recaptcha_language': |
|
248 | - $c->registration->recaptcha_language = $value; |
|
249 | - break; |
|
250 | - case 'espresso_dashboard_widget': |
|
251 | - $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
252 | - break; |
|
253 | - case 'use_personnel_manager': |
|
254 | - $c->admin->use_personnel_manager = ($value == 'Y'); |
|
255 | - break; |
|
256 | - case 'use_event_timezones': |
|
257 | - $c->admin->use_event_timezones = ($value == 'Y'); |
|
258 | - break; |
|
259 | - case 'affiliate_id': |
|
260 | - $c->admin->affiliate_id = $value; |
|
261 | - break; |
|
262 | - case 'site_license_key': |
|
263 | - $cn->core->site_license_key = $value; |
|
264 | - break; |
|
265 | - default: |
|
266 | - do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
267 | - } |
|
268 | - } |
|
228 | + break; |
|
229 | + case 'notify_url': |
|
230 | + $c->core->txn_page_id = $value; |
|
231 | + break; |
|
232 | + case 'use_captcha': |
|
233 | + $c->registration->use_captcha = ($value == 'Y'); |
|
234 | + break; |
|
235 | + case 'recaptcha_publickey': |
|
236 | + $c->registration->recaptcha_publickey = $value; |
|
237 | + break; |
|
238 | + case 'recaptcha_privatekey': |
|
239 | + $c->registration->recaptcha_privatekey = $value; |
|
240 | + break; |
|
241 | + case 'recaptcha_theme': |
|
242 | + $c->registration->recaptcha_theme = $value; |
|
243 | + break; |
|
244 | + case 'recaptcha_width': |
|
245 | + $c->registration->recaptcha_width = $value; |
|
246 | + break; |
|
247 | + case 'recaptcha_language': |
|
248 | + $c->registration->recaptcha_language = $value; |
|
249 | + break; |
|
250 | + case 'espresso_dashboard_widget': |
|
251 | + $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
252 | + break; |
|
253 | + case 'use_personnel_manager': |
|
254 | + $c->admin->use_personnel_manager = ($value == 'Y'); |
|
255 | + break; |
|
256 | + case 'use_event_timezones': |
|
257 | + $c->admin->use_event_timezones = ($value == 'Y'); |
|
258 | + break; |
|
259 | + case 'affiliate_id': |
|
260 | + $c->admin->affiliate_id = $value; |
|
261 | + break; |
|
262 | + case 'site_license_key': |
|
263 | + $cn->core->site_license_key = $value; |
|
264 | + break; |
|
265 | + default: |
|
266 | + do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Creates a 4.1 member price discount |
|
272 | - * @global type $wpdb |
|
273 | - * @param type $old_price |
|
274 | - * @return int |
|
275 | - */ |
|
276 | - private function _insert_new_global_surcharge_price($org_options) |
|
277 | - { |
|
278 | - $amount = floatval($org_options['surcharge']); |
|
279 | - // dont createa a price if the surcharge is 0 |
|
280 | - if ($amount <=.01) { |
|
281 | - return 0; |
|
282 | - } |
|
283 | - if ($org_options['surcharge_type'] == 'flat_rate') { |
|
284 | - $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
285 | - } else { |
|
286 | - $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
287 | - } |
|
288 | - global $wpdb; |
|
289 | - $cols_n_values = array( |
|
290 | - 'PRT_ID'=>$price_type, |
|
291 | - 'PRC_amount'=>$amount, |
|
292 | - 'PRC_name'=> $org_options['surcharge_text'], |
|
293 | - 'PRC_is_default'=>true, |
|
294 | - 'PRC_overrides'=>false, |
|
295 | - 'PRC_order'=>100, |
|
296 | - 'PRC_deleted'=>false, |
|
297 | - 'PRC_parent'=>null |
|
270 | + /** |
|
271 | + * Creates a 4.1 member price discount |
|
272 | + * @global type $wpdb |
|
273 | + * @param type $old_price |
|
274 | + * @return int |
|
275 | + */ |
|
276 | + private function _insert_new_global_surcharge_price($org_options) |
|
277 | + { |
|
278 | + $amount = floatval($org_options['surcharge']); |
|
279 | + // dont createa a price if the surcharge is 0 |
|
280 | + if ($amount <=.01) { |
|
281 | + return 0; |
|
282 | + } |
|
283 | + if ($org_options['surcharge_type'] == 'flat_rate') { |
|
284 | + $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
285 | + } else { |
|
286 | + $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
287 | + } |
|
288 | + global $wpdb; |
|
289 | + $cols_n_values = array( |
|
290 | + 'PRT_ID'=>$price_type, |
|
291 | + 'PRC_amount'=>$amount, |
|
292 | + 'PRC_name'=> $org_options['surcharge_text'], |
|
293 | + 'PRC_is_default'=>true, |
|
294 | + 'PRC_overrides'=>false, |
|
295 | + 'PRC_order'=>100, |
|
296 | + 'PRC_deleted'=>false, |
|
297 | + 'PRC_parent'=>null |
|
298 | 298 | |
299 | - ); |
|
300 | - $datatypes = array( |
|
301 | - '%d',// PRT_ID |
|
302 | - '%f',// PRT_amount |
|
303 | - '%s',// PRC_name |
|
304 | - '%d',// PRC_is_default |
|
305 | - '%d',// PRC_overrides |
|
306 | - '%d',// PRC_order |
|
307 | - '%d',// PRC_deleted |
|
308 | - '%d',// PRC_parent |
|
309 | - ); |
|
310 | - $price_table = $wpdb->prefix."esp_price"; |
|
311 | - $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
|
312 | - if (! $success) { |
|
313 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
|
314 | - 'org_options', |
|
315 | - array( |
|
316 | - 'surcharge'=>$org_options['surcharge'], |
|
317 | - 'surcharge_type'=>$org_options['surcharge_type'], |
|
318 | - 'surcharge_text'=>$org_options['surcharge_text']), |
|
319 | - $price_table, |
|
320 | - $cols_n_values, |
|
321 | - $datatypes |
|
322 | - )); |
|
323 | - return 0; |
|
324 | - } |
|
325 | - $new_id = $wpdb->insert_id; |
|
326 | - return $new_id; |
|
327 | - } |
|
299 | + ); |
|
300 | + $datatypes = array( |
|
301 | + '%d',// PRT_ID |
|
302 | + '%f',// PRT_amount |
|
303 | + '%s',// PRC_name |
|
304 | + '%d',// PRC_is_default |
|
305 | + '%d',// PRC_overrides |
|
306 | + '%d',// PRC_order |
|
307 | + '%d',// PRC_deleted |
|
308 | + '%d',// PRC_parent |
|
309 | + ); |
|
310 | + $price_table = $wpdb->prefix."esp_price"; |
|
311 | + $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
|
312 | + if (! $success) { |
|
313 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
|
314 | + 'org_options', |
|
315 | + array( |
|
316 | + 'surcharge'=>$org_options['surcharge'], |
|
317 | + 'surcharge_type'=>$org_options['surcharge_type'], |
|
318 | + 'surcharge_text'=>$org_options['surcharge_text']), |
|
319 | + $price_table, |
|
320 | + $cols_n_values, |
|
321 | + $datatypes |
|
322 | + )); |
|
323 | + return 0; |
|
324 | + } |
|
325 | + $new_id = $wpdb->insert_id; |
|
326 | + return $new_id; |
|
327 | + } |
|
328 | 328 | |
329 | - protected $_org_options_we_know_how_to_migrate = array( |
|
330 | - 'organization', |
|
331 | - 'organization_street1', |
|
332 | - 'organization_street2', |
|
333 | - 'organization_city', |
|
334 | - 'organization_state', |
|
335 | - 'organization_zip', |
|
336 | - 'contact_email', |
|
337 | - 'default_mail', |
|
338 | - 'payment_subject', |
|
339 | - 'payment_message', |
|
340 | - 'message', |
|
341 | - 'default_payment_status', |
|
342 | - 'surcharge',// unused? |
|
343 | - 'country_id',// unused? |
|
344 | - 'organization_country', |
|
329 | + protected $_org_options_we_know_how_to_migrate = array( |
|
330 | + 'organization', |
|
331 | + 'organization_street1', |
|
332 | + 'organization_street2', |
|
333 | + 'organization_city', |
|
334 | + 'organization_state', |
|
335 | + 'organization_zip', |
|
336 | + 'contact_email', |
|
337 | + 'default_mail', |
|
338 | + 'payment_subject', |
|
339 | + 'payment_message', |
|
340 | + 'message', |
|
341 | + 'default_payment_status', |
|
342 | + 'surcharge',// unused? |
|
343 | + 'country_id',// unused? |
|
344 | + 'organization_country', |
|
345 | 345 | // 'currency_symbol', |
346 | - 'expire_on_registration_end', |
|
347 | - 'email_before_payment', |
|
348 | - 'email_fancy_headers', |
|
349 | - 'enable_default_style', |
|
350 | - 'event_ssl_active', |
|
351 | - 'selected_style', |
|
352 | - 'show_pending_payment_options', |
|
353 | - 'show_reg_footer', |
|
354 | - 'skip_confirmation_page', |
|
355 | - 'allow_mer_discounts',// no equiv |
|
356 | - 'allow_mer_vouchers',// no equiv |
|
357 | - 'display_short_description_in_event_list', |
|
358 | - 'display_description_on_multi_reg_page', |
|
359 | - 'display_address_in_event_list', |
|
360 | - 'display_address_in_regform', |
|
361 | - 'use_custom_post_types',// no equiv |
|
362 | - 'display_ical_download', |
|
363 | - 'display_featured_image', |
|
364 | - 'themeroller', |
|
365 | - 'default_logo_url', |
|
366 | - 'event_page_id', |
|
367 | - 'return_url', |
|
368 | - 'cancel_return', |
|
369 | - 'notify_url', |
|
370 | - 'events_in_dashboard', |
|
371 | - 'use_captcha', |
|
372 | - 'recaptcha_publickey', |
|
373 | - 'recaptcha_privatekey', |
|
374 | - 'recaptcha_theme', |
|
375 | - 'recaptcha_width', |
|
376 | - 'recaptcha_language', |
|
377 | - 'espresso_dashboard_widget', |
|
378 | - 'time_reg_limit', |
|
346 | + 'expire_on_registration_end', |
|
347 | + 'email_before_payment', |
|
348 | + 'email_fancy_headers', |
|
349 | + 'enable_default_style', |
|
350 | + 'event_ssl_active', |
|
351 | + 'selected_style', |
|
352 | + 'show_pending_payment_options', |
|
353 | + 'show_reg_footer', |
|
354 | + 'skip_confirmation_page', |
|
355 | + 'allow_mer_discounts',// no equiv |
|
356 | + 'allow_mer_vouchers',// no equiv |
|
357 | + 'display_short_description_in_event_list', |
|
358 | + 'display_description_on_multi_reg_page', |
|
359 | + 'display_address_in_event_list', |
|
360 | + 'display_address_in_regform', |
|
361 | + 'use_custom_post_types',// no equiv |
|
362 | + 'display_ical_download', |
|
363 | + 'display_featured_image', |
|
364 | + 'themeroller', |
|
365 | + 'default_logo_url', |
|
366 | + 'event_page_id', |
|
367 | + 'return_url', |
|
368 | + 'cancel_return', |
|
369 | + 'notify_url', |
|
370 | + 'events_in_dashboard', |
|
371 | + 'use_captcha', |
|
372 | + 'recaptcha_publickey', |
|
373 | + 'recaptcha_privatekey', |
|
374 | + 'recaptcha_theme', |
|
375 | + 'recaptcha_width', |
|
376 | + 'recaptcha_language', |
|
377 | + 'espresso_dashboard_widget', |
|
378 | + 'time_reg_limit', |
|
379 | 379 | // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
380 | - 'use_personnel_manager',// no equiv |
|
381 | - 'use_event_timezones', |
|
382 | - 'full_logging', |
|
383 | - 'surcharge_type',// unused |
|
384 | - 'surcharge_text',// unused |
|
385 | - 'affiliate_id', |
|
386 | - 'site_license_key', |
|
387 | - ); |
|
380 | + 'use_personnel_manager',// no equiv |
|
381 | + 'use_event_timezones', |
|
382 | + 'full_logging', |
|
383 | + 'surcharge_type',// unused |
|
384 | + 'surcharge_text',// unused |
|
385 | + 'affiliate_id', |
|
386 | + 'site_license_key', |
|
387 | + ); |
|
388 | 388 | } |
@@ -18,68 +18,68 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - public function __construct($routing = true) |
|
22 | - { |
|
23 | - parent::__construct($routing); |
|
24 | - define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/'); |
|
25 | - } |
|
21 | + public function __construct($routing = true) |
|
22 | + { |
|
23 | + parent::__construct($routing); |
|
24 | + define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/'); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - protected function _extend_page_config() |
|
29 | - { |
|
28 | + protected function _extend_page_config() |
|
29 | + { |
|
30 | 30 | |
31 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings'; |
|
31 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings'; |
|
32 | 32 | |
33 | - // filters and action hooks here |
|
34 | - add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9); |
|
35 | - add_filter( |
|
36 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
37 | - array($this, 'update_debug_logging_options'), |
|
38 | - 10, |
|
39 | - 1 |
|
40 | - ); |
|
41 | - } |
|
33 | + // filters and action hooks here |
|
34 | + add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9); |
|
35 | + add_filter( |
|
36 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
37 | + array($this, 'update_debug_logging_options'), |
|
38 | + 10, |
|
39 | + 1 |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | 44 | |
45 | - /************* Logging Settings *************/ |
|
45 | + /************* Logging Settings *************/ |
|
46 | 46 | |
47 | - /** |
|
48 | - * debug_logging_options |
|
49 | - * |
|
50 | - * @param array $template_args |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function debug_logging_options($template_args = array()) |
|
55 | - { |
|
56 | - $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint( |
|
57 | - EE_Registry::instance()->CFG->admin->use_remote_logging |
|
58 | - ) : false; |
|
59 | - $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) |
|
60 | - && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) |
|
61 | - ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : ''; |
|
62 | - $template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php'; |
|
63 | - EEH_Template::display_template($template, $template_args); |
|
64 | - } |
|
47 | + /** |
|
48 | + * debug_logging_options |
|
49 | + * |
|
50 | + * @param array $template_args |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function debug_logging_options($template_args = array()) |
|
55 | + { |
|
56 | + $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint( |
|
57 | + EE_Registry::instance()->CFG->admin->use_remote_logging |
|
58 | + ) : false; |
|
59 | + $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) |
|
60 | + && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) |
|
61 | + ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : ''; |
|
62 | + $template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php'; |
|
63 | + EEH_Template::display_template($template, $template_args); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * update_debug_logging_options |
|
69 | - * |
|
70 | - * @param array $admin_options |
|
71 | - * |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function update_debug_logging_options($admin_options = array()) |
|
75 | - { |
|
76 | - $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint( |
|
77 | - $this->_req_data['use_remote_logging'] |
|
78 | - ) : $admin_options->use_remote_logging; |
|
79 | - $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw( |
|
80 | - $this->_req_data['remote_logging_url'] |
|
81 | - ) : $admin_options->remote_logging_url; |
|
67 | + /** |
|
68 | + * update_debug_logging_options |
|
69 | + * |
|
70 | + * @param array $admin_options |
|
71 | + * |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function update_debug_logging_options($admin_options = array()) |
|
75 | + { |
|
76 | + $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint( |
|
77 | + $this->_req_data['use_remote_logging'] |
|
78 | + ) : $admin_options->use_remote_logging; |
|
79 | + $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw( |
|
80 | + $this->_req_data['remote_logging_url'] |
|
81 | + ) : $admin_options->remote_logging_url; |
|
82 | 82 | |
83 | - return $admin_options; |
|
84 | - } |
|
83 | + return $admin_options; |
|
84 | + } |
|
85 | 85 | } |
@@ -15,81 +15,81 @@ |
||
15 | 15 | class Admin_Options_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Admin Options Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'admin-options-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Admin Options Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'admin-options-joyride'; |
|
22 | + } |
|
23 | 23 | |
24 | - protected function _set_tour_stops() |
|
25 | - { |
|
26 | - $this->_stops = array( |
|
27 | - 10 => array( |
|
28 | - 'content' => $this->_start(), |
|
29 | - ), |
|
30 | - 30 => array( |
|
31 | - 'id' => 'use_remote_logging', |
|
32 | - 'content' => $this->_use_remote_logging_stop(), |
|
33 | - 'options' => array( |
|
34 | - 'tipLocation' => 'right', |
|
35 | - 'tipAdjustmentY' => -50, |
|
36 | - 'tipAdjustmentX' => 15, |
|
37 | - ), |
|
38 | - ), |
|
39 | - 40 => array( |
|
40 | - 'id' => 'affiliate_info', |
|
41 | - 'content' => $this->_show_reg_footer_stop(), |
|
42 | - 'options' => array( |
|
43 | - 'tipLocation' => 'right', |
|
44 | - 'tipAdjustmentY' => -50, |
|
45 | - 'tipAdjustmentX' => 15, |
|
46 | - ), |
|
47 | - ), |
|
24 | + protected function _set_tour_stops() |
|
25 | + { |
|
26 | + $this->_stops = array( |
|
27 | + 10 => array( |
|
28 | + 'content' => $this->_start(), |
|
29 | + ), |
|
30 | + 30 => array( |
|
31 | + 'id' => 'use_remote_logging', |
|
32 | + 'content' => $this->_use_remote_logging_stop(), |
|
33 | + 'options' => array( |
|
34 | + 'tipLocation' => 'right', |
|
35 | + 'tipAdjustmentY' => -50, |
|
36 | + 'tipAdjustmentX' => 15, |
|
37 | + ), |
|
38 | + ), |
|
39 | + 40 => array( |
|
40 | + 'id' => 'affiliate_info', |
|
41 | + 'content' => $this->_show_reg_footer_stop(), |
|
42 | + 'options' => array( |
|
43 | + 'tipLocation' => 'right', |
|
44 | + 'tipAdjustmentY' => -50, |
|
45 | + 'tipAdjustmentX' => 15, |
|
46 | + ), |
|
47 | + ), |
|
48 | 48 | |
49 | - 60 => array( |
|
50 | - 'id' => 'help_tour_activation', |
|
51 | - 'content' => $this->_help_tour_activation_stop(), |
|
52 | - 'options' => array( |
|
53 | - 'tipLocation' => 'right', |
|
54 | - 'tipAdjustmentY' => -50, |
|
55 | - 'tipAdjustmentX' => 15, |
|
56 | - ), |
|
57 | - ), |
|
58 | - ); |
|
59 | - } |
|
49 | + 60 => array( |
|
50 | + 'id' => 'help_tour_activation', |
|
51 | + 'content' => $this->_help_tour_activation_stop(), |
|
52 | + 'options' => array( |
|
53 | + 'tipLocation' => 'right', |
|
54 | + 'tipAdjustmentY' => -50, |
|
55 | + 'tipAdjustmentX' => 15, |
|
56 | + ), |
|
57 | + ), |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - protected function _start() |
|
63 | - { |
|
64 | - $content = '<h3>' . __('Admin Options', 'event_espresso') . '</h3>'; |
|
65 | - $content .= '<p>' |
|
66 | - . __( |
|
67 | - 'This tour of the Admin Options page will go over different areas of the screen to help you understand what they are used for.', |
|
68 | - 'event_espresso' |
|
69 | - ) . '</p>'; |
|
70 | - return $content; |
|
71 | - } |
|
62 | + protected function _start() |
|
63 | + { |
|
64 | + $content = '<h3>' . __('Admin Options', 'event_espresso') . '</h3>'; |
|
65 | + $content .= '<p>' |
|
66 | + . __( |
|
67 | + 'This tour of the Admin Options page will go over different areas of the screen to help you understand what they are used for.', |
|
68 | + 'event_espresso' |
|
69 | + ) . '</p>'; |
|
70 | + return $content; |
|
71 | + } |
|
72 | 72 | |
73 | - protected function _use_remote_logging_stop() |
|
74 | - { |
|
75 | - return '<p>' |
|
76 | - . __( |
|
77 | - ' This option sends all Event Espresso debugging data and get / post variables to the specified URL below.', |
|
78 | - 'event_espresso' |
|
79 | - ) . '</p>'; |
|
80 | - } |
|
73 | + protected function _use_remote_logging_stop() |
|
74 | + { |
|
75 | + return '<p>' |
|
76 | + . __( |
|
77 | + ' This option sends all Event Espresso debugging data and get / post variables to the specified URL below.', |
|
78 | + 'event_espresso' |
|
79 | + ) . '</p>'; |
|
80 | + } |
|
81 | 81 | |
82 | - protected function _show_reg_footer_stop() |
|
83 | - { |
|
84 | - return '<p>' |
|
85 | - . __( |
|
86 | - 'Support us by adding a small link to Event Espresso in your event pages. You can even earn money for yourself by adding your affiliate link there!', |
|
87 | - 'event_espresso' |
|
88 | - ) . '</p>'; |
|
89 | - } |
|
82 | + protected function _show_reg_footer_stop() |
|
83 | + { |
|
84 | + return '<p>' |
|
85 | + . __( |
|
86 | + 'Support us by adding a small link to Event Espresso in your event pages. You can even earn money for yourself by adding your affiliate link there!', |
|
87 | + 'event_espresso' |
|
88 | + ) . '</p>'; |
|
89 | + } |
|
90 | 90 | |
91 | - protected function _help_tour_activation_stop() |
|
92 | - { |
|
93 | - return '<p>' . __('Turn these help tours on / off for Event Espresso pages.', 'event_espresso') . '</p>'; |
|
94 | - } |
|
91 | + protected function _help_tour_activation_stop() |
|
92 | + { |
|
93 | + return '<p>' . __('Turn these help tours on / off for Event Espresso pages.', 'event_espresso') . '</p>'; |
|
94 | + } |
|
95 | 95 | } |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | |
62 | 62 | protected function _start() |
63 | 63 | { |
64 | - $content = '<h3>' . __('Admin Options', 'event_espresso') . '</h3>'; |
|
64 | + $content = '<h3>'.__('Admin Options', 'event_espresso').'</h3>'; |
|
65 | 65 | $content .= '<p>' |
66 | 66 | . __( |
67 | 67 | 'This tour of the Admin Options page will go over different areas of the screen to help you understand what they are used for.', |
68 | 68 | 'event_espresso' |
69 | - ) . '</p>'; |
|
69 | + ).'</p>'; |
|
70 | 70 | return $content; |
71 | 71 | } |
72 | 72 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | . __( |
77 | 77 | ' This option sends all Event Espresso debugging data and get / post variables to the specified URL below.', |
78 | 78 | 'event_espresso' |
79 | - ) . '</p>'; |
|
79 | + ).'</p>'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | protected function _show_reg_footer_stop() |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | . __( |
86 | 86 | 'Support us by adding a small link to Event Espresso in your event pages. You can even earn money for yourself by adding your affiliate link there!', |
87 | 87 | 'event_espresso' |
88 | - ) . '</p>'; |
|
88 | + ).'</p>'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | protected function _help_tour_activation_stop() |
92 | 92 | { |
93 | - return '<p>' . __('Turn these help tours on / off for Event Espresso pages.', 'event_espresso') . '</p>'; |
|
93 | + return '<p>'.__('Turn these help tours on / off for Event Espresso pages.', 'event_espresso').'</p>'; |
|
94 | 94 | } |
95 | 95 | } |
@@ -32,12 +32,12 @@ |
||
32 | 32 | <li> |
33 | 33 | <strong><?php esc_html_e('Event Espresso Affiliate ID', 'event_espresso'); ?></strong><br /> |
34 | 34 | <?php printf( |
35 | - esc_html__( |
|
36 | - 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - '<a href="https://eventespresso.com/affiliates/">', |
|
40 | - '</a>' |
|
35 | + esc_html__( |
|
36 | + 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + '<a href="https://eventespresso.com/affiliates/">', |
|
40 | + '</a>' |
|
41 | 41 | ); ?> |
42 | 42 | </li> |
43 | 43 | </ul> |
@@ -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.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) { |
|
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.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) { |
|
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, |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | PRIMARY KEY (ATTM_ID), |
118 | 118 | KEY ATT_ID (ATT_ID), |
119 | 119 | KEY ATT_email (ATT_email(191))"; |
120 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
121 | - $table_name = 'esp_country'; |
|
122 | - $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
120 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
121 | + $table_name = 'esp_country'; |
|
122 | + $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
123 | 123 | CNT_ISO3 varchar(3) collate utf8_bin NOT NULL, |
124 | 124 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
125 | 125 | CNT_name varchar(45) collate utf8_bin NOT NULL, |
@@ -135,25 +135,25 @@ discard block |
||
135 | 135 | CNT_is_EU tinyint(1) DEFAULT '0', |
136 | 136 | CNT_active tinyint(1) DEFAULT '0', |
137 | 137 | PRIMARY KEY (CNT_ISO)"; |
138 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
139 | - $table_name = 'esp_currency'; |
|
140 | - $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
138 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
139 | + $table_name = 'esp_currency'; |
|
140 | + $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
141 | 141 | CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar', |
142 | 142 | CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars', |
143 | 143 | CUR_sign varchar(45) collate utf8_bin DEFAULT '$', |
144 | 144 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
145 | 145 | CUR_active tinyint(1) DEFAULT '0', |
146 | 146 | PRIMARY KEY (CUR_code)"; |
147 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
148 | - $table_name = 'esp_currency_payment_method'; |
|
149 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
147 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
148 | + $table_name = 'esp_currency_payment_method'; |
|
149 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
150 | 150 | CUR_code varchar(6) collate utf8_bin NOT NULL, |
151 | 151 | PMD_ID int(11) NOT NULL, |
152 | 152 | PRIMARY KEY (CPM_ID), |
153 | 153 | KEY PMD_ID (PMD_ID)"; |
154 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
155 | - $table_name = 'esp_datetime'; |
|
156 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
154 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
155 | + $table_name = 'esp_datetime'; |
|
156 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
157 | 157 | EVT_ID bigint(20) unsigned NOT NULL, |
158 | 158 | DTT_name varchar(255) NOT NULL DEFAULT '', |
159 | 159 | DTT_description text NOT NULL, |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | KEY DTT_EVT_start (DTT_EVT_start), |
170 | 170 | KEY EVT_ID (EVT_ID), |
171 | 171 | KEY DTT_is_primary (DTT_is_primary)"; |
172 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
173 | - $table_name = 'esp_event_meta'; |
|
174 | - $sql = " |
|
172 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
173 | + $table_name = 'esp_event_meta'; |
|
174 | + $sql = " |
|
175 | 175 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
176 | 176 | EVT_ID bigint(20) unsigned NOT NULL, |
177 | 177 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -187,34 +187,34 @@ discard block |
||
187 | 187 | EVT_donations tinyint(1) NULL, |
188 | 188 | PRIMARY KEY (EVTM_ID), |
189 | 189 | KEY EVT_ID (EVT_ID)"; |
190 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | - $table_name = 'esp_event_question_group'; |
|
192 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
190 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | + $table_name = 'esp_event_question_group'; |
|
192 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
193 | 193 | EVT_ID bigint(20) unsigned NOT NULL, |
194 | 194 | QSG_ID int(10) unsigned NOT NULL, |
195 | 195 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
196 | 196 | PRIMARY KEY (EQG_ID), |
197 | 197 | KEY EVT_ID (EVT_ID), |
198 | 198 | KEY QSG_ID (QSG_ID)"; |
199 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
200 | - $table_name = 'esp_event_venue'; |
|
201 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
199 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
200 | + $table_name = 'esp_event_venue'; |
|
201 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
202 | 202 | EVT_ID bigint(20) unsigned NOT NULL, |
203 | 203 | VNU_ID bigint(20) unsigned NOT NULL, |
204 | 204 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
205 | 205 | PRIMARY KEY (EVV_ID)"; |
206 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
207 | - $table_name = 'esp_extra_meta'; |
|
208 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
206 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
207 | + $table_name = 'esp_extra_meta'; |
|
208 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
209 | 209 | OBJ_ID int(11) DEFAULT NULL, |
210 | 210 | EXM_type varchar(45) DEFAULT NULL, |
211 | 211 | EXM_key varchar(45) DEFAULT NULL, |
212 | 212 | EXM_value text, |
213 | 213 | PRIMARY KEY (EXM_ID), |
214 | 214 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
215 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | - $table_name = 'esp_extra_join'; |
|
217 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
215 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | + $table_name = 'esp_extra_join'; |
|
217 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
218 | 218 | EXJ_first_model_id varchar(6) NOT NULL, |
219 | 219 | EXJ_first_model_name varchar(20) NOT NULL, |
220 | 220 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | PRIMARY KEY (EXJ_ID), |
223 | 223 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
224 | 224 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
225 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
226 | - $table_name = 'esp_line_item'; |
|
227 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
225 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
226 | + $table_name = 'esp_line_item'; |
|
227 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
228 | 228 | LIN_code varchar(245) NOT NULL DEFAULT '', |
229 | 229 | TXN_ID int(11) DEFAULT NULL, |
230 | 230 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | PRIMARY KEY (LIN_ID), |
244 | 244 | KEY LIN_code (LIN_code(191)), |
245 | 245 | KEY TXN_ID (TXN_ID)"; |
246 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | - $table_name = 'esp_log'; |
|
248 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
246 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | + $table_name = 'esp_log'; |
|
248 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
249 | 249 | LOG_time datetime DEFAULT NULL, |
250 | 250 | OBJ_ID varchar(45) DEFAULT NULL, |
251 | 251 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -256,18 +256,18 @@ discard block |
||
256 | 256 | KEY LOG_time (LOG_time), |
257 | 257 | KEY OBJ (OBJ_type,OBJ_ID), |
258 | 258 | KEY LOG_type (LOG_type)"; |
259 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | - $table_name = 'esp_message_template'; |
|
261 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
259 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | + $table_name = 'esp_message_template'; |
|
261 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
262 | 262 | GRP_ID int(10) unsigned NOT NULL, |
263 | 263 | MTP_context varchar(50) NOT NULL, |
264 | 264 | MTP_template_field varchar(30) NOT NULL, |
265 | 265 | MTP_content text NOT NULL, |
266 | 266 | PRIMARY KEY (MTP_ID), |
267 | 267 | KEY GRP_ID (GRP_ID)"; |
268 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
269 | - $table_name = 'esp_message_template_group'; |
|
270 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
268 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
269 | + $table_name = 'esp_message_template_group'; |
|
270 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
271 | 271 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
272 | 272 | MTP_name varchar(245) NOT NULL DEFAULT '', |
273 | 273 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
280 | 280 | PRIMARY KEY (GRP_ID), |
281 | 281 | KEY MTP_user_id (MTP_user_id)"; |
282 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
283 | - $table_name = 'esp_event_message_template'; |
|
284 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
282 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
283 | + $table_name = 'esp_event_message_template'; |
|
284 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
285 | 285 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
286 | 286 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
287 | 287 | PRIMARY KEY (EMT_ID), |
288 | 288 | KEY EVT_ID (EVT_ID), |
289 | 289 | KEY GRP_ID (GRP_ID)"; |
290 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
291 | - $table_name = 'esp_payment'; |
|
292 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
290 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
291 | + $table_name = 'esp_payment'; |
|
292 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
293 | 293 | TXN_ID int(10) unsigned DEFAULT NULL, |
294 | 294 | STS_ID varchar(3) collate utf8_bin DEFAULT NULL, |
295 | 295 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | PRIMARY KEY (PAY_ID), |
307 | 307 | KEY PAY_timestamp (PAY_timestamp), |
308 | 308 | KEY TXN_ID (TXN_ID)"; |
309 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
310 | - $table_name = 'esp_payment_method'; |
|
311 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
309 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
310 | + $table_name = 'esp_payment_method'; |
|
311 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
312 | 312 | PMD_type varchar(124) DEFAULT NULL, |
313 | 313 | PMD_name varchar(255) DEFAULT NULL, |
314 | 314 | PMD_desc text, |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | PRIMARY KEY (PMD_ID), |
325 | 325 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
326 | 326 | KEY PMD_type (PMD_type)"; |
327 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
328 | - $table_name = "esp_ticket_price"; |
|
329 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
327 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
328 | + $table_name = "esp_ticket_price"; |
|
329 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
330 | 330 | TKT_ID int(10) unsigned NOT NULL, |
331 | 331 | PRC_ID int(10) unsigned NOT NULL, |
332 | 332 | PRIMARY KEY (TKP_ID), |
333 | 333 | KEY TKT_ID (TKT_ID), |
334 | 334 | KEY PRC_ID (PRC_ID)"; |
335 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
336 | - $table_name = "esp_datetime_ticket"; |
|
337 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
335 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
336 | + $table_name = "esp_datetime_ticket"; |
|
337 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
338 | 338 | DTT_ID int(10) unsigned NOT NULL, |
339 | 339 | TKT_ID int(10) unsigned NOT NULL, |
340 | 340 | PRIMARY KEY (DTK_ID), |
341 | 341 | KEY DTT_ID (DTT_ID), |
342 | 342 | KEY TKT_ID (TKT_ID)"; |
343 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | - $table_name = "esp_ticket_template"; |
|
345 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | + $table_name = "esp_ticket_template"; |
|
345 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
346 | 346 | TTM_name varchar(45) NOT NULL, |
347 | 347 | TTM_description text, |
348 | 348 | TTM_file varchar(45), |
349 | 349 | PRIMARY KEY (TTM_ID)"; |
350 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | - $table_name = 'esp_question'; |
|
352 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
350 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | + $table_name = 'esp_question'; |
|
352 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
353 | 353 | QST_display_text text NOT NULL, |
354 | 354 | QST_admin_label varchar(255) NOT NULL, |
355 | 355 | QST_system varchar(25) NOT NULL DEFAULT "", |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
364 | 364 | PRIMARY KEY (QST_ID), |
365 | 365 | KEY QST_order (QST_order)'; |
366 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
367 | - $table_name = 'esp_question_group_question'; |
|
368 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
366 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
367 | + $table_name = 'esp_question_group_question'; |
|
368 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
369 | 369 | QSG_ID int(10) unsigned NOT NULL, |
370 | 370 | QST_ID int(10) unsigned NOT NULL, |
371 | 371 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
372 | 372 | PRIMARY KEY (QGQ_ID), |
373 | 373 | KEY QST_ID (QST_ID), |
374 | 374 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
375 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | - $table_name = 'esp_question_option'; |
|
377 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | + $table_name = 'esp_question_option'; |
|
377 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
378 | 378 | QSO_value varchar(255) NOT NULL, |
379 | 379 | QSO_desc text NOT NULL, |
380 | 380 | QST_ID int(10) unsigned NOT NULL, |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | PRIMARY KEY (QSO_ID), |
385 | 385 | KEY QST_ID (QST_ID), |
386 | 386 | KEY QSO_order (QSO_order)"; |
387 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
388 | - $table_name = 'esp_registration'; |
|
389 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
388 | + $table_name = 'esp_registration'; |
|
389 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
390 | 390 | EVT_ID bigint(20) unsigned NOT NULL, |
391 | 391 | ATT_ID bigint(20) unsigned NOT NULL, |
392 | 392 | TXN_ID int(10) unsigned NOT NULL, |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | KEY TKT_ID (TKT_ID), |
411 | 411 | KEY EVT_ID (EVT_ID), |
412 | 412 | KEY STS_ID (STS_ID)"; |
413 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
414 | - $table_name = 'esp_registration_payment'; |
|
415 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
413 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
414 | + $table_name = 'esp_registration_payment'; |
|
415 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | 416 | REG_ID int(10) unsigned NOT NULL, |
417 | 417 | PAY_ID int(10) unsigned NULL, |
418 | 418 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
419 | 419 | PRIMARY KEY (RPY_ID), |
420 | 420 | KEY REG_ID (REG_ID), |
421 | 421 | KEY PAY_ID (PAY_ID)"; |
422 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
423 | - $table_name = 'esp_checkin'; |
|
424 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
422 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
423 | + $table_name = 'esp_checkin'; |
|
424 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
425 | 425 | REG_ID int(10) unsigned NOT NULL, |
426 | 426 | DTT_ID int(10) unsigned NOT NULL, |
427 | 427 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | PRIMARY KEY (CHK_ID), |
430 | 430 | KEY REG_ID (REG_ID), |
431 | 431 | KEY DTT_ID (DTT_ID)"; |
432 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | - $table_name = 'esp_state'; |
|
434 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $table_name = 'esp_state'; |
|
434 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
435 | 435 | CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
436 | 436 | STA_abbrev varchar(24) collate utf8_bin NOT NULL, |
437 | 437 | STA_name varchar(100) collate utf8_bin NOT NULL, |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | PRIMARY KEY (STA_ID), |
440 | 440 | KEY STA_abbrev (STA_abbrev), |
441 | 441 | KEY CNT_ISO (CNT_ISO)"; |
442 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
443 | - $table_name = 'esp_status'; |
|
444 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
442 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
443 | + $table_name = 'esp_status'; |
|
444 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
445 | 445 | STS_code varchar(45) NOT NULL, |
446 | 446 | STS_type varchar(45) NOT NULL, |
447 | 447 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
450 | 450 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
451 | 451 | KEY STS_type (STS_type)"; |
452 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
453 | - $table_name = 'esp_transaction'; |
|
454 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
452 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
453 | + $table_name = 'esp_transaction'; |
|
454 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
455 | 455 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
456 | 456 | TXN_total decimal(10,3) DEFAULT '0.00', |
457 | 457 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | PRIMARY KEY (TXN_ID), |
464 | 464 | KEY TXN_timestamp (TXN_timestamp), |
465 | 465 | KEY STS_ID (STS_ID)"; |
466 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | - $table_name = 'esp_venue_meta'; |
|
468 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
466 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | + $table_name = 'esp_venue_meta'; |
|
468 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
469 | 469 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
470 | 470 | VNU_address varchar(255) DEFAULT NULL, |
471 | 471 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | KEY VNU_ID (VNU_ID), |
485 | 485 | KEY STA_ID (STA_ID), |
486 | 486 | KEY CNT_ISO (CNT_ISO)"; |
487 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | - // modified tables |
|
489 | - $table_name = "esp_price"; |
|
490 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
487 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | + // modified tables |
|
489 | + $table_name = "esp_price"; |
|
490 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | 491 | PRT_ID tinyint(3) unsigned NOT NULL, |
492 | 492 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
493 | 493 | PRC_name varchar(245) NOT NULL, |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | PRC_parent int(10) unsigned DEFAULT 0, |
501 | 501 | PRIMARY KEY (PRC_ID), |
502 | 502 | KEY PRT_ID (PRT_ID)"; |
503 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
504 | - $table_name = "esp_price_type"; |
|
505 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
503 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
504 | + $table_name = "esp_price_type"; |
|
505 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
506 | 506 | PRT_name varchar(45) NOT NULL, |
507 | 507 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
508 | 508 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
512 | 512 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
513 | 513 | PRIMARY KEY (PRT_ID)"; |
514 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
515 | - $table_name = "esp_ticket"; |
|
516 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
514 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
515 | + $table_name = "esp_ticket"; |
|
516 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
517 | 517 | TTM_ID int(10) unsigned NOT NULL, |
518 | 518 | TKT_name varchar(245) NOT NULL DEFAULT '', |
519 | 519 | TKT_description text NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
536 | 536 | PRIMARY KEY (TKT_ID), |
537 | 537 | KEY TKT_start_date (TKT_start_date)"; |
538 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | - $table_name = 'esp_question_group'; |
|
540 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $table_name = 'esp_question_group'; |
|
540 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | QSG_name varchar(255) NOT NULL, |
542 | 542 | QSG_identifier varchar(100) NOT NULL, |
543 | 543 | QSG_desc text NULL, |
@@ -550,223 +550,223 @@ discard block |
||
550 | 550 | PRIMARY KEY (QSG_ID), |
551 | 551 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
552 | 552 | KEY QSG_order (QSG_order)'; |
553 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
554 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
555 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
556 | - // (because many need to convert old string states to foreign keys into the states table) |
|
557 | - $script_4_1_defaults->insert_default_states(); |
|
558 | - $script_4_1_defaults->insert_default_countries(); |
|
559 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
560 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
561 | - $script_4_5_defaults->insert_default_price_types(); |
|
562 | - $script_4_5_defaults->insert_default_prices(); |
|
563 | - $script_4_5_defaults->insert_default_tickets(); |
|
564 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
565 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
566 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
567 | - $script_4_6_defaults->insert_default_currencies(); |
|
568 | - $this->verify_new_countries(); |
|
569 | - $this->verify_new_currencies(); |
|
570 | - return true; |
|
571 | - } |
|
553 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
554 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
555 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
556 | + // (because many need to convert old string states to foreign keys into the states table) |
|
557 | + $script_4_1_defaults->insert_default_states(); |
|
558 | + $script_4_1_defaults->insert_default_countries(); |
|
559 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
560 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
561 | + $script_4_5_defaults->insert_default_price_types(); |
|
562 | + $script_4_5_defaults->insert_default_prices(); |
|
563 | + $script_4_5_defaults->insert_default_tickets(); |
|
564 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
565 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
566 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
567 | + $script_4_6_defaults->insert_default_currencies(); |
|
568 | + $this->verify_new_countries(); |
|
569 | + $this->verify_new_currencies(); |
|
570 | + return true; |
|
571 | + } |
|
572 | 572 | |
573 | 573 | |
574 | 574 | |
575 | - /** |
|
576 | - * @return boolean |
|
577 | - */ |
|
578 | - public function schema_changes_after_migration() |
|
579 | - { |
|
580 | - $this->fix_non_default_taxes(); |
|
581 | - // this is actually the same as the last DMS |
|
582 | - /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
583 | - $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
584 | - return $script_4_7_defaults->schema_changes_after_migration(); |
|
585 | - } |
|
575 | + /** |
|
576 | + * @return boolean |
|
577 | + */ |
|
578 | + public function schema_changes_after_migration() |
|
579 | + { |
|
580 | + $this->fix_non_default_taxes(); |
|
581 | + // this is actually the same as the last DMS |
|
582 | + /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
583 | + $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
584 | + return $script_4_7_defaults->schema_changes_after_migration(); |
|
585 | + } |
|
586 | 586 | |
587 | 587 | |
588 | 588 | |
589 | - public function migration_page_hooks() |
|
590 | - { |
|
591 | - } |
|
589 | + public function migration_page_hooks() |
|
590 | + { |
|
591 | + } |
|
592 | 592 | |
593 | 593 | |
594 | 594 | |
595 | - /** |
|
596 | - * verifies each of the new countries exists that somehow we missed in 4.1 |
|
597 | - */ |
|
598 | - public function verify_new_countries() |
|
599 | - { |
|
600 | - // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
601 | - // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
602 | - // currency symbols: http://www.xe.com/symbols.php |
|
603 | - // 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 |
|
604 | - // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
605 | - $newer_countries = array( |
|
606 | - array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0), |
|
607 | - array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
608 | - array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0), |
|
609 | - array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0), |
|
610 | - array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
611 | - array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
612 | - array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
613 | - array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0), |
|
614 | - array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0), |
|
615 | - array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0), |
|
616 | - array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0), |
|
617 | - array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0), |
|
618 | - array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0), |
|
619 | - array( |
|
620 | - 'BQ', |
|
621 | - 'BES', |
|
622 | - 0, |
|
623 | - 'Bonaire, Saint Eustatius and Saba', |
|
624 | - 'USD', |
|
625 | - 'Dollar', |
|
626 | - 'Dollars', |
|
627 | - '$', |
|
628 | - 1, |
|
629 | - 2, |
|
630 | - '+599', |
|
631 | - 0, |
|
632 | - 0, |
|
633 | - ), |
|
634 | - array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0), |
|
635 | - array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0), |
|
636 | - array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0), |
|
637 | - array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0), |
|
638 | - array( |
|
639 | - 'HM', |
|
640 | - 'HMD', |
|
641 | - 0, |
|
642 | - 'Heard Island and McDonald Islands', |
|
643 | - 'AUD', |
|
644 | - 'Dollar', |
|
645 | - 'Dollars', |
|
646 | - '$', |
|
647 | - 1, |
|
648 | - 2, |
|
649 | - '+891', |
|
650 | - 0, |
|
651 | - 0, |
|
652 | - ), |
|
653 | - array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0), |
|
654 | - array( |
|
655 | - 'GS', |
|
656 | - 'SGS', |
|
657 | - 0, |
|
658 | - 'South Georgia and the South Sandwich Islands', |
|
659 | - 'GBP', |
|
660 | - 'Pound', |
|
661 | - 'Pounds', |
|
662 | - '£', |
|
663 | - 1, |
|
664 | - 2, |
|
665 | - '+500', |
|
666 | - 0, |
|
667 | - 0, |
|
668 | - ), |
|
669 | - array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0), |
|
670 | - array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0), |
|
671 | - array( |
|
672 | - 'UM', |
|
673 | - 'UMI', |
|
674 | - 0, |
|
675 | - 'United States Minor Outlying Islands', |
|
676 | - 'USD', |
|
677 | - 'Dollar', |
|
678 | - 'Dollars', |
|
679 | - '$', |
|
680 | - 1, |
|
681 | - 2, |
|
682 | - '+1', |
|
683 | - 0, |
|
684 | - 0, |
|
685 | - ), |
|
686 | - ); |
|
687 | - global $wpdb; |
|
688 | - $country_table = $wpdb->prefix . "esp_country"; |
|
689 | - $country_format = array( |
|
690 | - "CNT_ISO" => '%s', |
|
691 | - "CNT_ISO3" => '%s', |
|
692 | - "RGN_ID" => '%d', |
|
693 | - "CNT_name" => '%s', |
|
694 | - "CNT_cur_code" => '%s', |
|
695 | - "CNT_cur_single" => '%s', |
|
696 | - "CNT_cur_plural" => '%s', |
|
697 | - "CNT_cur_sign" => '%s', |
|
698 | - "CNT_cur_sign_b4" => '%d', |
|
699 | - "CNT_cur_dec_plc" => '%d', |
|
700 | - "CNT_tel_code" => '%s', |
|
701 | - "CNT_is_EU" => '%d', |
|
702 | - "CNT_active" => '%d', |
|
703 | - ); |
|
704 | - if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
705 | - foreach ($newer_countries as $country) { |
|
706 | - $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
|
707 | - $countries = $wpdb->get_var($SQL); |
|
708 | - if (! $countries) { |
|
709 | - $wpdb->insert( |
|
710 | - $country_table, |
|
711 | - array_combine(array_keys($country_format), $country), |
|
712 | - $country_format |
|
713 | - ); |
|
714 | - } |
|
715 | - } |
|
716 | - } |
|
717 | - } |
|
595 | + /** |
|
596 | + * verifies each of the new countries exists that somehow we missed in 4.1 |
|
597 | + */ |
|
598 | + public function verify_new_countries() |
|
599 | + { |
|
600 | + // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
601 | + // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
602 | + // currency symbols: http://www.xe.com/symbols.php |
|
603 | + // 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 |
|
604 | + // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
605 | + $newer_countries = array( |
|
606 | + array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0), |
|
607 | + array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
608 | + array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0), |
|
609 | + array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0), |
|
610 | + array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
611 | + array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
612 | + array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
613 | + array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0), |
|
614 | + array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0), |
|
615 | + array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0), |
|
616 | + array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0), |
|
617 | + array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0), |
|
618 | + array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0), |
|
619 | + array( |
|
620 | + 'BQ', |
|
621 | + 'BES', |
|
622 | + 0, |
|
623 | + 'Bonaire, Saint Eustatius and Saba', |
|
624 | + 'USD', |
|
625 | + 'Dollar', |
|
626 | + 'Dollars', |
|
627 | + '$', |
|
628 | + 1, |
|
629 | + 2, |
|
630 | + '+599', |
|
631 | + 0, |
|
632 | + 0, |
|
633 | + ), |
|
634 | + array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0), |
|
635 | + array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0), |
|
636 | + array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0), |
|
637 | + array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0), |
|
638 | + array( |
|
639 | + 'HM', |
|
640 | + 'HMD', |
|
641 | + 0, |
|
642 | + 'Heard Island and McDonald Islands', |
|
643 | + 'AUD', |
|
644 | + 'Dollar', |
|
645 | + 'Dollars', |
|
646 | + '$', |
|
647 | + 1, |
|
648 | + 2, |
|
649 | + '+891', |
|
650 | + 0, |
|
651 | + 0, |
|
652 | + ), |
|
653 | + array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0), |
|
654 | + array( |
|
655 | + 'GS', |
|
656 | + 'SGS', |
|
657 | + 0, |
|
658 | + 'South Georgia and the South Sandwich Islands', |
|
659 | + 'GBP', |
|
660 | + 'Pound', |
|
661 | + 'Pounds', |
|
662 | + '£', |
|
663 | + 1, |
|
664 | + 2, |
|
665 | + '+500', |
|
666 | + 0, |
|
667 | + 0, |
|
668 | + ), |
|
669 | + array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0), |
|
670 | + array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0), |
|
671 | + array( |
|
672 | + 'UM', |
|
673 | + 'UMI', |
|
674 | + 0, |
|
675 | + 'United States Minor Outlying Islands', |
|
676 | + 'USD', |
|
677 | + 'Dollar', |
|
678 | + 'Dollars', |
|
679 | + '$', |
|
680 | + 1, |
|
681 | + 2, |
|
682 | + '+1', |
|
683 | + 0, |
|
684 | + 0, |
|
685 | + ), |
|
686 | + ); |
|
687 | + global $wpdb; |
|
688 | + $country_table = $wpdb->prefix . "esp_country"; |
|
689 | + $country_format = array( |
|
690 | + "CNT_ISO" => '%s', |
|
691 | + "CNT_ISO3" => '%s', |
|
692 | + "RGN_ID" => '%d', |
|
693 | + "CNT_name" => '%s', |
|
694 | + "CNT_cur_code" => '%s', |
|
695 | + "CNT_cur_single" => '%s', |
|
696 | + "CNT_cur_plural" => '%s', |
|
697 | + "CNT_cur_sign" => '%s', |
|
698 | + "CNT_cur_sign_b4" => '%d', |
|
699 | + "CNT_cur_dec_plc" => '%d', |
|
700 | + "CNT_tel_code" => '%s', |
|
701 | + "CNT_is_EU" => '%d', |
|
702 | + "CNT_active" => '%d', |
|
703 | + ); |
|
704 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
705 | + foreach ($newer_countries as $country) { |
|
706 | + $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
|
707 | + $countries = $wpdb->get_var($SQL); |
|
708 | + if (! $countries) { |
|
709 | + $wpdb->insert( |
|
710 | + $country_table, |
|
711 | + array_combine(array_keys($country_format), $country), |
|
712 | + $country_format |
|
713 | + ); |
|
714 | + } |
|
715 | + } |
|
716 | + } |
|
717 | + } |
|
718 | 718 | |
719 | 719 | |
720 | 720 | |
721 | - /** |
|
722 | - * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
723 | - */ |
|
724 | - public function verify_new_currencies() |
|
725 | - { |
|
726 | - // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
727 | - // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
728 | - // currency symbols: http://www.xe.com/symbols.php |
|
729 | - // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
730 | - // ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
731 | - $newer_currencies = array( |
|
732 | - array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
|
733 | - ); |
|
734 | - global $wpdb; |
|
735 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
736 | - $currency_format = array( |
|
737 | - "CUR_code" => '%s', |
|
738 | - "CUR_single" => '%s', |
|
739 | - "CUR_plural" => '%s', |
|
740 | - "CUR_sign" => '%s', |
|
741 | - "CUR_dec_plc" => '%d', |
|
742 | - "CUR_active" => '%d', |
|
743 | - ); |
|
744 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
745 | - foreach ($newer_currencies as $currency) { |
|
746 | - $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
|
747 | - $countries = $wpdb->get_var($SQL); |
|
748 | - if (! $countries) { |
|
749 | - $wpdb->insert( |
|
750 | - $currency_table, |
|
751 | - array_combine(array_keys($currency_format), $currency), |
|
752 | - $currency_format |
|
753 | - ); |
|
754 | - } |
|
755 | - } |
|
756 | - } |
|
757 | - } |
|
721 | + /** |
|
722 | + * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
723 | + */ |
|
724 | + public function verify_new_currencies() |
|
725 | + { |
|
726 | + // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
727 | + // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
728 | + // currency symbols: http://www.xe.com/symbols.php |
|
729 | + // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
730 | + // ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
731 | + $newer_currencies = array( |
|
732 | + array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
|
733 | + ); |
|
734 | + global $wpdb; |
|
735 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
736 | + $currency_format = array( |
|
737 | + "CUR_code" => '%s', |
|
738 | + "CUR_single" => '%s', |
|
739 | + "CUR_plural" => '%s', |
|
740 | + "CUR_sign" => '%s', |
|
741 | + "CUR_dec_plc" => '%d', |
|
742 | + "CUR_active" => '%d', |
|
743 | + ); |
|
744 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
745 | + foreach ($newer_currencies as $currency) { |
|
746 | + $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
|
747 | + $countries = $wpdb->get_var($SQL); |
|
748 | + if (! $countries) { |
|
749 | + $wpdb->insert( |
|
750 | + $currency_table, |
|
751 | + array_combine(array_keys($currency_format), $currency), |
|
752 | + $currency_format |
|
753 | + ); |
|
754 | + } |
|
755 | + } |
|
756 | + } |
|
757 | + } |
|
758 | 758 | |
759 | 759 | |
760 | 760 | |
761 | - /** |
|
762 | - * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
763 | - * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
764 | - * we should be able to stop doing this in 4.9 |
|
765 | - */ |
|
766 | - public function fix_non_default_taxes() |
|
767 | - { |
|
768 | - global $wpdb; |
|
769 | - $query = $wpdb->prepare("UPDATE |
|
761 | + /** |
|
762 | + * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
763 | + * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
764 | + * we should be able to stop doing this in 4.9 |
|
765 | + */ |
|
766 | + public function fix_non_default_taxes() |
|
767 | + { |
|
768 | + global $wpdb; |
|
769 | + $query = $wpdb->prepare("UPDATE |
|
770 | 770 | {$wpdb->prefix}esp_price p INNER JOIN |
771 | 771 | {$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID |
772 | 772 | SET |
@@ -775,6 +775,6 @@ discard block |
||
775 | 775 | p.PRC_is_default = 0 AND |
776 | 776 | pt.PBT_ID = %d |
777 | 777 | ", EEM_Price_Type::base_type_tax); |
778 | - $wpdb->query($query); |
|
779 | - } |
|
778 | + $wpdb->query($query); |
|
779 | + } |
|
780 | 780 | } |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | // unfortunately, this needs to be done upon INCLUSION of this file, |
15 | 15 | // instead of construction, because it only gets constructed on first page load |
16 | 16 | // (all other times it gets resurrected from a wordpress option) |
17 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*'); |
|
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 | 20 | $matches = array(); |
21 | 21 | preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
22 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
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); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | if (version_compare($version_string, '4.8.0.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) { |
73 | 73 | // echo "$version_string can be migrated from"; |
74 | 74 | return true; |
75 | - } elseif (! $version_string) { |
|
75 | + } elseif ( ! $version_string) { |
|
76 | 76 | // echo "no version string provided: $version_string"; |
77 | 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 |
|
78 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | 79 | } else { |
80 | 80 | // echo "$version_string doesnt apply"; |
81 | 81 | return false; |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function schema_changes_before_migration() |
91 | 91 | { |
92 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
93 | 93 | $now_in_mysql = current_time('mysql', true); |
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
94 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
95 | 95 | $table_name = 'esp_answer'; |
96 | 96 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
97 | 97 | REG_ID int(10) unsigned NOT NULL, |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | ), |
686 | 686 | ); |
687 | 687 | global $wpdb; |
688 | - $country_table = $wpdb->prefix . "esp_country"; |
|
688 | + $country_table = $wpdb->prefix."esp_country"; |
|
689 | 689 | $country_format = array( |
690 | 690 | "CNT_ISO" => '%s', |
691 | 691 | "CNT_ISO3" => '%s', |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | foreach ($newer_countries as $country) { |
706 | 706 | $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
707 | 707 | $countries = $wpdb->get_var($SQL); |
708 | - if (! $countries) { |
|
708 | + if ( ! $countries) { |
|
709 | 709 | $wpdb->insert( |
710 | 710 | $country_table, |
711 | 711 | array_combine(array_keys($country_format), $country), |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
733 | 733 | ); |
734 | 734 | global $wpdb; |
735 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
735 | + $currency_table = $wpdb->prefix."esp_currency"; |
|
736 | 736 | $currency_format = array( |
737 | 737 | "CUR_code" => '%s', |
738 | 738 | "CUR_single" => '%s', |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | foreach ($newer_currencies as $currency) { |
746 | 746 | $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
747 | 747 | $countries = $wpdb->get_var($SQL); |
748 | - if (! $countries) { |
|
748 | + if ( ! $countries) { |
|
749 | 749 | $wpdb->insert( |
750 | 750 | $currency_table, |
751 | 751 | array_combine(array_keys($currency_format), $currency), |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | $stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*'); |
17 | 17 | $class_to_filepath = array(); |
18 | 18 | foreach ($stages as $filepath) { |
19 | - $matches = array(); |
|
20 | - preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
21 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
19 | + $matches = array(); |
|
20 | + preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
21 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
22 | 22 | } |
23 | 23 | // give addons a chance to autoload their stages too |
24 | 24 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath); |
@@ -31,59 +31,59 @@ discard block |
||
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * EE_DMS_Core_4_5_0 constructor. |
|
36 | - * |
|
37 | - * @param TableManager $table_manager |
|
38 | - * @param TableAnalysis $table_analysis |
|
39 | - */ |
|
40 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | - { |
|
42 | - $this->_pretty_name = __("Data Update to Event Espresso 4.5.0", "event_espresso"); |
|
43 | - $this->_priority = 10; |
|
44 | - $this->_migration_stages = array( |
|
45 | - new EE_DMS_4_5_0_update_wp_user_for_tickets(), |
|
46 | - new EE_DMS_4_5_0_update_wp_user_for_prices(), |
|
47 | - new EE_DMS_4_5_0_update_wp_user_for_price_types(), |
|
48 | - new EE_DMS_4_5_0_update_wp_user_for_question_groups(), |
|
49 | - new EE_DMS_4_5_0_invoice_settings(), |
|
50 | - ); |
|
51 | - parent::__construct($table_manager, $table_analysis); |
|
52 | - } |
|
34 | + /** |
|
35 | + * EE_DMS_Core_4_5_0 constructor. |
|
36 | + * |
|
37 | + * @param TableManager $table_manager |
|
38 | + * @param TableAnalysis $table_analysis |
|
39 | + */ |
|
40 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | + { |
|
42 | + $this->_pretty_name = __("Data Update to Event Espresso 4.5.0", "event_espresso"); |
|
43 | + $this->_priority = 10; |
|
44 | + $this->_migration_stages = array( |
|
45 | + new EE_DMS_4_5_0_update_wp_user_for_tickets(), |
|
46 | + new EE_DMS_4_5_0_update_wp_user_for_prices(), |
|
47 | + new EE_DMS_4_5_0_update_wp_user_for_price_types(), |
|
48 | + new EE_DMS_4_5_0_update_wp_user_for_question_groups(), |
|
49 | + new EE_DMS_4_5_0_invoice_settings(), |
|
50 | + ); |
|
51 | + parent::__construct($table_manager, $table_analysis); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - public function can_migrate_from_version($version_array) |
|
57 | - { |
|
58 | - $version_string = $version_array['Core']; |
|
59 | - if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) { |
|
56 | + public function can_migrate_from_version($version_array) |
|
57 | + { |
|
58 | + $version_string = $version_array['Core']; |
|
59 | + if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) { |
|
60 | 60 | // echo "$version_string can be migrated from"; |
61 | - return true; |
|
62 | - } elseif (! $version_string) { |
|
61 | + return true; |
|
62 | + } elseif (! $version_string) { |
|
63 | 63 | // echo "no version string provided: $version_string"; |
64 | - // no version string provided... this must be pre 4.3 |
|
65 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
66 | - } else { |
|
64 | + // no version string provided... this must be pre 4.3 |
|
65 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
66 | + } else { |
|
67 | 67 | // echo "$version_string doesnt apply"; |
68 | - return false; |
|
69 | - } |
|
70 | - } |
|
68 | + return false; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | 73 | |
74 | - public function schema_changes_before_migration() |
|
75 | - { |
|
76 | - // relies on 4.1's EEH_Activation::create_table |
|
77 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
78 | - $table_name = 'esp_answer'; |
|
79 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
74 | + public function schema_changes_before_migration() |
|
75 | + { |
|
76 | + // relies on 4.1's EEH_Activation::create_table |
|
77 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
78 | + $table_name = 'esp_answer'; |
|
79 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
80 | 80 | REG_ID int(10) unsigned NOT NULL, |
81 | 81 | QST_ID int(10) unsigned NOT NULL, |
82 | 82 | ANS_value text NOT NULL, |
83 | 83 | PRIMARY KEY (ANS_ID)"; |
84 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
85 | - $table_name = 'esp_attendee_meta'; |
|
86 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
84 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
85 | + $table_name = 'esp_attendee_meta'; |
|
86 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
87 | 87 | ATT_ID bigint(20) unsigned NOT NULL, |
88 | 88 | ATT_fname varchar(45) NOT NULL, |
89 | 89 | ATT_lname varchar(45) NOT NULL, |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | KEY ATT_fname (ATT_fname), |
100 | 100 | KEY ATT_lname (ATT_lname), |
101 | 101 | KEY ATT_email (ATT_email(191))"; |
102 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
103 | - $table_name = 'esp_country'; |
|
104 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
102 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
103 | + $table_name = 'esp_country'; |
|
104 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
105 | 105 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
106 | 106 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
107 | 107 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | CNT_is_EU tinyint(1) DEFAULT '0', |
118 | 118 | CNT_active tinyint(1) DEFAULT '0', |
119 | 119 | PRIMARY KEY (CNT_ISO)"; |
120 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
121 | - $table_name = 'esp_datetime'; |
|
122 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
120 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
121 | + $table_name = 'esp_datetime'; |
|
122 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
123 | 123 | EVT_ID bigint(20) unsigned NOT NULL, |
124 | 124 | DTT_name varchar(255) NOT NULL DEFAULT '', |
125 | 125 | DTT_description text NOT NULL, |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | PRIMARY KEY (DTT_ID), |
135 | 135 | KEY EVT_ID (EVT_ID), |
136 | 136 | KEY DTT_is_primary (DTT_is_primary)"; |
137 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
138 | - $table_name = 'esp_event_meta'; |
|
139 | - $sql = " |
|
137 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
138 | + $table_name = 'esp_event_meta'; |
|
139 | + $sql = " |
|
140 | 140 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
141 | 141 | EVT_ID bigint(20) unsigned NOT NULL, |
142 | 142 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -151,31 +151,31 @@ discard block |
||
151 | 151 | EVT_external_URL varchar(200) NULL, |
152 | 152 | EVT_donations tinyint(1) NULL, |
153 | 153 | PRIMARY KEY (EVTM_ID)"; |
154 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
155 | - $table_name = 'esp_event_question_group'; |
|
156 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
154 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
155 | + $table_name = 'esp_event_question_group'; |
|
156 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
157 | 157 | EVT_ID bigint(20) unsigned NOT NULL, |
158 | 158 | QSG_ID int(10) unsigned NOT NULL, |
159 | 159 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
160 | 160 | PRIMARY KEY (EQG_ID)"; |
161 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
162 | - $table_name = 'esp_event_venue'; |
|
163 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
161 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
162 | + $table_name = 'esp_event_venue'; |
|
163 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
164 | 164 | EVT_ID bigint(20) unsigned NOT NULL, |
165 | 165 | VNU_ID bigint(20) unsigned NOT NULL, |
166 | 166 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
167 | 167 | PRIMARY KEY (EVV_ID)"; |
168 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
169 | - $table_name = 'esp_extra_meta'; |
|
170 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
168 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
169 | + $table_name = 'esp_extra_meta'; |
|
170 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
171 | 171 | OBJ_ID int(11) DEFAULT NULL, |
172 | 172 | EXM_type varchar(45) DEFAULT NULL, |
173 | 173 | EXM_key varchar(45) DEFAULT NULL, |
174 | 174 | EXM_value text, |
175 | 175 | PRIMARY KEY (EXM_ID)"; |
176 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
177 | - $table_name = 'esp_line_item'; |
|
178 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
176 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
177 | + $table_name = 'esp_line_item'; |
|
178 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
179 | 179 | LIN_code varchar(245) NOT NULL DEFAULT '', |
180 | 180 | TXN_ID int(11) DEFAULT NULL, |
181 | 181 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -191,19 +191,19 @@ discard block |
||
191 | 191 | OBJ_ID int(11) DEFAULT NULL, |
192 | 192 | OBJ_type varchar(45)DEFAULT NULL, |
193 | 193 | PRIMARY KEY (LIN_ID)"; |
194 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
195 | - $table_name = 'esp_message_template'; |
|
196 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
194 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
195 | + $table_name = 'esp_message_template'; |
|
196 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
197 | 197 | GRP_ID int(10) unsigned NOT NULL, |
198 | 198 | MTP_context varchar(50) NOT NULL, |
199 | 199 | MTP_template_field varchar(30) NOT NULL, |
200 | 200 | MTP_content text NOT NULL, |
201 | 201 | PRIMARY KEY (MTP_ID), |
202 | 202 | KEY GRP_ID (GRP_ID)"; |
203 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
204 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
205 | - $table_name = 'esp_message_template_group'; |
|
206 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
203 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
204 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
205 | + $table_name = 'esp_message_template_group'; |
|
206 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
207 | 207 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
208 | 208 | MTP_name varchar(245) NOT NULL DEFAULT '', |
209 | 209 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -215,17 +215,17 @@ discard block |
||
215 | 215 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
216 | 216 | PRIMARY KEY (GRP_ID), |
217 | 217 | KEY MTP_user_id (MTP_user_id)"; |
218 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
219 | - $table_name = 'esp_event_message_template'; |
|
220 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
218 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
219 | + $table_name = 'esp_event_message_template'; |
|
220 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
221 | 221 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
222 | 222 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
223 | 223 | PRIMARY KEY (EMT_ID), |
224 | 224 | KEY EVT_ID (EVT_ID), |
225 | 225 | KEY GRP_ID (GRP_ID)"; |
226 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | - $table_name = 'esp_payment'; |
|
228 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
226 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | + $table_name = 'esp_payment'; |
|
228 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
229 | 229 | TXN_ID int(10) unsigned DEFAULT NULL, |
230 | 230 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
231 | 231 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -241,28 +241,28 @@ discard block |
||
241 | 241 | PRIMARY KEY (PAY_ID), |
242 | 242 | KEY TXN_ID (TXN_ID), |
243 | 243 | KEY PAY_timestamp (PAY_timestamp)"; |
244 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
245 | - $table_name = "esp_ticket_price"; |
|
246 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
244 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
245 | + $table_name = "esp_ticket_price"; |
|
246 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
247 | 247 | TKT_ID int(10) unsigned NOT NULL, |
248 | 248 | PRC_ID int(10) unsigned NOT NULL, |
249 | 249 | PRIMARY KEY (TKP_ID)"; |
250 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
251 | - $table_name = "esp_datetime_ticket"; |
|
252 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
250 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
251 | + $table_name = "esp_datetime_ticket"; |
|
252 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
253 | 253 | DTT_ID int(10) unsigned NOT NULL, |
254 | 254 | TKT_ID int(10) unsigned NOT NULL, |
255 | 255 | PRIMARY KEY (DTK_ID)"; |
256 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
257 | - $table_name = "esp_ticket_template"; |
|
258 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
256 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
257 | + $table_name = "esp_ticket_template"; |
|
258 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
259 | 259 | TTM_name varchar(45) NOT NULL, |
260 | 260 | TTM_description text, |
261 | 261 | TTM_file varchar(45), |
262 | 262 | PRIMARY KEY (TTM_ID)"; |
263 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | - $table_name = 'esp_question'; |
|
265 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
263 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | + $table_name = 'esp_question'; |
|
265 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
266 | 266 | QST_display_text text NOT NULL, |
267 | 267 | QST_admin_label varchar(255) NOT NULL, |
268 | 268 | QST_system varchar(25) DEFAULT NULL, |
@@ -274,25 +274,25 @@ discard block |
||
274 | 274 | QST_wp_user bigint(20) unsigned NULL, |
275 | 275 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
276 | 276 | PRIMARY KEY (QST_ID)'; |
277 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
278 | - $table_name = 'esp_question_group_question'; |
|
279 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
277 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
278 | + $table_name = 'esp_question_group_question'; |
|
279 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
280 | 280 | QSG_ID int(10) unsigned NOT NULL, |
281 | 281 | QST_ID int(10) unsigned NOT NULL, |
282 | 282 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
283 | 283 | PRIMARY KEY (QGQ_ID) "; |
284 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
285 | - $table_name = 'esp_question_option'; |
|
286 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
284 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
285 | + $table_name = 'esp_question_option'; |
|
286 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
287 | 287 | QSO_value varchar(255) NOT NULL, |
288 | 288 | QSO_desc text NOT NULL, |
289 | 289 | QST_ID int(10) unsigned NOT NULL, |
290 | 290 | QSO_order int(10) unsigned NOT NULL DEFAULT 0, |
291 | 291 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
292 | 292 | PRIMARY KEY (QSO_ID)"; |
293 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
294 | - $table_name = 'esp_registration'; |
|
295 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
293 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
294 | + $table_name = 'esp_registration'; |
|
295 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
296 | 296 | EVT_ID bigint(20) unsigned NOT NULL, |
297 | 297 | ATT_ID bigint(20) unsigned NOT NULL, |
298 | 298 | TXN_ID int(10) unsigned NOT NULL, |
@@ -315,25 +315,25 @@ discard block |
||
315 | 315 | KEY STS_ID (STS_ID), |
316 | 316 | KEY REG_url_link (REG_url_link), |
317 | 317 | KEY REG_code (REG_code)"; |
318 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
319 | - $table_name = 'esp_checkin'; |
|
320 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
318 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
319 | + $table_name = 'esp_checkin'; |
|
320 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
321 | 321 | REG_ID int(10) unsigned NOT NULL, |
322 | 322 | DTT_ID int(10) unsigned NOT NULL, |
323 | 323 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
324 | 324 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
325 | 325 | PRIMARY KEY (CHK_ID)"; |
326 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
327 | - $table_name = 'esp_state'; |
|
328 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
326 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
327 | + $table_name = 'esp_state'; |
|
328 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
329 | 329 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
330 | 330 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
331 | 331 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
332 | 332 | STA_active tinyint(1) DEFAULT '1', |
333 | 333 | PRIMARY KEY (STA_ID)"; |
334 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | - $table_name = 'esp_status'; |
|
336 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
334 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | + $table_name = 'esp_status'; |
|
336 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
337 | 337 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
338 | 338 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
339 | 339 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
342 | 342 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
343 | 343 | KEY STS_type (STS_type)"; |
344 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | - $table_name = 'esp_transaction'; |
|
346 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
344 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | + $table_name = 'esp_transaction'; |
|
346 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
347 | 347 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
348 | 348 | TXN_total decimal(10,3) DEFAULT '0.00', |
349 | 349 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | PRIMARY KEY (TXN_ID), |
355 | 355 | KEY TXN_timestamp (TXN_timestamp), |
356 | 356 | KEY STS_ID (STS_ID)"; |
357 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
358 | - $table_name = 'esp_venue_meta'; |
|
359 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
357 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
358 | + $table_name = 'esp_venue_meta'; |
|
359 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
360 | 360 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
361 | 361 | VNU_address varchar(255) DEFAULT NULL, |
362 | 362 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | PRIMARY KEY (VNUM_ID), |
375 | 375 | KEY STA_ID (STA_ID), |
376 | 376 | KEY CNT_ISO (CNT_ISO)"; |
377 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | - // modified tables |
|
379 | - $table_name = "esp_price"; |
|
380 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
377 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | + // modified tables |
|
379 | + $table_name = "esp_price"; |
|
380 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
381 | 381 | PRT_ID tinyint(3) unsigned NOT NULL, |
382 | 382 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
383 | 383 | PRC_name varchar(245) NOT NULL, |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | PRC_wp_user bigint(20) unsigned NULL, |
390 | 390 | PRC_parent int(10) unsigned DEFAULT 0, |
391 | 391 | PRIMARY KEY (PRC_ID)"; |
392 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
393 | - $table_name = "esp_price_type"; |
|
394 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
392 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
393 | + $table_name = "esp_price_type"; |
|
394 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | 395 | PRT_name varchar(45) NOT NULL, |
396 | 396 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
397 | 397 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
401 | 401 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
402 | 402 | PRIMARY KEY (PRT_ID)"; |
403 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
404 | - $table_name = "esp_ticket"; |
|
405 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
403 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
404 | + $table_name = "esp_ticket"; |
|
405 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
406 | 406 | TTM_ID int(10) unsigned NOT NULL, |
407 | 407 | TKT_name varchar(245) NOT NULL DEFAULT '', |
408 | 408 | TKT_description text NOT NULL, |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | TKT_parent int(10) unsigned DEFAULT '0', |
424 | 424 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
425 | 425 | PRIMARY KEY (TKT_ID)"; |
426 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
427 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
428 | - $table_name = 'esp_question_group'; |
|
429 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
426 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
427 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
428 | + $table_name = 'esp_question_group'; |
|
429 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
430 | 430 | QSG_name varchar(255) NOT NULL, |
431 | 431 | QSG_identifier varchar(100) NOT NULL, |
432 | 432 | QSG_desc text NULL, |
@@ -438,133 +438,133 @@ discard block |
||
438 | 438 | QSG_wp_user bigint(20) unsigned NULL, |
439 | 439 | PRIMARY KEY (QSG_ID), |
440 | 440 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
441 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
442 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
443 | - // (because many need to convert old string states to foreign keys into the states table) |
|
444 | - $script_4_1_defaults->insert_default_states(); |
|
445 | - $script_4_1_defaults->insert_default_countries(); |
|
446 | - // schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later. |
|
447 | - $this->insert_default_price_types(); |
|
448 | - $this->insert_default_prices(); |
|
449 | - $this->insert_default_tickets(); |
|
450 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
451 | - EE_Config::instance()->update_espresso_config(false, true); |
|
452 | - return true; |
|
453 | - } |
|
441 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
442 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
443 | + // (because many need to convert old string states to foreign keys into the states table) |
|
444 | + $script_4_1_defaults->insert_default_states(); |
|
445 | + $script_4_1_defaults->insert_default_countries(); |
|
446 | + // schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later. |
|
447 | + $this->insert_default_price_types(); |
|
448 | + $this->insert_default_prices(); |
|
449 | + $this->insert_default_tickets(); |
|
450 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
451 | + EE_Config::instance()->update_espresso_config(false, true); |
|
452 | + return true; |
|
453 | + } |
|
454 | 454 | |
455 | 455 | |
456 | 456 | |
457 | - /** |
|
458 | - * @return boolean |
|
459 | - */ |
|
460 | - public function schema_changes_after_migration() |
|
461 | - { |
|
462 | - return true; |
|
463 | - } |
|
457 | + /** |
|
458 | + * @return boolean |
|
459 | + */ |
|
460 | + public function schema_changes_after_migration() |
|
461 | + { |
|
462 | + return true; |
|
463 | + } |
|
464 | 464 | |
465 | 465 | |
466 | 466 | |
467 | - public function migration_page_hooks() |
|
468 | - { |
|
469 | - } |
|
467 | + public function migration_page_hooks() |
|
468 | + { |
|
469 | + } |
|
470 | 470 | |
471 | 471 | |
472 | 472 | |
473 | - /** |
|
474 | - * insert_default_price_types |
|
475 | - * |
|
476 | - * @since 4.5.0 |
|
477 | - * @return void |
|
478 | - */ |
|
479 | - public function insert_default_price_types() |
|
480 | - { |
|
481 | - global $wpdb; |
|
482 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
483 | - if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
484 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
485 | - $price_types_exist = $wpdb->get_var($SQL); |
|
486 | - if (! $price_types_exist) { |
|
487 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
488 | - $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
|
473 | + /** |
|
474 | + * insert_default_price_types |
|
475 | + * |
|
476 | + * @since 4.5.0 |
|
477 | + * @return void |
|
478 | + */ |
|
479 | + public function insert_default_price_types() |
|
480 | + { |
|
481 | + global $wpdb; |
|
482 | + $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
483 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
484 | + $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
485 | + $price_types_exist = $wpdb->get_var($SQL); |
|
486 | + if (! $price_types_exist) { |
|
487 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
488 | + $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
|
489 | 489 | (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, $user_id, 0), |
490 | 490 | (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, $user_id, 0), |
491 | 491 | (3, '" . __('Dollar Discount', 'event_espresso') . "', 2, 0, 30, $user_id, 0), |
492 | 492 | (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, $user_id, 0), |
493 | 493 | (5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3, 0, 50, $user_id, 0);"; |
494 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
495 | - $wpdb->query($SQL); |
|
496 | - } |
|
497 | - } |
|
498 | - } |
|
494 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
495 | + $wpdb->query($SQL); |
|
496 | + } |
|
497 | + } |
|
498 | + } |
|
499 | 499 | |
500 | 500 | |
501 | 501 | |
502 | - /** |
|
503 | - * insert DEFAULT prices. |
|
504 | - * If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices |
|
505 | - * when EEH_Activaion's initialize_db_content is called via ahook in |
|
506 | - * EE_Brewing_regular |
|
507 | - * |
|
508 | - * @since 4.5.0 |
|
509 | - * @return void |
|
510 | - */ |
|
511 | - public function insert_default_prices() |
|
512 | - { |
|
513 | - global $wpdb; |
|
514 | - $price_table = $wpdb->prefix . "esp_price"; |
|
515 | - if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
516 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
517 | - $prices_exist = $wpdb->get_var($SQL); |
|
518 | - if (! $prices_exist) { |
|
519 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
520 | - $SQL = "INSERT INTO $price_table |
|
502 | + /** |
|
503 | + * insert DEFAULT prices. |
|
504 | + * If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices |
|
505 | + * when EEH_Activaion's initialize_db_content is called via ahook in |
|
506 | + * EE_Brewing_regular |
|
507 | + * |
|
508 | + * @since 4.5.0 |
|
509 | + * @return void |
|
510 | + */ |
|
511 | + public function insert_default_prices() |
|
512 | + { |
|
513 | + global $wpdb; |
|
514 | + $price_table = $wpdb->prefix . "esp_price"; |
|
515 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
516 | + $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
517 | + $prices_exist = $wpdb->get_var($SQL); |
|
518 | + if (! $prices_exist) { |
|
519 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
520 | + $SQL = "INSERT INTO $price_table |
|
521 | 521 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES |
522 | 522 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, $user_id, 0, 0, 0);"; |
523 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
524 | - $wpdb->query($SQL); |
|
525 | - } |
|
526 | - } |
|
527 | - } |
|
523 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
524 | + $wpdb->query($SQL); |
|
525 | + } |
|
526 | + } |
|
527 | + } |
|
528 | 528 | |
529 | 529 | |
530 | 530 | |
531 | - /** |
|
532 | - * insert DEFAULT ticket |
|
533 | - * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field |
|
534 | - * |
|
535 | - * @since 4.5.0 |
|
536 | - * @return void |
|
537 | - */ |
|
538 | - public function insert_default_tickets() |
|
539 | - { |
|
540 | - global $wpdb; |
|
541 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
542 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
543 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
544 | - $tickets_exist = $wpdb->get_var($SQL); |
|
545 | - if (! $tickets_exist) { |
|
546 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
547 | - $SQL = "INSERT INTO $ticket_table |
|
531 | + /** |
|
532 | + * insert DEFAULT ticket |
|
533 | + * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field |
|
534 | + * |
|
535 | + * @since 4.5.0 |
|
536 | + * @return void |
|
537 | + */ |
|
538 | + public function insert_default_tickets() |
|
539 | + { |
|
540 | + global $wpdb; |
|
541 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
542 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
543 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
544 | + $tickets_exist = $wpdb->get_var($SQL); |
|
545 | + if (! $tickets_exist) { |
|
546 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
547 | + $SQL = "INSERT INTO $ticket_table |
|
548 | 548 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES |
549 | 549 | ( 1, 0, '" |
550 | - . __("Free Ticket", "event_espresso") |
|
551 | - . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
552 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
553 | - $wpdb->query($SQL); |
|
554 | - } |
|
555 | - } |
|
556 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
557 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
558 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
559 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
560 | - if (! $ticket_prc_exist) { |
|
561 | - $SQL = "INSERT INTO $ticket_price_table |
|
550 | + . __("Free Ticket", "event_espresso") |
|
551 | + . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
552 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
553 | + $wpdb->query($SQL); |
|
554 | + } |
|
555 | + } |
|
556 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
557 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
558 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
559 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
560 | + if (! $ticket_prc_exist) { |
|
561 | + $SQL = "INSERT INTO $ticket_price_table |
|
562 | 562 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
563 | 563 | ( 1, 1, 1 ) |
564 | 564 | "; |
565 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
566 | - $wpdb->query($SQL); |
|
567 | - } |
|
568 | - } |
|
569 | - } |
|
565 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
566 | + $wpdb->query($SQL); |
|
567 | + } |
|
568 | + } |
|
569 | + } |
|
570 | 570 | } |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | // unfortunately, this needs to be done upon INCLUSION of this file, |
14 | 14 | // instead of construction, because it only gets constructed on first page load |
15 | 15 | // (all other times it gets resurrected from a wordpress option) |
16 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*'); |
|
16 | +$stages = glob(EE_CORE.'data_migration_scripts/4_5_0_stages/*'); |
|
17 | 17 | $class_to_filepath = array(); |
18 | 18 | foreach ($stages as $filepath) { |
19 | 19 | $matches = array(); |
20 | 20 | preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
21 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
21 | + $class_to_filepath[$matches[1]] = $filepath; |
|
22 | 22 | } |
23 | 23 | // give addons a chance to autoload their stages too |
24 | 24 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath); |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) { |
60 | 60 | // echo "$version_string can be migrated from"; |
61 | 61 | return true; |
62 | - } elseif (! $version_string) { |
|
62 | + } elseif ( ! $version_string) { |
|
63 | 63 | // echo "no version string provided: $version_string"; |
64 | 64 | // no version string provided... this must be pre 4.3 |
65 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
66 | 66 | } else { |
67 | 67 | // echo "$version_string doesnt apply"; |
68 | 68 | return false; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function schema_changes_before_migration() |
75 | 75 | { |
76 | 76 | // relies on 4.1's EEH_Activation::create_table |
77 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
77 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
78 | 78 | $table_name = 'esp_answer'; |
79 | 79 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
80 | 80 | REG_ID int(10) unsigned NOT NULL, |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | public function insert_default_price_types() |
480 | 480 | { |
481 | 481 | global $wpdb; |
482 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
482 | + $price_type_table = $wpdb->prefix."esp_price_type"; |
|
483 | 483 | if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
484 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
484 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
485 | 485 | $price_types_exist = $wpdb->get_var($SQL); |
486 | - if (! $price_types_exist) { |
|
486 | + if ( ! $price_types_exist) { |
|
487 | 487 | $user_id = EEH_Activation::get_default_creator_id(); |
488 | 488 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
489 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, $user_id, 0), |
|
490 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, $user_id, 0), |
|
491 | - (3, '" . __('Dollar Discount', 'event_espresso') . "', 2, 0, 30, $user_id, 0), |
|
492 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, $user_id, 0), |
|
493 | - (5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3, 0, 50, $user_id, 0);"; |
|
489 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, $user_id, 0), |
|
490 | + (2, '".__('Percent Discount', 'event_espresso')."', 2, 1, 20, $user_id, 0), |
|
491 | + (3, '".__('Dollar Discount', 'event_espresso')."', 2, 0, 30, $user_id, 0), |
|
492 | + (4, '".__('Percent Surcharge', 'event_espresso')."', 3, 1, 40, $user_id, 0), |
|
493 | + (5, '".__('Dollar Surcharge', 'event_espresso')."', 3, 0, 50, $user_id, 0);"; |
|
494 | 494 | $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
495 | 495 | $wpdb->query($SQL); |
496 | 496 | } |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | public function insert_default_prices() |
512 | 512 | { |
513 | 513 | global $wpdb; |
514 | - $price_table = $wpdb->prefix . "esp_price"; |
|
514 | + $price_table = $wpdb->prefix."esp_price"; |
|
515 | 515 | if ($this->_get_table_analysis()->tableExists($price_table)) { |
516 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
516 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
517 | 517 | $prices_exist = $wpdb->get_var($SQL); |
518 | - if (! $prices_exist) { |
|
518 | + if ( ! $prices_exist) { |
|
519 | 519 | $user_id = EEH_Activation::get_default_creator_id(); |
520 | 520 | $SQL = "INSERT INTO $price_table |
521 | 521 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | public function insert_default_tickets() |
539 | 539 | { |
540 | 540 | global $wpdb; |
541 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
541 | + $ticket_table = $wpdb->prefix."esp_ticket"; |
|
542 | 542 | if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
543 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
543 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
544 | 544 | $tickets_exist = $wpdb->get_var($SQL); |
545 | - if (! $tickets_exist) { |
|
545 | + if ( ! $tickets_exist) { |
|
546 | 546 | $user_id = EEH_Activation::get_default_creator_id(); |
547 | 547 | $SQL = "INSERT INTO $ticket_table |
548 | 548 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | $wpdb->query($SQL); |
554 | 554 | } |
555 | 555 | } |
556 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
556 | + $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
|
557 | 557 | if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
558 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
558 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
559 | 559 | $ticket_prc_exist = $wpdb->get_var($SQL); |
560 | - if (! $ticket_prc_exist) { |
|
560 | + if ( ! $ticket_prc_exist) { |
|
561 | 561 | $SQL = "INSERT INTO $ticket_price_table |
562 | 562 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
563 | 563 | ( 1, 1, 1 ) |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | if (! empty($stages)) { |
15 | - foreach ($stages as $filepath) { |
|
16 | - $matches = array(); |
|
17 | - preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
18 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
19 | - } |
|
15 | + foreach ($stages as $filepath) { |
|
16 | + $matches = array(); |
|
17 | + preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
18 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | // give addons a chance to autoload their stages too |
22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath); |
@@ -44,91 +44,91 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * EE_DMS_Core_4_1_0 constructor. |
|
49 | - * |
|
50 | - * @param TableManager $table_manager |
|
51 | - * @param TableAnalysis $table_analysis |
|
52 | - */ |
|
53 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
54 | - { |
|
55 | - $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso"); |
|
56 | - $this->_priority = 10; |
|
57 | - $this->_migration_stages = array( |
|
58 | - new EE_DMS_4_1_0_org_options(), |
|
59 | - new EE_DMS_4_1_0_shortcodes(), |
|
60 | - new EE_DMS_4_1_0_gateways(), |
|
61 | - new EE_DMS_4_1_0_events(), |
|
62 | - new EE_DMS_4_1_0_prices(), |
|
63 | - new EE_DMS_4_1_0_category_details(), |
|
64 | - new EE_DMS_4_1_0_event_category(), |
|
65 | - new EE_DMS_4_1_0_venues(), |
|
66 | - new EE_DMS_4_1_0_event_venue(), |
|
67 | - new EE_DMS_4_1_0_question_groups(), |
|
68 | - new EE_DMS_4_1_0_questions(), |
|
69 | - new EE_DMS_4_1_0_question_group_question(), |
|
70 | - new EE_DMS_4_1_0_event_question_group(), |
|
71 | - new EE_DMS_4_1_0_attendees(), |
|
72 | - new EE_DMS_4_1_0_line_items(), |
|
73 | - new EE_DMS_4_1_0_answers(), |
|
74 | - new EE_DMS_4_1_0_checkins(), |
|
75 | - ); |
|
76 | - parent::__construct($table_manager, $table_analysis); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins |
|
83 | - * |
|
84 | - * @global wpdb $wpdb |
|
85 | - * @return boolean |
|
86 | - */ |
|
87 | - private function _checkin_table_exists() |
|
88 | - { |
|
89 | - global $wpdb; |
|
90 | - $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'"); |
|
91 | - if ($results) { |
|
92 | - return true; |
|
93 | - } else { |
|
94 | - return false; |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - public function can_migrate_from_version($version_array) |
|
101 | - { |
|
102 | - $version_string = $version_array['Core']; |
|
103 | - if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) { |
|
47 | + /** |
|
48 | + * EE_DMS_Core_4_1_0 constructor. |
|
49 | + * |
|
50 | + * @param TableManager $table_manager |
|
51 | + * @param TableAnalysis $table_analysis |
|
52 | + */ |
|
53 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
54 | + { |
|
55 | + $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso"); |
|
56 | + $this->_priority = 10; |
|
57 | + $this->_migration_stages = array( |
|
58 | + new EE_DMS_4_1_0_org_options(), |
|
59 | + new EE_DMS_4_1_0_shortcodes(), |
|
60 | + new EE_DMS_4_1_0_gateways(), |
|
61 | + new EE_DMS_4_1_0_events(), |
|
62 | + new EE_DMS_4_1_0_prices(), |
|
63 | + new EE_DMS_4_1_0_category_details(), |
|
64 | + new EE_DMS_4_1_0_event_category(), |
|
65 | + new EE_DMS_4_1_0_venues(), |
|
66 | + new EE_DMS_4_1_0_event_venue(), |
|
67 | + new EE_DMS_4_1_0_question_groups(), |
|
68 | + new EE_DMS_4_1_0_questions(), |
|
69 | + new EE_DMS_4_1_0_question_group_question(), |
|
70 | + new EE_DMS_4_1_0_event_question_group(), |
|
71 | + new EE_DMS_4_1_0_attendees(), |
|
72 | + new EE_DMS_4_1_0_line_items(), |
|
73 | + new EE_DMS_4_1_0_answers(), |
|
74 | + new EE_DMS_4_1_0_checkins(), |
|
75 | + ); |
|
76 | + parent::__construct($table_manager, $table_analysis); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins |
|
83 | + * |
|
84 | + * @global wpdb $wpdb |
|
85 | + * @return boolean |
|
86 | + */ |
|
87 | + private function _checkin_table_exists() |
|
88 | + { |
|
89 | + global $wpdb; |
|
90 | + $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'"); |
|
91 | + if ($results) { |
|
92 | + return true; |
|
93 | + } else { |
|
94 | + return false; |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + public function can_migrate_from_version($version_array) |
|
101 | + { |
|
102 | + $version_string = $version_array['Core']; |
|
103 | + if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) { |
|
104 | 104 | // echo "$version_string can be migrated fro"; |
105 | - return true; |
|
106 | - } elseif (! $version_string) { |
|
105 | + return true; |
|
106 | + } elseif (! $version_string) { |
|
107 | 107 | // echo "no version string provided: $version_string"; |
108 | - // no version string provided... this must be pre 4.1 |
|
109 | - // because since 4.1 we're |
|
110 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
111 | - } else { |
|
108 | + // no version string provided... this must be pre 4.1 |
|
109 | + // because since 4.1 we're |
|
110 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
111 | + } else { |
|
112 | 112 | // echo "$version_string doesnt apply"; |
113 | - return false; |
|
114 | - } |
|
115 | - } |
|
113 | + return false; |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - public function schema_changes_before_migration() |
|
120 | - { |
|
121 | - // relies on 4.1's EEH_Activation::create_table |
|
122 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
123 | - $table_name = 'esp_answer'; |
|
124 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
119 | + public function schema_changes_before_migration() |
|
120 | + { |
|
121 | + // relies on 4.1's EEH_Activation::create_table |
|
122 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
123 | + $table_name = 'esp_answer'; |
|
124 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
125 | 125 | REG_ID int(10) unsigned NOT NULL, |
126 | 126 | QST_ID int(10) unsigned NOT NULL, |
127 | 127 | ANS_value text NOT NULL, |
128 | 128 | PRIMARY KEY (ANS_ID)"; |
129 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
130 | - $table_name = 'esp_attendee_meta'; |
|
131 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
129 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
130 | + $table_name = 'esp_attendee_meta'; |
|
131 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
132 | 132 | ATT_ID bigint(20) unsigned NOT NULL, |
133 | 133 | ATT_fname varchar(45) NOT NULL, |
134 | 134 | ATT_lname varchar(45) NOT NULL, |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | KEY ATT_fname (ATT_fname), |
145 | 145 | KEY ATT_lname (ATT_lname), |
146 | 146 | KEY ATT_email (ATT_email(191))"; |
147 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
148 | - $table_name = 'esp_country'; |
|
149 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
147 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
148 | + $table_name = 'esp_country'; |
|
149 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
150 | 150 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
151 | 151 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
152 | 152 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | CNT_is_EU tinyint(1) DEFAULT '0', |
163 | 163 | CNT_active tinyint(1) DEFAULT '0', |
164 | 164 | PRIMARY KEY (CNT_ISO)"; |
165 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
166 | - $table_name = 'esp_datetime'; |
|
167 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
166 | + $table_name = 'esp_datetime'; |
|
167 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
168 | 168 | EVT_ID bigint(20) unsigned NOT NULL, |
169 | 169 | DTT_EVT_start datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
170 | 170 | DTT_EVT_end datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | PRIMARY KEY (DTT_ID), |
178 | 178 | KEY EVT_ID (EVT_ID), |
179 | 179 | KEY DTT_is_primary (DTT_is_primary)"; |
180 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
181 | - $table_name = 'esp_event_meta'; |
|
182 | - $sql = " |
|
180 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
181 | + $table_name = 'esp_event_meta'; |
|
182 | + $sql = " |
|
183 | 183 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
184 | 184 | EVT_ID bigint(20) unsigned NOT NULL, |
185 | 185 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -194,31 +194,31 @@ discard block |
||
194 | 194 | EVT_external_URL varchar(200) NULL, |
195 | 195 | EVT_donations tinyint(1) NULL, |
196 | 196 | PRIMARY KEY (EVTM_ID)"; |
197 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_event_question_group'; |
|
199 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_event_question_group'; |
|
199 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | QSG_ID int(10) unsigned NOT NULL, |
202 | 202 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
203 | 203 | PRIMARY KEY (EQG_ID)"; |
204 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
205 | - $table_name = 'esp_event_venue'; |
|
206 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
204 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
205 | + $table_name = 'esp_event_venue'; |
|
206 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
207 | 207 | EVT_ID bigint(20) unsigned NOT NULL, |
208 | 208 | VNU_ID bigint(20) unsigned NOT NULL, |
209 | 209 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
210 | 210 | PRIMARY KEY (EVV_ID)"; |
211 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
212 | - $table_name = 'esp_extra_meta'; |
|
213 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
211 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
212 | + $table_name = 'esp_extra_meta'; |
|
213 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
214 | 214 | OBJ_ID int(11) DEFAULT NULL, |
215 | 215 | EXM_type varchar(45) DEFAULT NULL, |
216 | 216 | EXM_key varchar(45) DEFAULT NULL, |
217 | 217 | EXM_value text, |
218 | 218 | PRIMARY KEY (EXM_ID)"; |
219 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | - $table_name = 'esp_line_item'; |
|
221 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
219 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $table_name = 'esp_line_item'; |
|
221 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
222 | 222 | LIN_code varchar(245) NOT NULL DEFAULT '', |
223 | 223 | TXN_ID int(11) DEFAULT NULL, |
224 | 224 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -234,18 +234,18 @@ discard block |
||
234 | 234 | OBJ_ID int(11) DEFAULT NULL, |
235 | 235 | OBJ_type varchar(45)DEFAULT NULL, |
236 | 236 | PRIMARY KEY (LIN_ID)"; |
237 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
238 | - $table_name = 'esp_message_template'; |
|
239 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
237 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
238 | + $table_name = 'esp_message_template'; |
|
239 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
240 | 240 | GRP_ID int(10) unsigned NOT NULL, |
241 | 241 | MTP_context varchar(50) NOT NULL, |
242 | 242 | MTP_template_field varchar(30) NOT NULL, |
243 | 243 | MTP_content text NOT NULL, |
244 | 244 | PRIMARY KEY (MTP_ID), |
245 | 245 | KEY GRP_ID (GRP_ID)"; |
246 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | - $table_name = 'esp_message_template_group'; |
|
248 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
246 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | + $table_name = 'esp_message_template_group'; |
|
248 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
249 | 249 | EVT_ID bigint(20) unsigned DEFAULT NULL, |
250 | 250 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
251 | 251 | MTP_messenger varchar(30) NOT NULL, |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | PRIMARY KEY (GRP_ID), |
258 | 258 | KEY EVT_ID (EVT_ID), |
259 | 259 | KEY MTP_user_id (MTP_user_id)"; |
260 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
261 | - $table_name = 'esp_payment'; |
|
262 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
260 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
261 | + $table_name = 'esp_payment'; |
|
262 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
263 | 263 | TXN_ID int(10) unsigned DEFAULT NULL, |
264 | 264 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
265 | 265 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | PRIMARY KEY (PAY_ID), |
276 | 276 | KEY TXN_ID (TXN_ID), |
277 | 277 | KEY PAY_timestamp (PAY_timestamp)"; |
278 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
279 | - $table_name = "esp_ticket"; |
|
280 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
278 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
279 | + $table_name = "esp_ticket"; |
|
280 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
281 | 281 | TTM_ID int(10) unsigned NOT NULL, |
282 | 282 | TKT_name varchar(245) NOT NULL DEFAULT '', |
283 | 283 | TKT_description text NOT NULL, |
@@ -296,28 +296,28 @@ discard block |
||
296 | 296 | TKT_parent int(10) unsigned DEFAULT '0', |
297 | 297 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
298 | 298 | PRIMARY KEY (TKT_ID)"; |
299 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
300 | - $table_name = "esp_ticket_price"; |
|
301 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
299 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
300 | + $table_name = "esp_ticket_price"; |
|
301 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
302 | 302 | TKT_ID int(10) unsigned NOT NULL, |
303 | 303 | PRC_ID int(10) unsigned NOT NULL, |
304 | 304 | PRIMARY KEY (TKP_ID)"; |
305 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | - $table_name = "esp_datetime_ticket"; |
|
307 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
305 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | + $table_name = "esp_datetime_ticket"; |
|
307 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
308 | 308 | DTT_ID int(10) unsigned NOT NULL, |
309 | 309 | TKT_ID int(10) unsigned NOT NULL, |
310 | 310 | PRIMARY KEY (DTK_ID)"; |
311 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
312 | - $table_name = "esp_ticket_template"; |
|
313 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
311 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
312 | + $table_name = "esp_ticket_template"; |
|
313 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
314 | 314 | TTM_name varchar(45) NOT NULL, |
315 | 315 | TTM_description text, |
316 | 316 | TTM_file varchar(45), |
317 | 317 | PRIMARY KEY (TTM_ID)"; |
318 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
319 | - $table_name = "esp_price"; |
|
320 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
318 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
319 | + $table_name = "esp_price"; |
|
320 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
321 | 321 | PRT_ID tinyint(3) unsigned NOT NULL, |
322 | 322 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
323 | 323 | PRC_name varchar(245) NOT NULL, |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
329 | 329 | PRC_parent int(10) unsigned DEFAULT 0, |
330 | 330 | PRIMARY KEY (PRC_ID)"; |
331 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
332 | - $table_name = "esp_price_type"; |
|
333 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
331 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
332 | + $table_name = "esp_price_type"; |
|
333 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
334 | 334 | PRT_name varchar(45) NOT NULL, |
335 | 335 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
336 | 336 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
339 | 339 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
340 | 340 | PRIMARY KEY (PRT_ID)"; |
341 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | - $table_name = 'esp_question'; |
|
343 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
341 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | + $table_name = 'esp_question'; |
|
343 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
344 | 344 | QST_display_text text NOT NULL, |
345 | 345 | QST_admin_label varchar(255) NOT NULL, |
346 | 346 | QST_system varchar(25) DEFAULT NULL, |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | QST_wp_user bigint(20) unsigned NULL, |
353 | 353 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
354 | 354 | PRIMARY KEY (QST_ID)'; |
355 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
356 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
357 | - $table_name = 'esp_question_group'; |
|
358 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
355 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
356 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
357 | + $table_name = 'esp_question_group'; |
|
358 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
359 | 359 | QSG_name varchar(255) NOT NULL, |
360 | 360 | QSG_identifier varchar(100) NOT NULL, |
361 | 361 | QSG_desc text NULL, |
@@ -366,23 +366,23 @@ discard block |
||
366 | 366 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
367 | 367 | PRIMARY KEY (QSG_ID), |
368 | 368 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
369 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
370 | - $table_name = 'esp_question_group_question'; |
|
371 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
369 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
370 | + $table_name = 'esp_question_group_question'; |
|
371 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
372 | 372 | QSG_ID int(10) unsigned NOT NULL, |
373 | 373 | QST_ID int(10) unsigned NOT NULL, |
374 | 374 | PRIMARY KEY (QGQ_ID) "; |
375 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | - $table_name = 'esp_question_option'; |
|
377 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | + $table_name = 'esp_question_option'; |
|
377 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
378 | 378 | QSO_value varchar(255) NOT NULL, |
379 | 379 | QSO_desc text NOT NULL, |
380 | 380 | QST_ID int(10) unsigned NOT NULL, |
381 | 381 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
382 | 382 | PRIMARY KEY (QSO_ID)"; |
383 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | - $table_name = 'esp_registration'; |
|
385 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
383 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $table_name = 'esp_registration'; |
|
385 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
386 | 386 | EVT_ID bigint(20) unsigned NOT NULL, |
387 | 387 | ATT_ID bigint(20) unsigned NOT NULL, |
388 | 388 | TXN_ID int(10) unsigned NOT NULL, |
@@ -405,25 +405,25 @@ discard block |
||
405 | 405 | KEY STS_ID (STS_ID), |
406 | 406 | KEY REG_url_link (REG_url_link), |
407 | 407 | KEY REG_code (REG_code)"; |
408 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
409 | - $table_name = 'esp_checkin'; |
|
410 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
408 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
409 | + $table_name = 'esp_checkin'; |
|
410 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
411 | 411 | REG_ID int(10) unsigned NOT NULL, |
412 | 412 | DTT_ID int(10) unsigned NOT NULL, |
413 | 413 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
414 | 414 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
415 | 415 | PRIMARY KEY (CHK_ID)"; |
416 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | - $table_name = 'esp_state'; |
|
418 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | + $table_name = 'esp_state'; |
|
418 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
419 | 419 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
420 | 420 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
421 | 421 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
422 | 422 | STA_active tinyint(1) DEFAULT '1', |
423 | 423 | PRIMARY KEY (STA_ID)"; |
424 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | - $table_name = 'esp_status'; |
|
426 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
424 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | + $table_name = 'esp_status'; |
|
426 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
427 | 427 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
428 | 428 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
429 | 429 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
432 | 432 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
433 | 433 | KEY STS_type (STS_type)"; |
434 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
435 | - $table_name = 'esp_transaction'; |
|
436 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
434 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
435 | + $table_name = 'esp_transaction'; |
|
436 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
437 | 437 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
438 | 438 | TXN_total decimal(10,3) DEFAULT '0.00', |
439 | 439 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -443,9 +443,9 @@ discard block |
||
443 | 443 | PRIMARY KEY (TXN_ID), |
444 | 444 | KEY TXN_timestamp (TXN_timestamp), |
445 | 445 | KEY STS_ID (STS_ID)"; |
446 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
447 | - $table_name = 'esp_venue_meta'; |
|
448 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
446 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
447 | + $table_name = 'esp_venue_meta'; |
|
448 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
449 | 449 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
450 | 450 | VNU_address varchar(255) DEFAULT NULL, |
451 | 451 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -463,52 +463,52 @@ discard block |
||
463 | 463 | PRIMARY KEY (VNUM_ID), |
464 | 464 | KEY STA_ID (STA_ID), |
465 | 465 | KEY CNT_ISO (CNT_ISO)"; |
466 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | - // setting up the default stats and countries is also essential for the data migrations to run |
|
468 | - // (because many need to convert old string states to foreign keys into the states table) |
|
469 | - $this->insert_default_states(); |
|
470 | - $this->insert_default_countries(); |
|
471 | - // setting up default prices, price types, and tickets is also essential for the price migrations |
|
472 | - $this->insert_default_price_types(); |
|
473 | - $this->insert_default_prices(); |
|
474 | - $this->insert_default_tickets(); |
|
475 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
476 | - EE_Config::instance()->update_espresso_config(false, true); |
|
477 | - return true; |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * Yes we could have cleaned up the ee3 tables here. But just in case someone |
|
484 | - * didn't backup their DB, and decides they want ot keep using EE3, we'll |
|
485 | - * leave them for now. Mayeb remove them in 4.5 or something. |
|
486 | - * |
|
487 | - * @return boolean |
|
488 | - */ |
|
489 | - public function schema_changes_after_migration() |
|
490 | - { |
|
491 | - return true; |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * insert_default_states |
|
498 | - * |
|
499 | - * @access public |
|
500 | - * @static |
|
501 | - * @return void |
|
502 | - */ |
|
503 | - public function insert_default_states() |
|
504 | - { |
|
505 | - global $wpdb; |
|
506 | - $state_table = $wpdb->prefix . "esp_state"; |
|
507 | - if ($this->_get_table_analysis()->tableExists($state_table)) { |
|
508 | - $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
509 | - $states = $wpdb->get_var($SQL); |
|
510 | - if (! $states) { |
|
511 | - $SQL = "INSERT INTO " . $state_table . " |
|
466 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | + // setting up the default stats and countries is also essential for the data migrations to run |
|
468 | + // (because many need to convert old string states to foreign keys into the states table) |
|
469 | + $this->insert_default_states(); |
|
470 | + $this->insert_default_countries(); |
|
471 | + // setting up default prices, price types, and tickets is also essential for the price migrations |
|
472 | + $this->insert_default_price_types(); |
|
473 | + $this->insert_default_prices(); |
|
474 | + $this->insert_default_tickets(); |
|
475 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
476 | + EE_Config::instance()->update_espresso_config(false, true); |
|
477 | + return true; |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * Yes we could have cleaned up the ee3 tables here. But just in case someone |
|
484 | + * didn't backup their DB, and decides they want ot keep using EE3, we'll |
|
485 | + * leave them for now. Mayeb remove them in 4.5 or something. |
|
486 | + * |
|
487 | + * @return boolean |
|
488 | + */ |
|
489 | + public function schema_changes_after_migration() |
|
490 | + { |
|
491 | + return true; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * insert_default_states |
|
498 | + * |
|
499 | + * @access public |
|
500 | + * @static |
|
501 | + * @return void |
|
502 | + */ |
|
503 | + public function insert_default_states() |
|
504 | + { |
|
505 | + global $wpdb; |
|
506 | + $state_table = $wpdb->prefix . "esp_state"; |
|
507 | + if ($this->_get_table_analysis()->tableExists($state_table)) { |
|
508 | + $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
509 | + $states = $wpdb->get_var($SQL); |
|
510 | + if (! $states) { |
|
511 | + $SQL = "INSERT INTO " . $state_table . " |
|
512 | 512 | (STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES |
513 | 513 | (1, 'US', 'AK', 'Alaska', 1), |
514 | 514 | (2, 'US', 'AL', 'Alabama', 1), |
@@ -579,29 +579,29 @@ discard block |
||
579 | 579 | (67, 'CA', 'PE', 'Prince Edward Island', 1), |
580 | 580 | (68, 'CA', 'QC', 'Quebec', 1), |
581 | 581 | (69, 'CA', 'SK', 'Saskatchewan', 1);"; |
582 | - $wpdb->query($SQL); |
|
583 | - } |
|
584 | - } |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * insert_default_countries |
|
591 | - * |
|
592 | - * @access public |
|
593 | - * @static |
|
594 | - * @return void |
|
595 | - */ |
|
596 | - public function insert_default_countries() |
|
597 | - { |
|
598 | - global $wpdb; |
|
599 | - $country_table = $wpdb->prefix . "esp_country"; |
|
600 | - if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
601 | - $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
602 | - $countries = $wpdb->get_var($SQL); |
|
603 | - if (! $countries) { |
|
604 | - $SQL = "INSERT INTO " . $country_table . " |
|
582 | + $wpdb->query($SQL); |
|
583 | + } |
|
584 | + } |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * insert_default_countries |
|
591 | + * |
|
592 | + * @access public |
|
593 | + * @static |
|
594 | + * @return void |
|
595 | + */ |
|
596 | + public function insert_default_countries() |
|
597 | + { |
|
598 | + global $wpdb; |
|
599 | + $country_table = $wpdb->prefix . "esp_country"; |
|
600 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
601 | + $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
602 | + $countries = $wpdb->get_var($SQL); |
|
603 | + if (! $countries) { |
|
604 | + $SQL = "INSERT INTO " . $country_table . " |
|
605 | 605 | (CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES |
606 | 606 | ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
607 | 607 | ('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0), |
@@ -829,984 +829,984 @@ discard block |
||
829 | 829 | ('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0), |
830 | 830 | ('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0), |
831 | 831 | ('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);"; |
832 | - $wpdb->query($SQL); |
|
833 | - } |
|
834 | - } |
|
835 | - } |
|
836 | - |
|
837 | - |
|
838 | - |
|
839 | - /** |
|
840 | - * insert_default_price_types |
|
841 | - * |
|
842 | - * @access public |
|
843 | - * @static |
|
844 | - * @return void |
|
845 | - */ |
|
846 | - public function insert_default_price_types() |
|
847 | - { |
|
848 | - global $wpdb; |
|
849 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
850 | - if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
851 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
852 | - $price_types_exist = $wpdb->get_var($SQL); |
|
853 | - if (! $price_types_exist) { |
|
854 | - $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
|
832 | + $wpdb->query($SQL); |
|
833 | + } |
|
834 | + } |
|
835 | + } |
|
836 | + |
|
837 | + |
|
838 | + |
|
839 | + /** |
|
840 | + * insert_default_price_types |
|
841 | + * |
|
842 | + * @access public |
|
843 | + * @static |
|
844 | + * @return void |
|
845 | + */ |
|
846 | + public function insert_default_price_types() |
|
847 | + { |
|
848 | + global $wpdb; |
|
849 | + $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
850 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
851 | + $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
852 | + $price_types_exist = $wpdb->get_var($SQL); |
|
853 | + if (! $price_types_exist) { |
|
854 | + $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
|
855 | 855 | (1, '" . esc_html__('Base Price', 'event_espresso') . "', 1, 0, 0, 0), |
856 | 856 | (2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2, 1, 20, 0), |
857 | 857 | (3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2, 0, 30, 0), |
858 | 858 | (4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, 0), |
859 | 859 | (5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3, 0, 50, 0);"; |
860 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
861 | - $wpdb->query($SQL); |
|
862 | - } |
|
863 | - } |
|
864 | - } |
|
865 | - |
|
866 | - |
|
867 | - |
|
868 | - /** |
|
869 | - * insert_default_prices. We assume we're upgrading to regular here. |
|
870 | - * If we're INSTALLING 4.1 CAF, then we add a few extra default prices |
|
871 | - * when EEH_Activaion's initialize_db_content is called via ahook in |
|
872 | - * EE_BRewing_regular |
|
873 | - * |
|
874 | - * @access public |
|
875 | - * @static |
|
876 | - * @return void |
|
877 | - */ |
|
878 | - public function insert_default_prices() |
|
879 | - { |
|
880 | - global $wpdb; |
|
881 | - $price_table = $wpdb->prefix . "esp_price"; |
|
882 | - if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
883 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
884 | - $prices_exist = $wpdb->get_var($SQL); |
|
885 | - if (! $prices_exist) { |
|
886 | - $SQL = "INSERT INTO $price_table |
|
860 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
861 | + $wpdb->query($SQL); |
|
862 | + } |
|
863 | + } |
|
864 | + } |
|
865 | + |
|
866 | + |
|
867 | + |
|
868 | + /** |
|
869 | + * insert_default_prices. We assume we're upgrading to regular here. |
|
870 | + * If we're INSTALLING 4.1 CAF, then we add a few extra default prices |
|
871 | + * when EEH_Activaion's initialize_db_content is called via ahook in |
|
872 | + * EE_BRewing_regular |
|
873 | + * |
|
874 | + * @access public |
|
875 | + * @static |
|
876 | + * @return void |
|
877 | + */ |
|
878 | + public function insert_default_prices() |
|
879 | + { |
|
880 | + global $wpdb; |
|
881 | + $price_table = $wpdb->prefix . "esp_price"; |
|
882 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
883 | + $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
884 | + $prices_exist = $wpdb->get_var($SQL); |
|
885 | + if (! $prices_exist) { |
|
886 | + $SQL = "INSERT INTO $price_table |
|
887 | 887 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES |
888 | 888 | (1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);"; |
889 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
890 | - $wpdb->query($SQL); |
|
891 | - } |
|
892 | - } |
|
893 | - } |
|
894 | - |
|
895 | - |
|
896 | - |
|
897 | - /** |
|
898 | - * insert default ticket |
|
899 | - * |
|
900 | - * @access public |
|
901 | - * @static |
|
902 | - * @return void |
|
903 | - */ |
|
904 | - public function insert_default_tickets() |
|
905 | - { |
|
906 | - global $wpdb; |
|
907 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
908 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
909 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
910 | - $tickets_exist = $wpdb->get_var($SQL); |
|
911 | - if (! $tickets_exist) { |
|
912 | - $SQL = "INSERT INTO $ticket_table |
|
889 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
890 | + $wpdb->query($SQL); |
|
891 | + } |
|
892 | + } |
|
893 | + } |
|
894 | + |
|
895 | + |
|
896 | + |
|
897 | + /** |
|
898 | + * insert default ticket |
|
899 | + * |
|
900 | + * @access public |
|
901 | + * @static |
|
902 | + * @return void |
|
903 | + */ |
|
904 | + public function insert_default_tickets() |
|
905 | + { |
|
906 | + global $wpdb; |
|
907 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
908 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
909 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
910 | + $tickets_exist = $wpdb->get_var($SQL); |
|
911 | + if (! $tickets_exist) { |
|
912 | + $SQL = "INSERT INTO $ticket_table |
|
913 | 913 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
914 | 914 | ( 1, 0, '" |
915 | - . esc_html__("Free Ticket", "event_espresso") |
|
916 | - . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
917 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
918 | - $wpdb->query($SQL); |
|
919 | - } |
|
920 | - } |
|
921 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
922 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
923 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
924 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
925 | - if (! $ticket_prc_exist) { |
|
926 | - $SQL = "INSERT INTO $ticket_price_table |
|
915 | + . esc_html__("Free Ticket", "event_espresso") |
|
916 | + . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
917 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
918 | + $wpdb->query($SQL); |
|
919 | + } |
|
920 | + } |
|
921 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
922 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
923 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
924 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
925 | + if (! $ticket_prc_exist) { |
|
926 | + $SQL = "INSERT INTO $ticket_price_table |
|
927 | 927 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
928 | 928 | ( 1, 1, 1 ) |
929 | 929 | "; |
930 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
931 | - $wpdb->query($SQL); |
|
932 | - } |
|
933 | - } |
|
934 | - } |
|
935 | - |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(), |
|
940 | - * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1 |
|
941 | - * country ID (int), a 2-letter ISO, 3-letter ISO, or name |
|
942 | - * |
|
943 | - * @global type $wpdb |
|
944 | - * @param string $country_name |
|
945 | - * @return array where keys are columns, values are column values |
|
946 | - */ |
|
947 | - public function get_or_create_country($country_name) |
|
948 | - { |
|
949 | - if (! $country_name) { |
|
950 | - throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso")); |
|
951 | - } |
|
952 | - global $wpdb; |
|
953 | - $country_table = $wpdb->prefix . "esp_country"; |
|
954 | - if (is_int($country_name)) { |
|
955 | - $country_name = $this->get_iso_from_3_1_country_id($country_name); |
|
956 | - } |
|
957 | - $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
|
930 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
931 | + $wpdb->query($SQL); |
|
932 | + } |
|
933 | + } |
|
934 | + } |
|
935 | + |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(), |
|
940 | + * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1 |
|
941 | + * country ID (int), a 2-letter ISO, 3-letter ISO, or name |
|
942 | + * |
|
943 | + * @global type $wpdb |
|
944 | + * @param string $country_name |
|
945 | + * @return array where keys are columns, values are column values |
|
946 | + */ |
|
947 | + public function get_or_create_country($country_name) |
|
948 | + { |
|
949 | + if (! $country_name) { |
|
950 | + throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso")); |
|
951 | + } |
|
952 | + global $wpdb; |
|
953 | + $country_table = $wpdb->prefix . "esp_country"; |
|
954 | + if (is_int($country_name)) { |
|
955 | + $country_name = $this->get_iso_from_3_1_country_id($country_name); |
|
956 | + } |
|
957 | + $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
|
958 | 958 | CNT_ISO LIKE %s OR |
959 | 959 | CNT_ISO3 LIKE %s OR |
960 | 960 | CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A); |
961 | - if (! $country) { |
|
962 | - // insert a new one then |
|
963 | - $cols_n_values = array( |
|
964 | - 'CNT_ISO' => $this->_find_available_country_iso(2), |
|
965 | - 'CNT_ISO3' => $this->_find_available_country_iso(3), |
|
966 | - 'RGN_ID' => 0, |
|
967 | - 'CNT_name' => $country_name, |
|
968 | - 'CNT_cur_code' => 'USD', |
|
969 | - 'CNT_cur_single' => 'Dollar', |
|
970 | - 'CNT_cur_plural' => 'Dollars', |
|
971 | - 'CNT_cur_sign' => '$', |
|
972 | - 'CNT_cur_sign_b4' => true, |
|
973 | - 'CNT_cur_dec_plc' => 2, |
|
974 | - 'CNT_cur_dec_mrk' => '.', |
|
975 | - 'CNT_cur_thsnds' => ',', |
|
976 | - 'CNT_tel_code' => '+1', |
|
977 | - 'CNT_is_EU' => false, |
|
978 | - 'CNT_active' => true, |
|
979 | - ); |
|
980 | - $data_types = array( |
|
981 | - '%s',// CNT_ISO |
|
982 | - '%s',// CNT_ISO3 |
|
983 | - '%d',// RGN_ID |
|
984 | - '%s',// CNT_name |
|
985 | - '%s',// CNT_cur_code |
|
986 | - '%s',// CNT_cur_single |
|
987 | - '%s',// CNT_cur_plural |
|
988 | - '%s',// CNT_cur_sign |
|
989 | - '%d',// CNT_cur_sign_b4 |
|
990 | - '%d',// CNT_cur_dec_plc |
|
991 | - '%s',// CNT_cur_dec_mrk |
|
992 | - '%s',// CNT_cur_thsnds |
|
993 | - '%s',// CNT_tel_code |
|
994 | - '%d',// CNT_is_EU |
|
995 | - '%d',// CNT_active |
|
996 | - ); |
|
997 | - $success = $wpdb->insert( |
|
998 | - $country_table, |
|
999 | - $cols_n_values, |
|
1000 | - $data_types |
|
1001 | - ); |
|
1002 | - if (! $success) { |
|
1003 | - throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1004 | - 'N/A', |
|
1005 | - array('country_id' => $country_name), |
|
1006 | - $country_table, |
|
1007 | - $cols_n_values, |
|
1008 | - $data_types |
|
1009 | - )); |
|
1010 | - } |
|
1011 | - $country = $cols_n_values; |
|
1012 | - } |
|
1013 | - return $country; |
|
1014 | - } |
|
1015 | - |
|
1016 | - |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * finds a country iso which hasnt been used yet |
|
1020 | - * |
|
1021 | - * @global type $wpdb |
|
1022 | - * @return string |
|
1023 | - */ |
|
1024 | - private function _find_available_country_iso($num_letters = 2) |
|
1025 | - { |
|
1026 | - global $wpdb; |
|
1027 | - $country_table = $wpdb->prefix . "esp_country"; |
|
1028 | - $attempts = 0; |
|
1029 | - do { |
|
1030 | - $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
|
1031 | - $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM " |
|
1032 | - . $country_table |
|
1033 | - . " WHERE CNT_ISO=%s", $current_iso)); |
|
1034 | - $attempts++; |
|
1035 | - // keep going until we find an available country code, or we arbitrarily |
|
1036 | - // decide we've tried this enough. Somehow they have way too many countries |
|
1037 | - // (probably because they're mis-using the EE3 country_id like a custom question) |
|
1038 | - } while (intval($country_with_that_iso) && $attempts < 200); |
|
1039 | - return $current_iso; |
|
1040 | - } |
|
1041 | - |
|
1042 | - |
|
1043 | - |
|
1044 | - /** |
|
1045 | - * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but |
|
1046 | - * is independent of outside code which can change in future versions of EE |
|
1047 | - * |
|
1048 | - * @global type $wpdb |
|
1049 | - * @param string $state_name |
|
1050 | - * @return array where keys are columns, values are column values |
|
1051 | - */ |
|
1052 | - public function get_or_create_state($state_name, $country_name = '') |
|
1053 | - { |
|
1054 | - if (! $state_name) { |
|
1055 | - throw new EE_Error(esc_html__( |
|
1056 | - "Could not get-or-create state because no state name was provided", |
|
1057 | - "event_espresso" |
|
1058 | - )); |
|
1059 | - } |
|
1060 | - try { |
|
1061 | - $country = $this->get_or_create_country($country_name); |
|
1062 | - $country_iso = $country['CNT_ISO']; |
|
1063 | - } catch (EE_Error $e) { |
|
1064 | - $country_iso = $this->get_default_country_iso(); |
|
1065 | - } |
|
1066 | - global $wpdb; |
|
1067 | - $state_table = $wpdb->prefix . "esp_state"; |
|
1068 | - $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
|
961 | + if (! $country) { |
|
962 | + // insert a new one then |
|
963 | + $cols_n_values = array( |
|
964 | + 'CNT_ISO' => $this->_find_available_country_iso(2), |
|
965 | + 'CNT_ISO3' => $this->_find_available_country_iso(3), |
|
966 | + 'RGN_ID' => 0, |
|
967 | + 'CNT_name' => $country_name, |
|
968 | + 'CNT_cur_code' => 'USD', |
|
969 | + 'CNT_cur_single' => 'Dollar', |
|
970 | + 'CNT_cur_plural' => 'Dollars', |
|
971 | + 'CNT_cur_sign' => '$', |
|
972 | + 'CNT_cur_sign_b4' => true, |
|
973 | + 'CNT_cur_dec_plc' => 2, |
|
974 | + 'CNT_cur_dec_mrk' => '.', |
|
975 | + 'CNT_cur_thsnds' => ',', |
|
976 | + 'CNT_tel_code' => '+1', |
|
977 | + 'CNT_is_EU' => false, |
|
978 | + 'CNT_active' => true, |
|
979 | + ); |
|
980 | + $data_types = array( |
|
981 | + '%s',// CNT_ISO |
|
982 | + '%s',// CNT_ISO3 |
|
983 | + '%d',// RGN_ID |
|
984 | + '%s',// CNT_name |
|
985 | + '%s',// CNT_cur_code |
|
986 | + '%s',// CNT_cur_single |
|
987 | + '%s',// CNT_cur_plural |
|
988 | + '%s',// CNT_cur_sign |
|
989 | + '%d',// CNT_cur_sign_b4 |
|
990 | + '%d',// CNT_cur_dec_plc |
|
991 | + '%s',// CNT_cur_dec_mrk |
|
992 | + '%s',// CNT_cur_thsnds |
|
993 | + '%s',// CNT_tel_code |
|
994 | + '%d',// CNT_is_EU |
|
995 | + '%d',// CNT_active |
|
996 | + ); |
|
997 | + $success = $wpdb->insert( |
|
998 | + $country_table, |
|
999 | + $cols_n_values, |
|
1000 | + $data_types |
|
1001 | + ); |
|
1002 | + if (! $success) { |
|
1003 | + throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1004 | + 'N/A', |
|
1005 | + array('country_id' => $country_name), |
|
1006 | + $country_table, |
|
1007 | + $cols_n_values, |
|
1008 | + $data_types |
|
1009 | + )); |
|
1010 | + } |
|
1011 | + $country = $cols_n_values; |
|
1012 | + } |
|
1013 | + return $country; |
|
1014 | + } |
|
1015 | + |
|
1016 | + |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * finds a country iso which hasnt been used yet |
|
1020 | + * |
|
1021 | + * @global type $wpdb |
|
1022 | + * @return string |
|
1023 | + */ |
|
1024 | + private function _find_available_country_iso($num_letters = 2) |
|
1025 | + { |
|
1026 | + global $wpdb; |
|
1027 | + $country_table = $wpdb->prefix . "esp_country"; |
|
1028 | + $attempts = 0; |
|
1029 | + do { |
|
1030 | + $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
|
1031 | + $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM " |
|
1032 | + . $country_table |
|
1033 | + . " WHERE CNT_ISO=%s", $current_iso)); |
|
1034 | + $attempts++; |
|
1035 | + // keep going until we find an available country code, or we arbitrarily |
|
1036 | + // decide we've tried this enough. Somehow they have way too many countries |
|
1037 | + // (probably because they're mis-using the EE3 country_id like a custom question) |
|
1038 | + } while (intval($country_with_that_iso) && $attempts < 200); |
|
1039 | + return $current_iso; |
|
1040 | + } |
|
1041 | + |
|
1042 | + |
|
1043 | + |
|
1044 | + /** |
|
1045 | + * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but |
|
1046 | + * is independent of outside code which can change in future versions of EE |
|
1047 | + * |
|
1048 | + * @global type $wpdb |
|
1049 | + * @param string $state_name |
|
1050 | + * @return array where keys are columns, values are column values |
|
1051 | + */ |
|
1052 | + public function get_or_create_state($state_name, $country_name = '') |
|
1053 | + { |
|
1054 | + if (! $state_name) { |
|
1055 | + throw new EE_Error(esc_html__( |
|
1056 | + "Could not get-or-create state because no state name was provided", |
|
1057 | + "event_espresso" |
|
1058 | + )); |
|
1059 | + } |
|
1060 | + try { |
|
1061 | + $country = $this->get_or_create_country($country_name); |
|
1062 | + $country_iso = $country['CNT_ISO']; |
|
1063 | + } catch (EE_Error $e) { |
|
1064 | + $country_iso = $this->get_default_country_iso(); |
|
1065 | + } |
|
1066 | + global $wpdb; |
|
1067 | + $state_table = $wpdb->prefix . "esp_state"; |
|
1068 | + $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
|
1069 | 1069 | (STA_abbrev LIKE %s OR |
1070 | 1070 | STA_name LIKE %s) AND |
1071 | 1071 | CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A); |
1072 | - if (! $state) { |
|
1073 | - // insert a new one then |
|
1074 | - $cols_n_values = array( |
|
1075 | - 'CNT_ISO' => $country_iso, |
|
1076 | - 'STA_abbrev' => substr($state_name, 0, 6), |
|
1077 | - 'STA_name' => $state_name, |
|
1078 | - 'STA_active' => true, |
|
1079 | - ); |
|
1080 | - $data_types = array( |
|
1081 | - '%s',// CNT_ISO |
|
1082 | - '%s',// STA_abbrev |
|
1083 | - '%s',// STA_name |
|
1084 | - '%d',// STA_active |
|
1085 | - ); |
|
1086 | - $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1087 | - if (! $success) { |
|
1088 | - throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1089 | - 'N/A', |
|
1090 | - array('state' => $state_name, 'country_id' => $country_name), |
|
1091 | - $state_table, |
|
1092 | - $cols_n_values, |
|
1093 | - $data_types |
|
1094 | - )); |
|
1095 | - } |
|
1096 | - $state = $cols_n_values; |
|
1097 | - $state['STA_ID'] = $wpdb->insert_id; |
|
1098 | - } |
|
1099 | - return $state; |
|
1100 | - } |
|
1101 | - |
|
1102 | - |
|
1103 | - |
|
1104 | - /** |
|
1105 | - * Fixes times like "5:00 PM" into the expected 24-hour format "17:00". |
|
1106 | - * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing |
|
1107 | - * |
|
1108 | - * @param type $timeString |
|
1109 | - * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes |
|
1110 | - * with leading zeros) |
|
1111 | - */ |
|
1112 | - public function convertTimeFromAMPM($timeString) |
|
1113 | - { |
|
1114 | - $matches = array(); |
|
1115 | - preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1116 | - if (! $matches || count($matches) < 3) { |
|
1117 | - $hour = '00'; |
|
1118 | - $minutes = '00'; |
|
1119 | - } else { |
|
1120 | - $hour = intval($matches[1]); |
|
1121 | - $minutes = $matches[2]; |
|
1122 | - } |
|
1123 | - if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1124 | - $hour = intval($hour) + 12; |
|
1125 | - } |
|
1126 | - $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1127 | - $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1128 | - return "$hour:$minutes"; |
|
1129 | - } |
|
1130 | - |
|
1131 | - |
|
1132 | - |
|
1133 | - /** |
|
1134 | - * Gets the ISO3 fora country given its 3.1 country ID. |
|
1135 | - * |
|
1136 | - * @param int $country_id |
|
1137 | - * @return string the country's ISO3 code |
|
1138 | - */ |
|
1139 | - public function get_iso_from_3_1_country_id($country_id) |
|
1140 | - { |
|
1141 | - $old_countries = array( |
|
1142 | - array(64, 'United States', 'US', 'USA', 1), |
|
1143 | - array(15, 'Australia', 'AU', 'AUS', 1), |
|
1144 | - array(39, 'Canada', 'CA', 'CAN', 1), |
|
1145 | - array(171, 'United Kingdom', 'GB', 'GBR', 1), |
|
1146 | - array(70, 'France', 'FR', 'FRA', 2), |
|
1147 | - array(111, 'Italy', 'IT', 'ITA', 2), |
|
1148 | - array(63, 'Spain', 'ES', 'ESP', 2), |
|
1149 | - array(1, 'Afghanistan', 'AF', 'AFG', 1), |
|
1150 | - array(2, 'Albania', 'AL', 'ALB', 1), |
|
1151 | - array(3, 'Germany', 'DE', 'DEU', 2), |
|
1152 | - array(198, 'Switzerland', 'CH', 'CHE', 1), |
|
1153 | - array(87, 'Netherlands', 'NL', 'NLD', 2), |
|
1154 | - array(197, 'Sweden', 'SE', 'SWE', 1), |
|
1155 | - array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2), |
|
1156 | - array(4, 'Andorra', 'AD', 'AND', 2), |
|
1157 | - array(5, 'Angola', 'AO', 'AGO', 1), |
|
1158 | - array(6, 'Anguilla', 'AI', 'AIA', 1), |
|
1159 | - array(7, 'Antarctica', 'AQ', 'ATA', 1), |
|
1160 | - array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1), |
|
1161 | - array(10, 'Saudi Arabia', 'SA', 'SAU', 1), |
|
1162 | - array(11, 'Algeria', 'DZ', 'DZA', 1), |
|
1163 | - array(12, 'Argentina', 'AR', 'ARG', 1), |
|
1164 | - array(13, 'Armenia', 'AM', 'ARM', 1), |
|
1165 | - array(14, 'Aruba', 'AW', 'ABW', 1), |
|
1166 | - array(16, 'Austria', 'AT', 'AUT', 2), |
|
1167 | - array(17, 'Azerbaijan', 'AZ', 'AZE', 1), |
|
1168 | - array(18, 'Bahamas', 'BS', 'BHS', 1), |
|
1169 | - array(19, 'Bahrain', 'BH', 'BHR', 1), |
|
1170 | - array(20, 'Bangladesh', 'BD', 'BGD', 1), |
|
1171 | - array(21, 'Barbados', 'BB', 'BRB', 1), |
|
1172 | - array(22, 'Belgium ', 'BE', 'BEL', 2), |
|
1173 | - array(23, 'Belize', 'BZ', 'BLZ', 1), |
|
1174 | - array(24, 'Benin', 'BJ', 'BEN', 1), |
|
1175 | - array(25, 'Bermudas', 'BM', 'BMU', 1), |
|
1176 | - array(26, 'Belarus', 'BY', 'BLR', 1), |
|
1177 | - array(27, 'Bolivia', 'BO', 'BOL', 1), |
|
1178 | - array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1), |
|
1179 | - array(29, 'Botswana', 'BW', 'BWA', 1), |
|
1180 | - array(96, 'Bouvet Island', 'BV', 'BVT', 1), |
|
1181 | - array(30, 'Brazil', 'BR', 'BRA', 1), |
|
1182 | - array(31, 'Brunei', 'BN', 'BRN', 1), |
|
1183 | - array(32, 'Bulgaria', 'BG', 'BGR', 1), |
|
1184 | - array(33, 'Burkina Faso', 'BF', 'BFA', 1), |
|
1185 | - array(34, 'Burundi', 'BI', 'BDI', 1), |
|
1186 | - array(35, 'Bhutan', 'BT', 'BTN', 1), |
|
1187 | - array(36, 'Cape Verde', 'CV', 'CPV', 1), |
|
1188 | - array(37, 'Cambodia', 'KH', 'KHM', 1), |
|
1189 | - array(38, 'Cameroon', 'CM', 'CMR', 1), |
|
1190 | - array(98, 'Cayman Islands', 'KY', 'CYM', 1), |
|
1191 | - array(172, 'Central African Republic', 'CF', 'CAF', 1), |
|
1192 | - array(40, 'Chad', 'TD', 'TCD', 1), |
|
1193 | - array(41, 'Chile', 'CL', 'CHL', 1), |
|
1194 | - array(42, 'China', 'CN', 'CHN', 1), |
|
1195 | - array(105, 'Christmas Island', 'CX', 'CXR', 1), |
|
1196 | - array(43, 'Cyprus', 'CY', 'CYP', 2), |
|
1197 | - array(99, 'Cocos Island', 'CC', 'CCK', 1), |
|
1198 | - array(100, 'Cook Islands', 'CK', 'COK', 1), |
|
1199 | - array(44, 'Colombia', 'CO', 'COL', 1), |
|
1200 | - array(45, 'Comoros', 'KM', 'COM', 1), |
|
1201 | - array(46, 'Congo', 'CG', 'COG', 1), |
|
1202 | - array(47, 'North Korea', 'KP', 'PRK', 1), |
|
1203 | - array(50, 'Costa Rica', 'CR', 'CRI', 1), |
|
1204 | - array(51, 'Croatia', 'HR', 'HRV', 1), |
|
1205 | - array(52, 'Cuba', 'CU', 'CUB', 1), |
|
1206 | - array(173, 'Czech Republic', 'CZ', 'CZE', 1), |
|
1207 | - array(53, 'Denmark', 'DK', 'DNK', 1), |
|
1208 | - array(54, 'Djibouti', 'DJ', 'DJI', 1), |
|
1209 | - array(55, 'Dominica', 'DM', 'DMA', 1), |
|
1210 | - array(174, 'Dominican Republic', 'DO', 'DOM', 1), |
|
1211 | - array(56, 'Ecuador', 'EC', 'ECU', 1), |
|
1212 | - array(57, 'Egypt', 'EG', 'EGY', 1), |
|
1213 | - array(58, 'El Salvador', 'SV', 'SLV', 1), |
|
1214 | - array(60, 'Eritrea', 'ER', 'ERI', 1), |
|
1215 | - array(61, 'Slovakia', 'SK', 'SVK', 2), |
|
1216 | - array(62, 'Slovenia', 'SI', 'SVN', 2), |
|
1217 | - array(65, 'Estonia', 'EE', 'EST', 2), |
|
1218 | - array(66, 'Ethiopia', 'ET', 'ETH', 1), |
|
1219 | - array(102, 'Faroe islands', 'FO', 'FRO', 1), |
|
1220 | - array(103, 'Falkland Islands', 'FK', 'FLK', 1), |
|
1221 | - array(67, 'Fiji', 'FJ', 'FJI', 1), |
|
1222 | - array(69, 'Finland', 'FI', 'FIN', 2), |
|
1223 | - array(71, 'Gabon', 'GA', 'GAB', 1), |
|
1224 | - array(72, 'Gambia', 'GM', 'GMB', 1), |
|
1225 | - array(73, 'Georgia', 'GE', 'GEO', 1), |
|
1226 | - array(74, 'Ghana', 'GH', 'GHA', 1), |
|
1227 | - array(75, 'Gibraltar', 'GI', 'GIB', 1), |
|
1228 | - array(76, 'Greece', 'GR', 'GRC', 2), |
|
1229 | - array(77, 'Grenada', 'GD', 'GRD', 1), |
|
1230 | - array(78, 'Greenland', 'GL', 'GRL', 1), |
|
1231 | - array(79, 'Guadeloupe', 'GP', 'GLP', 1), |
|
1232 | - array(80, 'Guam', 'GU', 'GUM', 1), |
|
1233 | - array(81, 'Guatemala', 'GT', 'GTM', 1), |
|
1234 | - array(82, 'Guinea', 'GN', 'GIN', 1), |
|
1235 | - array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1), |
|
1236 | - array(84, 'Guinea-Bissau', 'GW', 'GNB', 1), |
|
1237 | - array(85, 'Guyana', 'GY', 'GUY', 1), |
|
1238 | - array(86, 'Haiti', 'HT', 'HTI', 1), |
|
1239 | - array(88, 'Honduras', 'HN', 'HND', 1), |
|
1240 | - array(89, 'Hong Kong', 'HK', 'HKG', 1), |
|
1241 | - array(90, 'Hungary', 'HU', 'HUN', 1), |
|
1242 | - array(91, 'India', 'IN', 'IND', 1), |
|
1243 | - array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1), |
|
1244 | - array(92, 'Indonesia', 'ID', 'IDN', 1), |
|
1245 | - array(93, 'Iraq', 'IQ', 'IRQ', 1), |
|
1246 | - array(94, 'Iran', 'IR', 'IRN', 1), |
|
1247 | - array(95, 'Ireland', 'IE', 'IRL', 2), |
|
1248 | - array(97, 'Iceland', 'IS', 'ISL', 1), |
|
1249 | - array(110, 'Israel', 'IL', 'ISR', 1), |
|
1250 | - array(49, 'Ivory Coast ', 'CI', 'CIV', 1), |
|
1251 | - array(112, 'Jamaica', 'JM', 'JAM', 1), |
|
1252 | - array(113, 'Japan', 'JP', 'JPN', 1), |
|
1253 | - array(114, 'Jordan', 'JO', 'JOR', 1), |
|
1254 | - array(115, 'Kazakhstan', 'KZ', 'KAZ', 1), |
|
1255 | - array(116, 'Kenya', 'KE', 'KEN', 1), |
|
1256 | - array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1), |
|
1257 | - array(118, 'Kiribati', 'KI', 'KIR', 1), |
|
1258 | - array(48, 'South Korea', 'KR', 'KOR', 1), |
|
1259 | - array(228, 'Kosovo', 'XK', 'XKV', 2), |
|
1260 | - // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code |
|
1261 | - array(119, 'Kuwait', 'KW', 'KWT', 1), |
|
1262 | - array(120, 'Laos', 'LA', 'LAO', 1), |
|
1263 | - array(121, 'Latvia', 'LV', 'LVA', 2), |
|
1264 | - array(122, 'Lesotho', 'LS', 'LSO', 1), |
|
1265 | - array(123, 'Lebanon', 'LB', 'LBN', 1), |
|
1266 | - array(124, 'Liberia', 'LR', 'LBR', 1), |
|
1267 | - array(125, 'Libya', 'LY', 'LBY', 1), |
|
1268 | - array(126, 'Liechtenstein', 'LI', 'LIE', 1), |
|
1269 | - array(127, 'Lithuania', 'LT', 'LTU', 2), |
|
1270 | - array(128, 'Luxemburg', 'LU', 'LUX', 2), |
|
1271 | - array(129, 'Macao', 'MO', 'MAC', 1), |
|
1272 | - array(130, 'Macedonia', 'MK', 'MKD', 1), |
|
1273 | - array(131, 'Madagascar', 'MG', 'MDG', 1), |
|
1274 | - array(132, 'Malaysia', 'MY', 'MYS', 1), |
|
1275 | - array(133, 'Malawi', 'MW', 'MWI', 1), |
|
1276 | - array(134, 'Maldivas', 'MV', 'MDV', 1), |
|
1277 | - array(135, 'Mali', 'ML', 'MLI', 1), |
|
1278 | - array(136, 'Malta', 'MT', 'MLT', 2), |
|
1279 | - array(101, 'Northern Marianas', 'MP', 'MNP', 1), |
|
1280 | - array(137, 'Morocco', 'MA', 'MAR', 1), |
|
1281 | - array(104, 'Marshall islands', 'MH', 'MHL', 1), |
|
1282 | - array(138, 'Martinique', 'MQ', 'MTQ', 1), |
|
1283 | - array(139, 'Mauritius', 'MU', 'MUS', 1), |
|
1284 | - array(140, 'Mauritania', 'MR', 'MRT', 1), |
|
1285 | - array(141, 'Mayote', 'YT', 'MYT', 2), |
|
1286 | - array(142, 'Mexico', 'MX', 'MEX', 1), |
|
1287 | - array(143, 'Micronesia', 'FM', 'FSM', 1), |
|
1288 | - array(144, 'Moldova', 'MD', 'MDA', 1), |
|
1289 | - array(145, 'Monaco', 'MC', 'MCO', 2), |
|
1290 | - array(146, 'Mongolia', 'MN', 'MNG', 1), |
|
1291 | - array(147, 'Montserrat', 'MS', 'MSR', 1), |
|
1292 | - array(227, 'Montenegro', 'ME', 'MNE', 2), |
|
1293 | - array(148, 'Mozambique', 'MZ', 'MOZ', 1), |
|
1294 | - array(149, 'Myanmar', 'MM', 'MMR', 1), |
|
1295 | - array(150, 'Namibia', 'NA', 'NAM', 1), |
|
1296 | - array(151, 'Nauru', 'NR', 'NRU', 1), |
|
1297 | - array(152, 'Nepal', 'NP', 'NPL', 1), |
|
1298 | - array(9, 'Netherlands Antilles', 'AN', 'ANT', 1), |
|
1299 | - array(153, 'Nicaragua', 'NI', 'NIC', 1), |
|
1300 | - array(154, 'Niger', 'NE', 'NER', 1), |
|
1301 | - array(155, 'Nigeria', 'NG', 'NGA', 1), |
|
1302 | - array(156, 'Niue', 'NU', 'NIU', 1), |
|
1303 | - array(157, 'Norway', 'NO', 'NOR', 1), |
|
1304 | - array(158, 'New Caledonia', 'NC', 'NCL', 1), |
|
1305 | - array(159, 'New Zealand', 'NZ', 'NZL', 1), |
|
1306 | - array(160, 'Oman', 'OM', 'OMN', 1), |
|
1307 | - array(161, 'Pakistan', 'PK', 'PAK', 1), |
|
1308 | - array(162, 'Palau', 'PW', 'PLW', 1), |
|
1309 | - array(163, 'Panama', 'PA', 'PAN', 1), |
|
1310 | - array(164, 'Papua New Guinea', 'PG', 'PNG', 1), |
|
1311 | - array(165, 'Paraguay', 'PY', 'PRY', 1), |
|
1312 | - array(166, 'Peru', 'PE', 'PER', 1), |
|
1313 | - array(68, 'Philippines', 'PH', 'PHL', 1), |
|
1314 | - array(167, 'Poland', 'PL', 'POL', 1), |
|
1315 | - array(168, 'Portugal', 'PT', 'PRT', 2), |
|
1316 | - array(169, 'Puerto Rico', 'PR', 'PRI', 1), |
|
1317 | - array(170, 'Qatar', 'QA', 'QAT', 1), |
|
1318 | - array(176, 'Rwanda', 'RW', 'RWA', 1), |
|
1319 | - array(177, 'Romania', 'RO', 'ROM', 2), |
|
1320 | - array(178, 'Russia', 'RU', 'RUS', 1), |
|
1321 | - array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2), |
|
1322 | - array(180, 'Samoa', 'WS', 'WSM', 1), |
|
1323 | - array(181, 'American Samoa', 'AS', 'ASM', 1), |
|
1324 | - array(183, 'San Marino', 'SM', 'SMR', 2), |
|
1325 | - array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1), |
|
1326 | - array(185, 'Saint Helena', 'SH', 'SHN', 1), |
|
1327 | - array(186, 'Saint Lucia', 'LC', 'LCA', 1), |
|
1328 | - array(188, 'Senegal', 'SN', 'SEN', 1), |
|
1329 | - array(189, 'Seychelles', 'SC', 'SYC', 1), |
|
1330 | - array(190, 'Sierra Leona', 'SL', 'SLE', 1), |
|
1331 | - array(191, 'Singapore', 'SG', 'SGP', 1), |
|
1332 | - array(192, 'Syria', 'SY', 'SYR', 1), |
|
1333 | - array(193, 'Somalia', 'SO', 'SOM', 1), |
|
1334 | - array(194, 'Sri Lanka', 'LK', 'LKA', 1), |
|
1335 | - array(195, 'South Africa', 'ZA', 'ZAF', 1), |
|
1336 | - array(196, 'Sudan', 'SD', 'SDN', 1), |
|
1337 | - array(199, 'Suriname', 'SR', 'SUR', 1), |
|
1338 | - array(200, 'Swaziland', 'SZ', 'SWZ', 1), |
|
1339 | - array(201, 'Thailand', 'TH', 'THA', 1), |
|
1340 | - array(202, 'Taiwan', 'TW', 'TWN', 1), |
|
1341 | - array(203, 'Tanzania', 'TZ', 'TZA', 1), |
|
1342 | - array(204, 'Tajikistan', 'TJ', 'TJK', 1), |
|
1343 | - array(206, 'Timor-Leste', 'TL', 'TLS', 1), |
|
1344 | - array(207, 'Togo', 'TG', 'TGO', 1), |
|
1345 | - array(208, 'Tokelau', 'TK', 'TKL', 1), |
|
1346 | - array(209, 'Tonga', 'TO', 'TON', 1), |
|
1347 | - array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1), |
|
1348 | - array(211, 'Tunisia', 'TN', 'TUN', 1), |
|
1349 | - array(212, 'Turkmenistan', 'TM', 'TKM', 1), |
|
1350 | - array(213, 'Turkey', 'TR', 'TUR', 1), |
|
1351 | - array(214, 'Tuvalu', 'TV', 'TUV', 1), |
|
1352 | - array(215, 'Ukraine', 'UA', 'UKR', 1), |
|
1353 | - array(216, 'Uganda', 'UG', 'UGA', 1), |
|
1354 | - array(59, 'United Arab Emirates', 'AE', 'ARE', 1), |
|
1355 | - array(217, 'Uruguay', 'UY', 'URY', 1), |
|
1356 | - array(218, 'Uzbekistan', 'UZ', 'UZB', 1), |
|
1357 | - array(219, 'Vanuatu', 'VU', 'VUT', 1), |
|
1358 | - array(220, 'Vatican City', 'VA', 'VAT', 2), |
|
1359 | - array(221, 'Venezuela', 'VE', 'VEN', 1), |
|
1360 | - array(222, 'Vietnam', 'VN', 'VNM', 1), |
|
1361 | - array(108, 'Virgin Islands', 'VI', 'VIR', 1), |
|
1362 | - array(223, 'Yemen', 'YE', 'YEM', 1), |
|
1363 | - array(225, 'Zambia', 'ZM', 'ZMB', 1), |
|
1364 | - array(226, 'Zimbabwe', 'ZW', 'ZWE', 1), |
|
1365 | - ); |
|
1366 | - $country_iso = 'US'; |
|
1367 | - foreach ($old_countries as $country_array) { |
|
1368 | - // note: index 0 is the 3.1 country ID |
|
1369 | - if ($country_array[0] == $country_id) { |
|
1370 | - // note: index 2 is the ISO |
|
1371 | - $country_iso = $country_array[2]; |
|
1372 | - break; |
|
1373 | - } |
|
1374 | - } |
|
1375 | - return $country_iso; |
|
1376 | - } |
|
1377 | - |
|
1378 | - |
|
1379 | - |
|
1380 | - /** |
|
1381 | - * Gets the ISO3 for the |
|
1382 | - * |
|
1383 | - * @return string |
|
1384 | - */ |
|
1385 | - public function get_default_country_iso() |
|
1386 | - { |
|
1387 | - $old_org_options = get_option('events_organization_settings'); |
|
1388 | - $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
|
1389 | - return $iso; |
|
1390 | - } |
|
1391 | - |
|
1392 | - |
|
1393 | - |
|
1394 | - /** |
|
1395 | - * Converst a 3.1 payment status to its equivalent 4.1 regisration status |
|
1396 | - * |
|
1397 | - * @param string $payment_status possible value for 3.1's evens_attendee.payment_status |
|
1398 | - * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's |
|
1399 | - * default payment status, the event's default payment status, or |
|
1400 | - * the attendee's payment status) required pre-approval. |
|
1401 | - * @return string STS_ID for use in 4.1 |
|
1402 | - */ |
|
1403 | - public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) |
|
1404 | - { |
|
1405 | - // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
|
1406 | - if ($this_thing_required_pre_approval) { |
|
1407 | - return 'RNA'; |
|
1408 | - } else { |
|
1409 | - $mapping = $default_reg_stati_conversions = array( |
|
1410 | - 'Completed' => 'RAP', |
|
1411 | - '' => 'RPP', |
|
1412 | - 'Incomplete' => 'RPP', |
|
1413 | - 'Pending' => 'RAP', |
|
1414 | - // stati that only occurred on 3.1 attendees: |
|
1415 | - 'Payment Declined' => 'RPP', |
|
1416 | - 'Not Completed' => 'RPP', |
|
1417 | - 'Cancelled' => 'RPP', |
|
1418 | - 'Declined' => 'RPP', |
|
1419 | - ); |
|
1420 | - } |
|
1421 | - return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA'; |
|
1422 | - } |
|
1423 | - |
|
1424 | - |
|
1425 | - |
|
1426 | - /** |
|
1427 | - * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event |
|
1428 | - * and sets it as the featured image on the CPT event |
|
1429 | - * |
|
1430 | - * @param type $old_event |
|
1431 | - * @param type $new_cpt_id |
|
1432 | - * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
|
1433 | - * @return boolean whether or not we had to do the big job of creating an image attachment |
|
1434 | - */ |
|
1435 | - public function convert_image_url_to_attachment_and_attach_to_post( |
|
1436 | - $guid, |
|
1437 | - $new_cpt_id, |
|
1438 | - EE_Data_Migration_Script_Stage $migration_stage |
|
1439 | - ) { |
|
1440 | - $created_attachment_post = false; |
|
1441 | - $guid = $this->_get_original_guid($guid); |
|
1442 | - if ($guid) { |
|
1443 | - // check for an existing attachment post with this guid |
|
1444 | - $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
|
1445 | - if (! $attachment_post_id) { |
|
1446 | - // post thumbnail with that GUID doesn't exist, we should create one |
|
1447 | - $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
|
1448 | - $created_attachment_post = true; |
|
1449 | - } |
|
1450 | - // double-check we actually have an attachment post |
|
1451 | - if ($attachment_post_id) { |
|
1452 | - update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1453 | - } else { |
|
1454 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1455 | - "Could not update event image %s for CPT with ID %d, but attachments post ID is %d", |
|
1456 | - "event_espresso" |
|
1457 | - ), $guid, $new_cpt_id, $attachment_post_id)); |
|
1458 | - } |
|
1459 | - } |
|
1460 | - return $created_attachment_post; |
|
1461 | - } |
|
1462 | - |
|
1463 | - |
|
1464 | - |
|
1465 | - /** |
|
1466 | - * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead |
|
1467 | - * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype, |
|
1468 | - * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of |
|
1469 | - * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it |
|
1470 | - * exists |
|
1471 | - * |
|
1472 | - * @param string $guid_in_old_event |
|
1473 | - * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
|
1474 | - */ |
|
1475 | - private function _get_original_guid($guid_in_old_event) |
|
1476 | - { |
|
1477 | - $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1478 | - // do a head request to verify the file exists |
|
1479 | - $head_response = wp_remote_head($original_guid); |
|
1480 | - if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1481 | - return $original_guid; |
|
1482 | - } else { |
|
1483 | - return $guid_in_old_event; |
|
1484 | - } |
|
1485 | - } |
|
1486 | - |
|
1487 | - |
|
1488 | - |
|
1489 | - /** |
|
1490 | - * Creates an image attachment post for the GUID. If the GUID points to a remote image, |
|
1491 | - * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of |
|
1492 | - * thumbnails) |
|
1493 | - * |
|
1494 | - * @param type $guid |
|
1495 | - * @param EE_Data_Migration_Script_Stage $migration_stage |
|
1496 | - * @return int |
|
1497 | - */ |
|
1498 | - private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) |
|
1499 | - { |
|
1500 | - if (! $guid) { |
|
1501 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1502 | - "Cannot create image attachment for a blank GUID!", |
|
1503 | - "event_espresso" |
|
1504 | - ))); |
|
1505 | - return 0; |
|
1506 | - } |
|
1507 | - $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1508 | - $wp_upload_dir = wp_upload_dir(); |
|
1509 | - // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
|
1510 | - if (strpos($guid, $wp_upload_dir['url']) === false) { |
|
1511 | - // image is located remotely. download it and place it in the uploads directory |
|
1512 | - if (! is_readable($guid)) { |
|
1513 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1514 | - "Could not create image attachment from non-existent file: %s", |
|
1515 | - "event_espresso" |
|
1516 | - ), $guid)); |
|
1517 | - return 0; |
|
1518 | - } |
|
1519 | - $contents = file_get_contents($guid); |
|
1520 | - if ($contents === false) { |
|
1521 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1522 | - "Could not read image at %s, and therefore couldnt create an attachment post for it.", |
|
1523 | - "event_espresso" |
|
1524 | - ), $guid)); |
|
1525 | - return false; |
|
1526 | - } |
|
1527 | - $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid); |
|
1528 | - $savefile = fopen($local_filepath, 'w'); |
|
1529 | - fwrite($savefile, $contents); |
|
1530 | - fclose($savefile); |
|
1531 | - $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1532 | - } else { |
|
1533 | - $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1534 | - } |
|
1535 | - $attachment = array( |
|
1536 | - 'guid' => $guid, |
|
1537 | - 'post_mime_type' => $wp_filetype['type'], |
|
1538 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($guid)), |
|
1539 | - 'post_content' => '', |
|
1540 | - 'post_status' => 'inherit', |
|
1541 | - ); |
|
1542 | - $attach_id = wp_insert_attachment($attachment, $guid); |
|
1543 | - if (! $attach_id) { |
|
1544 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1545 | - "Could not create image attachment post from image '%s'. Attachment data was %s.", |
|
1546 | - "event_espresso" |
|
1547 | - ), $guid, $this->_json_encode($attachment))); |
|
1548 | - return $attach_id; |
|
1549 | - } |
|
1550 | - // you must first include the image.php file |
|
1551 | - // for the function wp_generate_attachment_metadata() to work |
|
1552 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1553 | - $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1554 | - if (! $attach_data) { |
|
1555 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1556 | - "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", |
|
1557 | - "event_espresso" |
|
1558 | - ), $attach_id, $local_filepath, $guid)); |
|
1559 | - return $attach_id; |
|
1560 | - } |
|
1561 | - $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1562 | - if (! $metadata_save_result) { |
|
1563 | - $migration_stage->add_error(sprintf(esc_html__( |
|
1564 | - "Could not update attachment metadata for attachment %d with data %s", |
|
1565 | - "event_espresso" |
|
1566 | - ), $attach_id, $this->_json_encode($attach_data))); |
|
1567 | - } |
|
1568 | - return $attach_id; |
|
1569 | - } |
|
1570 | - |
|
1571 | - |
|
1572 | - |
|
1573 | - /** |
|
1574 | - * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself), |
|
1575 | - * and returns its ID. |
|
1576 | - * |
|
1577 | - * @global type $wpdb |
|
1578 | - * @param string $guid |
|
1579 | - * @return int |
|
1580 | - */ |
|
1581 | - private function _get_image_attachment_id_by_GUID($guid) |
|
1582 | - { |
|
1583 | - global $wpdb; |
|
1584 | - $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1585 | - return $attachment_id; |
|
1586 | - } |
|
1587 | - |
|
1588 | - |
|
1589 | - |
|
1590 | - /** |
|
1591 | - * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string |
|
1592 | - * (and optionally a timezone; if none is given, the wp default is used) |
|
1593 | - * |
|
1594 | - * @param EE_Data_Migration_Script_base $stage |
|
1595 | - * @param array $row_of_data , the row from the DB (as an array) we're trying to find the |
|
1596 | - * UTC time for |
|
1597 | - * @param string $DATETIME_string |
|
1598 | - * @param string $timezone |
|
1599 | - * @return string |
|
1600 | - */ |
|
1601 | - public function convert_date_string_to_utc( |
|
1602 | - EE_Data_Migration_Script_Stage $stage, |
|
1603 | - $row_of_data, |
|
1604 | - $DATETIME_string, |
|
1605 | - $timezone = null |
|
1606 | - ) { |
|
1607 | - $original_tz = $timezone; |
|
1608 | - if (! $timezone) { |
|
1609 | - $timezone = $this->_get_wp_timezone(); |
|
1610 | - } |
|
1611 | - if (! $timezone) { |
|
1612 | - $stage->add_error(sprintf( |
|
1613 | - esc_html__("Could not find timezone given %s for %s", "event_espresso"), |
|
1614 | - $original_tz, |
|
1615 | - $row_of_data |
|
1616 | - )); |
|
1617 | - $timezone = 'UTC'; |
|
1618 | - } |
|
1619 | - try { |
|
1620 | - $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1621 | - EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC')); |
|
1622 | - } catch (Exception $e) { |
|
1623 | - $stage->add_error(sprintf(esc_html__( |
|
1624 | - "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", |
|
1625 | - "event_espresso" |
|
1626 | - ), $DATETIME_string, $timezone)); |
|
1627 | - $date_obj = new DateTime(); |
|
1628 | - } |
|
1629 | - return $date_obj->format('Y-m-d H:i:s'); |
|
1630 | - } |
|
1631 | - |
|
1632 | - |
|
1633 | - |
|
1634 | - /** |
|
1635 | - * Gets the default timezone string from wordpress (even if they set a gmt offset) |
|
1636 | - * |
|
1637 | - * @return string |
|
1638 | - */ |
|
1639 | - private function _get_wp_timezone() |
|
1640 | - { |
|
1641 | - $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1642 | - // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
|
1643 | - if (empty($timezone)) { |
|
1644 | - // let's get a the WordPress UTC offset |
|
1645 | - $offset = get_option('gmt_offset'); |
|
1646 | - $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1647 | - } |
|
1648 | - return $timezone; |
|
1649 | - } |
|
1650 | - |
|
1651 | - |
|
1652 | - |
|
1653 | - /** |
|
1654 | - * Gets the wordpress timezone string from a UTC offset |
|
1655 | - * |
|
1656 | - * @param int $offset |
|
1657 | - * @return boolean |
|
1658 | - */ |
|
1659 | - private function timezone_convert_to_string_from_offset($offset) |
|
1660 | - { |
|
1661 | - // shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did not work as expected - its not reliable |
|
1662 | - $offset *= 3600; // convert hour offset to seconds |
|
1663 | - $abbrarray = timezone_abbreviations_list(); |
|
1664 | - foreach ($abbrarray as $abbr) { |
|
1665 | - foreach ($abbr as $city) { |
|
1666 | - if ($city['offset'] == $offset) { |
|
1667 | - return $city['timezone_id']; |
|
1668 | - } |
|
1669 | - } |
|
1670 | - } |
|
1671 | - return false; |
|
1672 | - } |
|
1673 | - |
|
1674 | - |
|
1675 | - |
|
1676 | - public function migration_page_hooks() |
|
1677 | - { |
|
1678 | - add_filter( |
|
1679 | - 'FHEE__ee_migration_page__header', |
|
1680 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1681 | - 10, |
|
1682 | - 3 |
|
1683 | - ); |
|
1684 | - add_filter( |
|
1685 | - 'FHEE__ee_migration_page__p_after_header', |
|
1686 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1687 | - 10, |
|
1688 | - 2 |
|
1689 | - ); |
|
1690 | - add_filter( |
|
1691 | - 'FHEE__ee_migration_page__option_1_main', |
|
1692 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1693 | - 10, |
|
1694 | - 3 |
|
1695 | - ); |
|
1696 | - add_filter( |
|
1697 | - 'FHEE__ee_migration_page__option_1_button_text', |
|
1698 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1699 | - 10, |
|
1700 | - 3 |
|
1701 | - ); |
|
1702 | - add_action( |
|
1703 | - 'AHEE__ee_migration_page__option_1_extra_details', |
|
1704 | - array($this, '_migration_page_hook_option_1_extra_details'), |
|
1705 | - 10, |
|
1706 | - 3 |
|
1707 | - ); |
|
1708 | - add_filter( |
|
1709 | - 'FHEE__ee_migration_page__option_2_main', |
|
1710 | - array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1711 | - 10, |
|
1712 | - 4 |
|
1713 | - ); |
|
1714 | - add_filter( |
|
1715 | - 'FHEE__ee_migration_page__option_2_button_text', |
|
1716 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1717 | - 10, |
|
1718 | - 2 |
|
1719 | - ); |
|
1720 | - add_filter( |
|
1721 | - 'FHEE__ee_migration_page__option_2_details', |
|
1722 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1723 | - 10, |
|
1724 | - 2 |
|
1725 | - ); |
|
1726 | - add_action( |
|
1727 | - 'AHEE__ee_migration_page__after_migration_options_table', |
|
1728 | - array($this, '_migration_page_hook_after_migration_options_table') |
|
1729 | - ); |
|
1730 | - add_filter( |
|
1731 | - 'FHEE__ee_migration_page__done_migration_header', |
|
1732 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1733 | - 10, |
|
1734 | - 2 |
|
1735 | - ); |
|
1736 | - add_filter( |
|
1737 | - 'FHEE__ee_migration_page__p_after_done_migration_header', |
|
1738 | - array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1739 | - 10, |
|
1740 | - 2 |
|
1741 | - ); |
|
1742 | - add_filter( |
|
1743 | - 'FHEE__ee_migration_page__migration_options_template', |
|
1744 | - array($this,'use_migration_options_from_ee3_template') |
|
1745 | - ); |
|
1746 | - } |
|
1747 | - |
|
1748 | - |
|
1749 | - |
|
1750 | - public function _migrate_page_hook_simplify_version_strings( |
|
1751 | - $old_content, |
|
1752 | - $current_db_state, |
|
1753 | - $next_db_state, |
|
1754 | - $ultimate_db_state = null |
|
1755 | - ) { |
|
1756 | - return str_replace( |
|
1757 | - array($current_db_state, $next_db_state, $ultimate_db_state), |
|
1758 | - array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')), |
|
1759 | - $old_content |
|
1760 | - ); |
|
1761 | - } |
|
1762 | - |
|
1763 | - |
|
1764 | - |
|
1765 | - public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) |
|
1766 | - { |
|
1767 | - return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content); |
|
1768 | - } |
|
1769 | - |
|
1770 | - |
|
1771 | - |
|
1772 | - public function _migration_page_hook_option_1_extra_details() |
|
1773 | - { |
|
1774 | - ?> |
|
1072 | + if (! $state) { |
|
1073 | + // insert a new one then |
|
1074 | + $cols_n_values = array( |
|
1075 | + 'CNT_ISO' => $country_iso, |
|
1076 | + 'STA_abbrev' => substr($state_name, 0, 6), |
|
1077 | + 'STA_name' => $state_name, |
|
1078 | + 'STA_active' => true, |
|
1079 | + ); |
|
1080 | + $data_types = array( |
|
1081 | + '%s',// CNT_ISO |
|
1082 | + '%s',// STA_abbrev |
|
1083 | + '%s',// STA_name |
|
1084 | + '%d',// STA_active |
|
1085 | + ); |
|
1086 | + $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1087 | + if (! $success) { |
|
1088 | + throw new EE_Error($this->_create_error_message_for_db_insertion( |
|
1089 | + 'N/A', |
|
1090 | + array('state' => $state_name, 'country_id' => $country_name), |
|
1091 | + $state_table, |
|
1092 | + $cols_n_values, |
|
1093 | + $data_types |
|
1094 | + )); |
|
1095 | + } |
|
1096 | + $state = $cols_n_values; |
|
1097 | + $state['STA_ID'] = $wpdb->insert_id; |
|
1098 | + } |
|
1099 | + return $state; |
|
1100 | + } |
|
1101 | + |
|
1102 | + |
|
1103 | + |
|
1104 | + /** |
|
1105 | + * Fixes times like "5:00 PM" into the expected 24-hour format "17:00". |
|
1106 | + * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing |
|
1107 | + * |
|
1108 | + * @param type $timeString |
|
1109 | + * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes |
|
1110 | + * with leading zeros) |
|
1111 | + */ |
|
1112 | + public function convertTimeFromAMPM($timeString) |
|
1113 | + { |
|
1114 | + $matches = array(); |
|
1115 | + preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1116 | + if (! $matches || count($matches) < 3) { |
|
1117 | + $hour = '00'; |
|
1118 | + $minutes = '00'; |
|
1119 | + } else { |
|
1120 | + $hour = intval($matches[1]); |
|
1121 | + $minutes = $matches[2]; |
|
1122 | + } |
|
1123 | + if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1124 | + $hour = intval($hour) + 12; |
|
1125 | + } |
|
1126 | + $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1127 | + $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1128 | + return "$hour:$minutes"; |
|
1129 | + } |
|
1130 | + |
|
1131 | + |
|
1132 | + |
|
1133 | + /** |
|
1134 | + * Gets the ISO3 fora country given its 3.1 country ID. |
|
1135 | + * |
|
1136 | + * @param int $country_id |
|
1137 | + * @return string the country's ISO3 code |
|
1138 | + */ |
|
1139 | + public function get_iso_from_3_1_country_id($country_id) |
|
1140 | + { |
|
1141 | + $old_countries = array( |
|
1142 | + array(64, 'United States', 'US', 'USA', 1), |
|
1143 | + array(15, 'Australia', 'AU', 'AUS', 1), |
|
1144 | + array(39, 'Canada', 'CA', 'CAN', 1), |
|
1145 | + array(171, 'United Kingdom', 'GB', 'GBR', 1), |
|
1146 | + array(70, 'France', 'FR', 'FRA', 2), |
|
1147 | + array(111, 'Italy', 'IT', 'ITA', 2), |
|
1148 | + array(63, 'Spain', 'ES', 'ESP', 2), |
|
1149 | + array(1, 'Afghanistan', 'AF', 'AFG', 1), |
|
1150 | + array(2, 'Albania', 'AL', 'ALB', 1), |
|
1151 | + array(3, 'Germany', 'DE', 'DEU', 2), |
|
1152 | + array(198, 'Switzerland', 'CH', 'CHE', 1), |
|
1153 | + array(87, 'Netherlands', 'NL', 'NLD', 2), |
|
1154 | + array(197, 'Sweden', 'SE', 'SWE', 1), |
|
1155 | + array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2), |
|
1156 | + array(4, 'Andorra', 'AD', 'AND', 2), |
|
1157 | + array(5, 'Angola', 'AO', 'AGO', 1), |
|
1158 | + array(6, 'Anguilla', 'AI', 'AIA', 1), |
|
1159 | + array(7, 'Antarctica', 'AQ', 'ATA', 1), |
|
1160 | + array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1), |
|
1161 | + array(10, 'Saudi Arabia', 'SA', 'SAU', 1), |
|
1162 | + array(11, 'Algeria', 'DZ', 'DZA', 1), |
|
1163 | + array(12, 'Argentina', 'AR', 'ARG', 1), |
|
1164 | + array(13, 'Armenia', 'AM', 'ARM', 1), |
|
1165 | + array(14, 'Aruba', 'AW', 'ABW', 1), |
|
1166 | + array(16, 'Austria', 'AT', 'AUT', 2), |
|
1167 | + array(17, 'Azerbaijan', 'AZ', 'AZE', 1), |
|
1168 | + array(18, 'Bahamas', 'BS', 'BHS', 1), |
|
1169 | + array(19, 'Bahrain', 'BH', 'BHR', 1), |
|
1170 | + array(20, 'Bangladesh', 'BD', 'BGD', 1), |
|
1171 | + array(21, 'Barbados', 'BB', 'BRB', 1), |
|
1172 | + array(22, 'Belgium ', 'BE', 'BEL', 2), |
|
1173 | + array(23, 'Belize', 'BZ', 'BLZ', 1), |
|
1174 | + array(24, 'Benin', 'BJ', 'BEN', 1), |
|
1175 | + array(25, 'Bermudas', 'BM', 'BMU', 1), |
|
1176 | + array(26, 'Belarus', 'BY', 'BLR', 1), |
|
1177 | + array(27, 'Bolivia', 'BO', 'BOL', 1), |
|
1178 | + array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1), |
|
1179 | + array(29, 'Botswana', 'BW', 'BWA', 1), |
|
1180 | + array(96, 'Bouvet Island', 'BV', 'BVT', 1), |
|
1181 | + array(30, 'Brazil', 'BR', 'BRA', 1), |
|
1182 | + array(31, 'Brunei', 'BN', 'BRN', 1), |
|
1183 | + array(32, 'Bulgaria', 'BG', 'BGR', 1), |
|
1184 | + array(33, 'Burkina Faso', 'BF', 'BFA', 1), |
|
1185 | + array(34, 'Burundi', 'BI', 'BDI', 1), |
|
1186 | + array(35, 'Bhutan', 'BT', 'BTN', 1), |
|
1187 | + array(36, 'Cape Verde', 'CV', 'CPV', 1), |
|
1188 | + array(37, 'Cambodia', 'KH', 'KHM', 1), |
|
1189 | + array(38, 'Cameroon', 'CM', 'CMR', 1), |
|
1190 | + array(98, 'Cayman Islands', 'KY', 'CYM', 1), |
|
1191 | + array(172, 'Central African Republic', 'CF', 'CAF', 1), |
|
1192 | + array(40, 'Chad', 'TD', 'TCD', 1), |
|
1193 | + array(41, 'Chile', 'CL', 'CHL', 1), |
|
1194 | + array(42, 'China', 'CN', 'CHN', 1), |
|
1195 | + array(105, 'Christmas Island', 'CX', 'CXR', 1), |
|
1196 | + array(43, 'Cyprus', 'CY', 'CYP', 2), |
|
1197 | + array(99, 'Cocos Island', 'CC', 'CCK', 1), |
|
1198 | + array(100, 'Cook Islands', 'CK', 'COK', 1), |
|
1199 | + array(44, 'Colombia', 'CO', 'COL', 1), |
|
1200 | + array(45, 'Comoros', 'KM', 'COM', 1), |
|
1201 | + array(46, 'Congo', 'CG', 'COG', 1), |
|
1202 | + array(47, 'North Korea', 'KP', 'PRK', 1), |
|
1203 | + array(50, 'Costa Rica', 'CR', 'CRI', 1), |
|
1204 | + array(51, 'Croatia', 'HR', 'HRV', 1), |
|
1205 | + array(52, 'Cuba', 'CU', 'CUB', 1), |
|
1206 | + array(173, 'Czech Republic', 'CZ', 'CZE', 1), |
|
1207 | + array(53, 'Denmark', 'DK', 'DNK', 1), |
|
1208 | + array(54, 'Djibouti', 'DJ', 'DJI', 1), |
|
1209 | + array(55, 'Dominica', 'DM', 'DMA', 1), |
|
1210 | + array(174, 'Dominican Republic', 'DO', 'DOM', 1), |
|
1211 | + array(56, 'Ecuador', 'EC', 'ECU', 1), |
|
1212 | + array(57, 'Egypt', 'EG', 'EGY', 1), |
|
1213 | + array(58, 'El Salvador', 'SV', 'SLV', 1), |
|
1214 | + array(60, 'Eritrea', 'ER', 'ERI', 1), |
|
1215 | + array(61, 'Slovakia', 'SK', 'SVK', 2), |
|
1216 | + array(62, 'Slovenia', 'SI', 'SVN', 2), |
|
1217 | + array(65, 'Estonia', 'EE', 'EST', 2), |
|
1218 | + array(66, 'Ethiopia', 'ET', 'ETH', 1), |
|
1219 | + array(102, 'Faroe islands', 'FO', 'FRO', 1), |
|
1220 | + array(103, 'Falkland Islands', 'FK', 'FLK', 1), |
|
1221 | + array(67, 'Fiji', 'FJ', 'FJI', 1), |
|
1222 | + array(69, 'Finland', 'FI', 'FIN', 2), |
|
1223 | + array(71, 'Gabon', 'GA', 'GAB', 1), |
|
1224 | + array(72, 'Gambia', 'GM', 'GMB', 1), |
|
1225 | + array(73, 'Georgia', 'GE', 'GEO', 1), |
|
1226 | + array(74, 'Ghana', 'GH', 'GHA', 1), |
|
1227 | + array(75, 'Gibraltar', 'GI', 'GIB', 1), |
|
1228 | + array(76, 'Greece', 'GR', 'GRC', 2), |
|
1229 | + array(77, 'Grenada', 'GD', 'GRD', 1), |
|
1230 | + array(78, 'Greenland', 'GL', 'GRL', 1), |
|
1231 | + array(79, 'Guadeloupe', 'GP', 'GLP', 1), |
|
1232 | + array(80, 'Guam', 'GU', 'GUM', 1), |
|
1233 | + array(81, 'Guatemala', 'GT', 'GTM', 1), |
|
1234 | + array(82, 'Guinea', 'GN', 'GIN', 1), |
|
1235 | + array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1), |
|
1236 | + array(84, 'Guinea-Bissau', 'GW', 'GNB', 1), |
|
1237 | + array(85, 'Guyana', 'GY', 'GUY', 1), |
|
1238 | + array(86, 'Haiti', 'HT', 'HTI', 1), |
|
1239 | + array(88, 'Honduras', 'HN', 'HND', 1), |
|
1240 | + array(89, 'Hong Kong', 'HK', 'HKG', 1), |
|
1241 | + array(90, 'Hungary', 'HU', 'HUN', 1), |
|
1242 | + array(91, 'India', 'IN', 'IND', 1), |
|
1243 | + array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1), |
|
1244 | + array(92, 'Indonesia', 'ID', 'IDN', 1), |
|
1245 | + array(93, 'Iraq', 'IQ', 'IRQ', 1), |
|
1246 | + array(94, 'Iran', 'IR', 'IRN', 1), |
|
1247 | + array(95, 'Ireland', 'IE', 'IRL', 2), |
|
1248 | + array(97, 'Iceland', 'IS', 'ISL', 1), |
|
1249 | + array(110, 'Israel', 'IL', 'ISR', 1), |
|
1250 | + array(49, 'Ivory Coast ', 'CI', 'CIV', 1), |
|
1251 | + array(112, 'Jamaica', 'JM', 'JAM', 1), |
|
1252 | + array(113, 'Japan', 'JP', 'JPN', 1), |
|
1253 | + array(114, 'Jordan', 'JO', 'JOR', 1), |
|
1254 | + array(115, 'Kazakhstan', 'KZ', 'KAZ', 1), |
|
1255 | + array(116, 'Kenya', 'KE', 'KEN', 1), |
|
1256 | + array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1), |
|
1257 | + array(118, 'Kiribati', 'KI', 'KIR', 1), |
|
1258 | + array(48, 'South Korea', 'KR', 'KOR', 1), |
|
1259 | + array(228, 'Kosovo', 'XK', 'XKV', 2), |
|
1260 | + // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code |
|
1261 | + array(119, 'Kuwait', 'KW', 'KWT', 1), |
|
1262 | + array(120, 'Laos', 'LA', 'LAO', 1), |
|
1263 | + array(121, 'Latvia', 'LV', 'LVA', 2), |
|
1264 | + array(122, 'Lesotho', 'LS', 'LSO', 1), |
|
1265 | + array(123, 'Lebanon', 'LB', 'LBN', 1), |
|
1266 | + array(124, 'Liberia', 'LR', 'LBR', 1), |
|
1267 | + array(125, 'Libya', 'LY', 'LBY', 1), |
|
1268 | + array(126, 'Liechtenstein', 'LI', 'LIE', 1), |
|
1269 | + array(127, 'Lithuania', 'LT', 'LTU', 2), |
|
1270 | + array(128, 'Luxemburg', 'LU', 'LUX', 2), |
|
1271 | + array(129, 'Macao', 'MO', 'MAC', 1), |
|
1272 | + array(130, 'Macedonia', 'MK', 'MKD', 1), |
|
1273 | + array(131, 'Madagascar', 'MG', 'MDG', 1), |
|
1274 | + array(132, 'Malaysia', 'MY', 'MYS', 1), |
|
1275 | + array(133, 'Malawi', 'MW', 'MWI', 1), |
|
1276 | + array(134, 'Maldivas', 'MV', 'MDV', 1), |
|
1277 | + array(135, 'Mali', 'ML', 'MLI', 1), |
|
1278 | + array(136, 'Malta', 'MT', 'MLT', 2), |
|
1279 | + array(101, 'Northern Marianas', 'MP', 'MNP', 1), |
|
1280 | + array(137, 'Morocco', 'MA', 'MAR', 1), |
|
1281 | + array(104, 'Marshall islands', 'MH', 'MHL', 1), |
|
1282 | + array(138, 'Martinique', 'MQ', 'MTQ', 1), |
|
1283 | + array(139, 'Mauritius', 'MU', 'MUS', 1), |
|
1284 | + array(140, 'Mauritania', 'MR', 'MRT', 1), |
|
1285 | + array(141, 'Mayote', 'YT', 'MYT', 2), |
|
1286 | + array(142, 'Mexico', 'MX', 'MEX', 1), |
|
1287 | + array(143, 'Micronesia', 'FM', 'FSM', 1), |
|
1288 | + array(144, 'Moldova', 'MD', 'MDA', 1), |
|
1289 | + array(145, 'Monaco', 'MC', 'MCO', 2), |
|
1290 | + array(146, 'Mongolia', 'MN', 'MNG', 1), |
|
1291 | + array(147, 'Montserrat', 'MS', 'MSR', 1), |
|
1292 | + array(227, 'Montenegro', 'ME', 'MNE', 2), |
|
1293 | + array(148, 'Mozambique', 'MZ', 'MOZ', 1), |
|
1294 | + array(149, 'Myanmar', 'MM', 'MMR', 1), |
|
1295 | + array(150, 'Namibia', 'NA', 'NAM', 1), |
|
1296 | + array(151, 'Nauru', 'NR', 'NRU', 1), |
|
1297 | + array(152, 'Nepal', 'NP', 'NPL', 1), |
|
1298 | + array(9, 'Netherlands Antilles', 'AN', 'ANT', 1), |
|
1299 | + array(153, 'Nicaragua', 'NI', 'NIC', 1), |
|
1300 | + array(154, 'Niger', 'NE', 'NER', 1), |
|
1301 | + array(155, 'Nigeria', 'NG', 'NGA', 1), |
|
1302 | + array(156, 'Niue', 'NU', 'NIU', 1), |
|
1303 | + array(157, 'Norway', 'NO', 'NOR', 1), |
|
1304 | + array(158, 'New Caledonia', 'NC', 'NCL', 1), |
|
1305 | + array(159, 'New Zealand', 'NZ', 'NZL', 1), |
|
1306 | + array(160, 'Oman', 'OM', 'OMN', 1), |
|
1307 | + array(161, 'Pakistan', 'PK', 'PAK', 1), |
|
1308 | + array(162, 'Palau', 'PW', 'PLW', 1), |
|
1309 | + array(163, 'Panama', 'PA', 'PAN', 1), |
|
1310 | + array(164, 'Papua New Guinea', 'PG', 'PNG', 1), |
|
1311 | + array(165, 'Paraguay', 'PY', 'PRY', 1), |
|
1312 | + array(166, 'Peru', 'PE', 'PER', 1), |
|
1313 | + array(68, 'Philippines', 'PH', 'PHL', 1), |
|
1314 | + array(167, 'Poland', 'PL', 'POL', 1), |
|
1315 | + array(168, 'Portugal', 'PT', 'PRT', 2), |
|
1316 | + array(169, 'Puerto Rico', 'PR', 'PRI', 1), |
|
1317 | + array(170, 'Qatar', 'QA', 'QAT', 1), |
|
1318 | + array(176, 'Rwanda', 'RW', 'RWA', 1), |
|
1319 | + array(177, 'Romania', 'RO', 'ROM', 2), |
|
1320 | + array(178, 'Russia', 'RU', 'RUS', 1), |
|
1321 | + array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2), |
|
1322 | + array(180, 'Samoa', 'WS', 'WSM', 1), |
|
1323 | + array(181, 'American Samoa', 'AS', 'ASM', 1), |
|
1324 | + array(183, 'San Marino', 'SM', 'SMR', 2), |
|
1325 | + array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1), |
|
1326 | + array(185, 'Saint Helena', 'SH', 'SHN', 1), |
|
1327 | + array(186, 'Saint Lucia', 'LC', 'LCA', 1), |
|
1328 | + array(188, 'Senegal', 'SN', 'SEN', 1), |
|
1329 | + array(189, 'Seychelles', 'SC', 'SYC', 1), |
|
1330 | + array(190, 'Sierra Leona', 'SL', 'SLE', 1), |
|
1331 | + array(191, 'Singapore', 'SG', 'SGP', 1), |
|
1332 | + array(192, 'Syria', 'SY', 'SYR', 1), |
|
1333 | + array(193, 'Somalia', 'SO', 'SOM', 1), |
|
1334 | + array(194, 'Sri Lanka', 'LK', 'LKA', 1), |
|
1335 | + array(195, 'South Africa', 'ZA', 'ZAF', 1), |
|
1336 | + array(196, 'Sudan', 'SD', 'SDN', 1), |
|
1337 | + array(199, 'Suriname', 'SR', 'SUR', 1), |
|
1338 | + array(200, 'Swaziland', 'SZ', 'SWZ', 1), |
|
1339 | + array(201, 'Thailand', 'TH', 'THA', 1), |
|
1340 | + array(202, 'Taiwan', 'TW', 'TWN', 1), |
|
1341 | + array(203, 'Tanzania', 'TZ', 'TZA', 1), |
|
1342 | + array(204, 'Tajikistan', 'TJ', 'TJK', 1), |
|
1343 | + array(206, 'Timor-Leste', 'TL', 'TLS', 1), |
|
1344 | + array(207, 'Togo', 'TG', 'TGO', 1), |
|
1345 | + array(208, 'Tokelau', 'TK', 'TKL', 1), |
|
1346 | + array(209, 'Tonga', 'TO', 'TON', 1), |
|
1347 | + array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1), |
|
1348 | + array(211, 'Tunisia', 'TN', 'TUN', 1), |
|
1349 | + array(212, 'Turkmenistan', 'TM', 'TKM', 1), |
|
1350 | + array(213, 'Turkey', 'TR', 'TUR', 1), |
|
1351 | + array(214, 'Tuvalu', 'TV', 'TUV', 1), |
|
1352 | + array(215, 'Ukraine', 'UA', 'UKR', 1), |
|
1353 | + array(216, 'Uganda', 'UG', 'UGA', 1), |
|
1354 | + array(59, 'United Arab Emirates', 'AE', 'ARE', 1), |
|
1355 | + array(217, 'Uruguay', 'UY', 'URY', 1), |
|
1356 | + array(218, 'Uzbekistan', 'UZ', 'UZB', 1), |
|
1357 | + array(219, 'Vanuatu', 'VU', 'VUT', 1), |
|
1358 | + array(220, 'Vatican City', 'VA', 'VAT', 2), |
|
1359 | + array(221, 'Venezuela', 'VE', 'VEN', 1), |
|
1360 | + array(222, 'Vietnam', 'VN', 'VNM', 1), |
|
1361 | + array(108, 'Virgin Islands', 'VI', 'VIR', 1), |
|
1362 | + array(223, 'Yemen', 'YE', 'YEM', 1), |
|
1363 | + array(225, 'Zambia', 'ZM', 'ZMB', 1), |
|
1364 | + array(226, 'Zimbabwe', 'ZW', 'ZWE', 1), |
|
1365 | + ); |
|
1366 | + $country_iso = 'US'; |
|
1367 | + foreach ($old_countries as $country_array) { |
|
1368 | + // note: index 0 is the 3.1 country ID |
|
1369 | + if ($country_array[0] == $country_id) { |
|
1370 | + // note: index 2 is the ISO |
|
1371 | + $country_iso = $country_array[2]; |
|
1372 | + break; |
|
1373 | + } |
|
1374 | + } |
|
1375 | + return $country_iso; |
|
1376 | + } |
|
1377 | + |
|
1378 | + |
|
1379 | + |
|
1380 | + /** |
|
1381 | + * Gets the ISO3 for the |
|
1382 | + * |
|
1383 | + * @return string |
|
1384 | + */ |
|
1385 | + public function get_default_country_iso() |
|
1386 | + { |
|
1387 | + $old_org_options = get_option('events_organization_settings'); |
|
1388 | + $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
|
1389 | + return $iso; |
|
1390 | + } |
|
1391 | + |
|
1392 | + |
|
1393 | + |
|
1394 | + /** |
|
1395 | + * Converst a 3.1 payment status to its equivalent 4.1 regisration status |
|
1396 | + * |
|
1397 | + * @param string $payment_status possible value for 3.1's evens_attendee.payment_status |
|
1398 | + * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's |
|
1399 | + * default payment status, the event's default payment status, or |
|
1400 | + * the attendee's payment status) required pre-approval. |
|
1401 | + * @return string STS_ID for use in 4.1 |
|
1402 | + */ |
|
1403 | + public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) |
|
1404 | + { |
|
1405 | + // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
|
1406 | + if ($this_thing_required_pre_approval) { |
|
1407 | + return 'RNA'; |
|
1408 | + } else { |
|
1409 | + $mapping = $default_reg_stati_conversions = array( |
|
1410 | + 'Completed' => 'RAP', |
|
1411 | + '' => 'RPP', |
|
1412 | + 'Incomplete' => 'RPP', |
|
1413 | + 'Pending' => 'RAP', |
|
1414 | + // stati that only occurred on 3.1 attendees: |
|
1415 | + 'Payment Declined' => 'RPP', |
|
1416 | + 'Not Completed' => 'RPP', |
|
1417 | + 'Cancelled' => 'RPP', |
|
1418 | + 'Declined' => 'RPP', |
|
1419 | + ); |
|
1420 | + } |
|
1421 | + return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA'; |
|
1422 | + } |
|
1423 | + |
|
1424 | + |
|
1425 | + |
|
1426 | + /** |
|
1427 | + * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event |
|
1428 | + * and sets it as the featured image on the CPT event |
|
1429 | + * |
|
1430 | + * @param type $old_event |
|
1431 | + * @param type $new_cpt_id |
|
1432 | + * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
|
1433 | + * @return boolean whether or not we had to do the big job of creating an image attachment |
|
1434 | + */ |
|
1435 | + public function convert_image_url_to_attachment_and_attach_to_post( |
|
1436 | + $guid, |
|
1437 | + $new_cpt_id, |
|
1438 | + EE_Data_Migration_Script_Stage $migration_stage |
|
1439 | + ) { |
|
1440 | + $created_attachment_post = false; |
|
1441 | + $guid = $this->_get_original_guid($guid); |
|
1442 | + if ($guid) { |
|
1443 | + // check for an existing attachment post with this guid |
|
1444 | + $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
|
1445 | + if (! $attachment_post_id) { |
|
1446 | + // post thumbnail with that GUID doesn't exist, we should create one |
|
1447 | + $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
|
1448 | + $created_attachment_post = true; |
|
1449 | + } |
|
1450 | + // double-check we actually have an attachment post |
|
1451 | + if ($attachment_post_id) { |
|
1452 | + update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1453 | + } else { |
|
1454 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1455 | + "Could not update event image %s for CPT with ID %d, but attachments post ID is %d", |
|
1456 | + "event_espresso" |
|
1457 | + ), $guid, $new_cpt_id, $attachment_post_id)); |
|
1458 | + } |
|
1459 | + } |
|
1460 | + return $created_attachment_post; |
|
1461 | + } |
|
1462 | + |
|
1463 | + |
|
1464 | + |
|
1465 | + /** |
|
1466 | + * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead |
|
1467 | + * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype, |
|
1468 | + * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of |
|
1469 | + * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it |
|
1470 | + * exists |
|
1471 | + * |
|
1472 | + * @param string $guid_in_old_event |
|
1473 | + * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
|
1474 | + */ |
|
1475 | + private function _get_original_guid($guid_in_old_event) |
|
1476 | + { |
|
1477 | + $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1478 | + // do a head request to verify the file exists |
|
1479 | + $head_response = wp_remote_head($original_guid); |
|
1480 | + if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1481 | + return $original_guid; |
|
1482 | + } else { |
|
1483 | + return $guid_in_old_event; |
|
1484 | + } |
|
1485 | + } |
|
1486 | + |
|
1487 | + |
|
1488 | + |
|
1489 | + /** |
|
1490 | + * Creates an image attachment post for the GUID. If the GUID points to a remote image, |
|
1491 | + * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of |
|
1492 | + * thumbnails) |
|
1493 | + * |
|
1494 | + * @param type $guid |
|
1495 | + * @param EE_Data_Migration_Script_Stage $migration_stage |
|
1496 | + * @return int |
|
1497 | + */ |
|
1498 | + private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) |
|
1499 | + { |
|
1500 | + if (! $guid) { |
|
1501 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1502 | + "Cannot create image attachment for a blank GUID!", |
|
1503 | + "event_espresso" |
|
1504 | + ))); |
|
1505 | + return 0; |
|
1506 | + } |
|
1507 | + $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1508 | + $wp_upload_dir = wp_upload_dir(); |
|
1509 | + // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
|
1510 | + if (strpos($guid, $wp_upload_dir['url']) === false) { |
|
1511 | + // image is located remotely. download it and place it in the uploads directory |
|
1512 | + if (! is_readable($guid)) { |
|
1513 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1514 | + "Could not create image attachment from non-existent file: %s", |
|
1515 | + "event_espresso" |
|
1516 | + ), $guid)); |
|
1517 | + return 0; |
|
1518 | + } |
|
1519 | + $contents = file_get_contents($guid); |
|
1520 | + if ($contents === false) { |
|
1521 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1522 | + "Could not read image at %s, and therefore couldnt create an attachment post for it.", |
|
1523 | + "event_espresso" |
|
1524 | + ), $guid)); |
|
1525 | + return false; |
|
1526 | + } |
|
1527 | + $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid); |
|
1528 | + $savefile = fopen($local_filepath, 'w'); |
|
1529 | + fwrite($savefile, $contents); |
|
1530 | + fclose($savefile); |
|
1531 | + $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1532 | + } else { |
|
1533 | + $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1534 | + } |
|
1535 | + $attachment = array( |
|
1536 | + 'guid' => $guid, |
|
1537 | + 'post_mime_type' => $wp_filetype['type'], |
|
1538 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($guid)), |
|
1539 | + 'post_content' => '', |
|
1540 | + 'post_status' => 'inherit', |
|
1541 | + ); |
|
1542 | + $attach_id = wp_insert_attachment($attachment, $guid); |
|
1543 | + if (! $attach_id) { |
|
1544 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1545 | + "Could not create image attachment post from image '%s'. Attachment data was %s.", |
|
1546 | + "event_espresso" |
|
1547 | + ), $guid, $this->_json_encode($attachment))); |
|
1548 | + return $attach_id; |
|
1549 | + } |
|
1550 | + // you must first include the image.php file |
|
1551 | + // for the function wp_generate_attachment_metadata() to work |
|
1552 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1553 | + $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1554 | + if (! $attach_data) { |
|
1555 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1556 | + "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", |
|
1557 | + "event_espresso" |
|
1558 | + ), $attach_id, $local_filepath, $guid)); |
|
1559 | + return $attach_id; |
|
1560 | + } |
|
1561 | + $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1562 | + if (! $metadata_save_result) { |
|
1563 | + $migration_stage->add_error(sprintf(esc_html__( |
|
1564 | + "Could not update attachment metadata for attachment %d with data %s", |
|
1565 | + "event_espresso" |
|
1566 | + ), $attach_id, $this->_json_encode($attach_data))); |
|
1567 | + } |
|
1568 | + return $attach_id; |
|
1569 | + } |
|
1570 | + |
|
1571 | + |
|
1572 | + |
|
1573 | + /** |
|
1574 | + * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself), |
|
1575 | + * and returns its ID. |
|
1576 | + * |
|
1577 | + * @global type $wpdb |
|
1578 | + * @param string $guid |
|
1579 | + * @return int |
|
1580 | + */ |
|
1581 | + private function _get_image_attachment_id_by_GUID($guid) |
|
1582 | + { |
|
1583 | + global $wpdb; |
|
1584 | + $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1585 | + return $attachment_id; |
|
1586 | + } |
|
1587 | + |
|
1588 | + |
|
1589 | + |
|
1590 | + /** |
|
1591 | + * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string |
|
1592 | + * (and optionally a timezone; if none is given, the wp default is used) |
|
1593 | + * |
|
1594 | + * @param EE_Data_Migration_Script_base $stage |
|
1595 | + * @param array $row_of_data , the row from the DB (as an array) we're trying to find the |
|
1596 | + * UTC time for |
|
1597 | + * @param string $DATETIME_string |
|
1598 | + * @param string $timezone |
|
1599 | + * @return string |
|
1600 | + */ |
|
1601 | + public function convert_date_string_to_utc( |
|
1602 | + EE_Data_Migration_Script_Stage $stage, |
|
1603 | + $row_of_data, |
|
1604 | + $DATETIME_string, |
|
1605 | + $timezone = null |
|
1606 | + ) { |
|
1607 | + $original_tz = $timezone; |
|
1608 | + if (! $timezone) { |
|
1609 | + $timezone = $this->_get_wp_timezone(); |
|
1610 | + } |
|
1611 | + if (! $timezone) { |
|
1612 | + $stage->add_error(sprintf( |
|
1613 | + esc_html__("Could not find timezone given %s for %s", "event_espresso"), |
|
1614 | + $original_tz, |
|
1615 | + $row_of_data |
|
1616 | + )); |
|
1617 | + $timezone = 'UTC'; |
|
1618 | + } |
|
1619 | + try { |
|
1620 | + $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1621 | + EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC')); |
|
1622 | + } catch (Exception $e) { |
|
1623 | + $stage->add_error(sprintf(esc_html__( |
|
1624 | + "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", |
|
1625 | + "event_espresso" |
|
1626 | + ), $DATETIME_string, $timezone)); |
|
1627 | + $date_obj = new DateTime(); |
|
1628 | + } |
|
1629 | + return $date_obj->format('Y-m-d H:i:s'); |
|
1630 | + } |
|
1631 | + |
|
1632 | + |
|
1633 | + |
|
1634 | + /** |
|
1635 | + * Gets the default timezone string from wordpress (even if they set a gmt offset) |
|
1636 | + * |
|
1637 | + * @return string |
|
1638 | + */ |
|
1639 | + private function _get_wp_timezone() |
|
1640 | + { |
|
1641 | + $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1642 | + // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
|
1643 | + if (empty($timezone)) { |
|
1644 | + // let's get a the WordPress UTC offset |
|
1645 | + $offset = get_option('gmt_offset'); |
|
1646 | + $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1647 | + } |
|
1648 | + return $timezone; |
|
1649 | + } |
|
1650 | + |
|
1651 | + |
|
1652 | + |
|
1653 | + /** |
|
1654 | + * Gets the wordpress timezone string from a UTC offset |
|
1655 | + * |
|
1656 | + * @param int $offset |
|
1657 | + * @return boolean |
|
1658 | + */ |
|
1659 | + private function timezone_convert_to_string_from_offset($offset) |
|
1660 | + { |
|
1661 | + // shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did not work as expected - its not reliable |
|
1662 | + $offset *= 3600; // convert hour offset to seconds |
|
1663 | + $abbrarray = timezone_abbreviations_list(); |
|
1664 | + foreach ($abbrarray as $abbr) { |
|
1665 | + foreach ($abbr as $city) { |
|
1666 | + if ($city['offset'] == $offset) { |
|
1667 | + return $city['timezone_id']; |
|
1668 | + } |
|
1669 | + } |
|
1670 | + } |
|
1671 | + return false; |
|
1672 | + } |
|
1673 | + |
|
1674 | + |
|
1675 | + |
|
1676 | + public function migration_page_hooks() |
|
1677 | + { |
|
1678 | + add_filter( |
|
1679 | + 'FHEE__ee_migration_page__header', |
|
1680 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1681 | + 10, |
|
1682 | + 3 |
|
1683 | + ); |
|
1684 | + add_filter( |
|
1685 | + 'FHEE__ee_migration_page__p_after_header', |
|
1686 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1687 | + 10, |
|
1688 | + 2 |
|
1689 | + ); |
|
1690 | + add_filter( |
|
1691 | + 'FHEE__ee_migration_page__option_1_main', |
|
1692 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1693 | + 10, |
|
1694 | + 3 |
|
1695 | + ); |
|
1696 | + add_filter( |
|
1697 | + 'FHEE__ee_migration_page__option_1_button_text', |
|
1698 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1699 | + 10, |
|
1700 | + 3 |
|
1701 | + ); |
|
1702 | + add_action( |
|
1703 | + 'AHEE__ee_migration_page__option_1_extra_details', |
|
1704 | + array($this, '_migration_page_hook_option_1_extra_details'), |
|
1705 | + 10, |
|
1706 | + 3 |
|
1707 | + ); |
|
1708 | + add_filter( |
|
1709 | + 'FHEE__ee_migration_page__option_2_main', |
|
1710 | + array($this, '_migrate_page_hook_simplify_version_strings'), |
|
1711 | + 10, |
|
1712 | + 4 |
|
1713 | + ); |
|
1714 | + add_filter( |
|
1715 | + 'FHEE__ee_migration_page__option_2_button_text', |
|
1716 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1717 | + 10, |
|
1718 | + 2 |
|
1719 | + ); |
|
1720 | + add_filter( |
|
1721 | + 'FHEE__ee_migration_page__option_2_details', |
|
1722 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1723 | + 10, |
|
1724 | + 2 |
|
1725 | + ); |
|
1726 | + add_action( |
|
1727 | + 'AHEE__ee_migration_page__after_migration_options_table', |
|
1728 | + array($this, '_migration_page_hook_after_migration_options_table') |
|
1729 | + ); |
|
1730 | + add_filter( |
|
1731 | + 'FHEE__ee_migration_page__done_migration_header', |
|
1732 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1733 | + 10, |
|
1734 | + 2 |
|
1735 | + ); |
|
1736 | + add_filter( |
|
1737 | + 'FHEE__ee_migration_page__p_after_done_migration_header', |
|
1738 | + array($this, '_migration_page_hook_simplify_next_db_state'), |
|
1739 | + 10, |
|
1740 | + 2 |
|
1741 | + ); |
|
1742 | + add_filter( |
|
1743 | + 'FHEE__ee_migration_page__migration_options_template', |
|
1744 | + array($this,'use_migration_options_from_ee3_template') |
|
1745 | + ); |
|
1746 | + } |
|
1747 | + |
|
1748 | + |
|
1749 | + |
|
1750 | + public function _migrate_page_hook_simplify_version_strings( |
|
1751 | + $old_content, |
|
1752 | + $current_db_state, |
|
1753 | + $next_db_state, |
|
1754 | + $ultimate_db_state = null |
|
1755 | + ) { |
|
1756 | + return str_replace( |
|
1757 | + array($current_db_state, $next_db_state, $ultimate_db_state), |
|
1758 | + array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')), |
|
1759 | + $old_content |
|
1760 | + ); |
|
1761 | + } |
|
1762 | + |
|
1763 | + |
|
1764 | + |
|
1765 | + public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) |
|
1766 | + { |
|
1767 | + return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content); |
|
1768 | + } |
|
1769 | + |
|
1770 | + |
|
1771 | + |
|
1772 | + public function _migration_page_hook_option_1_extra_details() |
|
1773 | + { |
|
1774 | + ?> |
|
1775 | 1775 | <p><?php printf(esc_html__( |
1776 | - "Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", |
|
1777 | - "event_espresso" |
|
1778 | - )); ?></p><?php |
|
1779 | - } |
|
1776 | + "Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", |
|
1777 | + "event_espresso" |
|
1778 | + )); ?></p><?php |
|
1779 | + } |
|
1780 | 1780 | |
1781 | 1781 | |
1782 | 1782 | |
1783 | - public function _migration_page_hook_after_migration_options_table() |
|
1784 | - { |
|
1785 | - ?><p class="ee-attention"> |
|
1783 | + public function _migration_page_hook_after_migration_options_table() |
|
1784 | + { |
|
1785 | + ?><p class="ee-attention"> |
|
1786 | 1786 | <strong><span class="reminder-spn"> |
1787 | 1787 | <?php _e( |
1788 | - "Important note to those using Event Espresso 3 addons: ", |
|
1789 | - "event_espresso" |
|
1790 | - ); ?></span></strong> |
|
1788 | + "Important note to those using Event Espresso 3 addons: ", |
|
1789 | + "event_espresso" |
|
1790 | + ); ?></span></strong> |
|
1791 | 1791 | <br/> |
1792 | 1792 | <?php _e( |
1793 | - "Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", |
|
1794 | - "event_espresso" |
|
1795 | - ); ?> |
|
1793 | + "Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", |
|
1794 | + "event_espresso" |
|
1795 | + ); ?> |
|
1796 | 1796 | </p><?php |
1797 | - } |
|
1797 | + } |
|
1798 | 1798 | |
1799 | 1799 | |
1800 | 1800 | |
1801 | - /** |
|
1802 | - * When showing the migration options, show more options and info than normal (ie, give folks the option |
|
1803 | - * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because |
|
1804 | - * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea). |
|
1805 | - * @param $template_filepath |
|
1806 | - * @return string |
|
1807 | - */ |
|
1808 | - public function use_migration_options_from_ee3_template($template_filepath) |
|
1809 | - { |
|
1810 | - return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php'; |
|
1811 | - } |
|
1801 | + /** |
|
1802 | + * When showing the migration options, show more options and info than normal (ie, give folks the option |
|
1803 | + * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because |
|
1804 | + * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea). |
|
1805 | + * @param $template_filepath |
|
1806 | + * @return string |
|
1807 | + */ |
|
1808 | + public function use_migration_options_from_ee3_template($template_filepath) |
|
1809 | + { |
|
1810 | + return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php'; |
|
1811 | + } |
|
1812 | 1812 | } |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | // unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | // instead of construction, because it only gets constructed on first page load |
11 | 11 | // (all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*'); |
|
12 | +$stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*'); |
|
13 | 13 | $class_to_filepath = array(); |
14 | -if (! empty($stages)) { |
|
14 | +if ( ! empty($stages)) { |
|
15 | 15 | foreach ($stages as $filepath) { |
16 | 16 | $matches = array(); |
17 | 17 | preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
18 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
18 | + $class_to_filepath[$matches[1]] = $filepath; |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | // give addons a chance to autoload their stages too |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | private function _checkin_table_exists() |
88 | 88 | { |
89 | 89 | global $wpdb; |
90 | - $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'"); |
|
90 | + $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'"); |
|
91 | 91 | if ($results) { |
92 | 92 | return true; |
93 | 93 | } else { |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) { |
104 | 104 | // echo "$version_string can be migrated fro"; |
105 | 105 | return true; |
106 | - } elseif (! $version_string) { |
|
106 | + } elseif ( ! $version_string) { |
|
107 | 107 | // echo "no version string provided: $version_string"; |
108 | 108 | // no version string provided... this must be pre 4.1 |
109 | 109 | // because since 4.1 we're |
110 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
110 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
111 | 111 | } else { |
112 | 112 | // echo "$version_string doesnt apply"; |
113 | 113 | return false; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function schema_changes_before_migration() |
120 | 120 | { |
121 | 121 | // relies on 4.1's EEH_Activation::create_table |
122 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
122 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
123 | 123 | $table_name = 'esp_answer'; |
124 | 124 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
125 | 125 | REG_ID int(10) unsigned NOT NULL, |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | public function insert_default_states() |
504 | 504 | { |
505 | 505 | global $wpdb; |
506 | - $state_table = $wpdb->prefix . "esp_state"; |
|
506 | + $state_table = $wpdb->prefix."esp_state"; |
|
507 | 507 | if ($this->_get_table_analysis()->tableExists($state_table)) { |
508 | - $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
508 | + $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table; |
|
509 | 509 | $states = $wpdb->get_var($SQL); |
510 | - if (! $states) { |
|
511 | - $SQL = "INSERT INTO " . $state_table . " |
|
510 | + if ( ! $states) { |
|
511 | + $SQL = "INSERT INTO ".$state_table." |
|
512 | 512 | (STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES |
513 | 513 | (1, 'US', 'AK', 'Alaska', 1), |
514 | 514 | (2, 'US', 'AL', 'Alabama', 1), |
@@ -596,12 +596,12 @@ discard block |
||
596 | 596 | public function insert_default_countries() |
597 | 597 | { |
598 | 598 | global $wpdb; |
599 | - $country_table = $wpdb->prefix . "esp_country"; |
|
599 | + $country_table = $wpdb->prefix."esp_country"; |
|
600 | 600 | if ($this->_get_table_analysis()->tableExists($country_table)) { |
601 | - $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
601 | + $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table; |
|
602 | 602 | $countries = $wpdb->get_var($SQL); |
603 | - if (! $countries) { |
|
604 | - $SQL = "INSERT INTO " . $country_table . " |
|
603 | + if ( ! $countries) { |
|
604 | + $SQL = "INSERT INTO ".$country_table." |
|
605 | 605 | (CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES |
606 | 606 | ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
607 | 607 | ('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0), |
@@ -846,17 +846,17 @@ discard block |
||
846 | 846 | public function insert_default_price_types() |
847 | 847 | { |
848 | 848 | global $wpdb; |
849 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
849 | + $price_type_table = $wpdb->prefix."esp_price_type"; |
|
850 | 850 | if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
851 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
851 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
852 | 852 | $price_types_exist = $wpdb->get_var($SQL); |
853 | - if (! $price_types_exist) { |
|
853 | + if ( ! $price_types_exist) { |
|
854 | 854 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
855 | - (1, '" . esc_html__('Base Price', 'event_espresso') . "', 1, 0, 0, 0), |
|
856 | - (2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2, 1, 20, 0), |
|
857 | - (3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2, 0, 30, 0), |
|
858 | - (4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, 0), |
|
859 | - (5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3, 0, 50, 0);"; |
|
855 | + (1, '".esc_html__('Base Price', 'event_espresso')."', 1, 0, 0, 0), |
|
856 | + (2, '" . esc_html__('Percent Discount', 'event_espresso')."', 2, 1, 20, 0), |
|
857 | + (3, '" . esc_html__('Fixed Discount', 'event_espresso')."', 2, 0, 30, 0), |
|
858 | + (4, '" . esc_html__('Percent Surcharge', 'event_espresso')."', 3, 1, 40, 0), |
|
859 | + (5, '" . esc_html__('Fixed Surcharge', 'event_espresso')."', 3, 0, 50, 0);"; |
|
860 | 860 | $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
861 | 861 | $wpdb->query($SQL); |
862 | 862 | } |
@@ -878,11 +878,11 @@ discard block |
||
878 | 878 | public function insert_default_prices() |
879 | 879 | { |
880 | 880 | global $wpdb; |
881 | - $price_table = $wpdb->prefix . "esp_price"; |
|
881 | + $price_table = $wpdb->prefix."esp_price"; |
|
882 | 882 | if ($this->_get_table_analysis()->tableExists($price_table)) { |
883 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
883 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
884 | 884 | $prices_exist = $wpdb->get_var($SQL); |
885 | - if (! $prices_exist) { |
|
885 | + if ( ! $prices_exist) { |
|
886 | 886 | $SQL = "INSERT INTO $price_table |
887 | 887 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES |
888 | 888 | (1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);"; |
@@ -904,11 +904,11 @@ discard block |
||
904 | 904 | public function insert_default_tickets() |
905 | 905 | { |
906 | 906 | global $wpdb; |
907 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
907 | + $ticket_table = $wpdb->prefix."esp_ticket"; |
|
908 | 908 | if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
909 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
909 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
910 | 910 | $tickets_exist = $wpdb->get_var($SQL); |
911 | - if (! $tickets_exist) { |
|
911 | + if ( ! $tickets_exist) { |
|
912 | 912 | $SQL = "INSERT INTO $ticket_table |
913 | 913 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
914 | 914 | ( 1, 0, '" |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | $wpdb->query($SQL); |
919 | 919 | } |
920 | 920 | } |
921 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
921 | + $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
|
922 | 922 | if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
923 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
923 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
924 | 924 | $ticket_prc_exist = $wpdb->get_var($SQL); |
925 | - if (! $ticket_prc_exist) { |
|
925 | + if ( ! $ticket_prc_exist) { |
|
926 | 926 | $SQL = "INSERT INTO $ticket_price_table |
927 | 927 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
928 | 928 | ( 1, 1, 1 ) |
@@ -946,11 +946,11 @@ discard block |
||
946 | 946 | */ |
947 | 947 | public function get_or_create_country($country_name) |
948 | 948 | { |
949 | - if (! $country_name) { |
|
949 | + if ( ! $country_name) { |
|
950 | 950 | throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso")); |
951 | 951 | } |
952 | 952 | global $wpdb; |
953 | - $country_table = $wpdb->prefix . "esp_country"; |
|
953 | + $country_table = $wpdb->prefix."esp_country"; |
|
954 | 954 | if (is_int($country_name)) { |
955 | 955 | $country_name = $this->get_iso_from_3_1_country_id($country_name); |
956 | 956 | } |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | CNT_ISO LIKE %s OR |
959 | 959 | CNT_ISO3 LIKE %s OR |
960 | 960 | CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A); |
961 | - if (! $country) { |
|
961 | + if ( ! $country) { |
|
962 | 962 | // insert a new one then |
963 | 963 | $cols_n_values = array( |
964 | 964 | 'CNT_ISO' => $this->_find_available_country_iso(2), |
@@ -978,28 +978,28 @@ discard block |
||
978 | 978 | 'CNT_active' => true, |
979 | 979 | ); |
980 | 980 | $data_types = array( |
981 | - '%s',// CNT_ISO |
|
982 | - '%s',// CNT_ISO3 |
|
983 | - '%d',// RGN_ID |
|
984 | - '%s',// CNT_name |
|
985 | - '%s',// CNT_cur_code |
|
986 | - '%s',// CNT_cur_single |
|
987 | - '%s',// CNT_cur_plural |
|
988 | - '%s',// CNT_cur_sign |
|
989 | - '%d',// CNT_cur_sign_b4 |
|
990 | - '%d',// CNT_cur_dec_plc |
|
991 | - '%s',// CNT_cur_dec_mrk |
|
992 | - '%s',// CNT_cur_thsnds |
|
993 | - '%s',// CNT_tel_code |
|
994 | - '%d',// CNT_is_EU |
|
995 | - '%d',// CNT_active |
|
981 | + '%s', // CNT_ISO |
|
982 | + '%s', // CNT_ISO3 |
|
983 | + '%d', // RGN_ID |
|
984 | + '%s', // CNT_name |
|
985 | + '%s', // CNT_cur_code |
|
986 | + '%s', // CNT_cur_single |
|
987 | + '%s', // CNT_cur_plural |
|
988 | + '%s', // CNT_cur_sign |
|
989 | + '%d', // CNT_cur_sign_b4 |
|
990 | + '%d', // CNT_cur_dec_plc |
|
991 | + '%s', // CNT_cur_dec_mrk |
|
992 | + '%s', // CNT_cur_thsnds |
|
993 | + '%s', // CNT_tel_code |
|
994 | + '%d', // CNT_is_EU |
|
995 | + '%d', // CNT_active |
|
996 | 996 | ); |
997 | 997 | $success = $wpdb->insert( |
998 | 998 | $country_table, |
999 | 999 | $cols_n_values, |
1000 | 1000 | $data_types |
1001 | 1001 | ); |
1002 | - if (! $success) { |
|
1002 | + if ( ! $success) { |
|
1003 | 1003 | throw new EE_Error($this->_create_error_message_for_db_insertion( |
1004 | 1004 | 'N/A', |
1005 | 1005 | array('country_id' => $country_name), |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | private function _find_available_country_iso($num_letters = 2) |
1025 | 1025 | { |
1026 | 1026 | global $wpdb; |
1027 | - $country_table = $wpdb->prefix . "esp_country"; |
|
1027 | + $country_table = $wpdb->prefix."esp_country"; |
|
1028 | 1028 | $attempts = 0; |
1029 | 1029 | do { |
1030 | 1030 | $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | // keep going until we find an available country code, or we arbitrarily |
1036 | 1036 | // decide we've tried this enough. Somehow they have way too many countries |
1037 | 1037 | // (probably because they're mis-using the EE3 country_id like a custom question) |
1038 | - } while (intval($country_with_that_iso) && $attempts < 200); |
|
1038 | + }while (intval($country_with_that_iso) && $attempts < 200); |
|
1039 | 1039 | return $current_iso; |
1040 | 1040 | } |
1041 | 1041 | |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | */ |
1052 | 1052 | public function get_or_create_state($state_name, $country_name = '') |
1053 | 1053 | { |
1054 | - if (! $state_name) { |
|
1054 | + if ( ! $state_name) { |
|
1055 | 1055 | throw new EE_Error(esc_html__( |
1056 | 1056 | "Could not get-or-create state because no state name was provided", |
1057 | 1057 | "event_espresso" |
@@ -1064,12 +1064,12 @@ discard block |
||
1064 | 1064 | $country_iso = $this->get_default_country_iso(); |
1065 | 1065 | } |
1066 | 1066 | global $wpdb; |
1067 | - $state_table = $wpdb->prefix . "esp_state"; |
|
1067 | + $state_table = $wpdb->prefix."esp_state"; |
|
1068 | 1068 | $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
1069 | 1069 | (STA_abbrev LIKE %s OR |
1070 | 1070 | STA_name LIKE %s) AND |
1071 | 1071 | CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A); |
1072 | - if (! $state) { |
|
1072 | + if ( ! $state) { |
|
1073 | 1073 | // insert a new one then |
1074 | 1074 | $cols_n_values = array( |
1075 | 1075 | 'CNT_ISO' => $country_iso, |
@@ -1078,13 +1078,13 @@ discard block |
||
1078 | 1078 | 'STA_active' => true, |
1079 | 1079 | ); |
1080 | 1080 | $data_types = array( |
1081 | - '%s',// CNT_ISO |
|
1082 | - '%s',// STA_abbrev |
|
1083 | - '%s',// STA_name |
|
1084 | - '%d',// STA_active |
|
1081 | + '%s', // CNT_ISO |
|
1082 | + '%s', // STA_abbrev |
|
1083 | + '%s', // STA_name |
|
1084 | + '%d', // STA_active |
|
1085 | 1085 | ); |
1086 | 1086 | $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
1087 | - if (! $success) { |
|
1087 | + if ( ! $success) { |
|
1088 | 1088 | throw new EE_Error($this->_create_error_message_for_db_insertion( |
1089 | 1089 | 'N/A', |
1090 | 1090 | array('state' => $state_name, 'country_id' => $country_name), |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | { |
1114 | 1114 | $matches = array(); |
1115 | 1115 | preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
1116 | - if (! $matches || count($matches) < 3) { |
|
1116 | + if ( ! $matches || count($matches) < 3) { |
|
1117 | 1117 | $hour = '00'; |
1118 | 1118 | $minutes = '00'; |
1119 | 1119 | } else { |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | 'Declined' => 'RPP', |
1419 | 1419 | ); |
1420 | 1420 | } |
1421 | - return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA'; |
|
1421 | + return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA'; |
|
1422 | 1422 | } |
1423 | 1423 | |
1424 | 1424 | |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | if ($guid) { |
1443 | 1443 | // check for an existing attachment post with this guid |
1444 | 1444 | $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
1445 | - if (! $attachment_post_id) { |
|
1445 | + if ( ! $attachment_post_id) { |
|
1446 | 1446 | // post thumbnail with that GUID doesn't exist, we should create one |
1447 | 1447 | $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
1448 | 1448 | $created_attachment_post = true; |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
1478 | 1478 | // do a head request to verify the file exists |
1479 | 1479 | $head_response = wp_remote_head($original_guid); |
1480 | - if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1480 | + if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1481 | 1481 | return $original_guid; |
1482 | 1482 | } else { |
1483 | 1483 | return $guid_in_old_event; |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | */ |
1498 | 1498 | private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) |
1499 | 1499 | { |
1500 | - if (! $guid) { |
|
1500 | + if ( ! $guid) { |
|
1501 | 1501 | $migration_stage->add_error(sprintf(esc_html__( |
1502 | 1502 | "Cannot create image attachment for a blank GUID!", |
1503 | 1503 | "event_espresso" |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
1510 | 1510 | if (strpos($guid, $wp_upload_dir['url']) === false) { |
1511 | 1511 | // image is located remotely. download it and place it in the uploads directory |
1512 | - if (! is_readable($guid)) { |
|
1512 | + if ( ! is_readable($guid)) { |
|
1513 | 1513 | $migration_stage->add_error(sprintf(esc_html__( |
1514 | 1514 | "Could not create image attachment from non-existent file: %s", |
1515 | 1515 | "event_espresso" |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | ), $guid)); |
1525 | 1525 | return false; |
1526 | 1526 | } |
1527 | - $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid); |
|
1527 | + $local_filepath = $wp_upload_dir['path'].'/'.basename($guid); |
|
1528 | 1528 | $savefile = fopen($local_filepath, 'w'); |
1529 | 1529 | fwrite($savefile, $contents); |
1530 | 1530 | fclose($savefile); |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | 'post_status' => 'inherit', |
1541 | 1541 | ); |
1542 | 1542 | $attach_id = wp_insert_attachment($attachment, $guid); |
1543 | - if (! $attach_id) { |
|
1543 | + if ( ! $attach_id) { |
|
1544 | 1544 | $migration_stage->add_error(sprintf(esc_html__( |
1545 | 1545 | "Could not create image attachment post from image '%s'. Attachment data was %s.", |
1546 | 1546 | "event_espresso" |
@@ -1549,9 +1549,9 @@ discard block |
||
1549 | 1549 | } |
1550 | 1550 | // you must first include the image.php file |
1551 | 1551 | // for the function wp_generate_attachment_metadata() to work |
1552 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1552 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1553 | 1553 | $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
1554 | - if (! $attach_data) { |
|
1554 | + if ( ! $attach_data) { |
|
1555 | 1555 | $migration_stage->add_error(sprintf(esc_html__( |
1556 | 1556 | "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", |
1557 | 1557 | "event_espresso" |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | return $attach_id; |
1560 | 1560 | } |
1561 | 1561 | $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
1562 | - if (! $metadata_save_result) { |
|
1562 | + if ( ! $metadata_save_result) { |
|
1563 | 1563 | $migration_stage->add_error(sprintf(esc_html__( |
1564 | 1564 | "Could not update attachment metadata for attachment %d with data %s", |
1565 | 1565 | "event_espresso" |
@@ -1605,10 +1605,10 @@ discard block |
||
1605 | 1605 | $timezone = null |
1606 | 1606 | ) { |
1607 | 1607 | $original_tz = $timezone; |
1608 | - if (! $timezone) { |
|
1608 | + if ( ! $timezone) { |
|
1609 | 1609 | $timezone = $this->_get_wp_timezone(); |
1610 | 1610 | } |
1611 | - if (! $timezone) { |
|
1611 | + if ( ! $timezone) { |
|
1612 | 1612 | $stage->add_error(sprintf( |
1613 | 1613 | esc_html__("Could not find timezone given %s for %s", "event_espresso"), |
1614 | 1614 | $original_tz, |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | ); |
1742 | 1742 | add_filter( |
1743 | 1743 | 'FHEE__ee_migration_page__migration_options_template', |
1744 | - array($this,'use_migration_options_from_ee3_template') |
|
1744 | + array($this, 'use_migration_options_from_ee3_template') |
|
1745 | 1745 | ); |
1746 | 1746 | } |
1747 | 1747 | |
@@ -1807,6 +1807,6 @@ discard block |
||
1807 | 1807 | */ |
1808 | 1808 | public function use_migration_options_from_ee3_template($template_filepath) |
1809 | 1809 | { |
1810 | - return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php'; |
|
1810 | + return EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee3.template.php'; |
|
1811 | 1811 | } |
1812 | 1812 | } |